aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2010-03-04 20:06:17 -0800
committerDan Williams <dcbw@redhat.com>2010-03-04 20:06:17 -0800
commitc915de5512f69678d0062ceec4cc69fefcdf8fd3 (patch)
tree8b72020b3e95735951df4561f303af9c0cb294b0
parent3f7b173932bfb23ce83bfab8a74490f7dc85a7f7 (diff)
gsm: add ability for subclasses to handle power-on response
This lets subclasses handle errors when they know the device supports the power-up command. Also will let us simplify a number of plugins.
-rw-r--r--src/mm-generic-gsm.c28
-rw-r--r--src/mm-generic-gsm.h11
2 files changed, 30 insertions, 9 deletions
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
index 28a3a4fa..eb1c6756 100644
--- a/src/mm-generic-gsm.c
+++ b/src/mm-generic-gsm.c
@@ -496,6 +496,16 @@ mm_generic_gsm_enable_complete (MMGenericGsm *modem,
}
static void
+real_do_enable_power_up_done (MMGenericGsm *self,
+ GString *response,
+ GError *error,
+ MMCallbackInfo *info)
+{
+ /* Ignore power-up errors as not all devices actually support CFUN=1 */
+ mm_generic_gsm_enable_complete (MM_GENERIC_GSM (info->modem), NULL, info);
+}
+
+static void
enable_done (MMSerialPort *port,
GString *response,
GError *error,
@@ -503,16 +513,15 @@ enable_done (MMSerialPort *port,
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
- /* Ignore power-up command errors, not all devices actually support
- * CFUN=1.
- */
- /* FIXME: instead of just ignoring errors, since we allow subclasses
- * to override the power-on command, make a class function for powering
- * on the phone and let the subclass decided whether it wants to handle
- * errors or ignore them.
+ /* Let subclasses handle the power up command response/error; many devices
+ * don't support +CFUN, but for those that do let them handle the error
+ * correctly.
*/
-
- mm_generic_gsm_enable_complete (MM_GENERIC_GSM (info->modem), NULL, info);
+ g_assert (MM_GENERIC_GSM_GET_CLASS (info->modem)->do_enable_power_up_done);
+ MM_GENERIC_GSM_GET_CLASS (info->modem)->do_enable_power_up_done (MM_GENERIC_GSM (info->modem),
+ response,
+ error,
+ info);
}
static void
@@ -2396,6 +2405,7 @@ mm_generic_gsm_class_init (MMGenericGsmClass *klass)
object_class->finalize = finalize;
klass->do_enable = real_do_enable;
+ klass->do_enable_power_up_done = real_do_enable_power_up_done;
/* Properties */
g_object_class_override_property (object_class,
diff --git a/src/mm-generic-gsm.h b/src/mm-generic-gsm.h
index 4f190f8b..7589cf98 100644
--- a/src/mm-generic-gsm.h
+++ b/src/mm-generic-gsm.h
@@ -65,6 +65,17 @@ typedef struct {
* callback and user_data passed in here.
*/
void (*do_enable) (MMGenericGsm *self, MMModemFn callback, gpointer user_data);
+
+ /* Called after the generic class has attempted to power up the modem.
+ * Subclasses can handle errors here if they know the device supports their
+ * power up command. Will only be called if the device does *not* override
+ * the MMModem enable() command or allows the generic class' do_enable()
+ * handler to execute.
+ */
+ void (*do_enable_power_up_done) (MMGenericGsm *self,
+ GString *response,
+ GError *error,
+ MMCallbackInfo *info);
} MMGenericGsmClass;
GType mm_generic_gsm_get_type (void);