raster pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=cdb436ee8602728e18a63244988da22b25477819

commit cdb436ee8602728e18a63244988da22b25477819
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Tue Nov 24 21:55:10 2015 +0900

    e msgbus - move almost all of core dbus methods to msgbus module
    
    for security reaons, all the dbus methods that allow you to mess with
    e are now in the msgbus module - load at your own risk. this is
    irrelevant in x11, but in wayland this matters as wayland is actually
    secure.
    
    this also disables restart and shutdown dbus methods still in core.
    they are there but non-functional due to possibly being able to be
    abused in a wayland universe to "dos attack" the wm.
    
    @fix
---
 src/bin/e_msgbus.c                  | 422 ++----------------------------------
 src/modules/Makefile_msgbus.mk      |   5 +-
 src/modules/msgbus/e_mod_main.c     |  12 +-
 src/modules/msgbus/e_mod_main.h     |   3 +
 src/modules/msgbus/msgbus_audit.c   |  17 +-
 src/modules/msgbus/msgbus_desktop.c |  62 ++----
 src/modules/msgbus/msgbus_lang.c    |  15 +-
 src/modules/msgbus/msgbus_module.c  | 156 +++++++++++++
 src/modules/msgbus/msgbus_profile.c | 137 ++++++++++++
 src/modules/msgbus/msgbus_window.c  | 133 ++++++++++++
 10 files changed, 494 insertions(+), 468 deletions(-)

diff --git a/src/bin/e_msgbus.c b/src/bin/e_msgbus.c
index 03f8828..16f7944 100644
--- a/src/bin/e_msgbus.c
+++ b/src/bin/e_msgbus.c
@@ -1,115 +1,28 @@
 #include "e.h"
 
-/* local subsystem functions */
-static void           _e_msgbus_request_name_cb(void *data, const 
Eldbus_Message *msg,
-                                                Eldbus_Pending *pending);
-
-static Eldbus_Message *_e_msgbus_core_version_cb(const 
Eldbus_Service_Interface *iface,
-                                                const Eldbus_Message *msg);
-static Eldbus_Message *_e_msgbus_core_restart_cb(const 
Eldbus_Service_Interface *iface,
-                                                const Eldbus_Message *msg);
-static Eldbus_Message *_e_msgbus_core_shutdown_cb(const 
Eldbus_Service_Interface *iface,
-                                                 const Eldbus_Message *msg);
-
-static Eldbus_Message *_e_msgbus_module_load_cb(const Eldbus_Service_Interface 
*iface,
-                                               const Eldbus_Message *msg);
-static Eldbus_Message *_e_msgbus_module_unload_cb(const 
Eldbus_Service_Interface *iface,
-                                                 const Eldbus_Message *msg);
-static Eldbus_Message *_e_msgbus_module_enable_cb(const 
Eldbus_Service_Interface *iface,
-                                                 const Eldbus_Message *msg);
-static Eldbus_Message *_e_msgbus_module_disable_cb(const 
Eldbus_Service_Interface *iface,
-                                                  const Eldbus_Message *msg);
-static Eldbus_Message *_e_msgbus_module_list_cb(const Eldbus_Service_Interface 
*iface,
-                                               const Eldbus_Message *msg);
-
-static Eldbus_Message *_e_msgbus_profile_set_cb(const Eldbus_Service_Interface 
*iface,
-                                               const Eldbus_Message *msg);
-static Eldbus_Message *_e_msgbus_profile_get_cb(const Eldbus_Service_Interface 
*iface,
-                                               const Eldbus_Message *msg);
-static Eldbus_Message *_e_msgbus_profile_list_cb(const 
Eldbus_Service_Interface *iface,
-                                                const Eldbus_Message *msg);
-static Eldbus_Message *_e_msgbus_profile_add_cb(const Eldbus_Service_Interface 
*iface,
-                                               const Eldbus_Message *msg);
-static Eldbus_Message *_e_msgbus_profile_delete_cb(const 
Eldbus_Service_Interface *iface,
-                                                  const Eldbus_Message *msg);
-
-#define E_MSGBUS_WIN_ACTION_CB_PROTO(NAME)                                     
              \
-  static Eldbus_Message * _e_msgbus_window_##NAME##_cb(const 
Eldbus_Service_Interface * iface, \
-                                                      const Eldbus_Message * 
msg)
+#define PATH "/org/enlightenment/wm/RemoteObject"
 
-E_MSGBUS_WIN_ACTION_CB_PROTO(list);
-E_MSGBUS_WIN_ACTION_CB_PROTO(close);
-E_MSGBUS_WIN_ACTION_CB_PROTO(kill);
-E_MSGBUS_WIN_ACTION_CB_PROTO(focus);
-E_MSGBUS_WIN_ACTION_CB_PROTO(iconify);
-E_MSGBUS_WIN_ACTION_CB_PROTO(uniconify);
-E_MSGBUS_WIN_ACTION_CB_PROTO(maximize);
-E_MSGBUS_WIN_ACTION_CB_PROTO(unmaximize);
+/* local subsystem functions */
+static void            _e_msgbus_request_name_cb(void *data, const 
Eldbus_Message *msg, Eldbus_Pending *pending);
 
-/* local subsystem globals */
-static E_Msgbus_Data *_e_msgbus_data = NULL;
+static Eldbus_Message *_e_msgbus_core_version_cb(const 
Eldbus_Service_Interface *iface, const Eldbus_Message *msg);
+static Eldbus_Message *_e_msgbus_core_restart_cb(const 
Eldbus_Service_Interface *iface, const Eldbus_Message *msg);
+static Eldbus_Message *_e_msgbus_core_shutdown_cb(const 
Eldbus_Service_Interface *iface, const Eldbus_Message *msg);
 
