~ubuntu-branches/ubuntu/vivid/liferea/vivid-proposed

« back to all changes in this revision

Viewing changes to src/notification/notification.c

  • Committer: Package Import Robot
  • Author(s): Moray Allan, Bojo42, Rodrigo Gallardo, Moray Allan
  • Date: 2012-03-27 21:44:42 UTC
  • mfrom: (1.5.1)
  • mto: (3.3.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 122.
  • Revision ID: package-import@ubuntu.com-20120327214442-g0xfh714cdmsbnts
Tags: 1.8.3-0.1
[ Bojo42 ]
* Non-maintainer upload.
* New upstream release (Closes: #502307, #623619, #631778, #651913) 
* debian/patches:
  - drop libnotify0.7 as in upstream
  - debian-example-feeds: update, move planets from "News" to "Open Source"
  - www-browser: update due to new file location
  - libtool-dont-rearange-as-needed: rebase
* debian/control:
  - update Standards-Version
  - remove obsolete Build-Depends:
    - quilt not needed for "3.0 (quilt)" source format
    - libnm-glib-dev & libdbus-glib-1-dev: upstream switched to GDBus
    - liblua5.1-0-dev: LUA scripting support got dropped
  - new Build-Depends on libunique-dev, libjson-glib-dev & dh_autoreconf
  - update version dependencies
* debian/rules: run dh_autoreconf & update translations
* debian/liferea.install: nothing to ship from /usr/lib/liferea

[ Rodrigo Gallardo ]
* Lintian love:
  - debian/control: switch from Conflicts to Breaks
  - debian/rules: redo build targets

[ Moray Allan ]
* debian/copyright: update to include additional copyright owners.
* debian/patches/www-browser: also set default external browser.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "common.h"
25
25
#include "debug.h"
26
26
#include "node.h"
27
 
#include "plugin.h"
28
27
#include "notification/notification.h"
29
28
 
30
 
static GSList *notificationPlugins = NULL;
31
 
 
32
 
typedef notificationPluginPtr (*infoFunc)();
33
 
 
34
 
gboolean
35
 
notification_plugin_register (pluginPtr plugin, GModule *handle)
36
 
{
37
 
        notificationPluginPtr   notificationPlugin = NULL;
38
 
        infoFunc                notification_plugin_get_info;
39
 
 
40
 
        if (g_module_symbol (handle, "notification_plugin_get_info", (void*)&notification_plugin_get_info)) {
41
 
                /* load notification provider plugin info */
42
 
                if (NULL == (notificationPlugin = (*notification_plugin_get_info) ()))
43
 
                        return FALSE;
44
 
        }
45
 
 
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);
49
 
                return FALSE;
50
 
        } 
51
 
 
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);
56
 
                return FALSE;
57
 
        }
58
 
 
59
 
        /* add plugin to notification plugin instance list */
60
 
        notificationPlugins = g_slist_append (notificationPlugins, plugin);
61
 
 
62
 
        /* assign the symbols so the caller will accept the plugin */
63
 
        plugin->symbols = notificationPlugin;
64
 
        
65
 
        return TRUE;
66
 
}
67
 
 
68
 
static void
69
 
notification_plugin_init_for_type (notificationType type)
70
 
{
71
 
        GSList                  *iter;
72
 
        notificationPluginPtr   selectedPlugin = NULL;
73
 
        
74
 
        /* Check for already loaded plugin of same type and with higher priority */
75
 
        iter = notificationPlugins;
76
 
        while (iter) {
77
 
                notificationPluginPtr tmp = ((pluginPtr)iter->data)->symbols;
78
 
 
79
 
                if (tmp->type == type) {
80
 
                        if (!selectedPlugin || (tmp->priority > selectedPlugin->priority))
81
 
                                selectedPlugin = tmp;
82
 
                }
83
 
                iter = g_slist_next (iter);
84
 
        }
85
 
        
86
 
        /* Allow the plugin to initialize */
87
 
        if (selectedPlugin) {
88
 
                if ((*selectedPlugin->plugin_init) ()) {
89
 
                        debug2 (DEBUG_PLUGINS, "using \"%s\" for notification type %d", selectedPlugin->name, selectedPlugin->type);
90
 
                } else {
91
 
                        debug1 (DEBUG_PLUGINS, "notification plugin \"%s\" did not load succesfully", selectedPlugin->name);
92
 
                }
93
 
        }
94
 
}
95
 
 
96
 
void
97
 
notification_plugin_init (void)
98
 
{
99
 
        notification_plugin_init_for_type (NOTIFICATION_TYPE_POPUP);
100
 
        notification_plugin_init_for_type (NOTIFICATION_TYPE_TRAY);
101
 
}
102
 
 
103
 
void notification_enable(gboolean enabled) {
104
 
        notificationPluginPtr   plugin;
105
 
        GSList                  *iter;
106
 
 
107
 
        iter = notificationPlugins;
108
 
        while(iter) {
109
 
                plugin = ((pluginPtr)iter->data)->symbols;
110
 
                (*plugin->notification_enable)();
111
 
                iter = g_slist_next(iter);
112
 
        }
113
 
}
114
 
 
115
 
void notification_node_has_new_items(nodePtr node, gboolean enforced) { 
116
 
        notificationPluginPtr   plugin;
117
 
        GSList                  *iter;
118
 
        
119
 
        iter = notificationPlugins;
120
 
        while(iter) {
121
 
                plugin = ((pluginPtr)iter->data)->symbols;
122
 
                (*plugin->node_has_new_items)(node, enforced);
123
 
                iter = g_slist_next(iter);
124
 
        }
125
 
}
126
 
 
127
 
void notification_node_removed(nodePtr node) { 
128
 
        notificationPluginPtr   plugin;
129
 
        GSList                  *iter;
130
 
        
131
 
        iter = notificationPlugins;
132
 
        while(iter) {
133
 
                plugin = ((pluginPtr)iter->data)->symbols;
134
 
                (*plugin->node_removed)(node);
135
 
                iter = g_slist_next(iter);
136
 
        }
 
29
notificationPluginPtr notificationPlugin = NULL;
 
30
 
 
31
void
 
32
notification_plugin_register (notificationPluginPtr plugin)
 
33
{
 
34
        g_return_if_fail (!notificationPlugin);
 
35
 
 
36
        /* add plugin to notification plugin */
 
37
        notificationPlugin = plugin;
 
38
 
 
39
        g_return_if_fail ((notificationPlugin->plugin_init)());
 
40
}
 
41
 
 
42
void
 
43
notification_node_has_new_items(nodePtr node, gboolean enforced)
 
44
{
 
45
        (notificationPlugin->node_has_new_items)(node, enforced);
137
46
}