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:
@@ -495,6 +495,16 @@ mm_generic_gsm_enable_complete (MMGenericGsm *modem,
|
||||
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
|
||||
enable_done (MMSerialPort *port,
|
||||
GString *response,
|
||||
@@ -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.
|
||||
/* 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.
|
||||
*/
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
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,
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user