diff options
author | Thomas Bechtold <thomasbechtold@jpberlin.de> | 2011-03-11 20:25:22 -0600 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2011-03-11 20:25:22 -0600 |
commit | b3b1d5309a4ead90e9a503586b9224d345680d7f (patch) | |
tree | 80323c76ac4e6a37f3ffb97d54ce40a00e06b25f | |
parent | 971600b9099e5d98c32b28cbb0a5305c48c76728 (diff) |
core: allow plugins to handle custom init responses
-rw-r--r-- | plugins/mm-plugin-zte.c | 2 | ||||
-rw-r--r-- | src/mm-plugin-base.c | 28 | ||||
-rw-r--r-- | src/mm-plugin-base.h | 10 |
3 files changed, 37 insertions, 3 deletions
diff --git a/plugins/mm-plugin-zte.c b/plugins/mm-plugin-zte.c index bb2ee176..edc6dd4c 100644 --- a/plugins/mm-plugin-zte.c +++ b/plugins/mm-plugin-zte.c @@ -113,7 +113,7 @@ supports_port (MMPluginBase *base, * 1235f71b20c92cded4abd976ccc5010649aae1a0 and * f38ad328acfdc6ce29dd1380602c546b064161ae for more details. */ - mm_plugin_base_supports_task_set_custom_init_command (task, "ATE0+CPMS?", 3, 4, FALSE); + mm_plugin_base_supports_task_set_custom_init_command (task, "ATE0+CPMS?", 3, 4, FALSE, NULL, NULL); if (mm_plugin_base_probe_port (base, task, NULL)) return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS; diff --git a/src/mm-plugin-base.c b/src/mm-plugin-base.c index da8bc034..d027f437 100644 --- a/src/mm-plugin-base.c +++ b/src/mm-plugin-base.c @@ -115,6 +115,8 @@ typedef struct { guint32 custom_init_tries; guint32 custom_init_delay_seconds; gboolean custom_init_fail_if_timeout; + MMBaseSupportsTaskCustomInitResultFunc custom_init_callback; + gpointer custom_init_callback_data; MMSupportsPortResultFunc callback; gpointer callback_data; @@ -229,7 +231,9 @@ mm_plugin_base_supports_task_set_custom_init_command (MMPluginBaseSupportsTask * const char *cmd, guint32 delay_seconds, guint32 max_tries, - gboolean fail_if_timeout) + gboolean fail_if_timeout, + MMBaseSupportsTaskCustomInitResultFunc callback, + gpointer callback_data) { MMPluginBaseSupportsTaskPrivate *priv; @@ -243,6 +247,8 @@ mm_plugin_base_supports_task_set_custom_init_command (MMPluginBaseSupportsTask * priv->custom_init_max_tries = max_tries; priv->custom_init_delay_seconds = delay_seconds; priv->custom_init_fail_if_timeout = fail_if_timeout; + priv->custom_init_callback = callback; + priv->custom_init_callback_data = callback_data; } static void @@ -731,6 +737,7 @@ custom_init_response (MMAtSerialPort *port, { MMPluginBaseSupportsTask *task = MM_PLUGIN_BASE_SUPPORTS_TASK (user_data); MMPluginBaseSupportsTaskPrivate *task_priv = MM_PLUGIN_BASE_SUPPORTS_TASK_GET_PRIVATE (task); + MMPluginBaseClass* klass = MM_PLUGIN_BASE_GET_CLASS (task_priv->plugin); if (error) { task_priv->custom_init_tries++; @@ -745,6 +752,24 @@ custom_init_response (MMAtSerialPort *port, return; } } + } else { + /* custom handle init response */ + if (klass->handle_custom_init_response != NULL) + klass->handle_custom_init_response (task, response); + } + + /* check for custom init callback */ + if (task_priv->custom_init_callback != NULL) { + MMBaseSupportsTaskCustomInitResultFunc callback = task_priv->custom_init_callback; + guint32 level; + + level = callback (response, task_priv->custom_init_callback_data); + if (level > 0) { + /* Plugin supports the modem */ + task_priv->probed_caps = level; + probe_complete (task); + return; + } } /* Otherwise proceed to probing */ @@ -1243,6 +1268,7 @@ mm_plugin_base_class_init (MMPluginBaseClass *klass) g_type_class_add_private (object_class, sizeof (MMPluginBasePrivate)); klass->handle_probe_response = real_handle_probe_response; + klass->handle_custom_init_response = NULL; /* Virtual methods */ object_class->get_property = get_property; diff --git a/src/mm-plugin-base.h b/src/mm-plugin-base.h index a32d53bf..fa67c0a6 100644 --- a/src/mm-plugin-base.h +++ b/src/mm-plugin-base.h @@ -56,6 +56,9 @@ typedef struct { GType mm_plugin_base_supports_task_get_type (void); +typedef guint32 (*MMBaseSupportsTaskCustomInitResultFunc) (GString* response, + gpointer user_data); + MMPlugin *mm_plugin_base_supports_task_get_plugin (MMPluginBaseSupportsTask *task); GUdevDevice *mm_plugin_base_supports_task_get_port (MMPluginBaseSupportsTask *task); @@ -73,7 +76,9 @@ void mm_plugin_base_supports_task_set_custom_init_command (MMPluginBaseSupportsT const char *cmd, guint32 delay_seconds, guint32 max_tries, - gboolean fail_if_timeout); + gboolean fail_if_timeout, + MMBaseSupportsTaskCustomInitResultFunc callback, + gpointer callback_data); #define MM_TYPE_PLUGIN_BASE (mm_plugin_base_get_type ()) #define MM_PLUGIN_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_BASE, MMPluginBase)) @@ -114,6 +119,9 @@ struct _MMPluginBaseClass { const char *response, const GError *error); + void (*handle_custom_init_response) (MMPluginBaseSupportsTask *task, + GString *response); + /* Signals */ void (*probe_result) (MMPluginBase *self, MMPluginBaseSupportsTask *task, |