aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2011-11-28 17:51:20 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-03-15 14:14:28 +0100
commit73db436f71558c700254731f254d35dbcd3ba7c5 (patch)
tree905ad9e6e5c798fc3c3480f9bc8b6e634ac79e76 /src
parentbd24d0d14c415916bb739255178301359de1347a (diff)
iface-modem-3gpp: interface can be enabled
In addition to initializing the interface, to load initial values of all properties and export the object in DBus, the interface can now also be enabled. Enabling the 3GPP interface will take care of running the network registration process.
Diffstat (limited to 'src')
-rw-r--r--src/mm-iface-modem-3gpp.c88
-rw-r--r--src/mm-iface-modem-3gpp.h8
2 files changed, 96 insertions, 0 deletions
diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c
index 921d27ec..f3e8ef59 100644
--- a/src/mm-iface-modem-3gpp.c
+++ b/src/mm-iface-modem-3gpp.c
@@ -44,6 +44,94 @@ handle_scan (MmGdbusModem3gpp *skeleton,
/*****************************************************************************/
+typedef struct _EnablingContext EnablingContext;
+static void interface_enabling_step (EnablingContext *ctx);
+
+typedef enum {
+ ENABLING_STEP_FIRST,
+ ENABLING_STEP_LAST
+} EnablingStep;
+
+struct _EnablingContext {
+ MMIfaceModem3gpp *self;
+ MMAtSerialPort *primary;
+ EnablingStep step;
+ GSimpleAsyncResult *result;
+ MmGdbusModem3gpp *skeleton;
+};
+
+static EnablingContext *
+enabling_context_new (MMIfaceModem3gpp *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ EnablingContext *ctx;
+
+ ctx = g_new0 (EnablingContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->primary = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (self)));
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ enabling_context_new);
+ ctx->step = ENABLING_STEP_FIRST;
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_3GPP_DBUS_SKELETON, &ctx->skeleton,
+ NULL);
+ g_assert (ctx->skeleton != NULL);
+
+ return ctx;
+}
+
+static void
+enabling_context_complete_and_free (EnablingContext *ctx)
+{
+ g_simple_async_result_complete_in_idle (ctx->result);
+ g_object_unref (ctx->self);
+ g_object_unref (ctx->primary);
+ g_object_unref (ctx->result);
+ g_object_unref (ctx->skeleton);
+ g_free (ctx);
+}
+
+gboolean
+mm_iface_modem_3gpp_enable_finish (MMIfaceModem3gpp *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
+}
+
+static void
+interface_enabling_step (EnablingContext *ctx)
+{
+ switch (ctx->step) {
+ case ENABLING_STEP_FIRST:
+ /* Fall down to next step */
+ ctx->step++;
+
+ case ENABLING_STEP_LAST:
+ /* We are done without errors! */
+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
+ enabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ g_assert_not_reached ();
+}
+
+void
+mm_iface_modem_3gpp_enable (MMIfaceModem3gpp *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ interface_enabling_step (enabling_context_new (self,
+ callback,
+ user_data));
+}
+
+/*****************************************************************************/
+
typedef struct _InitializationContext InitializationContext;
static void interface_initialization_step (InitializationContext *ctx);
diff --git a/src/mm-iface-modem-3gpp.h b/src/mm-iface-modem-3gpp.h
index 0dc7389d..b00c74d3 100644
--- a/src/mm-iface-modem-3gpp.h
+++ b/src/mm-iface-modem-3gpp.h
@@ -53,6 +53,14 @@ gboolean mm_iface_modem_3gpp_initialize_finish (MMIfaceModem3gpp *self,
GAsyncResult *res,
GError **error);
+/* Enable Modem interface (async) */
+void mm_iface_modem_3gpp_enable (MMIfaceModem3gpp *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean mm_iface_modem_3gpp_enable_finish (MMIfaceModem3gpp *self,
+ GAsyncResult *res,
+ GError **error);
+
/* Shutdown Modem 3GPP interface */
void mm_iface_modem_3gpp_shutdown (MMIfaceModem3gpp *self);