device,plugin: let the MMPlugin' API know about
MMDevice'
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
#include <mm-errors-types.h>
|
#include <mm-errors-types.h>
|
||||||
|
|
||||||
#include "mm-device.h"
|
#include "mm-device.h"
|
||||||
|
#include "mm-plugin.h"
|
||||||
#include "mm-utils.h"
|
#include "mm-utils.h"
|
||||||
#include "mm-log.h"
|
#include "mm-log.h"
|
||||||
|
|
||||||
@@ -377,9 +378,7 @@ mm_device_create_modem (MMDevice *self,
|
|||||||
mm_plugin_get_name (self->priv->plugin),
|
mm_plugin_get_name (self->priv->plugin),
|
||||||
g_list_length (self->priv->port_probes));
|
g_list_length (self->priv->port_probes));
|
||||||
|
|
||||||
self->priv->modem = mm_plugin_create_modem (self->priv->plugin,
|
self->priv->modem = mm_plugin_create_modem (self->priv->plugin, self, error);
|
||||||
G_OBJECT (self),
|
|
||||||
error);
|
|
||||||
if (self->priv->modem) {
|
if (self->priv->modem) {
|
||||||
/* Keep the object manager */
|
/* Keep the object manager */
|
||||||
self->priv->object_manager = g_object_ref (object_manager);
|
self->priv->object_manager = g_object_ref (object_manager);
|
||||||
@@ -434,24 +433,26 @@ mm_device_get_udev_device (MMDevice *self)
|
|||||||
|
|
||||||
void
|
void
|
||||||
mm_device_set_plugin (MMDevice *self,
|
mm_device_set_plugin (MMDevice *self,
|
||||||
MMPlugin *plugin)
|
GObject *plugin)
|
||||||
{
|
{
|
||||||
g_object_set (self,
|
g_object_set (self,
|
||||||
MM_DEVICE_PLUGIN, plugin,
|
MM_DEVICE_PLUGIN, plugin,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
MMPlugin *
|
GObject *
|
||||||
mm_device_peek_plugin (MMDevice *self)
|
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)
|
mm_device_get_plugin (MMDevice *self)
|
||||||
{
|
{
|
||||||
return (self->priv->plugin ?
|
return (self->priv->plugin ?
|
||||||
MM_PLUGIN (g_object_ref (self->priv->plugin)) :
|
g_object_ref (self->priv->plugin) :
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,8 @@
|
|||||||
|
|
||||||
#include <gudev/gudev.h>
|
#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_TYPE_DEVICE (mm_device_get_type ())
|
||||||
#define MM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_DEVICE, MMDevice))
|
#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_peek_udev_device (MMDevice *self);
|
||||||
GUdevDevice *mm_device_get_udev_device (MMDevice *self);
|
GUdevDevice *mm_device_get_udev_device (MMDevice *self);
|
||||||
void mm_device_set_plugin (MMDevice *self,
|
void mm_device_set_plugin (MMDevice *self,
|
||||||
MMPlugin *plugin);
|
GObject *plugin);
|
||||||
MMPlugin *mm_device_peek_plugin (MMDevice *self);
|
GObject *mm_device_peek_plugin (MMDevice *self);
|
||||||
MMPlugin *mm_device_get_plugin (MMDevice *self);
|
GObject *mm_device_get_plugin (MMDevice *self);
|
||||||
MMBaseModem *mm_device_peek_modem (MMDevice *self);
|
MMBaseModem *mm_device_peek_modem (MMDevice *self);
|
||||||
MMBaseModem *mm_device_get_modem (MMDevice *self);
|
MMBaseModem *mm_device_get_modem (MMDevice *self);
|
||||||
|
|
||||||
|
@@ -165,19 +165,19 @@ port_probe_context_finished (PortProbeContext *port_probe_ctx)
|
|||||||
g_udev_device_get_name (port_probe_ctx->port),
|
g_udev_device_get_name (port_probe_ctx->port),
|
||||||
mm_plugin_get_name (port_probe_ctx->best_plugin),
|
mm_plugin_get_name (port_probe_ctx->best_plugin),
|
||||||
mm_device_get_path (ctx->device));
|
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 this plugin also to other port probes */
|
||||||
suggest_port_probe_result (ctx, port_probe_ctx->best_plugin);
|
suggest_port_probe_result (ctx, port_probe_ctx->best_plugin);
|
||||||
}
|
}
|
||||||
/* Warn if the best plugin found for this port differs from the
|
/* Warn if the best plugin found for this port differs from the
|
||||||
* best plugin found for the the first probed port. */
|
* 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_plugin_get_name (port_probe_ctx->best_plugin))) {
|
||||||
mm_warn ("(%s/%s): plugin mismatch error (expected: '%s', got: '%s')",
|
mm_warn ("(%s/%s): plugin mismatch error (expected: '%s', got: '%s')",
|
||||||
g_udev_device_get_subsystem (port_probe_ctx->port),
|
g_udev_device_get_subsystem (port_probe_ctx->port),
|
||||||
g_udev_device_get_name (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));
|
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 */
|
/* Ask the current plugin to check support of this port */
|
||||||
mm_plugin_supports_port (MM_PLUGIN (port_probe_ctx->current->data),
|
mm_plugin_supports_port (MM_PLUGIN (port_probe_ctx->current->data),
|
||||||
G_OBJECT (ctx->device),
|
ctx->device,
|
||||||
port_probe_ctx->port,
|
port_probe_ctx->port,
|
||||||
(GAsyncReadyCallback)plugin_supports_port_ready,
|
(GAsyncReadyCallback)plugin_supports_port_ready,
|
||||||
port_probe_ctx);
|
port_probe_ctx);
|
||||||
@@ -418,7 +418,9 @@ device_port_grabbed_cb (MMDevice *device,
|
|||||||
port_probe_ctx->current = ctx->self->priv->plugins;
|
port_probe_ctx->current = ctx->self->priv->plugins;
|
||||||
|
|
||||||
/* If we got one suggested, it will be the first one */
|
/* 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)
|
if (port_probe_ctx->suggested_plugin)
|
||||||
port_probe_ctx->current = g_list_find (port_probe_ctx->current,
|
port_probe_ctx->current = g_list_find (port_probe_ctx->current,
|
||||||
port_probe_ctx->suggested_plugin);
|
port_probe_ctx->suggested_plugin);
|
||||||
|
@@ -467,12 +467,11 @@ mm_plugin_supports_port_finish (MMPlugin *self,
|
|||||||
|
|
||||||
void
|
void
|
||||||
mm_plugin_supports_port (MMPlugin *self,
|
mm_plugin_supports_port (MMPlugin *self,
|
||||||
GObject *device_o,
|
MMDevice *device,
|
||||||
GUdevDevice *port,
|
GUdevDevice *port,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
MMDevice *device = MM_DEVICE (device_o);
|
|
||||||
MMPortProbe *probe;
|
MMPortProbe *probe;
|
||||||
GSimpleAsyncResult *async_result;
|
GSimpleAsyncResult *async_result;
|
||||||
PortProbeRunContext *ctx;
|
PortProbeRunContext *ctx;
|
||||||
@@ -579,10 +578,9 @@ out:
|
|||||||
|
|
||||||
MMBaseModem *
|
MMBaseModem *
|
||||||
mm_plugin_create_modem (MMPlugin *self,
|
mm_plugin_create_modem (MMPlugin *self,
|
||||||
GObject *device_o,
|
MMDevice *device,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
MMDevice *device = MM_DEVICE (device_o);
|
|
||||||
MMBaseModem *modem = NULL;
|
MMBaseModem *modem = NULL;
|
||||||
GList *port_probes, *l;
|
GList *port_probes, *l;
|
||||||
|
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#include "mm-base-modem.h"
|
#include "mm-base-modem.h"
|
||||||
#include "mm-port.h"
|
#include "mm-port.h"
|
||||||
#include "mm-port-probe.h"
|
#include "mm-port-probe.h"
|
||||||
|
#include "mm-device.h"
|
||||||
|
|
||||||
#define MM_PLUGIN_GENERIC_NAME "Generic"
|
#define MM_PLUGIN_GENERIC_NAME "Generic"
|
||||||
#define MM_PLUGIN_MAJOR_VERSION 4
|
#define MM_PLUGIN_MAJOR_VERSION 4
|
||||||
@@ -101,7 +102,7 @@ gint mm_plugin_cmp (const MMPlugin *plugin_a,
|
|||||||
const MMPlugin *plugin_b);
|
const MMPlugin *plugin_b);
|
||||||
|
|
||||||
void mm_plugin_supports_port (MMPlugin *plugin,
|
void mm_plugin_supports_port (MMPlugin *plugin,
|
||||||
GObject *device,
|
MMDevice *device,
|
||||||
GUdevDevice *port,
|
GUdevDevice *port,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
@@ -110,7 +111,7 @@ MMPluginSupportsResult mm_plugin_supports_port_finish (MMPlugin *plugin,
|
|||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
MMBaseModem *mm_plugin_create_modem (MMPlugin *plugin,
|
MMBaseModem *mm_plugin_create_modem (MMPlugin *plugin,
|
||||||
GObject *device,
|
MMDevice *device,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
#endif /* MM_PLUGIN_H */
|
#endif /* MM_PLUGIN_H */
|
||||||
|
Reference in New Issue
Block a user