Fix possible resource leak
[claws.git] / src / prefs_account.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2012 Hiroyuki Yamamoto and 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 #ifndef PREFS_ACCOUNT_H
21 #define PREFS_ACCOUNT_H
22
23 #ifdef HAVE_CONFIG_H
24 #include "claws-features.h"
25 #endif
26 #include "ssl.h"
27 typedef struct _PrefsAccount    PrefsAccount;
28
29 typedef enum {
30         A_POP3,
31         A_IMAP4,
32         A_NNTP,
33         A_LOCAL,
34         A_NONE, /* SMTP only */
35         NUM_RECV_PROTOCOLS
36 } RecvProtocol;
37
38 typedef enum {
39         SIG_FILE,
40         SIG_COMMAND,
41         SIG_DIRECT
42 } SigType;
43
44 #include <glib.h>
45
46 #include "smtp.h"
47 #include "gtk/prefswindow.h"
48
49 struct _Folder;
50
51 /* Changes to this data structure might need to be reflected
52  * in account_clone() */
53 struct _PrefsAccount
54 {
55         gchar *account_name;
56
57         /* Personal info */
58         gchar *name;
59         gchar *address;
60         gchar *organization;
61
62         /* Server info */
63         RecvProtocol protocol;
64         gchar *recv_server;
65         gchar *smtp_server;
66         gchar *nntp_server;
67         gboolean use_nntp_auth;
68         gboolean use_nntp_auth_onconnect;
69         gchar *userid;
70         gchar *passwd;
71         gchar *session_passwd;
72
73         gchar * local_mbox;
74         gboolean use_mail_command;
75         gchar * mail_command;
76
77         SSLType ssl_pop;
78         SSLType ssl_imap;
79         SSLType ssl_nntp;
80         SSLType ssl_smtp;
81         
82         gchar *out_ssl_client_cert_file;
83         gchar *out_ssl_client_cert_pass;
84         gchar *in_ssl_client_cert_file;
85         gchar *in_ssl_client_cert_pass;
86
87         gboolean ssl_certs_auto_accept;
88         gboolean use_nonblocking_ssl;
89
90         /* Receive */
91         gboolean use_apop_auth;
92         gboolean rmmail;
93         gint msg_leave_time;
94         gint msg_leave_hour;
95         gboolean recv_at_getall;
96         gboolean sd_rmmail_on_download;
97         gboolean enable_size_limit;
98         gint size_limit;
99         gboolean filter_on_recv;
100         gboolean filterhook_on_recv;
101         gchar *inbox;
102         gchar *local_inbox;
103         gint max_articles;
104         gboolean autochk_use_default;
105         gboolean autochk_use_custom;
106         gint autochk_itv;
107         guint autocheck_timer;
108
109         gint imap_auth_type;
110
111         gboolean receive_in_progress;
112
113         /* Send */
114         gboolean gen_msgid;
115         gboolean gen_xmailer;
116         gboolean add_customhdr;
117         gboolean use_smtp_auth;
118         SMTPAuthType smtp_auth_type;
119         gchar *smtp_userid;
120         gchar *smtp_passwd;
121         gchar *session_smtp_passwd;
122
123         gboolean pop_before_smtp;
124         gint pop_before_smtp_timeout;
125         time_t last_pop_login_time;
126
127         GSList *customhdr_list;
128
129         /* Compose */
130         SigType sig_type;
131         gchar    *sig_path;
132         gboolean  auto_sig;
133         gchar    *sig_sep;
134         gboolean  set_autocc;
135         gchar    *auto_cc;
136         gboolean  set_autobcc;
137         gchar    *auto_bcc;
138         gboolean  set_autoreplyto;
139         gchar    *auto_replyto;
140         gboolean  enable_default_dictionary;
141         gchar    *default_dictionary;
142         gboolean  enable_default_alt_dictionary;
143         gchar    *default_alt_dictionary;
144         gboolean  compose_with_format;
145         gchar    *compose_subject_format;
146         gchar    *compose_body_format;
147         gboolean  reply_with_format;
148         gchar    *reply_quotemark;
149         gchar    *reply_body_format;
150         gboolean  forward_with_format;
151         gchar    *forward_quotemark;
152         gchar    *forward_body_format;
153
154         /* Privacy */
155         gchar    *default_privacy_system;
156         gboolean  default_encrypt;
157         gboolean  default_encrypt_reply;
158         gboolean  default_sign;
159         gboolean  default_sign_reply;
160         gboolean  save_encrypted_as_clear_text;
161         gboolean  encrypt_to_self;
162
163         /* Advanced */
164         gboolean  set_smtpport;
165         gushort   smtpport;
166         gboolean  set_popport;
167         gushort   popport;
168         gboolean  set_imapport;
169         gushort   imapport;
170         gboolean  set_nntpport;
171         gushort   nntpport;
172         gboolean  set_domain;
173         gchar    *domain;
174         gboolean  set_gnutls_priority;
175         gchar    *gnutls_priority;
176         gboolean  msgid_with_addr;
177         gboolean  mark_crosspost_read;
178         gint      crosspost_col;
179
180 #ifndef G_OS_WIN32
181         /* Use this command to open a socket, rather than doing so
182          * directly.  Good if you want to perhaps use a special socks
183          * tunnel command, or run IMAP-over-SSH.  In this case the
184          * server, port etc are only for the user's own information
185          * and are not used.  username and password are used to
186          * authenticate the account only if necessary, since some
187          * tunnels will implicitly authenticate by running e.g. imapd
188          * as a particular user. */
189         gboolean  set_tunnelcmd;
190         gchar     *tunnelcmd;
191 #endif
192
193         gchar *imap_dir;
194         gboolean imap_subsonly;
195         gboolean low_bandwidth;
196
197         gboolean set_sent_folder;
198         gchar *sent_folder;
199         gboolean set_queue_folder;
200         gchar *queue_folder;
201         gboolean set_draft_folder;
202         gchar *draft_folder;
203         gboolean set_trash_folder;
204         gchar *trash_folder;
205
206         /* Default or not */
207         gboolean is_default;
208         /* Unique account ID */
209         gint account_id;
210
211         /* SOCKS proxy */
212         gboolean use_proxy;
213         gboolean use_default_proxy;
214         gboolean use_proxy_for_send;
215         ProxyInfo proxy_info;
216
217         struct _Folder *folder;
218         GHashTable *privacy_prefs;
219         SMTPSession *session;
220
221         gint config_version;
222 };
223
224 void prefs_account_init                 (void);
225
226 PrefsAccount *prefs_account_new                 (void);
227 PrefsAccount *prefs_account_new_from_config     (const gchar    *label);
228
229 void prefs_account_write_config_all     (GList          *account_list);
230
231 void prefs_account_free                 (PrefsAccount   *ac_prefs);
232
233 PrefsAccount *prefs_account_open        (PrefsAccount   *ac_prefs, gboolean *dirty);
234
235 const gchar *prefs_account_get_privacy_prefs(PrefsAccount *account, gchar *id);
236 void prefs_account_set_privacy_prefs(PrefsAccount *account, gchar *id, gchar *new_value);
237 gchar *prefs_account_generate_msgid(PrefsAccount *account);
238
239 void prefs_account_register_page        (PrefsPage      *page);
240 void prefs_account_unregister_page      (PrefsPage      *page);
241
242 gchar *prefs_account_cache_dir          (PrefsAccount   *ac_prefs, gboolean for_server);
243
244 #endif /* PREFS_ACCOUNT_H */