Merged pidgin/main into default
[pidgin-git.git] / libpurple / plugins / helloworld.c
blobc3e2045cb572c59da5bb8da95451c09b7c1d422f
1 /*
2 * Hello World Plugin
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
20 * 02111-1301, USA.
24 /* When writing a third-party plugin, do not include libpurple's internal.h
25 * included below. This file is for internal libpurple use only. We're including
26 * it here for our own convenience. */
27 #include "internal.h"
29 /* This file defines PURPLE_PLUGINS and includes all the libpurple headers */
30 #include <purple.h>
32 /* This function is the callback for the plugin action we added. All we're
33 * doing here is displaying a message. When the user selects the plugin
34 * action, this function is called. */
35 static void
36 plugin_action_test_cb (PurplePluginAction * action)
38 purple_notify_message (action->plugin, PURPLE_NOTIFY_MSG_INFO,
39 "Plugin Actions Test", "This is a plugin actions test :)", NULL, NULL,
40 NULL, NULL);
43 /* we tell libpurple in the PurplePluginInfo struct to call this function to
44 * get a list of plugin actions to use for the plugin. This function gives
45 * libpurple that list of actions. */
46 static GList *
47 plugin_actions (PurplePlugin * plugin)
49 /* some C89 (a.k.a. ANSI C) compilers will warn if any variable declaration
50 * includes an initilization that calls a function. To avoid that, we
51 * generally initialize our variables first with constant values like NULL
52 * or 0 and assign to them with function calls later */
53 GList *list = NULL;
54 PurplePluginAction *action = NULL;
56 /* The action gets created by specifying a name to show in the UI and a
57 * callback function to call. */
58 action = purple_plugin_action_new ("Plugin Action Test", plugin_action_test_cb);
60 /* libpurple requires a GList of plugin actions, even if there is only one
61 * action in the list. We append the action to a GList here. */
62 list = g_list_append (list, action);
64 /* Once the list is complete, we send it to libpurple. */
65 return list;
68 static PurplePluginInfo *
69 plugin_query (GError ** error)
71 const gchar * const authors[] = {
72 "John Bailey <rekkanoryo@cpw.pidgin.im>", /* correct author */
73 NULL
76 /* For specific notes on the meanings of each of these members, consult the
77 C Plugin Howto on the website. */
78 return purple_plugin_info_new (
79 "id", "core-hello_world",
80 "name", "Hello World!",
81 "version", DISPLAY_VERSION, /* This constant is defined in config.h, but you shouldn't use it for your
82 own plugins. We use it here because it's our plugin. And we're lazy. */
83 "category", "Example",
84 "summary", "Hello World Plugin",
85 "description", "Hello World Plugin",
86 "authors", authors,
87 "website", "http://helloworld.tld",
88 "abi-version", PURPLE_ABI_VERSION,
89 "actions-cb", plugin_actions, /* this tells libpurple the address of the function to call to get the list
90 of plugin actions. */
91 NULL
95 static gboolean
96 plugin_load (PurplePlugin * plugin, GError ** error)
98 purple_notify_message (plugin, PURPLE_NOTIFY_MSG_INFO, "Hello World!",
99 "This is the Hello World! plugin :)", NULL, NULL,
100 NULL, NULL);
102 return TRUE;
105 static gboolean
106 plugin_unload (PurplePlugin * plugin, GError ** error)
108 return TRUE;
111 PURPLE_PLUGIN_INIT (hello_world, plugin_query, plugin_load, plugin_unload);