base-modem: new virtual initialize() method
Whenever the first AT port is grabbed, we launch the initialize() method, which must have been implemented by the corresponding modem subclass.
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
#include <mm-gdbus-modem.h>
|
#include <mm-gdbus-modem.h>
|
||||||
|
|
||||||
#include "mm-base-modem.h"
|
#include "mm-base-modem.h"
|
||||||
|
|
||||||
#include "mm-errors.h"
|
#include "mm-errors.h"
|
||||||
#include "mm-log.h"
|
#include "mm-log.h"
|
||||||
#include "mm-at-serial-port.h"
|
#include "mm-at-serial-port.h"
|
||||||
@@ -144,6 +145,23 @@ serial_port_timed_out_cb (MMSerialPort *port,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
initialize_ready (MMBaseModem *self,
|
||||||
|
GAsyncResult *res)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!MM_BASE_MODEM_GET_CLASS (self)->initialize_finish (self, res, &error)) {
|
||||||
|
mm_warn ("couldn't initialize the modem: '%s'", error->message);
|
||||||
|
mm_base_modem_set_valid (self, FALSE);
|
||||||
|
g_error_free (error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mm_dbg ("modem properly initialized");
|
||||||
|
mm_base_modem_set_valid (self, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mm_base_modem_grab_port (MMBaseModem *self,
|
mm_base_modem_grab_port (MMBaseModem *self,
|
||||||
const gchar *subsys,
|
const gchar *subsys,
|
||||||
@@ -247,21 +265,12 @@ mm_base_modem_grab_port (MMBaseModem *self,
|
|||||||
if (!self->priv->data)
|
if (!self->priv->data)
|
||||||
self->priv->data = g_object_ref (port);
|
self->priv->data = g_object_ref (port);
|
||||||
|
|
||||||
/* TODO: GSM */
|
/* As soon as we get the primary AT port, we initialize the
|
||||||
/* /\* Get the modem's general info *\/ */
|
* modem */
|
||||||
/* initial_info_check (self); */
|
MM_BASE_MODEM_GET_CLASS (self)->initialize (self,
|
||||||
/* /\* Get modem's IMEI *\/ */
|
NULL, /* TODO: cancellable */
|
||||||
/* initial_imei_check (self); */
|
(GAsyncReadyCallback)initialize_ready,
|
||||||
/* /\* Get modem's initial lock/unlock state; this also ensures the */
|
NULL);
|
||||||
/* * SIM is ready by waiting if necessary for the SIM to initalize. */
|
|
||||||
/* *\/ */
|
|
||||||
/* initial_pin_check (self); */
|
|
||||||
|
|
||||||
/* TODO: CDMA */
|
|
||||||
/* /\* Get the modem's general info *\/ */
|
|
||||||
/* initial_info_check (self); */
|
|
||||||
/* /\* Get modem's ESN number *\/ */
|
|
||||||
/* initial_esn_check (self); */
|
|
||||||
|
|
||||||
} else if (ptype == MM_PORT_TYPE_SECONDARY)
|
} else if (ptype == MM_PORT_TYPE_SECONDARY)
|
||||||
self->priv->secondary = g_object_ref (port);
|
self->priv->secondary = g_object_ref (port);
|
||||||
@@ -293,7 +302,6 @@ mm_base_modem_grab_port (MMBaseModem *self,
|
|||||||
self->priv->data = g_object_ref (port);
|
self->priv->data = g_object_ref (port);
|
||||||
|
|
||||||
/* TODO: */
|
/* TODO: */
|
||||||
/* g_object_notify (G_OBJECT (self), MM_MODEM_DATA_DEVICE); */
|
|
||||||
/* check_valid (self); */
|
/* check_valid (self); */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -55,6 +55,16 @@ struct _MMBaseModem {
|
|||||||
|
|
||||||
struct _MMBaseModemClass {
|
struct _MMBaseModemClass {
|
||||||
MmGdbusObjectSkeletonClass parent;
|
MmGdbusObjectSkeletonClass parent;
|
||||||
|
|
||||||
|
/* Modem initialization.
|
||||||
|
* Whenever the primary AT port is grabbed, this method gets called */
|
||||||
|
void (* initialize) (MMBaseModem *self,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
gboolean (*initialize_finish) (MMBaseModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType mm_base_modem_get_type (void);
|
GType mm_base_modem_get_type (void);
|
||||||
|
Reference in New Issue
Block a user