fix notification's critical warning, cleanup logging and daemon.
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 1 May 2010 20:06:56 +0000 (20:06 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 1 May 2010 20:06:56 +0000 (20:06 +0000)
 * daemon now must be initialized, as it is independent from client;

 * client and daemon now have separate logging, actually just daemon
   have it now;

 * update gadget to use daemon_init call.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/e_dbus@48520 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/notification/E_Notification_Daemon.h
src/lib/notification/client.c
src/lib/notification/daemon.c
src/lib/notification/e_notify_private.h

index 5a4a113..9285373 100644 (file)
@@ -59,6 +59,9 @@ struct E_Notification_Daemon
 extern "C" {
 #endif
 
+  EAPI int e_notification_daemon_init(void);
+  EAPI int e_notification_daemon_shutdown(void);
+
 /* daemon */
    EAPI E_Notification_Daemon *e_notification_daemon_add(const char *name, const char *vendor);
    EAPI void e_notification_daemon_free(E_Notification_Daemon *d);
index 61aeffd..d2cc2d6 100644 (file)
@@ -3,7 +3,6 @@
 
 static E_DBus_Connection *client_conn;
 static int init_count = 0;
-int _e_dbus_notification_log_dom = -1;
 
 EAPI int
 e_notification_init(void)
@@ -17,15 +16,6 @@ e_notification_init(void)
     e_dbus_shutdown();
     return 0;
   }
-  
-  _e_dbus_notification_log_dom = eina_log_domain_register("e_dbus_notification",E_DBUS_COLOR_DEFAULT);
-  
-  if(_e_dbus_notification_log_dom < 0)
-    {
-      ERR("E-Dbus-notification Error: Impossible to create e_dbus_motification domain");
-      e_dbus_shutdown();
-      return 0;
-    }
 
   return ++init_count;
 }
@@ -34,7 +24,6 @@ EAPI int
 e_notification_shutdown(void)
 {
   if (--init_count) return init_count;
-  eina_log_domain_unregister(_e_dbus_notification_log_dom);
   e_dbus_connection_close(client_conn);
   client_conn = NULL;
   e_dbus_shutdown();
index 4278b6c..2e4127b 100644 (file)
@@ -7,6 +7,15 @@
 #include "e_notify_private.h"
 #include <string.h>
 
+#define DBG(...)   EINA_LOG_DOM_DBG(log_dom, __VA_ARGS__)
+#define INF(...)   EINA_LOG_DOM_INFO(log_dom, __VA_ARGS__)
+#define WRN(...)   EINA_LOG_DOM_WARN(log_dom, __VA_ARGS__)
+#define ERR(...)   EINA_LOG_DOM_ERR(log_dom, __VA_ARGS__)
+#define CRIT(...)  EINA_LOG_DOM_CRITICAL(log_dom, __VA_ARGS__)
+static int log_dom = -1;
+static int init_count = 0;
+static E_DBus_Interface *daemon_iface = NULL;
+
 static int e_notification_daemon_bus_init(E_Notification_Daemon *daemon);
 static int e_notification_daemon_object_init(E_Notification_Daemon *daemon);
 
@@ -65,13 +74,39 @@ method_get_server_information(E_DBus_Object *obj, DBusMessage *message)
 
 /**** daemon api ****/
 
+EAPI int
+e_notification_daemon_init(void)
+{
+   if (init_count) return ++init_count;
+   if (!e_dbus_init()) return 0;
+   log_dom = eina_log_domain_register
+     ("e_dbus_notification_daemon", E_DBUS_COLOR_DEFAULT);
+   if(log_dom < 0)
+     {
+       ERR("Impossible to create e_dbus_notification_daemon domain");
+       e_dbus_shutdown();
+       return 0;
+     }
+
+   daemon_iface = e_dbus_interface_new(E_NOTIFICATION_INTERFACE);
+
+   return ++init_count;
+}
+
+EAPI int
+e_notification_daemon_shutdown(void)
+{
+   if (--init_count) return init_count;
+   eina_log_domain_unregister(log_dom);
+   e_dbus_shutdown();
+   return 0;
+}
 
 EAPI E_Notification_Daemon *
 e_notification_daemon_add(const char *name, const char *vendor)
 {
   E_Notification_Daemon *daemon;
 
-  if (!e_dbus_init()) return NULL;
   daemon = calloc(1, sizeof(E_Notification_Daemon));
   if (daemon)
     e_notification_daemon_bus_init(daemon);
@@ -86,7 +121,8 @@ e_notification_daemon_add(const char *name, const char *vendor)
   daemon->name = strdup(name);
   daemon->vendor = strdup(vendor);
 
-  daemon->iface = e_dbus_interface_new(E_NOTIFICATION_INTERFACE);
+  e_dbus_interface_ref(daemon_iface);
+  daemon->iface = daemon_iface;
   e_dbus_interface_method_add(daemon->iface, "GetCapabilities", "", "as", method_get_capabilities);
   e_dbus_interface_method_add(daemon->iface, "Notify", "susssasa{sv}i", "u", method_notify);
   e_dbus_interface_method_add(daemon->iface, "CloseNotification", "u", "u", method_close_notification);
@@ -110,7 +146,6 @@ e_notification_daemon_free(E_Notification_Daemon *daemon)
   if (daemon->vendor) free(daemon->vendor);
   if (daemon->iface) e_dbus_interface_unref(daemon->iface);
   free(daemon);
-  e_dbus_shutdown();
 }
 
 EAPI void
@@ -147,17 +182,19 @@ cb_request_name(void *data, DBusMessage *msg, DBusError *err)
 
   if (dbus_error_is_set(err))
   {
-    ERR("E-dbus-notification Error (request_name): %s", err->message);
+    ERR("request_name: %s", err->message);
     dbus_error_free(err);
     return;
   }
 
-  INFO("E-dbus-notification received response with signature: '%s'", dbus_message_get_signature(msg));
+  INF("received response with signature: '%s'",
+      dbus_message_get_signature(msg));
   dbus_error_init(&new_err);
-  dbus_message_get_args(msg, &new_err, DBUS_TYPE_UINT32, &ret, DBUS_TYPE_INVALID);
+  dbus_message_get_args
+    (msg, &new_err, DBUS_TYPE_UINT32, &ret, DBUS_TYPE_INVALID);
   if (dbus_error_is_set(&new_err))
   {
-    ERR("E-dbus-notification Error (req name unmarshal): %s", new_err.message);
+    ERR("req name unmarshal: %s", new_err.message);
     dbus_error_free(&new_err);
     return;
   }
index 3c6efb7..250f6d5 100644 (file)
@@ -46,26 +46,6 @@ E_Notification_Image * e_notify_unmarshal_hint_image(DBusMessageIter *iter);
 #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__)
-
 
 struct E_Notification_Image
 {