plugins: simplify custom init commands

Instead of having two places that custom init stuff got processed
(a hook in the MMPluginBase class itself and a callback too) just
use a callback, and simplify it somewhat so that the plugin tracks
how many tries it cares about and what to do based on the response
or error.
This commit is contained in:
Dan Williams
2011-04-26 19:43:40 -05:00
parent 0b757465ff
commit 0befde3ce9
3 changed files with 74 additions and 48 deletions
+21 -1
View File
@@ -61,6 +61,22 @@ probe_result (MMPluginBase *base,
mm_plugin_base_supports_task_complete (task, get_level_for_capabilities (capabilities));
}
static gboolean
custom_init_response_cb (MMPluginBaseSupportsTask *task,
GString *response,
GError *error,
guint32 tries,
gboolean *out_fail,
guint32 *out_level,
gpointer user_data)
{
if (error)
return tries <= 4 ? TRUE : FALSE;
/* No error, assume success */
return FALSE;
}
static MMPluginSupportsResult
supports_port (MMPluginBase *base,
MMModem *existing,
@@ -113,7 +129,11 @@ 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, NULL, NULL);
mm_plugin_base_supports_task_set_custom_init_command (task,
"ATE0+CPMS?",
3,
custom_init_response_cb,
NULL);
if (mm_plugin_base_probe_port (base, task, 100000, NULL))
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;