tasn pushed a commit to branch master.

commit 5ff5d40c53e39d3803a70d10b511da2d70828c88
Author: Tom Hacohen <[email protected]>
Date:   Mon Apr 29 14:48:27 2013 +0100

    Added basic clouseau auto-start support.
    
    If the ELM_CLOUSEAU env var is set to 1 elm auto-starts clouseau.
    Next step would be integrating it into the elm config and making it
    toggle-able on run-time.
---
 src/lib/elm_main.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c
index 1c1009a..1ee5e22 100644
--- a/src/lib/elm_main.c
+++ b/src/lib/elm_main.c
@@ -204,6 +204,55 @@ _prefix_shutdown(void)
    app_pfx = NULL;
 }
 
+static struct {
+     Eina_Module *handle;
+     void (*init)(void);
+     void (*shutdown)(void);
+     Eina_Bool (*app_connect)(const char *appname);
+} _clouseau_info;
+
+#define _CLOUSEAU_LOAD_SYMBOL(cls_struct, sym) \
+   do \
+     { \
+        (cls_struct).sym = eina_module_symbol_get((cls_struct).handle, 
"clouseau_" #sym); \
+        if (!(cls_struct).sym) \
+          { \
+             WRN("Failed loading symbol '%s' from the clouseau library.", 
"clouseau_" #sym); \
+             eina_module_free((cls_struct).handle); \
+             (cls_struct).handle = NULL; \
+             return EINA_FALSE; \
+          } \
+     } \
+   while (0)
+
+static Eina_Bool
+_clouseau_module_load()
+{
+   const char *elm_clouseau_env = getenv("ELM_CLOUSEAU");
+   Eina_Bool want_cls = EINA_FALSE;
+   if (elm_clouseau_env)
+      want_cls = atoi(elm_clouseau_env);
+
+   if (!want_cls)
+      return EINA_FALSE;
+
+   _clouseau_info.handle = eina_module_new(
+         PACKAGE_LIB_DIR "/libclouseau" LIBEXT);
+   if (!eina_module_load(_clouseau_info.handle))
+     {
+        WRN("Failed loading the clouseau library.");
+        eina_module_free(_clouseau_info.handle);
+        _clouseau_info.handle = NULL;
+        return EINA_FALSE;
+     }
+
+   _CLOUSEAU_LOAD_SYMBOL(_clouseau_info, init);
+   _CLOUSEAU_LOAD_SYMBOL(_clouseau_info, shutdown);
+   _CLOUSEAU_LOAD_SYMBOL(_clouseau_info, app_connect);
+
+   return EINA_TRUE;
+}
+
 EAPI int
 elm_init(int    argc,
          char **argv)
@@ -213,6 +262,16 @@ elm_init(int    argc,
    elm_quicklaunch_init(argc, argv);
    elm_quicklaunch_sub_init(argc, argv);
    _prefix_shutdown();
+
+   if (_clouseau_module_load())
+     {
+        _clouseau_info.init();
+        if(!_clouseau_info.app_connect(elm_app_name_get()))
+          {
+             ERR("Failed connecting to the clouseau server.");
+          }
+     }
+
    return _elm_init_count;
 }
 
@@ -228,6 +287,13 @@ elm_shutdown(void)
    if (_elm_init_count > 0) return _elm_init_count;
    _elm_win_shutdown();
    while (_elm_win_deferred_free) ecore_main_loop_iterate();
+
+   if (_clouseau_info.shutdown)
+     {
+        _clouseau_info.shutdown();
+        eina_module_free(_clouseau_info.handle);
+        _clouseau_info.handle = NULL;
+     }
 // wrningz :(
 //   _prefix_shutdown();
    if (app_name)

-- 

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may

Reply via email to