#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);
/**** 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);
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);
if (daemon->vendor) free(daemon->vendor);
if (daemon->iface) e_dbus_interface_unref(daemon->iface);
free(daemon);
- e_dbus_shutdown();
}
EAPI void
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;
}