aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mm-device.c17
-rw-r--r--src/mm-device.h9
-rw-r--r--src/mm-plugin-manager.c12
-rw-r--r--src/mm-plugin.c6
-rw-r--r--src/mm-plugin.h5
5 files changed, 26 insertions, 23 deletions
diff --git a/src/mm-device.c b/src/mm-device.c
index 031b1fb8..00f1a9e7 100644
--- a/src/mm-device.c
+++ b/src/mm-device.c
@@ -23,6 +23,7 @@
#include <mm-errors-types.h>
#include "mm-device.h"
+#include "mm-plugin.h"
#include "mm-utils.h"
#include "mm-log.h"
@@ -377,9 +378,7 @@ mm_device_create_modem (MMDevice *self,
mm_plugin_get_name (self->priv->plugin),
g_list_length (self->priv->port_probes));
- self->priv->modem = mm_plugin_create_modem (self->priv->plugin,
- G_OBJECT (self),
- error);
+ self->priv->modem = mm_plugin_create_modem (self->priv->plugin, self, error);
if (self->priv->modem) {
/* Keep the object manager */
self->priv->object_manager = g_object_ref (object_manager);
@@ -434,24 +433,26 @@ mm_device_get_udev_device (MMDevice *self)
void
mm_device_set_plugin (MMDevice *self,
- MMPlugin *plugin)
+ GObject *plugin)
{
g_object_set (self,
MM_DEVICE_PLUGIN, plugin,
NULL);
}
-MMPlugin *
+GObject *
mm_device_peek_plugin (MMDevice *self)
{
- return self->priv->plugin;
+ return (self->priv->plugin ?
+ G_OBJECT (self->priv->plugin) :
+ NULL);
}
-MMPlugin *
+GObject *
mm_device_get_plugin (MMDevice *self)
{
return (self->priv->plugin ?
- MM_PLUGIN (g_object_ref (self->priv->plugin)) :
+ g_object_ref (self->priv->plugin) :
NULL);
}
diff --git a/src/mm-device.h b/src/mm-device.h
index 5c6acba4..4329107d 100644
--- a/src/mm-device.h
+++ b/src/mm-device.h
@@ -21,7 +21,8 @@
#include <gudev/gudev.h>
-#include "mm-plugin.h"
+#include "mm-base-modem.h"
+#include "mm-port-probe.h"
#define MM_TYPE_DEVICE (mm_device_get_type ())
#define MM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_DEVICE, MMDevice))
@@ -79,9 +80,9 @@ guint16 mm_device_get_product (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);
+ GObject *plugin);
+GObject *mm_device_peek_plugin (MMDevice *self);
+GObject *mm_device_get_plugin (MMDevice *self);
MMBaseModem *mm_device_peek_modem (MMDevice *self);
MMBaseModem *mm_device_get_modem (MMDevice *self);
diff --git a/src/mm-plugin-manager.c b/src/mm-plugin-manager.c
index 1d034a9c..d9809b71 100644
--- a/src/mm-plugin-manager.c
+++ b/src/mm-plugin-manager.c
@@ -165,19 +165,19 @@ port_probe_context_finished (PortProbeContext *port_probe_ctx)
g_udev_device_get_name (port_probe_ctx->port),
mm_plugin_get_name (port_probe_ctx->best_plugin),
mm_device_get_path (ctx->device));
- mm_device_set_plugin (ctx->device, port_probe_ctx->best_plugin);
+ mm_device_set_plugin (ctx->device, G_OBJECT (port_probe_ctx->best_plugin));
/* Suggest this plugin also to other port probes */
suggest_port_probe_result (ctx, port_probe_ctx->best_plugin);
}
/* Warn if the best plugin found for this port differs from the
* best plugin found for the the first probed port. */
- else if (!g_str_equal (mm_plugin_get_name (mm_device_peek_plugin (ctx->device)),
+ else if (!g_str_equal (mm_plugin_get_name (MM_PLUGIN (mm_device_peek_plugin (ctx->device))),
mm_plugin_get_name (port_probe_ctx->best_plugin))) {
mm_warn ("(%s/%s): plugin mismatch error (expected: '%s', got: '%s')",
g_udev_device_get_subsystem (port_probe_ctx->port),
g_udev_device_get_name (port_probe_ctx->port),
- mm_plugin_get_name (mm_device_peek_plugin (ctx->device)),
+ mm_plugin_get_name (MM_PLUGIN (mm_device_peek_plugin (ctx->device))),
mm_plugin_get_name (port_probe_ctx->best_plugin));
}
}
@@ -392,7 +392,7 @@ port_probe_context_step (PortProbeContext *port_probe_ctx)
/* Ask the current plugin to check support of this port */
mm_plugin_supports_port (MM_PLUGIN (port_probe_ctx->current->data),
- G_OBJECT (ctx->device),
+ ctx->device,
port_probe_ctx->port,
(GAsyncReadyCallback)plugin_supports_port_ready,
port_probe_ctx);
@@ -418,7 +418,9 @@ device_port_grabbed_cb (MMDevice *device,
port_probe_ctx->current = ctx->self->priv->plugins;
/* If we got one suggested, it will be the first one */
- port_probe_ctx->suggested_plugin = mm_device_get_plugin (device);
+ port_probe_ctx->suggested_plugin = (!!mm_device_peek_plugin (device) ?
+ MM_PLUGIN (mm_device_get_plugin (device)) :
+ NULL);
if (port_probe_ctx->suggested_plugin)
port_probe_ctx->current = g_list_find (port_probe_ctx->current,
port_probe_ctx->suggested_plugin);
diff --git a/src/mm-plugin.c b/src/mm-plugin.c
index 5bc62c09..40e215f8 100644
--- a/src/mm-plugin.c
+++ b/src/mm-plugin.c
@@ -467,12 +467,11 @@ mm_plugin_supports_port_finish (MMPlugin *self,
void
mm_plugin_supports_port (MMPlugin *self,
- GObject *device_o,
+ MMDevice *device,
GUdevDevice *port,
GAsyncReadyCallback callback,
gpointer user_data)
{
- MMDevice *device = MM_DEVICE (device_o);
MMPortProbe *probe;
GSimpleAsyncResult *async_result;
PortProbeRunContext *ctx;
@@ -579,10 +578,9 @@ out:
MMBaseModem *
mm_plugin_create_modem (MMPlugin *self,
- GObject *device_o,
+ MMDevice *device,
GError **error)
{
- MMDevice *device = MM_DEVICE (device_o);
MMBaseModem *modem = NULL;
GList *port_probes, *l;
diff --git a/src/mm-plugin.h b/src/mm-plugin.h
index 5a2c9c73..a3d8179e 100644
--- a/src/mm-plugin.h
+++ b/src/mm-plugin.h
@@ -25,6 +25,7 @@
#include "mm-base-modem.h"
#include "mm-port.h"
#include "mm-port-probe.h"
+#include "mm-device.h"
#define MM_PLUGIN_GENERIC_NAME "Generic"
#define MM_PLUGIN_MAJOR_VERSION 4
@@ -101,7 +102,7 @@ gint mm_plugin_cmp (const MMPlugin *plugin_a,
const MMPlugin *plugin_b);
void mm_plugin_supports_port (MMPlugin *plugin,
- GObject *device,
+ MMDevice *device,
GUdevDevice *port,
GAsyncReadyCallback callback,
gpointer user_data);
@@ -110,7 +111,7 @@ MMPluginSupportsResult mm_plugin_supports_port_finish (MMPlugin *plugin,
GError **error);
MMBaseModem *mm_plugin_create_modem (MMPlugin *plugin,
- GObject *device,
+ MMDevice *device,
GError **error);
#endif /* MM_PLUGIN_H */