libpurple/plugins/test-request-input.c

changeset 39243
24db7140b77d
child 39244
95f2cd048c67
equal deleted inserted replaced
39208:e35be74157b6 39243:24db7140b77d
1 /* pidgin
2 *
3 * Pidgin is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU 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 02111-1301 USA
20 */
21
22 #include <glib.h>
23
24 #include "internal.h"
25 #include "notify.h"
26 #include "plugins.h"
27 #include "version.h"
28
29 #define PREF_ROOT "/plugins"
30 #define PREF_TEST "/plugins/tests"
31 #define PREF_PREFIX "/plugins/tests/request-input"
32 #define PREF_SINGLE PREF_PREFIX "/single"
33 #define PREF_MULTIPLE PREF_PREFIX "/multiple"
34 #define PREF_HTML PREF_PREFIX "/html"
35
36 static void
37 plugin_input_callback(const gchar *pref, const gchar *text) {
38 purple_debug_info("test-request-input", "setting %s to %s", pref, text);
39 purple_prefs_set_string(pref, text);
40 }
41
42 static void
43 plugin_input_single(PurplePluginAction *action) {
44 purple_request_input(
45 NULL,
46 _("Test request input single"),
47 _("Test request input single"),
48 NULL,
49 purple_prefs_get_string(PREF_SINGLE),
50 FALSE,
51 FALSE,
52 NULL,
53 _("Ok"),
54 PURPLE_CALLBACK(plugin_input_callback),
55 _("Cancel"),
56 NULL,
57 purple_request_cpar_new(),
58 PREF_SINGLE
59 );
60 }
61
62 static void
63 plugin_input_multiple(PurplePluginAction *action) {
64 purple_request_input(
65 NULL,
66 _("Test request input multiple"),
67 _("Test request input multiple"),
68 NULL,
69 purple_prefs_get_string(PREF_MULTIPLE),
70 TRUE,
71 FALSE,
72 NULL,
73 _("Ok"),
74 PURPLE_CALLBACK(plugin_input_callback),
75 _("Cancel"),
76 NULL,
77 purple_request_cpar_new(),
78 PREF_MULTIPLE
79 );
80 }
81
82 static void
83 plugin_input_html(PurplePluginAction *action) {
84 purple_request_input(
85 NULL,
86 _("Test request input HTML"),
87 _("Test request input HTML"),
88 NULL,
89 purple_prefs_get_string(PREF_HTML),
90 FALSE,
91 FALSE,
92 "html",
93 _("Ok"),
94 PURPLE_CALLBACK(plugin_input_callback),
95 _("Cancel"),
96 NULL,
97 purple_request_cpar_new(),
98 PREF_HTML
99 );
100 }
101
102 static GList *
103 plugin_actions(PurplePlugin *plugin) {
104 GList *l = NULL;
105 PurplePluginAction *action = NULL;
106
107 action = purple_plugin_action_new(_("Input single"), plugin_input_single);
108 l = g_list_append(l, action);
109
110 action = purple_plugin_action_new(_("Input multiple"), plugin_input_multiple);
111 l = g_list_append(l, action);
112
113 action = purple_plugin_action_new(_("Input html"), plugin_input_html);
114 l = g_list_append(l, action);
115
116 return l;
117 }
118
119 static PurplePluginInfo *
120 plugin_query(GError **error) {
121 const gchar * const authors[] = {
122 "Gary Kramlich <grim@reaperworld.com>",
123 NULL
124 };
125
126 return purple_plugin_info_new(
127 "id", "core-test_request_input",
128 "name", N_("Test: request input"),
129 "version", DISPLAY_VERSION,
130 "category", N_("Testing"),
131 "summary", N_("Test Request Input"),
132 "description", N_("This plugin adds actions to test purple_request_input"),
133 "authors", authors,
134 "website", "https://pidgin.im",
135 "abi-version", PURPLE_ABI_VERSION,
136 "actions-cb", plugin_actions,
137 NULL
138 );
139 };
140
141 static gboolean
142 plugin_load(PurplePlugin *plugin, GError **error) {
143 purple_prefs_add_none(PREF_ROOT);
144 purple_prefs_add_none(PREF_TEST);
145 purple_prefs_add_none(PREF_PREFIX);
146 purple_prefs_add_string(PREF_SINGLE, "");
147 purple_prefs_add_string(PREF_MULTIPLE, "");
148 purple_prefs_add_string(PREF_HTML, "");
149
150 return TRUE;
151 }
152
153 static gboolean
154 plugin_unload(PurplePlugin *plugin, GError **error) {
155 return TRUE;
156 }
157
158 PURPLE_PLUGIN_INIT(test_request_input, plugin_query, plugin_load, plugin_unload);

mercurial