67d5e7a487034f000fff4e86270b25676c32176f
[claws.git] / src / common / sylpheed.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999,2000 Hiroyuki Yamamoto
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 2 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, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include <glib.h>
25
26 #if HAVE_LOCALE_H
27 #  include <locale.h>
28 #endif
29
30 #include "sylpheed.h"
31 #include "intl.h"
32 #include "defs.h"
33 #include "utils.h"
34 #include "ssl.h"
35 #include "version.h"
36 #include "plugin.h"
37
38 static gboolean sylpheed_initialized = FALSE;
39
40 gboolean sylpheed_init(int *argc, char ***argv)
41 {
42         if (sylpheed_initialized)
43                 return TRUE;
44
45         setlocale(LC_ALL, "");
46         bindtextdomain(PACKAGE, LOCALEDIR);
47         textdomain(PACKAGE);
48
49         /* backup if old rc file exists */
50         if (is_file_exist(RC_DIR)) {
51                 if (rename(RC_DIR, RC_DIR ".bak") < 0) {
52                         FILE_OP_ERROR(RC_DIR, "rename");
53                         return FALSE;
54                 }
55         }
56
57         srandom((gint)time(NULL));
58
59 #if USE_OPENSSL
60         ssl_init();
61 #endif
62
63         plugin_load_all();
64
65         sylpheed_initialized = TRUE;
66
67         return TRUE;
68 }
69
70 void sylpheed_done()
71 {
72         plugin_unload_all();
73
74 #if USE_OPENSSL
75         ssl_done();
76 #endif
77 }