diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2011-11-30 15:10:53 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-15 14:14:31 +0100 |
commit | c867da54b1312b59318d510ee9c9d2d61b5af23a (patch) | |
tree | 750ee6489e9ab20239547aa5e1cfd32863307d97 | |
parent | 8459eba214f83efa6dc795b748fe5fa1a9e93c66 (diff) |
iface-modem-3gpp: interface can be disabled
-rw-r--r-- | src/mm-iface-modem-3gpp.c | 88 | ||||
-rw-r--r-- | src/mm-iface-modem-3gpp.h | 8 |
2 files changed, 96 insertions, 0 deletions
diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c index 42802413..7caa1750 100644 --- a/src/mm-iface-modem-3gpp.c +++ b/src/mm-iface-modem-3gpp.c @@ -565,6 +565,94 @@ periodic_registration_check_enable (MMIfaceModem3gpp *self) /*****************************************************************************/ +typedef struct _DisablingContext DisablingContext; +static void interface_disabling_step (DisablingContext *ctx); + +typedef enum { + DISABLING_STEP_FIRST, + DISABLING_STEP_LAST +} DisablingStep; + +struct _DisablingContext { + MMIfaceModem3gpp *self; + MMAtSerialPort *primary; + DisablingStep step; + GSimpleAsyncResult *result; + MmGdbusModem *skeleton; +}; + +static DisablingContext * +disabling_context_new (MMIfaceModem3gpp *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + DisablingContext *ctx; + + ctx = g_new0 (DisablingContext, 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, + disabling_context_new); + ctx->step = DISABLING_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 +disabling_context_complete_and_free (DisablingContext *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_disable_finish (MMIfaceModem3gpp *self, + GAsyncResult *res, + GError **error) +{ + return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error); +} + +static void +interface_disabling_step (DisablingContext *ctx) +{ + switch (ctx->step) { + case DISABLING_STEP_FIRST: + /* Fall down to next step */ + ctx->step++; + + case DISABLING_STEP_LAST: + /* We are done without errors! */ + g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); + disabling_context_complete_and_free (ctx); + return; + } + + g_assert_not_reached (); +} + +void +mm_iface_modem_3gpp_disable (MMIfaceModem3gpp *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + interface_disabling_step (disabling_context_new (self, + callback, + user_data)); +} + +/*****************************************************************************/ + typedef struct _EnablingContext EnablingContext; static void interface_enabling_step (EnablingContext *ctx); diff --git a/src/mm-iface-modem-3gpp.h b/src/mm-iface-modem-3gpp.h index 9f8a9b63..b545078b 100644 --- a/src/mm-iface-modem-3gpp.h +++ b/src/mm-iface-modem-3gpp.h @@ -139,6 +139,14 @@ gboolean mm_iface_modem_3gpp_enable_finish (MMIfaceModem3gpp *self, GAsyncResult *res, GError **error); +/* Disable Modem interface (async) */ +void mm_iface_modem_3gpp_disable (MMIfaceModem3gpp *self, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_iface_modem_3gpp_disable_finish (MMIfaceModem3gpp *self, + GAsyncResult *res, + GError **error); + /* Shutdown Modem 3GPP interface */ void mm_iface_modem_3gpp_shutdown (MMIfaceModem3gpp *self); |