diff options
author | Gustavo Sverzut Barbieri <barbieri@gmail.com> | 2010-03-12 22:00:14 +0000 |
---|---|---|
committer | Gustavo Sverzut Barbieri <barbieri@gmail.com> | 2010-03-12 22:00:14 +0000 |
commit | e345b9c995044154693c1dab4b071506cc9fe657 (patch) | |
tree | 00def00380a4612cb0089aa96a13f08523e0d6ec | |
parent | ddc7ec3bfeebfa1e85dd6920766874b102b97302 (diff) | |
download | enlightenment-e345b9c995044154693c1dab4b071506cc9fe657.tar.gz |
cleanups, logs and simplify dbus message argument handling.
SVN revision: 47169
-rw-r--r-- | src/modules/msgbus/Makefile.am | 4 | ||||
-rw-r--r-- | src/modules/msgbus/e_mod_main.c | 7 | ||||
-rw-r--r-- | src/modules/msgbus/e_mod_main.h | 6 | ||||
-rw-r--r-- | src/modules/msgbus/msgbus_desktop.c | 110 | ||||
-rw-r--r-- | src/modules/msgbus/msgbus_desktop.h | 9 | ||||
-rw-r--r-- | src/modules/msgbus/msgbus_lang.c | 31 | ||||
-rw-r--r-- | src/modules/msgbus/msgbus_lang.h | 9 |
7 files changed, 89 insertions, 87 deletions
diff --git a/src/modules/msgbus/Makefile.am b/src/modules/msgbus/Makefile.am index 454729529f..51868514c1 100644 --- a/src/modules/msgbus/Makefile.am +++ b/src/modules/msgbus/Makefile.am @@ -25,9 +25,7 @@ pkg_LTLIBRARIES = module.la module_la_SOURCES = e_mod_main.c \ e_mod_main.h \ msgbus_lang.c \ - msgbus_lang.h \ - msgbus_desktop.c \ - msgbus_desktop.h + msgbus_desktop.c module_la_LIBADD = @e_libs@ @dlopen_libs@ module_la_LDFLAGS = -module -avoid-version diff --git a/src/modules/msgbus/e_mod_main.c b/src/modules/msgbus/e_mod_main.c index 60df318911..b1f6bc7b2e 100644 --- a/src/modules/msgbus/e_mod_main.c +++ b/src/modules/msgbus/e_mod_main.c @@ -1,10 +1,7 @@ /* * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ -#include "e.h" #include "e_mod_main.h" -#include "msgbus_lang.h" -#include "msgbus_desktop.h" /* actual module specifics */ static Eina_Array* ifaces = NULL; @@ -28,7 +25,7 @@ e_modapi_init(E_Module *m) } EAPI int -e_modapi_shutdown(E_Module *m) +e_modapi_shutdown(E_Module *m __UNUSED__) { E_DBus_Interface* iface; Eina_Array_Iterator iter; @@ -44,7 +41,7 @@ e_modapi_shutdown(E_Module *m) } EAPI int -e_modapi_save(E_Module *m) +e_modapi_save(E_Module *m __UNUSED__) { return 1; } diff --git a/src/modules/msgbus/e_mod_main.h b/src/modules/msgbus/e_mod_main.h index 2eb60362ec..a87f12bcca 100644 --- a/src/modules/msgbus/e_mod_main.h +++ b/src/modules/msgbus/e_mod_main.h @@ -4,10 +4,16 @@ #ifndef E_MOD_MAIN_H #define E_MOD_MAIN_H +#include "e.h" + EAPI extern E_Module_Api e_modapi; EAPI void *e_modapi_init (E_Module *m); EAPI int e_modapi_shutdown (E_Module *m); EAPI int e_modapi_save (E_Module *m); +/* sub-module initializers */ +void msgbus_lang_init(Eina_Array *ifaces); +void msgbus_desktop_init(Eina_Array *ifaces); + #endif diff --git a/src/modules/msgbus/msgbus_desktop.c b/src/modules/msgbus/msgbus_desktop.c index 5d6154657c..d8746232d9 100644 --- a/src/modules/msgbus/msgbus_desktop.c +++ b/src/modules/msgbus/msgbus_desktop.c @@ -1,9 +1,7 @@ /* * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ - -#include "e.h" -#include "msgbus_desktop.h" +#include "e_mod_main.h" static int _log_dom = -1; #define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__) @@ -12,23 +10,21 @@ static int _log_dom = -1; #define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__) static DBusMessage * -cb_virtual_desktops(E_DBus_Object *obj, DBusMessage *msg) +cb_virtual_desktops(E_DBus_Object *obj __UNUSED__, DBusMessage *msg) { - DBusMessage* reply; - DBusMessageIter iter; - - reply = dbus_message_new_method_return(msg); - dbus_message_iter_init_append(reply, &iter); - dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, - &(e_config->zone_desks_x_count)); - dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, - &(e_config->zone_desks_y_count)); + DBusMessage *reply = dbus_message_new_method_return(msg); + dbus_message_append_args(reply, + DBUS_TYPE_INT32, &(e_config->zone_desks_x_count), + DBUS_TYPE_INT32, &(e_config->zone_desks_y_count), + DBUS_TYPE_INVALID); + DBG("GetVirtualCount: %d %d", + e_config->zone_desks_x_count, e_config->zone_desks_y_count); return reply; } static DBusMessage * -cb_desktop_show(E_DBus_Object *obj, DBusMessage *msg) +cb_desktop_show(E_DBus_Object *obj __UNUSED__, DBusMessage *msg) { DBusError err; int x, y; @@ -45,7 +41,6 @@ cb_desktop_show(E_DBus_Object *obj, DBusMessage *msg) else { E_Zone *zone = e_util_zone_current_get(e_manager_current_get()); - fprintf(stderr, "show desktop %d,%d from zone %p.\n", x, y, zone); DBG("show desktop %d,%d from zone %p.", x, y, zone); e_zone_desk_flip_to(zone, x, y); } @@ -54,7 +49,7 @@ cb_desktop_show(E_DBus_Object *obj, DBusMessage *msg) } static DBusMessage * -cb_desktop_show_by_name(E_DBus_Object *obj, DBusMessage *msg) +cb_desktop_show_by_name(E_DBus_Object *obj __UNUSED__, DBusMessage *msg) { DBusError err; const char *name; @@ -91,54 +86,68 @@ cb_desktop_show_by_name(E_DBus_Object *obj, DBusMessage *msg) } static DBusMessage* -cb_desktop_bgadd(E_DBus_Object *obj, DBusMessage *msg) +cb_desktop_bgadd(E_DBus_Object *obj __UNUSED__, DBusMessage *msg) { - DBusMessageIter iter; + DBusError err; int container, zone, desk_x, desk_y; - char* path; - - dbus_message_iter_init(msg, &iter); - dbus_message_iter_get_basic(&iter, &container); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &zone); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &desk_x); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &desk_y); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &path); - - e_bg_add(container, zone, desk_x, desk_y, path); - e_bg_update(); - e_config_save_queue(); + const char *path; + + dbus_error_init(&err); + if (!dbus_message_get_args(msg, &err, + DBUS_TYPE_INT32, &container, + DBUS_TYPE_INT32, &zone, + DBUS_TYPE_INT32, &desk_x, + DBUS_TYPE_INT32, &desk_y, + DBUS_TYPE_STRING, &path, + DBUS_TYPE_INVALID)) + { + ERR("could not get Add arguments: %s: %s", err.name, err.message); + dbus_error_free(&err); + } + else if (path) + { + DBG("add bg container=%d, zone=%d, pos=%d,%d path=%s", + container, zone, desk_x, desk_y, path); + e_bg_add(container, zone, desk_x, desk_y, path); + e_bg_update(); + e_config_save_queue(); + } return dbus_message_new_method_return(msg); } static DBusMessage* -cb_desktop_bgdel(E_DBus_Object *obj, DBusMessage *msg) +cb_desktop_bgdel(E_DBus_Object *obj __UNUSED__, DBusMessage *msg) { - DBusMessageIter iter; + DBusError err; int container, zone, desk_x, desk_y; - dbus_message_iter_init(msg, &iter); - dbus_message_iter_get_basic(&iter, &container); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &zone); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &desk_x); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &desk_y); + dbus_error_init(&err); + if (!dbus_message_get_args(msg, &err, + DBUS_TYPE_INT32, &container, + DBUS_TYPE_INT32, &zone, + DBUS_TYPE_INT32, &desk_x, + DBUS_TYPE_INT32, &desk_y, + DBUS_TYPE_INVALID)) + { + ERR("could not get Del arguments: %s: %s", err.name, err.message); + dbus_error_free(&err); + } + else + { + DBG("del bg container=%d, zone=%d, pos=%d,%d", + container, zone, desk_x, desk_y); - e_bg_del(container, zone, desk_x, desk_y); - e_bg_update(); - e_config_save_queue(); + e_bg_del(container, zone, desk_x, desk_y); + e_bg_update(); + e_config_save_queue(); + } return dbus_message_new_method_return(msg); } static DBusMessage* -cb_desktop_bglist(E_DBus_Object *obj, DBusMessage *msg) +cb_desktop_bglist(E_DBus_Object *obj __UNUSED__, DBusMessage *msg) { Eina_List *list; E_Config_Desktop_Background *bg; @@ -159,6 +168,9 @@ cb_desktop_bglist(E_DBus_Object *obj, DBusMessage *msg) continue; } + DBG("Background container=%d zone=%d pos=%d,%d path=%s", + bg->container, bg->zone, bg->desk_x, bg->desk_y, bg->file); + dbus_message_iter_open_container(&arr, DBUS_TYPE_STRUCT, NULL, &sub); dbus_message_iter_append_basic(&sub, DBUS_TYPE_INT32, &(bg->container)); dbus_message_iter_append_basic(&sub, DBUS_TYPE_INT32, &(bg->zone)); @@ -202,7 +214,7 @@ void msgbus_desktop_init(Eina_Array *ifaces) e_dbus_interface_method_add(iface, "Add", "iiiis", "", cb_desktop_bgadd); e_dbus_interface_method_add(iface, "Del", "iiii", "", - cb_desktop_bgadd); + cb_desktop_bgdel); e_dbus_interface_method_add(iface, "List", "", "a(iiiis)", cb_desktop_bglist); e_msgbus_interface_attach(iface); diff --git a/src/modules/msgbus/msgbus_desktop.h b/src/modules/msgbus/msgbus_desktop.h deleted file mode 100644 index 084729c6cb..0000000000 --- a/src/modules/msgbus/msgbus_desktop.h +++ /dev/null @@ -1,9 +0,0 @@ -/* - * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 - */ -#ifndef MSGBUS_DESKTOP_H -#define MSGBUS_DESKTOP_H - -void msgbus_desktop_init(Eina_Array *ifaces); - -#endif /* MSGBUS_DESKTOP_H */ diff --git a/src/modules/msgbus/msgbus_lang.c b/src/modules/msgbus/msgbus_lang.c index ea8bb7c418..ec4f633edd 100644 --- a/src/modules/msgbus/msgbus_lang.c +++ b/src/modules/msgbus/msgbus_lang.c @@ -1,30 +1,30 @@ /* * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ -#include "e.h" -#include "msgbus_lang.h" +#include "e_mod_main.h" + +static int _log_dom = -1; +#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 DBusMessage * -cb_langs(E_DBus_Object *obj, DBusMessage *message) +cb_langs(E_DBus_Object *obj __UNUSED__, DBusMessage *message) { DBusMessage *reply; DBusMessageIter iter; DBusMessageIter arr; - Eina_List * languages; - Eina_List * l; - - memset(&arr, 0, sizeof(DBusMessageIter)); + const Eina_List *l; + const char *str; reply = dbus_message_new_method_return(message); dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &arr); - languages = e_intl_language_list(); - for (l = languages; l; l = l->next) + EINA_LIST_FOREACH(e_intl_language_list(), l, str) { - const char *str; - - str = l->data; + DBG("language: %s", str); dbus_message_iter_append_basic(&arr, DBUS_TYPE_STRING, &str); } @@ -37,6 +37,13 @@ void msgbus_lang_init(Eina_Array *ifaces) { E_DBus_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!"); + } + iface = e_dbus_interface_new("org.enlightenment.wm.Language"); if (iface) { diff --git a/src/modules/msgbus/msgbus_lang.h b/src/modules/msgbus/msgbus_lang.h deleted file mode 100644 index 6c6c1e1288..0000000000 --- a/src/modules/msgbus/msgbus_lang.h +++ /dev/null @@ -1,9 +0,0 @@ -/* - * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 - */ -#ifndef MSGBUS_LANG_H -#define MSGBUS_LANG_H - -void msgbus_lang_init(Eina_Array *ifaces); - -#endif /* MSGBUS_LANG_H */ |