summaryrefslogtreecommitdiff
path: root/src/lib/elementary/elm_sys_notify.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/elementary/elm_sys_notify.c')
-rw-r--r--src/lib/elementary/elm_sys_notify.c75
1 files changed, 56 insertions, 19 deletions
diff --git a/src/lib/elementary/elm_sys_notify.c b/src/lib/elementary/elm_sys_notify.c
index c58659a1a3..3fe67396b8 100644
--- a/src/lib/elementary/elm_sys_notify.c
+++ b/src/lib/elementary/elm_sys_notify.c
@@ -9,6 +9,9 @@
#include "elm_sys_notify_dbus.eo.h"
#include "elm_sys_notify_dbus.eo.legacy.h"
+#include "elm_sys_notify_cocoa.eo.h"
+#include "elm_sys_notify_cocoa.eo.legacy.h"
+
#define MY_CLASS ELM_SYS_NOTIFY_CLASS
#define MY_CLASS_NAME "Elm_Sys_Notify"
@@ -19,36 +22,44 @@ EAPI int ELM_EVENT_SYS_NOTIFY_ACTION_INVOKED = 0;
typedef const Eo_Class *(*Class_Get_Func)(void);
+typedef struct
+{
+ const char *name;
+ Class_Get_Func func;
+} Sys_Notify;
+
static Elm_Sys_Notify *_singleton = NULL;
/*
* Registration of notification servers is done UNIQUELY
* in the two structures below.
* 1) ALWAYS add a SRV_XXX before __SRV_LAST
- * 2) copy the #if ... #else ... #endif with the appropriate class
- * getter (generated by Eolian) or NULL when unsupported
+ * 2) add the appropriate class getter (generated by Eolian)
*
- * The rest of the code relies on the Srv enum and _class_getters
- * to register/unregister notification servers.
+ * The rest of the code relies on the Srv enum and _sys_notify
+ * to register/unregister notification servers, as well
+ * as the ELM_SYS_NOTIFY_SERVER environment variable
*/
typedef enum
{
SRV_DBUS = 0,
+ SRV_COCOA,
__SRV_LAST /* Sentinel */
} Srv;
-static Class_Get_Func _class_getters[__SRV_LAST] =
+static const Sys_Notify _sys_notify[__SRV_LAST] =
{
-#ifdef ELM_SYS_NOTIFY_DBUS_CLASS
- [SRV_DBUS] = elm_sys_notify_dbus_class_get
-#else
- [SRV_DBUS] = NULL
-#endif
+ [SRV_DBUS] = {
+ .name = "dbus",
+ .func = elm_sys_notify_dbus_class_get,
+ },
+ [SRV_COCOA] = {
+ .name = "cocoa",
+ .func = elm_sys_notify_cocoa_class_get,
+ },
};
-
-
typedef struct
{
Eo *servers[__SRV_LAST];
@@ -104,7 +115,9 @@ _elm_sys_notify_elm_sys_notify_interface_send(const Eo *obj EINA_UNUSED,
/* Propagate to all registered servers */
for (i = SRV_DBUS; i < __SRV_LAST; ++i)
if (sd->servers[i])
- elm_obj_sys_notify_interface_send(sd->servers[i], replaces_id, icon, summary, body, urgency, timeout, cb, cb_data);
+ elm_obj_sys_notify_interface_send(sd->servers[i], replaces_id, icon,
+ summary, body, urgency, timeout,
+ cb, cb_data);
}
EOLIAN static void
@@ -119,7 +132,8 @@ _elm_sys_notify_elm_sys_notify_interface_simple_send(const Eo *obj EINA_UNUSED,
/* Propagate to all registered servers */
for (i = SRV_DBUS; i < __SRV_LAST; ++i)
if (sd->servers[i])
- elm_obj_sys_notify_interface_simple_send(sd->servers[i], icon, summary, body);
+ elm_obj_sys_notify_interface_simple_send(sd->servers[i],
+ icon, summary, body);
}
EOLIAN static void
@@ -141,7 +155,7 @@ _elm_sys_notify_elm_sys_notify_interface_close(const Eo *obj EINA_UNUSED,
*============================================================================*/
EOLIAN static Eina_Bool
-_elm_sys_notify_servers_set(Eo *obj EINA_UNUSED,
+_elm_sys_notify_servers_set(Eo *obj EINA_UNUSED,
Elm_Sys_Notify_Data *sd,
Elm_Sys_Notify_Server servers)
{
@@ -162,7 +176,7 @@ _elm_sys_notify_servers_set(Eo *obj EINA_UNUSED,
/* If server is required, create when nonexistant */
if (servers & (1 << i))
{
- class_get = _class_getters[i];
+ class_get = _sys_notify[i].func;
if (!class_get)
{
CRI("Unsupported notification server");
@@ -170,6 +184,7 @@ _elm_sys_notify_servers_set(Eo *obj EINA_UNUSED,
}
sd->servers[i] = eo_add(class_get(), NULL);
+ printf("--> cocoa added\n");
if (EINA_UNLIKELY(!(sd->servers[i])))
{
CRI("Failed to create notification server");
@@ -233,6 +248,7 @@ elm_need_sys_notify(void)
Elm_Sys_Notify_Server servers = ELM_SYS_NOTIFY_SERVER_NONE;
Elm_Sys_Notify *manager;
Srv i;
+ const char *env;
/* In theory, there can be N notification managers, but
* in the implementation there will be only one: the
@@ -253,10 +269,29 @@ elm_need_sys_notify(void)
return EINA_FALSE;
}
+ /* Environment will override the default choice */
+ env = getenv("ELM_SYS_NOTIFY_SERVER");
+
/* Register available notification servers */
for (i = SRV_DBUS; i < __SRV_LAST; ++i)
- if (_class_getters[i])
- servers |= (1 << i);
+ {
+ if (env)
+ {
+ /*
+ * When env is specified, select the matching server only
+ */
+ if (!strcmp(env, _sys_notify[i].name))
+ {
+ servers |= (1 << i);
+ printf("--> Found %s\n", env);
+ break;
+ }
+ }
+ else
+ {
+ servers |= (1 << i);
+ }
+ }
/* If no server are available, don't even bother... */
if (servers == ELM_SYS_NOTIFY_SERVER_NONE)
@@ -275,7 +310,9 @@ elm_sys_notify_send(unsigned int replaces_id,
Elm_Sys_Notify_Send_Cb cb,
const void *cb_data)
{
- elm_obj_sys_notify_interface_send(_singleton, replaces_id, icon, summary, body, urgency, timeout, cb, cb_data);
+ elm_obj_sys_notify_interface_send(_singleton, replaces_id, icon,
+ summary, body, urgency, timeout,
+ cb, cb_data);
}
EAPI void