seoz pushed a commit to branch elementary-1.7.

commit 49a3f7ee22b6ddf0869a6ba82660308c3f4d0bbd
Author: Tom 'TAsn' Hacohen <[email protected]>
Date:   Fri Aug 30 16:39:51 2013 +0100

    Added clouseau integration.
    
    You need to make sure the clouseau daemon is running (clouseaud), and then
    you can just run applications by setting the env var ELM_CLOUSEAU to 1.
    This is very useful for platforms that do not have LD_PRELOAD, or block
    them for any reason.
    Most people should just stick to using clouseau_start or clouseau.
---
 ChangeLog          |  5 ++++
 NEWS               |  3 +++
 src/lib/elm_main.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 80 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index bdfa90e..29ce358 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -840,3 +840,8 @@
 2013-08-02  Eduardo Lima (Etrunko)
 
         * 1.7.8 release
+
+2013-08-30  Tom Hacohen (TAsn)
+
+       * Clouseau: Added clouseau integration.
+
diff --git a/NEWS b/NEWS
index 21c2a59..6866407 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@ Elementary 1.7.8
 Changes since Elementary 1.7.7:
 -------------------------
 
+Improvements:
+   * Clouseau: Added clouseau integration.
+
 Fixes:
 
    * Fix potential free'ed memory dereference in naviframe.
diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c
index 1a09663..81e6103 100644
--- a/src/lib/elm_main.c
+++ b/src/lib/elm_main.c
@@ -23,6 +23,12 @@
 
 #define SEMI_BROKEN_QUICKLAUNCH 1
 
+#ifdef __CYGWIN__
+# define LIBEXT ".dll"
+#else
+# define LIBEXT ".so"
+#endif
+
 static Elm_Version _version = { VMAJ, VMIN, VMIC, VREV };
 EAPI Elm_Version *elm_version = &_version;
 
@@ -198,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 "/clouseau/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)
@@ -206,6 +261,16 @@ elm_init(int    argc,
    if (_elm_init_count > 1) return _elm_init_count;
    elm_quicklaunch_sub_init(argc, argv);
    _prefix_shutdown();
+
+   if (_clouseau_module_load())
+     {
+        _clouseau_info.init();
+        if(!_clouseau_info.app_connect(argv[0]))
+          {
+             ERR("Failed connecting to the clouseau server.");
+          }
+     }
+
    return _elm_init_count;
 }
 
@@ -221,6 +286,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();
    elm_quicklaunch_sub_shutdown();

-- 

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk

Reply via email to