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:
Aleksander Morgado
2011-11-08 17:20:34 +01:00
parent 677e04be95
commit b00c409978
2 changed files with 34 additions and 16 deletions

View File

@@ -27,6 +27,7 @@
#include <mm-gdbus-modem.h>
#include "mm-base-modem.h"
#include "mm-errors.h"
#include "mm-log.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
mm_base_modem_grab_port (MMBaseModem *self,
const gchar *subsys,
@@ -247,21 +265,12 @@ mm_base_modem_grab_port (MMBaseModem *self,
if (!self->priv->data)
self->priv->data = g_object_ref (port);
/* TODO: GSM */
/* /\* Get the modem's general info *\/ */
/* initial_info_check (self); */
/* /\* Get modem's IMEI *\/ */
/* initial_imei_check (self); */
/* /\* Get modem's initial lock/unlock state; this also ensures the */
/* * 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); */
/* As soon as we get the primary AT port, we initialize the
* modem */
MM_BASE_MODEM_GET_CLASS (self)->initialize (self,
NULL, /* TODO: cancellable */
(GAsyncReadyCallback)initialize_ready,
NULL);
} else if (ptype == MM_PORT_TYPE_SECONDARY)
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);
/* TODO: */
/* g_object_notify (G_OBJECT (self), MM_MODEM_DATA_DEVICE); */
/* check_valid (self); */
}

View File

@@ -55,6 +55,16 @@ struct _MMBaseModem {
struct _MMBaseModemClass {
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);