Added clouseau integration.
authorTom 'TAsn' Hacohen <tom@stosb.com>
Fri, 30 Aug 2013 15:39:51 +0000 (16:39 +0100)
committerTom 'TAsn' Hacohen <tom@stosb.com>
Fri, 30 Aug 2013 15:41:03 +0000 (16:41 +0100)
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
NEWS
src/lib/elm_main.c

index bdfa90e57f22f3ab98447211633f03a2243eb14b..29ce358e46a5568466d24d161799455a088aca09 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 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 21c2a5905076c1bd6be13280a13485b5d39698b8..6866407896170cc0b161ed5e914f68ee0ed78305 100644 (file)
--- 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.
index 1a0966377ae57f2a40f20882ba01e10d85e04f7c..81e610340102fd8a0e3e150db2644ca01080bc87 100644 (file)
 
 #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();