Enlightenment CVS committal Author : sebastid Project : e17 Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_dbus Modified Files: Ecore_DBus.h ecore_dbus.c Log Message: Fix init() Add shutdown() =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_dbus/Ecore_DBus.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- Ecore_DBus.h 4 Sep 2005 18:53:46 -0000 1.3 +++ Ecore_DBus.h 7 Sep 2005 09:14:31 -0000 1.4 @@ -199,6 +199,8 @@ /* connection */ EAPI int ecore_dbus_init(void); + EAPI int ecore_dbus_shutdown(void); + EAPI Ecore_DBus_Server* ecore_dbus_server_connect(Ecore_DBus_Type compl_type, char *name, int port, const void *data); /* message */ EAPI unsigned int ecore_dbus_message_new_method_call(Ecore_DBus_Server *svr,char *service,char *path,char *interface,char *method,char *fmt, ...); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_dbus/ecore_dbus.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- ecore_dbus.c 30 Aug 2005 10:05:27 -0000 1.5 +++ ecore_dbus.c 7 Sep 2005 09:14:31 -0000 1.6 @@ -972,8 +972,9 @@ {"SKEY", 0, {NULL, NULL, NULL, NULL, NULL}}, }; -static int init_count = 0; -static Ecore_List *servers = NULL; +static int init_count = 0; +static Ecore_List *servers = NULL; +static Ecore_Event_Handler *handler[6]; static int _ecore_dbus_event_client_add(void *data, int ev_type, void *ev); @@ -993,31 +994,47 @@ int ecore_dbus_init(void) { - if (!init_count) - ecore_con_init(); - init_count++; - if (!ECORE_DBUS_EVENT_CLIENT_ADD) - { - ECORE_DBUS_EVENT_CLIENT_ADD = ecore_event_type_new(); - ECORE_DBUS_EVENT_CLIENT_DEL = ecore_event_type_new(); - ECORE_DBUS_EVENT_SERVER_ADD = ecore_event_type_new(); - ECORE_DBUS_EVENT_SERVER_DEL = ecore_event_type_new(); - ECORE_DBUS_EVENT_CLIENT_DATA = ecore_event_type_new(); - ECORE_DBUS_EVENT_SERVER_DATA = ecore_event_type_new(); - - ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, - _ecore_dbus_event_client_add, NULL); - ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, - _ecore_dbus_event_client_del, NULL); - ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, - _ecore_dbus_event_server_add, NULL); - ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, - _ecore_dbus_event_server_del, NULL); - ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, - _ecore_dbus_event_client_data, NULL); - ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, - _ecore_dbus_event_server_data, NULL); - } + int i = 0; + + if (++init_count != 1) return init_count; + + ecore_con_init(); + + ECORE_DBUS_EVENT_CLIENT_ADD = ecore_event_type_new(); + ECORE_DBUS_EVENT_CLIENT_DEL = ecore_event_type_new(); + ECORE_DBUS_EVENT_SERVER_ADD = ecore_event_type_new(); + ECORE_DBUS_EVENT_SERVER_DEL = ecore_event_type_new(); + ECORE_DBUS_EVENT_CLIENT_DATA = ecore_event_type_new(); + ECORE_DBUS_EVENT_SERVER_DATA = ecore_event_type_new(); + + handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, + _ecore_dbus_event_client_add, NULL); + handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, + _ecore_dbus_event_client_del, NULL); + handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, + _ecore_dbus_event_server_add, NULL); + handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, + _ecore_dbus_event_server_del, NULL); + handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, + _ecore_dbus_event_client_data, NULL); + handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, + _ecore_dbus_event_server_data, NULL); + + return init_count; +} + +int +ecore_dbus_shutdown(void) +{ + int i = 0; + + if (--init_count != 0) return init_count; + + for (i = 0; i < 6; i++) + ecore_event_handler_del(handler[i]); + + ecore_con_shutdown(); + return init_count; } ------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs