improvements after logging.
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 23 Sep 2009 00:00:11 +0000 (00:00 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 23 Sep 2009 00:00:11 +0000 (00:00 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/e_dbus@42632 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

19 files changed:
src/bin/hal.c
src/lib/dbus/e_dbus.c
src/lib/dbus/e_dbus_interfaces.c
src/lib/dbus/e_dbus_message.c
src/lib/dbus/e_dbus_methods.c
src/lib/dbus/e_dbus_object.c
src/lib/dbus/e_dbus_private.h
src/lib/dbus/e_dbus_signal.c
src/lib/hal/E_Hal.h
src/lib/hal/Makefile.am
src/lib/hal/e_hal_device.c
src/lib/hal/e_hal_main.c [new file with mode: 0644]
src/lib/hal/e_hal_manager.c
src/lib/hal/e_hal_private.h [new file with mode: 0644]
src/lib/hal/e_hal_util.c
src/lib/notification/Makefile.am
src/lib/notification/client.c
src/lib/notification/daemon.c
src/lib/notification/e_notify_private.h

index 9149118..d1876ff 100644 (file)
@@ -1,6 +1,5 @@
 #include "E_Hal.h"
 #include <config.h>
-#include "e_dbus_private.h"
 
 #if EWL_GUI
 #include <Ewl.h>
@@ -100,7 +99,7 @@ storage_free(Storage *storage)
 {
   Volume *v;
   Eina_List *l;
-  E_DBUS_LOG_INFO("storage_free: %s", storage->udi);
+  EINA_LOG_INFO("storage_free: %s", storage->udi);
 
   /* disconnect storage from volume */
   EINA_LIST_FOREACH(storage->volumes, l, v)
@@ -364,7 +363,7 @@ volume_append(const char *udi)
 {
   Volume *v;
   if (!udi) return NULL;
-  E_DBUS_LOG_INFO("ADDING %s", udi);
+  EINA_LOG_INFO("ADDING %s", udi);
   v = volume_new();
   v->udi = strdup(udi);
   volumes = eina_list_append(volumes, v);
@@ -394,7 +393,7 @@ cb_test_get_all_devices(void *user_data, void *reply_data, DBusError *error)
 
   EINA_LIST_FOREACH(ret->strings, l, device)
   {
-     E_DBUS_LOG_INFO("device: %s", device);
+     EINA_LOG_INFO("device: %s", device);
   }
 }
 
@@ -488,7 +487,7 @@ cb_signal_device_added(void *data, DBusMessage *msg)
   dbus_error_init(&err);
   dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &udi, DBUS_TYPE_INVALID);
   udi = strdup(udi);
-  E_DBUS_LOG_INFO("Ehal: Device added: %s", udi);
+  EINA_LOG_INFO("Ehal: Device added: %s", udi);
   ret = e_hal_device_query_capability(conn, udi, "storage", cb_is_storage, strdup(udi));
   e_hal_device_query_capability(conn, udi, "volume", cb_is_volume, strdup(udi));
 }
@@ -502,7 +501,7 @@ cb_signal_device_removed(void *data, DBusMessage *msg)
   dbus_error_init(&err);
 
   dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &udi, DBUS_TYPE_INVALID);
-  E_DBUS_LOG_INFO("Removed: %s", udi);
+  EINA_LOG_INFO("Removed: %s", udi);
   storage_remove(udi);
   volume_remove(udi);
 }
@@ -541,7 +540,7 @@ cb_volume_unmounted(void *user_data, void *method_return, DBusError *error)
 {
   Volume *vol = user_data;
   vol->mounted = 0;
-  E_DBUS_LOG_INFO("Volume unmounted reply: %s", vol->udi);
+  EINA_LOG_INFO("Volume unmounted reply: %s", vol->udi);
 }
 
 static void
@@ -549,7 +548,7 @@ cb_volume_mounted(void *user_data, void *method_return, DBusError *error)
 {
   Volume *vol = user_data;
   vol->mounted = 1;
-  E_DBUS_LOG_INFO("Volume mounted reply: %s", vol->udi);
+  EINA_LOG_INFO("Volume mounted reply: %s", vol->udi);
 }
 
 static void
@@ -558,7 +557,7 @@ cb_device_view_clicked(Ewl_Widget *w, void *ev, void *data)
   Device *dev = data;
   char buf[4096];
 
-  E_DBUS_LOG_INFO("Device clicked: %s", dev->udi);
+  EINA_LOG_INFO("Device clicked: %s", dev->udi);
   if (dev->type == DEVICE_TYPE_VOLUME)
   {
     Volume *vol = (Volume *)dev;
@@ -584,7 +583,7 @@ cb_device_view_clicked(Ewl_Widget *w, void *ev, void *data)
         mount_point = buf;
       }
 
-      E_DBUS_LOG_INFO("Attempting to mount %s to %s", vol->udi, mount_point);
+      EINA_LOG_INFO("Attempting to mount %s to %s", vol->udi, mount_point);
       e_hal_device_volume_mount(conn, vol->udi, mount_point, vol->fstype, NULL, cb_volume_mounted, vol);
     }
   }
@@ -626,8 +625,8 @@ device_view_device_set(Ewl_Icon *icon, Device *dev)
   }
   else
   {
-    fprintf(stderr, "Invalid device type.");
-    buf[0] = 0;
+     EINA_LOG_ERR("Invalid device type.");
+     buf[0] = 0;
   }
 
   ewl_icon_label_set(icon, buf);
@@ -794,12 +793,13 @@ main(int argc, char **argv)
   ecore_init();
   eina_init();
   e_dbus_init();
+  e_hal_init();
 
 #if EWL_GUI
   efreet_init();
   if (!ewl_init(&argc, argv))
   {
-    E_DBUS_LOG_INFO(stderr, "Unable to init EWL.");
+    EINA_LOG_INFO("Unable to init EWL.");
     return 1;
   }
 #endif
@@ -807,7 +807,7 @@ main(int argc, char **argv)
   conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
   if (!conn)
   {
-    E_DBUS_LOG_INFO(stderr, "Error connecting to system bus. Is it running?");
+    EINA_LOG_INFO("Error connecting to system bus. Is it running?");
     return 1;
   }
 
@@ -848,6 +848,7 @@ main(int argc, char **argv)
     }
   e_dbus_connection_close(conn);
   e_dbus_shutdown();
+  e_hal_shutdown();
   eina_shutdown();
   ecore_shutdown();
   return 1;
index ce85b1a..bff50f1 100644 (file)
@@ -18,7 +18,7 @@
  *  listen for NameOwnerChanged signals for names we have SignalHandler's for
  *    remap SH to listen for signals from new owner
  */
-int _E_DBUS_LOG_DOM_GLOBAL = -1;
+int _e_dbus_log_dom = -1;
 static int connection_slot = -1;
 
 static int init = 0;
@@ -56,12 +56,12 @@ e_dbus_fd_handler(void *data, Ecore_Fd_Handler *fd_handler)
   E_DBus_Handler_Data *hd;
   unsigned int condition = 0;
 
-  E_DBUS_LOG_DBG("fd handler (%ld)!", (long int)fd_handler);
+  DBG("fd handler (%ld)!", (long int)fd_handler);
 
   hd = data;
 
   if (!hd->enabled) {
-    E_DBUS_LOG_DBG("handler disabled");
+    DBG("handler disabled");
     if (hd->fd_handler) ecore_main_fd_handler_del(hd->fd_handler);
     hd->fd_handler = NULL;
     return 0;
@@ -70,7 +70,7 @@ e_dbus_fd_handler(void *data, Ecore_Fd_Handler *fd_handler)
   if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE)) condition |= DBUS_WATCH_WRITABLE;
   if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR)) condition |= DBUS_WATCH_ERROR;
 
-  if (condition & DBUS_WATCH_ERROR) E_DBUS_LOG_DBG("DBUS watch error");
+  if (condition & DBUS_WATCH_ERROR) DBG("DBUS watch error");
   dbus_watch_handle(hd->watch, condition);
   hd = NULL;
 
@@ -85,7 +85,7 @@ e_dbus_fd_handler_add(E_DBus_Handler_Data *hd)
   Ecore_Fd_Handler_Flags eflags;
 
   if (hd->fd_handler) return;
-  E_DBUS_LOG_DBG("fd handler add (%d)", hd->fd);
+  DBG("fd handler add (%d)", hd->fd);
 
   dflags = dbus_watch_get_flags(hd->watch);
   eflags = ECORE_FD_ERROR;
