aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-07-10 07:00:46 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-08-06 20:06:44 +0200
commit0aff871b04b76ca45aa9afbf7f1c88cb65c0e80d (patch)
tree50fa99164b357836a7a252a3b8dac08bef21c9e3 /src
parent815693661c7f6a4225d271d2cec67e59bad8e070 (diff)
device: split `MMDevice' creation and plugin setting
We want to be able to create the MMDevice way before we have decided which plugin to use.
Diffstat (limited to 'src')
-rw-r--r--src/mm-device.c21
-rw-r--r--src/mm-device.h5
-rw-r--r--src/mm-manager.c4
3 files changed, 20 insertions, 10 deletions
diff --git a/src/mm-device.c b/src/mm-device.c
index 3f6859a0..dfeaf6d4 100644
--- a/src/mm-device.c
+++ b/src/mm-device.c
@@ -262,6 +262,15 @@ mm_device_get_udev_device (MMDevice *self)
return G_UDEV_DEVICE (g_object_ref (self->priv->udev_device));
}
+void
+mm_device_set_plugin (MMDevice *self,
+ MMPlugin *plugin)
+{
+ g_object_set (self,
+ MM_DEVICE_PLUGIN, plugin,
+ NULL);
+}
+
MMPlugin *
mm_device_peek_plugin (MMDevice *self)
{
@@ -271,7 +280,9 @@ mm_device_peek_plugin (MMDevice *self)
MMPlugin *
mm_device_get_plugin (MMDevice *self)
{
- return MM_PLUGIN (g_object_ref (self->priv->plugin));
+ return (self->priv->plugin ?
+ MM_PLUGIN (g_object_ref (self->priv->plugin)) :
+ NULL);
}
MMBaseModem *
@@ -293,12 +304,10 @@ mm_device_get_modem (MMDevice *self)
/*****************************************************************************/
MMDevice *
-mm_device_new (GUdevDevice *udev_device,
- MMPlugin *plugin)
+mm_device_new (GUdevDevice *udev_device)
{
return MM_DEVICE (g_object_new (MM_TYPE_DEVICE,
MM_DEVICE_UDEV_DEVICE, udev_device,
- MM_DEVICE_PLUGIN, plugin,
NULL));
}
@@ -325,7 +334,7 @@ set_property (GObject *object,
self->priv->udev_device = g_value_dup_object (value);
break;
case PROP_PLUGIN:
- /* construct only */
+ g_clear_object (&(self->priv->plugin));
self->priv->plugin = g_value_dup_object (value);
break;
case PROP_MODEM:
@@ -400,7 +409,7 @@ mm_device_class_init (MMDeviceClass *klass)
"Plugin",
"Best plugin to manage this device",
MM_TYPE_PLUGIN,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+ G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_PLUGIN, properties[PROP_PLUGIN]);
properties[PROP_MODEM] =
diff --git a/src/mm-device.h b/src/mm-device.h
index dab11b7e..7eee70e3 100644
--- a/src/mm-device.h
+++ b/src/mm-device.h
@@ -49,8 +49,7 @@ struct _MMDeviceClass {
GType mm_device_get_type (void);
-MMDevice *mm_device_new (GUdevDevice *udev_device,
- MMPlugin *plugin);
+MMDevice *mm_device_new (GUdevDevice *udev_device);
void mm_device_grab_port (MMDevice *self,
GUdevDevice *udev_port);
@@ -66,6 +65,8 @@ void mm_device_remove_modem (MMDevice *self);
GUdevDevice *mm_device_peek_udev_device (MMDevice *self);
GUdevDevice *mm_device_get_udev_device (MMDevice *self);
+void mm_device_set_plugin (MMDevice *self,
+ MMPlugin *plugin);
MMPlugin *mm_device_peek_plugin (MMDevice *self);
MMPlugin *mm_device_get_plugin (MMDevice *self);
MMBaseModem *mm_device_peek_modem (MMDevice *self);
diff --git a/src/mm-manager.c b/src/mm-manager.c
index fc1e4292..a3323d88 100644
--- a/src/mm-manager.c
+++ b/src/mm-manager.c
@@ -173,8 +173,8 @@ find_port_support_ready_cb (MMPluginManager *plugin_manager,
if (!device) {
/* Create a generic device to track the available ports, and add it to the
* manager. */
- device = mm_device_new (ctx->physical_device,
- best_plugin);
+ device = mm_device_new (ctx->physical_device);
+ mm_device_set_plugin (device, best_plugin);
g_hash_table_insert (ctx->manager->priv->devices,
g_strdup (g_udev_device_get_sysfs_path (mm_device_peek_udev_device (device))),
device);