aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mm-manager.c37
-rw-r--r--src/mm-plugin-base.c25
-rw-r--r--src/mm-plugin-base.h3
-rw-r--r--src/mm-plugin.c12
-rw-r--r--src/mm-plugin.h9
5 files changed, 80 insertions, 6 deletions
diff --git a/src/mm-manager.c b/src/mm-manager.c
index b9076ee6..90a65db5 100644
--- a/src/mm-manager.c
+++ b/src/mm-manager.c
@@ -113,7 +113,6 @@ load_plugin (const char *path)
plugin = (*plugin_create_func) ();
if (plugin) {
g_object_weak_ref (G_OBJECT (plugin), (GWeakNotify) g_module_close, module);
- mm_info ("Loaded plugin %s", mm_plugin_get_name (plugin));
} else
mm_warn ("Could not load plugin %s: initialization failed", path);
@@ -124,6 +123,31 @@ load_plugin (const char *path)
return plugin;
}
+static gint
+compare_plugins (const MMPlugin *plugin_a,
+ const MMPlugin *plugin_b)
+{
+ /* The order of the plugins in the list is the same order used to check
+ * whether the plugin can manage a given modem:
+ * - First, modems that will check vendor ID from udev.
+ * - Then, modems that report to be sorted last (those which will check
+ * vendor ID also from the probed ones..
+ */
+ if (mm_plugin_get_sort_last (plugin_a) &&
+ !mm_plugin_get_sort_last (plugin_b))
+ return 1;
+ if (!mm_plugin_get_sort_last (plugin_a) &&
+ mm_plugin_get_sort_last (plugin_b))
+ return -1;
+ return 0;
+}
+
+static void
+found_plugin (MMPlugin *plugin)
+{
+ mm_info ("Loaded plugin '%s'", mm_plugin_get_name (plugin));
+}
+
static void
load_plugins (MMManager *manager)
{
@@ -162,10 +186,19 @@ load_plugins (MMManager *manager)
}
}
+ /* Sort last plugins that request it */
+ priv->plugins = g_slist_sort (priv->plugins, (GCompareFunc)compare_plugins);
+
/* Make sure the generic plugin is last */
if (generic_plugin)
priv->plugins = g_slist_append (priv->plugins, generic_plugin);
+ /* Now report about all the found plugins, in the same order they will be
+ * used while checking support */
+ g_slist_foreach (priv->plugins, (GFunc)found_plugin, NULL);
+
+ mm_info ("Successfully loaded %u plugins", g_slist_length (priv->plugins));
+
g_dir_close (dir);
}
@@ -812,7 +845,7 @@ device_added (MMManager *manager, GUdevDevice *device)
goto out;
}
- /* Success; now ask plugins if they can handle this port */
+ /* Success; now ask plugins if they can handle this port */
info = supports_info_new (manager, subsys, name, physdev_path);
g_hash_table_insert (priv->supports, g_strdup (key), info);
diff --git a/src/mm-plugin-base.c b/src/mm-plugin-base.c
index 09d72394..113303c5 100644
--- a/src/mm-plugin-base.c
+++ b/src/mm-plugin-base.c
@@ -65,11 +65,13 @@ typedef struct {
char *name;
GUdevClient *client;
GHashTable *tasks;
+ gboolean sort_last;
} MMPluginBasePrivate;
enum {
PROP_0,
PROP_NAME,
+ PROP_SORT_LAST,
LAST_PROP
};
@@ -1216,6 +1218,12 @@ get_name (MMPlugin *plugin)
return MM_PLUGIN_BASE_GET_PRIVATE (plugin)->name;
}
+static gboolean
+get_sort_last (const MMPlugin *plugin)
+{
+ return MM_PLUGIN_BASE_GET_PRIVATE (plugin)->sort_last;
+}
+
static char *
get_driver_name (GUdevDevice *device)
{
@@ -1387,6 +1395,7 @@ plugin_init (MMPlugin *plugin_class)
{
/* interface implementation */
plugin_class->get_name = get_name;
+ plugin_class->get_sort_last = get_sort_last;
plugin_class->supports_port = supports_port;
plugin_class->cancel_supports_port = cancel_supports_port;
plugin_class->grab_port = grab_port;
@@ -1424,6 +1433,10 @@ set_property (GObject *object, guint prop_id,
/* Construct only */
priv->name = g_value_dup_string (value);
break;
+ case PROP_SORT_LAST:
+ /* Construct only */
+ priv->sort_last = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1440,6 +1453,9 @@ get_property (GObject *object, guint prop_id,
case PROP_NAME:
g_value_set_string (value, priv->name);
break;
+ case PROP_SORT_LAST:
+ g_value_set_boolean (value, priv->sort_last);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1482,6 +1498,15 @@ mm_plugin_base_class_init (MMPluginBaseClass *klass)
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property
+ (object_class, PROP_SORT_LAST,
+ g_param_spec_boolean (MM_PLUGIN_BASE_SORT_LAST,
+ "Sort Last",
+ "Whether the plugin should be sorted last in the"
+ "list of plugins loaded",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
signals[PROBE_RESULT] =
g_signal_new ("probe-result",
G_OBJECT_CLASS_TYPE (object_class),
diff --git a/src/mm-plugin-base.h b/src/mm-plugin-base.h
index 91b3b8df..c41f017f 100644
--- a/src/mm-plugin-base.h
+++ b/src/mm-plugin-base.h
@@ -106,7 +106,8 @@ void mm_plugin_base_supports_task_add_custom_init_command (MMPluginBaseSupportsT
#define MM_IS_PLUBIN_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN_BASE))
#define MM_PLUGIN_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_BASE, MMPluginBaseClass))
-#define MM_PLUGIN_BASE_NAME "name"
+#define MM_PLUGIN_BASE_NAME "name"
+#define MM_PLUGIN_BASE_SORT_LAST "sort-last"
typedef struct _MMPluginBase MMPluginBase;
typedef struct _MMPluginBaseClass MMPluginBaseClass;
diff --git a/src/mm-plugin.c b/src/mm-plugin.c
index 7e5c582b..167af474 100644
--- a/src/mm-plugin.c
+++ b/src/mm-plugin.c
@@ -24,6 +24,14 @@ mm_plugin_get_name (MMPlugin *plugin)
return MM_PLUGIN_GET_INTERFACE (plugin)->get_name (plugin);
}
+gboolean
+mm_plugin_get_sort_last (const MMPlugin *plugin)
+{
+ g_return_val_if_fail (MM_IS_PLUGIN (plugin), FALSE);
+
+ return MM_PLUGIN_GET_INTERFACE (plugin)->get_sort_last (plugin);
+}
+
MMPluginSupportsResult
mm_plugin_supports_port (MMPlugin *plugin,
const char *subsys,
@@ -100,8 +108,8 @@ mm_plugin_get_type (void)
};
plugin_type = g_type_register_static (G_TYPE_INTERFACE,
- "MMPlugin",
- &plugin_info, 0);
+ "MMPlugin",
+ &plugin_info, 0);
g_type_interface_add_prerequisite (plugin_type, G_TYPE_OBJECT);
}
diff --git a/src/mm-plugin.h b/src/mm-plugin.h
index 4f1dfc09..07e3ee09 100644
--- a/src/mm-plugin.h
+++ b/src/mm-plugin.h
@@ -54,9 +54,14 @@ typedef enum {
struct _MMPlugin {
GTypeInterface g_iface;
- /* Methods */
+ /* Get plugin name */
const char *(*get_name) (MMPlugin *self);
+ /* Returns TRUE if the plugin should be sorted last in the list of plugins
+ * loaded. This is useful to indicate plugins that need an additional check
+ * on the probed vendor ID to see if they can support it. */
+ gboolean (*get_sort_last) (const MMPlugin *self);
+
/* Check whether a plugin supports a particular modem port, and what level
* of support the plugin has for the device. If the plugin can immediately
* determine whether a port is unsupported, it should return
@@ -104,6 +109,8 @@ GType mm_plugin_get_type (void);
const char *mm_plugin_get_name (MMPlugin *plugin);
+gboolean mm_plugin_get_sort_last (const MMPlugin *plugin);
+
MMPluginSupportsResult mm_plugin_supports_port (MMPlugin *plugin,
const char *subsys,
const char *name,