-static const Eldbus_Method core_methods[] = {
+static const Eldbus_Method core_methods[] =
+{
    { "Version", NULL, ELDBUS_ARGS({"s", "version"}), 
_e_msgbus_core_version_cb, 0 },
    { "Restart", NULL, NULL, _e_msgbus_core_restart_cb, 0 },
    { "Shutdown", NULL, NULL, _e_msgbus_core_shutdown_cb, 0 },
    { NULL, NULL, NULL, NULL, 0}
 };
 
-static const Eldbus_Method module_methods[] = {
-   { "Load", ELDBUS_ARGS({"s", "module"}), NULL, _e_msgbus_module_load_cb, 0 },
-   { "Unload", ELDBUS_ARGS({"s", "module"}), NULL, _e_msgbus_module_unload_cb, 
0 },
-   { "Enable", ELDBUS_ARGS({"s", "module"}), NULL, _e_msgbus_module_enable_cb, 
0 },
-   { "Disable", ELDBUS_ARGS({"s", "module"}), NULL, 
_e_msgbus_module_disable_cb, 0 },
-   { "List", NULL, ELDBUS_ARGS({"a(si)", "modules"}),
-     _e_msgbus_module_list_cb, 0 },
-   { NULL, NULL, NULL, NULL, 0}
-};
-
-static const Eldbus_Method profile_methods[] = {
-   { "Set", ELDBUS_ARGS({"s", "profile"}), NULL, _e_msgbus_profile_set_cb, 0 },
-   { "Get", NULL, ELDBUS_ARGS({"s", "profile"}), _e_msgbus_profile_get_cb, 0 },
-   { "List", NULL, ELDBUS_ARGS({"as", "array_profiles"}),
-     _e_msgbus_profile_list_cb, 0 },
-   { "Add", ELDBUS_ARGS({"s", "profile"}), NULL, _e_msgbus_profile_add_cb, 0 },
-   { "Delete", ELDBUS_ARGS({"s", "profile"}), NULL, 
_e_msgbus_profile_delete_cb, 0 },
-   { NULL, NULL, NULL, NULL, 0}
-};
-
-static const Eldbus_Method window_methods[] = {
-   { "List", NULL, ELDBUS_ARGS({"a(si)", "array_of_window"}),
-     _e_msgbus_window_list_cb, 0 },
-   { "Close", ELDBUS_ARGS({"i", "window_id"}), NULL, 
_e_msgbus_window_close_cb, 0 },
-   { "Kill", ELDBUS_ARGS({"i", "window_id"}), NULL, _e_msgbus_window_kill_cb, 
0 },
-   { "Focus", ELDBUS_ARGS({"i", "window_id"}), NULL, 
_e_msgbus_window_focus_cb, 0 },
-   { "Iconify", ELDBUS_ARGS({"i", "window_id"}), NULL,
-     _e_msgbus_window_iconify_cb, 0 },
-   { "Uniconify", ELDBUS_ARGS({"i", "window_id"}), NULL,
-     _e_msgbus_window_uniconify_cb, 0 },
-   { "Maximize", ELDBUS_ARGS({"i", "window_id"}), NULL,
-     _e_msgbus_window_maximize_cb, 0 },
-   { "Unmaximize", ELDBUS_ARGS({"i", "window_id"}), NULL,
-     _e_msgbus_window_unmaximize_cb, 0 },
-   { NULL, NULL, NULL, NULL, 0}
-};
-
-#define PATH "/org/enlightenment/wm/RemoteObject"
-
 static const Eldbus_Service_Interface_Desc core_desc = {
    "org.enlightenment.wm.Core", core_methods, NULL, NULL, NULL, NULL
 };
 
-static const Eldbus_Service_Interface_Desc module_desc = {
-   "org.enlightenment.wm.Module", module_methods, NULL, NULL, NULL, NULL
-};
-
-static const Eldbus_Service_Interface_Desc profile_desc = {
-   "org.enlightenment.wm.Profile", profile_methods, NULL, NULL, NULL, NULL
-};
-
-static const Eldbus_Service_Interface_Desc window_desc = {
-   "org.enlightenment.wm.Window", window_methods, NULL, NULL, NULL, NULL
-};
+/* local subsystem globals */
+static E_Msgbus_Data *_e_msgbus_data = NULL;
 
 /* externally accessible functions */
 EINTERN int
@@ -126,13 +39,11 @@ e_msgbus_init(void)
         return 0;
      }
 
-   _e_msgbus_data->iface = 
eldbus_service_interface_register(_e_msgbus_data->conn,
-                                                            PATH, &core_desc);
-   eldbus_service_interface_register(_e_msgbus_data->conn, PATH, &module_desc);
-   eldbus_service_interface_register(_e_msgbus_data->conn, PATH, 
&profile_desc);
-   eldbus_service_interface_register(_e_msgbus_data->conn, PATH, &window_desc);
-   eldbus_name_request(_e_msgbus_data->conn, "org.enlightenment.wm.service",
-                      0, _e_msgbus_request_name_cb, NULL);
+   _e_msgbus_data->iface = eldbus_service_interface_register
+     (_e_msgbus_data->conn, PATH, &core_desc);
+   eldbus_name_request(_e_msgbus_data->conn,
+                       "org.enlightenment.wm.service",
+                       0, _e_msgbus_request_name_cb, NULL);
    return 1;
 }
 
@@ -144,7 +55,8 @@ e_msgbus_shutdown(void)
    if (_e_msgbus_data->conn)
      {
         eldbus_name_release(_e_msgbus_data->conn,
-                           "org.enlightenment.wm.service", NULL, NULL);
+                            "org.enlightenment.wm.service",
+                            NULL, NULL);
         eldbus_connection_unref(_e_msgbus_data->conn);
      }
    eldbus_shutdown();
@@ -157,8 +69,7 @@ e_msgbus_shutdown(void)
 E_API Eldbus_Service_Interface *
 e_msgbus_interface_attach(const Eldbus_Service_Interface_Desc *desc)
 {
-   if (!_e_msgbus_data->iface)
-     return NULL;
+   if (!_e_msgbus_data->iface) return NULL;
    return eldbus_service_interface_register(_e_msgbus_data->conn, PATH, desc);
 }
 
@@ -199,7 +110,8 @@ static Eldbus_Message *
 _e_msgbus_core_restart_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
                           const Eldbus_Message *msg)
 {
-   e_sys_action_do(E_SYS_RESTART, NULL);
+   ERR("DBus restart API disabled for security reasons");
+//   e_sys_action_do(E_SYS_RESTART, NULL);
    return eldbus_message_method_return_new(msg);
 }
 