@@ -109,7 +109,7 @@ e_dbus_handler_data_free(void *data)
 {
   E_DBus_Handler_Data *hd = data;
   
-  E_DBUS_LOG_DBG("e_dbus_handler_data_free");
+  DBG("e_dbus_handler_data_free");
   if (hd->fd_handler)
   {
     hd->cd->fd_handlers = eina_list_remove(hd->cd->fd_handlers, hd->cd->fd_handlers);
@@ -134,7 +134,7 @@ e_dbus_connection_data_watch_add(E_DBus_Connection *cd, DBusWatch *watch)
 #else
   hd->fd = dbus_watch_get_fd(hd->watch);
 #endif
-  E_DBUS_LOG_DBG("watch add (enabled: %d)", hd->enabled);
+  DBG("watch add (enabled: %d)", hd->enabled);
   if (hd->enabled) e_dbus_fd_handler_add(hd);
 }
 
@@ -151,11 +151,11 @@ e_dbus_connection_new(DBusConnection *conn)
   conn_name = dbus_bus_get_unique_name(conn);
   if (conn_name)
   {
-    E_DBUS_LOG_DBG("Connected! Name: %s", conn_name);
+    DBG("Connected! Name: %s", conn_name);
     cd->conn_name = strdup(conn_name);
   }
   else
-    E_DBUS_LOG_DBG("Not connected");
+    DBG("Not connected");
 
   cd->shared_type = -1;
   cd->fd_handlers = NULL;
@@ -170,7 +170,7 @@ e_dbus_connection_free(void *data)
   E_DBus_Connection *cd = data;
   Ecore_Fd_Handler *fd_handler;
   Ecore_Timer *timer;
-  E_DBUS_LOG_DBG("e_dbus_connection free!");
+  DBG("e_dbus_connection free!");
 
   EINA_LIST_FREE(cd->fd_handlers, fd_handler)
     ecore_main_fd_handler_del(fd_handler);
@@ -195,12 +195,12 @@ static void
 cb_main_wakeup(void *data)
 {
   E_DBus_Connection *cd;
-  E_DBUS_LOG_DBG("wakeup main!");
+  DBG("wakeup main!");
 
   cd = data;
 
   if (!cd->idler) cd->idler = ecore_idler_add(e_dbus_idler, cd);
-  else E_DBUS_LOG_DBG("already idling");
+  else DBG("already idling");
 }
 
 static void
@@ -208,7 +208,7 @@ cb_dispatch_status(DBusConnection *conn, DBusDispatchStatus new_status, void *da
 {
   E_DBus_Connection *cd;
 
-  E_DBUS_LOG_DBG("dispatch status: %d!", new_status);
+  DBG("dispatch status: %d!", new_status);
   cd = data;
 
   if (new_status == DBUS_DISPATCH_DATA_REMAINS && !cd->idler) cd->idler = ecore_idler_add(e_dbus_idler, cd);
@@ -238,12 +238,12 @@ e_dbus_timeout_handler(void *data)
 
   if (dbus_timeout_get_enabled(td->timeout)) 
   {
-    E_DBUS_LOG_DBG("timeout_handler (not enabled, ending)");
+    DBG("timeout_handler (not enabled, ending)");
     td->handler = NULL;
     return 0;
   }
 
-  E_DBUS_LOG_DBG("timeout handler!");
+  DBG("timeout handler!");
   dbus_timeout_handle(td->timeout);
   return 1;
 }
@@ -252,7 +252,7 @@ static void
 e_dbus_timeout_data_free(void *timeout_data)
 {
   E_DBus_Timeout_Data *td = timeout_data;
-  E_DBUS_LOG_DBG("e_dbus_timeout_data_free");
+  DBG("e_dbus_timeout_data_free");
   if (td->handler) ecore_timer_del(td->handler);
   free(td);
 }
@@ -264,7 +264,7 @@ cb_timeout_add(DBusTimeout *timeout, void *data)
   E_DBus_Timeout_Data *td;
   
   cd = data;
-  E_DBUS_LOG_DBG("timeout add!");
+  DBG("timeout add!");
   td = calloc(1, sizeof(E_DBus_Timeout_Data));
   td->cd = cd;
   dbus_timeout_set_data(timeout, (void *)td, e_dbus_timeout_data_free);
@@ -282,7 +282,7 @@ static void
 cb_timeout_del(DBusTimeout *timeout, void *data)
 {
   E_DBus_Timeout_Data *td;
-  E_DBUS_LOG_DBG("timeout del!");
+  DBG("timeout del!");
 
   td = (E_DBus_Timeout_Data *)dbus_timeout_get_data(timeout);
 
@@ -300,7 +300,7 @@ static void
 cb_timeout_toggle(DBusTimeout *timeout, void *data)
 {
   E_DBus_Timeout_Data *td;
-  E_DBUS_LOG_DBG("timeout toggle!");
+  DBG("timeout toggle!");
 
   td = (E_DBus_Timeout_Data *)dbus_timeout_get_data(timeout);
 
@@ -324,7 +324,7 @@ cb_watch_add(DBusWatch *watch, void *data)
   E_DBus_Connection *cd;
   cd = data;
 
-  E_DBUS_LOG_DBG("cb_watch_add");
+  DBG("cb_watch_add");
   e_dbus_connection_data_watch_add(cd, watch);
 
   return true;
@@ -335,7 +335,7 @@ cb_watch_del(DBusWatch *watch, void *data)
 {
   E_DBus_Handler_Data *hd;
 
-  E_DBUS_LOG_DBG("cb_watch_del");
+  DBG("cb_watch_del");
   hd = (E_DBus_Handler_Data *)dbus_watch_get_data(watch);
 
   if (hd->fd_handler) 
@@ -351,7 +351,7 @@ cb_watch_toggle(DBusWatch *watch, void *data)
 {
   E_DBus_Handler_Data *hd;
 
-  E_DBUS_LOG_DBG("cb_watch_toggle");
+  DBG("cb_watch_toggle");
   hd = dbus_watch_get_data(watch);
 
   if (!hd) return;
@@ -371,25 +371,25 @@ static DBusHandlerResult
 e_dbus_filter(DBusConnection *conn, DBusMessage *message, void *user_data)
 {
   E_DBus_Connection *cd = user_data;
-  E_DBUS_LOG_DBG("-----------------");
-  E_DBUS_LOG_DBG("Message!");
+  DBG("-----------------");
+  DBG("Message!");
 
-  E_DBUS_LOG_DBG("type: %s", dbus_message_type_to_string(dbus_message_get_type(message)));
-  E_DBUS_LOG_DBG("path: %s", dbus_message_get_path(message));
-  E_DBUS_LOG_DBG("interface: %s", dbus_message_get_interface(message));
-  E_DBUS_LOG_DBG("member: %s", dbus_message_get_member(message));
-  E_DBUS_LOG_DBG("sender: %s", dbus_message_get_sender(message));
+  DBG("type: %s", dbus_message_type_to_string(dbus_message_get_type(message)));
+  DBG("path: %s", dbus_message_get_path(message));
+  DBG("interface: %s", dbus_message_get_interface(message));
+  DBG("member: %s", dbus_message_get_member(message));
+  DBG("sender: %s", dbus_message_get_sender(message));
 
   switch (dbus_message_get_type(message))
   {
     case DBUS_MESSAGE_TYPE_METHOD_CALL:
-      E_DBUS_LOG_DBG("signature: %s", dbus_message_get_signature(message));
+      DBG("signature: %s", dbus_message_get_signature(message));
       break;
     case DBUS_MESSAGE_TYPE_METHOD_RETURN:
-      E_DBUS_LOG_DBG("reply serial %d", dbus_message_get_reply_serial(message));
+      DBG("reply serial %d", dbus_message_get_reply_serial(message));
       break;
     case DBUS_MESSAGE_TYPE_ERROR:
-      E_DBUS_LOG_DBG("error: %s", dbus_message_get_error_name(message));
+      DBG("error: %s", dbus_message_get_error_name(message));
       break;
     case DBUS_MESSAGE_TYPE_SIGNAL:
       dbus_message_ref(message);
@@ -404,7 +404,7 @@ e_dbus_filter(DBusConnection *conn, DBusMessage *message, void *user_data)
     default:
       break;
   }
-  E_DBUS_LOG_DBG("-----------------");
+  DBG("-----------------");
 
   return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
@@ -419,13 +419,13 @@ e_dbus_idler(void *data)
 
   if (DBUS_DISPATCH_COMPLETE == dbus_connection_get_dispatch_status(cd->conn))
   {
-    E_DBUS_LOG_DBG("done dispatching!");
+    DBG("done dispatching!");
     cd->idler = NULL;
     return 0;
   }
   e_dbus_idler_active++;
   dbus_connection_ref(cd->conn);
-  E_DBUS_LOG_DBG("dispatch!");
+  DBG("dispatch!");
   dbus_connection_dispatch(cd->conn);
   dbus_connection_unref(cd->conn);
   e_dbus_idler_active--;
@@ -466,7 +466,7 @@ e_dbus_bus_get(DBusBusType type)
   conn = dbus_bus_get_private(type, &err);
   if (dbus_error_is_set(&err))
   {
-    E_DBUS_LOG_ERR("Error connecting to bus: %s", err.message);
+    ERR("Error connecting to bus: %s", err.message);
     dbus_error_free(&err);
     return NULL;
   }
@@ -474,7 +474,7 @@ e_dbus_bus_get(DBusBusType type)
   econn = e_dbus_connection_setup(conn);
   if (!econn)
   {
-    E_DBUS_LOG_ERR("Error setting up dbus connection.");
+    ERR("Error setting up dbus connection.");
     dbus_connection_close(conn);
     dbus_connection_unref(conn);
     return NULL;
@@ -539,7 +539,7 @@ e_dbus_connection_setup(DBusConnection *conn)
 EAPI void
 e_dbus_connection_close(E_DBus_Connection *conn)
 {
-  E_DBUS_LOG_DBG("e_dbus_connection_close");
+  DBG("e_dbus_connection_close");
 
   if (e_dbus_idler_active)
   {
@@ -606,12 +606,11 @@ e_dbus_init(void)
       fprintf(stderr,"E-dbus: Enable to initialize the eina module");
       return -1;
     }
-  
- _E_DBUS_LOG_DOM_GLOBAL = eina_log_domain_register("e_dbus",E_DBUS_COLOR_DEFAULT);
 
-  if(_E_DBUS_LOG_DOM_GLOBAL < 0)
+  _e_dbus_log_dom = eina_log_domain_register("e_dbus",E_DBUS_COLOR_DEFAULT);
+  if(_e_dbus_log_dom < 0)
     {
-      EINA_LOG_ERR("E-dbus: Enable to create a log domain\n");
+      EINA_LOG_ERR("Enable to create a 'e_dbus' log domain");
       eina_shutdown();
       return -1;
     }
@@ -629,7 +628,8 @@ e_dbus_shutdown(void)
 {
   if (--init) return init;
   e_dbus_object_shutdown();
-  eina_log_domain_unregister(_E_DBUS_LOG_DOM_GLOBAL);
+  eina_log_domain_unregister(_e_dbus_log_dom);
+  _e_dbus_log_dom = -1;
   eina_shutdown();
   return init;
 }
index 94476c3..1da46e9 100644 (file)
@@ -16,7 +16,7 @@ _dbus_peer_call(E_DBus_Connection *conn, const char *method_name, const char *de
     (destination, path, "org.freedesktop.DBus.Peer", method_name);
   if (!msg)
     {
-      E_DBUS_LOG_ERR("E-dbus Error: failed to create message for method call: %s() at "
+      ERR("E-dbus Error: failed to create message for method call: %s() at "
            "\"%s\" at \"%s\"",
            method_name, destination, path);
        return NULL;
@@ -26,7 +26,7 @@ _dbus_peer_call(E_DBus_Connection *conn, const char *method_name, const char *de
   dbus_message_unref(msg);
 
   if (!ret)
-    E_DBUS_LOG_ERR("E-dbus Error: could not %s() \"%s\" at \"%s\".",
+    ERR("E-dbus Error: could not %s() \"%s\" at \"%s\".",
          method_name, destination, path);
   
   return ret;
@@ -69,7 +69,7 @@ _dbus_message_property_method_call(E_DBus_Connection *conn, const char *method_n
 
   if (!conn)
     {
-      E_DBUS_LOG_ERR("E-dbus Error: no connection for call of %s", method_name);
+      ERR("E-dbus Error: no connection for call of %s", method_name);
        return NULL;
     }
 
@@ -77,7 +77,7 @@ _dbus_message_property_method_call(E_DBus_Connection *conn, const char *method_n
     (destination, path, "org.freedesktop.DBus.Properties", method_name);
   if (!msg)
     {
-      E_DBUS_LOG_ERR("E-dbus Error: failed to create message for method call: %s() at "
+      ERR("E-dbus Error: failed to create message for method call: %s() at "
            "\"%s\" at \"%s\"",
            method_name, destination, path);
       return NULL;
@@ -110,7 +110,7 @@ e_dbus_properties_get_all(E_DBus_Connection *conn, const char *destination, cons
   dbus_message_unref(msg);
 
   if (!ret)
-    E_DBUS_LOG_ERR("ERROR: failed to call GetAll() at \"%s\" at \"%s\"",
+    ERR("ERROR: failed to call GetAll() at \"%s\" at \"%s\"",
          destination, path);
 
   return ret;
@@ -141,7 +141,7 @@ e_dbus_properties_get(E_DBus_Connection *conn, const char *destination, const ch
   dbus_message_unref(msg);
 
   if (!ret)
-    E_DBUS_LOG_ERR("E-dbus Error: failed to call Get() at \"%s\" at \"%s\"",
+    ERR("E-dbus Error: failed to call Get() at \"%s\" at \"%s\"",
          destination, path);
 
   return ret;
@@ -197,7 +197,7 @@ e_dbus_properties_set(E_DBus_Connection *conn, const char *destination, const ch
   dbus_message_unref(msg);
 
   if (!ret)
-    E_DBUS_LOG_ERR("E-dbus Error: failed to call Set() at \"%s\" at \"%s\"",
+    ERR("E-dbus Error: failed to call Set() at \"%s\" at \"%s\"",
          destination, path);
 
   return ret;
index 1afb702..d011ee0 100644 (file)
@@ -18,7 +18,7 @@ cb_pending(DBusPendingCall *pending, void *user_data)
 
   if (!dbus_pending_call_get_completed(pending))
   {
-    E_DBUS_LOG_INFO("E-dbus: NOT COMPLETED");
+    INFO("E-dbus: NOT COMPLETED");
     free(data);
     dbus_message_unref(msg);
     dbus_pending_call_unref(pending);
index 4e67c9e..71250b6 100644 (file)
@@ -10,7 +10,7 @@ _dbus_message_method_call(const char *method_name)
      ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus",
       method_name);
    if (!msg)
-     E_DBUS_LOG_ERR("E-dbus Error: failed to create message for method call: %s",
+     ERR("E-dbus Error: failed to create message for method call: %s",
           method_name);
    return msg;
 }
@@ -23,7 +23,7 @@ _dbus_call__void(E_DBus_Connection *conn, const const char *method_name, E_DBus_
 
   if (!conn)
     {
-      E_DBUS_LOG_ERR("E.dbus Error: no connection for call of %s", method_name);
+      ERR("E.dbus Error: no connection for call of %s", method_name);
       return NULL;
     }
   
@@ -34,7 +34,7 @@ _dbus_call__void(E_DBus_Connection *conn, const const char *method_name, E_DBus_
   dbus_message_unref(msg);
 
   if (!ret)
-    E_DBUS_LOG_ERR("E-dbus Error: failed to call %s()", method_name);
+    ERR("E-dbus Error: failed to call %s()", method_name);
 
   return ret;
 }
@@ -47,7 +47,7 @@ _dbus_call__str(E_DBus_Connection *conn, const const char *method_name, const ch
 
   if (!conn)
     {
-      E_DBUS_LOG_ERR("E-dbus Error: no connection for call of %s", method_name);
+      ERR("E-dbus Error: no connection for call of %s", method_name);
        return NULL;
     }
 
@@ -59,7 +59,7 @@ _dbus_call__str(E_DBus_Connection *conn, const const char *method_name, const ch
   dbus_message_unref(msg);
 
   if (!ret)
-    E_DBUS_LOG_ERR("E-dbus Error: failed to call %s(\"%s\")", method_name, str);
+    ERR("E-dbus Error: failed to call %s(\"%s\")", method_name, str);
   
   return ret;
 }
@@ -73,7 +73,7 @@ e_dbus_request_name(E_DBus_Connection *conn, const char *name, unsigned int flag
 
   if (!conn)
     {
-       E_DBUS_LOG_ERR("E-dbus Error: no connection for call of RequestName");
+       ERR("E-dbus Error: no connection for call of RequestName");
        return NULL;
     }
 
@@ -130,7 +130,7 @@ e_dbus_start_service_by_name(E_DBus_Connection *conn, const char *name, unsigned
 
    if (!conn)
      {
-       E_DBUS_LOG_ERR("ERROR: no connection for call of %s", method_name);
+       ERR("ERROR: no connection for call of %s", method_name);
        return NULL;
      }
 
@@ -145,7 +145,7 @@ e_dbus_start_service_by_name(E_DBus_Connection *conn, const char *name, unsigned
    dbus_message_unref(msg);
 
    if (!ret)
-     E_DBUS_LOG_ERR("E-dbus Error: failed to call %s(\"%s\")", method_name, name);
+     ERR("E-dbus Error: failed to call %s(\"%s\")", method_name, name);
 
    return ret;
 }
index 4b561e7..102b141 100644 (file)
@@ -250,7 +250,7 @@ e_dbus_object_free(E_DBus_Object *obj)
 
   if (!obj) return;
 
-  E_DBUS_LOG_DBG("e_dbus_object_free (%s)", obj->path);
+  DBG("e_dbus_object_free (%s)", obj->path);
   dbus_connection_unregister_object_path(obj->conn->conn, obj->path);
   e_dbus_connection_close(obj->conn);
 
@@ -331,7 +331,7 @@ e_dbus_object_interface_attach(E_DBus_Object *obj, E_DBus_Interface *iface)
   e_dbus_interface_ref(iface);
   obj->interfaces = eina_list_append(obj->interfaces, iface);
   obj->introspection_dirty = 1;
-  E_DBUS_LOG_DBG("e_dbus_object_interface_attach (%s, %s) ", obj->path, iface->name);
+  DBG("e_dbus_object_interface_attach (%s, %s) ", obj->path, iface->name);
 }
 
 EAPI void
@@ -339,7 +339,7 @@ e_dbus_object_interface_detach(E_DBus_Object *obj, E_DBus_Interface *iface)
 {
   E_DBus_Interface *found;
 
-  E_DBUS_LOG_DBG("e_dbus_object_interface_detach (%s, %s) ", obj->path, iface->name);
+  DBG("e_dbus_object_interface_detach (%s, %s) ", obj->path, iface->name);
   found = eina_list_data_find(obj->interfaces, iface);
   if (found == NULL) return;
 
@@ -352,13 +352,13 @@ EAPI void
 e_dbus_interface_ref(E_DBus_Interface *iface)
 {
   iface->refcount++;
-  E_DBUS_LOG_DBG("e_dbus_interface_ref (%s) = %d", iface->name, iface->refcount);
+  DBG("e_dbus_interface_ref (%s) = %d", iface->name, iface->refcount);
 }
 
 EAPI void
 e_dbus_interface_unref(E_DBus_Interface *iface)
 {
-  E_DBUS_LOG_DBG("e_dbus_interface_unref (%s) = %d", iface->name, iface->refcount - 1);
+  DBG("e_dbus_interface_unref (%s) = %d", iface->name, iface->refcount - 1);
   if (--(iface->refcount) == 0)
     e_dbus_interface_free(iface);
 }
@@ -396,7 +396,7 @@ e_dbus_interface_method_add(E_DBus_Interface *iface, const char *member, const c
   E_DBus_Method *m;
 
   m = e_dbus_method_new(member, signature, reply_signature, func);
-  E_DBUS_LOG_DBG("E-dbus: Add method %s: %p", member, m);
+  DBG("E-dbus: Add method %s: %p", member, m);
   if (!m) return 0;
 
   iface->methods = eina_list_append(iface->methods, m);
@@ -418,7 +418,7 @@ e_dbus_interface_signal_add(E_DBus_Interface *iface, const char *name, const cha
   E_DBus_Signal *s;
 
   s = e_dbus_signal_new(name, signature);
-  E_DBUS_LOG_DBG("E-dbus: Add signal %s: %p", name, s);
+  DBG("E-dbus: Add signal %s: %p", name, s);
   if (!s) return 0;
 
   iface->signals = eina_list_append(iface->signals, s);
@@ -605,7 +605,7 @@ _introspect_interface_append(Ecore_Strbuf *buf, E_DBus_Interface *iface, int lev
   ecore_strbuf_append(buf, "\">\n");
   level++;
 
-  E_DBUS_LOG_DBG("introspect iface: %s", iface->name);
+  DBG("introspect iface: %s", iface->name);
   EINA_LIST_FOREACH(iface->methods, l, method)
     _introspect_method_append(buf, method, level);
   EINA_LIST_FOREACH(iface->signals, l, signal)
@@ -622,7 +622,7 @@ _introspect_method_append(Ecore_Strbuf *buf, E_DBus_Method *method, int level)
   char *type;
 
   _introspect_indent_append(buf, level);
-  E_DBUS_LOG_DBG("introspect method: %s\n", method->member);
+  DBG("introspect method: %s\n", method->member);
   ecore_strbuf_append(buf, "<method name=\"");
   ecore_strbuf_append(buf, method->member);
   ecore_strbuf_append(buf, "\">\n");
@@ -670,7 +670,7 @@ _introspect_signal_append(Ecore_Strbuf *buf, E_DBus_Signal *signal, int level)
   char *type;
 
   _introspect_indent_append(buf, level);
-  E_DBUS_LOG_DBG("introspect signal: %s", signal->name);
+  DBG("introspect signal: %s", signal->name);
   ecore_strbuf_append(buf, "<signal name=\"");
   ecore_strbuf_append(buf, signal->name);
   ecore_strbuf_append(buf, "\">\n");
index 374ad89..18fcae9 100644 (file)
@@ -5,12 +5,14 @@
 #include "Ecore_Data.h"
 #include "eina_log.h"
 
-#define E_DBUS_COLOR_DEFAULT "\033[36m"
-extern int _E_DBUS_LOG_DOM_GLOBAL ;
-#define E_DBUS_LOG_DBG(...)   EINA_LOG_DOM_DBG(_E_DBUS_LOG_DOM_GLOBAL , __VA_ARGS__)
-#define E_DBUS_LOG_INFO(...)    EINA_LOG_DOM_INFO(_E_DBUS_LOG_DOM_GLOBAL , __VA_ARGS__)
-#define E_DBUS_LOG_WARN(...) EINA_LOG_DOM_WARN(_E_DBUS_LOG_DOM_GLOBAL , __VA_ARGS__)
-#define E_DBUS_LOG_ERR(...)   EINA_LOG_DOM_ERR(_E_DBUS_LOG_DOM_GLOBAL , __VA_ARGS__)
+#ifndef E_DBUS_COLOR_DEFAULT
+#define E_DBUS_COLOR_DEFAULT EINA_COLOR_CYAN
+#endif
+extern int _e_dbus_log_dom;
+#define DBG(...)   EINA_LOG_DOM_DBG(_e_dbus_log_dom, __VA_ARGS__)
+#define INFO(...)    EINA_LOG_DOM_INFO(_e_dbus_log_dom, __VA_ARGS__)
+#define WARN(...) EINA_LOG_DOM_WARN(_e_dbus_log_dom, __VA_ARGS__)
+#define ERR(...)   EINA_LOG_DOM_ERR(_e_dbus_log_dom, __VA_ARGS__)
 
 
 struct E_DBus_Connection
index d87f1af..fe3cc34 100644 (file)
@@ -69,7 +69,7 @@ cb_name_owner(void *data, DBusMessage *msg, DBusError *err)
 
  error:
   if (err)
-    E_DBUS_LOG_ERR("Error: %s %s", err->name, err->message);
+    ERR("Error: %s %s", err->name, err->message);
 /* FIXME: this is bad. the handler gets silently freed and the caller has no
  * idea that it was freed - or if, or when.
   conn->signal_handlers = eina_list_remove(conn->signal_handlers, sh);
@@ -86,7 +86,7 @@ _match_append(char *buf, int size, int *used, const char *keyword, int keyword_s
 
    if (*used + keyword_size + value_size + sizeof(",=''") >= size)
      {
-       E_DBUS_LOG_ERR("cannot add match %s='%s': too long!", keyword, value);
+       ERR("cannot add match %s='%s': too long!", keyword, value);
        return 0;
      }
 
@@ -156,7 +156,7 @@ e_dbus_signal_handler_add(E_DBus_Connection *conn, const char *sender, const cha
   sh = malloc(sizeof(*sh) + len);
   if (!sh)
     {
-       E_DBUS_LOG_ERR("could not allocate signal handler.");
+       ERR("could not allocate signal handler.");
        return NULL;
     }
 
index 4e124a2..bdb3410 100644 (file)
@@ -104,6 +104,9 @@ typedef struct E_Hal_Capability E_Hal_Manager_New_Capability;
 extern "C" {
 #endif
 
+   EAPI int e_hal_init(void);
+   EAPI int e_hal_shutdown(void);
+
 /* org.freedesktop.Hal.Device */
    EAPI DBusPendingCall *e_hal_device_get_property(E_DBus_Connection *conn, const char *udi, const char *property, E_DBus_Callback_Func cb_func, void *data);
    EAPI DBusPendingCall *e_hal_device_get_all_properties(E_DBus_Connection *conn, const char *udi, E_DBus_Callback_Func cb_func, void *data);
index 4727b39..14f3f28 100644 (file)
@@ -9,11 +9,14 @@ if BUILD_EHAL
 lib_LTLIBRARIES = libehal.la
 include_HEADERS = E_Hal.h
 
+noinst_HEADERS = e_hal_private.h
+
 libehal_la_SOURCES = \
 E_Hal.h \
 e_hal_device.c  \
 e_hal_manager.c \
-e_hal_util.c 
+e_hal_util.c \
+e_hal_main.c
 
 libehal_la_LIBADD = \
 @EDBUS_LIBS@ \
index 7d0460c..bfb3c4d 100644 (file)
@@ -1,5 +1,5 @@
 #include <E_Hal.h>
-#include <e_dbus_private.h>
+#include "e_hal_private.h"
 
 #define e_hal_device_call_new(udi, member) dbus_message_new_method_call(E_HAL_SENDER, udi, E_HAL_DEVICE_INTERFACE, member)
 #define e_hal_device_volume_call_new(udi, member) dbus_message_new_method_call(E_HAL_SENDER, udi, E_HAL_DEVICE_VOLUME_INTERFACE, member)
@@ -140,7 +140,7 @@ unmarshal_device_get_all_properties(DBusMessage *msg, DBusError *err)
         }
         break;
       default:
-        E_DBUS_LOG_WARN("Ehal Error: unexpected property type (%s): %c", name, dbus_message_iter_get_arg_type(&v_iter));
+        WARN("Ehal Error: unexpected property type (%s): %c", name, dbus_message_iter_get_arg_type(&v_iter));
         break;
     }
     eina_hash_add(ret->properties, name, prop);
diff --git a/src/lib/hal/e_hal_main.c b/src/lib/hal/e_hal_main.c
new file mode 100644 (file)
index 0000000..6d2bf44
--- /dev/null
@@ -0,0 +1,55 @@
+#include <E_Hal.h>
+#include "e_hal_private.h"
+
+int _e_dbus_hal_log_dom = -1;
+int _e_dbus_hal_init_count = 0;
+
+EAPI int
+e_hal_init(void)
+{
+   if (_e_dbus_hal_init_count)
+     return ++_e_dbus_hal_init_count;
+
+   if (!eina_init())
+     return 0;
+
+   _e_dbus_hal_log_dom = eina_log_domain_register
+     ("e_hal", E_DBUS_COLOR_DEFAULT);
+   if (_e_dbus_hal_log_dom < 0)
+     {
+       EINA_LOG_ERR("Could not register 'e_hal' log domain.");
+       goto error_log_domain;
+       return 0;
+     }
+
+   if (!e_dbus_init()) {
+      ERR("Could not initialize E_DBus.");
+      goto error_e_dbus;
+   }
+
+   _e_dbus_hal_init_count = 1;
+   return 1;
+
+ error_e_dbus:
+   eina_log_domain_unregister(_e_dbus_hal_log_dom);
+   _e_dbus_hal_log_dom = -1;
+ error_log_domain:
+   eina_shutdown();
+   return 0;
+}
+
+EAPI int
+e_hal_shutdown(void)
+{
+   _e_dbus_hal_init_count--;
+   if (_e_dbus_hal_init_count)
+     return _e_dbus_hal_init_count;
+
+   e_dbus_shutdown();
+
+   eina_log_domain_unregister(_e_dbus_hal_log_dom);
+   _e_dbus_hal_log_dom = -1;
+   eina_shutdown();
+
+   return 0;
+}
index 891412b..935bb99 100644 (file)
@@ -1,4 +1,5 @@
 #include "E_Hal.h"
+#include "e_hal_private.h"
 
 #define e_hal_manager_call_new(member) dbus_message_new_method_call(E_HAL_SENDER, E_HAL_MANAGER_PATH, E_HAL_MANAGER_INTERFACE, member)
 
diff --git a/src/lib/hal/e_hal_private.h b/src/lib/hal/e_hal_private.h
new file mode 100644 (file)
index 0000000..1190714
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef E_HAL_PRIVATE_H
+#define E_HAL_PRIVATE_H
+
+#ifndef E_DBUS_COLOR_DEFAULT
+#define E_DBUS_COLOR_DEFAULT EINA_COLOR_CYAN
+#endif
+extern int _e_dbus_hal_log_dom;
+#ifdef ERR
+#undef ERR
+#endif
+#ifdef INF
+#undef INF
+#endif
+#ifdef WARN
+#undef WARN
+#endif
+#ifdef DBG
+#undef DBG
+#endif
+
+#define DBG(...)   EINA_LOG_DOM_DBG(_e_dbus_hal_log_dom, __VA_ARGS__)
+#define INFO(...)    EINA_LOG_DOM_INFO(_e_dbus_hal_log_dom, __VA_ARGS__)
+#define WARN(...) EINA_LOG_DOM_WARN(_e_dbus_hal_log_dom, __VA_ARGS__)
+#define ERR(...)   EINA_LOG_DOM_ERR(_e_dbus_hal_log_dom, __VA_ARGS__)
+
+#endif
index ad89bad..a79003e 100644 (file)
@@ -1,5 +1,6 @@
 #include <E_Hal.h>
 #include <string.h>
+#include "e_hal_private.h"
 
 /**
  * @internal
index b30c498..1f55004 100644 (file)
@@ -9,6 +9,8 @@ if BUILD_ENOTIFY
 lib_LTLIBRARIES = libenotify.la
 include_HEADERS = E_Notify.h E_Notification_Daemon.h
 
+noinst_HEADERS = e_notify_private.h
+
 libenotify_la_SOURCES = \
 E_Notify.h \
 E_Notification_Daemon.h \
index 528df8e..61aeffd 100644 (file)
@@ -1,6 +1,5 @@
 #include "E_Notify.h"
 #include "e_notify_private.h"
-#include "e_dbus_private.h"
 
 static E_DBus_Connection *client_conn;
 static int init_count = 0;
@@ -23,7 +22,7 @@ e_notification_init(void)
   
   if(_e_dbus_notification_log_dom < 0)
     {
-      E_DBUS_LOG_ERR("E-Dbus-notification Error: Impossible to create e_dbus_motification domain");
+      ERR("E-Dbus-notification Error: Impossible to create e_dbus_motification domain");
       e_dbus_shutdown();
       return 0;
     }
index 01afdb4..fd82524 100644 (file)
@@ -1,7 +1,6 @@
 #include "E_Notify.h"
 #include "E_Notification_Daemon.h"
 #include "e_notify_private.h"
-#include "e_dbus_private.h"
 #include <string.h>
 
 static int e_notification_daemon_bus_init(E_Notification_Daemon *daemon);
index e4562af..3c6efb7 100644 (file)
@@ -43,16 +43,29 @@ void e_notify_marshal_hint_image(DBusMessageIter *iter, E_Notification_Image *im
 E_Notification_Image * e_notify_unmarshal_hint_image(DBusMessageIter *iter);
 
 
-extern int _e_dbus_notification_log_dom ;
+#ifndef E_DBUS_COLOR_DEFAULT
+#define E_DBUS_COLOR_DEFAULT EINA_COLOR_CYAN
+#endif
+extern int _e_dbus_notification_log_dom;
+
+#ifdef ERR
 #undef ERR
+#endif
+#ifdef INF
 #undef INF
+#endif
+#ifdef WARN
 #undef WARN
+#endif
+#ifdef DBG
 #undef DBG
+#endif
+
+#define DBG(...)   EINA_LOG_DOM_DBG(_e_dbus_notification_log_dom, __VA_ARGS__)
+#define INFO(...)    EINA_LOG_DOM_INFO(_e_dbus_notification_log_dom, __VA_ARGS__)
+#define WARN(...) EINA_LOG_DOM_WARN(_e_dbus_notification_log_dom, __VA_ARGS__)
+#define ERR(...)   EINA_LOG_DOM_ERR(_e_dbus_notification_log_dom, __VA_ARGS__)
 
-#define DBG(...)   EINA_LOG_DOM_DBG(_e_dbus_notification_log_dom , __VA_ARGS__)
-#define INFO(...)    EINA_LOG_DOM_INFO(_e_dbus_notification_log_dom , __VA_ARGS__)
-#define WARN(...) EINA_LOG_DOM_WARN(_e_dbus_notification_log_dom , __VA_ARGS__)
-#define ERR(...)   EINA_LOG_DOM_ERR(_e_dbus_notification_log_dom , __VA_ARGS__)
 
 struct E_Notification_Image
 {