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.
This commit is contained in:
Dan Williams
2010-03-04 20:06:17 -08:00
parent 3f7b173932
commit c915de5512
2 changed files with 30 additions and 9 deletions

View File

@@ -495,6 +495,16 @@ mm_generic_gsm_enable_complete (MMGenericGsm *modem,
mm_callback_info_schedule (info); mm_callback_info_schedule (info);
} }
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 static void
enable_done (MMSerialPort *port, enable_done (MMSerialPort *port,
GString *response, GString *response,
@@ -503,16 +513,15 @@ enable_done (MMSerialPort *port,
{ {
MMCallbackInfo *info = (MMCallbackInfo *) user_data; MMCallbackInfo *info = (MMCallbackInfo *) user_data;
/* Ignore power-up command errors, not all devices actually support /* Let subclasses handle the power up command response/error; many devices
* CFUN=1. * don't support +CFUN, but for those that do let them handle the error
* correctly.
*/ */
/* FIXME: instead of just ignoring errors, since we allow subclasses g_assert (MM_GENERIC_GSM_GET_CLASS (info->modem)->do_enable_power_up_done);
* to override the power-on command, make a class function for powering MM_GENERIC_GSM_GET_CLASS (info->modem)->do_enable_power_up_done (MM_GENERIC_GSM (info->modem),
* on the phone and let the subclass decided whether it wants to handle response,
* errors or ignore them. error,
*/ info);
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (info->modem), NULL, info);
} }
static void static void
@@ -2396,6 +2405,7 @@ mm_generic_gsm_class_init (MMGenericGsmClass *klass)
object_class->finalize = finalize; object_class->finalize = finalize;
klass->do_enable = real_do_enable; klass->do_enable = real_do_enable;
klass->do_enable_power_up_done = real_do_enable_power_up_done;
/* Properties */ /* Properties */
g_object_class_override_property (object_class, g_object_class_override_property (object_class,

View File

@@ -65,6 +65,17 @@ typedef struct {
* callback and user_data passed in here. * callback and user_data passed in here.
*/ */
void (*do_enable) (MMGenericGsm *self, MMModemFn callback, gpointer user_data); 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; } MMGenericGsmClass;
GType mm_generic_gsm_get_type (void); GType mm_generic_gsm_get_type (void);