understanding that ConnMan hasn't reached a stable API."
#endif
+#define CONNMAN_PLUGIN_PRIORITY_LOW -100
+#define CONNMAN_PLUGIN_PRIORITY_DEFAULT 0
+#define CONNMAN_PLUGIN_PRIORITY_HIGH 100
+
/**
* SECTION:plugin
* @title: Plugin premitives
const char *name;
const char *description;
const char *version;
+ int priority;
int (*init) (void);
void (*exit) (void);
};
*/
#define CONNMAN_PLUGIN_DEFINE(name, description, version, init, exit) \
struct connman_plugin_desc connman_plugin_desc = { \
- #name, description, version, init, exit \
+ #name, description, version, \
+ CONNMAN_PLUGIN_PRIORITY_DEFAULT, init, exit \
};
#ifdef __cplusplus
struct connman_plugin_desc *desc;
};
+static gint compare_priority(gconstpointer a, gconstpointer b)
+{
+ const struct connman_plugin *plugin1 = a;
+ const struct connman_plugin *plugin2 = b;
+
+ return plugin2->desc->priority - plugin1->desc->priority;
+}
+
static gboolean add_plugin(void *handle, struct connman_plugin_desc *desc)
{
struct connman_plugin *plugin;
return FALSE;
}
- plugins = g_slist_append(plugins, plugin);
+ plugins = g_slist_insert_sorted(plugins, plugin, compare_priority);
return TRUE;
}