comparison libpurple/plugins/notify_example.c @ 19958:2c69ceca8067

Adding a notify API example plugin.
author John Bailey <rekkanoryo@rekkanoryo.org>
date Wed, 12 Sep 2007 17:21:08 +0000
parents
children 26f562916f98
comparison
equal deleted inserted replaced
19957:f0a87b0d9955 19958:2c69ceca8067
1 /*
2 * Notify API Example Plugin
3 *
4 * Copyright (C) 2007, John Bailey <rekkanoryo@cpw.pidgin.im>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02111-1301, USA.
20 *
21 */
22
23 #ifdef HAVE_CONFIG_H
24 # include <config.h>
25 #endif
26
27 #include <glib.h>
28
29 /* This is the required definition of PURPLE_PLUGINS as required for a plugin,
30 * but we protect it with an #ifndef because config.h may define it for us
31 * already and this would cause an unneeded compiler warning. */
32 #ifndef PURPLE_PLUGINS
33 # define PURPLE_PLUGINS
34 #endif
35
36 #define PLUGIN_ID "core-notifyexample"
37 #define PLUGIN_AUTHOR "John Bailey <rekkanoryo@cpw.pidgin.im>"
38
39 #include <notify.h>
40 #include <plugin.h>
41 #include <version.h>
42
43 static PurplePlugin *notify_example = NULL;
44
45 static void
46 notify_error_cb(PurplePluginAction *action)
47 {
48 purple_notify_error(notify_example, "Test Notification", "Test Notification",
49 "This is a test error notification");
50 }
51
52 static void
53 notify_info_cb(PurplePluginAction *action)
54 {
55 purple_notify_info(notify_example, "Test Notification", "Test Notification",
56 "This is a test informative notification");
57 }
58
59 static void
60 notify_warn_cb(PurplePluginAction *action)
61 {
62 purple_notify_warning(notify_example, "Test Notification", "Test Notification",
63 "This is a test warning notification");
64 }
65
66 static void
67 notify_format_cb(PurplePluginAction *action)
68 {
69 purple_notify_formatted(notify_example, "Test Notification", "Test Notification",
70 "Test Notification",
71 "<I>This is a test notification with formatted text.</I>", NULL, NULL);
72 }
73
74 static void
75 notify_uri_cb(PurplePluginAction *action)
76 {
77 purple_notify_uri(notify_example, "http://www.pidgin.im/");
78 }
79
80 static GList *
81 plugin_actions(PurplePlugin *plugin, gpointer context)
82 {
83 GList *actions = NULL;
84 PurplePluginAction *action = NULL;
85
86 actions = g_list_prepend(actions,
87 purple_plugin_action_new("Show Error Notification", notify_error_cb));
88
89 actions = g_list_prepend(actions,
90 purple_plugin_action_new("Show Info Notification", notify_info_cb));
91
92 actions = g_list_prepend(actions,
93 purple_plugin_action_new("Show Warning Notification", notify_warn_cb));
94
95 actions = g_list_prepend(actions,
96 purple_plugin_action_new("Show Formatted Notification", notify_format_cb));
97
98 actions = g_list_prepend(actions,
99 purple_plugin_action_new("Show URI Notification", notify_uri_cb));
100
101 return g_list_reverse(actions);
102 }
103
104 static gboolean
105 plugin_load(PurplePlugin *plugin)
106 {
107 notify_example = plugin;
108
109 return TRUE;
110 }
111
112 static PurplePluginInfo info = {
113 PURPLE_PLUGIN_MAGIC, /* magic number */
114 PURPLE_MAJOR_VERSION, /* purple major */
115 PURPLE_MINOR_VERSION, /* purple minor */
116 PURPLE_PLUGIN_STANDARD, /* plugin type */
117 NULL, /* UI requirement */
118 0, /* flags */
119 NULL, /* dependencies */
120 PURPLE_PRIORITY_DEFAULT, /* priority */
121
122 PLUGIN_ID, /* id */
123 "Notify API Example", /* name */
124 VERSION, /* version */
125 "Notify API Example", /* summary */
126 "Notify API Example", /* description */
127 PLUGIN_AUTHOR, /* author */
128 "http://pidgin.im", /* homepage */
129
130 plugin_load, /* load */
131 NULL, /* unload */
132 NULL, /* destroy */
133
134 NULL, /* ui info */
135 NULL, /* extra info */
136 NULL, /* prefs info */
137 plugin_actions, /* actions */
138 NULL, /* reserved */
139 NULL, /* reserved */
140 NULL, /* reserved */
141 NULL /* reserved */
142 };
143
144 static void
145 init_plugin(PurplePlugin *plugin)
146 {
147 }
148
149 PURPLE_INIT_PLUGIN(notifyexample, init_plugin, info)
150