Check for LOGIN xxxx as well if debug is on, so we dont print passwords to
[platform/upstream/evolution-data-server.git] / camel / camel.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 /* 
4  *
5  * Author : 
6  *  Bertrand Guiheneuf <bertrand@helixcode.com>
7  *
8  * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
9  *
10  * This program is free software; you can redistribute it and/or 
11  * modify it under the terms of version 2 of the GNU General Public 
12  * License as published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22  * USA
23  */
24
25 #ifdef HAVE_CONFIG_H
26 #include <config.h>
27 #endif
28
29 #include <signal.h>
30
31 #ifdef HAVE_NSS
32 #include <nspr.h>
33 #include <prthread.h>
34 #include "nss.h"      /* Don't use <> here or it will include the system nss.h instead */
35 #include <ssl.h>
36 #endif /* HAVE_NSS */
37
38 #include "camel.h"
39 #include "camel-mime-utils.h"
40
41 gboolean camel_verbose_debug = FALSE;
42
43 #ifdef HAVE_NSS
44 static void
45 camel_shutdown (void)
46 {
47         NSS_Shutdown ();
48         
49         PR_Cleanup ();
50 }
51 #endif /* HAVE_NSS */
52
53 gint
54 camel_init (const char *configdir, gboolean nss_init)
55 {
56 #ifdef ENABLE_THREADS
57 #ifdef G_THREADS_ENABLED        
58         /*g_thread_init (NULL);*/
59 #else /* G_THREADS_ENABLED */
60         g_warning ("Threads are not supported by your version of glib");
61 #endif /* G_THREADS_ENABLED */
62 #endif /* ENABLE_THREADS */
63         
64         if (getenv ("CAMEL_VERBOSE_DEBUG"))
65                 camel_verbose_debug = TRUE;
66
67         /* initialise global camel_object_type */
68         camel_object_get_type();
69
70         camel_mime_utils_init();
71
72 #ifdef HAVE_NSS
73         if (nss_init) {
74                 PR_Init (PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 10);
75                 
76                 if (NSS_InitReadWrite (configdir) == SECFailure) {
77                         /* fall back on using volatile dbs? */
78                         if (NSS_NoDB_Init (configdir) == SECFailure) {
79                                 g_warning ("Failed to initialize NSS");
80                                 return -1;
81                         }
82                 }
83                 
84                 NSS_SetDomesticPolicy ();
85                 
86                 g_atexit (camel_shutdown);
87         }
88         
89         SSL_OptionSetDefault (SSL_ENABLE_SSL2, PR_TRUE);
90         SSL_OptionSetDefault (SSL_ENABLE_SSL3, PR_TRUE);
91         SSL_OptionSetDefault (SSL_ENABLE_TLS, PR_TRUE);
92         SSL_OptionSetDefault (SSL_V2_COMPATIBLE_HELLO, PR_TRUE /* maybe? */);
93 #endif /* HAVE_NSS */
94         
95         return 0;
96 }