@@ -207,297 +119,7 @@ static Eldbus_Message *
 _e_msgbus_core_shutdown_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
                            const Eldbus_Message *msg)
 {
-   e_sys_action_do(E_SYS_EXIT, NULL);
-   return eldbus_message_method_return_new(msg);
-}
-
-/* Modules Handlers */
-static Eldbus_Message *
-_e_msgbus_module_load_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
-                         const Eldbus_Message *msg)
-{
-   char *module;
-   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
-
-   if (!eldbus_message_arguments_get(msg, "s", &module))
-     return reply;
-
-   if (!e_module_find(module))
-     {
-        e_module_new(module);
-        e_config_save_queue();
-     }
-
-   return reply;
-}
-
-static Eldbus_Message *
-_e_msgbus_module_unload_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
-                           const Eldbus_Message *msg)
-{
-   char *module;
-   E_Module *m;
-   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
-
-   if (!eldbus_message_arguments_get(msg, "s", &module))
-     return reply;
-
-   if ((m = e_module_find(module)))
-     {
-        e_module_disable(m);
-        e_object_del(E_OBJECT(m));
-        e_config_save_queue();
-     }
-
-   return reply;
-}
-
-static Eldbus_Message *
-_e_msgbus_module_enable_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
-                           const Eldbus_Message *msg)
-{
-   char *module;
-   E_Module *m;
-   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
-
-   if (!eldbus_message_arguments_get(msg, "s", &module))
-     return reply;
-
-   if ((m = e_module_find(module)))
-     {
-        e_module_enable(m);
-        e_config_save_queue();
-     }
-
-   return reply;
-}
-
-static Eldbus_Message *
-_e_msgbus_module_disable_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
-                            const Eldbus_Message *msg)
-{
-   char *module;
-   E_Module *m;
-   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
-
-   if (!eldbus_message_arguments_get(msg, "s", &module))
-     return reply;
-
-   if ((m = e_module_find(module)))
-     {
-        e_module_disable(m);
-        e_config_save_queue();
-     }
-
-   return reply;
-}
-
-static Eldbus_Message *
-_e_msgbus_module_list_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
-                         const Eldbus_Message *msg)
-{
-   Eina_List *l;
-   E_Module *mod;
-   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
-   Eldbus_Message_Iter *main_iter, *array;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(reply, NULL);
-   main_iter = eldbus_message_iter_get(reply);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(main_iter, reply);
-
-   eldbus_message_iter_arguments_append(main_iter, "a(si)", &array);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(array, reply);
-
-   EINA_LIST_FOREACH(e_module_list(), l, mod)
-     {
-        Eldbus_Message_Iter *s;
-        const char *name;
-        int enabled;
-
-        name = mod->name;
-        enabled = mod->enabled;
-
-        eldbus_message_iter_arguments_append(array, "(si)", &s);
-        if (!s) continue;
-        eldbus_message_iter_arguments_append(s, "si", name, enabled);
-        eldbus_message_iter_container_close(array, s);
-     }
-   eldbus_message_iter_container_close(main_iter, array);
-
-   return reply;
-}
-
-/* Profile Handlers */
-static Eldbus_Message *
-_e_msgbus_profile_set_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
-                         const Eldbus_Message *msg)
-{
-   char *profile;
-   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
-
-   if (!eldbus_message_arguments_get(msg, "s", &profile))
-     return reply;
-
-   e_config_save_flush();
-   e_config_profile_set(profile);
-   e_config_profile_save();
-   e_config_save_block_set(1);
-   e_sys_action_do(E_SYS_RESTART, NULL);
-
-   return reply;
-}
-
-static Eldbus_Message *
-_e_msgbus_profile_get_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
-                         const Eldbus_Message *msg)
-{
-   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
-   const char *profile;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(reply, NULL);
-   profile = e_config_profile_get();
-   eldbus_message_arguments_append(reply, "s", profile);
-   return reply;
-}
-
-static Eldbus_Message *
-_e_msgbus_profile_list_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
-                          const Eldbus_Message *msg)
-{
-   Eina_List *l;
-   char *name;
-   Eldbus_Message *reply;
-   Eldbus_Message_Iter *array, *main_iter;
-
-   reply = eldbus_message_method_return_new(msg);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(reply, NULL);
-
-   main_iter = eldbus_message_iter_get(reply);
-   EINA_SAFETY_ON_FALSE_RETURN_VAL(main_iter, reply);
-
-   eldbus_message_iter_arguments_append(main_iter, "as", &array);
-   EINA_SAFETY_ON_FALSE_RETURN_VAL(array, reply);
-
-   l = e_config_profile_list();
-   EINA_LIST_FREE(l, name)
-     {
-        eldbus_message_iter_basic_append(array, 's', name);
-        free(name);
-     }
-   eldbus_message_iter_container_close(main_iter, array);
-
-   return reply;
-}
-
-static Eldbus_Message *
-_e_msgbus_profile_add_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
-                         const Eldbus_Message *msg)
-{
-   char *profile;
-   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
-
-   if (!eldbus_message_arguments_get(msg, "s", &profile))
-     return reply;
-   e_config_profile_add(profile);
-
-   return reply;
-}
-
-static Eldbus_Message *
-_e_msgbus_profile_delete_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
-                            const Eldbus_Message *msg)
-{
-   char *profile;
-
-   if (!eldbus_message_arguments_get(msg, "s", &profile))
-     return eldbus_message_method_return_new(msg);
-   if (!strcmp(e_config_profile_get(), profile))
-     return eldbus_message_error_new(msg,
-                                    "org.enlightenment.DBus.InvalidArgument",
-                                    "Can't delete active profile");
-   e_config_profile_del(profile);
+   ERR("DBus shutdown API disabled for security reasons");
+//   e_sys_action_do(E_SYS_EXIT, NULL);
    return eldbus_message_method_return_new(msg);
 }
-
-/* Window handlers */
-static Eldbus_Message *
-_e_msgbus_window_list_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
-                         const Eldbus_Message *msg)
-{
-   const Eina_List *l;
-   E_Client *ec;
-   Eldbus_Message *reply;
-   Eldbus_Message_Iter *main_iter, *array;
-
-   reply = eldbus_message_method_return_new(msg);
-   EINA_SAFETY_ON_FALSE_RETURN_VAL(reply, NULL);
-
-   main_iter = eldbus_message_iter_get(reply);
-   EINA_SAFETY_ON_FALSE_RETURN_VAL(main_iter, reply);
-
-   eldbus_message_iter_arguments_append(main_iter, "a(si)", &array);
-   EINA_SAFETY_ON_FALSE_RETURN_VAL(array, reply);
-
-   EINA_LIST_FOREACH(e_comp->clients, l, ec)
-     {
-        Eldbus_Message_Iter *s;
-
-        if (e_client_util_ignored_get(ec)) continue;
-
-        eldbus_message_iter_arguments_append(array, "(si)", &s);
-        if (!s) continue;
-        eldbus_message_iter_arguments_append(s, "si", ec->icccm.name,
-                                            e_client_util_win_get(ec));
-        eldbus_message_iter_container_close(array, s);
-     }
-   eldbus_message_iter_container_close(main_iter, array);
-
-   return reply;
-}
-
-#define E_MSGBUS_WIN_ACTION_CB_BEGIN(NAME)                                     
  \
-  static Eldbus_Message *                                                      
   \
-  _e_msgbus_window_##NAME##_cb(const Eldbus_Service_Interface * iface 
EINA_UNUSED, \
-                               const Eldbus_Message * msg)                     
   \
