static NMActStageReturn act_stage1_prepare (NMModem *modem, NMActRequest *req, GPtrArray **out_hints, const char **out_setting_name, NMDeviceStateReason *reason) { NMModemGsm *self = NM_MODEM_GSM (modem); NMModemGsmPrivate *priv = NM_MODEM_GSM_GET_PRIVATE (self); NMConnection *connection; connection = nm_act_request_get_connection (req); g_assert (connection); *out_setting_name = nm_connection_need_secrets (connection, out_hints); if (!*out_setting_name) { gboolean enabled = nm_modem_get_mm_enabled (modem); if (priv->connect_properties) g_hash_table_destroy (priv->connect_properties); priv->connect_properties = create_connect_properties (connection); if (enabled) do_connect (self); else do_enable (self); } else { /* NMModem will handle requesting secrets... */ } return NM_ACT_STAGE_RETURN_POSTPONE; }
static void stage1_enable_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data) { NMModemGsm *self = NM_MODEM_GSM (user_data); NMDeviceStateReason reason; GError *error = NULL; if (dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) do_connect (self); else { nm_log_warn (LOGD_MB, "GSM modem enable failed: (%d) %s", error ? error->code : -1, error && error->message ? error->message : "(unknown)"); if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_PIN)) handle_enable_pin_required (self); else { /* try to translate the error reason */ reason = translate_mm_error (error); if (reason == NM_DEVICE_STATE_REASON_UNKNOWN) reason = NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED; g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, reason); } g_error_free (error); } }
static void stage1_pin_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data) { NMModemGsm *self = NM_MODEM_GSM (user_data); NMModemGsmPrivate *priv = NM_MODEM_GSM_GET_PRIVATE (self); NMDeviceStateReason reason; GError *error = NULL; if (dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) { /* Success; try to enable the modem again. Wait a few seconds to ensure * that ModemManager is ready for the enable right after the unlock. */ if (priv->enable_delay_id == 0) priv->enable_delay_id = g_timeout_add_seconds (4, (GSourceFunc) do_enable, self); } else { nm_log_warn (LOGD_MB, "GSM PIN unlock failed: (%d) %s", error ? error->code : -1, error && error->message ? error->message : "(unknown)"); /* try to translate the error reason */ reason = translate_mm_error (error); if (reason == NM_DEVICE_STATE_REASON_UNKNOWN) reason = NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED; g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, reason); g_error_free (error); } }
static void stage1_prepare_done (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data) { NMModemGsm *self = NM_MODEM_GSM (user_data); NMModemGsmPrivate *priv = NM_MODEM_GSM_GET_PRIVATE (self); GError *error = NULL; priv->call = NULL; if (priv->connect_properties) { g_hash_table_destroy (priv->connect_properties); priv->connect_properties = NULL; } if (dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID)) g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, TRUE, NM_DEVICE_STATE_REASON_NONE); else { if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_PIN)) ask_for_pin (self, FALSE); else if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_WRONG)) ask_for_pin (self, TRUE); else { nm_log_warn (LOGD_MB, "GSM connection failed: (%d) %s", error ? error->code : -1, error && error->message ? error->message : "(unknown)"); g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, translate_mm_error (error)); } g_error_free (error); } }
static void dispose (GObject *object) { NMModemGsm *self = NM_MODEM_GSM (object); NMModemGsmPrivate *priv = NM_MODEM_GSM_GET_PRIVATE (self); if (priv->connect_properties) g_hash_table_destroy (priv->connect_properties); G_OBJECT_CLASS (nm_modem_gsm_parent_class)->dispose (object); }
static void stage1_pin_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data) { NMModemGsm *self = NM_MODEM_GSM (user_data); NMDeviceStateReason reason; GError *error = NULL; if (dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) { /* Success; go back and try the enable again */ do_enable (self); } else { nm_log_warn (LOGD_MB, "GSM PIN unlock failed: (%d) %s", error ? error->code : -1, error && error->message ? error->message : "(unknown)"); /* try to translate the error reason */ reason = translate_mm_error (error); if (reason == NM_DEVICE_STATE_REASON_UNKNOWN) reason = NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED; g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, reason); g_error_free (error); } }