summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-02-09 03:25:48 -0600
committerDan Williams <dcbw@redhat.com>2014-02-21 09:45:06 -0600
commit4611aec5c2412464184be16b736168d1bc73f2d3 (patch)
treed9d36823b8d1a64a35e57e4dbfb5058eebe46c45
parent12787f85656830be55296e96eb4553f3f301ab69 (diff)
downloadNetworkManager-4611aec5c2412464184be16b736168d1bc73f2d3.tar.gz
mobile: consolidate secrets requests into NMDeviceModem
Both old and new ModemManager classes were doing the same thing, so consolidate that into the superclass and save some LoC.
-rw-r--r--src/modem-manager/nm-modem-broadband.c55
-rw-r--r--src/modem-manager/nm-modem-old.c30
-rw-r--r--src/modem-manager/nm-modem.c56
-rw-r--r--src/modem-manager/nm-modem.h4
4 files changed, 61 insertions, 84 deletions
diff --git a/src/modem-manager/nm-modem-broadband.c b/src/modem-manager/nm-modem-broadband.c
index 032557de99..611931f6b9 100644
--- a/src/modem-manager/nm-modem-broadband.c
+++ b/src/modem-manager/nm-modem-broadband.c
@@ -296,47 +296,34 @@ create_gsm_connect_properties (NMConnection *connection)
static NMActStageReturn
act_stage1_prepare (NMModem *_self,
- NMActRequest *req,
- GPtrArray **out_hints,
- const char **out_setting_name,
+ NMConnection *connection,
NMDeviceStateReason *reason)
{
NMModemBroadband *self = NM_MODEM_BROADBAND (_self);
- NMConnection *connection;
+ MMModemCapability caps;
- connection = nm_act_request_get_connection (req);
- g_assert (connection);
-
- *out_setting_name = nm_connection_need_secrets (connection, out_hints);
- if (!*out_setting_name) {
- MMModemCapability caps;
-
- caps = mm_modem_get_current_capabilities (self->priv->modem_iface);
-
- g_clear_object (&self->priv->connect_properties);
+ g_clear_object (&self->priv->connect_properties);
- if (MODEM_CAPS_3GPP (caps))
- self->priv->connect_properties = create_gsm_connect_properties (connection);
- else if (MODEM_CAPS_3GPP2 (caps))
- self->priv->connect_properties = create_cdma_connect_properties (connection);
- else {
- nm_log_warn (LOGD_MB, "(%s) not a mobile broadband modem",
- nm_modem_get_uid (NM_MODEM (self)));
- return NM_ACT_STAGE_RETURN_FAILURE;
- }
+ caps = mm_modem_get_current_capabilities (self->priv->modem_iface);
+ if (MODEM_CAPS_3GPP (caps))
+ self->priv->connect_properties = create_gsm_connect_properties (connection);
+ else if (MODEM_CAPS_3GPP2 (caps))
+ self->priv->connect_properties = create_cdma_connect_properties (connection);
+ else {
+ nm_log_warn (LOGD_MB, "(%s) not a mobile broadband modem",
+ nm_modem_get_uid (NM_MODEM (self)));
+ return NM_ACT_STAGE_RETURN_FAILURE;
+ }
- if (!self->priv->simple_iface)
- self->priv->simple_iface = mm_object_get_modem_simple (self->priv->modem_object);
+ if (!self->priv->simple_iface)
+ self->priv->simple_iface = mm_object_get_modem_simple (self->priv->modem_object);
- g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (self->priv->simple_iface), MODEM_CONNECT_TIMEOUT_SECS * 1000);
- mm_modem_simple_connect (self->priv->simple_iface,
- self->priv->connect_properties,
- NULL,
- (GAsyncReadyCallback)connect_ready,
- g_object_ref (self));
- } else {
- /* NMModem will handle requesting secrets... */
- }
+ g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (self->priv->simple_iface), MODEM_CONNECT_TIMEOUT_SECS * 1000);
+ mm_modem_simple_connect (self->priv->simple_iface,
+ self->priv->connect_properties,
+ NULL,
+ (GAsyncReadyCallback)connect_ready,
+ g_object_ref (self));
return NM_ACT_STAGE_RETURN_POSTPONE;
}
diff --git a/src/modem-manager/nm-modem-old.c b/src/modem-manager/nm-modem-old.c
index 866a94a122..f8bbcebb85 100644
--- a/src/modem-manager/nm-modem-old.c
+++ b/src/modem-manager/nm-modem-old.c
@@ -538,33 +538,21 @@ G_GNUC_END_IGNORE_DEPRECATIONS
static NMActStageReturn
act_stage1_prepare (NMModem *modem,
- NMActRequest *req,
- GPtrArray **out_hints,
- const char **out_setting_name,
+ NMConnection *connection,
NMDeviceStateReason *reason)
{
NMModemOld *self = NM_MODEM_OLD (modem);
NMModemOldPrivate *priv = NM_MODEM_OLD_GET_PRIVATE (self);
- NMConnection *connection;
+ gboolean enabled = nm_modem_get_mm_enabled (modem);
- 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 (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... */
- }
+ if (enabled)
+ do_connect (self);
+ else
+ do_enable (self);
return NM_ACT_STAGE_RETURN_POSTPONE;
}
diff --git a/src/modem-manager/nm-modem.c b/src/modem-manager/nm-modem.c
index 77ab710c7f..f427142e2b 100644
--- a/src/modem-manager/nm-modem.c
+++ b/src/modem-manager/nm-modem.c
@@ -416,9 +416,7 @@ nm_modem_get_secrets (NMModem *self,
static NMActStageReturn
act_stage1_prepare (NMModem *modem,
- NMActRequest *req,
- GPtrArray **out_hints,
- const char **out_setting_name,
+ NMConnection *connection,
NMDeviceStateReason *reason)
{
*reason = NM_DEVICE_STATE_REASON_UNKNOWN;
@@ -435,37 +433,43 @@ nm_modem_act_stage1_prepare (NMModem *self,
GPtrArray *hints = NULL;
const char *setting_name = NULL;
NMSettingsGetSecretsFlags flags = NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION;
+ NMConnection *connection;
if (priv->act_request)
g_object_unref (priv->act_request);
priv->act_request = g_object_ref (req);
- ret = NM_MODEM_GET_CLASS (self)->act_stage1_prepare (self,
- req,
- &hints,
- &setting_name,
- reason);
- if ((ret == NM_ACT_STAGE_RETURN_POSTPONE) && setting_name) {
- if (priv->secrets_tries++)
- flags |= NM_SETTINGS_GET_SECRETS_FLAG_REQUEST_NEW;
-
- priv->secrets_id = nm_act_request_get_secrets (req,
- setting_name,
- flags,
- hints ? g_ptr_array_index (hints, 0) : NULL,
- modem_secrets_cb,
- self);
- if (priv->secrets_id)
- g_signal_emit (self, signals[AUTH_REQUESTED], 0);
- else {
- *reason = NM_DEVICE_STATE_REASON_NO_SECRETS;
- ret = NM_ACT_STAGE_RETURN_FAILURE;
- }
+ connection = nm_act_request_get_connection (req);
+ g_assert (connection);
- if (hints)
- g_ptr_array_free (hints, TRUE);
+ setting_name = nm_connection_need_secrets (connection, &hints);
+ if (!setting_name) {
+ /* Ready to connect */
+ g_assert (!hints);
+ return NM_MODEM_GET_CLASS (self)->act_stage1_prepare (self, connection, reason);
}
+ /* Secrets required... */
+ if (priv->secrets_tries++)
+ flags |= NM_SETTINGS_GET_SECRETS_FLAG_REQUEST_NEW;
+
+ priv->secrets_id = nm_act_request_get_secrets (req,
+ setting_name,
+ flags,
+ hints ? g_ptr_array_index (hints, 0) : NULL,
+ modem_secrets_cb,
+ self);
+ if (priv->secrets_id) {
+ g_signal_emit (self, signals[AUTH_REQUESTED], 0);
+ ret = NM_ACT_STAGE_RETURN_POSTPONE;
+ } else {
+ *reason = NM_DEVICE_STATE_REASON_NO_SECRETS;
+ ret = NM_ACT_STAGE_RETURN_FAILURE;
+ }
+
+ if (hints)
+ g_ptr_array_free (hints, TRUE);
+
return ret;
}
diff --git a/src/modem-manager/nm-modem.h b/src/modem-manager/nm-modem.h
index 8d754eb35c..531c79388e 100644
--- a/src/modem-manager/nm-modem.h
+++ b/src/modem-manager/nm-modem.h
@@ -95,9 +95,7 @@ typedef struct {
GError **error);
NMActStageReturn (*act_stage1_prepare) (NMModem *modem,
- NMActRequest *req,
- GPtrArray **out_hints,
- const char **out_setting_name,
+ NMConnection *connection,
NMDeviceStateReason *reason);
NMActStageReturn (*static_stage3_ip4_config_start) (NMModem *self,