Open an explorer.exe window at the location of the file when clicking
[pidgin-git.git] / libpurple / plugins / helloworld.c
blob7bb2b1105b5f2e64bb5c280bfbde850e27f5fe45
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 #ifdef HAVE_CONFIG_H
25 # include <config.h>
26 #endif
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
34 #include <glib.h>
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
46 #include <notify.h>
47 #include <plugin.h>
48 #include <version.h>
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. */
58 static void
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,
63 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. */
69 static GList *
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 */
76 GList *list = NULL;
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. */
88 return list;
91 static gboolean
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,
96 NULL);
98 helloworld_plugin = plugin; /* assign this here so we have a valid handle later */
100 return TRUE;
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,
112 NULL,
113 PURPLE_PRIORITY_DEFAULT,
115 "core-hello_world",
116 "Hello World!",
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",
126 plugin_load,
127 NULL,
128 NULL,
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
141 static void
142 init_plugin (PurplePlugin * plugin)
146 PURPLE_INIT_PLUGIN (hello_world, init_plugin, info)