1 /*
2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2012 the Claws Mail Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 */
19
20 #include <glib.h>
21 #include <glib/gi18n.h>
22
23
24 #include "version.h"
25 #include "claws.h"
26 #include "plugin.h"
27 #include "utils.h"
28 #include "hooks.h"
29 #include "log.h"
30
31 #define PLUGIN_NAME (_("Demo"))
32
my_log_hook(gpointer source,gpointer data)33 gboolean my_log_hook(gpointer source, gpointer data)
34 {
35 LogText *logtext = (LogText *)source;
36
37 g_print("*** Demo Plugin log: %s\n", logtext->text);
38
39 return FALSE;
40 }
41
42 static gulong hook_id = HOOK_NONE;
43
plugin_init(gchar ** error)44 gint plugin_init(gchar **error)
45 {
46 if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
47 VERSION_NUMERIC, PLUGIN_NAME, error))
48 return -1;
49
50 hook_id = hooks_register_hook(LOG_APPEND_TEXT_HOOKLIST, my_log_hook, NULL);
51 if (hook_id == HOOK_NONE) {
52 *error = g_strdup(_("Failed to register log text hook"));
53 return -1;
54 }
55
56 g_print("Demo plugin loaded\n");
57
58 return 0;
59 }
60
plugin_done(void)61 gboolean plugin_done(void)
62 {
63 hooks_unregister_hook(LOG_APPEND_TEXT_HOOKLIST, hook_id);
64
65 g_print("Demo plugin unloaded\n");
66 return TRUE;
67 }
68
plugin_name(void)69 const gchar *plugin_name(void)
70 {
71 return PLUGIN_NAME;
72 }
73
plugin_desc(void)74 const gchar *plugin_desc(void)
75 {
76 return _("This Plugin is only a demo of how to write plugins for Claws Mail. "
77 "It installs a hook for new log output and writes it to stdout."
78 "\n\n"
79 "It is not really useful.");
80 }
81
plugin_type(void)82 const gchar *plugin_type(void)
83 {
84 return "Common";
85 }
86
plugin_licence(void)87 const gchar *plugin_licence(void)
88 {
89 return "GPL3+";
90 }
91
plugin_version(void)92 const gchar *plugin_version(void)
93 {
94 return VERSION;
95 }
96
plugin_provides(void)97 struct PluginFeature *plugin_provides(void)
98 {
99 static struct PluginFeature features[] =
100 { {PLUGIN_OTHER, N_("Demo")},
101 {PLUGIN_NOTHING, NULL}};
102 return features;
103 }
104