From dc30536456dbbface927e6c76ca3bf3e4647afa5 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Sun, 4 Sep 2011 23:59:43 +0200 Subject: plugin-base: rewrite port supports check as fully asynchronous Before this change, supports check was either synchronous (e.g. in some UNSUPPORTED cases) or asynchronous (when IN_PROGRESS was returned). With this fix, the supports check requested to the plugin will always be completed asynchronously; either directly in an idle before launching any real probing operation, or once the probing operation is finished. Therefore, it is not expected to get a IN_PROGRESS reply in mm_plugin_supports_port_finish(), only UNSUPPORTED|SUPPORTED|DEFERRED. --- src/mm-plugin.h | 56 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 23 deletions(-) (limited to 'src/mm-plugin.h') diff --git a/src/mm-plugin.h b/src/mm-plugin.h index 07e3ee09..39598de8 100644 --- a/src/mm-plugin.h +++ b/src/mm-plugin.h @@ -18,6 +18,8 @@ #define MM_PLUGIN_H #include +#include + #include #define MM_PLUGIN_GENERIC_NAME "Generic" @@ -48,7 +50,8 @@ typedef void (*MMSupportsPortResultFunc) (MMPlugin *plugin, typedef enum { MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED = 0x0, MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS, - MM_PLUGIN_SUPPORTS_PORT_DEFER + MM_PLUGIN_SUPPORTS_PORT_DEFER, + MM_PLUGIN_SUPPORTS_PORT_SUPPORTED } MMPluginSupportsResult; struct _MMPlugin { @@ -63,22 +66,24 @@ struct _MMPlugin { gboolean (*get_sort_last) (const MMPlugin *self); /* Check whether a plugin supports a particular modem port, and what level - * of support the plugin has for the device. If the plugin can immediately - * determine whether a port is unsupported, it should return - * FALSE. Otherwise, if the plugin needs to perform additional operations - * (ie, probing) to determine the level of support or additional details - * about a port, it should queue that operation (but *not* block on the - * result) and return TRUE to indicate the operation is ongoing. When the - * operation is finished or the level of support is known, the plugin should - * call the provided callback and pass that callback the provided user_data. + * of support the plugin has for the device. + * The check is done always asynchronously. When the result of the check is + * ready, the passed callback will be called, and the result will be ready + * to get retrieved with supports_port_finish(). */ - MMPluginSupportsResult (*supports_port) (MMPlugin *self, - const char *subsys, - const char *name, - const char *physdev_path, - MMModem *existing, - MMSupportsPortResultFunc callback, - gpointer user_data); + void (* supports_port) (MMPlugin *self, + const gchar *subsys, + const gchar *name, + const gchar *physdev_path, + MMModem *existing, + GAsyncReadyCallback callback, + gpointer user_data); + + /* Allows to get the result of an asynchronous port support check. */ + MMPluginSupportsResult (* supports_port_finish) (MMPlugin *self, + GAsyncResult *result, + guint *level, + GError **error); /* Called to cancel an ongoing supports_port() operation or to notify the * plugin to clean up that operation. For example, if two plugins support @@ -111,13 +116,18 @@ const char *mm_plugin_get_name (MMPlugin *plugin); gboolean mm_plugin_get_sort_last (const MMPlugin *plugin); -MMPluginSupportsResult mm_plugin_supports_port (MMPlugin *plugin, - const char *subsys, - const char *name, - const char *physdev_path, - MMModem *existing, - MMSupportsPortResultFunc callback, - gpointer user_data); +void mm_plugin_supports_port (MMPlugin *plugin, + const gchar *subsys, + const gchar *name, + const gchar *physdev_path, + MMModem *existing, + GAsyncReadyCallback callback, + gpointer user_data); + +MMPluginSupportsResult mm_plugin_supports_port_finish (MMPlugin *plugin, + GAsyncResult *result, + guint *level, + GError **error); void mm_plugin_cancel_supports_port (MMPlugin *plugin, const char *subsys, -- cgit v1.2.3-70-g09d2