summaryrefslogtreecommitdiffstats
path: root/src/plugin.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel.holtmann@intel.com>2009-05-10 22:35:29 -0700
committerMarcel Holtmann <marcel.holtmann@intel.com>2009-05-10 22:35:29 -0700
commitf2e2cd7787b14eba5160f3ff4f1b2493e55d6f4d (patch)
treee7643fb03c74025ca7423c41f3271bdc98819a0a /src/plugin.c
parent64c42764736de15544e58666bdf97de088f7a7b5 (diff)
downloadofono-f2e2cd7787b14eba5160f3ff4f1b2493e55d6f4d.tar.bz2
Add support for builtin plugins
Diffstat (limited to 'src/plugin.c')
-rw-r--r--src/plugin.c52
1 files changed, 37 insertions, 15 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 9822359f..27c2a929 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -53,7 +53,7 @@ static gboolean add_plugin(void *handle, struct ofono_plugin_desc *desc)
return FALSE;
if (g_str_equal(desc->version, OFONO_VERSION) == FALSE) {
- DBG("version mismatch for %s", desc->description);
+ ofono_error("Version mismatch for %s", desc->description);
return FALSE;
}
@@ -70,15 +70,44 @@ static gboolean add_plugin(void *handle, struct ofono_plugin_desc *desc)
return TRUE;
}
+static gboolean check_plugin(struct ofono_plugin_desc *desc,
+ const char *pattern, const char *exclude)
+{
+ if (exclude != NULL &&
+ g_pattern_match_simple(exclude, desc->name) == TRUE) {
+ ofono_info("Excluding %s", desc->description);
+ return FALSE;
+ }
+
+ if (pattern != NULL &&
+ g_pattern_match_simple(pattern, desc->name) == FALSE) {
+ ofono_info("Ignoring %s", desc->description);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+#include "plugins/builtin.h"
+
int __ofono_plugin_init(const char *pattern, const char *exclude)
{
GSList *list;
GDir *dir;
const gchar *file;
gchar *filename;
+ unsigned int i;
DBG("");
+ for (i = 0; __ofono_builtin[i]; i++) {
+ if (check_plugin(__ofono_builtin[i],
+ pattern, exclude) == FALSE)
+ continue;
+
+ add_plugin(NULL, __ofono_builtin[i]);
+ }
+
dir = g_dir_open(PLUGINDIR, 0, NULL);
if (dir != NULL) {
while ((file = g_dir_read_name(dir)) != NULL) {
@@ -93,8 +122,8 @@ int __ofono_plugin_init(const char *pattern, const char *exclude)
handle = dlopen(filename, RTLD_NOW);
if (handle == NULL) {
- g_warning("Can't load %s: %s", filename,
- dlerror());
+ ofono_error("Can't load %s: %s",
+ filename, dlerror());
g_free(filename);
continue;
}
@@ -103,21 +132,13 @@ int __ofono_plugin_init(const char *pattern, const char *exclude)
desc = dlsym(handle, "ofono_plugin_desc");
if (desc == NULL) {
- g_warning("Can't load symbol: %s", dlerror());
- dlclose(handle);
- continue;
- }
-
- if (exclude != NULL && g_pattern_match_simple(exclude,
- desc->name) == TRUE) {
- DBG("excluding %s", desc->description);
+ ofono_error("Can't load symbol: %s",
+ dlerror());
dlclose(handle);
continue;
}
- if (pattern != NULL && g_pattern_match_simple(pattern,
- desc->name) == FALSE) {
- DBG("ignoring %s", desc->description);
+ if (check_plugin(desc, pattern, exclude) == FALSE) {
dlclose(handle);
continue;
}
@@ -153,7 +174,8 @@ void __ofono_plugin_cleanup(void)
if (plugin->active == TRUE && plugin->desc->exit)
plugin->desc->exit();
- dlclose(plugin->handle);
+ if (plugin->handle)
+ dlclose(plugin->handle);
g_free(plugin);
}