aboutsummaryrefslogtreecommitdiff
path: root/plugins/mm-modem-zte.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2011-04-18 22:08:19 -0500
committerDan Williams <dcbw@redhat.com>2011-04-18 22:08:19 -0500
commit8333fb657ab6e30e51aec8f4449dc4c505fea6f4 (patch)
tree2aca93c0b471dfb61cd9ae2c001873beed9fede3 /plugins/mm-modem-zte.c
parent74b1503c602e1268b5199ef36c9611d7cb08adc1 (diff)
icera: fix abuse of GInterface
The GInterface structure for MMModemIcera isn't instance data, thus we shouldn't be storing an instance pointer in it. Instead, make implemtors store the intstance data in their private structure, and have them implement an accessor for the Icera-private data. This makes everone (especially GObject) happy. It's a bit of additional indirection, but we still get to use the MM_MODEM_ICERA_GET_PRIVATE() and we still get to cast the passed-in GInterface MMModemIcera into the various GSM MMModem subclasses, which is all we ever wanted anyway.
Diffstat (limited to 'plugins/mm-modem-zte.c')
-rw-r--r--plugins/mm-modem-zte.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/plugins/mm-modem-zte.c b/plugins/mm-modem-zte.c
index e5446c2f..99652f57 100644
--- a/plugins/mm-modem-zte.c
+++ b/plugins/mm-modem-zte.c
@@ -43,6 +43,7 @@ typedef struct {
guint32 cpms_tries;
guint cpms_timeout;
gboolean is_icera;
+ MMModemIceraPrivate *icera;
} MMModemZtePrivate;
MMModem *
@@ -52,17 +53,23 @@ mm_modem_zte_new (const char *device,
guint32 vendor,
guint32 product)
{
+ MMModem *modem;
+
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
g_return_val_if_fail (plugin != NULL, NULL);
- return MM_MODEM (g_object_new (MM_TYPE_MODEM_ZTE,
- MM_MODEM_MASTER_DEVICE, device,
- MM_MODEM_DRIVER, driver,
- MM_MODEM_PLUGIN, plugin,
- MM_MODEM_HW_VID, vendor,
- MM_MODEM_HW_PID, product,
- NULL));
+ modem = MM_MODEM (g_object_new (MM_TYPE_MODEM_ZTE,
+ MM_MODEM_MASTER_DEVICE, device,
+ MM_MODEM_DRIVER, driver,
+ MM_MODEM_PLUGIN, plugin,
+ MM_MODEM_HW_VID, vendor,
+ MM_MODEM_HW_PID, product,
+ NULL));
+ if (modem)
+ MM_MODEM_ZTE_GET_PRIVATE (modem)->icera = mm_modem_icera_init_private ();
+
+ return modem;
}
/*****************************************************************************/
@@ -620,6 +627,14 @@ grab_port (MMModem *modem,
/*****************************************************************************/
+static MMModemIceraPrivate *
+get_icera_private (MMModemIcera *icera)
+{
+ return MM_MODEM_ZTE_GET_PRIVATE (icera)->icera;
+}
+
+/*****************************************************************************/
+
static void
modem_init (MMModem *modem_class)
{
@@ -630,9 +645,9 @@ modem_init (MMModem *modem_class)
}
static void
-modem_icera_init (MMModemIcera *icera_class)
+modem_icera_init (MMModemIcera *icera)
{
- mm_modem_icera_prepare (icera_class);
+ icera->get_private = get_icera_private;
}
static void
@@ -655,7 +670,7 @@ dispose (GObject *object)
if (priv->cpms_timeout)
g_source_remove (priv->cpms_timeout);
- mm_modem_icera_cleanup (MM_MODEM_ICERA (self));
+ mm_modem_icera_dispose_private (MM_MODEM_ICERA (self));
G_OBJECT_CLASS (mm_modem_zte_parent_class)->dispose (object);
}