1.1.4
by Sebastien Bacher
Import upstream version 2.2.0 |
1 |
/*
|
2 |
* Hello World Plugin
|
|
3 |
*
|
|
4 |
* Copyright (C) 2004, Gary Kramlich <grim@guifications.org>,
|
|
5 |
* 2007, John Bailey <rekkanoryo@cpw.pidgin.im>
|
|
6 |
*
|
|
7 |
* This program is free software; you can redistribute it and/or
|
|
8 |
* modify it under the terms of the GNU General Public License as
|
|
9 |
* published by the Free Software Foundation; either version 2 of the
|
|
10 |
* License, or (at your option) any later version.
|
|
11 |
*
|
|
12 |
* This program is distributed in the hope that it will be useful, but
|
|
13 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
15 |
* General Public License for more details.
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License
|
|
18 |
* along with this program; if not, write to the Free Software
|
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
20 |
* 02111-1301, USA.
|
|
21 |
*
|
|
22 |
*/
|
|
23 |
||
24 |
#ifdef HAVE_CONFIG_H
|
|
25 |
# include <config.h>
|
|
26 |
#endif
|
|
27 |
||
28 |
/* config.h may define PURPLE_PLUGINS; protect the definition here so that we
|
|
29 |
* don't get complaints about redefinition when it's not necessary. */
|
|
30 |
#ifndef PURPLE_PLUGINS
|
|
31 |
# define PURPLE_PLUGINS
|
|
32 |
#endif
|
|
33 |
||
34 |
#include <glib.h> |
|
35 |
||
1.1.5
by Sebastien Bacher
Import upstream version 2.2.1 |
36 |
/* This will prevent compiler errors in some instances and is better explained in the
|
37 |
* how-to documents on the wiki */
|
|
38 |
#ifndef G_GNUC_NULL_TERMINATED
|
|
39 |
# if __GNUC__ >= 4
|
|
40 |
# define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
|
|
41 |
# else
|
|
42 |
# define G_GNUC_NULL_TERMINATED
|
|
43 |
# endif
|
|
44 |
#endif
|
|
45 |
||
1.1.4
by Sebastien Bacher
Import upstream version 2.2.0 |
46 |
#include <notify.h> |
47 |
#include <plugin.h> |
|
48 |
#include <version.h> |
|
49 |
||
50 |
/* we're adding this here and assigning it in plugin_load because we need
|
|
51 |
* a valid plugin handle for our call to purple_notify_message() in the
|
|
52 |
* plugin_action_test_cb() callback function */
|
|
53 |
PurplePlugin *helloworld_plugin = NULL; |
|
54 |
||
55 |
/* This function is the callback for the plugin action we added. All we're
|
|
56 |
* doing here is displaying a message. When the user selects the plugin
|
|
57 |
* action, this function is called. */
|
|
58 |
static void |
|
59 |
plugin_action_test_cb (PurplePluginAction * action) |
|
60 |
{
|
|
61 |
purple_notify_message (helloworld_plugin, PURPLE_NOTIFY_MSG_INFO, |
|
62 |
"Plugin Actions Test", "This is a plugin actions test :)", NULL, NULL, |
|
63 |
NULL); |
|
64 |
}
|
|
65 |
||
66 |
/* we tell libpurple in the PurplePluginInfo struct to call this function to
|
|
67 |
* get a list of plugin actions to use for the plugin. This function gives
|
|
68 |
* libpurple that list of actions. */
|
|
69 |
static GList * |
|
70 |
plugin_actions (PurplePlugin * plugin, gpointer context) |
|
71 |
{
|
|
72 |
/* some C89 (a.k.a. ANSI C) compilers will warn if any variable declaration
|
|
73 |
* includes an initilization that calls a function. To avoid that, we
|
|
74 |
* generally initialize our variables first with constant values like NULL
|
|
75 |
* or 0 and assign to them with function calls later */
|
|
76 |
GList *list = NULL; |
|
77 |
PurplePluginAction *action = NULL; |
|
78 |
||
79 |
/* The action gets created by specifying a name to show in the UI and a
|
|
80 |
* callback function to call. */
|
|
81 |
action = purple_plugin_action_new ("Plugin Action Test", plugin_action_test_cb); |
|
82 |
||
83 |
/* libpurple requires a GList of plugin actions, even if there is only one
|
|
84 |
* action in the list. We append the action to a GList here. */
|
|
85 |
list = g_list_append (list, action); |
|
86 |
||
87 |
/* Once the list is complete, we send it to libpurple. */
|
|
88 |
return list; |
|
89 |
}
|
|
90 |
||
91 |
static gboolean |
|
92 |
plugin_load (PurplePlugin * plugin) |
|
93 |
{
|
|
94 |
purple_notify_message (plugin, PURPLE_NOTIFY_MSG_INFO, "Hello World!", |
|
95 |
"This is the Hello World! plugin :)", NULL, NULL, |
|
96 |
NULL); |
|
97 |
||
98 |
helloworld_plugin = plugin; /* assign this here so we have a valid handle later */ |
|
99 |
||
100 |
return TRUE; |
|
101 |
}
|
|
102 |
||
103 |
/* For specific notes on the meanings of each of these members, consult the C Plugin Howto
|
|
104 |
* on the website. */
|
|
105 |
static PurplePluginInfo info = { |
|
106 |
PURPLE_PLUGIN_MAGIC, |
|
107 |
PURPLE_MAJOR_VERSION, |
|
108 |
PURPLE_MINOR_VERSION, |
|
109 |
PURPLE_PLUGIN_STANDARD, |
|
110 |
NULL, |
|
111 |
0, |
|
112 |
NULL, |
|
113 |
PURPLE_PRIORITY_DEFAULT, |
|
114 |
||
115 |
"core-hello_world", |
|
116 |
"Hello World!", |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
117 |
DISPLAY_VERSION, /* This constant is defined in config.h, but you shouldn't use it for |
118 |
your own plugins. We use it here because it's our plugin. And we're lazy. */
|
|
1.1.4
by Sebastien Bacher
Import upstream version 2.2.0 |
119 |
|
120 |
"Hello World Plugin", |
|
121 |
"Hello World Plugin", |
|
122 |
"John Bailey <rekkanoryo@cpw.pidgin.im>", /* correct author */ |
|
123 |
"http://helloworld.tld", |
|
124 |
||
125 |
||
126 |
plugin_load, |
|
127 |
NULL, |
|
128 |
NULL, |
|
129 |
||
130 |
NULL, |
|
131 |
NULL, |
|
132 |
NULL, |
|
133 |
plugin_actions, /* this tells libpurple the address of the function to call |
|
134 |
to get the list of plugin actions. */
|
|
135 |
NULL, |
|
136 |
NULL, |
|
137 |
NULL, |
|
138 |
NULL
|
|
139 |
};
|
|
140 |
||
141 |
static void |
|
142 |
init_plugin (PurplePlugin * plugin) |
|
143 |
{
|
|
144 |
}
|
|
145 |
||
146 |
PURPLE_INIT_PLUGIN (hello_world, init_plugin, info) |