4 * Copyright (C) 2004, Gary Kramlich <grim@guifications.org>,
5 * 2007, John Bailey <rekkanoryo@cpw.pidgin.im>
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.
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.
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
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
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
40 # define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
42 # define G_GNUC_NULL_TERMINATED
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
;
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. */
59 plugin_action_test_cb (PurplePluginAction
* action
)
61 purple_notify_message (helloworld_plugin
, PURPLE_NOTIFY_MSG_INFO
,
62 "Plugin Actions Test", "This is a plugin actions test :)", NULL
, NULL
,
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. */
70 plugin_actions (PurplePlugin
* plugin
, gpointer context
)
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 */
77 PurplePluginAction
*action
= NULL
;
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
);
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
);
87 /* Once the list is complete, we send it to libpurple. */
92 plugin_load (PurplePlugin
* plugin
)
94 purple_notify_message (plugin
, PURPLE_NOTIFY_MSG_INFO
, "Hello World!",
95 "This is the Hello World! plugin :)", NULL
, NULL
,
98 helloworld_plugin
= plugin
; /* assign this here so we have a valid handle later */
103 /* For specific notes on the meanings of each of these members, consult the C Plugin Howto
105 static PurplePluginInfo info
= {
107 PURPLE_MAJOR_VERSION
,
108 PURPLE_MINOR_VERSION
,
109 PURPLE_PLUGIN_STANDARD
,
113 PURPLE_PRIORITY_DEFAULT
,
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. */
120 "Hello World Plugin",
121 "Hello World Plugin",
122 "John Bailey <rekkanoryo@cpw.pidgin.im>", /* correct author */
123 "http://helloworld.tld",
133 plugin_actions
, /* this tells libpurple the address of the function to call
134 to get the list of plugin actions. */
142 init_plugin (PurplePlugin
* plugin
)
146 PURPLE_INIT_PLUGIN (hello_world
, init_plugin
, info
)