aboutsummaryrefslogtreecommitdiff
path: root/src/mm-iface-modem.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-06-29 09:52:37 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-08-06 20:07:20 +0200
commit68c276efc1d7c856f8ce9790f384ae485fcaad66 (patch)
tree61a982822f45629778b884a34dd68f58a71786e8 /src/mm-iface-modem.c
parent3b1d3063ba9aacb6ecbb927de3f20bd938c45f55 (diff)
broadband-modem: new generic steps in initialization/enabling/disabling
Instead of hardcoding the logic to decide which ports are open or closed in the different steps, we now let the subclasses of MMBroadbandModem to do that themselves. We now provide: * initialization_started() and initialization_stopped(): the generic implementation does the serial port open/close in these steps. * enabling_started(): the generic implementation does the serial port opening here. The serial ports are kept open as long the modem is in enabled state. * disabling_stopped(): the generic implementation does the serial port closing here.
Diffstat (limited to 'src/mm-iface-modem.c')
-rw-r--r--src/mm-iface-modem.c125
1 files changed, 0 insertions, 125 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c
index 4e3378f6..d347281c 100644
--- a/src/mm-iface-modem.c
+++ b/src/mm-iface-modem.c
@@ -2290,15 +2290,11 @@ typedef enum {
DISABLING_STEP_CURRENT_BANDS,
DISABLING_STEP_ALLOWED_MODES,
DISABLING_STEP_MODEM_POWER_DOWN,
- DISABLING_STEP_CLOSE_PORTS,
DISABLING_STEP_LAST
} DisablingStep;
struct _DisablingContext {
MMIfaceModem *self;
- MMAtSerialPort *primary;
- MMAtSerialPort *secondary;
- MMQcdmSerialPort *qcdm;
DisablingStep step;
MMModemState previous_state;
gboolean disabled;
@@ -2315,9 +2311,6 @@ disabling_context_new (MMIfaceModem *self,
ctx = g_new0 (DisablingContext, 1);
ctx->self = g_object_ref (self);
- ctx->primary = mm_base_modem_get_port_primary (MM_BASE_MODEM (self));
- ctx->secondary = mm_base_modem_get_port_secondary (MM_BASE_MODEM (self));
- ctx->qcdm = mm_base_modem_get_port_qcdm (MM_BASE_MODEM (self));
ctx->result = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
@@ -2352,12 +2345,6 @@ disabling_context_complete_and_free (DisablingContext *ctx)
MM_MODEM_STATE_CHANGE_REASON_UNKNOWN);
g_object_unref (ctx->self);
- if (ctx->primary)
- g_object_unref (ctx->primary);
- if (ctx->secondary)
- g_object_unref (ctx->secondary);
- if (ctx->qcdm)
- g_object_unref (ctx->qcdm);
g_object_unref (ctx->result);
g_object_unref (ctx->skeleton);
g_free (ctx);
@@ -2432,22 +2419,6 @@ interface_disabling_step (DisablingContext *ctx)
/* Fall down to next step */
ctx->step++;
- case DISABLING_STEP_CLOSE_PORTS:
- /* While the modem is enabled ports are kept open, so we need to close
- * them when the modem gets disabled. As this (should) be the last
- * closing in order to get it really closed (open count = 1), it should
- * be safe to check whether they are really open before trying to close.
- */
- mm_dbg ("Closing all ports...");
- if (ctx->primary && mm_serial_port_is_open (MM_SERIAL_PORT (ctx->primary)))
- mm_serial_port_close (MM_SERIAL_PORT (ctx->primary));
- if (ctx->secondary && mm_serial_port_is_open (MM_SERIAL_PORT (ctx->secondary)))
- mm_serial_port_close (MM_SERIAL_PORT (ctx->secondary));
- if (ctx->qcdm && mm_serial_port_is_open (MM_SERIAL_PORT (ctx->qcdm)))
- mm_serial_port_close (MM_SERIAL_PORT (ctx->qcdm));
- /* Fall down to next step */
- ctx->step++;
-
case DISABLING_STEP_LAST:
/* We are done without errors! */
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
@@ -2477,8 +2448,6 @@ static void interface_enabling_step (EnablingContext *ctx);
typedef enum {
ENABLING_STEP_FIRST,
- ENABLING_STEP_OPEN_PORTS,
- ENABLING_STEP_FLASH_PORT,
ENABLING_STEP_MODEM_INIT,
ENABLING_STEP_MODEM_POWER_UP,
ENABLING_STEP_MODEM_AFTER_POWER_UP,
@@ -2492,12 +2461,6 @@ typedef enum {
struct _EnablingContext {
MMIfaceModem *self;
- MMAtSerialPort *primary;
- gboolean primary_open;
- MMAtSerialPort *secondary;
- gboolean secondary_open;
- MMQcdmSerialPort *qcdm;
- gboolean qcdm_open;
EnablingStep step;
MMModemCharset supported_charsets;
const MMModemCharset *current_charset;
@@ -2517,9 +2480,6 @@ enabling_context_new (MMIfaceModem *self,
ctx = g_new0 (EnablingContext, 1);
ctx->self = g_object_ref (self);
- ctx->primary = mm_base_modem_get_port_primary (MM_BASE_MODEM (self));
- ctx->secondary = mm_base_modem_get_port_secondary (MM_BASE_MODEM (self));
- ctx->qcdm = mm_base_modem_get_port_qcdm (MM_BASE_MODEM (self));
ctx->cancellable = g_object_ref (cancellable);
ctx->result = g_simple_async_result_new (G_OBJECT (self),
callback,
@@ -2560,23 +2520,9 @@ enabling_context_complete_and_free (EnablingContext *ctx)
MM_MODEM_STATE_DISABLED :
MM_MODEM_STATE_LOCKED),
MM_MODEM_STATE_CHANGE_REASON_UNKNOWN);
-
- /* Close the ports if enabling failed */
- if (ctx->primary_open)
- mm_serial_port_close (MM_SERIAL_PORT (ctx->primary));
- if (ctx->secondary_open)
- mm_serial_port_close (MM_SERIAL_PORT (ctx->secondary));
- if (ctx->qcdm_open)
- mm_serial_port_close (MM_SERIAL_PORT (ctx->qcdm));
}
g_object_unref (ctx->self);
- if (ctx->primary)
- g_object_unref (ctx->primary);
- if (ctx->secondary)
- g_object_unref (ctx->secondary);
- if (ctx->qcdm)
- g_object_unref (ctx->qcdm);
g_object_unref (ctx->result);
g_object_unref (ctx->cancellable);
g_object_unref (ctx->skeleton);
@@ -2731,24 +2677,6 @@ load_current_bands_ready (MMIfaceModem *self,
interface_enabling_step (ctx);
}
-static void
-interface_enabling_flash_done (MMSerialPort *port,
- GError *error,
- gpointer user_data)
-{
- EnablingContext *ctx = user_data;
-
- if (error) {
- g_simple_async_result_set_from_error (ctx->result, error);
- enabling_context_complete_and_free (ctx);
- return;
- }
-
- /* Go on to next step */
- ctx->step++;
- interface_enabling_step (ctx);
-}
-
static const MMModemCharset best_charsets[] = {
MM_MODEM_CHARSET_UTF8,
MM_MODEM_CHARSET_UCS2,
@@ -2770,59 +2698,6 @@ interface_enabling_step (EnablingContext *ctx)
/* Fall down to next step */
ctx->step++;
- case ENABLING_STEP_OPEN_PORTS: {
- GError *error = NULL;
-
- /* Open primary port */
- if (!ctx->primary) {
- g_simple_async_result_set_error (ctx->result,
- MM_CORE_ERROR,
- MM_CORE_ERROR_FAILED,
- "Cannot enable: no primary port");
- enabling_context_complete_and_free (ctx);
- return;
- }
-
- if (!mm_serial_port_open (MM_SERIAL_PORT (ctx->primary), &error)) {
- g_simple_async_result_take_error (ctx->result, error);
- enabling_context_complete_and_free (ctx);
- return;
- }
- ctx->primary_open = TRUE;
-
- /* If there is a secondary AT port, open it */
- if (ctx->secondary) {
- if (!mm_serial_port_open (MM_SERIAL_PORT (ctx->secondary), &error)) {
- g_simple_async_result_take_error (ctx->result, error);
- enabling_context_complete_and_free (ctx);
- return;
- }
- ctx->secondary_open = TRUE;
- }
-
- /* If there is a qcdm AT port, open it */
- if (ctx->qcdm) {
- if (!mm_serial_port_open (MM_SERIAL_PORT (ctx->qcdm), &error)) {
- g_simple_async_result_take_error (ctx->result, error);
- enabling_context_complete_and_free (ctx);
- return;
- }
- ctx->qcdm_open = TRUE;
- }
-
- /* Fall down to next step */
- ctx->step++;
- }
-
- case ENABLING_STEP_FLASH_PORT:
- /* Flash port */
- mm_serial_port_flash (MM_SERIAL_PORT (ctx->primary),
- 100,
- FALSE,
- interface_enabling_flash_done,
- ctx);
- return;
-
case ENABLING_STEP_MODEM_INIT:
if (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->modem_init &&
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->modem_init_finish) {