24
24
#include "common.h"
28
27
#include "notification/notification.h"
30
static GSList *notificationPlugins = NULL;
32
typedef notificationPluginPtr (*infoFunc)();
35
notification_plugin_register (pluginPtr plugin, GModule *handle)
37
notificationPluginPtr notificationPlugin = NULL;
38
infoFunc notification_plugin_get_info;
40
if (g_module_symbol (handle, "notification_plugin_get_info", (void*)¬ification_plugin_get_info)) {
41
/* load notification provider plugin info */
42
if (NULL == (notificationPlugin = (*notification_plugin_get_info) ()))
46
/* check notification provider plugin version */
47
if (NOTIFICATION_PLUGIN_API_VERSION != notificationPlugin->api_version) {
48
debug3 (DEBUG_PLUGINS, "notification API version mismatch: \"%s\" has version %d should be %d", plugin->name, notificationPlugin->api_version, NOTIFICATION_PLUGIN_API_VERSION);
52
/* check if all mandatory symbols are provided */
53
if (!(notificationPlugin->plugin_init &&
54
notificationPlugin->plugin_deinit)) {
55
debug1 (DEBUG_PLUGINS, "mandatory symbols missing: \"%s\"", plugin->name);
59
/* add plugin to notification plugin instance list */
60
notificationPlugins = g_slist_append (notificationPlugins, plugin);
62
/* assign the symbols so the caller will accept the plugin */
63
plugin->symbols = notificationPlugin;
69
notification_plugin_init_for_type (notificationType type)
72
notificationPluginPtr selectedPlugin = NULL;
74
/* Check for already loaded plugin of same type and with higher priority */
75
iter = notificationPlugins;
77
notificationPluginPtr tmp = ((pluginPtr)iter->data)->symbols;
79
if (tmp->type == type) {
80
if (!selectedPlugin || (tmp->priority > selectedPlugin->priority))
83
iter = g_slist_next (iter);
86
/* Allow the plugin to initialize */
88
if ((*selectedPlugin->plugin_init) ()) {
89
debug2 (DEBUG_PLUGINS, "using \"%s\" for notification type %d", selectedPlugin->name, selectedPlugin->type);
91
debug1 (DEBUG_PLUGINS, "notification plugin \"%s\" did not load succesfully", selectedPlugin->name);
97
notification_plugin_init (void)
99
notification_plugin_init_for_type (NOTIFICATION_TYPE_POPUP);
100
notification_plugin_init_for_type (NOTIFICATION_TYPE_TRAY);
103
void notification_enable(gboolean enabled) {
104
notificationPluginPtr plugin;
107
iter = notificationPlugins;
109
plugin = ((pluginPtr)iter->data)->symbols;
110
(*plugin->notification_enable)();
111
iter = g_slist_next(iter);
115
void notification_node_has_new_items(nodePtr node, gboolean enforced) {
116
notificationPluginPtr plugin;
119
iter = notificationPlugins;
121
plugin = ((pluginPtr)iter->data)->symbols;
122
(*plugin->node_has_new_items)(node, enforced);
123
iter = g_slist_next(iter);
127
void notification_node_removed(nodePtr node) {
128
notificationPluginPtr plugin;
131
iter = notificationPlugins;
133
plugin = ((pluginPtr)iter->data)->symbols;
134
(*plugin->node_removed)(node);
135
iter = g_slist_next(iter);
29
notificationPluginPtr notificationPlugin = NULL;
32
notification_plugin_register (notificationPluginPtr plugin)
34
g_return_if_fail (!notificationPlugin);
36
/* add plugin to notification plugin */
37
notificationPlugin = plugin;
39
g_return_if_fail ((notificationPlugin->plugin_init)());
43
notification_node_has_new_items(nodePtr node, gboolean enforced)
45
(notificationPlugin->node_has_new_items)(node, enforced);