aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2011-12-27 10:17:34 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-03-15 14:14:38 +0100
commit8ff310be28450c780e63d12aef0289da601d0fa6 (patch)
tree853aeece55ce7ec7610d6183f0fc12cd69ace108 /src
parent3c90793f225c697b4fef7da23fcac9bd47a34be2 (diff)
iface-modem-simple: use the new connect properties object
Diffstat (limited to 'src')
-rw-r--r--src/mm-iface-modem-simple.c98
1 files changed, 26 insertions, 72 deletions
diff --git a/src/mm-iface-modem-simple.c b/src/mm-iface-modem-simple.c
index c47c8db5..65d74284 100644
--- a/src/mm-iface-modem-simple.c
+++ b/src/mm-iface-modem-simple.c
@@ -44,15 +44,7 @@ typedef struct {
ConnectionStep step;
/* Expected input properties */
- gchar *pin;
- gchar *operator_id;
- MMModemBand allowed_bands;
- MMModemMode allowed_modes;
- MMModemMode preferred_mode;
- gchar *apn;
- gchar *ip_type;
- gchar *number;
- gboolean allow_roaming;
+ MMCommonConnectProperties *properties;
/* Results to set */
gchar *bearer;
@@ -61,67 +53,13 @@ typedef struct {
static void
connection_context_free (ConnectionContext *ctx)
{
- g_free (ctx->bearer);
- g_free (ctx->pin);
- g_free (ctx->operator_id);
- g_free (ctx->apn);
- g_free (ctx->ip_type);
- g_free (ctx->number);
+ g_object_unref (ctx->properties);
g_object_unref (ctx->skeleton);
g_object_unref (ctx->invocation);
g_object_unref (ctx->self);
g_free (ctx);
}
-static void
-connection_properties_parse (GVariant *properties,
- ConnectionContext *ctx)
-{
- GVariantIter iter;
- const gchar *key;
- GVariant *value;
-
- /* Set defaults */
- ctx->pin = NULL;
- ctx->operator_id = NULL;
- ctx->allowed_bands = MM_MODEM_BAND_ANY;
- ctx->allowed_modes = MM_MODEM_MODE_ANY;
- ctx->preferred_mode = MM_MODEM_MODE_NONE;
- ctx->apn = NULL;
- ctx->ip_type = NULL;
- ctx->number = NULL;
- ctx->allow_roaming = TRUE;
-
- g_variant_iter_init (&iter, properties);
- while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) {
- if (g_str_equal (key, "pin")) {
- g_warn_if_fail (ctx->pin == NULL);
- ctx->pin = g_variant_dup_string (value, NULL);
- } else if (g_str_equal (key, "operator-id")) {
- g_warn_if_fail (ctx->operator_id == NULL);
- ctx->operator_id = g_variant_dup_string (value, NULL);
- } else if (g_str_equal (key, "allowed-bands")) {
- ctx->allowed_bands = g_variant_get_uint64 (value);
- } else if (g_str_equal (key, "allowed-modes")) {
- ctx->allowed_modes = g_variant_get_uint32 (value);
- } else if (g_str_equal (key, "preferred-mode")) {
- ctx->preferred_mode = g_variant_get_uint32 (value);
- } else if (g_str_equal (key, "apn")) {
- g_warn_if_fail (ctx->apn == NULL);
- ctx->apn = g_variant_dup_string (value, NULL);
- } else if (g_str_equal (key, "ip-type")) {
- g_warn_if_fail (ctx->ip_type == NULL);
- ctx->ip_type = g_variant_dup_string (value, NULL);
- } else if (g_str_equal (key, "number")) {
- g_warn_if_fail (ctx->number == NULL);
- ctx->number = g_variant_dup_string (value, NULL);
- } else if (g_str_equal (key, "allow-roaming")) {
- ctx->allow_roaming = g_variant_get_boolean (value);
- } else
- mm_warn ("Ignoring unexpected property '%s'", key);
- }
-}
-
static void connection_step (ConnectionContext *ctx);
static void
@@ -227,7 +165,7 @@ unlock_check_ready (MMIfaceModem *self,
/* During simple connect we are only allowed to use SIM PIN */
if (lock != MM_MODEM_LOCK_SIM_PIN ||
- !ctx->pin) {
+ !mm_common_connect_properties_get_pin (ctx->properties)) {
GEnumClass *enum_class;
GEnumValue *value;
@@ -260,7 +198,7 @@ unlock_check_ready (MMIfaceModem *self,
}
mm_sim_send_pin (sim,
- ctx->pin,
+ mm_common_connect_properties_get_pin (ctx->properties),
NULL,
(GAsyncReadyCallback)send_pin_ready,
ctx);
@@ -292,15 +230,23 @@ connection_step (ConnectionContext *ctx)
ctx);
return;
- case CONNECTION_STEP_ALLOWED_MODE:
+ case CONNECTION_STEP_ALLOWED_MODE: {
+ MMModemMode allowed_modes = MM_MODEM_MODE_ANY;
+ MMModemMode preferred_mode = MM_MODEM_MODE_NONE;
+
mm_info ("Simple connect state (%d/%d): Allowed mode",
ctx->step, CONNECTION_STEP_LAST);
+
+ mm_common_connect_properties_get_allowed_modes (ctx->properties,
+ &allowed_modes,
+ &preferred_mode);
mm_iface_modem_set_allowed_modes (MM_IFACE_MODEM (ctx->self),
- ctx->allowed_modes,
- ctx->preferred_mode,
+ allowed_modes,
+ preferred_mode,
(GAsyncReadyCallback)set_allowed_modes_ready,
ctx);
return;
+ }
case CONNECTION_STEP_REGISTER:
mm_info ("Simple connect state (%d/%d): Register",
@@ -308,7 +254,7 @@ connection_step (ConnectionContext *ctx)
if (mm_iface_modem_is_3gpp (MM_IFACE_MODEM (ctx->self))) {
mm_iface_modem_3gpp_register_in_network (
MM_IFACE_MODEM_3GPP (ctx->self),
- ctx->operator_id,
+ mm_common_connect_properties_get_operator_id (ctx->properties),
(GAsyncReadyCallback)register_in_network_ready,
ctx);
return;
@@ -345,17 +291,25 @@ connection_step (ConnectionContext *ctx)
static gboolean
handle_connect (MmGdbusModemSimple *skeleton,
GDBusMethodInvocation *invocation,
- GVariant *properties,
+ GVariant *dictionary,
MMIfaceModemSimple *self)
{
+ GError *error = NULL;
+ MMCommonConnectProperties *properties;
ConnectionContext *ctx;
+ properties = mm_common_connect_properties_new_from_dictionary (dictionary, &error);
+ if (!properties) {
+ g_dbus_method_invocation_take_error (invocation, error);
+ return TRUE;
+ }
+
ctx = g_new0 (ConnectionContext, 1);
ctx->skeleton = g_object_ref (skeleton);
ctx->invocation = g_object_ref (invocation);
ctx->self = g_object_ref (self);
ctx->step = CONNECTION_STEP_FIRST;
- connection_properties_parse (properties, ctx);
+ ctx->properties = properties;
/* Start */
connection_step (ctx);