aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mm-iface-modem-3gpp-ussd.c145
-rw-r--r--src/mm-iface-modem-3gpp.c173
-rw-r--r--src/mm-iface-modem-cdma.c154
-rw-r--r--src/mm-iface-modem-firmware.c46
-rw-r--r--src/mm-iface-modem-location.c169
-rw-r--r--src/mm-iface-modem-messaging.c244
-rw-r--r--src/mm-iface-modem-simple.c23
-rw-r--r--src/mm-iface-modem-time.c158
-rw-r--r--src/mm-iface-modem.c461
9 files changed, 747 insertions, 826 deletions
diff --git a/src/mm-iface-modem-3gpp-ussd.c b/src/mm-iface-modem-3gpp-ussd.c
index 0763c08e..db62cbbc 100644
--- a/src/mm-iface-modem-3gpp-ussd.c
+++ b/src/mm-iface-modem-3gpp-ussd.c
@@ -475,35 +475,14 @@ struct _DisablingContext {
MmGdbusModem3gppUssd *skeleton;
};
-static DisablingContext *
-disabling_context_new (MMIfaceModem3gppUssd *self,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- DisablingContext *ctx;
-
- ctx = g_new0 (DisablingContext, 1);
- ctx->self = g_object_ref (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_USSD_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->result);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -596,9 +575,28 @@ mm_iface_modem_3gpp_ussd_disable (MMIfaceModem3gppUssd *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- interface_disabling_step (disabling_context_new (self,
- callback,
- user_data));
+ DisablingContext *ctx;
+
+ ctx = g_new0 (DisablingContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_3gpp_ussd_disable);
+ ctx->step = DISABLING_STEP_FIRST;
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_3GPP_USSD_DBUS_SKELETON, &ctx->skeleton,
+ NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ disabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ interface_disabling_step (ctx);
}
/*****************************************************************************/
@@ -620,35 +618,14 @@ struct _EnablingContext {
MmGdbusModem3gppUssd *skeleton;
};
-static EnablingContext *
-enabling_context_new (MMIfaceModem3gppUssd *self,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- EnablingContext *ctx;
-
- ctx = g_new0 (EnablingContext, 1);
- ctx->self = g_object_ref (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_USSD_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->result);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -741,9 +718,28 @@ mm_iface_modem_3gpp_ussd_enable (MMIfaceModem3gppUssd *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- interface_enabling_step (enabling_context_new (self,
- callback,
- user_data));
+ EnablingContext *ctx;
+
+ ctx = g_new0 (EnablingContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_3gpp_ussd_enable);
+ ctx->step = ENABLING_STEP_FIRST;
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_3GPP_USSD_DBUS_SKELETON, &ctx->skeleton,
+ NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ enabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ interface_enabling_step (ctx);
}
/*****************************************************************************/
@@ -765,27 +761,6 @@ struct _InitializationContext {
InitializationStep step;
};
-static InitializationContext *
-initialization_context_new (MMIfaceModem3gppUssd *self,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- InitializationContext *ctx;
-
- ctx = g_new0 (InitializationContext, 1);
- ctx->self = g_object_ref (self);
- ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- initialization_context_new);
- ctx->step = INITIALIZATION_STEP_FIRST;
- g_object_get (ctx->self,
- MM_IFACE_MODEM_3GPP_USSD_DBUS_SKELETON, &ctx->skeleton,
- NULL);
- g_assert (ctx->skeleton != NULL);
- return ctx;
-}
-
static void
initialization_context_complete_and_free (InitializationContext *ctx)
{
@@ -915,9 +890,6 @@ mm_iface_modem_3gpp_ussd_initialize_finish (MMIfaceModem3gppUssd *self,
GAsyncResult *res,
GError **error)
{
- g_return_val_if_fail (MM_IS_IFACE_MODEM_3GPP_USSD (self), FALSE);
- g_return_val_if_fail (G_IS_ASYNC_RESULT (res), FALSE);
-
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
@@ -926,10 +898,9 @@ mm_iface_modem_3gpp_ussd_initialize (MMIfaceModem3gppUssd *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ InitializationContext *ctx;
MmGdbusModem3gppUssd *skeleton = NULL;
- g_return_if_fail (MM_IS_IFACE_MODEM_3GPP_USSD (self));
-
/* Did we already create it? */
g_object_get (self,
MM_IFACE_MODEM_3GPP_USSD_DBUS_SKELETON, &skeleton,
@@ -948,18 +919,22 @@ mm_iface_modem_3gpp_ussd_initialize (MMIfaceModem3gppUssd *self,
}
/* Perform async initialization here */
- interface_initialization_step (initialization_context_new (self,
- callback,
- user_data));
- g_object_unref (skeleton);
- return;
+
+ ctx = g_new0 (InitializationContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_3gpp_ussd_initialize);
+ ctx->step = INITIALIZATION_STEP_FIRST;
+ ctx->skeleton = skeleton;
+
+ interface_initialization_step (ctx);
}
void
mm_iface_modem_3gpp_ussd_shutdown (MMIfaceModem3gppUssd *self)
{
- g_return_if_fail (MM_IS_IFACE_MODEM_3GPP_USSD (self));
-
/* Unexport DBus interface and remove the skeleton */
mm_gdbus_object_skeleton_set_modem3gpp_ussd (MM_GDBUS_OBJECT_SKELETON (self), NULL);
g_object_set (self,
diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c
index 961495b2..1e0cd30c 100644
--- a/src/mm-iface-modem-3gpp.c
+++ b/src/mm-iface-modem-3gpp.c
@@ -49,6 +49,8 @@ mm_iface_modem_3gpp_bind_simple_status (MMIfaceModem3gpp *self,
g_object_get (self,
MM_IFACE_MODEM_3GPP_DBUS_SKELETON, &skeleton,
NULL);
+ if (!skeleton)
+ return;
g_object_bind_property (skeleton, "registration-state",
status, MM_SIMPLE_PROPERTY_3GPP_REGISTRATION_STATE,
@@ -169,7 +171,8 @@ register_in_network_context_complete_and_free (RegisterInNetworkContext *ctx)
}
g_free (ctx->operator_id);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_object_unref (ctx->self);
g_slice_free (RegisterInNetworkContext, ctx);
}
@@ -314,6 +317,14 @@ mm_iface_modem_3gpp_register_in_network (MMIfaceModem3gpp *self,
g_object_get (self,
MM_IFACE_MODEM_3GPP_DBUS_SKELETON, &ctx->skeleton,
NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ register_in_network_context_complete_and_free (ctx);
+ return;
+ }
/* Validate input MCC/MNC */
if (ctx->operator_id && !mm_3gpp_parse_operator_id (ctx->operator_id, NULL, NULL, &error)) {
@@ -882,6 +893,14 @@ mm_iface_modem_3gpp_reload_current_operator (MMIfaceModem3gpp *self,
g_object_get (self,
MM_IFACE_MODEM_3GPP_DBUS_SKELETON, &ctx->skeleton,
NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ reload_current_operator_context_complete_and_free (ctx);
+ return;
+ }
ctx->operator_code_loaded = !(MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_operator_code &&
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_operator_code_finish);
@@ -1213,35 +1232,14 @@ struct _DisablingContext {
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->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->result);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -1376,9 +1374,28 @@ mm_iface_modem_3gpp_disable (MMIfaceModem3gpp *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- interface_disabling_step (disabling_context_new (self,
- callback,
- user_data));
+ DisablingContext *ctx;
+
+ ctx = g_new0 (DisablingContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_3gpp_disable);
+ ctx->step = DISABLING_STEP_FIRST;
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_3GPP_DBUS_SKELETON, &ctx->skeleton,
+ NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ disabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ interface_disabling_step (ctx);
}
/*****************************************************************************/
@@ -1404,30 +1421,6 @@ struct _EnablingContext {
MmGdbusModem3gpp *skeleton;
};
-static EnablingContext *
-enabling_context_new (MMIfaceModem3gpp *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- EnablingContext *ctx;
-
- ctx = g_new0 (EnablingContext, 1);
- ctx->self = g_object_ref (self);
- ctx->cancellable = g_object_ref (cancellable);
- 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)
{
@@ -1435,7 +1428,8 @@ enabling_context_complete_and_free (EnablingContext *ctx)
g_object_unref (ctx->self);
g_object_unref (ctx->result);
g_object_unref (ctx->cancellable);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -1666,10 +1660,29 @@ mm_iface_modem_3gpp_enable (MMIfaceModem3gpp *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- interface_enabling_step (enabling_context_new (self,
- cancellable,
- callback,
- user_data));
+ EnablingContext *ctx;
+
+ ctx = g_new0 (EnablingContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->cancellable = g_object_ref (cancellable);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_3gpp_enable);
+ ctx->step = ENABLING_STEP_FIRST;
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_3GPP_DBUS_SKELETON, &ctx->skeleton,
+ NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ enabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ interface_enabling_step (ctx);
}
/*****************************************************************************/
@@ -1692,29 +1705,6 @@ struct _InitializationContext {
InitializationStep step;
};
-static InitializationContext *
-initialization_context_new (MMIfaceModem3gpp *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- InitializationContext *ctx;
-
- ctx = g_new0 (InitializationContext, 1);
- ctx->self = g_object_ref (self);
- ctx->cancellable = g_object_ref (cancellable);
- ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- initialization_context_new);
- ctx->step = INITIALIZATION_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
initialization_context_complete_and_free (InitializationContext *ctx)
{
@@ -1885,9 +1875,6 @@ mm_iface_modem_3gpp_initialize_finish (MMIfaceModem3gpp *self,
GAsyncResult *res,
GError **error)
{
- g_return_val_if_fail (MM_IS_IFACE_MODEM_3GPP (self), FALSE);
- g_return_val_if_fail (G_IS_ASYNC_RESULT (res), FALSE);
-
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
@@ -1898,8 +1885,7 @@ mm_iface_modem_3gpp_initialize (MMIfaceModem3gpp *self,
gpointer user_data)
{
MmGdbusModem3gpp *skeleton = NULL;
-
- g_return_if_fail (MM_IS_IFACE_MODEM_3GPP (self));
+ InitializationContext *ctx;
/* Did we already create it? */
g_object_get (self,
@@ -1933,20 +1919,23 @@ mm_iface_modem_3gpp_initialize (MMIfaceModem3gpp *self,
}
}
+ ctx = g_new0 (InitializationContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->cancellable = g_object_ref (cancellable);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_3gpp_initialize);
+ ctx->step = INITIALIZATION_STEP_FIRST;
+ ctx->skeleton = skeleton;
+
/* Perform async initialization here */
- interface_initialization_step (initialization_context_new (self,
- cancellable,
- callback,
- user_data));
- g_object_unref (skeleton);
- return;
+ interface_initialization_step (ctx);
}
void
mm_iface_modem_3gpp_shutdown (MMIfaceModem3gpp *self)
{
- g_return_if_fail (MM_IS_IFACE_MODEM_3GPP (self));
-
/* Remove RegistrationCheckContext object to make sure any pending
* invocation of periodic_registration_check is cancelled before the
* DBus skeleton is removed. */
diff --git a/src/mm-iface-modem-cdma.c b/src/mm-iface-modem-cdma.c
index ab4ea4ce..8478df52 100644
--- a/src/mm-iface-modem-cdma.c
+++ b/src/mm-iface-modem-cdma.c
@@ -45,6 +45,8 @@ mm_iface_modem_cdma_bind_simple_status (MMIfaceModemCdma *self,
g_object_get (self,
MM_IFACE_MODEM_CDMA_DBUS_SKELETON, &skeleton,
NULL);
+ if (!skeleton)
+ return;
g_object_bind_property (skeleton, "cdma1x-registration-state",
status, MM_SIMPLE_PROPERTY_CDMA_CDMA1X_REGISTRATION_STATE,
@@ -1189,35 +1191,14 @@ struct _DisablingContext {
MmGdbusModemCdma *skeleton;
};
-static DisablingContext *
-disabling_context_new (MMIfaceModemCdma *self,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- DisablingContext *ctx;
-
- ctx = g_new0 (DisablingContext, 1);
- ctx->self = g_object_ref (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_CDMA_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->result);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -1317,9 +1298,28 @@ mm_iface_modem_cdma_disable (MMIfaceModemCdma *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- interface_disabling_step (disabling_context_new (self,
- callback,
- user_data));
+ DisablingContext *ctx;
+
+ ctx = g_new0 (DisablingContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_cdma_disable);
+ ctx->step = DISABLING_STEP_FIRST;
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_CDMA_DBUS_SKELETON, &ctx->skeleton,
+ NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ disabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ interface_disabling_step (ctx);
}
/*****************************************************************************/
@@ -1344,30 +1344,6 @@ struct _EnablingContext {
MmGdbusModemCdma *skeleton;
};
-static EnablingContext *
-enabling_context_new (MMIfaceModemCdma *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- EnablingContext *ctx;
-
- ctx = g_new0 (EnablingContext, 1);
- ctx->self = g_object_ref (self);
- ctx->cancellable = g_object_ref (cancellable);
- 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_CDMA_DBUS_SKELETON, &ctx->skeleton,
- NULL);
- g_assert (ctx->skeleton != NULL);
-
- return ctx;
-}
-
static void
enabling_context_complete_and_free (EnablingContext *ctx)
{
@@ -1375,7 +1351,8 @@ enabling_context_complete_and_free (EnablingContext *ctx)
g_object_unref (ctx->self);
g_object_unref (ctx->result);
g_object_unref (ctx->cancellable);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -1520,10 +1497,29 @@ mm_iface_modem_cdma_enable (MMIfaceModemCdma *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- interface_enabling_step (enabling_context_new (self,
- cancellable,
- callback,
- user_data));
+ EnablingContext *ctx;
+
+ ctx = g_new0 (EnablingContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->cancellable = g_object_ref (cancellable);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_cdma_enable);
+ ctx->step = ENABLING_STEP_FIRST;
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_CDMA_DBUS_SKELETON, &ctx->skeleton,
+ NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ enabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ interface_enabling_step (ctx);
}
/*****************************************************************************/
@@ -1546,29 +1542,6 @@ struct _InitializationContext {
InitializationStep step;
};
-static InitializationContext *
-initialization_context_new (MMIfaceModemCdma *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- InitializationContext *ctx;
-
- ctx = g_new0 (InitializationContext, 1);
- ctx->self = g_object_ref (self);
- ctx->cancellable = g_object_ref (cancellable);
- ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- initialization_context_new);
- ctx->step = INITIALIZATION_STEP_FIRST;
- g_object_get (ctx->self,
- MM_IFACE_MODEM_CDMA_DBUS_SKELETON, &ctx->skeleton,
- NULL);
- g_assert (ctx->skeleton != NULL);
- return ctx;
-}
-
static void
initialization_context_complete_and_free (InitializationContext *ctx)
{
@@ -1695,9 +1668,6 @@ mm_iface_modem_cdma_initialize_finish (MMIfaceModemCdma *self,
GAsyncResult *res,
GError **error)
{
- g_return_val_if_fail (MM_IS_IFACE_MODEM_CDMA (self), FALSE);
- g_return_val_if_fail (G_IS_ASYNC_RESULT (res), FALSE);
-
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
@@ -1707,10 +1677,9 @@ mm_iface_modem_cdma_initialize (MMIfaceModemCdma *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ InitializationContext *ctx;
MmGdbusModemCdma *skeleton = NULL;
- g_return_if_fail (MM_IS_IFACE_MODEM_CDMA (self));
-
/* Did we already create it? */
g_object_get (self,
MM_IFACE_MODEM_CDMA_DBUS_SKELETON, &skeleton,
@@ -1738,18 +1707,23 @@ mm_iface_modem_cdma_initialize (MMIfaceModemCdma *self,
}
/* Perform async initialization here */
- interface_initialization_step (initialization_context_new (self,
- cancellable,
- callback,
- user_data));
- g_object_unref (skeleton);
+
+ ctx = g_new0 (InitializationContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->cancellable = g_object_ref (cancellable);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_cdma_initialize);
+ ctx->step = INITIALIZATION_STEP_FIRST;
+ ctx->skeleton = skeleton;
+
+ interface_initialization_step (ctx);
}
void
mm_iface_modem_cdma_shutdown (MMIfaceModemCdma *self)
{
- g_return_if_fail (MM_IS_IFACE_MODEM_CDMA (self));
-
/* Remove RegistrationCheckContext object to make sure any pending
* invocation of periodic_registration_check is cancelled before the
* DBus skeleton is removed. */
diff --git a/src/mm-iface-modem-firmware.c b/src/mm-iface-modem-firmware.c
index fa9c5e45..9d41f223 100644
--- a/src/mm-iface-modem-firmware.c
+++ b/src/mm-iface-modem-firmware.c
@@ -253,29 +253,6 @@ struct _InitializationContext {
InitializationStep step;
};
-static InitializationContext *
-initialization_context_new (MMIfaceModemFirmware *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- InitializationContext *ctx;
-
- ctx = g_new0 (InitializationContext, 1);
- ctx->self = g_object_ref (self);
- ctx->cancellable = g_object_ref (cancellable);
- ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- initialization_context_new);
- ctx->step = INITIALIZATION_STEP_FIRST;
- g_object_get (ctx->self,
- MM_IFACE_MODEM_FIRMWARE_DBUS_SKELETON, &ctx->skeleton,
- NULL);
- g_assert (ctx->skeleton != NULL);
- return ctx;
-}
-
static void
initialization_context_complete_and_free (InitializationContext *ctx)
{
@@ -418,9 +395,6 @@ mm_iface_modem_firmware_initialize_finish (MMIfaceModemFirmware *self,
GAsyncResult *res,
GError **error)
{
- g_return_val_if_fail (MM_IS_IFACE_MODEM_FIRMWARE (self), FALSE);
- g_return_val_if_fail (G_IS_ASYNC_RESULT (res), FALSE);
-
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
@@ -430,10 +404,9 @@ mm_iface_modem_firmware_initialize (MMIfaceModemFirmware *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ InitializationContext *ctx;
MmGdbusModemFirmware *skeleton = NULL;
- g_return_if_fail (MM_IS_IFACE_MODEM_FIRMWARE (self));
-
/* Did we already create it? */
g_object_get (self,
MM_IFACE_MODEM_FIRMWARE_DBUS_SKELETON, &skeleton,
@@ -446,11 +419,18 @@ mm_iface_modem_firmware_initialize (MMIfaceModemFirmware *self,
}
/* Perform async initialization here */
- interface_initialization_step (initialization_context_new (self,
- cancellable,
- callback,
- user_data));
- g_object_unref (skeleton);
+
+ ctx = g_new0 (InitializationContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->cancellable = g_object_ref (cancellable);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_firmware_initialize);
+ ctx->step = INITIALIZATION_STEP_FIRST;
+ ctx->skeleton = skeleton;
+
+ interface_initialization_step (ctx);
}
void
diff --git a/src/mm-iface-modem-location.c b/src/mm-iface-modem-location.c
index d6e897c2..6009fd12 100644
--- a/src/mm-iface-modem-location.c
+++ b/src/mm-iface-modem-location.c
@@ -379,7 +379,8 @@ update_location_source_status (MMIfaceModemLocation *self,
g_object_get (self,
MM_IFACE_MODEM_LOCATION_DBUS_SKELETON, &skeleton,
NULL);
- g_assert (skeleton != NULL);
+ if (!skeleton)
+ return;
/* Update status in the interface */
mask = mm_gdbus_modem_location_get_enabled (skeleton);
@@ -440,7 +441,8 @@ setup_gathering_context_complete_and_free (SetupGatheringContext *ctx)
{
g_simple_async_result_complete_in_idle (ctx->result);
g_object_unref (ctx->result);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_object_unref (ctx->self);
g_free (ctx);
}
@@ -598,7 +600,14 @@ setup_gathering (MMIfaceModemLocation *self,
g_object_get (self,
MM_IFACE_MODEM_LOCATION_DBUS_SKELETON, &ctx->skeleton,
NULL);
- g_assert (ctx->skeleton != NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ setup_gathering_context_complete_and_free (ctx);
+ return;
+ }
/* Get current list of enabled sources */
currently_enabled = mm_gdbus_modem_location_get_enabled (ctx->skeleton);
@@ -880,35 +889,14 @@ struct _DisablingContext {
MmGdbusModemLocation *skeleton;
};
-static DisablingContext *
-disabling_context_new (MMIfaceModemLocation *self,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- DisablingContext *ctx;
-
- ctx = g_new0 (DisablingContext, 1);
- ctx->self = g_object_ref (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_LOCATION_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->result);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -969,9 +957,28 @@ mm_iface_modem_location_disable (MMIfaceModemLocation *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- interface_disabling_step (disabling_context_new (self,
- callback,
- user_data));
+ DisablingContext *ctx;
+
+ ctx = g_new0 (DisablingContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_location_disable);
+ ctx->step = DISABLING_STEP_FIRST;
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_LOCATION_DBUS_SKELETON, &ctx->skeleton,
+ NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ disabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ interface_disabling_step (ctx);
}
/*****************************************************************************/
@@ -993,30 +1000,6 @@ struct _EnablingContext {
MmGdbusModemLocation *skeleton;
};
-static EnablingContext *
-enabling_context_new (MMIfaceModemLocation *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- EnablingContext *ctx;
-
- ctx = g_new0 (EnablingContext, 1);
- ctx->self = g_object_ref (self);
- ctx->cancellable = g_object_ref (cancellable);
- 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_LOCATION_DBUS_SKELETON, &ctx->skeleton,
- NULL);
- g_assert (ctx->skeleton != NULL);
-
- return ctx;
-}
-
static void
enabling_context_complete_and_free (EnablingContext *ctx)
{
@@ -1024,7 +1007,8 @@ enabling_context_complete_and_free (EnablingContext *ctx)
g_object_unref (ctx->self);
g_object_unref (ctx->result);
g_object_unref (ctx->cancellable);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -1111,10 +1095,29 @@ mm_iface_modem_location_enable (MMIfaceModemLocation *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- interface_enabling_step (enabling_context_new (self,
- cancellable,
- callback,
- user_data));
+ EnablingContext *ctx;
+
+ ctx = g_new0 (EnablingContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->cancellable = g_object_ref (cancellable);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_location_enable);
+ ctx->step = ENABLING_STEP_FIRST;
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_LOCATION_DBUS_SKELETON, &ctx->skeleton,
+ NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ enabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ interface_enabling_step (ctx);
}
/*****************************************************************************/
@@ -1138,30 +1141,6 @@ struct _InitializationContext {
MMModemLocationSource capabilities;
};
-static InitializationContext *
-initialization_context_new (MMIfaceModemLocation *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- InitializationContext *ctx;
-
- ctx = g_new0 (InitializationContext, 1);
- ctx->self = g_object_ref (self);
- ctx->capabilities = MM_MODEM_LOCATION_SOURCE_NONE;
- ctx->cancellable = g_object_ref (cancellable);
- ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- initialization_context_new);
- ctx->step = INITIALIZATION_STEP_FIRST;
- g_object_get (ctx->self,
- MM_IFACE_MODEM_LOCATION_DBUS_SKELETON, &ctx->skeleton,
- NULL);
- g_assert (ctx->skeleton != NULL);
- return ctx;
-}
-
static void
initialization_context_complete_and_free (InitializationContext *ctx)
{
@@ -1279,9 +1258,6 @@ mm_iface_modem_location_initialize_finish (MMIfaceModemLocation *self,
GAsyncResult *res,
GError **error)
{
- g_return_val_if_fail (MM_IS_IFACE_MODEM_LOCATION (self), FALSE);
- g_return_val_if_fail (G_IS_ASYNC_RESULT (res), FALSE);
-
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
@@ -1291,10 +1267,9 @@ mm_iface_modem_location_initialize (MMIfaceModemLocation *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ InitializationContext *ctx;
MmGdbusModemLocation *skeleton = NULL;
- g_return_if_fail (MM_IS_IFACE_MODEM_LOCATION (self));
-
/* Did we already create it? */
g_object_get (self,
MM_IFACE_MODEM_LOCATION_DBUS_SKELETON, &skeleton,
@@ -1315,18 +1290,24 @@ mm_iface_modem_location_initialize (MMIfaceModemLocation *self,
}
/* Perform async initialization here */
- interface_initialization_step (initialization_context_new (self,
- cancellable,
- callback,
- user_data));
- g_object_unref (skeleton);
+
+ ctx = g_new0 (InitializationContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->capabilities = MM_MODEM_LOCATION_SOURCE_NONE;
+ ctx->cancellable = g_object_ref (cancellable);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_location_initialize);
+ ctx->step = INITIALIZATION_STEP_FIRST;
+ ctx->skeleton = skeleton;
+
+ interface_initialization_step (ctx);
}
void
mm_iface_modem_location_shutdown (MMIfaceModemLocation *self)
{
- g_return_if_fail (MM_IS_IFACE_MODEM_LOCATION (self));
-
/* Unexport DBus interface and remove the skeleton */
mm_gdbus_object_skeleton_set_modem_location (MM_GDBUS_OBJECT_SKELETON (self), NULL);
g_object_set (self,
diff --git a/src/mm-iface-modem-messaging.c b/src/mm-iface-modem-messaging.c
index d94f6c14..f7349681 100644
--- a/src/mm-iface-modem-messaging.c
+++ b/src/mm-iface-modem-messaging.c
@@ -205,7 +205,14 @@ handle_delete_auth_ready (MMBaseModem *self,
g_object_get (self,
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
NULL);
- g_assert (list != NULL);
+ if (!list) {
+ g_dbus_method_invocation_return_error (ctx->invocation,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_WRONG_STATE,
+ "Cannot delete SMS: missing SMS list");
+ handle_delete_context_free (ctx);
+ return;
+ }
mm_sms_list_delete_sms (list,
ctx->path,
@@ -297,6 +304,7 @@ handle_create_auth_ready (MMBaseModem *self,
properties,
&error);
if (!sms) {
+ g_object_unref (properties);
g_dbus_method_invocation_take_error (ctx->invocation, error);
handle_create_context_free (ctx);
return;
@@ -305,7 +313,16 @@ handle_create_auth_ready (MMBaseModem *self,
g_object_get (self,
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
NULL);
- g_assert (list != NULL);
+ if (!list) {
+ g_object_unref (properties);
+ g_object_unref (sms);
+ g_dbus_method_invocation_return_error (ctx->invocation,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_WRONG_STATE,
+ "Cannot create SMS: missing SMS list");
+ handle_create_context_free (ctx);
+ return;
+ }
/* Add it to the list */
mm_sms_list_add_sms (list, sms);
@@ -372,7 +389,13 @@ handle_list (MmGdbusModemMessaging *skeleton,
g_object_get (self,
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
NULL);
- g_assert (list != NULL);
+ if (!list) {
+ g_dbus_method_invocation_return_error (invocation,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_WRONG_STATE,
+ "Cannot list SMS: missing SMS list");
+ return TRUE;
+ }
paths = mm_sms_list_get_paths (list);
mm_gdbus_modem_messaging_complete_list (skeleton,
@@ -398,7 +421,9 @@ mm_iface_modem_messaging_take_part (MMIfaceModemMessaging *self,
g_object_get (self,
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
NULL);
- g_assert (list != NULL);
+ if (!list)
+ return FALSE;
+
added = mm_sms_list_take_part (list, sms_part, state, storage, &error);
if (!added) {
mm_dbg ("Couldn't take part in SMS list: '%s'", error->message);
@@ -504,35 +529,14 @@ struct _DisablingContext {
MmGdbusModemMessaging *skeleton;
};
-static DisablingContext *
-disabling_context_new (MMIfaceModemMessaging *self,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- DisablingContext *ctx;
-
- ctx = g_new0 (DisablingContext, 1);
- ctx->self = g_object_ref (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_MESSAGING_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->result);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -633,12 +637,31 @@ interface_disabling_step (DisablingContext *ctx)
void
mm_iface_modem_messaging_disable (MMIfaceModemMessaging *self,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
- interface_disabling_step (disabling_context_new (self,
- callback,
- user_data));
+ DisablingContext *ctx;
+
+ ctx = g_new0 (DisablingContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_messaging_disable);
+ ctx->step = DISABLING_STEP_FIRST;
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_MESSAGING_DBUS_SKELETON, &ctx->skeleton,
+ NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ disabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ interface_disabling_step (ctx);
}
/*****************************************************************************/
@@ -665,30 +688,6 @@ struct _EnablingContext {
guint mem1_storage_index;
};
-static EnablingContext *
-enabling_context_new (MMIfaceModemMessaging *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- EnablingContext *ctx;
-
- ctx = g_new0 (EnablingContext, 1);
- ctx->self = g_object_ref (self);
- ctx->cancellable = g_object_ref (cancellable);
- 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_MESSAGING_DBUS_SKELETON, &ctx->skeleton,
- NULL);
- g_assert (ctx->skeleton != NULL);
-
- return ctx;
-}
-
static void
enabling_context_complete_and_free (EnablingContext *ctx)
{
@@ -696,7 +695,8 @@ enabling_context_complete_and_free (EnablingContext *ctx)
g_object_unref (ctx->self);
g_object_unref (ctx->result);
g_object_unref (ctx->cancellable);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -722,28 +722,24 @@ mm_iface_modem_messaging_enable_finish (MMIfaceModemMessaging *self,
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
-#undef VOID_REPLY_READY_FN
-#define VOID_REPLY_READY_FN(NAME) \
- static void \
- NAME##_ready (MMIfaceModemMessaging *self, \
- GAsyncResult *res, \
- EnablingContext *ctx) \
- { \
- GError *error = NULL; \
- \
- MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (self)->NAME##_finish (self, res, &error); \
- if (error) { \
- g_simple_async_result_take_error (ctx->result, error); \
- enabling_context_complete_and_free (ctx); \
- return; \
- } \
- \
- /* Go on to next step */ \
- ctx->step++; \
- interface_enabling_step (ctx); \
+static void
+setup_sms_format_ready (MMIfaceModemMessaging *self,
+ GAsyncResult *res,
+ EnablingContext *ctx)
+{
+ GError *error = NULL;
+
+ MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (self)->setup_sms_format_finish (self, res, &error);
+ if (error) {
+ g_simple_async_result_take_error (ctx->result, error);
+ enabling_context_complete_and_free (ctx);
+ return;
}
-VOID_REPLY_READY_FN (setup_sms_format)
+ /* Go on to next step */
+ ctx->step++;
+ interface_enabling_step (ctx);
+}
static void load_initial_sms_parts_from_storages (EnablingContext *ctx);
@@ -820,7 +816,24 @@ load_initial_sms_parts_from_storages (EnablingContext *ctx)
return;
}
-VOID_REPLY_READY_FN (setup_unsolicited_events)
+static void
+setup_unsolicited_events_ready (MMIfaceModemMessaging *self,
+ GAsyncResult *res,
+ EnablingContext *ctx)
+{
+ GError *error = NULL;
+
+ MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (self)->setup_unsolicited_events_finish (self, res, &error);
+ if (error) {
+ g_simple_async_result_take_error (ctx->result, error);
+ enabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ /* Go on to next step */
+ ctx->step++;
+ interface_enabling_step (ctx);
+}
static void
enable_unsolicited_events_ready (MMIfaceModemMessaging *self,
@@ -989,10 +1002,29 @@ mm_iface_modem_messaging_enable (MMIfaceModemMessaging *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- interface_enabling_step (enabling_context_new (self,
- cancellable,
- callback,
- user_data));
+ EnablingContext *ctx;
+
+ ctx = g_new0 (EnablingContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->cancellable = g_object_ref (cancellable);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_messaging_enable);
+ ctx->step = ENABLING_STEP_FIRST;
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_MESSAGING_DBUS_SKELETON, &ctx->skeleton,
+ NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ enabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ interface_enabling_step (ctx);
}
/*****************************************************************************/
@@ -1016,29 +1048,6 @@ struct _InitializationContext {
InitializationStep step;
};
-static InitializationContext *
-initialization_context_new (MMIfaceModemMessaging *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- InitializationContext *ctx;
-
- ctx = g_new0 (InitializationContext, 1);
- ctx->self = g_object_ref (self);
- ctx->cancellable = g_object_ref (cancellable);
- ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- initialization_context_new);
- ctx->step = INITIALIZATION_STEP_FIRST;
- g_object_get (ctx->self,
- MM_IFACE_MODEM_MESSAGING_DBUS_SKELETON, &ctx->skeleton,
- NULL);
- g_assert (ctx->skeleton != NULL);
- return ctx;
-}
-
static void
initialization_context_complete_and_free (InitializationContext *ctx)
{
@@ -1269,9 +1278,6 @@ mm_iface_modem_messaging_initialize_finish (MMIfaceModemMessaging *self,
GAsyncResult *res,
GError **error)
{
- g_return_val_if_fail (MM_IS_IFACE_MODEM_MESSAGING (self), FALSE);
- g_return_val_if_fail (G_IS_ASYNC_RESULT (res), FALSE);
-
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
@@ -1281,10 +1287,9 @@ mm_iface_modem_messaging_initialize (MMIfaceModemMessaging *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ InitializationContext *ctx;
MmGdbusModemMessaging *skeleton = NULL;
- g_return_if_fail (MM_IS_IFACE_MODEM_MESSAGING (self));
-
/* Did we already create it? */
g_object_get (self,
MM_IFACE_MODEM_MESSAGING_DBUS_SKELETON, &skeleton,
@@ -1304,18 +1309,23 @@ mm_iface_modem_messaging_initialize (MMIfaceModemMessaging *self,
}
/* Perform async initialization here */
- interface_initialization_step (initialization_context_new (self,
- cancellable,
- callback,
- user_data));
- g_object_unref (skeleton);
+
+ ctx = g_new0 (InitializationContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->cancellable = g_object_ref (cancellable);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_messaging_initialize);
+ ctx->step = INITIALIZATION_STEP_FIRST;
+ ctx->skeleton = skeleton;
+
+ interface_initialization_step (ctx);
}
void
mm_iface_modem_messaging_shutdown (MMIfaceModemMessaging *self)
{
- g_return_if_fail (MM_IS_IFACE_MODEM_MESSAGING (self));
-
/* Unexport DBus interface and remove the skeleton */
mm_gdbus_object_skeleton_set_modem_messaging (MM_GDBUS_OBJECT_SKELETON (self), NULL);
g_object_set (self,
diff --git a/src/mm-iface-modem-simple.c b/src/mm-iface-modem-simple.c
index 952a3c03..a74c03c4 100644
--- a/src/mm-iface-modem-simple.c
+++ b/src/mm-iface-modem-simple.c
@@ -643,6 +643,15 @@ connection_step (ConnectionContext *ctx)
g_object_get (ctx->self,
MM_IFACE_MODEM_BEARER_LIST, &list,
NULL);
+ if (!list) {
+ g_dbus_method_invocation_return_error (
+ ctx->invocation,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get the bearer list");
+ connection_context_free (ctx);
+ return;
+ }
bearer_properties = mm_simple_connect_properties_get_bearer_properties (ctx->properties);
@@ -891,6 +900,16 @@ disconnect_auth_ready (MMBaseModem *self,
g_object_get (self,
MM_IFACE_MODEM_BEARER_LIST, &list,
NULL);
+ if (!list) {
+ g_dbus_method_invocation_return_error (
+ ctx->invocation,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get the bearer list");
+ disconnection_context_free (ctx);
+ return;
+ }
+
mm_bearer_list_foreach (list,
(MMBearerListForeachFunc)build_connected_bearer_list,
ctx);
@@ -968,8 +987,6 @@ mm_iface_modem_simple_initialize (MMIfaceModemSimple *self)
{
MmGdbusModemSimple *skeleton = NULL;
- g_return_if_fail (MM_IS_IFACE_MODEM_SIMPLE (self));
-
/* Did we already create it? */
g_object_get (self,
MM_IFACE_MODEM_SIMPLE_DBUS_SKELETON, &skeleton,
@@ -1005,8 +1022,6 @@ mm_iface_modem_simple_initialize (MMIfaceModemSimple *self)
void
mm_iface_modem_simple_shutdown (MMIfaceModemSimple *self)
{
- g_return_if_fail (MM_IS_IFACE_MODEM_SIMPLE (self));
-
/* Unexport DBus interface and remove the skeleton */
mm_gdbus_object_skeleton_set_modem_simple (MM_GDBUS_OBJECT_SKELETON (self), NULL);
g_object_set (self,
diff --git a/src/mm-iface-modem-time.c b/src/mm-iface-modem-time.c
index 9a5d1d98..1a6ab213 100644
--- a/src/mm-iface-modem-time.c
+++ b/src/mm-iface-modem-time.c
@@ -184,7 +184,8 @@ update_network_timezone_dictionary (MMIfaceModemTime *self,
g_object_get (self,
MM_IFACE_MODEM_TIME_DBUS_SKELETON, &skeleton,
NULL);
- g_assert (skeleton != NULL);
+ if (!skeleton)
+ return;
dictionary = mm_network_timezone_get_dictionary (tz);
mm_gdbus_modem_time_set_network_timezone (skeleton, dictionary);
@@ -374,6 +375,8 @@ mm_iface_modem_time_update_network_time (MMIfaceModemTime *self,
g_object_get (self,
MM_IFACE_MODEM_TIME_DBUS_SKELETON, &skeleton,
NULL);
+ if (!skeleton)
+ return;
/* Notify about the updated network time */
mm_gdbus_modem_time_emit_network_time_changed (skeleton, network_time);
@@ -401,35 +404,14 @@ struct _DisablingContext {
MmGdbusModemTime *skeleton;
};
-static DisablingContext *
-disabling_context_new (MMIfaceModemTime *self,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- DisablingContext *ctx;
-
- ctx = g_new0 (DisablingContext, 1);
- ctx->self = g_object_ref (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_TIME_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->result);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -548,9 +530,28 @@ mm_iface_modem_time_disable (MMIfaceModemTime *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- interface_disabling_step (disabling_context_new (self,
- callback,
- user_data));
+ DisablingContext *ctx;
+
+ ctx = g_new0 (DisablingContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_time_disable);
+ ctx->step = DISABLING_STEP_FIRST;
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_TIME_DBUS_SKELETON, &ctx->skeleton,
+ NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ disabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ interface_disabling_step (ctx);
}
/*****************************************************************************/
@@ -574,30 +575,6 @@ struct _EnablingContext {
MmGdbusModemTime *skeleton;
};
-static EnablingContext *
-enabling_context_new (MMIfaceModemTime *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- EnablingContext *ctx;
-
- ctx = g_new0 (EnablingContext, 1);
- ctx->self = g_object_ref (self);
- ctx->cancellable = g_object_ref (cancellable);
- 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_TIME_DBUS_SKELETON, &ctx->skeleton,
- NULL);
- g_assert (ctx->skeleton != NULL);
-
- return ctx;
-}
-
static void
enabling_context_complete_and_free (EnablingContext *ctx)
{
@@ -605,7 +582,8 @@ enabling_context_complete_and_free (EnablingContext *ctx)
g_object_unref (ctx->self);
g_object_unref (ctx->result);
g_object_unref (ctx->cancellable);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -768,10 +746,29 @@ mm_iface_modem_time_enable (MMIfaceModemTime *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- interface_enabling_step (enabling_context_new (self,
- cancellable,
- callback,
- user_data));
+ EnablingContext *ctx;
+
+ ctx = g_new0 (EnablingContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->cancellable = g_object_ref (cancellable);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_time_enable);
+ ctx->step = ENABLING_STEP_FIRST;
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_TIME_DBUS_SKELETON, &ctx->skeleton,
+ NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ enabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ interface_enabling_step (ctx);
}
/*****************************************************************************/
@@ -794,29 +791,6 @@ struct _InitializationContext {
InitializationStep step;
};
-static InitializationContext *
-initialization_context_new (MMIfaceModemTime *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- InitializationContext *ctx;
-
- ctx = g_new0 (InitializationContext, 1);
- ctx->self = g_object_ref (self);
- ctx->cancellable = g_object_ref (cancellable);
- ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- initialization_context_new);
- ctx->step = INITIALIZATION_STEP_FIRST;
- g_object_get (ctx->self,
- MM_IFACE_MODEM_TIME_DBUS_SKELETON, &ctx->skeleton,
- NULL);
- g_assert (ctx->skeleton != NULL);
- return ctx;
-}
-
static void
initialization_context_complete_and_free (InitializationContext *ctx)
{
@@ -955,9 +929,6 @@ mm_iface_modem_time_initialize_finish (MMIfaceModemTime *self,
GAsyncResult *res,
GError **error)
{
- g_return_val_if_fail (MM_IS_IFACE_MODEM_TIME (self), FALSE);
- g_return_val_if_fail (G_IS_ASYNC_RESULT (res), FALSE);
-
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
@@ -967,35 +938,38 @@ mm_iface_modem_time_initialize (MMIfaceModemTime *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ InitializationContext *ctx;
MmGdbusModemTime *skeleton = NULL;
- g_return_if_fail (MM_IS_IFACE_MODEM_TIME (self));
-
/* Did we already create it? */
g_object_get (self,
MM_IFACE_MODEM_TIME_DBUS_SKELETON, &skeleton,
NULL);
if (!skeleton) {
skeleton = mm_gdbus_modem_time_skeleton_new ();
-
g_object_set (self,
MM_IFACE_MODEM_TIME_DBUS_SKELETON, skeleton,
NULL);
}
/* Perform async initialization here */
- interface_initialization_step (initialization_context_new (self,
- cancellable,
- callback,
- user_data));
- g_object_unref (skeleton);
+
+ ctx = g_new0 (InitializationContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->cancellable = g_object_ref (cancellable);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_time_initialize);
+ ctx->step = INITIALIZATION_STEP_FIRST;
+ ctx->skeleton = skeleton;
+
+ interface_initialization_step (ctx);
}
void
mm_iface_modem_time_shutdown (MMIfaceModemTime *self)
{
- g_return_if_fail (MM_IS_IFACE_MODEM_TIME (self));
-
/* Unexport DBus interface and remove the skeleton */
mm_gdbus_object_skeleton_set_modem_time (MM_GDBUS_OBJECT_SKELETON (self), NULL);
g_object_set (self,
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c
index a4f44fdd..f57be968 100644
--- a/src/mm-iface-modem.c
+++ b/src/mm-iface-modem.c
@@ -52,6 +52,8 @@ mm_iface_modem_bind_simple_status (MMIfaceModem *self,
g_object_get (self,
MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
NULL);
+ if (!skeleton)
+ return;
g_object_bind_property (skeleton, "state",
status, MM_SIMPLE_PROPERTY_STATE,
@@ -141,60 +143,64 @@ bearer_status_changed (MMBearer *bearer,
g_object_unref (list);
}
+typedef struct {
+ MMIfaceModem *self;
+ MMBearerList *list;
+ GSimpleAsyncResult *result;
+} CreateBearerContext;
+
+static void
+create_bearer_context_complete_and_free (CreateBearerContext *ctx)
+{
+ g_simple_async_result_complete_in_idle (ctx->result);
+ g_object_unref (ctx->result);
+ g_object_unref (ctx->self);
+ if (ctx->list)
+ g_object_unref (ctx->list);
+ g_slice_free (CreateBearerContext, ctx);
+}
+
MMBearer *
mm_iface_modem_create_bearer_finish (MMIfaceModem *self,
GAsyncResult *res,
GError **error)
{
- MMBearer *bearer;
-
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
return NULL;
- bearer = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
-
- return g_object_ref (bearer);
+ return g_object_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
}
static void
create_bearer_ready (MMIfaceModem *self,
GAsyncResult *res,
- GSimpleAsyncResult *simple)
+ CreateBearerContext *ctx)
{
MMBearer *bearer;
GError *error = NULL;
- bearer = MM_IFACE_MODEM_GET_INTERFACE (self)->create_bearer_finish (self,
- res,
- &error);
- if (error)
- g_simple_async_result_take_error (simple, error);
- else {
- MMBearerList *list = NULL;
-
- g_object_get (self,
- MM_IFACE_MODEM_BEARER_LIST, &list,
- NULL);
+ bearer = MM_IFACE_MODEM_GET_INTERFACE (self)->create_bearer_finish (self, res, &error);
+ if (error) {
+ g_simple_async_result_take_error (ctx->result, error);
+ create_bearer_context_complete_and_free (ctx);
+ return;
+ }
- if (!mm_bearer_list_add_bearer (list, bearer, &error))
- g_simple_async_result_take_error (simple, error);
- else {
- /* If bearer properly created and added to the list, follow its
- * status */
- g_signal_connect (bearer,
- "notify::" MM_BEARER_STATUS,
- (GCallback)bearer_status_changed,
- self);
- g_simple_async_result_set_op_res_gpointer (simple,
- g_object_ref (bearer),
- g_object_unref);
- }
+ if (!mm_bearer_list_add_bearer (ctx->list, bearer, &error)) {
+ g_simple_async_result_take_error (ctx->result, error);
+ create_bearer_context_complete_and_free (ctx);
g_object_unref (bearer);
- g_object_unref (list);
+ return;
}
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
+ /* If bearer properly created and added to the list, follow its
+ * status */
+ g_signal_connect (bearer,
+ "notify::" MM_BEARER_STATUS,
+ (GCallback)bearer_status_changed,
+ self);
+ g_simple_async_result_set_op_res_gpointer (ctx->result, g_object_ref (bearer), g_object_unref);
+ create_bearer_context_complete_and_free (ctx);
}
void
@@ -203,31 +209,43 @@ mm_iface_modem_create_bearer (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- MMBearerList *list = NULL;
+ CreateBearerContext *ctx;
+ ctx = g_slice_new (CreateBearerContext);
+ ctx->self = g_object_ref (self);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_create_bearer);
g_object_get (self,
- MM_IFACE_MODEM_BEARER_LIST, &list,
+ MM_IFACE_MODEM_BEARER_LIST, &ctx->list,
NULL);
+ if (!ctx->list) {
+ g_simple_async_result_set_error (
+ ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Cannot add new bearer: bearer list not found");
+ create_bearer_context_complete_and_free (ctx);
+ return;
+ }
- if (mm_bearer_list_get_count (list) == mm_bearer_list_get_max (list))
- g_simple_async_report_error_in_idle (
- G_OBJECT (self),
- callback,
- user_data,
+ if (mm_bearer_list_get_count (ctx->list) == mm_bearer_list_get_max (ctx->list)) {
+ g_simple_async_result_set_error (
+ ctx->result,
MM_CORE_ERROR,
MM_CORE_ERROR_TOO_MANY,
"Cannot add new bearer: already reached maximum (%u)",
- mm_bearer_list_get_count (list));
- else
- MM_IFACE_MODEM_GET_INTERFACE (self)->create_bearer (
- self,
- properties,
- (GAsyncReadyCallback)create_bearer_ready,
- g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- mm_iface_modem_create_bearer));
- g_object_unref (list);
+ mm_bearer_list_get_count (ctx->list));
+ create_bearer_context_complete_and_free (ctx);
+ return;
+ }
+
+ MM_IFACE_MODEM_GET_INTERFACE (self)->create_bearer (
+ self,
+ properties,
+ (GAsyncReadyCallback)create_bearer_ready,
+ ctx);
}
typedef struct {
@@ -431,6 +449,7 @@ typedef struct {
MmGdbusModem *skeleton;
GDBusMethodInvocation *invocation;
MMIfaceModem *self;
+ MMBearerList *list;
gchar *bearer_path;
} HandleDeleteBearerContext;
@@ -440,6 +459,8 @@ handle_delete_bearer_context_free (HandleDeleteBearerContext *ctx)
g_object_unref (ctx->skeleton);
g_object_unref (ctx->invocation);
g_object_unref (ctx->self);
+ if (ctx->list)
+ g_object_unref (ctx->list);
g_free (ctx->bearer_path);
g_free (ctx);
}
@@ -449,7 +470,6 @@ handle_delete_bearer_auth_ready (MMBaseModem *self,
GAsyncResult *res,
HandleDeleteBearerContext *ctx)
{
- MMBearerList *list = NULL;
GError *error = NULL;
if (!mm_base_modem_authorize_finish (self, res, &error)) {
@@ -458,16 +478,13 @@ handle_delete_bearer_auth_ready (MMBaseModem *self,
return;
}
- g_object_get (self,
- MM_IFACE_MODEM_BEARER_LIST, &list,
- NULL);
-
- if (!mm_bearer_list_delete_bearer (list, ctx->bearer_path, &error))
+ if (!ctx->list)
+ mm_gdbus_modem_complete_delete_bearer (ctx->skeleton, ctx->invocation);
+ else if (!mm_bearer_list_delete_bearer (ctx->list, ctx->bearer_path, &error))
g_dbus_method_invocation_take_error (ctx->invocation, error);
else
mm_gdbus_modem_complete_delete_bearer (ctx->skeleton, ctx->invocation);
- g_object_unref (list);
handle_delete_bearer_context_free (ctx);
}
@@ -484,6 +501,9 @@ handle_delete_bearer (MmGdbusModem *skeleton,
ctx->invocation = g_object_ref (invocation);
ctx->self = g_object_ref (self);
ctx->bearer_path = g_strdup (bearer);
+ g_object_get (self,
+ MM_IFACE_MODEM_BEARER_LIST, &ctx->list,
+ NULL);
mm_base_modem_authorize (MM_BASE_MODEM (self),
invocation,
@@ -506,6 +526,13 @@ handle_list_bearers (MmGdbusModem *skeleton,
g_object_get (self,
MM_IFACE_MODEM_BEARER_LIST, &list,
NULL);
+ if (!list) {
+ g_dbus_method_invocation_return_error (invocation,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Bearer list not found");
+ return TRUE;
+ }
paths = mm_bearer_list_get_paths (list);
mm_gdbus_modem_complete_list_bearers (skeleton,
@@ -717,9 +744,6 @@ get_last_signal_quality_update_time (MMIfaceModem *self)
static gboolean
expire_signal_quality (MMIfaceModem *self)
{
- GVariant *old;
- guint signal_quality = 0;
- gboolean recent = FALSE;
MmGdbusModem *skeleton = NULL;
SignalQualityUpdateContext *ctx;
@@ -727,25 +751,31 @@ expire_signal_quality (MMIfaceModem *self)
MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
NULL);
- old = mm_gdbus_modem_get_signal_quality (skeleton);
- g_variant_get (old,
- "(ub)",
- &signal_quality,
- &recent);
+ if (skeleton) {
+ GVariant *old;
+ guint signal_quality = 0;
+ gboolean recent = FALSE;
+
+ old = mm_gdbus_modem_get_signal_quality (skeleton);
+ g_variant_get (old,
+ "(ub)",
+ &signal_quality,
+ &recent);
+
+ /* If value is already not recent, we're done */
+ if (recent) {
+ mm_dbg ("Signal quality value not updated in %us, "
+ "marking as not being recent",
+ SIGNAL_QUALITY_RECENT_TIMEOUT_SEC);
+ mm_gdbus_modem_set_signal_quality (skeleton,
+ g_variant_new ("(ub)",
+ signal_quality,
+ FALSE));
+ }
- /* If value is already not recent, we're done */
- if (recent) {
- mm_dbg ("Signal quality value not updated in %us, "
- "marking as not being recent",
- SIGNAL_QUALITY_RECENT_TIMEOUT_SEC);
- mm_gdbus_modem_set_signal_quality (skeleton,
- g_variant_new ("(ub)",
- signal_quality,
- FALSE));
+ g_object_unref (skeleton);
}
- g_object_unref (skeleton);
-
/* Remove source id */
ctx = g_object_get_qdata (G_OBJECT (self), signal_quality_update_context_quark);
ctx->recent_timeout_source = 0;
@@ -968,6 +998,14 @@ mm_iface_modem_update_state (MMIfaceModem *self,
MM_IFACE_MODEM_BEARER_LIST, &bearer_list,
NULL);
+ if (!skeleton || !bearer_list) {
+ if (skeleton)
+ g_object_unref (skeleton);
+ if (bearer_list)
+ g_object_unref (bearer_list);
+ return;
+ }
+
/* While connected we don't want registration status changes to change
* the modem's state away from CONNECTED. */
if ((new_state == MM_MODEM_STATE_SEARCHING ||
@@ -1463,8 +1501,10 @@ set_bands_context_complete_and_free (SetBandsContext *ctx)
g_simple_async_result_complete_in_idle (ctx->result);
g_object_unref (ctx->result);
g_object_unref (ctx->self);
- g_object_unref (ctx->skeleton);
- g_array_unref (ctx->bands_array);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
+ if (ctx->bands_array)
+ g_array_unref (ctx->bands_array);
g_free (ctx);
}
@@ -1576,9 +1616,6 @@ mm_iface_modem_set_bands (MMIfaceModem *self,
return;
}
- bands_string = mm_common_build_bands_string ((MMModemBand *)bands_array->data,
- bands_array->len);
-
/* Setup context */
ctx = g_new0 (SetBandsContext, 1);
ctx->self = g_object_ref (self);
@@ -1589,6 +1626,17 @@ mm_iface_modem_set_bands (MMIfaceModem *self,
g_object_get (self,
MM_IFACE_MODEM_DBUS_SKELETON, &ctx->skeleton,
NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ set_bands_context_complete_and_free (ctx);
+ return;
+ }
+
+ bands_string = mm_common_build_bands_string ((MMModemBand *)bands_array->data,
+ bands_array->len);
/* Get list of supported bands */
supported_bands_array = (mm_common_bands_variant_to_garray (
@@ -1776,7 +1824,8 @@ set_allowed_modes_context_complete_and_free (SetAllowedModesContext *ctx)
g_simple_async_result_complete_in_idle (ctx->result);
g_object_unref (ctx->result);
g_object_unref (ctx->self);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -1839,6 +1888,15 @@ mm_iface_modem_set_allowed_modes (MMIfaceModem *self,
g_object_get (self,
MM_IFACE_MODEM_DBUS_SKELETON, &ctx->skeleton,
NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ set_allowed_modes_context_complete_and_free (ctx);
+ return;
+ }
+
/* Get list of supported modes */
supported = mm_gdbus_modem_get_supported_modes (ctx->skeleton);
@@ -2002,42 +2060,23 @@ handle_set_allowed_modes (MmGdbusModem *skeleton,
/*****************************************************************************/
-typedef struct _UnlockCheckContext UnlockCheckContext;
-struct _UnlockCheckContext {
+typedef struct {
MMIfaceModem *self;
guint pin_check_tries;
guint pin_check_timeout_id;
GSimpleAsyncResult *result;
MmGdbusModem *skeleton;
MMModemLock lock;
-};
-
-static UnlockCheckContext *
-unlock_check_context_new (MMIfaceModem *self,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- UnlockCheckContext *ctx;
-
- ctx = g_new0 (UnlockCheckContext, 1);
- ctx->self = g_object_ref (self);
- ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- unlock_check_context_new);
- g_object_get (ctx->self,
- MM_IFACE_MODEM_DBUS_SKELETON, &ctx->skeleton,
- NULL);
- g_assert (ctx->skeleton != NULL);
- return ctx;
-}
+} UnlockCheckContext;
static void
-unlock_check_context_free (UnlockCheckContext *ctx)
+unlock_check_context_complete_and_free (UnlockCheckContext *ctx)
{
- g_object_unref (ctx->self);
+ g_simple_async_result_complete_in_idle (ctx->result);
g_object_unref (ctx->result);
- g_object_unref (ctx->skeleton);
+ g_object_unref (ctx->self);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -2145,8 +2184,7 @@ modem_after_sim_unlock_ready (MMIfaceModem *self,
g_simple_async_result_set_op_res_gpointer (ctx->result,
GUINT_TO_POINTER (ctx->lock),
NULL);
- g_simple_async_result_complete (ctx->result);
- unlock_check_context_free (ctx);
+ unlock_check_context_complete_and_free (ctx);
}
static void
@@ -2175,8 +2213,7 @@ unlock_check_ready (MMIfaceModem *self,
MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_SIM_WRONG)) {
g_simple_async_result_take_error (ctx->result, error);
- g_simple_async_result_complete (ctx->result);
- unlock_check_context_free (ctx);
+ unlock_check_context_complete_and_free (ctx);
return;
}
@@ -2226,8 +2263,7 @@ unlock_check_ready (MMIfaceModem *self,
g_simple_async_result_set_op_res_gpointer (ctx->result,
GUINT_TO_POINTER (ctx->lock),
NULL);
- g_simple_async_result_complete (ctx->result);
- unlock_check_context_free (ctx);
+ unlock_check_context_complete_and_free (ctx);
}
void
@@ -2237,7 +2273,23 @@ mm_iface_modem_unlock_check (MMIfaceModem *self,
{
UnlockCheckContext *ctx;
- ctx = unlock_check_context_new (self, callback, user_data);
+ ctx = g_new0 (UnlockCheckContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_unlock_check);
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_DBUS_SKELETON, &ctx->skeleton,
+ NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ unlock_check_context_complete_and_free (ctx);
+ return;
+ }
/* If we're already unlocked, we're done */
if (mm_gdbus_modem_get_unlock_required (ctx->skeleton) != MM_MODEM_LOCK_NONE &&
@@ -2254,8 +2306,7 @@ mm_iface_modem_unlock_check (MMIfaceModem *self,
g_simple_async_result_set_op_res_gpointer (ctx->result,
GUINT_TO_POINTER (MM_MODEM_LOCK_NONE),
NULL);
- g_simple_async_result_complete_in_idle (ctx->result);
- unlock_check_context_free (ctx);
+ unlock_check_context_complete_and_free (ctx);
}
/*****************************************************************************/
@@ -2284,6 +2335,8 @@ update_unlock_retries (MMIfaceModem *self,
g_object_get (self,
MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
NULL);
+ if (!skeleton)
+ return;
previous_dictionary = mm_gdbus_modem_get_unlock_retries (skeleton);
previous_unlock_retries = mm_unlock_retries_new_from_dictionary (previous_dictionary);
@@ -2381,33 +2434,6 @@ struct _DisablingContext {
MmGdbusModem *skeleton;
};
-static DisablingContext *
-disabling_context_new (MMIfaceModem *self,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- DisablingContext *ctx;
-
- ctx = g_new0 (DisablingContext, 1);
- ctx->self = g_object_ref (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_DBUS_SKELETON, &ctx->skeleton,
- MM_IFACE_MODEM_STATE, &ctx->previous_state,
- NULL);
- g_assert (ctx->skeleton != NULL);
-
- mm_iface_modem_update_state (ctx->self,
- MM_MODEM_STATE_DISABLING,
- MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED);
-
- return ctx;
-}
-
static void
disabling_context_complete_and_free (DisablingContext *ctx)
{
@@ -2425,7 +2451,8 @@ disabling_context_complete_and_free (DisablingContext *ctx)
g_object_unref (ctx->self);
g_object_unref (ctx->result);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -2514,9 +2541,33 @@ mm_iface_modem_disable (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- interface_disabling_step (disabling_context_new (self,
- callback,
- user_data));
+ DisablingContext *ctx;
+
+ ctx = g_new0 (DisablingContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_disable);
+ ctx->step = DISABLING_STEP_FIRST;
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_DBUS_SKELETON, &ctx->skeleton,
+ MM_IFACE_MODEM_STATE, &ctx->previous_state,
+ NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ disabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ mm_iface_modem_update_state (ctx->self,
+ MM_MODEM_STATE_DISABLING,
+ MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED);
+
+ interface_disabling_step (ctx);
}
/*****************************************************************************/
@@ -2549,34 +2600,6 @@ struct _EnablingContext {
MmGdbusModem *skeleton;
};
-static EnablingContext *
-enabling_context_new (MMIfaceModem *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- EnablingContext *ctx;
-
- ctx = g_new0 (EnablingContext, 1);
- ctx->self = g_object_ref (self);
- ctx->cancellable = g_object_ref (cancellable);
- 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_DBUS_SKELETON, &ctx->skeleton,
- NULL);
- g_assert (ctx->skeleton != NULL);
-
- mm_iface_modem_update_state (ctx->self,
- MM_MODEM_STATE_ENABLING,
- MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED);
-
- return ctx;
-}
-
static void
enabling_context_complete_and_free (EnablingContext *ctx)
{
@@ -2586,7 +2609,7 @@ enabling_context_complete_and_free (EnablingContext *ctx)
mm_iface_modem_update_state (ctx->self,
MM_MODEM_STATE_ENABLED,
MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED);
- else {
+ else if (ctx->skeleton) {
MMModemLock lock;
/* Fallback to DISABLED/LOCKED */
@@ -2604,7 +2627,8 @@ enabling_context_complete_and_free (EnablingContext *ctx)
g_object_unref (ctx->self);
g_object_unref (ctx->result);
g_object_unref (ctx->cancellable);
- g_object_unref (ctx->skeleton);
+ if (ctx->skeleton)
+ g_object_unref (ctx->skeleton);
g_free (ctx);
}
@@ -2926,10 +2950,33 @@ mm_iface_modem_enable (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- interface_enabling_step (enabling_context_new (self,
- cancellable,
- callback,
- user_data));
+ EnablingContext *ctx;
+
+ ctx = g_new0 (EnablingContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->cancellable = g_object_ref (cancellable);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_enable);
+ ctx->step = ENABLING_STEP_FIRST;
+ g_object_get (ctx->self,
+ MM_IFACE_MODEM_DBUS_SKELETON, &ctx->skeleton,
+ NULL);
+ if (!ctx->skeleton) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't get interface skeleton");
+ enabling_context_complete_and_free (ctx);
+ return;
+ }
+
+ mm_iface_modem_update_state (ctx->self,
+ MM_MODEM_STATE_ENABLING,
+ MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED);
+
+ interface_enabling_step (ctx);
}
/*****************************************************************************/
@@ -2967,29 +3014,6 @@ struct _InitializationContext {
GError *fatal_error;
};
-static InitializationContext *
-initialization_context_new (MMIfaceModem *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- InitializationContext *ctx;
-
- ctx = g_new0 (InitializationContext, 1);
- ctx->self = g_object_ref (self);
- ctx->cancellable = g_object_ref (cancellable);
- ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- initialization_context_new);
- ctx->step = INITIALIZATION_STEP_FIRST;
- g_object_get (ctx->self,
- MM_IFACE_MODEM_DBUS_SKELETON, &ctx->skeleton,
- NULL);
- g_assert (ctx->skeleton != NULL);
- return ctx;
-}
-
static void
initialization_context_complete_and_free (InitializationContext *ctx)
{
@@ -3648,9 +3672,6 @@ mm_iface_modem_initialize_finish (MMIfaceModem *self,
GAsyncResult *res,
GError **error)
{
- g_return_val_if_fail (MM_IS_IFACE_MODEM (self), FALSE);
- g_return_val_if_fail (G_IS_ASYNC_RESULT (res), FALSE);
-
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
@@ -3660,10 +3681,9 @@ mm_iface_modem_initialize (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ InitializationContext *ctx;
MmGdbusModem *skeleton = NULL;
- g_return_if_fail (MM_IS_IFACE_MODEM (self));
-
/* Did we already create it? */
g_object_get (self,
MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
@@ -3707,19 +3727,22 @@ mm_iface_modem_initialize (MMIfaceModem *self,
}
/* Perform async initialization here */
- interface_initialization_step (initialization_context_new (self,
- cancellable,
- callback,
- user_data));
- g_object_unref (skeleton);
- return;
+ ctx = g_new0 (InitializationContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->cancellable = g_object_ref (cancellable);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_iface_modem_initialize);
+ ctx->step = INITIALIZATION_STEP_FIRST;
+ ctx->skeleton = skeleton;
+
+ interface_initialization_step (ctx);
}
void
mm_iface_modem_shutdown (MMIfaceModem *self)
{
- g_return_if_fail (MM_IS_IFACE_MODEM (self));
-
/* Remove SignalQualityCheckContext object to make sure any pending
* invocation of periodic_signal_quality_check is cancelled before
* SignalQualityUpdateContext is removed (as signal_quality_check_ready may