core: make sure objects retrieved with g_object_get() are valid in the ifaces
The interfaces usually retrieve objects (e.g. skeletons) from the Modem object using g_object_get(), but we didn't make sure that these objects were actually valid before using them. This should clean up errors happening when the modem gets unplugged and still some actions are ongoing. Should fix https://bugzilla.gnome.org/show_bug.cgi?id=685933
This commit is contained in:
@@ -475,34 +475,13 @@ struct _DisablingContext {
|
|||||||
MmGdbusModem3gppUssd *skeleton;
|
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
|
static void
|
||||||
disabling_context_complete_and_free (DisablingContext *ctx)
|
disabling_context_complete_and_free (DisablingContext *ctx)
|
||||||
{
|
{
|
||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -596,9 +575,28 @@ mm_iface_modem_3gpp_ussd_disable (MMIfaceModem3gppUssd *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
interface_disabling_step (disabling_context_new (self,
|
DisablingContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_new0 (DisablingContext, 1);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
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,34 +618,13 @@ struct _EnablingContext {
|
|||||||
MmGdbusModem3gppUssd *skeleton;
|
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
|
static void
|
||||||
enabling_context_complete_and_free (EnablingContext *ctx)
|
enabling_context_complete_and_free (EnablingContext *ctx)
|
||||||
{
|
{
|
||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -741,9 +718,28 @@ mm_iface_modem_3gpp_ussd_enable (MMIfaceModem3gppUssd *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
interface_enabling_step (enabling_context_new (self,
|
EnablingContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_new0 (EnablingContext, 1);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
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;
|
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
|
static void
|
||||||
initialization_context_complete_and_free (InitializationContext *ctx)
|
initialization_context_complete_and_free (InitializationContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -915,9 +890,6 @@ mm_iface_modem_3gpp_ussd_initialize_finish (MMIfaceModem3gppUssd *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
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);
|
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,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
InitializationContext *ctx;
|
||||||
MmGdbusModem3gppUssd *skeleton = NULL;
|
MmGdbusModem3gppUssd *skeleton = NULL;
|
||||||
|
|
||||||
g_return_if_fail (MM_IS_IFACE_MODEM_3GPP_USSD (self));
|
|
||||||
|
|
||||||
/* Did we already create it? */
|
/* Did we already create it? */
|
||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_3GPP_USSD_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_3GPP_USSD_DBUS_SKELETON, &skeleton,
|
||||||
@@ -948,18 +919,22 @@ mm_iface_modem_3gpp_ussd_initialize (MMIfaceModem3gppUssd *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Perform async initialization here */
|
/* Perform async initialization here */
|
||||||
interface_initialization_step (initialization_context_new (self,
|
|
||||||
|
ctx = g_new0 (InitializationContext, 1);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
user_data,
|
||||||
g_object_unref (skeleton);
|
mm_iface_modem_3gpp_ussd_initialize);
|
||||||
return;
|
ctx->step = INITIALIZATION_STEP_FIRST;
|
||||||
|
ctx->skeleton = skeleton;
|
||||||
|
|
||||||
|
interface_initialization_step (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mm_iface_modem_3gpp_ussd_shutdown (MMIfaceModem3gppUssd *self)
|
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 */
|
/* Unexport DBus interface and remove the skeleton */
|
||||||
mm_gdbus_object_skeleton_set_modem3gpp_ussd (MM_GDBUS_OBJECT_SKELETON (self), NULL);
|
mm_gdbus_object_skeleton_set_modem3gpp_ussd (MM_GDBUS_OBJECT_SKELETON (self), NULL);
|
||||||
g_object_set (self,
|
g_object_set (self,
|
||||||
|
@@ -49,6 +49,8 @@ mm_iface_modem_3gpp_bind_simple_status (MMIfaceModem3gpp *self,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_3GPP_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_3GPP_DBUS_SKELETON, &skeleton,
|
||||||
NULL);
|
NULL);
|
||||||
|
if (!skeleton)
|
||||||
|
return;
|
||||||
|
|
||||||
g_object_bind_property (skeleton, "registration-state",
|
g_object_bind_property (skeleton, "registration-state",
|
||||||
status, MM_SIMPLE_PROPERTY_3GPP_REGISTRATION_STATE,
|
status, MM_SIMPLE_PROPERTY_3GPP_REGISTRATION_STATE,
|
||||||
@@ -169,6 +171,7 @@ register_in_network_context_complete_and_free (RegisterInNetworkContext *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_free (ctx->operator_id);
|
g_free (ctx->operator_id);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_slice_free (RegisterInNetworkContext, ctx);
|
g_slice_free (RegisterInNetworkContext, ctx);
|
||||||
@@ -314,6 +317,14 @@ mm_iface_modem_3gpp_register_in_network (MMIfaceModem3gpp *self,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_3GPP_DBUS_SKELETON, &ctx->skeleton,
|
MM_IFACE_MODEM_3GPP_DBUS_SKELETON, &ctx->skeleton,
|
||||||
NULL);
|
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 */
|
/* Validate input MCC/MNC */
|
||||||
if (ctx->operator_id && !mm_3gpp_parse_operator_id (ctx->operator_id, NULL, NULL, &error)) {
|
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,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_3GPP_DBUS_SKELETON, &ctx->skeleton,
|
MM_IFACE_MODEM_3GPP_DBUS_SKELETON, &ctx->skeleton,
|
||||||
NULL);
|
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 &&
|
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);
|
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_operator_code_finish);
|
||||||
@@ -1213,34 +1232,13 @@ struct _DisablingContext {
|
|||||||
MmGdbusModem *skeleton;
|
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
|
static void
|
||||||
disabling_context_complete_and_free (DisablingContext *ctx)
|
disabling_context_complete_and_free (DisablingContext *ctx)
|
||||||
{
|
{
|
||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -1376,9 +1374,28 @@ mm_iface_modem_3gpp_disable (MMIfaceModem3gpp *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
interface_disabling_step (disabling_context_new (self,
|
DisablingContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_new0 (DisablingContext, 1);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
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;
|
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
|
static void
|
||||||
enabling_context_complete_and_free (EnablingContext *ctx)
|
enabling_context_complete_and_free (EnablingContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -1435,6 +1428,7 @@ enabling_context_complete_and_free (EnablingContext *ctx)
|
|||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->cancellable);
|
g_object_unref (ctx->cancellable);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -1666,10 +1660,29 @@ mm_iface_modem_3gpp_enable (MMIfaceModem3gpp *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
interface_enabling_step (enabling_context_new (self,
|
EnablingContext *ctx;
|
||||||
cancellable,
|
|
||||||
|
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,
|
callback,
|
||||||
user_data));
|
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;
|
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
|
static void
|
||||||
initialization_context_complete_and_free (InitializationContext *ctx)
|
initialization_context_complete_and_free (InitializationContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -1885,9 +1875,6 @@ mm_iface_modem_3gpp_initialize_finish (MMIfaceModem3gpp *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
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);
|
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)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
MmGdbusModem3gpp *skeleton = NULL;
|
MmGdbusModem3gpp *skeleton = NULL;
|
||||||
|
InitializationContext *ctx;
|
||||||
g_return_if_fail (MM_IS_IFACE_MODEM_3GPP (self));
|
|
||||||
|
|
||||||
/* Did we already create it? */
|
/* Did we already create it? */
|
||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
@@ -1933,20 +1919,23 @@ mm_iface_modem_3gpp_initialize (MMIfaceModem3gpp *self,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform async initialization here */
|
ctx = g_new0 (InitializationContext, 1);
|
||||||
interface_initialization_step (initialization_context_new (self,
|
ctx->self = g_object_ref (self);
|
||||||
cancellable,
|
ctx->cancellable = g_object_ref (cancellable);
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
user_data,
|
||||||
g_object_unref (skeleton);
|
mm_iface_modem_3gpp_initialize);
|
||||||
return;
|
ctx->step = INITIALIZATION_STEP_FIRST;
|
||||||
|
ctx->skeleton = skeleton;
|
||||||
|
|
||||||
|
/* Perform async initialization here */
|
||||||
|
interface_initialization_step (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mm_iface_modem_3gpp_shutdown (MMIfaceModem3gpp *self)
|
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
|
/* Remove RegistrationCheckContext object to make sure any pending
|
||||||
* invocation of periodic_registration_check is cancelled before the
|
* invocation of periodic_registration_check is cancelled before the
|
||||||
* DBus skeleton is removed. */
|
* DBus skeleton is removed. */
|
||||||
|
@@ -45,6 +45,8 @@ mm_iface_modem_cdma_bind_simple_status (MMIfaceModemCdma *self,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_CDMA_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_CDMA_DBUS_SKELETON, &skeleton,
|
||||||
NULL);
|
NULL);
|
||||||
|
if (!skeleton)
|
||||||
|
return;
|
||||||
|
|
||||||
g_object_bind_property (skeleton, "cdma1x-registration-state",
|
g_object_bind_property (skeleton, "cdma1x-registration-state",
|
||||||
status, MM_SIMPLE_PROPERTY_CDMA_CDMA1X_REGISTRATION_STATE,
|
status, MM_SIMPLE_PROPERTY_CDMA_CDMA1X_REGISTRATION_STATE,
|
||||||
@@ -1189,34 +1191,13 @@ struct _DisablingContext {
|
|||||||
MmGdbusModemCdma *skeleton;
|
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
|
static void
|
||||||
disabling_context_complete_and_free (DisablingContext *ctx)
|
disabling_context_complete_and_free (DisablingContext *ctx)
|
||||||
{
|
{
|
||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -1317,9 +1298,28 @@ mm_iface_modem_cdma_disable (MMIfaceModemCdma *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
interface_disabling_step (disabling_context_new (self,
|
DisablingContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_new0 (DisablingContext, 1);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
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;
|
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
|
static void
|
||||||
enabling_context_complete_and_free (EnablingContext *ctx)
|
enabling_context_complete_and_free (EnablingContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -1375,6 +1351,7 @@ enabling_context_complete_and_free (EnablingContext *ctx)
|
|||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->cancellable);
|
g_object_unref (ctx->cancellable);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -1520,10 +1497,29 @@ mm_iface_modem_cdma_enable (MMIfaceModemCdma *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
interface_enabling_step (enabling_context_new (self,
|
EnablingContext *ctx;
|
||||||
cancellable,
|
|
||||||
|
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,
|
callback,
|
||||||
user_data));
|
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;
|
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
|
static void
|
||||||
initialization_context_complete_and_free (InitializationContext *ctx)
|
initialization_context_complete_and_free (InitializationContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -1695,9 +1668,6 @@ mm_iface_modem_cdma_initialize_finish (MMIfaceModemCdma *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
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);
|
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,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
InitializationContext *ctx;
|
||||||
MmGdbusModemCdma *skeleton = NULL;
|
MmGdbusModemCdma *skeleton = NULL;
|
||||||
|
|
||||||
g_return_if_fail (MM_IS_IFACE_MODEM_CDMA (self));
|
|
||||||
|
|
||||||
/* Did we already create it? */
|
/* Did we already create it? */
|
||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_CDMA_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_CDMA_DBUS_SKELETON, &skeleton,
|
||||||
@@ -1738,18 +1707,23 @@ mm_iface_modem_cdma_initialize (MMIfaceModemCdma *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Perform async initialization here */
|
/* Perform async initialization here */
|
||||||
interface_initialization_step (initialization_context_new (self,
|
|
||||||
cancellable,
|
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,
|
callback,
|
||||||
user_data));
|
user_data,
|
||||||
g_object_unref (skeleton);
|
mm_iface_modem_cdma_initialize);
|
||||||
|
ctx->step = INITIALIZATION_STEP_FIRST;
|
||||||
|
ctx->skeleton = skeleton;
|
||||||
|
|
||||||
|
interface_initialization_step (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mm_iface_modem_cdma_shutdown (MMIfaceModemCdma *self)
|
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
|
/* Remove RegistrationCheckContext object to make sure any pending
|
||||||
* invocation of periodic_registration_check is cancelled before the
|
* invocation of periodic_registration_check is cancelled before the
|
||||||
* DBus skeleton is removed. */
|
* DBus skeleton is removed. */
|
||||||
|
@@ -253,29 +253,6 @@ struct _InitializationContext {
|
|||||||
InitializationStep step;
|
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
|
static void
|
||||||
initialization_context_complete_and_free (InitializationContext *ctx)
|
initialization_context_complete_and_free (InitializationContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -418,9 +395,6 @@ mm_iface_modem_firmware_initialize_finish (MMIfaceModemFirmware *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
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);
|
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,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
InitializationContext *ctx;
|
||||||
MmGdbusModemFirmware *skeleton = NULL;
|
MmGdbusModemFirmware *skeleton = NULL;
|
||||||
|
|
||||||
g_return_if_fail (MM_IS_IFACE_MODEM_FIRMWARE (self));
|
|
||||||
|
|
||||||
/* Did we already create it? */
|
/* Did we already create it? */
|
||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_FIRMWARE_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_FIRMWARE_DBUS_SKELETON, &skeleton,
|
||||||
@@ -446,11 +419,18 @@ mm_iface_modem_firmware_initialize (MMIfaceModemFirmware *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Perform async initialization here */
|
/* Perform async initialization here */
|
||||||
interface_initialization_step (initialization_context_new (self,
|
|
||||||
cancellable,
|
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,
|
callback,
|
||||||
user_data));
|
user_data,
|
||||||
g_object_unref (skeleton);
|
mm_iface_modem_firmware_initialize);
|
||||||
|
ctx->step = INITIALIZATION_STEP_FIRST;
|
||||||
|
ctx->skeleton = skeleton;
|
||||||
|
|
||||||
|
interface_initialization_step (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -379,7 +379,8 @@ update_location_source_status (MMIfaceModemLocation *self,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_LOCATION_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_LOCATION_DBUS_SKELETON, &skeleton,
|
||||||
NULL);
|
NULL);
|
||||||
g_assert (skeleton != NULL);
|
if (!skeleton)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Update status in the interface */
|
/* Update status in the interface */
|
||||||
mask = mm_gdbus_modem_location_get_enabled (skeleton);
|
mask = mm_gdbus_modem_location_get_enabled (skeleton);
|
||||||
@@ -440,6 +441,7 @@ setup_gathering_context_complete_and_free (SetupGatheringContext *ctx)
|
|||||||
{
|
{
|
||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
@@ -598,7 +600,14 @@ setup_gathering (MMIfaceModemLocation *self,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_LOCATION_DBUS_SKELETON, &ctx->skeleton,
|
MM_IFACE_MODEM_LOCATION_DBUS_SKELETON, &ctx->skeleton,
|
||||||
NULL);
|
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 */
|
/* Get current list of enabled sources */
|
||||||
currently_enabled = mm_gdbus_modem_location_get_enabled (ctx->skeleton);
|
currently_enabled = mm_gdbus_modem_location_get_enabled (ctx->skeleton);
|
||||||
@@ -880,34 +889,13 @@ struct _DisablingContext {
|
|||||||
MmGdbusModemLocation *skeleton;
|
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
|
static void
|
||||||
disabling_context_complete_and_free (DisablingContext *ctx)
|
disabling_context_complete_and_free (DisablingContext *ctx)
|
||||||
{
|
{
|
||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -969,9 +957,28 @@ mm_iface_modem_location_disable (MMIfaceModemLocation *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
interface_disabling_step (disabling_context_new (self,
|
DisablingContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_new0 (DisablingContext, 1);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
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;
|
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
|
static void
|
||||||
enabling_context_complete_and_free (EnablingContext *ctx)
|
enabling_context_complete_and_free (EnablingContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -1024,6 +1007,7 @@ enabling_context_complete_and_free (EnablingContext *ctx)
|
|||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->cancellable);
|
g_object_unref (ctx->cancellable);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -1111,10 +1095,29 @@ mm_iface_modem_location_enable (MMIfaceModemLocation *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
interface_enabling_step (enabling_context_new (self,
|
EnablingContext *ctx;
|
||||||
cancellable,
|
|
||||||
|
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,
|
callback,
|
||||||
user_data));
|
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;
|
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
|
static void
|
||||||
initialization_context_complete_and_free (InitializationContext *ctx)
|
initialization_context_complete_and_free (InitializationContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -1279,9 +1258,6 @@ mm_iface_modem_location_initialize_finish (MMIfaceModemLocation *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
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);
|
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,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
InitializationContext *ctx;
|
||||||
MmGdbusModemLocation *skeleton = NULL;
|
MmGdbusModemLocation *skeleton = NULL;
|
||||||
|
|
||||||
g_return_if_fail (MM_IS_IFACE_MODEM_LOCATION (self));
|
|
||||||
|
|
||||||
/* Did we already create it? */
|
/* Did we already create it? */
|
||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_LOCATION_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_LOCATION_DBUS_SKELETON, &skeleton,
|
||||||
@@ -1315,18 +1290,24 @@ mm_iface_modem_location_initialize (MMIfaceModemLocation *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Perform async initialization here */
|
/* Perform async initialization here */
|
||||||
interface_initialization_step (initialization_context_new (self,
|
|
||||||
cancellable,
|
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,
|
callback,
|
||||||
user_data));
|
user_data,
|
||||||
g_object_unref (skeleton);
|
mm_iface_modem_location_initialize);
|
||||||
|
ctx->step = INITIALIZATION_STEP_FIRST;
|
||||||
|
ctx->skeleton = skeleton;
|
||||||
|
|
||||||
|
interface_initialization_step (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mm_iface_modem_location_shutdown (MMIfaceModemLocation *self)
|
mm_iface_modem_location_shutdown (MMIfaceModemLocation *self)
|
||||||
{
|
{
|
||||||
g_return_if_fail (MM_IS_IFACE_MODEM_LOCATION (self));
|
|
||||||
|
|
||||||
/* Unexport DBus interface and remove the skeleton */
|
/* Unexport DBus interface and remove the skeleton */
|
||||||
mm_gdbus_object_skeleton_set_modem_location (MM_GDBUS_OBJECT_SKELETON (self), NULL);
|
mm_gdbus_object_skeleton_set_modem_location (MM_GDBUS_OBJECT_SKELETON (self), NULL);
|
||||||
g_object_set (self,
|
g_object_set (self,
|
||||||
|
@@ -205,7 +205,14 @@ handle_delete_auth_ready (MMBaseModem *self,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
|
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
|
||||||
NULL);
|
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,
|
mm_sms_list_delete_sms (list,
|
||||||
ctx->path,
|
ctx->path,
|
||||||
@@ -297,6 +304,7 @@ handle_create_auth_ready (MMBaseModem *self,
|
|||||||
properties,
|
properties,
|
||||||
&error);
|
&error);
|
||||||
if (!sms) {
|
if (!sms) {
|
||||||
|
g_object_unref (properties);
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
handle_create_context_free (ctx);
|
handle_create_context_free (ctx);
|
||||||
return;
|
return;
|
||||||
@@ -305,7 +313,16 @@ handle_create_auth_ready (MMBaseModem *self,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
|
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
|
||||||
NULL);
|
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 */
|
/* Add it to the list */
|
||||||
mm_sms_list_add_sms (list, sms);
|
mm_sms_list_add_sms (list, sms);
|
||||||
@@ -372,7 +389,13 @@ handle_list (MmGdbusModemMessaging *skeleton,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
|
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
|
||||||
NULL);
|
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);
|
paths = mm_sms_list_get_paths (list);
|
||||||
mm_gdbus_modem_messaging_complete_list (skeleton,
|
mm_gdbus_modem_messaging_complete_list (skeleton,
|
||||||
@@ -398,7 +421,9 @@ mm_iface_modem_messaging_take_part (MMIfaceModemMessaging *self,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
|
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
|
||||||
NULL);
|
NULL);
|
||||||
g_assert (list != NULL);
|
if (!list)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
added = mm_sms_list_take_part (list, sms_part, state, storage, &error);
|
added = mm_sms_list_take_part (list, sms_part, state, storage, &error);
|
||||||
if (!added) {
|
if (!added) {
|
||||||
mm_dbg ("Couldn't take part in SMS list: '%s'", error->message);
|
mm_dbg ("Couldn't take part in SMS list: '%s'", error->message);
|
||||||
@@ -504,34 +529,13 @@ struct _DisablingContext {
|
|||||||
MmGdbusModemMessaging *skeleton;
|
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
|
static void
|
||||||
disabling_context_complete_and_free (DisablingContext *ctx)
|
disabling_context_complete_and_free (DisablingContext *ctx)
|
||||||
{
|
{
|
||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -636,9 +640,28 @@ mm_iface_modem_messaging_disable (MMIfaceModemMessaging *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
interface_disabling_step (disabling_context_new (self,
|
DisablingContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_new0 (DisablingContext, 1);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
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;
|
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
|
static void
|
||||||
enabling_context_complete_and_free (EnablingContext *ctx)
|
enabling_context_complete_and_free (EnablingContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -696,6 +695,7 @@ enabling_context_complete_and_free (EnablingContext *ctx)
|
|||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->cancellable);
|
g_object_unref (ctx->cancellable);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
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);
|
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef VOID_REPLY_READY_FN
|
static void
|
||||||
#define VOID_REPLY_READY_FN(NAME) \
|
setup_sms_format_ready (MMIfaceModemMessaging *self,
|
||||||
static void \
|
GAsyncResult *res,
|
||||||
NAME##_ready (MMIfaceModemMessaging *self, \
|
EnablingContext *ctx)
|
||||||
GAsyncResult *res, \
|
{
|
||||||
EnablingContext *ctx) \
|
GError *error = NULL;
|
||||||
{ \
|
|
||||||
GError *error = NULL; \
|
MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (self)->setup_sms_format_finish (self, res, &error);
|
||||||
\
|
if (error) {
|
||||||
MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (self)->NAME##_finish (self, res, &error); \
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
if (error) { \
|
enabling_context_complete_and_free (ctx);
|
||||||
g_simple_async_result_take_error (ctx->result, error); \
|
return;
|
||||||
enabling_context_complete_and_free (ctx); \
|
|
||||||
return; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
/* Go on to next step */ \
|
|
||||||
ctx->step++; \
|
|
||||||
interface_enabling_step (ctx); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
static void load_initial_sms_parts_from_storages (EnablingContext *ctx);
|
||||||
|
|
||||||
@@ -820,7 +816,24 @@ load_initial_sms_parts_from_storages (EnablingContext *ctx)
|
|||||||
return;
|
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
|
static void
|
||||||
enable_unsolicited_events_ready (MMIfaceModemMessaging *self,
|
enable_unsolicited_events_ready (MMIfaceModemMessaging *self,
|
||||||
@@ -989,10 +1002,29 @@ mm_iface_modem_messaging_enable (MMIfaceModemMessaging *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
interface_enabling_step (enabling_context_new (self,
|
EnablingContext *ctx;
|
||||||
cancellable,
|
|
||||||
|
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,
|
callback,
|
||||||
user_data));
|
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;
|
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
|
static void
|
||||||
initialization_context_complete_and_free (InitializationContext *ctx)
|
initialization_context_complete_and_free (InitializationContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -1269,9 +1278,6 @@ mm_iface_modem_messaging_initialize_finish (MMIfaceModemMessaging *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
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);
|
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,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
InitializationContext *ctx;
|
||||||
MmGdbusModemMessaging *skeleton = NULL;
|
MmGdbusModemMessaging *skeleton = NULL;
|
||||||
|
|
||||||
g_return_if_fail (MM_IS_IFACE_MODEM_MESSAGING (self));
|
|
||||||
|
|
||||||
/* Did we already create it? */
|
/* Did we already create it? */
|
||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_MESSAGING_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_MESSAGING_DBUS_SKELETON, &skeleton,
|
||||||
@@ -1304,18 +1309,23 @@ mm_iface_modem_messaging_initialize (MMIfaceModemMessaging *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Perform async initialization here */
|
/* Perform async initialization here */
|
||||||
interface_initialization_step (initialization_context_new (self,
|
|
||||||
cancellable,
|
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,
|
callback,
|
||||||
user_data));
|
user_data,
|
||||||
g_object_unref (skeleton);
|
mm_iface_modem_messaging_initialize);
|
||||||
|
ctx->step = INITIALIZATION_STEP_FIRST;
|
||||||
|
ctx->skeleton = skeleton;
|
||||||
|
|
||||||
|
interface_initialization_step (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mm_iface_modem_messaging_shutdown (MMIfaceModemMessaging *self)
|
mm_iface_modem_messaging_shutdown (MMIfaceModemMessaging *self)
|
||||||
{
|
{
|
||||||
g_return_if_fail (MM_IS_IFACE_MODEM_MESSAGING (self));
|
|
||||||
|
|
||||||
/* Unexport DBus interface and remove the skeleton */
|
/* Unexport DBus interface and remove the skeleton */
|
||||||
mm_gdbus_object_skeleton_set_modem_messaging (MM_GDBUS_OBJECT_SKELETON (self), NULL);
|
mm_gdbus_object_skeleton_set_modem_messaging (MM_GDBUS_OBJECT_SKELETON (self), NULL);
|
||||||
g_object_set (self,
|
g_object_set (self,
|
||||||
|
@@ -643,6 +643,15 @@ connection_step (ConnectionContext *ctx)
|
|||||||
g_object_get (ctx->self,
|
g_object_get (ctx->self,
|
||||||
MM_IFACE_MODEM_BEARER_LIST, &list,
|
MM_IFACE_MODEM_BEARER_LIST, &list,
|
||||||
NULL);
|
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);
|
bearer_properties = mm_simple_connect_properties_get_bearer_properties (ctx->properties);
|
||||||
|
|
||||||
@@ -891,6 +900,16 @@ disconnect_auth_ready (MMBaseModem *self,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_BEARER_LIST, &list,
|
MM_IFACE_MODEM_BEARER_LIST, &list,
|
||||||
NULL);
|
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,
|
mm_bearer_list_foreach (list,
|
||||||
(MMBearerListForeachFunc)build_connected_bearer_list,
|
(MMBearerListForeachFunc)build_connected_bearer_list,
|
||||||
ctx);
|
ctx);
|
||||||
@@ -968,8 +987,6 @@ mm_iface_modem_simple_initialize (MMIfaceModemSimple *self)
|
|||||||
{
|
{
|
||||||
MmGdbusModemSimple *skeleton = NULL;
|
MmGdbusModemSimple *skeleton = NULL;
|
||||||
|
|
||||||
g_return_if_fail (MM_IS_IFACE_MODEM_SIMPLE (self));
|
|
||||||
|
|
||||||
/* Did we already create it? */
|
/* Did we already create it? */
|
||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_SIMPLE_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_SIMPLE_DBUS_SKELETON, &skeleton,
|
||||||
@@ -1005,8 +1022,6 @@ mm_iface_modem_simple_initialize (MMIfaceModemSimple *self)
|
|||||||
void
|
void
|
||||||
mm_iface_modem_simple_shutdown (MMIfaceModemSimple *self)
|
mm_iface_modem_simple_shutdown (MMIfaceModemSimple *self)
|
||||||
{
|
{
|
||||||
g_return_if_fail (MM_IS_IFACE_MODEM_SIMPLE (self));
|
|
||||||
|
|
||||||
/* Unexport DBus interface and remove the skeleton */
|
/* Unexport DBus interface and remove the skeleton */
|
||||||
mm_gdbus_object_skeleton_set_modem_simple (MM_GDBUS_OBJECT_SKELETON (self), NULL);
|
mm_gdbus_object_skeleton_set_modem_simple (MM_GDBUS_OBJECT_SKELETON (self), NULL);
|
||||||
g_object_set (self,
|
g_object_set (self,
|
||||||
|
@@ -184,7 +184,8 @@ update_network_timezone_dictionary (MMIfaceModemTime *self,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_TIME_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_TIME_DBUS_SKELETON, &skeleton,
|
||||||
NULL);
|
NULL);
|
||||||
g_assert (skeleton != NULL);
|
if (!skeleton)
|
||||||
|
return;
|
||||||
|
|
||||||
dictionary = mm_network_timezone_get_dictionary (tz);
|
dictionary = mm_network_timezone_get_dictionary (tz);
|
||||||
mm_gdbus_modem_time_set_network_timezone (skeleton, dictionary);
|
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,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_TIME_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_TIME_DBUS_SKELETON, &skeleton,
|
||||||
NULL);
|
NULL);
|
||||||
|
if (!skeleton)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Notify about the updated network time */
|
/* Notify about the updated network time */
|
||||||
mm_gdbus_modem_time_emit_network_time_changed (skeleton, network_time);
|
mm_gdbus_modem_time_emit_network_time_changed (skeleton, network_time);
|
||||||
@@ -401,34 +404,13 @@ struct _DisablingContext {
|
|||||||
MmGdbusModemTime *skeleton;
|
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
|
static void
|
||||||
disabling_context_complete_and_free (DisablingContext *ctx)
|
disabling_context_complete_and_free (DisablingContext *ctx)
|
||||||
{
|
{
|
||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -548,9 +530,28 @@ mm_iface_modem_time_disable (MMIfaceModemTime *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
interface_disabling_step (disabling_context_new (self,
|
DisablingContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_new0 (DisablingContext, 1);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
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;
|
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
|
static void
|
||||||
enabling_context_complete_and_free (EnablingContext *ctx)
|
enabling_context_complete_and_free (EnablingContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -605,6 +582,7 @@ enabling_context_complete_and_free (EnablingContext *ctx)
|
|||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->cancellable);
|
g_object_unref (ctx->cancellable);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -768,10 +746,29 @@ mm_iface_modem_time_enable (MMIfaceModemTime *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
interface_enabling_step (enabling_context_new (self,
|
EnablingContext *ctx;
|
||||||
cancellable,
|
|
||||||
|
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,
|
callback,
|
||||||
user_data));
|
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;
|
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
|
static void
|
||||||
initialization_context_complete_and_free (InitializationContext *ctx)
|
initialization_context_complete_and_free (InitializationContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -955,9 +929,6 @@ mm_iface_modem_time_initialize_finish (MMIfaceModemTime *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
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);
|
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,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
InitializationContext *ctx;
|
||||||
MmGdbusModemTime *skeleton = NULL;
|
MmGdbusModemTime *skeleton = NULL;
|
||||||
|
|
||||||
g_return_if_fail (MM_IS_IFACE_MODEM_TIME (self));
|
|
||||||
|
|
||||||
/* Did we already create it? */
|
/* Did we already create it? */
|
||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_TIME_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_TIME_DBUS_SKELETON, &skeleton,
|
||||||
NULL);
|
NULL);
|
||||||
if (!skeleton) {
|
if (!skeleton) {
|
||||||
skeleton = mm_gdbus_modem_time_skeleton_new ();
|
skeleton = mm_gdbus_modem_time_skeleton_new ();
|
||||||
|
|
||||||
g_object_set (self,
|
g_object_set (self,
|
||||||
MM_IFACE_MODEM_TIME_DBUS_SKELETON, skeleton,
|
MM_IFACE_MODEM_TIME_DBUS_SKELETON, skeleton,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform async initialization here */
|
/* Perform async initialization here */
|
||||||
interface_initialization_step (initialization_context_new (self,
|
|
||||||
cancellable,
|
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,
|
callback,
|
||||||
user_data));
|
user_data,
|
||||||
g_object_unref (skeleton);
|
mm_iface_modem_time_initialize);
|
||||||
|
ctx->step = INITIALIZATION_STEP_FIRST;
|
||||||
|
ctx->skeleton = skeleton;
|
||||||
|
|
||||||
|
interface_initialization_step (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mm_iface_modem_time_shutdown (MMIfaceModemTime *self)
|
mm_iface_modem_time_shutdown (MMIfaceModemTime *self)
|
||||||
{
|
{
|
||||||
g_return_if_fail (MM_IS_IFACE_MODEM_TIME (self));
|
|
||||||
|
|
||||||
/* Unexport DBus interface and remove the skeleton */
|
/* Unexport DBus interface and remove the skeleton */
|
||||||
mm_gdbus_object_skeleton_set_modem_time (MM_GDBUS_OBJECT_SKELETON (self), NULL);
|
mm_gdbus_object_skeleton_set_modem_time (MM_GDBUS_OBJECT_SKELETON (self), NULL);
|
||||||
g_object_set (self,
|
g_object_set (self,
|
||||||
|
@@ -52,6 +52,8 @@ mm_iface_modem_bind_simple_status (MMIfaceModem *self,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
|
||||||
NULL);
|
NULL);
|
||||||
|
if (!skeleton)
|
||||||
|
return;
|
||||||
|
|
||||||
g_object_bind_property (skeleton, "state",
|
g_object_bind_property (skeleton, "state",
|
||||||
status, MM_SIMPLE_PROPERTY_STATE,
|
status, MM_SIMPLE_PROPERTY_STATE,
|
||||||
@@ -141,60 +143,64 @@ bearer_status_changed (MMBearer *bearer,
|
|||||||
g_object_unref (list);
|
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 *
|
MMBearer *
|
||||||
mm_iface_modem_create_bearer_finish (MMIfaceModem *self,
|
mm_iface_modem_create_bearer_finish (MMIfaceModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
MMBearer *bearer;
|
|
||||||
|
|
||||||
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
bearer = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
|
return g_object_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
|
||||||
|
|
||||||
return g_object_ref (bearer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
create_bearer_ready (MMIfaceModem *self,
|
create_bearer_ready (MMIfaceModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GSimpleAsyncResult *simple)
|
CreateBearerContext *ctx)
|
||||||
{
|
{
|
||||||
MMBearer *bearer;
|
MMBearer *bearer;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
bearer = MM_IFACE_MODEM_GET_INTERFACE (self)->create_bearer_finish (self,
|
bearer = MM_IFACE_MODEM_GET_INTERFACE (self)->create_bearer_finish (self, res, &error);
|
||||||
res,
|
if (error) {
|
||||||
&error);
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
if (error)
|
create_bearer_context_complete_and_free (ctx);
|
||||||
g_simple_async_result_take_error (simple, error);
|
return;
|
||||||
else {
|
}
|
||||||
MMBearerList *list = NULL;
|
|
||||||
|
|
||||||
g_object_get (self,
|
if (!mm_bearer_list_add_bearer (ctx->list, bearer, &error)) {
|
||||||
MM_IFACE_MODEM_BEARER_LIST, &list,
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
NULL);
|
create_bearer_context_complete_and_free (ctx);
|
||||||
|
g_object_unref (bearer);
|
||||||
|
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
|
/* If bearer properly created and added to the list, follow its
|
||||||
* status */
|
* status */
|
||||||
g_signal_connect (bearer,
|
g_signal_connect (bearer,
|
||||||
"notify::" MM_BEARER_STATUS,
|
"notify::" MM_BEARER_STATUS,
|
||||||
(GCallback)bearer_status_changed,
|
(GCallback)bearer_status_changed,
|
||||||
self);
|
self);
|
||||||
g_simple_async_result_set_op_res_gpointer (simple,
|
g_simple_async_result_set_op_res_gpointer (ctx->result, g_object_ref (bearer), g_object_unref);
|
||||||
g_object_ref (bearer),
|
create_bearer_context_complete_and_free (ctx);
|
||||||
g_object_unref);
|
|
||||||
}
|
|
||||||
g_object_unref (bearer);
|
|
||||||
g_object_unref (list);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_simple_async_result_complete (simple);
|
|
||||||
g_object_unref (simple);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -203,31 +209,43 @@ mm_iface_modem_create_bearer (MMIfaceModem *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
MMBearerList *list = NULL;
|
CreateBearerContext *ctx;
|
||||||
|
|
||||||
g_object_get (self,
|
ctx = g_slice_new (CreateBearerContext);
|
||||||
MM_IFACE_MODEM_BEARER_LIST, &list,
|
ctx->self = g_object_ref (self);
|
||||||
NULL);
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
|
|
||||||
if (mm_bearer_list_get_count (list) == mm_bearer_list_get_max (list))
|
|
||||||
g_simple_async_report_error_in_idle (
|
|
||||||
G_OBJECT (self),
|
|
||||||
callback,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
|
mm_iface_modem_create_bearer);
|
||||||
|
g_object_get (self,
|
||||||
|
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 (ctx->list) == mm_bearer_list_get_max (ctx->list)) {
|
||||||
|
g_simple_async_result_set_error (
|
||||||
|
ctx->result,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_TOO_MANY,
|
MM_CORE_ERROR_TOO_MANY,
|
||||||
"Cannot add new bearer: already reached maximum (%u)",
|
"Cannot add new bearer: already reached maximum (%u)",
|
||||||
mm_bearer_list_get_count (list));
|
mm_bearer_list_get_count (ctx->list));
|
||||||
else
|
create_bearer_context_complete_and_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MM_IFACE_MODEM_GET_INTERFACE (self)->create_bearer (
|
MM_IFACE_MODEM_GET_INTERFACE (self)->create_bearer (
|
||||||
self,
|
self,
|
||||||
properties,
|
properties,
|
||||||
(GAsyncReadyCallback)create_bearer_ready,
|
(GAsyncReadyCallback)create_bearer_ready,
|
||||||
g_simple_async_result_new (G_OBJECT (self),
|
ctx);
|
||||||
callback,
|
|
||||||
user_data,
|
|
||||||
mm_iface_modem_create_bearer));
|
|
||||||
g_object_unref (list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -431,6 +449,7 @@ typedef struct {
|
|||||||
MmGdbusModem *skeleton;
|
MmGdbusModem *skeleton;
|
||||||
GDBusMethodInvocation *invocation;
|
GDBusMethodInvocation *invocation;
|
||||||
MMIfaceModem *self;
|
MMIfaceModem *self;
|
||||||
|
MMBearerList *list;
|
||||||
gchar *bearer_path;
|
gchar *bearer_path;
|
||||||
} HandleDeleteBearerContext;
|
} HandleDeleteBearerContext;
|
||||||
|
|
||||||
@@ -440,6 +459,8 @@ handle_delete_bearer_context_free (HandleDeleteBearerContext *ctx)
|
|||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_object_unref (ctx->invocation);
|
g_object_unref (ctx->invocation);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
|
if (ctx->list)
|
||||||
|
g_object_unref (ctx->list);
|
||||||
g_free (ctx->bearer_path);
|
g_free (ctx->bearer_path);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -449,7 +470,6 @@ handle_delete_bearer_auth_ready (MMBaseModem *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
HandleDeleteBearerContext *ctx)
|
HandleDeleteBearerContext *ctx)
|
||||||
{
|
{
|
||||||
MMBearerList *list = NULL;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
||||||
@@ -458,16 +478,13 @@ handle_delete_bearer_auth_ready (MMBaseModem *self,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_get (self,
|
if (!ctx->list)
|
||||||
MM_IFACE_MODEM_BEARER_LIST, &list,
|
mm_gdbus_modem_complete_delete_bearer (ctx->skeleton, ctx->invocation);
|
||||||
NULL);
|
else if (!mm_bearer_list_delete_bearer (ctx->list, ctx->bearer_path, &error))
|
||||||
|
|
||||||
if (!mm_bearer_list_delete_bearer (list, ctx->bearer_path, &error))
|
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
else
|
else
|
||||||
mm_gdbus_modem_complete_delete_bearer (ctx->skeleton, ctx->invocation);
|
mm_gdbus_modem_complete_delete_bearer (ctx->skeleton, ctx->invocation);
|
||||||
|
|
||||||
g_object_unref (list);
|
|
||||||
handle_delete_bearer_context_free (ctx);
|
handle_delete_bearer_context_free (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,6 +501,9 @@ handle_delete_bearer (MmGdbusModem *skeleton,
|
|||||||
ctx->invocation = g_object_ref (invocation);
|
ctx->invocation = g_object_ref (invocation);
|
||||||
ctx->self = g_object_ref (self);
|
ctx->self = g_object_ref (self);
|
||||||
ctx->bearer_path = g_strdup (bearer);
|
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),
|
mm_base_modem_authorize (MM_BASE_MODEM (self),
|
||||||
invocation,
|
invocation,
|
||||||
@@ -506,6 +526,13 @@ handle_list_bearers (MmGdbusModem *skeleton,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_BEARER_LIST, &list,
|
MM_IFACE_MODEM_BEARER_LIST, &list,
|
||||||
NULL);
|
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);
|
paths = mm_bearer_list_get_paths (list);
|
||||||
mm_gdbus_modem_complete_list_bearers (skeleton,
|
mm_gdbus_modem_complete_list_bearers (skeleton,
|
||||||
@@ -717,9 +744,6 @@ get_last_signal_quality_update_time (MMIfaceModem *self)
|
|||||||
static gboolean
|
static gboolean
|
||||||
expire_signal_quality (MMIfaceModem *self)
|
expire_signal_quality (MMIfaceModem *self)
|
||||||
{
|
{
|
||||||
GVariant *old;
|
|
||||||
guint signal_quality = 0;
|
|
||||||
gboolean recent = FALSE;
|
|
||||||
MmGdbusModem *skeleton = NULL;
|
MmGdbusModem *skeleton = NULL;
|
||||||
SignalQualityUpdateContext *ctx;
|
SignalQualityUpdateContext *ctx;
|
||||||
|
|
||||||
@@ -727,6 +751,11 @@ expire_signal_quality (MMIfaceModem *self)
|
|||||||
MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
if (skeleton) {
|
||||||
|
GVariant *old;
|
||||||
|
guint signal_quality = 0;
|
||||||
|
gboolean recent = FALSE;
|
||||||
|
|
||||||
old = mm_gdbus_modem_get_signal_quality (skeleton);
|
old = mm_gdbus_modem_get_signal_quality (skeleton);
|
||||||
g_variant_get (old,
|
g_variant_get (old,
|
||||||
"(ub)",
|
"(ub)",
|
||||||
@@ -745,6 +774,7 @@ expire_signal_quality (MMIfaceModem *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (skeleton);
|
g_object_unref (skeleton);
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove source id */
|
/* Remove source id */
|
||||||
ctx = g_object_get_qdata (G_OBJECT (self), signal_quality_update_context_quark);
|
ctx = g_object_get_qdata (G_OBJECT (self), signal_quality_update_context_quark);
|
||||||
@@ -968,6 +998,14 @@ mm_iface_modem_update_state (MMIfaceModem *self,
|
|||||||
MM_IFACE_MODEM_BEARER_LIST, &bearer_list,
|
MM_IFACE_MODEM_BEARER_LIST, &bearer_list,
|
||||||
NULL);
|
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
|
/* While connected we don't want registration status changes to change
|
||||||
* the modem's state away from CONNECTED. */
|
* the modem's state away from CONNECTED. */
|
||||||
if ((new_state == MM_MODEM_STATE_SEARCHING ||
|
if ((new_state == MM_MODEM_STATE_SEARCHING ||
|
||||||
@@ -1463,7 +1501,9 @@ set_bands_context_complete_and_free (SetBandsContext *ctx)
|
|||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
|
if (ctx->bands_array)
|
||||||
g_array_unref (ctx->bands_array);
|
g_array_unref (ctx->bands_array);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -1576,9 +1616,6 @@ mm_iface_modem_set_bands (MMIfaceModem *self,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bands_string = mm_common_build_bands_string ((MMModemBand *)bands_array->data,
|
|
||||||
bands_array->len);
|
|
||||||
|
|
||||||
/* Setup context */
|
/* Setup context */
|
||||||
ctx = g_new0 (SetBandsContext, 1);
|
ctx = g_new0 (SetBandsContext, 1);
|
||||||
ctx->self = g_object_ref (self);
|
ctx->self = g_object_ref (self);
|
||||||
@@ -1589,6 +1626,17 @@ mm_iface_modem_set_bands (MMIfaceModem *self,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_DBUS_SKELETON, &ctx->skeleton,
|
MM_IFACE_MODEM_DBUS_SKELETON, &ctx->skeleton,
|
||||||
NULL);
|
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 */
|
/* Get list of supported bands */
|
||||||
supported_bands_array = (mm_common_bands_variant_to_garray (
|
supported_bands_array = (mm_common_bands_variant_to_garray (
|
||||||
@@ -1776,6 +1824,7 @@ set_allowed_modes_context_complete_and_free (SetAllowedModesContext *ctx)
|
|||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -1839,6 +1888,15 @@ mm_iface_modem_set_allowed_modes (MMIfaceModem *self,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_DBUS_SKELETON, &ctx->skeleton,
|
MM_IFACE_MODEM_DBUS_SKELETON, &ctx->skeleton,
|
||||||
NULL);
|
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 */
|
/* Get list of supported modes */
|
||||||
supported = mm_gdbus_modem_get_supported_modes (ctx->skeleton);
|
supported = mm_gdbus_modem_get_supported_modes (ctx->skeleton);
|
||||||
|
|
||||||
@@ -2002,41 +2060,22 @@ handle_set_allowed_modes (MmGdbusModem *skeleton,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
typedef struct _UnlockCheckContext UnlockCheckContext;
|
typedef struct {
|
||||||
struct _UnlockCheckContext {
|
|
||||||
MMIfaceModem *self;
|
MMIfaceModem *self;
|
||||||
guint pin_check_tries;
|
guint pin_check_tries;
|
||||||
guint pin_check_timeout_id;
|
guint pin_check_timeout_id;
|
||||||
GSimpleAsyncResult *result;
|
GSimpleAsyncResult *result;
|
||||||
MmGdbusModem *skeleton;
|
MmGdbusModem *skeleton;
|
||||||
MMModemLock lock;
|
MMModemLock lock;
|
||||||
};
|
} UnlockCheckContext;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
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->result);
|
||||||
|
g_object_unref (ctx->self);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -2145,8 +2184,7 @@ modem_after_sim_unlock_ready (MMIfaceModem *self,
|
|||||||
g_simple_async_result_set_op_res_gpointer (ctx->result,
|
g_simple_async_result_set_op_res_gpointer (ctx->result,
|
||||||
GUINT_TO_POINTER (ctx->lock),
|
GUINT_TO_POINTER (ctx->lock),
|
||||||
NULL);
|
NULL);
|
||||||
g_simple_async_result_complete (ctx->result);
|
unlock_check_context_complete_and_free (ctx);
|
||||||
unlock_check_context_free (ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2175,8 +2213,7 @@ unlock_check_ready (MMIfaceModem *self,
|
|||||||
MM_MOBILE_EQUIPMENT_ERROR,
|
MM_MOBILE_EQUIPMENT_ERROR,
|
||||||
MM_MOBILE_EQUIPMENT_ERROR_SIM_WRONG)) {
|
MM_MOBILE_EQUIPMENT_ERROR_SIM_WRONG)) {
|
||||||
g_simple_async_result_take_error (ctx->result, error);
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
g_simple_async_result_complete (ctx->result);
|
unlock_check_context_complete_and_free (ctx);
|
||||||
unlock_check_context_free (ctx);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2226,8 +2263,7 @@ unlock_check_ready (MMIfaceModem *self,
|
|||||||
g_simple_async_result_set_op_res_gpointer (ctx->result,
|
g_simple_async_result_set_op_res_gpointer (ctx->result,
|
||||||
GUINT_TO_POINTER (ctx->lock),
|
GUINT_TO_POINTER (ctx->lock),
|
||||||
NULL);
|
NULL);
|
||||||
g_simple_async_result_complete (ctx->result);
|
unlock_check_context_complete_and_free (ctx);
|
||||||
unlock_check_context_free (ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -2237,7 +2273,23 @@ mm_iface_modem_unlock_check (MMIfaceModem *self,
|
|||||||
{
|
{
|
||||||
UnlockCheckContext *ctx;
|
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 we're already unlocked, we're done */
|
||||||
if (mm_gdbus_modem_get_unlock_required (ctx->skeleton) != MM_MODEM_LOCK_NONE &&
|
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,
|
g_simple_async_result_set_op_res_gpointer (ctx->result,
|
||||||
GUINT_TO_POINTER (MM_MODEM_LOCK_NONE),
|
GUINT_TO_POINTER (MM_MODEM_LOCK_NONE),
|
||||||
NULL);
|
NULL);
|
||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
unlock_check_context_complete_and_free (ctx);
|
||||||
unlock_check_context_free (ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -2284,6 +2335,8 @@ update_unlock_retries (MMIfaceModem *self,
|
|||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
|
||||||
NULL);
|
NULL);
|
||||||
|
if (!skeleton)
|
||||||
|
return;
|
||||||
|
|
||||||
previous_dictionary = mm_gdbus_modem_get_unlock_retries (skeleton);
|
previous_dictionary = mm_gdbus_modem_get_unlock_retries (skeleton);
|
||||||
previous_unlock_retries = mm_unlock_retries_new_from_dictionary (previous_dictionary);
|
previous_unlock_retries = mm_unlock_retries_new_from_dictionary (previous_dictionary);
|
||||||
@@ -2381,33 +2434,6 @@ struct _DisablingContext {
|
|||||||
MmGdbusModem *skeleton;
|
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
|
static void
|
||||||
disabling_context_complete_and_free (DisablingContext *ctx)
|
disabling_context_complete_and_free (DisablingContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -2425,6 +2451,7 @@ disabling_context_complete_and_free (DisablingContext *ctx)
|
|||||||
|
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -2514,9 +2541,33 @@ mm_iface_modem_disable (MMIfaceModem *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
interface_disabling_step (disabling_context_new (self,
|
DisablingContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_new0 (DisablingContext, 1);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
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;
|
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
|
static void
|
||||||
enabling_context_complete_and_free (EnablingContext *ctx)
|
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_iface_modem_update_state (ctx->self,
|
||||||
MM_MODEM_STATE_ENABLED,
|
MM_MODEM_STATE_ENABLED,
|
||||||
MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED);
|
MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED);
|
||||||
else {
|
else if (ctx->skeleton) {
|
||||||
MMModemLock lock;
|
MMModemLock lock;
|
||||||
|
|
||||||
/* Fallback to DISABLED/LOCKED */
|
/* Fallback to DISABLED/LOCKED */
|
||||||
@@ -2604,6 +2627,7 @@ enabling_context_complete_and_free (EnablingContext *ctx)
|
|||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->cancellable);
|
g_object_unref (ctx->cancellable);
|
||||||
|
if (ctx->skeleton)
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -2926,10 +2950,33 @@ mm_iface_modem_enable (MMIfaceModem *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
interface_enabling_step (enabling_context_new (self,
|
EnablingContext *ctx;
|
||||||
cancellable,
|
|
||||||
|
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,
|
callback,
|
||||||
user_data));
|
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;
|
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
|
static void
|
||||||
initialization_context_complete_and_free (InitializationContext *ctx)
|
initialization_context_complete_and_free (InitializationContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -3648,9 +3672,6 @@ mm_iface_modem_initialize_finish (MMIfaceModem *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
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);
|
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,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
InitializationContext *ctx;
|
||||||
MmGdbusModem *skeleton = NULL;
|
MmGdbusModem *skeleton = NULL;
|
||||||
|
|
||||||
g_return_if_fail (MM_IS_IFACE_MODEM (self));
|
|
||||||
|
|
||||||
/* Did we already create it? */
|
/* Did we already create it? */
|
||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
|
MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
|
||||||
@@ -3707,19 +3727,22 @@ mm_iface_modem_initialize (MMIfaceModem *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Perform async initialization here */
|
/* Perform async initialization here */
|
||||||
interface_initialization_step (initialization_context_new (self,
|
ctx = g_new0 (InitializationContext, 1);
|
||||||
cancellable,
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->cancellable = g_object_ref (cancellable);
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
user_data,
|
||||||
g_object_unref (skeleton);
|
mm_iface_modem_initialize);
|
||||||
return;
|
ctx->step = INITIALIZATION_STEP_FIRST;
|
||||||
|
ctx->skeleton = skeleton;
|
||||||
|
|
||||||
|
interface_initialization_step (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mm_iface_modem_shutdown (MMIfaceModem *self)
|
mm_iface_modem_shutdown (MMIfaceModem *self)
|
||||||
{
|
{
|
||||||
g_return_if_fail (MM_IS_IFACE_MODEM (self));
|
|
||||||
|
|
||||||
/* Remove SignalQualityCheckContext object to make sure any pending
|
/* Remove SignalQualityCheckContext object to make sure any pending
|
||||||
* invocation of periodic_signal_quality_check is cancelled before
|
* invocation of periodic_signal_quality_check is cancelled before
|
||||||
* SignalQualityUpdateContext is removed (as signal_quality_check_ready may
|
* SignalQualityUpdateContext is removed (as signal_quality_check_ready may
|
||||||
|
Reference in New Issue
Block a user