iface-modem: let different SIM object creation implementations
We let objects implementing the Modem interface to provide their own SIM creation method. This allows plugins to subclass MMSim themselves.
This commit is contained in:
@@ -2426,12 +2426,16 @@ sim_new_ready (GAsyncInitable *initable,
|
|||||||
MMSim *sim;
|
MMSim *sim;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
sim = mm_sim_new_finish (initable, res, &error);
|
sim = MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim_finish (ctx->self, res, &error);
|
||||||
if (!sim) {
|
if (!sim) {
|
||||||
|
/* FATAL */
|
||||||
mm_warn ("couldn't create SIM: '%s'",
|
mm_warn ("couldn't create SIM: '%s'",
|
||||||
error ? error->message : "Unknown error");
|
error ? error->message : "Unknown error");
|
||||||
g_clear_error (&error);
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
} else {
|
initialization_context_complete_and_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
g_object_bind_property (sim, MM_SIM_PATH,
|
g_object_bind_property (sim, MM_SIM_PATH,
|
||||||
ctx->skeleton, "sim",
|
ctx->skeleton, "sim",
|
||||||
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||||
@@ -2440,7 +2444,6 @@ sim_new_ready (GAsyncInitable *initable,
|
|||||||
MM_IFACE_MODEM_SIM, sim,
|
MM_IFACE_MODEM_SIM, sim,
|
||||||
NULL);
|
NULL);
|
||||||
g_object_unref (sim);
|
g_object_unref (sim);
|
||||||
}
|
|
||||||
|
|
||||||
/* Go on to next step */
|
/* Go on to next step */
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
@@ -2685,15 +2688,18 @@ interface_initialization_step (InitializationContext *ctx)
|
|||||||
/* Fall down to next step */
|
/* Fall down to next step */
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
|
|
||||||
case INITIALIZATION_STEP_SIM: {
|
case INITIALIZATION_STEP_SIM:
|
||||||
|
/* If the modem doesn't need any SIM, skip */
|
||||||
|
if (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim &&
|
||||||
|
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim_finish) {
|
||||||
MMSim *sim = NULL;
|
MMSim *sim = NULL;
|
||||||
|
|
||||||
g_object_get (ctx->self,
|
g_object_get (ctx->self,
|
||||||
MM_IFACE_MODEM_SIM, &sim,
|
MM_IFACE_MODEM_SIM, &sim,
|
||||||
NULL);
|
NULL);
|
||||||
if (!sim) {
|
if (!sim) {
|
||||||
mm_sim_new (MM_BASE_MODEM (ctx->self),
|
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim (
|
||||||
NULL, /* TODO: cancellable */
|
MM_IFACE_MODEM (ctx->self),
|
||||||
(GAsyncReadyCallback)sim_new_ready,
|
(GAsyncReadyCallback)sim_new_ready,
|
||||||
ctx);
|
ctx);
|
||||||
return;
|
return;
|
||||||
@@ -2706,6 +2712,7 @@ interface_initialization_step (InitializationContext *ctx)
|
|||||||
NULL, /* TODO: cancellable */
|
NULL, /* TODO: cancellable */
|
||||||
(GAsyncReadyCallback)sim_reinit_ready,
|
(GAsyncReadyCallback)sim_reinit_ready,
|
||||||
ctx);
|
ctx);
|
||||||
|
g_object_unref (sim);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include "mm-charsets.h"
|
#include "mm-charsets.h"
|
||||||
#include "mm-at-serial-port.h"
|
#include "mm-at-serial-port.h"
|
||||||
#include "mm-bearer.h"
|
#include "mm-bearer.h"
|
||||||
|
#include "mm-sim.h"
|
||||||
|
|
||||||
#define MM_TYPE_IFACE_MODEM (mm_iface_modem_get_type ())
|
#define MM_TYPE_IFACE_MODEM (mm_iface_modem_get_type ())
|
||||||
#define MM_IFACE_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_IFACE_MODEM, MMIfaceModem))
|
#define MM_IFACE_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_IFACE_MODEM, MMIfaceModem))
|
||||||
@@ -253,6 +254,14 @@ struct _MMIfaceModem {
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
/* Create SIM */
|
||||||
|
void (*create_sim) (MMIfaceModem *self,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
MMSim * (*create_sim_finish) (MMIfaceModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
/* Create bearer */
|
/* Create bearer */
|
||||||
void (*create_bearer) (MMIfaceModem *self,
|
void (*create_bearer) (MMIfaceModem *self,
|
||||||
MMCommonBearerProperties *properties,
|
MMCommonBearerProperties *properties,
|
||||||
|
Reference in New Issue
Block a user