diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-08 23:19:19 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-16 14:53:23 +0100 |
commit | cdd339f8024af8088d94f0ffde78beef5a0c998d (patch) | |
tree | 74d01d0a5e6365a34880eb83e2b423ebfc1419d3 | |
parent | 215c27808230352e3def81b45808ef29a9cd5b7a (diff) |
base-modem: implement new modem-wide cancellable, and rework AT commands
Instead of the `_in_port()' variants, we'll provide more generic
`_full()' methods. These should be used either if we want to send commands
to a specific port, or if we want to use a specific user-provided GCancellable.
In addition to this user-provided GCancellable, we keep the internal modem-wide
one.
-rw-r--r-- | plugins/cinterion/mm-broadband-modem-cinterion.c | 36 | ||||
-rw-r--r-- | plugins/gobi/mm-broadband-modem-gobi.c | 1 | ||||
-rw-r--r-- | plugins/iridium/mm-bearer-iridium.c | 12 | ||||
-rw-r--r-- | plugins/iridium/mm-broadband-modem-iridium.c | 5 | ||||
-rw-r--r-- | plugins/nokia/mm-broadband-modem-nokia.c | 1 | ||||
-rw-r--r-- | plugins/novatel/mm-broadband-bearer-novatel.c | 4 | ||||
-rw-r--r-- | plugins/novatel/mm-broadband-modem-novatel.c | 3 | ||||
-rw-r--r-- | plugins/option/mm-broadband-modem-option.c | 3 | ||||
-rw-r--r-- | src/mm-base-modem-at.c | 185 | ||||
-rw-r--r-- | src/mm-base-modem-at.h | 91 | ||||
-rw-r--r-- | src/mm-base-modem.c | 16 | ||||
-rw-r--r-- | src/mm-base-modem.h | 3 | ||||
-rw-r--r-- | src/mm-broadband-bearer.c | 191 | ||||
-rw-r--r-- | src/mm-broadband-modem.c | 162 | ||||
-rw-r--r-- | src/mm-sim.c | 7 | ||||
-rw-r--r-- | src/mm-sms.c | 4 |
16 files changed, 334 insertions, 390 deletions
diff --git a/plugins/cinterion/mm-broadband-modem-cinterion.c b/plugins/cinterion/mm-broadband-modem-cinterion.c index 814189bf..f622ce3c 100644 --- a/plugins/cinterion/mm-broadband-modem-cinterion.c +++ b/plugins/cinterion/mm-broadband-modem-cinterion.c @@ -118,20 +118,16 @@ enable_unsolicited_events (MMIfaceModem3gpp *self, GAsyncReadyCallback callback, gpointer user_data) { - mm_base_modem_at_command_in_port ( - MM_BASE_MODEM (self), - /* Only primary port is expected in the Cinterion modems */ - mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)), - /* AT=CMER=[<mode>[,<keyp>[,<disp>[,<ind>[,<bfr>]]]]] - * but <ind> should be either not set, or equal to 0 or 2. - * Enabled with 2. - */ - "+CMER=3,0,0,2", - 3, - FALSE, - NULL, /* cancellable */ - callback, - user_data); + /* AT=CMER=[<mode>[,<keyp>[,<disp>[,<ind>[,<bfr>]]]]] + * but <ind> should be either not set, or equal to 0 or 2. + * Enabled with 2. + */ + mm_base_modem_at_command (MM_BASE_MODEM (self), + "+CMER=3,0,0,2", + 3, + FALSE, + callback, + user_data); } /*****************************************************************************/ @@ -158,7 +154,6 @@ messaging_enable_unsolicited_events (MMIfaceModemMessaging *self, "+CNMI=2,1,2,2,1", 3, FALSE, - NULL, /* cancellable */ callback, user_data); } @@ -204,7 +199,6 @@ send_sleep_mode_command (MMBroadbandModemCinterion *self, self->priv->sleep_mode_cmd, 5, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)sleep_ready, operation_result); return; @@ -281,7 +275,6 @@ modem_power_down (MMIfaceModem *self, "+CFUN=?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)supported_functionality_status_query_ready, result); } @@ -484,7 +477,6 @@ sind_query_ready (MMBroadbandModemCinterion *self, "^SMONG", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)smong_query_ready, operation_result); } @@ -512,7 +504,6 @@ load_access_technologies (MMIfaceModem *self, "^SIND?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)sind_query_ready, result); return; @@ -523,7 +514,6 @@ load_access_technologies (MMIfaceModem *self, "^SMONG", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)smong_query_ready, result); } @@ -620,7 +610,6 @@ load_supported_modes (MMIfaceModem *self, "+WS46=?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)supported_networks_query_ready, result); } @@ -708,7 +697,6 @@ set_allowed_modes (MMIfaceModem *self, cmd->str, 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)allowed_access_technology_update_ready, result); g_string_free (cmd, TRUE); @@ -983,7 +971,6 @@ load_current_bands (MMIfaceModem *self, "AT^SCFG=\"Radio/Band\"", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)((!broadband->priv->only_utran && !broadband->priv->both_geran_utran) ? get_2g_band_ready : @@ -1082,7 +1069,6 @@ set_bands_3g (MMIfaceModem *self, cmd, 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)scfg_set_ready, result); g_free (cmd); @@ -1179,7 +1165,6 @@ set_bands_2g (MMIfaceModem *self, cmd, 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)scfg_set_ready, result); @@ -1261,7 +1246,6 @@ setup_flow_control (MMIfaceModem *self, "\\Q3", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)setup_flow_control_ready, result); } diff --git a/plugins/gobi/mm-broadband-modem-gobi.c b/plugins/gobi/mm-broadband-modem-gobi.c index 95a99961..01568b47 100644 --- a/plugins/gobi/mm-broadband-modem-gobi.c +++ b/plugins/gobi/mm-broadband-modem-gobi.c @@ -81,7 +81,6 @@ load_access_technologies (MMIfaceModem *self, "*CNTI=0", 3, FALSE, - NULL, /* cancellable */ callback, user_data); } diff --git a/plugins/iridium/mm-bearer-iridium.c b/plugins/iridium/mm-bearer-iridium.c index d13f3666..1caa68e1 100644 --- a/plugins/iridium/mm-bearer-iridium.c +++ b/plugins/iridium/mm-bearer-iridium.c @@ -114,7 +114,7 @@ connect_report_ready (MMBaseModem *modem, } /* If we got a proper extended reply, build the new error to be set */ - result = mm_base_modem_at_command_in_port_finish (modem, res, NULL); + result = mm_base_modem_at_command_full_finish (modem, res, NULL); if (result && g_str_has_prefix (result, "+CEER: ") && strlen (result) > 7) { @@ -146,10 +146,10 @@ dial_ready (MMBaseModem *modem, /* DO NOT check for cancellable here. If we got here without errors, the * bearer is really connected and therefore we need to reflect that in * the state machine. */ - mm_base_modem_at_command_in_port_finish (modem, res, &(ctx->saved_error)); + mm_base_modem_at_command_full_finish (modem, res, &(ctx->saved_error)); if (ctx->saved_error) { /* Try to get more information why it failed */ - mm_base_modem_at_command_in_port ( + mm_base_modem_at_command_full ( modem, ctx->primary, "+CEER", @@ -199,7 +199,7 @@ service_type_ready (MMBaseModem *modem, } /* Errors setting the service type will be critical */ - mm_base_modem_at_command_in_port_finish (modem, res, &error); + mm_base_modem_at_command_full_finish (modem, res, &error); if (error) { g_simple_async_result_take_error (ctx->result, error); connect_context_complete_and_free (ctx); @@ -209,7 +209,7 @@ service_type_ready (MMBaseModem *modem, /* We just use the default number to dial in the Iridium network. Also note * that we won't specify a specific port to use; Iridium modems only expose * one. */ - mm_base_modem_at_command_in_port ( + mm_base_modem_at_command_full ( modem, ctx->primary, "ATDT008816000025", @@ -249,7 +249,7 @@ connect (MMBearer *self, /* Bearer service type set to 9600bps (V.110), which behaves better than the * default 9600bps (V.32). */ - mm_base_modem_at_command_in_port ( + mm_base_modem_at_command_full ( modem, ctx->primary, "+CBST=71,0,1", diff --git a/plugins/iridium/mm-broadband-modem-iridium.c b/plugins/iridium/mm-broadband-modem-iridium.c index 78ccf3bd..4ea8f06e 100644 --- a/plugins/iridium/mm-broadband-modem-iridium.c +++ b/plugins/iridium/mm-broadband-modem-iridium.c @@ -88,7 +88,6 @@ after_atz_sleep_cb (GSimpleAsyncResult *simple) modem_init_sequence, NULL, /* response_processor_context */ NULL, /* response_processor_context_free */ - NULL, /* cancellable */ (GAsyncReadyCallback)init_sequence_ready, simple); g_object_unref (self); @@ -132,7 +131,6 @@ modem_init (MMIfaceModem *self, "Z", 3, TRUE, - NULL, /* cancellable */ (GAsyncReadyCallback)atz_ready, result); } @@ -201,7 +199,6 @@ messaging_enable_unsolicited_events (MMIfaceModemMessaging *self, "+CNMI=2,1,0,0,1", 3, FALSE, - NULL, /* cancellable */ callback, user_data); } @@ -251,7 +248,6 @@ load_signal_quality (MMIfaceModem *self, "+CSQF", 3, FALSE, - NULL, /* cancellable */ callback, user_data); } @@ -308,7 +304,6 @@ setup_flow_control (MMIfaceModem *self, "&K3", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)setup_flow_control_ready, result); } diff --git a/plugins/nokia/mm-broadband-modem-nokia.c b/plugins/nokia/mm-broadband-modem-nokia.c index 7c2c722d..3e8a1661 100644 --- a/plugins/nokia/mm-broadband-modem-nokia.c +++ b/plugins/nokia/mm-broadband-modem-nokia.c @@ -79,7 +79,6 @@ modem_init (MMIfaceModem *self, modem_init_sequence, NULL, /* response_processor_context */ NULL, /* response_processor_context_free */ - NULL, /* cancellable */ callback, user_data); } diff --git a/plugins/novatel/mm-broadband-bearer-novatel.c b/plugins/novatel/mm-broadband-bearer-novatel.c index e480114a..2f9b4565 100644 --- a/plugins/novatel/mm-broadband-bearer-novatel.c +++ b/plugins/novatel/mm-broadband-bearer-novatel.c @@ -171,7 +171,6 @@ connect_3gpp_qmistatus (DetailedConnectContext *ctx) "$NWQMISTATUS", 3, /* timeout */ FALSE, /* allow_cached */ - NULL, /* cancellable */ (GAsyncReadyCallback)connect_3gpp_qmistatus_ready, /* callback */ ctx); /* user_data */ @@ -230,7 +229,6 @@ connect_3gpp (MMBroadbandBearer *self, "$NWQMICONNECT=,,,,,,,,,,", 10, /* timeout */ FALSE, /* allow_cached */ - NULL, /* cancellable */ (GAsyncReadyCallback)connect_3gpp_qmiconnect_ready, ctx); /* user_data */ } @@ -338,7 +336,6 @@ disconnect_3gpp_check_status (MMBaseModem *modem, "$NWQMISTATUS", 3, /* timeout */ FALSE, /* allow_cached */ - NULL, /* cancellable */ (GAsyncReadyCallback)disconnect_3gpp_status_complete, ctx); /* user_data */ } @@ -362,7 +359,6 @@ disconnect_3gpp (MMBroadbandBearer *self, "$NWQMIDISCONNECT", 10, /* timeout */ FALSE, /* allow_cached */ - NULL, /* cancellable */ (GAsyncReadyCallback)disconnect_3gpp_check_status, ctx); /* user_data */ } diff --git a/plugins/novatel/mm-broadband-modem-novatel.c b/plugins/novatel/mm-broadband-modem-novatel.c index 7fbc8346..1932be04 100644 --- a/plugins/novatel/mm-broadband-modem-novatel.c +++ b/plugins/novatel/mm-broadband-modem-novatel.c @@ -206,7 +206,6 @@ load_supported_modes (MMIfaceModem *self, "+WS46=?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)supported_networks_query_ready, result); } @@ -362,7 +361,6 @@ load_current_bands (MMIfaceModem *self, "$NWBAND?", 3, FALSE, - NULL, (GAsyncReadyCallback)load_current_bands_done, result); } @@ -424,7 +422,6 @@ set_bands (MMIfaceModem *self, cmd, 3, FALSE, - NULL, (GAsyncReadyCallback)set_bands_done, result); diff --git a/plugins/option/mm-broadband-modem-option.c b/plugins/option/mm-broadband-modem-option.c index bf15b1de..cfc7b59c 100644 --- a/plugins/option/mm-broadband-modem-option.c +++ b/plugins/option/mm-broadband-modem-option.c @@ -306,7 +306,6 @@ load_access_technologies_step (AccessTechnologiesContext *ctx) "_OSSYS?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)ossys_query_ready, ctx); break; @@ -317,7 +316,6 @@ load_access_technologies_step (AccessTechnologiesContext *ctx) "_OCTI?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)octi_query_ready, ctx); return; @@ -331,7 +329,6 @@ load_access_technologies_step (AccessTechnologiesContext *ctx) "_OWCTI?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)owcti_query_ready, ctx); return; diff --git a/src/mm-base-modem-at.c b/src/mm-base-modem-at.c index 6985f41a..04a350f9 100644 --- a/src/mm-base-modem-at.c +++ b/src/mm-base-modem-at.c @@ -70,6 +70,13 @@ abort_async_if_port_unusable (MMBaseModem *self, return TRUE; } +static void +modem_cancellable_cancelled (GCancellable *modem_cancellable, + GCancellable *user_cancellable) +{ + g_cancellable_cancel (user_cancellable); +} + /*****************************************************************************/ /* AT sequence handling */ @@ -77,6 +84,9 @@ typedef struct { MMBaseModem *self; MMAtSerialPort *port; GCancellable *cancellable; + gulong cancelled_id; + GCancellable *modem_cancellable; + GCancellable *user_cancellable; const MMBaseModemAtCommand *current; const MMBaseModemAtCommand *sequence; GSimpleAsyncResult *simple; @@ -95,8 +105,15 @@ at_sequence_context_free (AtSequenceContext *ctx) if (ctx->response_processor_context && ctx->response_processor_context_free) ctx->response_processor_context_free (ctx->response_processor_context); - if (ctx->cancellable) - g_object_unref (ctx->cancellable); + + if (ctx->cancelled_id) + g_cancellable_disconnect (ctx->modem_cancellable, + ctx->cancelled_id); + if (ctx->user_cancellable) + g_object_unref (ctx->user_cancellable); + g_object_unref (ctx->modem_cancellable); + g_object_unref (ctx->cancellable); + if (ctx->result) g_variant_unref (ctx->result); if (ctx->simple) @@ -105,10 +122,10 @@ at_sequence_context_free (AtSequenceContext *ctx) } GVariant * -mm_base_modem_at_sequence_in_port_finish (MMBaseModem *self, - GAsyncResult *res, - gpointer *response_processor_context, - GError **error) +mm_base_modem_at_sequence_full_finish (MMBaseModem *self, + GAsyncResult *res, + gpointer *response_processor_context, + GError **error) { AtSequenceContext *ctx; @@ -223,14 +240,14 @@ at_sequence_parse_response (MMAtSerialPort *port, } void -mm_base_modem_at_sequence_in_port (MMBaseModem *self, - MMAtSerialPort *port, - const MMBaseModemAtCommand *sequence, - gpointer response_processor_context, - GDestroyNotify response_processor_context_free, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +mm_base_modem_at_sequence_full (MMBaseModem *self, + MMAtSerialPort *port, + const MMBaseModemAtCommand *sequence, + gpointer response_processor_context, + GDestroyNotify response_processor_context_free, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { AtSequenceContext *ctx; @@ -242,17 +259,30 @@ mm_base_modem_at_sequence_in_port (MMBaseModem *self, ctx = g_new0 (AtSequenceContext, 1); ctx->self = g_object_ref (self); ctx->port = g_object_ref (port); - ctx->cancellable = (cancellable ? - g_object_ref (cancellable) : - NULL); ctx->simple = g_simple_async_result_new (G_OBJECT (self), callback, user_data, - mm_base_modem_at_sequence_in_port); + mm_base_modem_at_sequence_full); ctx->current = ctx->sequence = sequence; ctx->response_processor_context = response_processor_context; ctx->response_processor_context_free = response_processor_context_free; + /* Setup cancellables */ + ctx->modem_cancellable = mm_base_modem_get_cancellable (self); + ctx->user_cancellable = cancellable ? g_object_ref (cancellable) : NULL; + if (!ctx->user_cancellable) + /* Just the modem-wide one, use it directly */ + ctx->cancellable = g_object_ref (ctx->modem_cancellable); + else { + /* Use the user provided one, which will also get cancelled if the modem + * wide-one gets cancelled */ + ctx->cancellable = g_object_ref (ctx->user_cancellable); + ctx->cancelled_id = g_cancellable_connect (ctx->modem_cancellable, + G_CALLBACK (modem_cancellable_cancelled), + ctx->user_cancellable, + NULL); + } + /* Go on with the first one in the sequence */ mm_at_serial_port_queue_command ( ctx->port, @@ -269,7 +299,7 @@ mm_base_modem_at_sequence_finish (MMBaseModem *self, gpointer *response_processor_context, GError **error) { - return (mm_base_modem_at_sequence_in_port_finish ( + return (mm_base_modem_at_sequence_full_finish ( self, res, response_processor_context, @@ -281,7 +311,6 @@ mm_base_modem_at_sequence (MMBaseModem *self, const MMBaseModemAtCommand *sequence, gpointer response_processor_context, GDestroyNotify response_processor_context_free, - GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -299,13 +328,13 @@ mm_base_modem_at_sequence (MMBaseModem *self, return; } - mm_base_modem_at_sequence_in_port ( + mm_base_modem_at_sequence_full ( self, port, sequence, response_processor_context, response_processor_context_free, - cancellable, + NULL, callback, user_data); } @@ -375,15 +404,25 @@ typedef struct { MMBaseModem *self; MMAtSerialPort *port; GCancellable *cancellable; + gulong cancelled_id; + GCancellable *modem_cancellable; + GCancellable *user_cancellable; GSimpleAsyncResult *result; } AtCommandContext; static void at_command_context_free (AtCommandContext *ctx) { - if (ctx->cancellable) - g_object_unref (ctx->cancellable); mm_serial_port_close (MM_SERIAL_PORT (ctx->port)); + + if (ctx->cancelled_id) + g_cancellable_disconnect (ctx->modem_cancellable, + ctx->cancelled_id); + if (ctx->user_cancellable) + g_object_unref (ctx->user_cancellable); + g_object_unref (ctx->modem_cancellable); + g_object_unref (ctx->cancellable); + g_object_unref (ctx->port); g_object_unref (ctx->result); g_object_unref (ctx->self); @@ -391,7 +430,7 @@ at_command_context_free (AtCommandContext *ctx) } const gchar * -mm_base_modem_at_command_in_port_finish (MMBaseModem *self, +mm_base_modem_at_command_full_finish (MMBaseModem *self, GAsyncResult *res, GError **error) { @@ -433,14 +472,14 @@ at_command_parse_response (MMAtSerialPort *port, } void -mm_base_modem_at_command_in_port (MMBaseModem *self, - MMAtSerialPort *port, - const gchar *command, - guint timeout, - gboolean allow_cached, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +mm_base_modem_at_command_full (MMBaseModem *self, + MMAtSerialPort *port, + const gchar *command, + guint timeout, + gboolean allow_cached, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { AtCommandContext *ctx; @@ -448,16 +487,30 @@ mm_base_modem_at_command_in_port (MMBaseModem *self, if (!abort_async_if_port_unusable (self, port, callback, user_data)) return; - ctx = g_new (AtCommandContext, 1); + ctx = g_new0 (AtCommandContext, 1); ctx->self = g_object_ref (self); ctx->port = g_object_ref (port); - ctx->cancellable = (cancellable ? - g_object_ref (cancellable) : - NULL); ctx->result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, - mm_base_modem_at_command_in_port); + mm_base_modem_at_command_full); + + /* Setup cancellables */ + ctx->modem_cancellable = mm_base_modem_get_cancellable (self); + ctx->user_cancellable = cancellable ? g_object_ref (cancellable) : NULL; + if (!ctx->user_cancellable) + /* Just the modem-wide one, use it directly */ + ctx->cancellable = g_object_ref (ctx->modem_cancellable); + else { + /* Use the user provided one, which will also get cancelled if the modem + * wide-one gets cancelled */ + ctx->cancellable = g_object_ref (ctx->user_cancellable); + ctx->cancelled_id = g_cancellable_connect (ctx->modem_cancellable, + G_CALLBACK (modem_cancellable_cancelled), + ctx->user_cancellable, + NULL); + } + /* Go on with the command */ if (allow_cached) @@ -483,7 +536,7 @@ mm_base_modem_at_command_finish (MMBaseModem *self, GAsyncResult *res, GError **error) { - return mm_base_modem_at_command_in_port_finish (self, res, error); + return mm_base_modem_at_command_full_finish (self, res, error); } void @@ -491,7 +544,6 @@ mm_base_modem_at_command (MMBaseModem *self, const gchar *command, guint timeout, gboolean allow_cached, - GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -509,49 +561,12 @@ mm_base_modem_at_command (MMBaseModem *self, return; } - mm_base_modem_at_command_in_port (self, - port, - command, - timeout, - allow_cached, - cancellable, - callback, - user_data); -} - -/*****************************************************************************/ -/* Single AT command handling, completely ignoring the response */ - -void -mm_base_modem_at_command_in_port_ignore_reply (MMBaseModem *self, - MMAtSerialPort *port, - const gchar *command, - guint timeout) -{ - /* Use the async method without callback, so that we ensure port - * gets opened and such, if needed */ - mm_base_modem_at_command_in_port (self, - port, - command, - timeout, - FALSE, - NULL, /* cancellable */ - NULL, /* callback */ - NULL); /* user_data */ -} - -void -mm_base_modem_at_command_ignore_reply (MMBaseModem *self, - const gchar *command, - guint timeout) -{ - MMAtSerialPort *port; - - /* No port given, so we'll try to guess which is best */ - port = mm_base_modem_peek_best_at_port (self, NULL); - if (!port) - /* No valid port, and we ignore replies, so just exit. */ - return; - - mm_base_modem_at_command_in_port_ignore_reply (self, port, command, timeout); + mm_base_modem_at_command_full (self, + port, + command, + timeout, + allow_cached, + NULL, + callback, + user_data); } diff --git a/src/mm-base-modem-at.h b/src/mm-base-modem-at.h index b4b2f651..fb98669d 100644 --- a/src/mm-base-modem-at.h +++ b/src/mm-base-modem-at.h @@ -63,31 +63,33 @@ typedef struct { MMBaseModemAtResponseProcessor response_processor; } MMBaseModemAtCommand; -/* AT sequence handling */ -void mm_base_modem_at_sequence (MMBaseModem *self, - const MMBaseModemAtCommand *sequence, - gpointer response_processor_context, - GDestroyNotify response_processor_context_free, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -GVariant *mm_base_modem_at_sequence_finish (MMBaseModem *self, - GAsyncResult *res, - gpointer *response_processor_context, - GError **error); - -void mm_base_modem_at_sequence_in_port (MMBaseModem *self, - MMAtSerialPort *port, +/* Generic AT sequence handling, using the best AT port available and without + * explicit cancellations. */ +void mm_base_modem_at_sequence (MMBaseModem *self, const MMBaseModemAtCommand *sequence, gpointer response_processor_context, GDestroyNotify response_processor_context_free, - GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); -GVariant *mm_base_modem_at_sequence_in_port_finish (MMBaseModem *self, - GAsyncResult *res, - gpointer *response_processor_context, - GError **error); +GVariant *mm_base_modem_at_sequence_finish (MMBaseModem *self, + GAsyncResult *res, + gpointer *response_processor_context, + GError **error); + +/* Fully detailed AT sequence handling, when specific AT port and/or explicit + * cancellations need to be used. */ +void mm_base_modem_at_sequence_full (MMBaseModem *self, + MMAtSerialPort *port, + const MMBaseModemAtCommand *sequence, + gpointer response_processor_context, + GDestroyNotify response_processor_context_free, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GVariant *mm_base_modem_at_sequence_full_finish (MMBaseModem *self, + GAsyncResult *res, + gpointer *response_processor_context, + GError **error); /* Common helper response processors */ @@ -119,37 +121,30 @@ gboolean mm_base_modem_response_processor_no_result_continue (MMBaseModem *self, GVariant **result, GError **result_error); -/* Single AT command, returning the whole response string */ -void mm_base_modem_at_command (MMBaseModem *self, - const gchar *command, - guint timeout, - gboolean allow_cached, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); +/* Generic AT command handling, using the best AT port available and without + * explicit cancellations. */ +void mm_base_modem_at_command (MMBaseModem *self, + const gchar *command, + guint timeout, + gboolean allow_cached, + GAsyncReadyCallback callback, + gpointer user_data); const gchar *mm_base_modem_at_command_finish (MMBaseModem *self, GAsyncResult *res, GError **error); -void mm_base_modem_at_command_in_port (MMBaseModem *self, - MMAtSerialPort *port, - const gchar *command, - guint timeout, - gboolean allow_cached, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -const gchar *mm_base_modem_at_command_in_port_finish (MMBaseModem *self, - GAsyncResult *res, - GError **error); - -/* Fire and forget an AT command */ -void mm_base_modem_at_command_ignore_reply (MMBaseModem *self, - const gchar *command, - guint timeout); -void mm_base_modem_at_command_in_port_ignore_reply (MMBaseModem *self, - MMAtSerialPort *port, - const gchar *command, - guint timeout); +/* Fully detailed AT command handling, when specific AT port and/or explicit + * cancellations need to be used. */ +void mm_base_modem_at_command_full (MMBaseModem *self, + MMAtSerialPort *port, + const gchar *command, + guint timeout, + gboolean allow_cached, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +const gchar *mm_base_modem_at_command_full_finish (MMBaseModem *self, + GAsyncResult *res, + GError **error); #endif /* MM_BASE_MODEM_AT_H */ diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c index fc984f26..f2e0c0ac 100644 --- a/src/mm-base-modem.c +++ b/src/mm-base-modem.c @@ -387,6 +387,22 @@ mm_base_modem_get_valid (MMBaseModem *self) return self->priv->valid; } +GCancellable * +mm_base_modem_peek_cancellable (MMBaseModem *self) +{ + g_return_val_if_fail (MM_IS_BASE_MODEM (self), NULL); + + return self->priv->cancellable; +} + +GCancellable * +mm_base_modem_get_cancellable (MMBaseModem *self) +{ + g_return_val_if_fail (MM_IS_BASE_MODEM (self), NULL); + + return g_object_ref (self->priv->cancellable); +} + MMAtSerialPort * mm_base_modem_get_port_primary (MMBaseModem *self) { diff --git a/src/mm-base-modem.h b/src/mm-base-modem.h index 05174fc4..9404a0ec 100644 --- a/src/mm-base-modem.h +++ b/src/mm-base-modem.h @@ -140,6 +140,9 @@ const gchar *mm_base_modem_get_plugin (MMBaseModem *self); guint mm_base_modem_get_vendor_id (MMBaseModem *self); guint mm_base_modem_get_product_id (MMBaseModem *self); +GCancellable *mm_base_modem_peek_cancellable (MMBaseModem *self); +GCancellable *mm_base_modem_get_cancellable (MMBaseModem *self); + void mm_base_modem_authorize (MMBaseModem *self, GDBusMethodInvocation *invocation, const gchar *authorization, diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c index 64eec160..42a525e4 100644 --- a/src/mm-broadband-bearer.c +++ b/src/mm-broadband-bearer.c @@ -272,7 +272,7 @@ dial_cdma_ready (MMBaseModem *modem, /* DO NOT check for cancellable here. If we got here without errors, the * bearer is really connected and therefore we need to reflect that in * the state machine. */ - mm_base_modem_at_command_finish (modem, res, &error); + mm_base_modem_at_command_full_finish (modem, res, &error); if (error) { mm_warn ("Couldn't connect: '%s'", error->message); g_simple_async_result_take_error (ctx->result, error); @@ -296,15 +296,15 @@ cdma_connect_context_dial (DetailedConnectContext *ctx) command = g_strconcat ("DT", ctx->self->priv->number, NULL); else command = g_strdup ("DT#777"); - mm_base_modem_at_command_in_port ( - ctx->modem, - ctx->primary, - command, - 90, - FALSE, - NULL, /* cancellable */ - (GAsyncReadyCallback)dial_cdma_ready, - ctx); + + mm_base_modem_at_command_full (ctx->modem, + ctx->primary, + command, + 90, + FALSE, + NULL, + (GAsyncReadyCallback)dial_cdma_ready, + ctx); g_free (command); } @@ -319,7 +319,7 @@ set_rm_protocol_ready (MMBaseModem *self, if (detailed_connect_context_complete_and_free_if_cancelled (ctx)) return; - mm_base_modem_at_command_finish (self, res, &error); + mm_base_modem_at_command_full_finish (self, res, &error); if (error) { mm_warn ("Couldn't set RM protocol: '%s'", error->message); g_simple_async_result_take_error (ctx->result, error); @@ -345,7 +345,7 @@ current_rm_protocol_ready (MMBaseModem *self, if (detailed_connect_context_complete_and_free_if_cancelled (ctx)) return; - result = mm_base_modem_at_command_finish (self, res, &error); + result = mm_base_modem_at_command_full_finish (self, res, &error); if (error) { mm_warn ("Couldn't query current RM protocol: '%s'", error->message); g_simple_async_result_take_error (ctx->result, error); @@ -383,15 +383,14 @@ current_rm_protocol_ready (MMBaseModem *self, } command = g_strdup_printf ("+CRM=%u", new_index); - mm_base_modem_at_command_in_port ( - ctx->modem, - ctx->primary, - command, - 3, - FALSE, - NULL, /* cancellable */ - (GAsyncReadyCallback)set_rm_protocol_ready, - ctx); + mm_base_modem_at_command_full (ctx->modem, + ctx->primary, + command, + 3, + FALSE, + NULL, + (GAsyncReadyCallback)set_rm_protocol_ready, + ctx); g_free (command); return; } @@ -425,15 +424,14 @@ connect_cdma (MMBroadbandBearer *self, if (self->priv->rm_protocol != MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN) { /* Need to query current RM protocol */ mm_dbg ("Querying current RM protocol set..."); - mm_base_modem_at_command_in_port ( - ctx->modem, - ctx->primary, - "+CRM?", - 3, - FALSE, - NULL, /* cancellable */ - (GAsyncReadyCallback)current_rm_protocol_ready, - ctx); + mm_base_modem_at_command_full (ctx->modem, + ctx->primary, + "+CRM?", + 3, + FALSE, + NULL, /* cancellable */ + (GAsyncReadyCallback)current_rm_protocol_ready, + ctx); return; } @@ -535,7 +533,7 @@ extended_error_ready (MMBaseModem *modem, if (dial_3gpp_context_complete_and_free_if_cancelled (ctx)) return; - result = mm_base_modem_at_command_finish (modem, res, NULL); + result = mm_base_modem_at_command_full_finish (modem, res, NULL); if (result && g_str_has_prefix (result, "+CEER: ") && strlen (result) > 7) { @@ -562,19 +560,18 @@ atd_ready (MMBaseModem *modem, /* DO NOT check for cancellable here. If we got here without errors, the * bearer is really connected and therefore we need to reflect that in * the state machine. */ - mm_base_modem_at_command_finish (modem, res, &ctx->saved_error); + mm_base_modem_at_command_full_finish (modem, res, &ctx->saved_error); if (ctx->saved_error) { /* Try to get more information why it failed */ - mm_base_modem_at_command_in_port ( - ctx->modem, - ctx->primary, - "+CEER", - 3, - FALSE, - NULL, /* cancellable */ - (GAsyncReadyCallback)extended_error_ready, - ctx); + mm_base_modem_at_command_full (ctx->modem, + ctx->primary, + "+CEER", + 3, + FALSE, + NULL, /* cancellable */ + (GAsyncReadyCallback)extended_error_ready, + ctx); return; } @@ -604,15 +601,14 @@ dial_3gpp (MMBroadbandBearer *self, /* Use default *99 to connect */ command = g_strdup_printf ("ATD*99***%d#", cid); - mm_base_modem_at_command_in_port ( - ctx->modem, - ctx->primary, - command, - 60, - FALSE, - NULL, /* cancellable */ - (GAsyncReadyCallback)atd_ready, - ctx); + mm_base_modem_at_command_full (ctx->modem, + ctx->primary, + command, + 60, + FALSE, + NULL, /* cancellable */ + (GAsyncReadyCallback)atd_ready, + ctx); g_free (command); } @@ -664,7 +660,7 @@ initialize_pdp_context_ready (MMBaseModem *self, if (detailed_connect_context_complete_and_free_if_cancelled (ctx)) return; - mm_base_modem_at_command_finish (self, res, &error); + mm_base_modem_at_command_full_finish (self, res, &error); if (error) { mm_warn ("Couldn't initialize PDP context with our APN: '%s'", error->message); @@ -691,7 +687,7 @@ find_cid_ready (MMBaseModem *self, gchar *command; GError *error = NULL; - result = mm_base_modem_at_sequence_finish (self, res, NULL, &error); + result = mm_base_modem_at_sequence_full_finish (self, res, NULL, &error); if (!result) { mm_warn ("Couldn't find best CID to use: '%s'", error->message); g_simple_async_result_take_error (ctx->result, error); @@ -710,15 +706,14 @@ find_cid_ready (MMBaseModem *self, command = g_strdup_printf ("+CGDCONT=%u,\"IP\",\"%s\"", ctx->cid, ctx->self->priv->apn); - mm_base_modem_at_command_in_port ( - ctx->modem, - ctx->primary, - command, - 3, - FALSE, - NULL, /* cancellable */ - (GAsyncReadyCallback)initialize_pdp_context_ready, - ctx); + mm_base_modem_at_command_full (ctx->modem, + ctx->primary, + command, + 3, + FALSE, + NULL, /* cancellable */ + (GAsyncReadyCallback)initialize_pdp_context_ready, + ctx); g_free (command); } @@ -914,15 +909,14 @@ connect_3gpp (MMBroadbandBearer *self, user_data); mm_dbg ("Looking for best CID..."); - mm_base_modem_at_sequence_in_port ( - ctx->modem, - ctx->primary, - find_cid_sequence, - ctx, /* also passed as response processor context */ - NULL, /* response_processor_context_free */ - NULL, /* cancellable */ - (GAsyncReadyCallback)find_cid_ready, - ctx); + mm_base_modem_at_sequence_full (ctx->modem, + ctx->primary, + find_cid_sequence, + ctx, /* also passed as response processor context */ + NULL, /* response_processor_context_free */ + NULL, /* cancellable */ + (GAsyncReadyCallback)find_cid_ready, + ctx); } /*****************************************************************************/ @@ -1343,7 +1337,7 @@ cgact_primary_ready (MMBaseModem *modem, GError *error = NULL; /* Ignore errors for now */ - mm_base_modem_at_command_finish (MM_BASE_MODEM (modem), res, &error); + mm_base_modem_at_command_full_finish (MM_BASE_MODEM (modem), res, &error); if (error) { mm_dbg ("PDP context deactivation failed (not fatal): %s", error->message); g_error_free (error); @@ -1398,15 +1392,14 @@ primary_flash_3gpp_ready (MMSerialPort *port, /* Port is disconnected; update the state */ mm_port_set_connected (ctx->data, FALSE); - mm_base_modem_at_command_in_port ( - ctx->modem, - ctx->primary, - ctx->cgact_command, - 3, - FALSE, - NULL, /* cancellable */ - (GAsyncReadyCallback)cgact_primary_ready, - ctx); + mm_base_modem_at_command_full (ctx->modem, + ctx->primary, + ctx->cgact_command, + 3, + FALSE, + NULL, /* cancellable */ + (GAsyncReadyCallback)cgact_primary_ready, + ctx); } static void @@ -1416,7 +1409,7 @@ cgact_secondary_ready (MMBaseModem *modem, { GError *error = NULL; - mm_base_modem_at_command_finish (MM_BASE_MODEM (modem), res, &error); + mm_base_modem_at_command_full_finish (MM_BASE_MODEM (modem), res, &error); if (!error) ctx->cgact_sent = TRUE; else @@ -1463,15 +1456,14 @@ disconnect_3gpp (MMBroadbandBearer *self, */ if (ctx->secondary && mm_port_get_connected (MM_PORT (ctx->primary))) { - mm_base_modem_at_command_in_port ( - ctx->modem, - ctx->secondary, - ctx->cgact_command, - 3, - FALSE, - NULL, /* cancellable */ - (GAsyncReadyCallback)cgact_secondary_ready, - ctx); + mm_base_modem_at_command_full (ctx->modem, + ctx->secondary, + ctx->cgact_command, + 3, + FALSE, + NULL, /* cancellable */ + (GAsyncReadyCallback)cgact_secondary_ready, + ctx); return; } @@ -1742,7 +1734,7 @@ crm_range_ready (MMBaseModem *modem, GError *error = NULL; const gchar *response; - response = mm_base_modem_at_command_finish (modem, res, &error); + response = mm_base_modem_at_command_full_finish (modem, res, &error); if (error) { /* We should possibly take this error as fatal. If we were told to use a * specific Rm protocol, we must be able to check if it is supported. */ @@ -1868,15 +1860,14 @@ interface_initialization_step (InitAsyncContext *ctx) * supported. */ if (mm_iface_modem_is_cdma (MM_IFACE_MODEM (ctx->modem)) && ctx->self->priv->rm_protocol != MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN) { - mm_base_modem_at_command_in_port ( - ctx->modem, - ctx->port, - "+CRM=?", - 3, - TRUE, /* getting range, so reply can be cached */ - NULL, /* cancellable */ - (GAsyncReadyCallback)crm_range_ready, - ctx); + mm_base_modem_at_command_full (ctx->modem, + ctx->port, + "+CRM=?", + 3, + TRUE, /* getting range, so reply can be cached */ + NULL, /* cancellable */ + (GAsyncReadyCallback)crm_range_ready, + ctx); return; } diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index 60742d16..f04bc621 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -484,7 +484,6 @@ modem_load_current_capabilities (MMIfaceModem *self, capabilities, NULL, /* response_processor_context */ NULL, /* response_processor_context_free */ - NULL, /* cancellable */ callback, user_data); } @@ -526,7 +525,6 @@ modem_load_manufacturer (MMIfaceModem *self, manufacturers, NULL, /* response_processor_context */ NULL, /* response_processor_context_free */ - NULL, /* cancellable */ callback, user_data); } @@ -568,7 +566,6 @@ modem_load_model (MMIfaceModem *self, models, NULL, /* response_processor_context */ NULL, /* response_processor_context_free */ - NULL, /* cancellable */ callback, user_data); } @@ -610,7 +607,6 @@ modem_load_revision (MMIfaceModem *self, revisions, NULL, /* response_processor_context */ NULL, /* response_processor_context_free */ - NULL, /* cancellable */ callback, user_data); } @@ -659,7 +655,6 @@ modem_load_equipment_identifier (MMIfaceModem *self, commands, NULL, /* response_processor_context */ NULL, /* response_processor_context_free */ - NULL, /* cancellable */ callback, user_data); } @@ -753,7 +748,6 @@ modem_load_device_identifier (MMIfaceModem *self, device_identifier_steps, g_new0 (DeviceIdentifierContext, 1), (GDestroyNotify)device_identifier_context_free, - NULL, /* cancellable */ callback, user_data); } @@ -785,7 +779,6 @@ modem_load_own_numbers (MMIfaceModem *self, "+CNUM", 3, FALSE, - NULL, /* cancellable */ callback, user_data); } @@ -908,7 +901,6 @@ modem_load_unlock_required (MMIfaceModem *self, "+CPIN?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)cpin_query_ready, result); } @@ -1019,7 +1011,7 @@ signal_quality_csq_ready (MMBroadbandModem *self, GVariant *result; const gchar *result_str; - result = mm_base_modem_at_sequence_in_port_finish (MM_BASE_MODEM (self), res, NULL, &error); + result = mm_base_modem_at_sequence_full_finish (MM_BASE_MODEM (self), res, NULL, &error); if (error) { g_simple_async_result_take_error (ctx->result, error); signal_quality_context_complete_and_free (ctx); @@ -1072,7 +1064,7 @@ static const MMBaseModemAtCommand signal_quality_csq_sequence[] = { static void signal_quality_csq (SignalQualityContext *ctx) { - mm_base_modem_at_sequence_in_port ( + mm_base_modem_at_sequence_full ( MM_BASE_MODEM (ctx->self), MM_AT_SERIAL_PORT (ctx->port), signal_quality_csq_sequence, @@ -1149,14 +1141,14 @@ signal_quality_cind_ready (MMBroadbandModem *self, static void signal_quality_cind (SignalQualityContext *ctx) { - mm_base_modem_at_command_in_port (MM_BASE_MODEM (ctx->self), - MM_AT_SERIAL_PORT (ctx->port), - "+CIND?", - 3, - FALSE, - NULL, /* cancellable */ - (GAsyncReadyCallback)signal_quality_cind_ready, - ctx); + mm_base_modem_at_command_full (MM_BASE_MODEM (ctx->self), + MM_AT_SERIAL_PORT (ctx->port), + "+CIND?", + 3, + FALSE, + NULL, /* cancellable */ + (GAsyncReadyCallback)signal_quality_cind_ready, + ctx); } static void @@ -1372,7 +1364,6 @@ modem_3gpp_setup_indicators (MMIfaceModem3gpp *self, "+CIND=?", 3, TRUE, - NULL, /* cancellable */ (GAsyncReadyCallback)cind_format_check_ready, result); } @@ -1555,14 +1546,14 @@ run_unsolicited_events_setup (UnsolicitedEventsContext *ctx) /* Enable unsolicited events in given port */ if (port) { - mm_base_modem_at_command_in_port (MM_BASE_MODEM (ctx->self), - port, - ctx->command, - 3, - FALSE, - NULL, /* cancellable */ - (GAsyncReadyCallback)unsolicited_events_setup_ready, - ctx); + mm_base_modem_at_command_full (MM_BASE_MODEM (ctx->self), + port, + ctx->command, + 3, + FALSE, + NULL, /* cancellable */ + (GAsyncReadyCallback)unsolicited_events_setup_ready, + ctx); return; } @@ -1699,7 +1690,6 @@ charset_change_ready (MMBroadbandModem *self, "+CSCS?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)current_charset_query_ready, ctx); } @@ -1757,7 +1747,6 @@ modem_setup_charset (MMIfaceModem *self, ctx->charset_commands, NULL, /* response_processor_context */ NULL, /* response_processor_context_free */ - NULL, /* cancellable */ (GAsyncReadyCallback)charset_change_ready, ctx); } @@ -1831,7 +1820,6 @@ modem_load_supported_charsets (MMIfaceModem *self, "+CSCS=?", 3, TRUE, - NULL, /* cancellable */ (GAsyncReadyCallback)cscs_format_check_ready, result); } @@ -1856,9 +1844,12 @@ modem_setup_flow_control (MMIfaceModem *self, GSimpleAsyncResult *result; /* By default, try to set XOFF/XON flow control */ - mm_base_modem_at_command_ignore_reply (MM_BASE_MODEM (self), - "+IFC=1,1", - 3); + mm_base_modem_at_command (MM_BASE_MODEM (self), + "+IFC=1,1", + 3, + FALSE, + NULL, + NULL); result = g_simple_async_result_new (G_OBJECT (self), callback, @@ -1894,9 +1885,12 @@ modem_power_up (MMIfaceModem *self, if (mm_iface_modem_is_cdma_only (self)) mm_dbg ("Skipping Power-up in CDMA-only modem..."); else - mm_base_modem_at_command_ignore_reply (MM_BASE_MODEM (self), - "+CFUN=1", - 5); + mm_base_modem_at_command (MM_BASE_MODEM (self), + "+CFUN=1", + 5, + FALSE, + NULL, + NULL); result = g_simple_async_result_new (G_OBJECT (self), callback, @@ -1930,7 +1924,6 @@ modem_command (MMIfaceModem *self, mm_base_modem_at_command (MM_BASE_MODEM (self), cmd, timeout, FALSE, - NULL, /* cancellable */ callback, user_data); } @@ -1976,7 +1969,6 @@ modem_init (MMIfaceModem *self, modem_init_sequence, NULL, /* response_processor_context */ NULL, /* response_processor_context_free */ - NULL, /* cancellable */ callback, user_data); } @@ -2009,7 +2001,6 @@ modem_3gpp_load_imei (MMIfaceModem3gpp *self, "+CGSN", 3, TRUE, - NULL, /* cancellable */ callback, user_data); } @@ -2093,7 +2084,6 @@ get_next_facility_lock_status (LoadEnabledFacilityLocksContext *ctx) cmd, 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)clck_single_query_ready, ctx); return; @@ -2158,7 +2148,6 @@ modem_3gpp_load_enabled_facility_locks (MMIfaceModem3gpp *self, "+CLCK=?", 3, TRUE, - NULL, /* cancellable */ (GAsyncReadyCallback)clck_test_ready, ctx); } @@ -2195,7 +2184,6 @@ modem_3gpp_load_operator_code (MMIfaceModem3gpp *self, "+COPS=3,2;+COPS?", 3, FALSE, - NULL, /* cancellable */ callback, user_data); } @@ -2232,7 +2220,6 @@ modem_3gpp_load_operator_name (MMIfaceModem3gpp *self, "+COPS=3,0;+COPS?", 3, FALSE, - NULL, /* cancellable */ callback, user_data); } @@ -2411,7 +2398,6 @@ modem_3gpp_scan_networks (MMIfaceModem3gpp *self, "+COPS=?", 120, FALSE, - NULL, /* cancellable */ callback, user_data); } @@ -2552,7 +2538,7 @@ register_in_3gpp_network_ready (MMBroadbandModem *self, { GError *error = NULL; - mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error); + mm_base_modem_at_command_full_finish (MM_BASE_MODEM (self), res, &error); if (error) { /* Propagate error in COPS, if any */ @@ -2628,14 +2614,18 @@ modem_3gpp_register_in_network (MMIfaceModem3gpp *self, if (command) { /* Don't setup an additional timeout to handle registration timeouts. We * already do this with the 120s timeout in the AT command: if that times - * out, we can consider the registration itself timed out. */ - mm_base_modem_at_command (MM_BASE_MODEM (self), - command, - 120, - FALSE, - ctx->cancellable, - (GAsyncReadyCallback)register_in_3gpp_network_ready, - ctx); + * out, we can consider the registration itself timed out. + * + * NOTE that we provide our own Cancellable here; we want to be able to + * cancel the operation at any time. */ + mm_base_modem_at_command_full (MM_BASE_MODEM (self), + mm_base_modem_peek_best_at_port (MM_BASE_MODEM (self), NULL), + command, + 120, + FALSE, + ctx->cancellable, + (GAsyncReadyCallback)register_in_3gpp_network_ready, + ctx); g_free (command); return; } @@ -2783,7 +2773,6 @@ modem_3gpp_run_cs_registration_check (MMIfaceModem3gpp *self, "+CREG?", 10, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)registration_status_check_ready, result); } @@ -2805,7 +2794,6 @@ modem_3gpp_run_ps_registration_check (MMIfaceModem3gpp *self, "+CGREG?", 10, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)registration_status_check_ready, result); } @@ -2850,7 +2838,7 @@ cleanup_registration_sequence_ready (MMBroadbandModem *self, { GError *error = NULL; - mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error); + mm_base_modem_at_command_full_finish (MM_BASE_MODEM (self), res, &error); if (error) { g_simple_async_result_take_error (ctx->result, error); g_simple_async_result_complete (ctx->result); @@ -2865,7 +2853,7 @@ cleanup_registration_sequence_ready (MMBroadbandModem *self, if (secondary) { /* Now use the same registration setup in secondary port, if any */ ctx->secondary_done = TRUE; - mm_base_modem_at_command_in_port ( + mm_base_modem_at_command_full ( MM_BASE_MODEM (self), secondary, ctx->command, @@ -2912,7 +2900,7 @@ modem_3gpp_cleanup_cs_registration (MMIfaceModem3gpp *self, modem_3gpp_cleanup_cs_registration); ctx->command = g_strdup ("+CREG=0"); - mm_base_modem_at_command_in_port ( + mm_base_modem_at_command_full ( MM_BASE_MODEM (self), mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)), ctx->command, @@ -2937,7 +2925,7 @@ modem_3gpp_cleanup_ps_registration (MMIfaceModem3gpp *self, modem_3gpp_cleanup_cs_registration); ctx->command = g_strdup ("+CGREG=0"); - mm_base_modem_at_command_in_port ( + mm_base_modem_at_command_full ( MM_BASE_MODEM (self), mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)), ctx->command, @@ -3022,7 +3010,7 @@ setup_registration_sequence_ready (MMBroadbandModem *self, GError *error = NULL; if (ctx->secondary_done) { - mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error); + mm_base_modem_at_command_full_finish (MM_BASE_MODEM (self), res, &error); if (error) { g_simple_async_result_take_error (ctx->result, error); g_simple_async_result_complete (ctx->result); @@ -3047,13 +3035,13 @@ setup_registration_sequence_ready (MMBroadbandModem *self, if (secondary) { /* Now use the same registration setup in secondary port, if any */ ctx->secondary_done = TRUE; - mm_base_modem_at_command_in_port ( + mm_base_modem_at_command_full ( MM_BASE_MODEM (self), mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)), g_variant_get_string (command, NULL), 3, FALSE, - NULL, /* cancellable */ + NULL, /* cancellable */ (GAsyncReadyCallback)setup_registration_sequence_ready, ctx); return; @@ -3079,13 +3067,13 @@ modem_3gpp_setup_cs_registration (MMIfaceModem3gpp *self, callback, user_data, modem_3gpp_setup_cs_registration); - mm_base_modem_at_sequence_in_port ( + mm_base_modem_at_sequence_full ( MM_BASE_MODEM (self), mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)), cs_registration_sequence, NULL, /* response processor context */ NULL, /* response processor context free */ - NULL, /* cancellable */ + NULL, /* cancellable */ (GAsyncReadyCallback)setup_registration_sequence_ready, ctx); } @@ -3102,13 +3090,13 @@ modem_3gpp_setup_ps_registration (MMIfaceModem3gpp *self, callback, user_data, modem_3gpp_setup_ps_registration); - mm_base_modem_at_sequence_in_port ( + mm_base_modem_at_sequence_full ( MM_BASE_MODEM (self), mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)), ps_registration_sequence, NULL, /* response processor context */ NULL, /* response processor context free */ - NULL, /* cancellable */ + NULL, /* cancellable */ (GAsyncReadyCallback)setup_registration_sequence_ready, ctx); } @@ -3159,7 +3147,6 @@ modem_3gpp_ussd_cancel (MMIfaceModem3gppUssd *self, "+CUSD=2", 3, TRUE, - NULL, /* cancellable */ (GAsyncReadyCallback)cancel_command_ready, result); } @@ -3248,7 +3235,6 @@ modem_3gpp_ussd_send (MMIfaceModem3gppUssd *self, at_command, 3, TRUE, - NULL, /* cancellable */ (GAsyncReadyCallback)ussd_send_command_ready, result); g_free (at_command); @@ -3592,7 +3578,6 @@ modem_3gpp_ussd_disable_unsolicited_result_codes (MMIfaceModem3gppUssd *self, "+CUSD=0", 3, TRUE, - NULL, /* cancellable */ (GAsyncReadyCallback)urc_enable_disable_ready, result); } @@ -3613,7 +3598,6 @@ modem_3gpp_ussd_enable_unsolicited_result_codes (MMIfaceModem3gppUssd *self, "+CUSD=1", 3, TRUE, - NULL, /* cancellable */ (GAsyncReadyCallback)urc_enable_disable_ready, result); } @@ -3666,7 +3650,6 @@ modem_3gpp_ussd_check_support (MMIfaceModem3gppUssd *self, "+CUSD=?", 3, TRUE, - NULL, /* cancellable */ (GAsyncReadyCallback)cusd_format_check_ready, result); } @@ -3732,7 +3715,6 @@ modem_messaging_check_support (MMIfaceModemMessaging *self, "+CNMI=?", 3, TRUE, - NULL, /* cancellable */ (GAsyncReadyCallback)cnmi_format_check_ready, result); } @@ -3838,7 +3820,6 @@ modem_messaging_load_supported_storages (MMIfaceModemMessaging *self, "+CPMS=?", 3, TRUE, - NULL, /* cancellable */ (GAsyncReadyCallback)cpms_format_check_ready, result); } @@ -3894,7 +3875,6 @@ modem_messaging_set_preferred_storages (MMIfaceModemMessaging *self, cmd, 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)cpms_set_ready, result); g_free (cmd); @@ -3945,7 +3925,6 @@ set_preferred_sms_format (MMBroadbandModem *self, cmd, 3, TRUE, - NULL, /* cancellable */ (GAsyncReadyCallback)cmgf_set_ready, result); g_free (cmd); @@ -4012,7 +3991,6 @@ modem_messaging_setup_sms_format (MMIfaceModemMessaging *self, "+CMGF=?", 3, TRUE, - NULL, /* cancellable */ (GAsyncReadyCallback)cmgf_format_check_ready, result); } @@ -4133,7 +4111,6 @@ cmti_received (MMAtSerialPort *port, command, 10, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)sms_part_ready, ctx); g_free (command); @@ -4218,7 +4195,6 @@ modem_messaging_enable_unsolicited_events (MMIfaceModemMessaging *self, "+CNMI=2,1,2,1,0", 3, FALSE, - NULL, /* cancellable */ callback, user_data); } @@ -4524,7 +4500,6 @@ list_parts_storage_ready (MMBroadbandModem *self, "+CMGL=\"ALL\""), 20, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback) (MM_BROADBAND_MODEM (self)->priv->modem_messaging_sms_pdu_mode ? sms_pdu_part_list_ready : sms_text_part_list_ready), @@ -4587,7 +4562,6 @@ modem_cdma_load_esn (MMIfaceModemCdma *self, "+GSN", 3, TRUE, - NULL, /* cancellable */ callback, user_data); } @@ -5055,7 +5029,6 @@ qcdm_cdma_status_ready (MMQcdmSerialPort *port, "+CSS?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)css_query_ready, ctx); return; @@ -5121,7 +5094,6 @@ modem_cdma_get_cdma1x_serving_system (MMIfaceModemCdma *self, "+CSS?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)css_query_ready, ctx); } @@ -5191,7 +5163,6 @@ modem_cdma_get_service_status (MMIfaceModemCdma *self, "+CAD?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)cad_query_ready, result); } @@ -5340,7 +5311,6 @@ spservice_ready (MMIfaceModemCdma *self, "$SPERI?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)speri_ready, ctx); } @@ -5386,7 +5356,6 @@ modem_cdma_get_detailed_registration_state (MMIfaceModemCdma *self, "+SPSERVICE?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)spservice_ready, ctx); } @@ -5522,7 +5491,6 @@ spservice_check_ready (MMIfaceModemCdma *self, "$SPERI?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)speri_check_ready, ctx); } @@ -5558,7 +5526,6 @@ modem_cdma_setup_registration_checks (MMIfaceModemCdma *self, "+SPSERVICE?", 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)spservice_check_ready, ctx); } @@ -6516,18 +6483,19 @@ initialize_step (InitializeContext *ctx) } ctx->close_port = TRUE; + /* TODO: This two commands are the only ones not subclassable; should + * change that. */ + /* Try to disable echo */ - mm_base_modem_at_command_in_port_ignore_reply ( - MM_BASE_MODEM (ctx->self), - ctx->port, - "E0", - 3); + mm_base_modem_at_command_full (MM_BASE_MODEM (ctx->self), + ctx->port, + "E0", 3, + FALSE, NULL, NULL, NULL); /* Try to get extended errors */ - mm_base_modem_at_command_in_port_ignore_reply ( - MM_BASE_MODEM (ctx->self), - ctx->port, - "+CMEE=1", - 3); + mm_base_modem_at_command_full (MM_BASE_MODEM (ctx->self), + ctx->port, + "+CMEE=1", 3, + FALSE, NULL, NULL, NULL); /* Fall down to next step */ ctx->step++; } diff --git a/src/mm-sim.c b/src/mm-sim.c index fbb20752..e7a0b511 100644 --- a/src/mm-sim.c +++ b/src/mm-sim.c @@ -130,7 +130,6 @@ change_pin (MMSim *self, command, 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)change_pin_ready, result); g_free (command); @@ -299,7 +298,6 @@ enable_pin (MMSim *self, command, 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)enable_pin_ready, result); g_free (command); @@ -470,7 +468,6 @@ common_send_pin_puk (MMSim *self, command, 3, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)send_pin_puk_ready, result); g_free (command); @@ -1068,7 +1065,6 @@ load_sim_identifier (MMSim *self, "+CRSM=176,12258,0,0,10", 20, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)load_sim_identifier_command_ready, g_simple_async_result_new (G_OBJECT (self), callback, @@ -1108,7 +1104,6 @@ load_imsi (MMSim *self, "+CIMI", 3, TRUE, - NULL, /* cancellable */ (GAsyncReadyCallback)load_imsi_command_ready, g_simple_async_result_new (G_OBJECT (self), callback, @@ -1246,7 +1241,6 @@ load_operator_identifier (MMSim *self, "+CRSM=176,28589,0,0,4", 10, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)load_operator_identifier_command_ready, g_simple_async_result_new (G_OBJECT (self), callback, @@ -1358,7 +1352,6 @@ load_operator_name (MMSim *self, "+CRSM=176,28486,0,0,17", 10, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)load_operator_name_command_ready, g_simple_async_result_new (G_OBJECT (self), callback, diff --git a/src/mm-sms.c b/src/mm-sms.c index 66f1fd4f..849722fe 100644 --- a/src/mm-sms.c +++ b/src/mm-sms.c @@ -568,7 +568,6 @@ sms_store (MMSms *self, cmd, 10, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback) store_ready, ctx); g_free (cmd); @@ -645,7 +644,6 @@ sms_send_generic (SmsSendContext *ctx) cmd, 10, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)send_generic_ready, ctx); g_free (cmd); @@ -683,7 +681,6 @@ sms_send_from_storage (SmsSendContext *ctx) cmd, 10, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)send_from_storage_ready, ctx); g_free (cmd); @@ -814,7 +811,6 @@ delete_next_part (SmsDeletePartsContext *ctx) cmd, 10, FALSE, - NULL, /* cancellable */ (GAsyncReadyCallback)delete_part_ready, ctx); g_free (cmd); |