-  {                                                                            
  \
-     E_Client *ec;                                                             
  \
-     int xwin;                                                                 
  \
-                                                                               
  \
-     if (!eldbus_message_arguments_get(msg, "i", &xwin))                       
   \
-       return eldbus_message_method_return_new(msg);                           
   \
-     ec = e_pixmap_find_client(E_PIXMAP_TYPE_X, xwin);                         
         \
-     if (ec)                                                                   
  \
-       {
-#define E_MSGBUS_WIN_ACTION_CB_END             \
-  }                                            \
-                                               \
-  return eldbus_message_method_return_new(msg); \
-  }
-
- E_MSGBUS_WIN_ACTION_CB_BEGIN(close)
- e_client_act_close_begin(ec);
- E_MSGBUS_WIN_ACTION_CB_END
-
-  E_MSGBUS_WIN_ACTION_CB_BEGIN(kill)
- e_client_act_kill_begin(ec);
- E_MSGBUS_WIN_ACTION_CB_END
-
-  E_MSGBUS_WIN_ACTION_CB_BEGIN(focus)
- e_client_activate(ec, 1);
- E_MSGBUS_WIN_ACTION_CB_END
-
-  E_MSGBUS_WIN_ACTION_CB_BEGIN(iconify)
- e_client_iconify(ec);
- E_MSGBUS_WIN_ACTION_CB_END
-
-  E_MSGBUS_WIN_ACTION_CB_BEGIN(uniconify)
- e_client_uniconify(ec);
- E_MSGBUS_WIN_ACTION_CB_END
-
-  E_MSGBUS_WIN_ACTION_CB_BEGIN(maximize)
- e_client_maximize(ec, e_config->maximize_policy);
- E_MSGBUS_WIN_ACTION_CB_END
-
-  E_MSGBUS_WIN_ACTION_CB_BEGIN(unmaximize)
- e_client_unmaximize(ec, E_MAXIMIZE_BOTH);
- E_MSGBUS_WIN_ACTION_CB_END
diff --git a/src/modules/Makefile_msgbus.mk b/src/modules/Makefile_msgbus.mk
index 15f9d72..f0f4013 100644
--- a/src/modules/Makefile_msgbus.mk
+++ b/src/modules/Makefile_msgbus.mk
@@ -17,7 +17,10 @@ src/modules/msgbus/e_mod_main.h \
 src/modules/msgbus/e_mod_main.c \
 src/modules/msgbus/msgbus_audit.c \
 src/modules/msgbus/msgbus_desktop.c \
-src/modules/msgbus/msgbus_lang.c
+src/modules/msgbus/msgbus_lang.c \
+src/modules/msgbus/msgbus_module.c \
+src/modules/msgbus/msgbus_profile.c \
+src/modules/msgbus/msgbus_window.c
 
 PHONIES += msgbus install-msgbus
 msgbus: $(msgbuspkg_LTLIBRARIES) $(msgbus_DATA)
diff --git a/src/modules/msgbus/e_mod_main.c b/src/modules/msgbus/e_mod_main.c
index a872d1f..ea2dc7a 100644
--- a/src/modules/msgbus/e_mod_main.c
+++ b/src/modules/msgbus/e_mod_main.c
@@ -1,7 +1,7 @@
 #include "e_mod_main.h"
 
 /* actual module specifics */
-static Eina_Array* ifaces = NULL;
+static Eina_Array *ifaces = NULL;
 
 /* module setup */
 E_API E_Module_Api e_modapi =
