Release 0.7
[connman] / src / plugin.c
index 0d90fd9..7fb7d44 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  Connection Manager
  *
- *  Copyright (C) 2007-2008  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2007-2009  Intel Corporation. All rights reserved.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License version 2 as
@@ -40,6 +40,12 @@ static gboolean add_plugin(void *handle, struct connman_plugin_desc *desc)
 {
        struct connman_plugin *plugin;
 
+       if (desc->init == NULL)
+               return FALSE;
+
+       if (g_str_equal(desc->version, CONNMAN_VERSION) == FALSE)
+               return FALSE;
+
        plugin = g_try_new0(struct connman_plugin, 1);
        if (plugin == NULL)
                return FALSE;
@@ -47,14 +53,17 @@ static gboolean add_plugin(void *handle, struct connman_plugin_desc *desc)
        plugin->handle = handle;
        plugin->desc = desc;
 
-       plugins = g_slist_append(plugins, plugin);
+       if (desc->init() < 0) {
+               g_free(plugin);
+               return FALSE;
+       }
 
-       desc->init();
+       plugins = g_slist_append(plugins, plugin);
 
        return TRUE;
 }
 
-int __connman_plugin_init(void)
+int __connman_plugin_init(const char *pattern)
 {
        GDir *dir;
        const gchar *file;
@@ -91,7 +100,9 @@ int __connman_plugin_init(void)
                                continue;
                        }
 
-                       if (desc->init == NULL) {
+                       if (pattern != NULL && g_pattern_match_simple(pattern,
+                                                       desc->name) == FALSE) {
+                               DBG("ignoring %s", desc->description);
                                dlclose(handle);
                                continue;
                        }