diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2013-06-03 12:44:40 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-06-05 19:15:15 +0200 |
commit | 5b080915200d0ba5de28d50bb088eba0aef9b362 (patch) | |
tree | 7e7d8a785ecd9c05e1249bd4659963ae95a59a64 | |
parent | b41278c423cb81547c65da46057912ad9372715d (diff) |
api,introspection: Simple.Connect() won't change neither bands nor allowed modes
We won't allow changing modes or bands through Simple.Connect(). Applications
should instead look at the corresponding SupportedBands or SupportedModes, and
then use SetCurrentBands() or SetCurrentModes() explicitly.
-rw-r--r-- | docs/reference/libmm-glib/libmm-glib-sections.txt | 4 | ||||
-rw-r--r-- | introspection/org.freedesktop.ModemManager1.Modem.Simple.xml | 21 | ||||
-rw-r--r-- | libmm-glib/mm-simple-connect-properties.c | 221 | ||||
-rw-r--r-- | libmm-glib/mm-simple-connect-properties.h | 12 | ||||
-rw-r--r-- | src/mm-iface-modem-simple.c | 160 |
5 files changed, 1 insertions, 417 deletions
diff --git a/docs/reference/libmm-glib/libmm-glib-sections.txt b/docs/reference/libmm-glib/libmm-glib-sections.txt index 36a80f60..2af58403 100644 --- a/docs/reference/libmm-glib/libmm-glib-sections.txt +++ b/docs/reference/libmm-glib/libmm-glib-sections.txt @@ -639,10 +639,6 @@ mm_simple_connect_properties_get_pin mm_simple_connect_properties_set_pin mm_simple_connect_properties_get_operator_id mm_simple_connect_properties_set_operator_id -mm_simple_connect_properties_get_current_bands -mm_simple_connect_properties_set_current_bands -mm_simple_connect_properties_get_current_modes -mm_simple_connect_properties_set_current_modes mm_simple_connect_properties_get_apn mm_simple_connect_properties_set_apn mm_simple_connect_properties_get_allowed_auth diff --git a/introspection/org.freedesktop.ModemManager1.Modem.Simple.xml b/introspection/org.freedesktop.ModemManager1.Modem.Simple.xml index ae50387f..1e7d6acc 100644 --- a/introspection/org.freedesktop.ModemManager1.Modem.Simple.xml +++ b/introspection/org.freedesktop.ModemManager1.Modem.Simple.xml @@ -52,27 +52,6 @@ given as a string value (signature <literal>"s"</literal>). </listitem> </varlistentry> - <varlistentry><term><literal>"current-bands"</literal></term> - <listitem> - List of <link linkend="MMModemBand">MMModemBand</link> values, - to specify all the bands allowed in the modem, given as a list of - unsigned integer values (signature <literal>"au"</literal>). - </listitem> - </varlistentry> - <varlistentry><term><literal>"allowed-modes"</literal></term> - <listitem> - Bitmask of <link linkend="MMModemMode">MMModemMode</link> values, - to specify all the modes allowed in the modem, given as an - unsigned integer value (signature <literal>"u"</literal>). - </listitem> - </varlistentry> - <varlistentry><term><literal>"preferred-mode"</literal></term> - <listitem> - Specific <link linkend="MMModemMode">MMModemMode</link> preferred - among the ones allowed, if any. Given as an unsigned integer value - (signature <literal>"u"</literal>). - </listitem> - </varlistentry> <varlistentry><term><literal>"apn"</literal></term> <listitem> For GSM/UMTS and LTE devices the APN to use, diff --git a/libmm-glib/mm-simple-connect-properties.c b/libmm-glib/mm-simple-connect-properties.c index 9b956b70..f57cc4f0 100644 --- a/libmm-glib/mm-simple-connect-properties.c +++ b/libmm-glib/mm-simple-connect-properties.c @@ -35,23 +35,12 @@ G_DEFINE_TYPE (MMSimpleConnectProperties, mm_simple_connect_properties, G_TYPE_O #define PROPERTY_PIN "pin" #define PROPERTY_OPERATOR_ID "operator-id" -#define PROPERTY_CURRENT_BANDS "current-bands" -#define PROPERTY_ALLOWED_MODES "allowed-modes" -#define PROPERTY_PREFERRED_MODE "preferred-mode" struct _MMSimpleConnectPropertiesPrivate { /* PIN */ gchar *pin; /* Operator ID */ gchar *operator_id; - /* Bands */ - gboolean current_bands_set; - MMModemBand *current_bands; - guint n_current_bands; - /* Modes */ - gboolean current_modes_set; - MMModemMode allowed_modes; - MMModemMode preferred_mode; /* Bearer properties */ MMBearerProperties *bearer_properties; }; @@ -129,110 +118,6 @@ mm_simple_connect_properties_get_operator_id (MMSimpleConnectProperties *self) /*****************************************************************************/ /** - * mm_simple_connect_properties_set_current_bands: - * @self: a #MMSimpleConnectProperties. - * @bands: array of #MMModemBand values. - * @n_bands: number of elements in @bands. - * - * Sets the frequency bands to use. - */ -void -mm_simple_connect_properties_set_current_bands (MMSimpleConnectProperties *self, - const MMModemBand *bands, - guint n_bands) -{ - g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self)); - - g_free (self->priv->current_bands); - self->priv->n_current_bands = n_bands; - self->priv->current_bands = g_new (MMModemBand, self->priv->n_current_bands); - memcpy (self->priv->current_bands, - bands, - sizeof (MMModemBand) * self->priv->n_current_bands); - self->priv->current_bands_set = TRUE; -} - -/** - * mm_simple_connect_properties_get_current_bands: - * @self: a #MMSimpleConnectProperties. - * @bands: (out): location for the array of #MMModemBand values. Do not free the returned value, it is owned by @self. - * @n_bands: (out) number of elements in @bands. - * - * Gets the frequency bands to use. - * - * Returns: %TRUE if @bands is set, %FALSE otherwise. - */ -gboolean -mm_simple_connect_properties_get_current_bands (MMSimpleConnectProperties *self, - const MMModemBand **bands, - guint *n_bands) -{ - g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), FALSE); - g_return_val_if_fail (bands != NULL, FALSE); - g_return_val_if_fail (n_bands != NULL, FALSE); - - if (self->priv->current_bands_set) { - *bands = self->priv->current_bands; - *n_bands = self->priv->n_current_bands; - return TRUE; - } - - return FALSE; -} - -/*****************************************************************************/ - -/** - * mm_simple_connect_properties_set_current_modes: - * @self: a #MMSimpleConnectProperties. - * @allowed: bitmask of #MMModemMode values specifying which are allowed. - * @preferred: a #MMModemMode value, specifying which of the ones in @allowed is preferred, if any. - * - * Sets the modes allowed to use, and which of them is preferred. - */ -void -mm_simple_connect_properties_set_current_modes (MMSimpleConnectProperties *self, - MMModemMode allowed, - MMModemMode preferred) -{ - g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self)); - - self->priv->allowed_modes = allowed; - self->priv->preferred_mode = preferred; - self->priv->current_modes_set = TRUE; -} - -/** - * mm_simple_connect_properties_get_current_modes: - * @self: a #MMSimpleConnectProperties. - * @allowed: (out): location for the bitmask of #MMModemMode values specifying which are allowed. - * @preferred: (out): loction for a #MMModemMode value, specifying which of the ones in @allowed is preferred, if any. - * - * Gets the modes allowed to use, and which of them is preferred. - * - * Returns: %TRUE if @allowed and @preferred are set, %FALSE otherwise. - */ -gboolean -mm_simple_connect_properties_get_current_modes (MMSimpleConnectProperties *self, - MMModemMode *allowed, - MMModemMode *preferred) -{ - g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), FALSE); - g_return_val_if_fail (allowed != NULL, FALSE); - g_return_val_if_fail (preferred != NULL, FALSE); - - if (self->priv->current_modes_set) { - *allowed = self->priv->allowed_modes; - *preferred = self->priv->preferred_mode; - return TRUE; - } - - return FALSE; -} - -/*****************************************************************************/ - -/** * mm_simple_connect_properties_set_apn: * @self: a #MMSimpleConnectProperties. * @apn: Name of the access point. @@ -517,24 +402,6 @@ mm_simple_connect_properties_get_dictionary (MMSimpleConnectProperties *self) PROPERTY_OPERATOR_ID, g_variant_new_string (self->priv->operator_id)); - if (self->priv->current_bands) - g_variant_builder_add (&builder, - "{sv}", - PROPERTY_CURRENT_BANDS, - mm_common_bands_array_to_variant (self->priv->current_bands, - self->priv->n_current_bands)); - - if (self->priv->current_modes_set) { - g_variant_builder_add (&builder, - "{sv}", - PROPERTY_ALLOWED_MODES, - g_variant_new_uint32 (self->priv->allowed_modes)); - g_variant_builder_add (&builder, - "{sv}", - PROPERTY_PREFERRED_MODE, - g_variant_new_uint32 (self->priv->preferred_mode)); - } - /* Merge dictionaries */ bearer_properties_dictionary = mm_bearer_properties_get_dictionary (self->priv->bearer_properties); g_variant_iter_init (&iter, bearer_properties_dictionary); @@ -575,20 +442,7 @@ key_value_foreach (const gchar *key, mm_simple_connect_properties_set_pin (ctx->self, value); else if (g_str_equal (key, PROPERTY_OPERATOR_ID)) mm_simple_connect_properties_set_operator_id (ctx->self, value); - else if (g_str_equal (key, PROPERTY_CURRENT_BANDS)) { - MMModemBand *bands = NULL; - guint n_bands = 0; - - mm_common_get_bands_from_string (value, &bands, &n_bands, &ctx->error); - if (!ctx->error) { - mm_simple_connect_properties_set_current_bands (ctx->self, bands, n_bands); - g_free (bands); - } - } else if (g_str_equal (key, PROPERTY_ALLOWED_MODES)) { - ctx->allowed_modes_str = g_strdup (value); - } else if (g_str_equal (key, PROPERTY_PREFERRED_MODE)) { - ctx->preferred_mode_str = g_strdup (value); - } else { + else { ctx->error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS, "Invalid properties string, unexpected key '%s'", @@ -605,8 +459,6 @@ mm_simple_connect_properties_new_from_string (const gchar *str, ParseKeyValueContext ctx; ctx.error = NULL; - ctx.allowed_modes_str = NULL; - ctx.preferred_mode_str = NULL; ctx.self = mm_simple_connect_properties_new (); mm_common_parse_key_value_string (str, @@ -620,34 +472,6 @@ mm_simple_connect_properties_new_from_string (const gchar *str, g_object_unref (ctx.self); ctx.self = NULL; } - else if (ctx.allowed_modes_str || ctx.preferred_mode_str) { - MMModemMode allowed_modes; - MMModemMode preferred_mode = MM_MODEM_MODE_NONE; - - allowed_modes = (ctx.allowed_modes_str ? - mm_common_get_modes_from_string (ctx.allowed_modes_str, - &ctx.error) : - MM_MODEM_MODE_ANY); - - if (!ctx.error && ctx.preferred_mode_str) { - preferred_mode = mm_common_get_modes_from_string (ctx.preferred_mode_str, - &ctx.error); - } - - if (ctx.error) { - g_propagate_error (error, ctx.error); - g_object_unref (ctx.self); - ctx.self = NULL; - } else { - mm_simple_connect_properties_set_current_modes ( - ctx.self, - allowed_modes, - preferred_mode); - } - } - - g_free (ctx.allowed_modes_str); - g_free (ctx.preferred_mode_str); return ctx.self; } @@ -663,8 +487,6 @@ mm_simple_connect_properties_new_from_dictionary (GVariant *dictionary, gchar *key; GVariant *value; MMSimpleConnectProperties *self; - GVariant *allowed_modes_variant = NULL; - GVariant *preferred_mode_variant = NULL; self = mm_simple_connect_properties_new (); if (!dictionary) @@ -696,19 +518,6 @@ mm_simple_connect_properties_new_from_dictionary (GVariant *dictionary, mm_simple_connect_properties_set_operator_id ( self, g_variant_get_string (value, NULL)); - else if (g_str_equal (key, PROPERTY_CURRENT_BANDS)) { - GArray *array; - - array = mm_common_bands_variant_to_garray (value); - mm_simple_connect_properties_set_current_bands ( - self, - (MMModemBand *)array->data, - array->len); - g_array_unref (array); - } else if (g_str_equal (key, PROPERTY_ALLOWED_MODES)) - allowed_modes_variant = g_variant_ref (value); - else if (g_str_equal (key, PROPERTY_PREFERRED_MODE)) - preferred_mode_variant = g_variant_ref (value); else { /* Set inner error, will stop the loop */ inner_error = g_error_new (MM_CORE_ERROR, @@ -728,28 +537,6 @@ mm_simple_connect_properties_new_from_dictionary (GVariant *dictionary, g_object_unref (self); self = NULL; } - /* If we got allowed modes variant, check if we got preferred mode */ - else if (allowed_modes_variant) { - mm_simple_connect_properties_set_current_modes ( - self, - g_variant_get_uint32 (allowed_modes_variant), - (preferred_mode_variant ? - g_variant_get_uint32 (preferred_mode_variant) : - MM_MODEM_MODE_NONE)); - } - /* If we only got preferred mode, assume allowed is ANY */ - else if (preferred_mode_variant) { - mm_simple_connect_properties_set_current_modes ( - self, - MM_MODEM_MODE_ANY, - g_variant_get_uint32 (preferred_mode_variant)); - } - - /* Cleanup last things before exiting */ - if (allowed_modes_variant) - g_variant_unref (allowed_modes_variant); - if (preferred_mode_variant) - g_variant_unref (preferred_mode_variant); return self; } @@ -779,11 +566,6 @@ mm_simple_connect_properties_init (MMSimpleConnectProperties *self) /* Some defaults */ self->priv->bearer_properties = mm_bearer_properties_new (); - self->priv->allowed_modes = MM_MODEM_MODE_ANY; - self->priv->preferred_mode = MM_MODEM_MODE_NONE; - self->priv->current_bands = g_new (MMModemBand, 1); - self->priv->current_bands[0] = MM_MODEM_BAND_UNKNOWN; - self->priv->n_current_bands = 1; } static void @@ -793,7 +575,6 @@ finalize (GObject *object) g_free (self->priv->pin); g_free (self->priv->operator_id); - g_free (self->priv->current_bands); g_object_unref (self->priv->bearer_properties); G_OBJECT_CLASS (mm_simple_connect_properties_parent_class)->finalize (object); diff --git a/libmm-glib/mm-simple-connect-properties.h b/libmm-glib/mm-simple-connect-properties.h index 30a06fd9..e9c09ae3 100644 --- a/libmm-glib/mm-simple-connect-properties.h +++ b/libmm-glib/mm-simple-connect-properties.h @@ -63,12 +63,6 @@ void mm_simple_connect_properties_set_pin (MMSimpleConnectProperties * const gchar *pin); void mm_simple_connect_properties_set_operator_id (MMSimpleConnectProperties *self, const gchar *operator_id); -void mm_simple_connect_properties_set_current_bands (MMSimpleConnectProperties *self, - const MMModemBand *bands, - guint n_bands); -void mm_simple_connect_properties_set_current_modes (MMSimpleConnectProperties *self, - MMModemMode allowed, - MMModemMode preferred); void mm_simple_connect_properties_set_apn (MMSimpleConnectProperties *self, const gchar *apn); void mm_simple_connect_properties_set_allowed_auth (MMSimpleConnectProperties *self, @@ -86,12 +80,6 @@ void mm_simple_connect_properties_set_number (MMSimpleConnectProperties * const gchar *mm_simple_connect_properties_get_pin (MMSimpleConnectProperties *self); const gchar *mm_simple_connect_properties_get_operator_id (MMSimpleConnectProperties *self); -gboolean mm_simple_connect_properties_get_current_bands (MMSimpleConnectProperties *self, - const MMModemBand **bands, - guint *n_bands); -gboolean mm_simple_connect_properties_get_current_modes (MMSimpleConnectProperties *self, - MMModemMode *allowed, - MMModemMode *preferred); const gchar *mm_simple_connect_properties_get_apn (MMSimpleConnectProperties *self); MMBearerAllowedAuth mm_simple_connect_properties_get_allowed_auth (MMSimpleConnectProperties *self); const gchar *mm_simple_connect_properties_get_user (MMSimpleConnectProperties *self); diff --git a/src/mm-iface-modem-simple.c b/src/mm-iface-modem-simple.c index 5d1e1b21..bb850a18 100644 --- a/src/mm-iface-modem-simple.c +++ b/src/mm-iface-modem-simple.c @@ -174,8 +174,6 @@ typedef enum { CONNECTION_STEP_WAIT_FOR_INITIALIZED, CONNECTION_STEP_ENABLE, CONNECTION_STEP_WAIT_FOR_ENABLED, - CONNECTION_STEP_CURRENT_MODES, - CONNECTION_STEP_CURRENT_BANDS, CONNECTION_STEP_REGISTER, CONNECTION_STEP_BEARER, CONNECTION_STEP_CONNECT, @@ -187,8 +185,6 @@ typedef struct { GDBusMethodInvocation *invocation; MMIfaceModemSimple *self; ConnectionStep step; - gulong state_changed_id; - guint state_changed_wait_id; /* Expected input properties */ GVariant *dictionary; @@ -201,9 +197,6 @@ typedef struct { static void connection_context_free (ConnectionContext *ctx) { - g_assert (ctx->state_changed_id == 0); - g_assert (ctx->state_changed_wait_id == 0); - g_variant_unref (ctx->dictionary); if (ctx->properties) g_object_unref (ctx->properties); @@ -274,82 +267,6 @@ register_in_3gpp_or_cdma_network_ready (MMIfaceModemSimple *self, connection_step (ctx); } -static gboolean -after_set_current_modes_timeout_cb (ConnectionContext *ctx) -{ - /* Allowed modes set... almost there! */ - ctx->step++; - connection_step (ctx); - return FALSE; -} - -static void -set_current_modes_ready (MMBaseModem *self, - GAsyncResult *res, - ConnectionContext *ctx) -{ - GError *error = NULL; - - if (!mm_iface_modem_set_current_modes_finish (MM_IFACE_MODEM (self), res, &error)) { - if (g_error_matches (error, - MM_CORE_ERROR, - MM_CORE_ERROR_UNSUPPORTED)) { - g_error_free (error); - /* If setting bands is unsupported, keep on without sleep */ - ctx->step++; - connection_step (ctx); - } else { - g_dbus_method_invocation_take_error (ctx->invocation, error); - connection_context_free (ctx); - } - return; - } - - /* Setting allowed modes will reset the current registration, so we'll need - * a couple of seconds to settle down. This sleep time just makes sure that - * the modem has enough time to report being unregistered. */ - mm_dbg ("Will wait to settle down after updating allowed modes"); - g_timeout_add_seconds (2, (GSourceFunc)after_set_current_modes_timeout_cb, ctx); -} - -static gboolean -after_set_current_bands_timeout_cb (ConnectionContext *ctx) -{ - /* Bands set... almost there! */ - ctx->step++; - connection_step (ctx); - return FALSE; -} - -static void -set_current_bands_ready (MMBaseModem *self, - GAsyncResult *res, - ConnectionContext *ctx) -{ - GError *error = NULL; - - if (!mm_iface_modem_set_current_bands_finish (MM_IFACE_MODEM (self), res, &error)) { - if (g_error_matches (error, - MM_CORE_ERROR, - MM_CORE_ERROR_UNSUPPORTED)) { - g_error_free (error); - /* If setting bands is unsupported, keep on without sleep */ - ctx->step++; - connection_step (ctx); - } else { - g_dbus_method_invocation_take_error (ctx->invocation, error); - connection_context_free (ctx); - } - return; - } - - /* Setting bands will reset the current registration, so we'll need a couple - * of seconds to settle down. This sleep time just makes sure that the modem - * has enough time to report being unregistered. */ - mm_dbg ("Will wait to settle down after updating bands"); - g_timeout_add_seconds (2, (GSourceFunc)after_set_current_bands_timeout_cb, ctx); -} - static void wait_for_enabled_ready (MMIfaceModem *self, GAsyncResult *res, @@ -556,59 +473,6 @@ connection_step (ConnectionContext *ctx) ctx); return; - case CONNECTION_STEP_CURRENT_MODES: { - MMModemMode allowed_modes = MM_MODEM_MODE_ANY; - MMModemMode preferred_mode = MM_MODEM_MODE_NONE; - - mm_info ("Simple connect state (%d/%d): Current modes", - ctx->step, CONNECTION_STEP_LAST); - - /* Don't set modes unless explicitly requested to do so */ - if (mm_simple_connect_properties_get_current_modes (ctx->properties, - &allowed_modes, - &preferred_mode)) { - mm_iface_modem_set_current_modes (MM_IFACE_MODEM (ctx->self), - allowed_modes, - preferred_mode, - (GAsyncReadyCallback)set_current_modes_ready, - ctx); - return; - } - - /* Fall down to next step */ - ctx->step++; - } - - case CONNECTION_STEP_CURRENT_BANDS: { - const MMModemBand *bands = NULL; - guint n_bands = 0; - - mm_info ("Simple connect state (%d/%d): Current Bands", - ctx->step, CONNECTION_STEP_LAST); - - /* Don't set bands unless explicitly requested to do so */ - if (mm_simple_connect_properties_get_current_bands (ctx->properties, &bands, &n_bands)) { - GArray *array; - guint i; - - if (bands && *bands) { - array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), n_bands); - for (i = 0; i < n_bands; i++) - g_array_insert_val (array, i, bands[i]); - - mm_iface_modem_set_current_bands (MM_IFACE_MODEM (ctx->self), - array, - (GAsyncReadyCallback)set_current_bands_ready, - ctx); - g_array_unref (array); - return; - } - } - - /* Fall down to next step */ - ctx->step++; - } - case CONNECTION_STEP_REGISTER: mm_info ("Simple connect state (%d/%d): Register", ctx->step, CONNECTION_STEP_LAST); @@ -778,10 +642,6 @@ connect_auth_ready (MMBaseModem *self, /* Log about all the parameters being used for the simple connect */ { - const MMModemBand *bands; - guint n_bands; - MMModemMode allowed; - MMModemMode preferred; MMBearerAllowedAuth allowed_auth; gchar *str; MMBearerIpFamily ip_family; @@ -790,25 +650,6 @@ connect_auth_ready (MMBaseModem *self, mm_dbg (" PIN: %s", VALIDATE_UNSPECIFIED (mm_simple_connect_properties_get_pin (ctx->properties))); - if (mm_simple_connect_properties_get_current_modes (ctx->properties, &allowed, &preferred)) { - str = mm_modem_mode_build_string_from_mask (allowed); - mm_dbg (" Allowed mode: %s", str); - g_free (str); - str = mm_modem_mode_build_string_from_mask (preferred); - mm_dbg (" Preferred mode: %s", str); - g_free (str); - } else { - mm_dbg (" Allowed mode: %s", VALIDATE_UNSPECIFIED (NULL)); - mm_dbg (" Preferred mode: %s", VALIDATE_UNSPECIFIED (NULL)); - } - - if (mm_simple_connect_properties_get_current_bands (ctx->properties, &bands, &n_bands)) { - str = mm_common_build_bands_string (bands, n_bands); - mm_dbg (" Bands: %s", str); - g_free (str); - } else - mm_dbg (" Bands: %s", VALIDATE_UNSPECIFIED (NULL)); - mm_dbg (" Operator ID: %s", VALIDATE_UNSPECIFIED (mm_simple_connect_properties_get_operator_id (ctx->properties))); mm_dbg (" Allowed roaming: %s", mm_simple_connect_properties_get_allow_roaming (ctx->properties) ? "yes" : "no"); @@ -831,7 +672,6 @@ connect_auth_ready (MMBaseModem *self, } else mm_dbg (" Allowed authentication: %s", VALIDATE_UNSPECIFIED (NULL)); - mm_dbg (" User: %s", VALIDATE_UNSPECIFIED (mm_simple_connect_properties_get_user (ctx->properties))); mm_dbg (" Password: %s", VALIDATE_UNSPECIFIED (mm_simple_connect_properties_get_password (ctx->properties))); |