Fix error creation and warning
[claws.git] / src / plugins / managesieve / sieve_plugin.c
blob4c6bbd9890d0ada29ff97ad8b9efbc84fcfd7440
1 /*
2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2015 the Claws Mail Team
4 * Copyright (C) 2014-2015 Charles Lehner
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "config.h"
23 #include <glib.h>
24 #include <glib/gi18n.h>
26 #include "version.h"
27 #include "claws.h"
28 #include "plugin.h"
29 #include "utils.h"
30 #include "hooks.h"
31 #include "menu.h"
32 #include "mainwindow.h"
33 #include "log.h"
34 #include "sieve_prefs.h"
35 #include "sieve_manager.h"
36 #include "sieve_editor.h"
38 #define PLUGIN_NAME (_("ManageSieve"))
40 static gint main_menu_id = 0;
42 static void manage_cb(GtkAction *action, gpointer data) {
43 sieve_manager_show();
46 static GtkActionEntry sieve_main_menu[] = {{
47 "Tools/ManageSieveFilters",
48 NULL, N_("Manage Sieve Filters..."), NULL, NULL, G_CALLBACK(manage_cb)
49 }};
51 /**
52 * Initialize plugin.
54 * @param error For storing the returned error message.
56 * @return 0 if initialization succeeds, -1 on failure.
58 gint plugin_init(gchar **error)
60 MainWindow *mainwin = mainwindow_get_mainwindow();
62 if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
63 VERSION_NUMERIC, PLUGIN_NAME, error))
64 return -1;
66 gtk_action_group_add_actions(mainwin->action_group, sieve_main_menu, 1,
67 (gpointer)mainwin);
68 MENUITEM_ADDUI_ID_MANAGER(mainwin->ui_manager,
69 "/Menu/Tools", "ManageSieveFilters", "Tools/ManageSieveFilters",
70 GTK_UI_MANAGER_MENUITEM, main_menu_id)
72 sieve_prefs_init();
74 debug_print("ManageSieve plugin loaded\n");
76 return 0;
79 /**
80 * Destructor for the plugin.
81 * Unregister callback functions and free stuff.
83 * @return Always TRUE.
85 gboolean plugin_done(void)
87 MainWindow *mainwin = mainwindow_get_mainwindow();
89 sieve_prefs_done();
90 sieve_managers_done();
91 sieve_editors_close();
92 sieve_sessions_close();
94 if (mainwin)
95 MENUITEM_REMUI_MANAGER(mainwin->ui_manager,
96 mainwin->action_group,
97 "Tools/ManageSieveFilters", main_menu_id);
99 debug_print("ManageSieve plugin unloaded\n");
101 return TRUE;
104 const gchar *plugin_name(void)
106 return PLUGIN_NAME;
110 * Get the description of the plugin.
112 * @return The plugin's description, maybe translated.
114 const gchar *plugin_desc(void)
116 return _("Manage sieve filters on a server using the ManageSieve protocol.");
120 * Get the kind of plugin.
122 * @return The "GTK3" constant.
124 const gchar *plugin_type(void)
126 return "GTK3";
129 * Get the license acronym the plugin is released under.
131 * @return The "GPL3+" constant.
133 const gchar *plugin_licence(void)
135 return "GPL3+";
139 * Get the version of the plugin.
141 * @return The current version string.
143 const gchar *plugin_version(void)
145 return VERSION;
149 * Get the features implemented by the plugin.
151 * @return A constant PluginFeature structure with the features.
153 struct PluginFeature *plugin_provides(void)
155 static struct PluginFeature features[] =
156 { {PLUGIN_UTILITY, N_("ManageSieve")},
157 {PLUGIN_NOTHING, NULL}};
159 return features;