65d22c7db90a7693c2cc8ad919c50569f1ea272b
[claws.git] / src / plugins / archive / archiver.c
1 /* vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: */
2
3 /*
4  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
5  * Copyright (C) 1999-2008 Michael Rasmussen and the Claws Mail Team
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 3 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, see <http://www.gnu.org/licenses/>.
19  * 
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #  include "config.h"
24 #include "claws-features.h"
25 #endif
26
27 #include <glib.h>
28 #include <glib/gi18n.h>
29
30 #include <gtk/gtk.h>
31
32 #include "common/claws.h"
33 #include "common/version.h"
34 #include "plugin.h"
35 #include "mimeview.h"
36 #include "utils.h"
37 #include "alertpanel.h"
38 #include "statusbar.h"
39 #include "archiver.h"
40 #include "archiver_prefs.h"
41 #include "menu.h"
42
43 #include <archive.h>
44
45 #define PLUGIN_NAME (_("Mail Archiver"))
46
47 static void create_archive_cb(GtkAction *action, gpointer data) {
48
49         debug_print("Call-back function called\n");
50         
51         archiver_gtk_show();
52 }
53
54 static GtkActionEntry archiver_main_menu[] = {{
55         "Tools/CreateArchive",
56         NULL, N_("Create Archive..."), NULL, NULL, G_CALLBACK(create_archive_cb)
57 }};
58
59 static gint main_menu_id = 0;
60 static char *plugin_description = NULL;
61
62 gint plugin_init(gchar** error)
63 {
64         MainWindow *mainwin = mainwindow_get_mainwindow();
65
66         if (!check_plugin_version(MAKE_NUMERIC_VERSION(3,4,0,65),
67                                 VERSION_NUMERIC, PLUGIN_NAME, error))
68                 return -1;
69
70         gtk_action_group_add_actions(mainwin->action_group, archiver_main_menu,
71                         1, (gpointer)mainwin);
72         MENUITEM_ADDUI_ID_MANAGER(mainwin->ui_manager, "/Menu/Tools", "CreateArchive", 
73                           "Tools/CreateArchive", GTK_UI_MANAGER_MENUITEM,
74                           main_menu_id)
75
76         archiver_prefs_init();
77
78         debug_print("archive plugin loaded\n");
79
80         return 0;
81 }
82
83 gboolean plugin_done(void)
84 {
85         MainWindow *mainwin = mainwindow_get_mainwindow();
86
87         if (mainwin == NULL)
88                 return FALSE;
89
90         MENUITEM_REMUI_MANAGER(mainwin->ui_manager,mainwin->action_group, "Tools/CreateArchive", main_menu_id);
91         main_menu_id = 0;
92
93         if (plugin_description != NULL) {
94                 g_free(plugin_description);
95                 plugin_description = NULL;
96         }
97
98         archiver_prefs_done();
99         debug_print("archive plugin unloaded\n");
100
101         return TRUE;
102 }
103
104 const gchar* plugin_licence(void) {
105         return "GPL3+";
106 }
107
108 const gchar* plugin_version(void) {
109         return VERSION;
110 }
111
112 const gchar* plugin_type(void) {
113         return "GTK2";
114 }
115
116 const gchar* plugin_name(void) {
117         return PLUGIN_NAME;
118 }
119
120 const gchar* plugin_desc(void) {
121         if (plugin_description == NULL) {
122
123                 plugin_description = g_strdup_printf(_("This plugin adds archiving features to Claws Mail.\n"
124                         "\n"
125                         "It enables you to select a mail folder that you want "
126                         "to be archived, and then choose a name, format and "
127                         "location for the archive. Subfolders can be included "
128                         "and MD5 checksums can be added for each file in the "
129                         "archive. Several archiving options are also available.\n"
130                         "\n"
131                         "The archive can be stored as:\n%s"
132                         "\n"
133                         "The archive can be compressed using:\n%s"
134                         "\n"
135                         "The archives can be restored with any standard tool "
136                         "that supports the chosen format and compression.\n"
137                         "\n"
138                         "The supported folder types are MH, IMAP, RSSyl and "
139                         "vCalendar.\n"
140                         "\n"
141                         "To activate the archiving feature go to /Tools/Create Archive\n"
142                         "\n"
143                         "Default options can be set in /Configuration/Preferences/Plugins"
144                         "/Mail Archiver"),
145
146 /* archive formats (untranslated, libarchive-version dependant) */
147                         "\tTAR\n\tPAX\n\tSHAR\n\tCPIO\n",
148
149 /* compression formats (untranslated, libarchive-version dependant) */
150                         "\tGZIP\n\tBZIP2\n\tCOMPRESS\n"
151 #if ARCHIVE_VERSION_NUMBER >= 2006990
152                         "\tLZMA\n\tXZ\n"
153 #endif
154 #if ARCHIVE_VERSION_NUMBER >= 3000000
155                         "\tLZIP\n"
156 #endif
157 #if ARCHIVE_VERSION_NUMBER >= 3001000
158                         "\tLRZIP\n\tLZOP\n\tGRZIP\n"
159 #endif
160 #if ARCHIVE_VERSION_NUMBER >= 3001900
161                         "\tLZ4\n"
162 #endif
163                         );
164         }
165         return plugin_description;
166 }
167
168 struct PluginFeature* plugin_provides(void) {
169         static struct PluginFeature features[] =
170         { {PLUGIN_UTILITY, N_("Archiver")},
171           {PLUGIN_NOTHING, NULL} };
172         return features;
173 }