@@ -13,21 +13,23 @@ E_API E_Module_Api e_modapi =
 E_API void *
 e_modapi_init(E_Module *m)
 {
-   ifaces = eina_array_new(5);
-
+   ifaces = eina_array_new(10);
    msgbus_lang_init(ifaces);
    msgbus_desktop_init(ifaces);
    msgbus_audit_init(ifaces);
-
+   msgbus_module_init(ifaces);
+   msgbus_profile_init(ifaces);
+   msgbus_window_init(ifaces);
    return m;
 }
 
 E_API int
 e_modapi_shutdown(E_Module *m EINA_UNUSED)
 {
-   Eldbus_Service_Interface* iface;
+   Eldbus_Service_Interface *iface;
    Eina_Array_Iterator iter;
    size_t i;
+
    EINA_ARRAY_ITER_NEXT(ifaces, i, iface, iter)
      eldbus_service_interface_unregister(iface);
    eina_array_free(ifaces);
diff --git a/src/modules/msgbus/e_mod_main.h b/src/modules/msgbus/e_mod_main.h
index 7faa875..e28c11d 100644
--- a/src/modules/msgbus/e_mod_main.h
+++ b/src/modules/msgbus/e_mod_main.h
@@ -7,6 +7,9 @@
 void msgbus_lang_init(Eina_Array *ifaces);
 void msgbus_desktop_init(Eina_Array *ifaces);
 void msgbus_audit_init(Eina_Array *ifaces);
+void msgbus_module_init(Eina_Array *ifaces);
+void msgbus_profile_init(Eina_Array *ifaces);
+void msgbus_window_init(Eina_Array *ifaces);
 
 /**
  * @addtogroup Optional_Control
diff --git a/src/modules/msgbus/msgbus_audit.c 
b/src/modules/msgbus/msgbus_audit.c
index dc61674..0459179 100644
--- a/src/modules/msgbus/msgbus_audit.c
+++ b/src/modules/msgbus/msgbus_audit.c
@@ -19,11 +19,9 @@ cb_audit_timer_dump(const Eldbus_Service_Interface *iface 
EINA_UNUSED,
 
    tmp = ecore_timer_dump();
    if (!tmp)
-     eldbus_message_arguments_append(reply, "s",
-                                    "Not enable, recompile Ecore with 
ecore_timer_dump.");
-   else
-     eldbus_message_arguments_append(reply, "s", tmp);
-
+     eldbus_message_arguments_append
+       (reply, "s", "Not enable, recompile Ecore with ecore_timer_dump.");
+   else eldbus_message_arguments_append(reply, "s", tmp);
    return reply;
 }
 
@@ -42,12 +40,11 @@ void msgbus_audit_init(Eina_Array *ifaces)
 
    if (_log_dom == -1)
      {
-       _log_dom = eina_log_domain_register("msgbus_audit", EINA_COLOR_BLUE);
-       if (_log_dom < 0)
-         EINA_LOG_ERR("could not register msgbus_audit log domain!");
+        _log_dom = eina_log_domain_register("msgbus_audit", EINA_COLOR_BLUE);
+        if (_log_dom < 0)
+          EINA_LOG_ERR("could not register msgbus_audit log domain!");
      }
 
    iface = e_msgbus_interface_attach(&audit);
-   if (iface)
-     eina_array_push(ifaces, iface);
+   if (iface) eina_array_push(ifaces, iface);
 }
diff --git a/src/modules/msgbus/msgbus_desktop.c 
b/src/modules/msgbus/msgbus_desktop.c
index d5f388a..cb298e9 100644
--- a/src/modules/msgbus/msgbus_desktop.c
+++ b/src/modules/msgbus/msgbus_desktop.c
@@ -16,10 +16,9 @@ cb_virtual_desktops(const Eldbus_Service_Interface *iface 
EINA_UNUSED,
 {
    Eldbus_Message *reply = eldbus_message_method_return_new(msg);
    eldbus_message_arguments_append(reply, "ii", e_config->zone_desks_x_count,
-                                  e_config->zone_desks_y_count);
+                                   e_config->zone_desks_y_count);
    DBG("GetVirtualCount: %d %d",
        e_config->zone_desks_x_count, e_config->zone_desks_y_count);
-
    return reply;
 }
 
@@ -40,7 +39,6 @@ cb_desktop_show(const Eldbus_Service_Interface *iface 
EINA_UNUSED,
    zone = e_zone_current_get();
    DBG("show desktop %d,%d from zone %p.", x, y, zone);
    e_zone_desk_flip_to(zone, x, y);
-
    return reply;
 }
 
@@ -82,7 +80,6 @@ cb_desktop_lock(const Eldbus_Service_Interface *iface 
EINA_UNUSED,
 {
    DBG("desklock requested");
    e_desklock_show(EINA_FALSE);
-
    return eldbus_message_method_return_new(msg);
 }
 
@@ -92,7 +89,6 @@ cb_desktop_unlock(const Eldbus_Service_Interface *iface 
EINA_UNUSED,
 {
    DBG("deskunlock requested");
    e_desklock_hide();
-
    return eldbus_message_method_return_new(msg);
 }
 
@@ -104,19 +100,17 @@ cb_desktop_bgadd(const Eldbus_Service_Interface *iface 
EINA_UNUSED,
    const char *path;
    Eldbus_Message *reply = eldbus_message_method_return_new(msg);
 
-   if (!eldbus_message_arguments_get(msg, "iiis", &zone, &desk_x,
-                                    &desk_y, &path))
+   if (!eldbus_message_arguments_get(msg, "iiis", &zone,
+                                     &desk_x, &desk_y, &path))
      {
         ERR("could not get Add arguments");
         return reply;
      }
 
-   DBG("add bg zone=%d, pos=%d,%d path=%s",
-       zone, desk_x, desk_y, path);
+   DBG("add bg zone=%d, pos=%d,%d path=%s", zone, desk_x, desk_y, path);
    e_bg_add(zone, desk_x, desk_y, path);
    e_bg_update();
    e_config_save_queue();
-
    return reply;
 }
 
@@ -127,19 +121,16 @@ cb_desktop_bgdel(const Eldbus_Service_Interface *iface 
EINA_UNUSED,
    int zone, desk_x, desk_y;
    Eldbus_Message *reply = eldbus_message_method_return_new(msg);
 
-   if (!eldbus_message_arguments_get(msg, "iii", &zone, &desk_x,
-                                    &desk_y))
+   if (!eldbus_message_arguments_get(msg, "iii", &zone, &desk_x, &desk_y))
      {
         ERR("could not get Del arguments");
         return reply;
      }
 
-   DBG("del bg zone=%d, pos=%d,%d",
-       zone, desk_x, desk_y);
+   DBG("del bg zone=%d, pos=%d,%d", zone, desk_x, desk_y);
    e_bg_del(zone, desk_x, desk_y);
    e_bg_update();
    e_config_save_queue();
-
    return reply;
 }
 
@@ -152,12 +143,10 @@ cb_desktop_bglist(const Eldbus_Service_Interface *iface 
EINA_UNUSED,
    Eldbus_Message *reply = eldbus_message_method_return_new(msg);
    Eldbus_Message_Iter *main_iter, *array;
 
-   if (!reply)
-     return NULL;
+   if (!reply) return NULL;
 
    main_iter = eldbus_message_iter_get(reply);
-   if (!main_iter)
-     return reply;
+   if (!main_iter) return reply;
 
    if (!eldbus_message_iter_arguments_append(main_iter, "a(iiiis)", &array))
      return reply;
@@ -166,10 +155,7 @@ cb_desktop_bglist(const Eldbus_Service_Interface *iface 
EINA_UNUSED,
      {
         Eldbus_Message_Iter *s;
 
-        if (!bg || !bg->file)
-          {
-             continue;
-          }
+        if (!bg || !bg->file) continue;
         DBG("Background zone=%d pos=%d,%d path=%s",
             bg->zone, bg->desk_x, bg->desk_y, bg->file);
         eldbus_message_iter_arguments_append(array, "(iiiis)", &s);
@@ -179,28 +165,21 @@ cb_desktop_bglist(const Eldbus_Service_Interface *iface 
EINA_UNUSED,
         eldbus_message_iter_container_close(array, s);
      }
    eldbus_message_iter_container_close(main_iter, array);
-
    return reply;
 }
 
 static const Eldbus_Method desktop_methods[] = {
-   { "GetVirtualCount", NULL, ELDBUS_ARGS({"i", "desk_x"}, {"i", "desk_y"}),
-      cb_virtual_desktops, 0 },
-   { "Show", ELDBUS_ARGS({"i", "desk_x"}, {"i", "desk_y"}), NULL,
-      cb_desktop_show, 0 },
-   { "ShowByName", ELDBUS_ARGS({"s", "desk_name"}), NULL,
-      cb_desktop_show_by_name, 0 },
+   { "GetVirtualCount", NULL, ELDBUS_ARGS({"i", "desk_x"}, {"i", "desk_y"}), 
cb_virtual_desktops, 0 },
+   { "Show", ELDBUS_ARGS({"i", "desk_x"}, {"i", "desk_y"}), NULL, 
cb_desktop_show, 0 },
+   { "ShowByName", ELDBUS_ARGS({"s", "desk_name"}), NULL, 
cb_desktop_show_by_name, 0 },
    { "Lock", NULL, NULL, cb_desktop_lock, 0 },
    { "Unlock", NULL, NULL, cb_desktop_unlock, 0 },
    { NULL, NULL, NULL, NULL, 0 }
 };
 
 static const Eldbus_Method background_methods[] = {
-   { "Add",
-      ELDBUS_ARGS({"i", "zone"}, {"i", "desk_x"}, {"i", "desk_y"}, {"s", 
"path"}),
-      NULL, cb_desktop_bgadd, 0 },
-   { "Del", ELDBUS_ARGS({"i", "zone"}, {"i", "desk_x"}, {"i", "desk_y"}),
-      NULL, cb_desktop_bgdel, 0 },
+   { "Add", ELDBUS_ARGS({"i", "zone"}, {"i", "desk_x"}, {"i", "desk_y"}, {"s", 
"path"}), NULL, cb_desktop_bgadd, 0 },
+   { "Del", ELDBUS_ARGS({"i", "zone"}, {"i", "desk_x"}, {"i", "desk_y"}), 
NULL, cb_desktop_bgdel, 0 },
    { "List", ELDBUS_ARGS({"a(iiis)", "array_of_bg"}), NULL, cb_desktop_bglist, 
0 },
    { NULL, NULL, NULL, NULL, 0 }
 };
@@ -219,15 +198,12 @@ void msgbus_desktop_init(Eina_Array *ifaces)
 
    if (_log_dom == -1)
      {
-       _log_dom = eina_log_domain_register("msgbus_desktop", EINA_COLOR_BLUE);
-       if (_log_dom < 0)
-         EINA_LOG_ERR("could not register msgbus_desktop log domain!");
+        _log_dom = eina_log_domain_register("msgbus_desktop", EINA_COLOR_BLUE);
+        if (_log_dom < 0)
+          EINA_LOG_ERR("could not register msgbus_desktop log domain!");
      }
    iface = e_msgbus_interface_attach(&desktop);
-   if (iface)
-     eina_array_push(ifaces, iface);
-   iface = NULL;
+   if (iface) eina_array_push(ifaces, iface);
    iface = e_msgbus_interface_attach(&bg);
-   if (iface)
-     eina_array_push(ifaces, iface);
+   if (iface) eina_array_push(ifaces, iface);
 }
diff --git a/src/modules/msgbus/msgbus_lang.c b/src/modules/msgbus/msgbus_lang.c
index 5489145..2cf3263 100644
--- a/src/modules/msgbus/msgbus_lang.c
+++ b/src/modules/msgbus/msgbus_lang.c
@@ -31,14 +31,11 @@ cb_langs(const Eldbus_Service_Interface *iface EINA_UNUSED,
         eldbus_message_iter_basic_append(array, 's', str);
      }
    eldbus_message_iter_container_close(main_iter, array);
-
    return reply;
 }
 
 static const Eldbus_Method methods[] = {
-   {
-    "List", NULL, ELDBUS_ARGS({"as", "langs"}), cb_langs, 0
-   },
+   { "List", NULL, ELDBUS_ARGS({"as", "langs"}), cb_langs, 0 },
    { NULL, NULL, NULL, NULL, 0 }
 };
 
@@ -49,14 +46,14 @@ static const Eldbus_Service_Interface_Desc lang = {
 void msgbus_lang_init(Eina_Array *ifaces)
 {
    Eldbus_Service_Interface *iface;
+
    if (_log_dom == -1)
      {
-       _log_dom = eina_log_domain_register("msgbus_lang", EINA_COLOR_BLUE);
-       if (_log_dom < 0)
-         EINA_LOG_ERR("could not register msgbus_lang log domain!");
+        _log_dom = eina_log_domain_register("msgbus_lang", EINA_COLOR_BLUE);
+        if (_log_dom < 0)
+          EINA_LOG_ERR("could not register msgbus_lang log domain!");
      }
 
    iface = e_msgbus_interface_attach(&lang);
-   if (iface)
-     eina_array_push(ifaces, iface);
+   if (iface) eina_array_push(ifaces, iface);
 }
diff --git a/src/modules/msgbus/msgbus_module.c 
b/src/modules/msgbus/msgbus_module.c
new file mode 100644
index 0000000..7a56196
--- /dev/null
+++ b/src/modules/msgbus/msgbus_module.c
@@ -0,0 +1,156 @@
+#include "e_mod_main.h"
+
+static int _log_dom = -1;
+#undef DBG
+#undef WARN
+#undef INF
+#undef ERR
+#define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__)
+#define WARN(...) EINA_LOG_DOM_WARN(_log_dom, __VA_ARGS__)
+#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__)
+#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__)
+
+static Eldbus_Message *_e_msgbus_module_load_cb(const Eldbus_Service_Interface 
*iface, const Eldbus_Message *msg);
+static Eldbus_Message *_e_msgbus_module_unload_cb(const 
Eldbus_Service_Interface *iface, const Eldbus_Message *msg);
+static Eldbus_Message *_e_msgbus_module_enable_cb(const 
Eldbus_Service_Interface *iface, const Eldbus_Message *msg);
+static Eldbus_Message *_e_msgbus_module_disable_cb(const 
Eldbus_Service_Interface *iface, const Eldbus_Message *msg);
+static Eldbus_Message *_e_msgbus_module_list_cb(const Eldbus_Service_Interface 
*iface, const Eldbus_Message *msg);
+static const Eldbus_Method module_methods[] = {
+   { "Load", ELDBUS_ARGS({"s", "module"}), NULL, _e_msgbus_module_load_cb, 0 },
+   { "Unload", ELDBUS_ARGS({"s", "module"}), NULL, _e_msgbus_module_unload_cb, 
0 },
+   { "Enable", ELDBUS_ARGS({"s", "module"}), NULL, _e_msgbus_module_enable_cb, 
0 },
+   { "Disable", ELDBUS_ARGS({"s", "module"}), NULL, 
_e_msgbus_module_disable_cb, 0 },
+   { "List", NULL, ELDBUS_ARGS({"a(si)", "modules"}), 
_e_msgbus_module_list_cb, 0 },
+   { NULL, NULL, NULL, NULL, 0}
+};
+
+static const Eldbus_Service_Interface_Desc module = {
+   "org.enlightenment.wm.Module", module_methods, NULL, NULL, NULL, NULL
+};
+
+/* Modules Handlers */
+static Eldbus_Message *
+_e_msgbus_module_load_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
+                         const Eldbus_Message *msg)
+{
+   char *module;
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+
+   if (!eldbus_message_arguments_get(msg, "s", &module)) return reply;
+
+   if (!e_module_find(module))
+     {
+        e_module_new(module);
+        e_config_save_queue();
+     }
+
+   return reply;
+}
+
+static Eldbus_Message *
+_e_msgbus_module_unload_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
+                           const Eldbus_Message *msg)
+{
+   char *module;
+   E_Module *m;
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+
+   if (!eldbus_message_arguments_get(msg, "s", &module)) return reply;
+
+   if ((m = e_module_find(module)))
+     {
+        e_module_disable(m);
+        e_object_del(E_OBJECT(m));
+        e_config_save_queue();
+     }
+
+   return reply;
+}
+
+static Eldbus_Message *
+_e_msgbus_module_enable_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
+                           const Eldbus_Message *msg)
+{
+   char *module;
+   E_Module *m;
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+
+   if (!eldbus_message_arguments_get(msg, "s", &module)) return reply;
+
+   if ((m = e_module_find(module)))
+     {
+        e_module_enable(m);
+        e_config_save_queue();
+     }
+
+   return reply;
+}
+
+static Eldbus_Message *
+_e_msgbus_module_disable_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
+                            const Eldbus_Message *msg)
+{
+   char *module;
+   E_Module *m;
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+
+   if (!eldbus_message_arguments_get(msg, "s", &module)) return reply;
+
+   if ((m = e_module_find(module)))
+     {
+        e_module_disable(m);
+        e_config_save_queue();
+     }
+
+   return reply;
+}
+
+static Eldbus_Message *
+_e_msgbus_module_list_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
+                         const Eldbus_Message *msg)
+{
+   Eina_List *l;
+   E_Module *mod;
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   Eldbus_Message_Iter *main_iter, *array;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(reply, NULL);
+   main_iter = eldbus_message_iter_get(reply);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(main_iter, reply);
+
+   eldbus_message_iter_arguments_append(main_iter, "a(si)", &array);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(array, reply);
+
+   EINA_LIST_FOREACH(e_module_list(), l, mod)
+     {
+        Eldbus_Message_Iter *s;
+        const char *name;
+        int enabled;
+
+        name = mod->name;
+        enabled = mod->enabled;
+
+        eldbus_message_iter_arguments_append(array, "(si)", &s);
+        if (!s) continue;
+        eldbus_message_iter_arguments_append(s, "si", name, enabled);
+        eldbus_message_iter_container_close(array, s);
+     }
+   eldbus_message_iter_container_close(main_iter, array);
+
+   return reply;
+}
+
+void msgbus_module_init(Eina_Array *ifaces)
+{
+   Eldbus_Service_Interface *iface;
+
+   if (_log_dom == -1)
+     {
+        _log_dom = eina_log_domain_register("msgbus_module", EINA_COLOR_BLUE);
+        if (_log_dom < 0)
+          EINA_LOG_ERR("could not register msgbus_module log domain!");
+     }
+
+   iface = e_msgbus_interface_attach(&module);
+   if (iface) eina_array_push(ifaces, iface);
+}
diff --git a/src/modules/msgbus/msgbus_profile.c 
b/src/modules/msgbus/msgbus_profile.c
new file mode 100644
index 0000000..24b2913
--- /dev/null
+++ b/src/modules/msgbus/msgbus_profile.c
@@ -0,0 +1,137 @@
+#include "e_mod_main.h"
+
+static int _log_dom = -1;
+#undef DBG
+#undef WARN
+#undef INF
+#undef ERR
+#define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__)
+#define WARN(...) EINA_LOG_DOM_WARN(_log_dom, __VA_ARGS__)
+#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__)
+#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__)
+
+static Eldbus_Message *_e_msgbus_profile_set_cb(const Eldbus_Service_Interface 
*iface, const Eldbus_Message *msg);
+static Eldbus_Message *_e_msgbus_profile_get_cb(const Eldbus_Service_Interface 
*iface, const Eldbus_Message *msg);
+static Eldbus_Message *_e_msgbus_profile_list_cb(const 
Eldbus_Service_Interface *iface, const Eldbus_Message *msg);
+static Eldbus_Message *_e_msgbus_profile_add_cb(const Eldbus_Service_Interface 
*iface, const Eldbus_Message *msg);
+static Eldbus_Message *_e_msgbus_profile_delete_cb(const 
Eldbus_Service_Interface *iface, const Eldbus_Message *msg);
+
+static const Eldbus_Method profile_methods[] = {
+   { "Set", ELDBUS_ARGS({"s", "profile"}), NULL, _e_msgbus_profile_set_cb, 0 },
+   { "Get", NULL, ELDBUS_ARGS({"s", "profile"}), _e_msgbus_profile_get_cb, 0 },
+   { "List", NULL, ELDBUS_ARGS({"as", "array_profiles"}), 
_e_msgbus_profile_list_cb, 0 },
+   { "Add", ELDBUS_ARGS({"s", "profile"}), NULL, _e_msgbus_profile_add_cb, 0 },
+   { "Delete", ELDBUS_ARGS({"s", "profile"}), NULL, 
_e_msgbus_profile_delete_cb, 0 },
+   { NULL, NULL, NULL, NULL, 0}
+};
+
+static const Eldbus_Service_Interface_Desc profile = {
+   "org.enlightenment.wm.Profile", profile_methods, NULL, NULL, NULL, NULL
+};
+
+/* Profile Handlers */
+static Eldbus_Message *
+_e_msgbus_profile_set_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
+                         const Eldbus_Message *msg)
+{
+   char *profile;
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+
+   if (!eldbus_message_arguments_get(msg, "s", &profile))
+     return reply;
+
+   e_config_save_flush();
+   e_config_profile_set(profile);
+   e_config_profile_save();
+   e_config_save_block_set(1);
+   e_sys_action_do(E_SYS_RESTART, NULL);
+
+   return reply;
+}
+
+static Eldbus_Message *
+_e_msgbus_profile_get_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
+                         const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   const char *profile;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(reply, NULL);
+   profile = e_config_profile_get();
+   eldbus_message_arguments_append(reply, "s", profile);
+   return reply;
+}
+
+static Eldbus_Message *
+_e_msgbus_profile_list_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
+                          const Eldbus_Message *msg)
+{
+   Eina_List *l;
+   char *name;
+   Eldbus_Message *reply;
+   Eldbus_Message_Iter *array, *main_iter;
+
+   reply = eldbus_message_method_return_new(msg);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(reply, NULL);
+
+   main_iter = eldbus_message_iter_get(reply);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(main_iter, reply);
+
+   eldbus_message_iter_arguments_append(main_iter, "as", &array);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(array, reply);
+
+   l = e_config_profile_list();
+   EINA_LIST_FREE(l, name)
+     {
+        eldbus_message_iter_basic_append(array, 's', name);
+        free(name);
+     }
+   eldbus_message_iter_container_close(main_iter, array);
+
+   return reply;
+}
+
+static Eldbus_Message *
+_e_msgbus_profile_add_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
+                         const Eldbus_Message *msg)
+{
+   char *profile;
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+
+   if (!eldbus_message_arguments_get(msg, "s", &profile))
+     return reply;
+   e_config_profile_add(profile);
+
+   return reply;
+}
+
+static Eldbus_Message *
+_e_msgbus_profile_delete_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
+                            const Eldbus_Message *msg)
+{
+   char *profile;
+
+   if (!eldbus_message_arguments_get(msg, "s", &profile))
+     return eldbus_message_method_return_new(msg);
+   if (!strcmp(e_config_profile_get(), profile))
+     return eldbus_message_error_new(msg,
+                                    "org.enlightenment.DBus.InvalidArgument",
+                                    "Can't delete active profile");
+   e_config_profile_del(profile);
+   return eldbus_message_method_return_new(msg);
+}
+
+void msgbus_profile_init(Eina_Array *ifaces)
+{
+   Eldbus_Service_Interface *iface;
+
+   if (_log_dom == -1)
+     {
+        _log_dom = eina_log_domain_register("msgbus_profile", EINA_COLOR_BLUE);
+        if (_log_dom < 0)
+          EINA_LOG_ERR("could not register msgbus_profile log domain!");
+     }
+
+   iface = e_msgbus_interface_attach(&profile);
+   if (iface) eina_array_push(ifaces, iface);
+}
diff --git a/src/modules/msgbus/msgbus_window.c 
b/src/modules/msgbus/msgbus_window.c
new file mode 100644
index 0000000..2e7bb28
--- /dev/null
+++ b/src/modules/msgbus/msgbus_window.c
@@ -0,0 +1,133 @@
+#include "e_mod_main.h"
+
+static int _log_dom = -1;
+#undef DBG
+#undef WARN
+#undef INF
+#undef ERR
+#define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__)
+#define WARN(...) EINA_LOG_DOM_WARN(_log_dom, __VA_ARGS__)
+#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__)
+#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__)
+
+#define E_MSGBUS_WIN_ACTION_CB_PROTO(NAME) \
+  static Eldbus_Message * _e_msgbus_window_##NAME##_cb(const 
Eldbus_Service_Interface * iface, const Eldbus_Message * msg)
+
+E_MSGBUS_WIN_ACTION_CB_PROTO(list);
+E_MSGBUS_WIN_ACTION_CB_PROTO(close);
+E_MSGBUS_WIN_ACTION_CB_PROTO(kill);
+E_MSGBUS_WIN_ACTION_CB_PROTO(focus);
+E_MSGBUS_WIN_ACTION_CB_PROTO(iconify);
+E_MSGBUS_WIN_ACTION_CB_PROTO(uniconify);
+E_MSGBUS_WIN_ACTION_CB_PROTO(maximize);
+E_MSGBUS_WIN_ACTION_CB_PROTO(unmaximize);
+
+static const Eldbus_Method window_methods[] = {
+   { "List", NULL, ELDBUS_ARGS({"a(si)", "array_of_window"}), 
_e_msgbus_window_list_cb, 0 },
+   { "Close", ELDBUS_ARGS({"i", "window_id"}), NULL, 
_e_msgbus_window_close_cb, 0 },
+   { "Kill", ELDBUS_ARGS({"i", "window_id"}), NULL, _e_msgbus_window_kill_cb, 
0 },
+   { "Focus", ELDBUS_ARGS({"i", "window_id"}), NULL, 
_e_msgbus_window_focus_cb, 0 },
+   { "Iconify", ELDBUS_ARGS({"i", "window_id"}), NULL, 
_e_msgbus_window_iconify_cb, 0 },
+   { "Uniconify", ELDBUS_ARGS({"i", "window_id"}), NULL, 
_e_msgbus_window_uniconify_cb, 0 },
+   { "Maximize", ELDBUS_ARGS({"i", "window_id"}), NULL, 
_e_msgbus_window_maximize_cb, 0 },
+   { "Unmaximize", ELDBUS_ARGS({"i", "window_id"}), NULL, 
_e_msgbus_window_unmaximize_cb, 0 },
+   { NULL, NULL, NULL, NULL, 0}
+};
+
+static const Eldbus_Service_Interface_Desc window = {
+   "org.enlightenment.wm.Window", window_methods, NULL, NULL, NULL, NULL
+};
+
+/* Window handlers */
+static Eldbus_Message *
+_e_msgbus_window_list_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
+                         const Eldbus_Message *msg)
+{
+   const Eina_List *l;
+   E_Client *ec;
+   Eldbus_Message *reply;
+   Eldbus_Message_Iter *main_iter, *array;
+
+   reply = eldbus_message_method_return_new(msg);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(reply, NULL);
+
+   main_iter = eldbus_message_iter_get(reply);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(main_iter, reply);
+
+   eldbus_message_iter_arguments_append(main_iter, "a(si)", &array);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(array, reply);
+
+   EINA_LIST_FOREACH(e_comp->clients, l, ec)
+     {
+        Eldbus_Message_Iter *s;
+
+        if (e_client_util_ignored_get(ec)) continue;
+
+        eldbus_message_iter_arguments_append(array, "(si)", &s);
+        if (!s) continue;
+        eldbus_message_iter_arguments_append(s, "si", ec->icccm.name,
+                                            e_client_util_win_get(ec));
+        eldbus_message_iter_container_close(array, s);
+     }
+   eldbus_message_iter_container_close(main_iter, array);
+
+   return reply;
+}
+
+#define E_MSGBUS_WIN_ACTION_CB_BEGIN(NAME) \
+   static Eldbus_Message * \
+   _e_msgbus_window_##NAME##_cb(const Eldbus_Service_Interface *iface 
EINA_UNUSED, \
+                                const Eldbus_Message *msg) { \
+      E_Client *ec; \
+      int xwin; \
+      if (!eldbus_message_arguments_get(msg, "i", &xwin)) \
+        return eldbus_message_method_return_new(msg); \
+      ec = e_pixmap_find_client(E_PIXMAP_TYPE_X, xwin); \
+      if (ec) {
+#define E_MSGBUS_WIN_ACTION_CB_END \
+      } \
+      return eldbus_message_method_return_new(msg); \
+   }
+
+E_MSGBUS_WIN_ACTION_CB_BEGIN(close)
+  e_client_act_close_begin(ec);
+E_MSGBUS_WIN_ACTION_CB_END
+
+E_MSGBUS_WIN_ACTION_CB_BEGIN(kill)
+  e_client_act_kill_begin(ec);
+E_MSGBUS_WIN_ACTION_CB_END
+
+E_MSGBUS_WIN_ACTION_CB_BEGIN(focus)
+  e_client_activate(ec, 1);
+E_MSGBUS_WIN_ACTION_CB_END
+
+E_MSGBUS_WIN_ACTION_CB_BEGIN(iconify)
+  e_client_iconify(ec);
+E_MSGBUS_WIN_ACTION_CB_END
+
+E_MSGBUS_WIN_ACTION_CB_BEGIN(uniconify)
+  e_client_uniconify(ec);
+E_MSGBUS_WIN_ACTION_CB_END
+
+E_MSGBUS_WIN_ACTION_CB_BEGIN(maximize)
+  e_client_maximize(ec, e_config->maximize_policy);
+E_MSGBUS_WIN_ACTION_CB_END
+
+E_MSGBUS_WIN_ACTION_CB_BEGIN(unmaximize)
+  e_client_unmaximize(ec, E_MAXIMIZE_BOTH);
+E_MSGBUS_WIN_ACTION_CB_END
+
+void msgbus_window_init(Eina_Array *ifaces)
+{
+   Eldbus_Service_Interface *iface;
+
+   if (_log_dom == -1)
+     {
+        _log_dom = eina_log_domain_register("msgbus_window", EINA_COLOR_BLUE);
+        if (_log_dom < 0)
+          EINA_LOG_ERR("could not register msgbus_window log domain!");
+     }
+
+   iface = e_msgbus_interface_attach(&window);
+   if (iface) eina_array_push(ifaces, iface);
+}

-- 


Reply via email to