Commit fb2ba5db authored by Chris T's avatar Chris T

Improve suspending from modem

parent 7b6b8c11
......@@ -527,13 +527,22 @@ pur_mm_get_modem_state (void)
mm_modem_set_power_state_sync (modem->modem, MM_MODEM_POWER_STATE_ON, NULL, &error);
pur_mm_state (PUR_MM_STATE_MODEM_DISABLED);
return FALSE;
case MM_MODEM_STATE_DISABLING:
mms_error("ModemManagerPlugin(): MM_MODEM_STATE_DISABLING");
pur_mm_state (PUR_MM_STATE_MODEM_DISABLED);
return FALSE;
case MM_MODEM_STATE_ENABLING:
mms_error("ModemManagerPlugin(): MM_MODEM_STATE_ENABLING");
pur_mm_state (PUR_MM_STATE_MODEM_DISABLED);
return FALSE;
default:
break;
mms_error("ModemManagerPlugin(): MM_MODEM_OTHER_BAD_STATE: %d", state);
pur_mm_state (PUR_MM_STATE_MODEM_DISABLED);
return FALSE;
}
} else {
mms_error("ModemManagerPlugin(): MM_MODEM_STATE_ENABLED");
}
mms_error("ModemManagerPlugin(): MM_MODEM_GOOD_STATE: %d", state);
pur_mm_state (PUR_MM_STATE_READY);
return TRUE;
}
......@@ -544,13 +553,7 @@ state_changed_cb(MMModem *cb_modem,
MMModemStateChangeReason reason)
{
mms_error("ModemManagerPlugin(): State Change: Old State: %d New State: %d, Reason: %d", old, new, reason);
if (new >= MM_MODEM_STATE_ENABLED) {
mms_error("ModemManagerPlugin(): Modem is ready");
g_signal_handler_disconnect (modem->gdbus_modem,
modem->modem_state_watch_id);
pur_mm_state (PUR_MM_STATE_MODEM_FOUND);
}
pur_mm_get_modem_state ();
}
......@@ -563,33 +566,28 @@ pur_mm_state (int state)
case PUR_MM_STATE_MODEM_FOUND:
if (!modem->modem_available) {
if (modem->modem) {
if (!pur_mm_get_modem_state ()) {
mms_error("ModemManagerPlugin(): There's a problem with the modem!");
modem->gdbus_modem = MM_GDBUS_MODEM(modem->modem);
mm_modem_get_sim (modem->modem,
NULL,
(GAsyncReadyCallback)cb_get_sim_ready,
NULL);
modem->gdbus_modem = MM_GDBUS_MODEM(modem->modem);
modem->modem_state_watch_id = g_signal_connect(modem->gdbus_modem,
modem->modem_state_watch_id = g_signal_connect(modem->gdbus_modem,
"state-changed",
G_CALLBACK(state_changed_cb),
NULL);
mms_error("ModemManagerPlugin(): Monitoring the modem to see if it will recover....");
break;
} else {
pur_mm_state (PUR_MM_STATE_READY);
mm_modem_get_sim (modem->modem,
NULL,
(GAsyncReadyCallback)cb_get_sim_ready,
NULL);
}
}
modem->modem_available = TRUE;
pur_mm_get_modem_state ();
}
mmsd_plugin_connect();
break;
case PUR_MM_STATE_NO_MODEM:
if (modem->modem_available) {
g_signal_handler_disconnect (modem->gdbus_modem,
modem->modem_state_watch_id);
mmsd_plugin_disconnect();
mms_error("ModemManagerPlugin(): Modem vanished, Disabling plugin");
} else {
mms_error("ModemManagerPlugin(): Could not connect to modem");
......@@ -599,20 +597,20 @@ pur_mm_state (int state)
break;
case PUR_MM_STATE_NO_MESSAGING_MODEM:
if (modem->modem_available) {
mmsd_plugin_disconnect();
mms_error("ModemManagerPlugin(): Modem has no messaging capabilities");
}
modem->modem_available = FALSE;
g_signal_handler_disconnect (modem->gdbus_modem,
modem->modem_state_watch_id);
mmsd_plugin_disconnect();
mms_error("ModemManagerPlugin(): Modem has no messaging capabilities");
mms_error("ModemManagerPlugin(): PUR_MM_STATE_NO_MESSAGING_MODEM");
modem->modem_available = FALSE;
break;
case PUR_MM_STATE_MODEM_DISABLED:
mms_error("ModemManagerPlugin(): Modem disabled");
modem->modem_available = FALSE;
mms_error("ModemManagerPlugin(): PUR_MM_STATE_MODEM_DISABLED");
mms_service_set_bearer_handler(modem->service, NULL, NULL);
modem->modem_available = FALSE;
break;
case PUR_MM_STATE_MANAGER_FOUND:
......@@ -652,12 +650,13 @@ pur_mm_state (int state)
case PUR_MM_STATE_MODEM_UNLOCK_ERROR:
mms_error("ModemManagerPlugin(): SIM card unlock failed");
mms_error("ModemManagerPlugin(): PUR_MM_STATE_MODEM_UNLOCK_ERROR");
break;
case PUR_MM_STATE_READY:
mms_error("ModemManagerPlugin(): PUR_MM_STATE_READY");
modem->modem_available = TRUE;
mmsd_plugin_connect();
break;
default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment