Enlightenment CVS committal

Author  : pfritz
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_engines.c ewl_engines.h ewl_io_manager.c ewl_io_manager.h 


Log Message:
use ecore_plugin instead of dlopen

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_engines.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -3 -r1.48 -r1.49
--- ewl_engines.c       23 Aug 2007 05:26:50 -0000      1.48
+++ ewl_engines.c       5 Sep 2007 18:33:26 -0000       1.49
@@ -4,8 +4,6 @@
 #include "ewl_macros.h"
 #include "ewl_debug.h"
 
-#include <dlfcn.h>
-
 #define EWL_ENGINE_DIR "engines"
 
 enum Ewl_Engine_Hook_Type
@@ -18,6 +16,7 @@
 typedef enum Ewl_Engine_Hook_Type Ewl_Engine_Hook_Type;
 
 static Ecore_Hash *ewl_engines = NULL;
+static int ewl_engines_path = 0;
 static void ewl_engine_free(Ewl_Engine *engine);
 static void **ewl_engine_hooks_get(Ewl_Engine *engine, Ewl_Engine_Hook_Type 
type);
 static void *ewl_engine_hook_get(Ewl_Embed *embed,
@@ -52,6 +51,11 @@
        DENTER_FUNCTION(DLEVEL_STABLE);
 
        IF_FREE_HASH(ewl_engines);
+       if (ewl_engines_path)
+       {
+               ecore_path_group_del(ewl_engines_path);
+               ewl_engines_path = 0;
+       }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -118,8 +122,7 @@
        Ecore_DList *(*dependancies)(void);
        Ecore_DList *deps = NULL;
        Ecore_DList *dep_list;
-       void *handle;
-       char filename[PATH_MAX];
+       Ecore_Plugin *plugin;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("name", name, NULL);
@@ -129,31 +132,25 @@
        if (engine)
                DRETURN_PTR(engine, DLEVEL_STABLE);
 
-       snprintf(filename, sizeof(filename), "%s/ewl/%s/%s.so.%s",
-                                                       PACKAGE_LIB_DIR,
-                                                       EWL_ENGINE_DIR, name,
-                                                       INTERFACE_CURRENT);
-       if (!ecore_file_exists(filename))
+       if (!ewl_engines_path)
        {
-               snprintf(filename, sizeof(filename), "%s/ewl/%s/%s.%s.so",
+               char pathname[PATH_MAX];
+
+               ewl_engines_path = ecore_path_group_new("Ewl Engine Paths");
+               snprintf(pathname, sizeof(pathname), "%s/ewl/%s/",
                                                        PACKAGE_LIB_DIR,
-                                                       EWL_ENGINE_DIR, name,
-                                                       INTERFACE_CURRENT);
-               if (!ecore_file_exists(filename))
-               {
-                       DWARNING("Given engine name dosen't exist.");
-                       DRETURN_PTR(NULL, DLEVEL_STABLE);
-               }
+                                                       EWL_ENGINE_DIR);
+               ecore_path_group_add(ewl_engines_path, pathname);
        }
 
-       handle = dlopen(filename, RTLD_LAZY | RTLD_GLOBAL);
-       if (!handle)
+       plugin = ecore_plugin_load(ewl_engines_path, name, INTERFACE_CURRENT);
+       if (!plugin)
        {
-               DWARNING("Unable to dlopen engine file.");
+               DWARNING("Unable to open engine file.");
                DRETURN_PTR(NULL, DLEVEL_STABLE);
        }
 
-       dependancies = dlsym(handle, "ewl_engine_dependancies");
+       dependancies = ecore_plugin_symbol_get(plugin, 
"ewl_engine_dependancies");
        if (!dependancies)
        {
                DWARNING("Unable to find ewl_engine_dependancies in "
@@ -189,7 +186,7 @@
                ecore_dlist_destroy(dep_list);
        }
 
-       create_engine = dlsym(handle, "ewl_engine_create");
+       create_engine = ecore_plugin_symbol_get(plugin, "ewl_engine_create");
        if (!create_engine)
        {
                DWARNING("Unable to find ewl_engine_create in engine file.");
@@ -203,7 +200,7 @@
                DRETURN_PTR(NULL, DLEVEL_STABLE);
        }
 
-       engine->handle = handle;
+       engine->plugin = plugin;
        engine->dependancies = deps;
 
        ecore_hash_set(ewl_engines, strdup(name), engine);
@@ -1574,8 +1571,8 @@
        if (engine->dependancies)
                ecore_dlist_destroy(engine->dependancies);
 
-       dlclose(engine->handle);
-       engine->handle = NULL;
+       ecore_plugin_unload(engine->plugin);
+       engine->plugin = NULL;
 
        FREE(engine);
 
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_engines.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -3 -r1.29 -r1.30
--- ewl_engines.h       23 Aug 2007 05:26:50 -0000      1.29
+++ ewl_engines.h       5 Sep 2007 18:33:26 -0000       1.30
@@ -142,8 +142,7 @@
  */
 struct Ewl_Engine
 {
-       void *handle;                   /**< The dlsym handle */
-       char *name;                     /**< The name of the engine */
+       Ecore_Plugin * plugin;          /**< The plugin of the engine */
 
        Ecore_DList *dependancies;      /**< The engines this one depends on */
        Ewl_Engine_Info *functions;     /**< The functions used by ewl,
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_io_manager.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -3 -r1.15 -r1.16
--- ewl_io_manager.c    23 Aug 2007 05:26:51 -0000      1.15
+++ ewl_io_manager.c    5 Sep 2007 18:33:26 -0000       1.16
@@ -7,10 +7,10 @@
 #include "ewl_debug.h"
 
 #include <Efreet_Mime.h>
-#include <dlfcn.h>
 
 static Ecore_Hash *ewl_io_manager_plugins = NULL;
 static Ecore_Hash *ewl_io_manager_ext_icon_map = NULL;
+static int ewl_io_manager_path = 0;
 static int ewl_io_manager_strcasecompare(const void *key1, const void *key2);
 static void ewl_io_manager_cb_free_plugin(void *data);
 
@@ -86,6 +86,11 @@
 
        IF_FREE_HASH(ewl_io_manager_ext_icon_map);
        IF_FREE_HASH(ewl_io_manager_plugins);
+       if (ewl_io_manager_path) 
+       {
+               ecore_path_group_del(ewl_io_manager_path);
+               ewl_io_manager_path = 0;
+       }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -272,7 +277,7 @@
 ewl_io_manager_plugin_get(const char *mime)
 {
        Ewl_IO_Manager_Plugin *plugin = NULL;
-       char file[PATH_MAX];
+       char name[PATH_MAX];
        char *m = NULL, *ptr;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
@@ -283,17 +288,25 @@
        if (plugin)
                DRETURN_PTR(plugin, DLEVEL_STABLE);
 
+       if (!ewl_io_manager_path)
+       {
+               ewl_io_manager_path = ecore_path_group_new("Ewl IO Manager");
+               ecore_path_group_add(ewl_io_manager_path,
+                               PACKAGE_LIB_DIR"/ewl/plugins/");
+       }
+
        m = strdup(mime);
        while ((ptr = strchr(m, '/')))
                *ptr = '_';
 
-       snprintf(file, sizeof(file),
-               "%s/ewl/plugins/ewl_io_manager_%s_plugin.so", PACKAGE_LIB_DIR,
-               m);
+       snprintf(name, sizeof(name), "ewl_io_manager_%s_plugin", m);
        FREE(m);
 
-       if (!ecore_file_exists(file))
+       plugin = NEW(Ewl_IO_Manager_Plugin, 1);
+       plugin->plugin = ecore_plugin_load(ewl_io_manager_path, name, NULL);
+       if (!plugin->plugin)
        {
+               FREE(plugin);
                m = strdup(mime);
                plugin = NULL;
 
@@ -304,31 +317,31 @@
                        *ptr = '\0';
                        plugin = ewl_io_manager_plugin_get(m);
                }
+
                FREE(m);
                DRETURN_PTR(plugin, DLEVEL_STABLE);
        }
-
-       plugin = NEW(Ewl_IO_Manager_Plugin, 1);
-       plugin->handle = dlopen(file, RTLD_LAZY | RTLD_GLOBAL);
-       if (!plugin->handle)
-       {
-               FREE(plugin);
-               DRETURN_PTR(NULL, DLEVEL_STABLE);
-       }
-
+       
        plugin->uri_read =
-               dlsym(plugin->handle, "ewl_io_manager_plugin_uri_read");
+               ecore_plugin_symbol_get(plugin->plugin, 
+                                       "ewl_io_manager_plugin_uri_read");
        plugin->string_read =
-               dlsym(plugin->handle, "ewl_io_manager_plugin_string_read");
+               ecore_plugin_symbol_get(plugin->plugin, 
+                                       "ewl_io_manager_plugin_string_read");
 
        plugin->uri_write =
-               dlsym(plugin->handle, "ewl_io_manager_plugin_uri_write");
+               ecore_plugin_symbol_get(plugin->plugin, 
+                                       "ewl_io_manager_plugin_uri_write");
        plugin->string_write =
-               dlsym(plugin->handle, "ewl_io_manager_plugin_string_write");
+               ecore_plugin_symbol_get(plugin->plugin, 
+                                       "ewl_io_manager_plugin_string_write");
 
        if (!plugin->uri_read || !plugin->uri_write
                        || !plugin->uri_write || !plugin->string_write)
        {
+               if (plugin->plugin)
+                       ecore_plugin_unload(plugin->plugin);
+
                FREE(plugin);
                DRETURN_PTR(NULL, DLEVEL_STABLE);
        }
@@ -365,10 +378,10 @@
        DCHECK_PARAM_PTR("data", data);
 
        plugin = data;
-       if (plugin->handle)
-               dlclose(plugin->handle);
+       if (plugin->plugin)
+               ecore_plugin_unload(plugin->plugin);
 
-       plugin->handle = NULL;
+       plugin->plugin = NULL;
        plugin->uri_write = NULL;
        plugin->uri_read = NULL;
        plugin->string_read = NULL;
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_io_manager.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ewl_io_manager.h    23 Aug 2007 05:26:51 -0000      1.6
+++ ewl_io_manager.h    5 Sep 2007 18:33:26 -0000       1.7
@@ -12,7 +12,7 @@
  */
 struct Ewl_IO_Manager_Plugin
 {
-       void *handle;                   /**< The libray handle */
+       Ecore_Plugin *plugin;                   /**< The libray handle */
 
        Ewl_Widget *(*uri_read)(const char *uri);       /**< The URI read 
fuction */
        Ewl_Widget *(*string_read)(const char *string); /**< The string read 
function */



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to