Improve some sieve-related translations
[claws.git] / src / prefs_account.c
blobe291a19f27a50e35a490563fadbb237b3b4f9d24
1 /*
2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2022 the Claws Mail team and Hiroyuki Yamamoto
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.
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.
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/>.
19 #ifdef HAVE_CONFIG_H
20 # include "config.h"
21 #include "claws-features.h"
22 #endif
24 #include "defs.h"
26 #ifdef G_OS_WIN32
27 #include <winsock2.h>
28 #include <ws2tcpip.h>
29 #endif
31 #include <glib.h>
32 #include <glib/gi18n.h>
33 #include <gtk/gtk.h>
34 #include <gdk/gdkkeysyms.h>
35 #include <gtk/filesel.h>
36 #include <stdio.h>
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #include <sys/socket.h>
40 #include <netinet/in.h>
41 #include <string.h>
42 #include <stdlib.h>
43 #include <ctype.h>
44 #include "main.h"
45 #include "prefs_gtk.h"
46 #include "prefs_account.h"
47 #include "prefs_receive.h"
48 #include "prefs_common.h"
49 #include "prefs_customheader.h"
50 #include "account.h"
51 #include "mainwindow.h"
52 #include "manage_window.h"
53 #include "folder.h"
54 #include "foldersel.h"
55 #include "inc.h"
56 #include "menu.h"
57 #include "gtkutils.h"
58 #include "utils.h"
59 #include "alertpanel.h"
60 #include "colorlabel.h"
61 #include "smtp.h"
62 #include "imap.h"
63 #include "pop.h"
64 #ifdef USE_OAUTH2
65 #include "oauth2.h"
66 #endif
67 #include "remotefolder.h"
68 #include "combobox.h"
69 #include "setup.h"
70 #include "quote_fmt.h"
71 #include "hooks.h"
72 #include "privacy.h"
73 #include "inputdialog.h"
74 #include "ssl_certificate.h"
75 #include "passwordstore.h"
76 #include "file-utils.h"
77 #ifdef USE_GNUTLS
78 #include <gnutls/gnutls.h>
79 #endif
81 static gboolean cancelled;
82 static gboolean new_account;
84 static PrefsAccount tmp_ac_prefs;
86 static GtkWidget *sigfile_radiobtn;
87 static GtkWidget *sigcmd_radiobtn;
88 static GtkWidget *entry_sigpath;
89 static GtkWidget *signature_browse_button;
90 static GtkWidget *signature_edit_button;
92 #ifdef USE_GNUTLS
93 static GtkWidget *entry_in_cert_file;
94 static GtkWidget *entry_out_cert_file;
95 static GtkWidget *in_ssl_cert_browse_button;
96 static GtkWidget *out_ssl_cert_browse_button;
97 #endif
99 struct AutocheckWidgets {
100 GtkWidget *autochk_hour_spinbtn;
101 GtkWidget *autochk_min_spinbtn;
102 GtkWidget *autochk_sec_spinbtn;
105 static GSList *prefs_pages = NULL;
107 #ifdef USE_OAUTH2
108 static GTask *oauth2_listener_task;
109 static int oauth2_listener_cancel = 0;
110 static int oauth2_listener_closed = 0;
111 #endif
113 typedef struct BasicPage
115 PrefsPage page;
117 GtkWidget *vbox;
119 GtkWidget *acname_entry;
120 GtkWidget *default_checkbtn;
122 GtkWidget *name_entry;
123 GtkWidget *addr_entry;
124 GtkWidget *org_entry;
126 GtkWidget *serv_frame;
127 GtkWidget *serv_table;
128 gpointer *protocol_optmenu;
129 GtkWidget *recvserv_label;
130 GtkWidget *smtpserv_label;
131 GtkWidget *nntpserv_label;
132 GtkWidget *localmbox_label;
133 GtkWidget *mailcmd_label;
134 GtkWidget *recvserv_entry;
135 GtkWidget *smtpserv_entry;
136 GtkWidget *nntpserv_entry;
137 GtkWidget *nntpauth_checkbtn;
138 GtkWidget *nntpauth_onconnect_checkbtn;
139 GtkWidget *localmbox_entry;
140 GtkWidget *mailcmd_checkbtn;
141 GtkWidget *mailcmd_entry;
142 GtkWidget *uid_label;
143 GtkWidget *pass_label;
144 GtkWidget *uid_entry;
145 GtkWidget *pass_entry;
146 GtkWidget *showpwd_checkbtn;
147 GtkWidget *auto_configure_btn;
148 GtkWidget *auto_configure_cancel_btn;
149 GtkWidget *auto_configure_lbl;
150 } BasicPage;
152 typedef struct ReceivePage
154 PrefsPage page;
156 GtkWidget *vbox;
158 GtkWidget *pop3_frame;
159 GtkWidget *pop_auth_checkbtn;
160 GtkWidget *pop_auth_type_optmenu;
161 GtkWidget *rmmail_checkbtn;
162 GtkWidget *leave_time_spinbtn;
163 GtkWidget *leave_hour_spinbtn;
164 GtkWidget *size_limit_checkbtn;
165 GtkWidget *size_limit_spinbtn;
166 GtkWidget *inbox_label;
167 GtkWidget *inbox_entry;
168 GtkWidget *inbox_btn;
170 GtkWidget *autochk_frame;
172 GtkWidget *local_frame;
173 GtkWidget *local_inbox_label;
174 GtkWidget *local_inbox_entry;
175 GtkWidget *local_inbox_btn;
177 GtkWidget *filter_on_recv_checkbtn;
178 GtkWidget *filterhook_on_recv_checkbtn;
179 GtkWidget *recvatgetall_checkbtn;
181 GtkWidget *imap_frame;
182 GtkWidget *imap_auth_type_optmenu;
183 GtkWidget *imapdir_label;
184 GtkWidget *imapdir_entry;
185 GtkWidget *subsonly_checkbtn;
186 GtkWidget *low_bandwidth_checkbtn;
188 GtkWidget *frame_maxarticle;
189 GtkWidget *maxarticle_label;
190 GtkWidget *maxarticle_spinbtn;
191 GtkAdjustment *maxarticle_spinbtn_adj;
193 GtkWidget *autochk_checkbtn;
194 GtkWidget *autochk_use_default_checkbtn;
195 struct AutocheckWidgets *autochk_widgets;
196 } ReceivePage;
198 typedef struct SendPage
200 PrefsPage page;
202 GtkWidget *vbox;
204 GtkWidget *msgid_checkbtn;
205 GtkWidget *xmailer_checkbtn;
206 GtkWidget *customhdr_checkbtn;
207 GtkWidget *msgid_with_addr_checkbtn;
208 GtkWidget *smtp_auth_checkbtn;
209 GtkWidget *smtp_auth_type_optmenu;
210 GtkWidget *smtp_uid_entry;
211 GtkWidget *smtp_pass_entry;
212 GtkWidget *pop_bfr_smtp_checkbtn;
213 GtkWidget *pop_bfr_smtp_tm_spinbtn;
214 GtkWidget *pop_auth_timeout_lbl;
215 GtkWidget *pop_auth_minutes_lbl;
216 } SendPage;
218 #ifdef USE_OAUTH2
219 typedef struct Oauth2Page
221 PrefsPage page;
223 GtkWidget *vbox;
224 GtkWidget *oauth2_sensitive;
226 GtkWidget *oauth2_authorise_btn;
227 GtkWidget *oauth2_deauthorise_btn;
228 GtkWidget *oauth2_authcode_entry;
229 GtkWidget *oauth2_auth_optmenu;
230 GtkWidget *oauth2_link_button;
231 GtkWidget *oauth2_link_copy_button;
232 gpointer *protocol_optmenu;
233 GtkWidget *oauth2_client_id_entry;
234 GtkWidget *oauth2_client_secret_entry;
235 } Oauth2Page;
236 #endif
238 typedef struct
240 gchar *auth_uri;
241 GtkWidget *entry;
242 } AuthCodeQueryButtonData;
244 typedef struct ComposePage
246 PrefsPage page;
248 GtkWidget *vbox;
250 GtkWidget *sigfile_radiobtn;
251 GtkWidget *entry_sigpath;
252 GtkWidget *checkbtn_autosig;
253 GtkWidget *entry_sigsep;
254 GtkWidget *autocc_checkbtn;
255 GtkWidget *autocc_entry;
256 GtkWidget *autobcc_checkbtn;
257 GtkWidget *autobcc_entry;
258 GtkWidget *autoreplyto_checkbtn;
259 GtkWidget *autoreplyto_entry;
260 #if USE_ENCHANT
261 GtkWidget *checkbtn_enable_default_dictionary;
262 GtkWidget *combo_default_dictionary;
263 GtkWidget *checkbtn_enable_default_alt_dictionary;
264 GtkWidget *combo_default_alt_dictionary;
265 #endif
266 } ComposePage;
268 typedef struct TemplatesPage
270 PrefsPage page;
272 GtkWidget *vbox;
274 GtkWidget *checkbtn_compose_with_format;
275 GtkWidget *compose_subject_format;
276 GtkWidget *compose_body_format;
277 GtkWidget *checkbtn_reply_with_format;
278 GtkWidget *reply_quotemark;
279 GtkWidget *reply_body_format;
280 GtkWidget *checkbtn_forward_with_format;
281 GtkWidget *forward_quotemark;
282 GtkWidget *forward_body_format;
283 } TemplatesPage;
285 typedef struct PrivacyPage
287 PrefsPage page;
289 GtkWidget *vbox;
291 GtkWidget *default_privacy_system;
292 GtkWidget *default_encrypt_checkbtn;
293 GtkWidget *default_encrypt_reply_checkbtn;
294 GtkWidget *default_sign_checkbtn;
295 GtkWidget *default_sign_reply_checkbtn;
296 GtkWidget *save_clear_text_checkbtn;
297 GtkWidget *encrypt_to_self_checkbtn;
298 } PrivacyPage;
300 typedef struct SSLPage
302 PrefsPage page;
304 GtkWidget *vbox;
306 GtkWidget *pop_frame;
307 GtkWidget *pop_nossl_radiobtn;
308 GtkWidget *pop_ssltunnel_radiobtn;
309 GtkWidget *pop_starttls_radiobtn;
311 GtkWidget *imap_frame;
312 GtkWidget *imap_nossl_radiobtn;
313 GtkWidget *imap_ssltunnel_radiobtn;
314 GtkWidget *imap_starttls_radiobtn;
316 GtkWidget *nntp_frame;
317 GtkWidget *nntp_nossl_radiobtn;
318 GtkWidget *nntp_ssltunnel_radiobtn;
320 GtkWidget *send_frame;
321 GtkWidget *smtp_nossl_radiobtn;
322 GtkWidget *smtp_ssltunnel_radiobtn;
323 GtkWidget *smtp_starttls_radiobtn;
325 GtkWidget *entry_in_cert_file;
326 GtkWidget *entry_in_cert_pass;
327 GtkWidget *entry_out_cert_file;
328 GtkWidget *entry_out_cert_pass;
330 GtkWidget *ssl_certs_auto_accept_checkbtn;
331 GtkWidget *use_nonblocking_ssl_checkbtn;
332 } SSLPage;
334 typedef struct ProxyPage
336 PrefsPage page;
338 GtkWidget *vbox;
340 GtkWidget *proxy_checkbtn;
341 GtkWidget *default_proxy_checkbtn;
342 GtkWidget *socks4_radiobtn;
343 GtkWidget *socks5_radiobtn;
344 GtkWidget *proxy_host_entry;
345 GtkWidget *proxy_port_spinbtn;
346 GtkWidget *proxy_auth_checkbtn;
347 GtkWidget *proxy_name_entry;
348 GtkWidget *proxy_pass_entry;
349 GtkWidget *proxy_send_checkbtn;
350 } ProxyPage;
352 typedef struct AdvancedPage
354 PrefsPage page;
356 GtkWidget *vbox;
358 GtkWidget *smtpport_checkbtn;
359 GtkWidget *smtpport_spinbtn;
360 GtkWidget *popport_hbox;
361 GtkWidget *popport_checkbtn;
362 GtkWidget *popport_spinbtn;
363 GtkWidget *imapport_hbox;
364 GtkWidget *imapport_checkbtn;
365 GtkWidget *imapport_spinbtn;
366 GtkWidget *nntpport_hbox;
367 GtkWidget *nntpport_checkbtn;
368 GtkWidget *nntpport_spinbtn;
369 GtkWidget *domain_checkbtn;
370 GtkWidget *domain_entry;
371 GtkWidget *crosspost_checkbtn;
372 GtkWidget *crosspost_colormenu;
374 #ifndef G_OS_WIN32
375 GtkWidget *tunnelcmd_checkbtn;
376 GtkWidget *tunnelcmd_entry;
377 #endif
379 GtkWidget *sent_folder_checkbtn;
380 GtkWidget *sent_folder_entry;
381 GtkWidget *queue_folder_checkbtn;
382 GtkWidget *queue_folder_entry;
383 GtkWidget *draft_folder_checkbtn;
384 GtkWidget *draft_folder_entry;
385 GtkWidget *trash_folder_checkbtn;
386 GtkWidget *trash_folder_entry;
387 } AdvancedPage;
389 static BasicPage basic_page;
390 static ReceivePage receive_page;
391 static SendPage send_page;
392 #ifdef USE_OAUTH2
393 static Oauth2Page oauth2_page;
394 #endif
395 static ComposePage compose_page;
396 static TemplatesPage templates_page;
397 static PrivacyPage privacy_page;
398 #ifdef USE_GNUTLS
399 static SSLPage ssl_page;
400 #endif
401 static ProxyPage proxy_page;
402 static AdvancedPage advanced_page;
404 struct BasicProtocol {
405 GtkWidget *combobox;
406 GtkWidget *label;
407 GtkWidget *descrlabel;
408 GtkWidget *no_imap_warn_icon;
409 GtkWidget *no_imap_warn_label;
412 static char *protocol_names[] = {
413 N_("POP"),
414 N_("IMAP"),
415 N_("News (NNTP)"),
416 N_("Local mbox file"),
417 N_("None (SMTP only)")
420 #ifdef USE_OAUTH2
421 struct Oauth2Listener {
422 int success;
423 Oauth2Service service;
424 OAUTH2Data *OAUTH2Data;
425 gchar *trim_text;
427 #endif
429 static void prefs_account_protocol_set_data_from_optmenu(PrefParam *pparam);
430 static void prefs_account_protocol_set_optmenu (PrefParam *pparam);
431 static void prefs_account_protocol_changed (GtkComboBox *combobox, gpointer data);
433 static void prefs_account_set_string_from_combobox (PrefParam *pparam);
434 static void prefs_account_set_privacy_combobox_from_string (PrefParam *pparam);
436 static void prefs_account_imap_auth_type_set_data_from_optmenu (PrefParam *pparam);
437 static void prefs_account_imap_auth_type_set_optmenu (PrefParam *pparam);
438 static void prefs_account_smtp_auth_type_set_data_from_optmenu (PrefParam *pparam);
439 static void prefs_account_smtp_auth_type_set_optmenu (PrefParam *pparam);
440 static void prefs_account_pop_auth_type_set_data_from_optmenu (PrefParam *pparam);
441 static void prefs_account_pop_auth_type_set_optmenu (PrefParam *pparam);
442 #ifdef USE_OAUTH2
443 static void prefs_account_oauth2_provider_set_data_from_optmenu (PrefParam *pparam);
444 static void prefs_account_oauth2_provider_set_optmenu (PrefParam *pparam);
445 static void prefs_account_oauth2_copy_url (GtkButton *button, gpointer data);
446 static void prefs_account_oauth2_listener(GTask *task, gpointer source, gpointer task_data, GCancellable *cancellable);
447 static void prefs_account_oauth2_callback(GObject *source, GAsyncResult *res, gpointer user_data);
448 static int prefs_account_oauth2_get_line(int sock, char *buf, int size);
449 static void prefs_account_oauth2_set_sensitivity(void);
450 static void prefs_account_oauth2_set_auth_sensitivity(void);
451 static void prefs_account_oauth2_obtain_tokens(GtkButton *button, gpointer data);
452 #endif
453 static void prefs_account_set_autochk_interval_from_widgets(PrefParam *pparam);
454 static void prefs_account_set_autochk_interval_to_widgets(PrefParam *pparam);
456 static void prefs_account_enum_set_data_from_radiobtn (PrefParam *pparam);
457 static void prefs_account_enum_set_radiobtn (PrefParam *pparam);
459 static void crosspost_color_toggled(void);
460 static void prefs_account_crosspost_set_data_from_colormenu(PrefParam *pparam);
461 static void prefs_account_crosspost_set_colormenu(PrefParam *pparam);
463 static void prefs_account_nntpauth_toggled(GtkToggleButton *button, gpointer user_data);
464 static void prefs_account_mailcmd_toggled(GtkToggleButton *button, gpointer user_data);
465 static void prefs_account_showpwd_checkbtn_toggled(GtkToggleButton *button, gpointer user_data);
466 static void prefs_account_entry_changed_newline_check_cb(GtkWidget *entry, gpointer user_data);
467 static void prefs_account_filter_on_recv_toggled(GtkToggleButton *button, gpointer user_data);
469 #if USE_ENCHANT
470 static void prefs_account_compose_default_dictionary_set_string_from_optmenu (PrefParam *pparam);
471 static void prefs_account_compose_default_dictionary_set_optmenu_from_string (PrefParam *pparam);
472 #endif
474 static gchar *privacy_prefs;
476 static PrefParam basic_param[] = {
477 {"account_name", NULL, &tmp_ac_prefs.account_name, P_STRING,
478 &basic_page.acname_entry, prefs_set_data_from_entry, prefs_set_entry},
480 {"is_default", "FALSE", &tmp_ac_prefs.is_default, P_BOOL,
481 &basic_page.default_checkbtn,
482 prefs_set_data_from_toggle, prefs_set_toggle},
484 {"name", NULL, &tmp_ac_prefs.name, P_STRING,
485 &basic_page.name_entry, prefs_set_data_from_entry, prefs_set_entry},
487 {"address", NULL, &tmp_ac_prefs.address, P_STRING,
488 &basic_page.addr_entry, prefs_set_data_from_entry, prefs_set_entry},
490 {"organization", NULL, &tmp_ac_prefs.organization, P_STRING,
491 &basic_page.org_entry, prefs_set_data_from_entry, prefs_set_entry},
493 {"protocol", NULL, &tmp_ac_prefs.protocol, P_ENUM,
494 (GtkWidget **)&basic_page.protocol_optmenu,
495 prefs_account_protocol_set_data_from_optmenu,
496 prefs_account_protocol_set_optmenu},
498 {"receive_server", NULL, &tmp_ac_prefs.recv_server, P_STRING,
499 &basic_page.recvserv_entry, prefs_set_data_from_entry, prefs_set_entry},
501 {"smtp_server", NULL, &tmp_ac_prefs.smtp_server, P_STRING,
502 &basic_page.smtpserv_entry, prefs_set_data_from_entry, prefs_set_entry},
504 {"nntp_server", NULL, &tmp_ac_prefs.nntp_server, P_STRING,
505 &basic_page.nntpserv_entry, prefs_set_data_from_entry, prefs_set_entry},
507 {"local_mbox", "/var/mail", &tmp_ac_prefs.local_mbox, P_STRING,
508 &basic_page.localmbox_entry, prefs_set_data_from_entry, prefs_set_entry},
510 {"use_mail_command", "FALSE", &tmp_ac_prefs.use_mail_command, P_BOOL,
511 &basic_page.mailcmd_checkbtn, prefs_set_data_from_toggle, prefs_set_toggle},
513 {"mail_command", DEFAULT_SENDMAIL_CMD, &tmp_ac_prefs.mail_command, P_STRING,
514 &basic_page.mailcmd_entry, prefs_set_data_from_entry, prefs_set_entry},
516 {"use_nntp_auth", "FALSE", &tmp_ac_prefs.use_nntp_auth, P_BOOL,
517 &basic_page.nntpauth_checkbtn,
518 prefs_set_data_from_toggle, prefs_set_toggle},
520 {"use_nntp_auth_onconnect", "FALSE", &tmp_ac_prefs.use_nntp_auth_onconnect, P_BOOL,
521 &basic_page.nntpauth_onconnect_checkbtn,
522 prefs_set_data_from_toggle, prefs_set_toggle},
524 {"user_id", NULL, &tmp_ac_prefs.userid, P_STRING,
525 &basic_page.uid_entry, prefs_set_data_from_entry, prefs_set_entry},
527 {"password", NULL, &tmp_ac_prefs.passwd, P_PASSWORD,
528 NULL, NULL, NULL},
530 {"config_version", "-1", &tmp_ac_prefs.config_version, P_INT,
531 NULL, NULL, NULL},
533 {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
536 static PrefParam receive_param[] = {
537 {"use_apop_auth", "FALSE", &tmp_ac_prefs.use_apop_auth, P_BOOL,
538 NULL, NULL}, /* deprecated */
540 {"use_pop_auth", "FALSE", &tmp_ac_prefs.use_pop_auth, P_BOOL,
541 &receive_page.pop_auth_checkbtn,
542 prefs_set_data_from_toggle, prefs_set_toggle},
544 {"pop_auth_method", "0", &tmp_ac_prefs.pop_auth_type, P_ENUM,
545 &receive_page.pop_auth_type_optmenu,
546 prefs_account_pop_auth_type_set_data_from_optmenu,
547 prefs_account_pop_auth_type_set_optmenu},
549 {"remove_mail", "TRUE", &tmp_ac_prefs.rmmail, P_BOOL,
550 &receive_page.rmmail_checkbtn,
551 prefs_set_data_from_toggle, prefs_set_toggle},
553 #ifndef GENERIC_UMPC
554 {"message_leave_time", "7", &tmp_ac_prefs.msg_leave_time, P_INT,
555 &receive_page.leave_time_spinbtn,
556 prefs_set_data_from_spinbtn, prefs_set_spinbtn},
557 #else
558 {"message_leave_time", "30", &tmp_ac_prefs.msg_leave_time, P_INT,
559 &receive_page.leave_time_spinbtn,
560 prefs_set_data_from_spinbtn, prefs_set_spinbtn},
561 #endif
562 {"message_leave_hour", "0", &tmp_ac_prefs.msg_leave_hour, P_INT,
563 &receive_page.leave_hour_spinbtn,
564 prefs_set_data_from_spinbtn, prefs_set_spinbtn},
566 {"enable_size_limit", "FALSE", &tmp_ac_prefs.enable_size_limit, P_BOOL,
567 &receive_page.size_limit_checkbtn,
568 prefs_set_data_from_toggle, prefs_set_toggle},
569 {"size_limit", "1024", &tmp_ac_prefs.size_limit, P_INT,
570 &receive_page.size_limit_spinbtn,
571 prefs_set_data_from_spinbtn, prefs_set_spinbtn},
573 {"filter_on_receive", "TRUE", &tmp_ac_prefs.filter_on_recv, P_BOOL,
574 &receive_page.filter_on_recv_checkbtn,
575 prefs_set_data_from_toggle, prefs_set_toggle},
577 {"filterhook_on_receive", "TRUE", &tmp_ac_prefs.filterhook_on_recv, P_BOOL,
578 &receive_page.filterhook_on_recv_checkbtn,
579 prefs_set_data_from_toggle, prefs_set_toggle},
581 {"imap_auth_method", "0", &tmp_ac_prefs.imap_auth_type, P_ENUM,
582 &receive_page.imap_auth_type_optmenu,
583 prefs_account_imap_auth_type_set_data_from_optmenu,
584 prefs_account_imap_auth_type_set_optmenu},
586 {"receive_at_get_all", "TRUE", &tmp_ac_prefs.recv_at_getall, P_BOOL,
587 &receive_page.recvatgetall_checkbtn,
588 prefs_set_data_from_toggle, prefs_set_toggle},
590 {"max_news_articles", "300", &tmp_ac_prefs.max_articles, P_INT,
591 &receive_page.maxarticle_spinbtn,
592 prefs_set_data_from_spinbtn, prefs_set_spinbtn},
594 {"inbox", "#mh/Mailbox/inbox", &tmp_ac_prefs.inbox, P_STRING,
595 &receive_page.inbox_entry, prefs_set_data_from_entry, prefs_set_entry},
597 {"local_inbox", "#mh/Mailbox/inbox", &tmp_ac_prefs.local_inbox, P_STRING,
598 &receive_page.local_inbox_entry, prefs_set_data_from_entry, prefs_set_entry},
600 {"imap_directory", NULL, &tmp_ac_prefs.imap_dir, P_STRING,
601 &receive_page.imapdir_entry, prefs_set_data_from_entry, prefs_set_entry},
603 {"imap_subsonly", "TRUE", &tmp_ac_prefs.imap_subsonly, P_BOOL,
604 &receive_page.subsonly_checkbtn,
605 prefs_set_data_from_toggle, prefs_set_toggle},
607 {"low_bandwidth", "FALSE", &tmp_ac_prefs.low_bandwidth, P_BOOL,
608 &receive_page.low_bandwidth_checkbtn,
609 prefs_set_data_from_toggle, prefs_set_toggle},
611 {"autochk_use_default", "TRUE", &tmp_ac_prefs.autochk_use_default, P_BOOL,
612 &receive_page.autochk_use_default_checkbtn,
613 prefs_set_data_from_toggle, prefs_set_toggle},
615 {"autochk_use_custom", "FALSE", &tmp_ac_prefs.autochk_use_custom, P_BOOL,
616 &receive_page.autochk_checkbtn,
617 prefs_set_data_from_toggle, prefs_set_toggle},
619 /* Here we lie a bit, passing a pointer to our custom struct,
620 * disguised as a GtkWidget pointer, to get around the
621 * inflexibility of PrefParam system. */
622 {"autochk_interval", "600", &tmp_ac_prefs.autochk_itv, P_INT,
623 (GtkWidget **)&receive_page.autochk_widgets,
624 prefs_account_set_autochk_interval_from_widgets,
625 prefs_account_set_autochk_interval_to_widgets},
627 {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
630 static PrefParam send_param[] = {
631 {"generate_msgid", "TRUE", &tmp_ac_prefs.gen_msgid, P_BOOL,
632 &send_page.msgid_checkbtn,
633 prefs_set_data_from_toggle, prefs_set_toggle},
635 {"generate_xmailer", "TRUE", &tmp_ac_prefs.gen_xmailer, P_BOOL,
636 &send_page.xmailer_checkbtn,
637 prefs_set_data_from_toggle, prefs_set_toggle},
639 {"add_custom_header", "FALSE", &tmp_ac_prefs.add_customhdr, P_BOOL,
640 &send_page.customhdr_checkbtn,
641 prefs_set_data_from_toggle, prefs_set_toggle},
643 {"msgid_with_addr", "FALSE", &tmp_ac_prefs.msgid_with_addr, P_BOOL,
644 &send_page.msgid_with_addr_checkbtn,
645 prefs_set_data_from_toggle, prefs_set_toggle},
647 {"use_smtp_auth", "FALSE", &tmp_ac_prefs.use_smtp_auth, P_BOOL,
648 &send_page.smtp_auth_checkbtn,
649 prefs_set_data_from_toggle, prefs_set_toggle},
651 {"smtp_auth_method", "0", &tmp_ac_prefs.smtp_auth_type, P_ENUM,
652 &send_page.smtp_auth_type_optmenu,
653 prefs_account_smtp_auth_type_set_data_from_optmenu,
654 prefs_account_smtp_auth_type_set_optmenu},
656 {"smtp_user_id", NULL, &tmp_ac_prefs.smtp_userid, P_STRING,
657 &send_page.smtp_uid_entry, prefs_set_data_from_entry, prefs_set_entry},
658 {"smtp_password", NULL, &tmp_ac_prefs.smtp_passwd, P_PASSWORD,
659 NULL, NULL, NULL},
661 {"pop_before_smtp", "FALSE", &tmp_ac_prefs.pop_before_smtp, P_BOOL,
662 &send_page.pop_bfr_smtp_checkbtn,
663 prefs_set_data_from_toggle, prefs_set_toggle},
665 {"pop_before_smtp_timeout", "5", &tmp_ac_prefs.pop_before_smtp_timeout, P_INT,
666 &send_page.pop_bfr_smtp_tm_spinbtn,
667 prefs_set_data_from_spinbtn, prefs_set_spinbtn},
669 {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
672 static PrefParam oauth2_param[] = {
673 #ifdef USE_OAUTH2
674 {"oauth2_auth_provider", "0", &tmp_ac_prefs.oauth2_provider, P_ENUM,
675 &oauth2_page.oauth2_auth_optmenu,
676 prefs_account_oauth2_provider_set_data_from_optmenu,
677 prefs_account_oauth2_provider_set_optmenu},
679 {"oauth2_date", 0, &tmp_ac_prefs.oauth2_date, P_INT,
680 NULL, NULL, NULL},
682 {"oauth2_authcode", NULL, &tmp_ac_prefs.oauth2_authcode, P_PASSWORD,
683 NULL, NULL, NULL},
685 {"oauth2_client_id", NULL, &tmp_ac_prefs.oauth2_client_id, P_STRING,
686 &oauth2_page.oauth2_client_id_entry, prefs_set_data_from_entry, prefs_set_entry},
688 {"oauth2_client_secret", NULL, &tmp_ac_prefs.oauth2_client_secret, P_STRING,
689 &oauth2_page.oauth2_client_secret_entry, prefs_set_data_from_entry, prefs_set_entry},
690 #else
691 {"oauth2_auth_provider", "0", &tmp_ac_prefs.oauth2_provider, P_ENUM,
692 NULL, NULL, NULL},
694 {"oauth2_date", 0, &tmp_ac_prefs.oauth2_date, P_INT,
695 NULL, NULL, NULL},
697 {"oauth2_authcode", NULL, &tmp_ac_prefs.oauth2_authcode, P_PASSWORD,
698 NULL, NULL, NULL},
700 {"oauth2_client_id", NULL, &tmp_ac_prefs.oauth2_client_id, P_STRING,
701 NULL, NULL, NULL},
703 {"oauth2_client_secret", NULL, &tmp_ac_prefs.oauth2_client_secret, P_STRING,
704 NULL, NULL, NULL},
706 #endif
708 {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
711 static PrefParam compose_param[] = {
712 {"signature_type", "0", &tmp_ac_prefs.sig_type, P_ENUM,
713 &compose_page.sigfile_radiobtn,
714 prefs_account_enum_set_data_from_radiobtn,
715 prefs_account_enum_set_radiobtn},
716 {"signature_path", "~" G_DIR_SEPARATOR_S DEFAULT_SIGNATURE,
717 &tmp_ac_prefs.sig_path, P_STRING, &compose_page.entry_sigpath,
718 prefs_set_data_from_entry, prefs_set_entry},
720 {"auto_signature", "TRUE", &tmp_ac_prefs.auto_sig, P_BOOL,
721 &compose_page.checkbtn_autosig,
722 prefs_set_data_from_toggle, prefs_set_toggle},
724 {"signature_separator", "-- ", &tmp_ac_prefs.sig_sep, P_STRING,
725 &compose_page.entry_sigsep,
726 prefs_set_data_from_entry, prefs_set_entry},
728 {"set_autocc", "FALSE", &tmp_ac_prefs.set_autocc, P_BOOL,
729 &compose_page.autocc_checkbtn,
730 prefs_set_data_from_toggle, prefs_set_toggle},
732 {"auto_cc", NULL, &tmp_ac_prefs.auto_cc, P_STRING,
733 &compose_page.autocc_entry,
734 prefs_set_data_from_entry, prefs_set_entry},
736 {"set_autobcc", "FALSE", &tmp_ac_prefs.set_autobcc, P_BOOL,
737 &compose_page.autobcc_checkbtn,
738 prefs_set_data_from_toggle, prefs_set_toggle},
740 {"auto_bcc", NULL, &tmp_ac_prefs.auto_bcc, P_STRING,
741 &compose_page.autobcc_entry,
742 prefs_set_data_from_entry, prefs_set_entry},
744 {"set_autoreplyto", "FALSE", &tmp_ac_prefs.set_autoreplyto, P_BOOL,
745 &compose_page.autoreplyto_checkbtn,
746 prefs_set_data_from_toggle, prefs_set_toggle},
748 {"auto_replyto", NULL, &tmp_ac_prefs.auto_replyto, P_STRING,
749 &compose_page.autoreplyto_entry,
750 prefs_set_data_from_entry, prefs_set_entry},
752 #if USE_ENCHANT
753 {"enable_default_dictionary", "", &tmp_ac_prefs.enable_default_dictionary, P_BOOL,
754 &compose_page.checkbtn_enable_default_dictionary,
755 prefs_set_data_from_toggle, prefs_set_toggle},
757 {"default_dictionary", NULL, &tmp_ac_prefs.default_dictionary, P_STRING,
758 &compose_page.combo_default_dictionary,
759 prefs_account_compose_default_dictionary_set_string_from_optmenu,
760 prefs_account_compose_default_dictionary_set_optmenu_from_string},
762 {"enable_default_alt_dictionary", "", &tmp_ac_prefs.enable_default_alt_dictionary, P_BOOL,
763 &compose_page.checkbtn_enable_default_alt_dictionary,
764 prefs_set_data_from_toggle, prefs_set_toggle},
766 {"default_alt_dictionary", NULL, &tmp_ac_prefs.default_alt_dictionary, P_STRING,
767 &compose_page.combo_default_alt_dictionary,
768 prefs_account_compose_default_dictionary_set_string_from_optmenu,
769 prefs_account_compose_default_dictionary_set_optmenu_from_string},
770 #else
771 {"enable_default_dictionary", "", &tmp_ac_prefs.enable_default_dictionary, P_BOOL,
772 NULL, NULL, NULL},
774 {"default_dictionary", NULL, &tmp_ac_prefs.default_dictionary, P_STRING,
775 NULL, NULL, NULL},
777 {"enable_default_alt_dictionary", "", &tmp_ac_prefs.enable_default_alt_dictionary, P_BOOL,
778 NULL, NULL, NULL},
780 {"default_alt_dictionary", NULL, &tmp_ac_prefs.default_alt_dictionary, P_STRING,
781 NULL, NULL, NULL},
782 #endif
784 {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
787 static PrefParam templates_param[] = {
788 {"compose_with_format", "FALSE", &tmp_ac_prefs.compose_with_format, P_BOOL,
789 &templates_page.checkbtn_compose_with_format,
790 prefs_set_data_from_toggle, prefs_set_toggle},
792 {"compose_subject_format", NULL, &tmp_ac_prefs.compose_subject_format, P_STRING,
793 &templates_page.compose_subject_format,
794 prefs_set_escaped_data_from_entry, prefs_set_entry_from_escaped},
796 {"compose_body_format", NULL, &tmp_ac_prefs.compose_body_format, P_STRING,
797 &templates_page.compose_body_format,
798 prefs_set_escaped_data_from_text, prefs_set_text_from_escaped},
800 {"reply_with_format", "FALSE", &tmp_ac_prefs.reply_with_format, P_BOOL,
801 &templates_page.checkbtn_reply_with_format,
802 prefs_set_data_from_toggle, prefs_set_toggle},
804 {"reply_quotemark", NULL, &tmp_ac_prefs.reply_quotemark, P_STRING,
805 &templates_page.reply_quotemark,
806 prefs_set_data_from_entry, prefs_set_entry_from_escaped},
808 {"reply_body_format", NULL, &tmp_ac_prefs.reply_body_format, P_STRING,
809 &templates_page.reply_body_format,
810 prefs_set_escaped_data_from_text, prefs_set_text_from_escaped},
812 {"forward_with_format", "FALSE", &tmp_ac_prefs.forward_with_format, P_BOOL,
813 &templates_page.checkbtn_forward_with_format,
814 prefs_set_data_from_toggle, prefs_set_toggle},
816 {"forward_quotemark", NULL, &tmp_ac_prefs.forward_quotemark, P_STRING,
817 &templates_page.forward_quotemark,
818 prefs_set_data_from_entry, prefs_set_entry_from_escaped},
820 {"forward_body_format", NULL, &tmp_ac_prefs.forward_body_format, P_STRING,
821 &templates_page.forward_body_format,
822 prefs_set_escaped_data_from_text, prefs_set_text_from_escaped},
824 {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
827 static PrefParam privacy_param[] = {
828 {"default_privacy_system", "", &tmp_ac_prefs.default_privacy_system, P_STRING,
829 &privacy_page.default_privacy_system,
830 prefs_account_set_string_from_combobox,
831 prefs_account_set_privacy_combobox_from_string},
833 {"default_encrypt", "FALSE", &tmp_ac_prefs.default_encrypt, P_BOOL,
834 &privacy_page.default_encrypt_checkbtn,
835 prefs_set_data_from_toggle, prefs_set_toggle},
837 {"default_encrypt_reply", "TRUE", &tmp_ac_prefs.default_encrypt_reply, P_BOOL,
838 &privacy_page.default_encrypt_reply_checkbtn,
839 prefs_set_data_from_toggle, prefs_set_toggle},
841 {"default_sign", "FALSE", &tmp_ac_prefs.default_sign, P_BOOL,
842 &privacy_page.default_sign_checkbtn,
843 prefs_set_data_from_toggle, prefs_set_toggle},
844 #ifdef G_OS_UNIX
845 {"default_sign_reply", "TRUE", &tmp_ac_prefs.default_sign_reply, P_BOOL,
846 &privacy_page.default_sign_reply_checkbtn,
847 prefs_set_data_from_toggle, prefs_set_toggle},
848 #else
849 /* Bug 2367: disturbing for Win32 users with no keypair */
850 {"default_sign_reply", "FALSE", &tmp_ac_prefs.default_sign_reply, P_BOOL,
851 &privacy_page.default_sign_reply_checkbtn,
852 prefs_set_data_from_toggle, prefs_set_toggle},
853 #endif
854 {"save_clear_text", "FALSE", &tmp_ac_prefs.save_encrypted_as_clear_text, P_BOOL,
855 &privacy_page.save_clear_text_checkbtn,
856 prefs_set_data_from_toggle, prefs_set_toggle},
858 {"encrypt_to_self", "FALSE", &tmp_ac_prefs.encrypt_to_self, P_BOOL,
859 &privacy_page.encrypt_to_self_checkbtn,
860 prefs_set_data_from_toggle, prefs_set_toggle},
862 {"privacy_prefs", "", &privacy_prefs, P_STRING,
863 NULL, NULL, NULL},
865 {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
868 static PrefParam ssl_param[] = {
869 #ifdef USE_GNUTLS
870 {"ssl_pop", "0", &tmp_ac_prefs.ssl_pop, P_ENUM,
871 &ssl_page.pop_nossl_radiobtn,
872 prefs_account_enum_set_data_from_radiobtn,
873 prefs_account_enum_set_radiobtn},
875 {"ssl_imap", "0", &tmp_ac_prefs.ssl_imap, P_ENUM,
876 &ssl_page.imap_nossl_radiobtn,
877 prefs_account_enum_set_data_from_radiobtn,
878 prefs_account_enum_set_radiobtn},
880 {"ssl_nntp", "0", &tmp_ac_prefs.ssl_nntp, P_ENUM,
881 &ssl_page.nntp_nossl_radiobtn,
882 prefs_account_enum_set_data_from_radiobtn,
883 prefs_account_enum_set_radiobtn},
885 {"ssl_smtp", "0", &tmp_ac_prefs.ssl_smtp, P_ENUM,
886 &ssl_page.smtp_nossl_radiobtn,
887 prefs_account_enum_set_data_from_radiobtn,
888 prefs_account_enum_set_radiobtn},
890 {"ssl_certs_auto_accept", "0", &tmp_ac_prefs.ssl_certs_auto_accept, P_BOOL,
891 &ssl_page.ssl_certs_auto_accept_checkbtn,
892 prefs_set_data_from_toggle, prefs_set_toggle},
894 {"use_nonblocking_ssl", "1", &tmp_ac_prefs.use_nonblocking_ssl, P_BOOL,
895 &ssl_page.use_nonblocking_ssl_checkbtn,
896 prefs_set_data_from_toggle, prefs_set_toggle},
898 {"use_tls_sni", "1", &tmp_ac_prefs.use_tls_sni, P_BOOL,
899 NULL, NULL, NULL},
901 {"in_ssl_client_cert_file", "", &tmp_ac_prefs.in_ssl_client_cert_file, P_STRING,
902 &ssl_page.entry_in_cert_file, prefs_set_data_from_entry, prefs_set_entry},
904 {"in_ssl_client_cert_pass", "", &tmp_ac_prefs.in_ssl_client_cert_pass, P_PASSWORD,
905 NULL, NULL, NULL},
907 {"out_ssl_client_cert_file", "", &tmp_ac_prefs.out_ssl_client_cert_file, P_STRING,
908 &ssl_page.entry_out_cert_file, prefs_set_data_from_entry, prefs_set_entry},
910 {"out_ssl_client_cert_pass", "", &tmp_ac_prefs.out_ssl_client_cert_pass, P_PASSWORD,
911 NULL, NULL, NULL},
912 #else
913 {"ssl_pop", "0", &tmp_ac_prefs.ssl_pop, P_ENUM,
914 NULL, NULL, NULL},
916 {"ssl_imap", "0", &tmp_ac_prefs.ssl_imap, P_ENUM,
917 NULL, NULL, NULL},
919 {"ssl_nntp", "0", &tmp_ac_prefs.ssl_nntp, P_ENUM,
920 NULL, NULL, NULL},
922 {"ssl_smtp", "0", &tmp_ac_prefs.ssl_smtp, P_ENUM,
923 NULL, NULL, NULL},
925 {"in_ssl_client_cert_file", "", &tmp_ac_prefs.in_ssl_client_cert_file, P_STRING,
926 NULL, NULL, NULL},
928 {"in_ssl_client_cert_pass", "", &tmp_ac_prefs.in_ssl_client_cert_pass, P_PASSWORD,
929 NULL, NULL, NULL},
931 {"out_ssl_client_cert_file", "", &tmp_ac_prefs.out_ssl_client_cert_file, P_STRING,
932 NULL, NULL, NULL},
934 {"out_ssl_client_cert_pass", "", &tmp_ac_prefs.out_ssl_client_cert_pass, P_PASSWORD,
935 NULL, NULL, NULL},
937 {"ssl_certs_auto_accept", "0", &tmp_ac_prefs.ssl_certs_auto_accept, P_BOOL,
938 NULL, NULL, NULL},
940 {"use_nonblocking_ssl", "1", &tmp_ac_prefs.use_nonblocking_ssl, P_BOOL,
941 NULL, NULL, NULL},
942 #endif /* USE_GNUTLS */
944 {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
947 static PrefParam proxy_param[] = {
948 /* SOCKS proxy */
949 {"use_proxy", "FALSE", &tmp_ac_prefs.use_proxy, P_BOOL,
950 &proxy_page.proxy_checkbtn,
951 prefs_set_data_from_toggle, prefs_set_toggle},
953 {"use_default_proxy", "TRUE", &tmp_ac_prefs.use_default_proxy, P_BOOL,
954 &proxy_page.default_proxy_checkbtn,
955 prefs_set_data_from_toggle, prefs_set_toggle},
957 {"use_proxy_for_send", "TRUE", &tmp_ac_prefs.use_proxy_for_send, P_BOOL,
958 &proxy_page.proxy_send_checkbtn,
959 prefs_set_data_from_toggle, prefs_set_toggle},
961 {"proxy_type", "1", &tmp_ac_prefs.proxy_info.proxy_type, P_ENUM,
962 &proxy_page.socks4_radiobtn,
963 prefs_account_enum_set_data_from_radiobtn,
964 prefs_account_enum_set_radiobtn},
966 {"proxy_host", "localhost", &tmp_ac_prefs.proxy_info.proxy_host, P_STRING,
967 &proxy_page.proxy_host_entry,
968 prefs_set_data_from_entry, prefs_set_entry},
970 {"proxy_port", "1080", &tmp_ac_prefs.proxy_info.proxy_port, P_USHORT,
971 &proxy_page.proxy_port_spinbtn,
972 prefs_set_data_from_spinbtn, prefs_set_spinbtn},
974 {"use_proxy_auth", "FALSE", &tmp_ac_prefs.proxy_info.use_proxy_auth, P_BOOL,
975 &proxy_page.proxy_auth_checkbtn,
976 prefs_set_data_from_toggle, prefs_set_toggle},
978 {"proxy_name", "", &tmp_ac_prefs.proxy_info.proxy_name, P_STRING,
979 &proxy_page.proxy_name_entry,
980 prefs_set_data_from_entry, prefs_set_entry},
982 {"proxy_pass", NULL, &tmp_ac_prefs.proxy_info.proxy_pass, P_PASSWORD,
983 NULL, NULL, NULL},
986 {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
989 static PrefParam advanced_param[] = {
990 {"set_smtpport", "FALSE", &tmp_ac_prefs.set_smtpport, P_BOOL,
991 &advanced_page.smtpport_checkbtn,
992 prefs_set_data_from_toggle, prefs_set_toggle},
994 {"smtp_port", "25", &tmp_ac_prefs.smtpport, P_USHORT,
995 &advanced_page.smtpport_spinbtn,
996 prefs_set_data_from_spinbtn, prefs_set_spinbtn},
998 {"set_popport", "FALSE", &tmp_ac_prefs.set_popport, P_BOOL,
999 &advanced_page.popport_checkbtn,
1000 prefs_set_data_from_toggle, prefs_set_toggle},
1002 {"pop_port", "110", &tmp_ac_prefs.popport, P_USHORT,
1003 &advanced_page.popport_spinbtn,
1004 prefs_set_data_from_spinbtn, prefs_set_spinbtn},
1006 {"set_imapport", "FALSE", &tmp_ac_prefs.set_imapport, P_BOOL,
1007 &advanced_page.imapport_checkbtn,
1008 prefs_set_data_from_toggle, prefs_set_toggle},
1010 {"imap_port", "143", &tmp_ac_prefs.imapport, P_USHORT,
1011 &advanced_page.imapport_spinbtn,
1012 prefs_set_data_from_spinbtn, prefs_set_spinbtn},
1014 {"set_nntpport", "FALSE", &tmp_ac_prefs.set_nntpport, P_BOOL,
1015 &advanced_page.nntpport_checkbtn,
1016 prefs_set_data_from_toggle, prefs_set_toggle},
1018 {"nntp_port", "119", &tmp_ac_prefs.nntpport, P_USHORT,
1019 &advanced_page.nntpport_spinbtn,
1020 prefs_set_data_from_spinbtn, prefs_set_spinbtn},
1022 {"set_domain", "FALSE", &tmp_ac_prefs.set_domain, P_BOOL,
1023 &advanced_page.domain_checkbtn,
1024 prefs_set_data_from_toggle, prefs_set_toggle},
1026 {"domain", NULL, &tmp_ac_prefs.domain, P_STRING,
1027 &advanced_page.domain_entry,
1028 prefs_set_data_from_entry, prefs_set_entry},
1030 #ifdef USE_GNUTLS
1031 {"gnutls_set_priority", "FALSE", &tmp_ac_prefs.set_gnutls_priority, P_BOOL,
1032 NULL, NULL, NULL},
1034 {"gnutls_priority", NULL, &tmp_ac_prefs.gnutls_priority, P_STRING,
1035 NULL, NULL, NULL},
1036 #endif
1038 #ifndef G_OS_WIN32
1039 {"set_tunnelcmd", "FALSE", &tmp_ac_prefs.set_tunnelcmd, P_BOOL,
1040 &advanced_page.tunnelcmd_checkbtn,
1041 prefs_set_data_from_toggle, prefs_set_toggle},
1043 {"tunnelcmd", NULL, &tmp_ac_prefs.tunnelcmd, P_STRING,
1044 &advanced_page.tunnelcmd_entry,
1045 prefs_set_data_from_entry, prefs_set_entry},
1046 #endif
1047 {"mark_crosspost_read", "FALSE", &tmp_ac_prefs.mark_crosspost_read, P_BOOL,
1048 &advanced_page.crosspost_checkbtn,
1049 prefs_set_data_from_toggle, prefs_set_toggle},
1051 {"crosspost_color", NULL, &tmp_ac_prefs.crosspost_col, P_ENUM,
1052 &advanced_page.crosspost_colormenu,
1053 prefs_account_crosspost_set_data_from_colormenu,
1054 prefs_account_crosspost_set_colormenu},
1056 {"set_sent_folder", "FALSE", &tmp_ac_prefs.set_sent_folder, P_BOOL,
1057 &advanced_page.sent_folder_checkbtn,
1058 prefs_set_data_from_toggle, prefs_set_toggle},
1059 {"sent_folder", NULL, &tmp_ac_prefs.sent_folder, P_STRING,
1060 &advanced_page.sent_folder_entry,
1061 prefs_set_data_from_entry, prefs_set_entry},
1063 {"set_queue_folder", "FALSE", &tmp_ac_prefs.set_queue_folder, P_BOOL,
1064 &advanced_page.queue_folder_checkbtn,
1065 prefs_set_data_from_toggle, prefs_set_toggle},
1066 {"queue_folder", NULL, &tmp_ac_prefs.queue_folder, P_STRING,
1067 &advanced_page.queue_folder_entry,
1068 prefs_set_data_from_entry, prefs_set_entry},
1070 {"set_draft_folder", "FALSE", &tmp_ac_prefs.set_draft_folder, P_BOOL,
1071 &advanced_page.draft_folder_checkbtn,
1072 prefs_set_data_from_toggle, prefs_set_toggle},
1073 {"draft_folder", NULL, &tmp_ac_prefs.draft_folder, P_STRING,
1074 &advanced_page.draft_folder_entry,
1075 prefs_set_data_from_entry, prefs_set_entry},
1077 {"set_trash_folder", "FALSE", &tmp_ac_prefs.set_trash_folder, P_BOOL,
1078 &advanced_page.trash_folder_checkbtn,
1079 prefs_set_data_from_toggle, prefs_set_toggle},
1080 {"trash_folder", NULL, &tmp_ac_prefs.trash_folder, P_STRING,
1081 &advanced_page.trash_folder_entry,
1082 prefs_set_data_from_entry, prefs_set_entry},
1085 {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
1088 static gint prefs_account_get_new_id (void);
1090 static void prefs_account_select_folder_cb (GtkWidget *widget, gpointer data);
1092 static void prefs_account_sigfile_radiobtn_cb (GtkWidget *widget, gpointer data);
1094 static void prefs_account_sigcmd_radiobtn_cb (GtkWidget *widget, gpointer data);
1096 static void prefs_account_signature_browse_cb (GtkWidget *widget, gpointer data);
1097 #ifdef USE_GNUTLS
1098 static void prefs_account_in_cert_browse_cb (GtkWidget *widget, gpointer data);
1100 static void prefs_account_out_cert_browse_cb (GtkWidget *widget, gpointer data);
1101 #endif
1102 static void prefs_account_signature_edit_cb (GtkWidget *widget, gpointer data);
1104 static void pop_bfr_smtp_tm_set_sens (GtkWidget *widget, gpointer data);
1106 #if (defined USE_GNUTLS)
1107 static void auto_configure_cb (GtkWidget *widget, gpointer data);
1109 #endif
1110 static void prefs_account_edit_custom_header (void);
1112 static void prefs_account_receive_itv_spinbutton_value_changed_cb(GtkWidget *w, gpointer data);
1114 #define COMBOBOX_PRIVACY_PLUGIN_ID 3
1116 /* Enable/disable necessary preference widgets based on current privacy
1117 * system choice. */
1118 static void privacy_system_activated(GtkWidget *combobox)
1120 gtk_widget_set_sensitive (privacy_page.save_clear_text_checkbtn,
1121 !gtk_toggle_button_get_active(
1122 GTK_TOGGLE_BUTTON(privacy_page.encrypt_to_self_checkbtn)));
1125 /* Populate the privacy system choice combobox with valid choices */
1126 static void update_privacy_system_menu() {
1127 GtkListStore *menu;
1128 GtkTreeIter iter;
1129 GSList *system_ids, *cur;
1131 menu = GTK_LIST_STORE(gtk_combo_box_get_model(
1132 GTK_COMBO_BOX(privacy_page.default_privacy_system)));
1134 /* First add "None", as that one is always available. :) */
1135 gtk_list_store_append(menu, &iter);
1136 gtk_list_store_set(menu, &iter,
1137 COMBOBOX_TEXT, _("None"),
1138 COMBOBOX_DATA, 0,
1139 COMBOBOX_SENS, TRUE,
1140 COMBOBOX_PRIVACY_PLUGIN_ID, "",
1141 -1);
1143 /* Now go through list of available privacy systems and add an entry
1144 * for each. */
1145 system_ids = privacy_get_system_ids();
1146 for (cur = system_ids; cur != NULL; cur = g_slist_next(cur)) {
1147 gchar *id = (gchar *) cur->data;
1148 const gchar *name;
1150 name = privacy_system_get_name(id);
1151 gtk_list_store_append(menu, &iter);
1152 gtk_list_store_set(menu, &iter,
1153 COMBOBOX_TEXT, name,
1154 COMBOBOX_DATA, 1,
1155 COMBOBOX_SENS, TRUE,
1156 COMBOBOX_PRIVACY_PLUGIN_ID, id,
1157 -1);
1158 g_free(id);
1160 g_slist_free(system_ids);
1164 #define TABLE_YPAD 2
1166 static void basic_create_widget_func(PrefsPage * _page,
1167 GtkWindow * window,
1168 gpointer data)
1170 BasicPage *page = (BasicPage *) _page;
1171 PrefsAccount *ac_prefs = (PrefsAccount *) data;
1173 GtkWidget *vbox1;
1174 GtkWidget *hbox;
1175 GtkWidget *label;
1176 GtkWidget *acname_entry;
1177 GtkWidget *default_checkbtn;
1178 GtkWidget *frame1;
1179 GtkWidget *table1;
1180 GtkWidget *name_entry;
1181 GtkWidget *addr_entry;
1182 GtkWidget *org_entry;
1184 GtkWidget *serv_frame;
1185 GtkWidget *vbox2;
1186 GtkWidget *optmenubox;
1187 GtkWidget *optmenu;
1188 GtkWidget *optlabel;
1189 GtkWidget *no_imap_warn_icon;
1190 GtkWidget *no_imap_warn_label;
1191 GtkWidget *serv_table;
1192 GtkWidget *recvserv_label;
1193 GtkWidget *smtpserv_label;
1194 GtkWidget *nntpserv_label;
1195 GtkWidget *localmbox_label;
1196 GtkWidget *mailcmd_label;
1197 GtkWidget *recvserv_entry;
1198 GtkWidget *smtpserv_entry;
1199 GtkWidget *nntpserv_entry;
1200 GtkWidget *nntpauth_checkbtn;
1201 GtkWidget *nntpauth_onconnect_checkbtn;
1202 GtkWidget *localmbox_entry;
1203 GtkWidget *mailcmd_checkbtn;
1204 GtkWidget *mailcmd_entry;
1205 GtkWidget *uid_label;
1206 GtkWidget *pass_label;
1207 GtkWidget *uid_entry;
1208 GtkWidget *pass_entry;
1209 GtkWidget *auto_configure_btn;
1210 GtkWidget *auto_configure_cancel_btn;
1211 GtkWidget *auto_configure_lbl;
1212 GtkWidget *showpwd_checkbtn;
1213 GtkListStore *menu;
1214 GtkTreeIter iter;
1215 gchar *buf;
1217 struct BasicProtocol *protocol_optmenu;
1218 gint i;
1220 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
1221 gtk_widget_show (vbox1);
1222 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1224 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
1225 gtk_widget_show (hbox);
1226 gtk_box_pack_start (GTK_BOX (vbox1), hbox, FALSE, FALSE, 0);
1228 label = gtk_label_new (_("Name of account"));
1229 gtk_widget_show (label);
1230 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1232 acname_entry = gtk_entry_new ();
1233 gtk_widget_show (acname_entry);
1234 gtk_widget_set_size_request (acname_entry, DEFAULT_ENTRY_WIDTH, -1);
1235 gtk_box_pack_start (GTK_BOX (hbox), acname_entry, TRUE, TRUE, 0);
1237 default_checkbtn = gtk_check_button_new_with_label (_("Set as default"));
1238 gtk_widget_show (default_checkbtn);
1239 #ifndef GENERIC_UMPC
1240 gtk_box_pack_end (GTK_BOX (hbox), default_checkbtn, TRUE, FALSE, 0);
1241 #else
1242 gtk_box_pack_start (GTK_BOX (vbox1), default_checkbtn, FALSE, FALSE, 0);
1244 #endif
1245 PACK_FRAME (vbox1, frame1, _("Personal information"));
1247 table1 = gtk_grid_new();
1248 gtk_widget_show (table1);
1249 gtk_container_add (GTK_CONTAINER (frame1), table1);
1250 gtk_container_set_border_width (GTK_CONTAINER (table1), 8);
1251 gtk_grid_set_row_spacing(GTK_GRID(table1), VSPACING_NARROW);
1252 gtk_grid_set_column_spacing(GTK_GRID(table1), 8);
1254 label = gtk_label_new (_("Full name"));
1255 gtk_widget_show (label);
1256 gtk_label_set_xalign(GTK_LABEL (label), 1.0);
1257 gtk_grid_attach(GTK_GRID(table1), label, 0, 0, 1, 1);
1259 label = gtk_label_new (_("Mail address"));
1260 gtk_widget_show (label);
1261 gtk_label_set_xalign(GTK_LABEL (label), 1.0);
1262 gtk_grid_attach(GTK_GRID(table1), label, 0, 1, 1, 1);
1264 label = gtk_label_new (_("Organization"));
1265 gtk_widget_show (label);
1266 gtk_label_set_xalign(GTK_LABEL (label), 1.0);
1267 gtk_grid_attach(GTK_GRID(table1), label, 0, 2, 1, 1);
1269 name_entry = gtk_entry_new ();
1270 gtk_widget_show (name_entry);
1271 gtk_grid_attach(GTK_GRID(table1), name_entry, 1, 0, 1, 1);
1272 gtk_widget_set_hexpand(name_entry, TRUE);
1273 gtk_widget_set_halign(name_entry, GTK_ALIGN_FILL);
1275 addr_entry = gtk_entry_new ();
1276 gtk_widget_show (addr_entry);
1277 gtk_grid_attach(GTK_GRID(table1), addr_entry, 1, 1, 1, 1);
1278 gtk_widget_set_hexpand(addr_entry, TRUE);
1279 gtk_widget_set_halign(addr_entry, GTK_ALIGN_FILL);
1281 org_entry = gtk_entry_new ();
1282 gtk_widget_show (org_entry);
1283 gtk_grid_attach(GTK_GRID(table1), org_entry, 1, 2, 1, 1);
1284 gtk_widget_set_hexpand(org_entry, TRUE);
1285 gtk_widget_set_halign(org_entry, GTK_ALIGN_FILL);
1287 vbox2 = gtkut_get_options_frame(vbox1, &serv_frame, _("Server information"));
1289 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
1290 gtk_widget_show (hbox);
1291 gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1293 label = gtk_label_new (_("Protocol"));
1294 gtk_widget_show (label);
1295 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1297 /* Create GtkHBox for protocol combobox and label */
1298 optmenubox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 20);
1299 gtk_widget_show(optmenubox);
1300 gtk_box_pack_start (GTK_BOX (hbox), optmenubox, FALSE, FALSE, 0);
1302 /* Create and populate the combobox */
1303 optmenu = gtkut_sc_combobox_create(NULL, FALSE);
1304 gtk_box_pack_start(GTK_BOX (optmenubox), optmenu, FALSE, FALSE, 0);
1306 menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu)));
1307 for( i = 0; i < NUM_RECV_PROTOCOLS; i++ )
1308 if( protocol_names[i] != NULL )
1309 COMBOBOX_ADD (menu, _(protocol_names[i]), i);
1311 g_signal_connect(G_OBJECT(optmenu), "changed",
1312 G_CALLBACK(prefs_account_protocol_changed), NULL);
1314 /* Create protocol label, empty for now */
1315 optlabel = gtk_label_new("");
1316 gtk_label_set_use_markup(GTK_LABEL(optlabel), TRUE);
1317 gtk_label_set_justify(GTK_LABEL(optlabel), GTK_JUSTIFY_CENTER);
1318 gtk_box_pack_start(GTK_BOX (optmenubox), optlabel, FALSE, FALSE, 0);
1320 auto_configure_btn = gtk_button_new_with_label(_("Auto-configure"));
1321 gtk_box_pack_start(GTK_BOX (optmenubox), auto_configure_btn, FALSE, FALSE, 0);
1322 auto_configure_cancel_btn = gtk_button_new_with_label(_("Cancel"));
1323 gtk_box_pack_start(GTK_BOX (optmenubox), auto_configure_cancel_btn, FALSE, FALSE, 0);
1324 auto_configure_lbl = gtk_label_new("");
1325 gtk_label_set_justify(GTK_LABEL(auto_configure_lbl), GTK_JUSTIFY_LEFT);
1326 gtk_box_pack_start(GTK_BOX (optmenubox), auto_configure_lbl, FALSE, FALSE, 0);
1327 #if (defined USE_GNUTLS)
1328 gtk_widget_show(auto_configure_btn);
1329 gtk_widget_show(auto_configure_lbl);
1330 g_signal_connect (G_OBJECT (auto_configure_btn), "clicked",
1331 G_CALLBACK (auto_configure_cb), NULL);
1332 g_signal_connect (G_OBJECT (auto_configure_cancel_btn), "clicked",
1333 G_CALLBACK (auto_configure_cb), NULL);
1334 #endif
1336 no_imap_warn_icon = gtk_image_new_from_icon_name
1337 ("dialog-warning", GTK_ICON_SIZE_SMALL_TOOLBAR);
1338 buf = g_strconcat("<span weight=\"bold\">",
1339 _("Warning: this version of Claws Mail\n"
1340 "has been built without IMAP and News support."), "</span>", NULL);
1341 no_imap_warn_label = gtk_label_new(buf);
1342 g_free(buf);
1343 gtk_label_set_use_markup(GTK_LABEL(no_imap_warn_label), TRUE);
1345 gtk_box_pack_start(GTK_BOX (optmenubox), no_imap_warn_icon, FALSE, FALSE, 0);
1346 gtk_box_pack_start(GTK_BOX (optmenubox), no_imap_warn_label, FALSE, FALSE, 0);
1347 /* Set up a struct to store pointers to necessary widgets */
1348 protocol_optmenu = g_new(struct BasicProtocol, 1);
1349 protocol_optmenu->combobox = optmenu;
1350 protocol_optmenu->label = optlabel;
1351 protocol_optmenu->descrlabel = label;
1352 protocol_optmenu->no_imap_warn_icon = no_imap_warn_icon;
1353 protocol_optmenu->no_imap_warn_label = no_imap_warn_label;
1355 serv_table = gtk_grid_new ();
1356 gtk_widget_show (serv_table);
1357 gtk_grid_set_row_spacing(GTK_GRID(serv_table), VSPACING_NARROW);
1358 gtk_grid_set_column_spacing(GTK_GRID(serv_table), 8);
1359 gtk_box_pack_start (GTK_BOX (vbox2), serv_table, FALSE, FALSE, 0);
1361 nntpserv_entry = gtk_entry_new ();
1362 gtk_widget_show (nntpserv_entry);
1363 gtk_grid_attach(GTK_GRID(serv_table), nntpserv_entry, 1, 0, 2, 1);
1364 gtk_widget_set_hexpand(nntpserv_entry, TRUE);
1365 gtk_widget_set_halign(nntpserv_entry, GTK_ALIGN_FILL);
1367 nntpauth_checkbtn = gtk_check_button_new_with_label
1368 (_("This server requires authentication"));
1369 gtk_widget_show (nntpauth_checkbtn);
1371 gtk_grid_attach(GTK_GRID(serv_table), nntpauth_checkbtn, 0, 6, 2, 1);
1373 nntpauth_onconnect_checkbtn = gtk_check_button_new_with_label
1374 (_("Authenticate on connect"));
1375 gtk_widget_show (nntpauth_onconnect_checkbtn);
1377 gtk_grid_attach(GTK_GRID(serv_table), nntpauth_onconnect_checkbtn, 2, 6, 1, 1);
1379 recvserv_entry = gtk_entry_new ();
1380 gtk_widget_show (recvserv_entry);
1381 gtk_grid_attach(GTK_GRID(serv_table), recvserv_entry, 1, 2, 2, 1);
1382 gtk_widget_set_hexpand(recvserv_entry, TRUE);
1383 gtk_widget_set_halign(recvserv_entry, GTK_ALIGN_FILL);
1385 localmbox_entry = gtk_entry_new ();
1386 gtk_widget_show (localmbox_entry);
1387 gtk_grid_attach(GTK_GRID(serv_table), localmbox_entry, 1, 3, 2, 1);
1388 gtk_widget_set_hexpand(localmbox_entry, TRUE);
1389 gtk_widget_set_halign(localmbox_entry, GTK_ALIGN_FILL);
1391 smtpserv_entry = gtk_entry_new ();
1392 gtk_widget_show (smtpserv_entry);
1393 gtk_grid_attach(GTK_GRID(serv_table), smtpserv_entry, 1, 4, 2, 1);
1394 gtk_widget_set_hexpand(smtpserv_entry, TRUE);
1395 gtk_widget_set_halign(smtpserv_entry, GTK_ALIGN_FILL);
1397 mailcmd_entry = gtk_entry_new ();
1398 gtk_widget_show (mailcmd_entry);
1399 gtk_grid_attach(GTK_GRID(serv_table), mailcmd_entry, 1, 6, 2, 1);
1400 gtk_widget_set_hexpand(mailcmd_entry, TRUE);
1401 gtk_widget_set_halign(mailcmd_entry, GTK_ALIGN_FILL);
1403 uid_entry = gtk_entry_new ();
1404 gtk_widget_show (uid_entry);
1405 gtk_widget_set_size_request (uid_entry, DEFAULT_ENTRY_WIDTH, -1);
1406 gtk_grid_attach(GTK_GRID(serv_table), uid_entry, 1, 7, 1, 1);
1407 gtk_widget_set_hexpand(uid_entry, TRUE);
1408 gtk_widget_set_halign(uid_entry, GTK_ALIGN_FILL);
1409 g_signal_connect(G_OBJECT(uid_entry), "changed",
1410 G_CALLBACK(prefs_account_entry_changed_newline_check_cb),
1411 GINT_TO_POINTER(ac_prefs->protocol));
1413 pass_entry = gtk_entry_new ();
1414 gtk_widget_show (pass_entry);
1415 gtk_widget_set_size_request (pass_entry, DEFAULT_ENTRY_WIDTH, -1);
1416 gtk_grid_attach(GTK_GRID(serv_table), pass_entry, 1, 8, 1, 1);
1417 gtk_widget_set_hexpand(pass_entry, TRUE);
1418 gtk_widget_set_halign(pass_entry, GTK_ALIGN_FILL);
1419 gtk_entry_set_visibility (GTK_ENTRY (pass_entry), FALSE);
1420 g_signal_connect(G_OBJECT(pass_entry), "changed",
1421 G_CALLBACK(prefs_account_entry_changed_newline_check_cb),
1422 GINT_TO_POINTER(ac_prefs->protocol));
1424 nntpserv_label = gtk_label_new (_("News server"));
1425 gtk_widget_show (nntpserv_label);
1426 gtk_label_set_xalign(GTK_LABEL (nntpserv_label), 1.0);
1427 gtk_grid_attach(GTK_GRID(serv_table), nntpserv_label, 0, 0, 1, 1);
1429 recvserv_label = gtk_label_new (_("Server for receiving"));
1430 gtk_widget_show (recvserv_label);
1431 gtk_label_set_xalign(GTK_LABEL (recvserv_label), 1.0);
1432 gtk_grid_attach(GTK_GRID(serv_table), recvserv_label, 0, 2, 1, 1);
1434 localmbox_label = gtk_label_new (_("Local mailbox"));
1435 gtk_widget_show (localmbox_label);
1436 gtk_label_set_xalign(GTK_LABEL (localmbox_label), 1.0);
1437 gtk_grid_attach(GTK_GRID(serv_table), localmbox_label, 0, 3, 1, 1);
1439 smtpserv_label = gtk_label_new (_("SMTP server (send)"));
1440 gtk_widget_show (smtpserv_label);
1441 gtk_label_set_xalign(GTK_LABEL (smtpserv_label), 1.0);
1442 gtk_grid_attach(GTK_GRID(serv_table), smtpserv_label, 0, 4, 1, 1);
1444 mailcmd_checkbtn = gtk_check_button_new_with_label
1445 (_("Use mail command rather than SMTP server"));
1446 gtk_widget_show (mailcmd_checkbtn);
1447 gtk_grid_attach(GTK_GRID(serv_table), mailcmd_checkbtn, 0, 5, 2, 1);
1449 g_signal_connect(G_OBJECT(mailcmd_checkbtn), "toggled",
1450 G_CALLBACK(prefs_account_mailcmd_toggled),
1451 NULL);
1453 mailcmd_label = gtk_label_new (_("command to send mails"));
1454 gtk_widget_show (mailcmd_label);
1455 gtk_label_set_xalign(GTK_LABEL (mailcmd_label), 1.0);
1456 gtk_grid_attach(GTK_GRID(serv_table), mailcmd_label, 0, 6, 1, 1);
1458 uid_label = gtk_label_new (_("User ID"));
1459 gtk_widget_show (uid_label);
1460 gtk_label_set_xalign(GTK_LABEL (uid_label), 1.0);
1461 gtk_grid_attach(GTK_GRID(serv_table), uid_label, 0, 7, 1, 1);
1463 pass_label = gtk_label_new (_("Password"));
1464 gtk_widget_show (pass_label);
1465 #ifdef GENERIC_UMPC
1466 gtk_label_set_xalign(GTK_LABEL (pass_label), 1.0);
1467 #endif
1468 gtk_grid_attach(GTK_GRID(serv_table), pass_label, 0, 8, 1, 1);
1470 showpwd_checkbtn = gtk_check_button_new_with_label (_("Show password"));
1471 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn), FALSE);
1472 gtk_widget_show(showpwd_checkbtn);
1473 gtk_grid_attach(GTK_GRID(serv_table), showpwd_checkbtn, 2, 8, 1, 1);
1474 g_signal_connect(G_OBJECT(showpwd_checkbtn), "toggled",
1475 G_CALLBACK(prefs_account_showpwd_checkbtn_toggled), pass_entry);
1477 SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, uid_label);
1478 SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, pass_label);
1479 SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, uid_entry);
1480 SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, pass_entry);
1481 SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, showpwd_checkbtn);
1482 SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, nntpauth_onconnect_checkbtn);
1484 page->acname_entry = acname_entry;
1485 page->default_checkbtn = default_checkbtn;
1487 page->name_entry = name_entry;
1488 page->addr_entry = addr_entry;
1489 page->org_entry = org_entry;
1491 page->serv_frame = serv_frame;
1492 page->serv_table = serv_table;
1493 page->protocol_optmenu = (gpointer)protocol_optmenu;
1494 page->recvserv_label = recvserv_label;
1495 page->recvserv_entry = recvserv_entry;
1496 page->smtpserv_label = smtpserv_label;
1497 page->smtpserv_entry = smtpserv_entry;
1498 page->nntpserv_label = nntpserv_label;
1499 page->nntpserv_entry = nntpserv_entry;
1500 page->nntpauth_checkbtn = nntpauth_checkbtn;
1501 page->nntpauth_onconnect_checkbtn = nntpauth_onconnect_checkbtn;
1502 page->localmbox_label = localmbox_label;
1503 page->localmbox_entry = localmbox_entry;
1504 page->mailcmd_checkbtn = mailcmd_checkbtn;
1505 page->mailcmd_label = mailcmd_label;
1506 page->mailcmd_entry = mailcmd_entry;
1507 page->uid_label = uid_label;
1508 page->pass_label = pass_label;
1509 page->uid_entry = uid_entry;
1510 page->pass_entry = pass_entry;
1511 page->showpwd_checkbtn = showpwd_checkbtn;
1512 page->auto_configure_btn = auto_configure_btn;
1513 page->auto_configure_cancel_btn = auto_configure_cancel_btn;
1514 page->auto_configure_lbl = auto_configure_lbl;
1516 if (new_account) {
1517 prefs_set_dialog_to_default(basic_param);
1518 buf = g_strdup_printf(_("Account%d"), ac_prefs->account_id);
1519 gtk_entry_set_text(GTK_ENTRY(basic_page.acname_entry), buf);
1520 g_free(buf);
1521 } else {
1522 prefs_set_dialog(basic_param);
1524 /* Passwords are handled outside of PrefParams. */
1525 buf = passwd_store_get_account(ac_prefs->account_id,
1526 PWS_ACCOUNT_RECV);
1527 gtk_entry_set_text(GTK_ENTRY(page->pass_entry), buf != NULL ? buf : "");
1528 if (buf != NULL) {
1529 memset(buf, 0, strlen(buf));
1530 g_free(buf);
1534 page->vbox = vbox1;
1536 page->page.widget = vbox1;
1539 static void receive_create_widget_func(PrefsPage * _page,
1540 GtkWindow * window,
1541 gpointer data)
1543 ReceivePage *page = (ReceivePage *) _page;
1544 PrefsAccount *ac_prefs = (PrefsAccount *) data;
1546 GtkWidget *vbox1, *vbox2, *vbox3, *vbox4, *vbox5;
1547 GtkWidget *hbox1, *hbox2, *hbox3;
1548 GtkWidget *frame1;
1549 GtkWidget *pop_auth_checkbtn;
1550 GtkWidget *rmmail_checkbtn;
1551 GtkWidget *hbox_spc;
1552 GtkWidget *leave_time_label;
1553 GtkWidget *leave_time_spinbtn;
1554 GtkWidget *leave_hour_label;
1555 GtkWidget *leave_hour_spinbtn;
1556 GtkWidget *size_limit_checkbtn;
1557 GtkWidget *size_limit_spinbtn;
1558 GtkWidget *label;
1559 GtkWidget *filter_on_recv_checkbtn;
1560 GtkWidget *filterhook_on_recv_checkbtn;
1561 GtkWidget *inbox_label;
1562 GtkWidget *inbox_entry;
1563 GtkWidget *inbox_btn;
1564 GtkWidget *imap_frame;
1565 GtkWidget *imapdir_label;
1566 GtkWidget *imapdir_entry;
1567 GtkWidget *subsonly_checkbtn;
1568 GtkWidget *low_bandwidth_checkbtn;
1569 GtkWidget *local_frame;
1570 GtkWidget *local_vbox;
1571 GtkWidget *local_hbox;
1572 GtkWidget *local_inbox_label;
1573 GtkWidget *local_inbox_entry;
1574 GtkWidget *local_inbox_btn;
1575 GtkWidget *autochk_checkbtn;
1576 GtkWidget *autochk_hour_spinbtn, *autochk_hour_label;
1577 GtkWidget *autochk_min_spinbtn, *autochk_min_label;
1578 GtkWidget *autochk_sec_spinbtn, *autochk_sec_label;
1579 GtkWidget *autochk_use_default_checkbtn;
1580 GtkAdjustment *adj;
1581 struct AutocheckWidgets *autochk_widgets;
1583 GtkWidget *optmenu, *optmenu2;
1584 GtkListStore *menu, *menu2;
1585 GtkTreeIter iter;
1586 GtkWidget *recvatgetall_checkbtn;
1588 GtkWidget *frame, *frame2;
1589 GtkWidget *maxarticle_label;
1590 GtkWidget *maxarticle_spinbtn;
1591 GtkAdjustment *maxarticle_spinbtn_adj;
1593 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
1594 gtk_widget_show (vbox1);
1595 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1597 local_vbox = gtkut_get_options_frame(vbox1, &local_frame, _("Local"));
1599 local_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
1600 gtk_widget_show (local_hbox);
1601 gtk_box_pack_start (GTK_BOX (local_vbox), local_hbox, TRUE, TRUE, 0);
1603 local_inbox_label = gtk_label_new (_("Default Inbox"));
1604 gtk_widget_show (local_inbox_label);
1605 gtk_box_pack_start (GTK_BOX (local_hbox), local_inbox_label, FALSE, FALSE, 0);
1607 local_inbox_entry = gtk_entry_new ();
1608 gtk_widget_show (local_inbox_entry);
1609 CLAWS_SET_TIP(local_inbox_entry,
1610 _("Unfiltered messages will be stored in this folder"));
1611 gtk_box_pack_start (GTK_BOX (local_hbox), local_inbox_entry, TRUE, TRUE, 0);
1613 local_inbox_btn = gtkut_get_browse_file_btn(_("Bro_wse"));
1614 gtk_widget_show (local_inbox_btn);
1615 CLAWS_SET_TIP(local_inbox_btn,
1616 _("Unfiltered messages will be stored in this folder"));
1617 gtk_box_pack_start (GTK_BOX (local_hbox), local_inbox_btn, FALSE, FALSE, 0);
1618 g_signal_connect (G_OBJECT (local_inbox_btn), "clicked",
1619 G_CALLBACK (prefs_account_select_folder_cb),
1620 local_inbox_entry);
1622 vbox2 = gtkut_get_options_frame(vbox1, &frame1, _("POP"));
1624 PACK_CHECK_BUTTON (vbox2, pop_auth_checkbtn,
1625 _("Authenticate before POP connection"));
1627 //vbox5 = gtk_vbox_new (FALSE, 0);
1628 vbox5 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
1629 gtk_widget_show (vbox5);
1630 gtk_box_pack_start (GTK_BOX (vbox2), vbox5, FALSE, FALSE, 0);
1632 hbox3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
1633 gtk_widget_show (hbox3);
1634 gtk_box_pack_start (GTK_BOX (vbox5), hbox3, FALSE, FALSE, 0);
1636 hbox_spc = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
1637 gtk_widget_show (hbox_spc);
1638 gtk_box_pack_start (GTK_BOX (hbox3), hbox_spc, FALSE, FALSE, 0);
1639 gtk_widget_set_size_request (hbox_spc, 12, -1);
1641 label = gtk_label_new (_("Authentication method"));
1642 gtk_widget_show (label);
1643 gtk_box_pack_start (GTK_BOX (hbox3), label, FALSE, FALSE, 0);
1645 optmenu2 = gtkut_sc_combobox_create(NULL, FALSE);
1646 menu2 = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu2)));
1647 gtk_widget_show (optmenu2);
1648 gtk_box_pack_start (GTK_BOX (hbox3), optmenu2, FALSE, FALSE, 0);
1650 COMBOBOX_ADD (menu2, _("Select"), 0);
1651 COMBOBOX_ADD (menu2, NULL, 0);
1652 COMBOBOX_ADD (menu2, "APOP", POPAUTH_APOP);
1653 COMBOBOX_ADD (menu2, "OAuth2", POPAUTH_OAUTH2);
1654 #ifndef USE_OAUTH2
1655 gtk_list_store_set(menu2, &iter, COMBOBOX_SENS, FALSE, -1);
1656 #endif
1658 SET_TOGGLE_SENSITIVITY (pop_auth_checkbtn, vbox5);
1660 PACK_CHECK_BUTTON (vbox2, rmmail_checkbtn,
1661 _("Remove messages on server when received"));
1663 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
1664 gtk_widget_show (hbox1);
1665 gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1667 hbox_spc = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
1668 gtk_widget_show (hbox_spc);
1669 gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
1670 gtk_widget_set_size_request (hbox_spc, 12, -1);
1672 leave_time_label = gtk_label_new (_("Remove after"));
1673 gtk_widget_show (leave_time_label);
1674 gtk_box_pack_start (GTK_BOX (hbox1), leave_time_label, FALSE, FALSE, 0);
1676 leave_time_spinbtn = gtk_spin_button_new_with_range(0, 365, 1);
1677 gtk_widget_show (leave_time_spinbtn);
1678 CLAWS_SET_TIP(leave_time_spinbtn,
1679 _("0 days and 0 hours : remove immediately"));
1680 gtk_box_pack_start (GTK_BOX (hbox1), leave_time_spinbtn, FALSE, FALSE, 0);
1682 leave_time_label = gtk_label_new (_("days"));
1683 gtk_widget_show (leave_time_label);
1684 gtk_box_pack_start (GTK_BOX (hbox1), leave_time_label, FALSE, FALSE, 0);
1686 leave_hour_spinbtn = gtk_spin_button_new_with_range(0, 23, 1);
1687 gtk_widget_show (leave_hour_spinbtn);
1688 CLAWS_SET_TIP(leave_hour_spinbtn,
1689 _("0 days and 0 hours : remove immediately"));
1690 gtk_box_pack_start (GTK_BOX (hbox1), leave_hour_spinbtn, FALSE, FALSE, 0);
1692 leave_hour_label = gtk_label_new (_("hours"));
1693 gtk_widget_show (leave_hour_label);
1694 gtk_box_pack_start (GTK_BOX (hbox1), leave_hour_label, FALSE, FALSE, 0);
1696 SET_TOGGLE_SENSITIVITY (rmmail_checkbtn, hbox1);
1698 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
1699 gtk_widget_show (hbox1);
1700 gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1702 PACK_CHECK_BUTTON (hbox1, size_limit_checkbtn, _("Receive size limit"));
1704 CLAWS_SET_TIP(size_limit_checkbtn,
1705 _("Messages over this limit will be partially retrieved. "
1706 "When selecting them you will be able to download them fully "
1707 "or delete them."));
1709 size_limit_spinbtn = gtk_spin_button_new_with_range(0, 100000, 1);
1710 gtk_widget_show (size_limit_spinbtn);
1711 gtk_box_pack_start (GTK_BOX (hbox1), size_limit_spinbtn, FALSE, FALSE, 0);
1713 label = gtk_label_new (_("KiB"));
1714 gtk_widget_show (label);
1715 gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1717 SET_TOGGLE_SENSITIVITY (size_limit_checkbtn, size_limit_spinbtn);
1719 PACK_SPACER(vbox2, vbox3, VSPACING_NARROW_2);
1721 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
1722 gtk_widget_show (hbox1);
1723 gtk_box_pack_start (GTK_BOX (vbox2), hbox1, TRUE, TRUE, 0);
1725 inbox_label = gtk_label_new (_("Default Inbox"));
1726 gtk_widget_show (inbox_label);
1727 gtk_box_pack_start (GTK_BOX (hbox1), inbox_label, FALSE, FALSE, 0);
1729 inbox_entry = gtk_entry_new ();
1730 gtk_widget_show (inbox_entry);
1731 CLAWS_SET_TIP(inbox_entry,
1732 _("Unfiltered messages will be stored in this folder"));
1733 gtk_box_pack_start (GTK_BOX (hbox1), inbox_entry, TRUE, TRUE, 0);
1735 inbox_btn = gtkut_get_browse_file_btn(_("Bro_wse"));
1736 gtk_widget_show (inbox_btn);
1737 CLAWS_SET_TIP(inbox_btn,
1738 _("Unfiltered messages will be stored in this folder"));
1739 gtk_box_pack_start (GTK_BOX (hbox1), inbox_btn, FALSE, FALSE, 0);
1740 g_signal_connect (G_OBJECT (inbox_btn), "clicked",
1741 G_CALLBACK (prefs_account_select_folder_cb),
1742 inbox_entry);
1744 vbox2 = gtkut_get_options_frame(vbox1, &frame2, _("NNTP"));
1746 hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
1747 gtk_widget_show (hbox2);
1748 gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
1750 maxarticle_label = gtk_label_new
1751 (_("Maximum number of articles to download"));
1752 gtk_widget_show (maxarticle_label);
1753 gtk_box_pack_start (GTK_BOX (hbox2), maxarticle_label, FALSE, FALSE, 0);
1755 maxarticle_spinbtn_adj =
1756 GTK_ADJUSTMENT(gtk_adjustment_new (300, 0, 10000, 10, 100, 0));
1757 maxarticle_spinbtn = gtk_spin_button_new
1758 (GTK_ADJUSTMENT (maxarticle_spinbtn_adj), 10, 0);
1759 gtk_widget_show (maxarticle_spinbtn);
1760 CLAWS_SET_TIP(maxarticle_spinbtn,
1761 _("unlimited if 0 is specified"));
1762 gtk_box_pack_start (GTK_BOX (hbox2), maxarticle_spinbtn,
1763 FALSE, FALSE, 0);
1764 gtk_widget_set_size_request (maxarticle_spinbtn, 64, -1);
1765 gtk_spin_button_set_numeric
1766 (GTK_SPIN_BUTTON (maxarticle_spinbtn), TRUE);
1768 vbox2 = gtkut_get_options_frame(vbox1, &imap_frame, _("IMAP"));
1770 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
1771 gtk_widget_show (hbox1);
1772 gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1774 label = gtk_label_new (_("Authentication method"));
1775 gtk_widget_show (label);
1776 gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1779 optmenu = gtkut_sc_combobox_create(NULL, FALSE);
1780 menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu)));
1781 gtk_widget_show (optmenu);
1782 gtk_box_pack_start (GTK_BOX (hbox1), optmenu, FALSE, FALSE, 0);
1784 COMBOBOX_ADD (menu, _("Automatic"), 0);
1785 COMBOBOX_ADD (menu, NULL, 0);
1786 COMBOBOX_ADD (menu, _("Plain text"), IMAP_AUTH_PLAINTEXT);
1787 COMBOBOX_ADD (menu, "CRAM-MD5", IMAP_AUTH_CRAM_MD5);
1788 COMBOBOX_ADD (menu, "ANONYMOUS", IMAP_AUTH_ANON);
1789 COMBOBOX_ADD (menu, "GSSAPI", IMAP_AUTH_GSSAPI);
1790 COMBOBOX_ADD (menu, "DIGEST-MD5", IMAP_AUTH_DIGEST_MD5);
1791 COMBOBOX_ADD (menu, "SCRAM-SHA-1", IMAP_AUTH_SCRAM_SHA1);
1792 COMBOBOX_ADD (menu, "PLAIN", IMAP_AUTH_PLAIN);
1793 COMBOBOX_ADD (menu, "LOGIN", IMAP_AUTH_LOGIN);
1794 COMBOBOX_ADD (menu, "OAUTH2", IMAP_AUTH_OAUTH2);
1795 #ifndef USE_OAUTH2
1796 gtk_list_store_set(menu, &iter, COMBOBOX_SENS, FALSE, -1);
1797 #endif
1799 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
1800 gtk_widget_show (hbox1);
1801 gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 4);
1803 imapdir_label = gtk_label_new (_("IMAP server directory"));
1804 gtk_widget_show (imapdir_label);
1805 gtk_box_pack_start (GTK_BOX (hbox1), imapdir_label, FALSE, FALSE, 0);
1807 imapdir_label = gtk_label_new(_("(usually empty)"));
1808 gtk_widget_show (imapdir_label);
1809 gtkut_widget_set_small_font_size (imapdir_label);
1810 gtk_box_pack_start (GTK_BOX (hbox1), imapdir_label, FALSE, FALSE, 0);
1812 imapdir_entry = gtk_entry_new();
1813 gtk_widget_show (imapdir_entry);
1814 gtk_box_pack_start (GTK_BOX (hbox1), imapdir_entry, FALSE, FALSE, 0);
1816 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
1817 gtk_widget_show (hbox1);
1818 gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 4);
1820 PACK_CHECK_BUTTON (hbox1, subsonly_checkbtn,
1821 _("Show subscribed folders only"));
1823 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
1824 gtk_widget_show (hbox1);
1825 gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 4);
1827 PACK_CHECK_BUTTON (hbox1, low_bandwidth_checkbtn,
1828 _("Bandwidth-efficient mode (prevents retrieving remote tags)"));
1829 CLAWS_SET_TIP(low_bandwidth_checkbtn,
1830 _("This mode uses less bandwidth, but can be slower with some servers."));
1832 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
1833 gtk_widget_show (hbox1);
1834 gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 4);
1836 /* Auto-checking */
1837 vbox4 = gtkut_get_options_frame(vbox1, &frame, _("Automatic checking"));
1839 PACK_CHECK_BUTTON(vbox4, autochk_use_default_checkbtn,
1840 _("Use global settings"));
1842 hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
1843 gtk_box_pack_start(GTK_BOX(vbox4), hbox2, FALSE, FALSE, 0);
1845 PACK_CHECK_BUTTON(hbox2, autochk_checkbtn,
1846 _("Check for new mail every"));
1848 adj = gtk_adjustment_new(5, 0, 99, 1, 10, 0);
1849 autochk_hour_spinbtn = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1, 0);
1850 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(autochk_hour_spinbtn), TRUE);
1851 gtk_box_pack_start(GTK_BOX(hbox2), autochk_hour_spinbtn, FALSE, FALSE, 0);
1852 autochk_hour_label = gtk_label_new(_("hours"));
1853 gtk_box_pack_start(GTK_BOX(hbox2), autochk_hour_label, FALSE, FALSE, 0);
1855 adj = gtk_adjustment_new(5, 0, 99, 1, 10, 0);
1856 autochk_min_spinbtn = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1, 0);
1857 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(autochk_min_spinbtn), TRUE);
1858 gtk_box_pack_start(GTK_BOX(hbox2), autochk_min_spinbtn, FALSE, FALSE, 0);
1859 autochk_min_label = gtk_label_new(_("minutes"));
1860 gtk_box_pack_start(GTK_BOX(hbox2), autochk_min_label, FALSE, FALSE, 0);
1862 adj = gtk_adjustment_new(5, 0, 99, 1, 10, 0);
1863 autochk_sec_spinbtn = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1, 0);
1864 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(autochk_sec_spinbtn), TRUE);
1865 gtk_box_pack_start(GTK_BOX(hbox2), autochk_sec_spinbtn, FALSE, FALSE, 0);
1866 autochk_sec_label = gtk_label_new(_("seconds"));
1867 gtk_box_pack_start(GTK_BOX(hbox2), autochk_sec_label, FALSE, FALSE, 0);
1869 autochk_widgets = g_new0(struct AutocheckWidgets, 1);
1870 autochk_widgets->autochk_hour_spinbtn = autochk_hour_spinbtn;
1871 autochk_widgets->autochk_min_spinbtn = autochk_min_spinbtn;
1872 autochk_widgets->autochk_sec_spinbtn = autochk_sec_spinbtn;
1874 gtk_widget_show_all(vbox4);
1876 SET_TOGGLE_SENSITIVITY_REVERSE(autochk_use_default_checkbtn, hbox2);
1877 SET_TOGGLE_SENSITIVITY(autochk_checkbtn, autochk_hour_spinbtn);
1878 SET_TOGGLE_SENSITIVITY(autochk_checkbtn, autochk_min_spinbtn);
1879 SET_TOGGLE_SENSITIVITY(autochk_checkbtn, autochk_sec_spinbtn);
1880 SET_TOGGLE_SENSITIVITY(autochk_checkbtn, autochk_hour_label);
1881 SET_TOGGLE_SENSITIVITY(autochk_checkbtn, autochk_min_label);
1882 SET_TOGGLE_SENSITIVITY(autochk_checkbtn, autochk_sec_label);
1884 PACK_CHECK_BUTTON (vbox1, filter_on_recv_checkbtn,
1885 _("Filter messages on receiving"));
1887 g_signal_connect(G_OBJECT(filter_on_recv_checkbtn), "toggled",
1888 G_CALLBACK(prefs_account_filter_on_recv_toggled),
1889 NULL);
1890 g_signal_connect(G_OBJECT(autochk_hour_spinbtn), "value-changed",
1891 G_CALLBACK(prefs_account_receive_itv_spinbutton_value_changed_cb),
1892 (gpointer) page);
1893 g_signal_connect(G_OBJECT(autochk_min_spinbtn), "value-changed",
1894 G_CALLBACK(prefs_account_receive_itv_spinbutton_value_changed_cb),
1895 (gpointer) page);
1896 g_signal_connect(G_OBJECT(autochk_sec_spinbtn), "value-changed",
1897 G_CALLBACK(prefs_account_receive_itv_spinbutton_value_changed_cb),
1898 (gpointer) page);
1900 PACK_CHECK_BUTTON (vbox1, filterhook_on_recv_checkbtn,
1901 _("Allow filtering using plugins on receiving"));
1903 PACK_CHECK_BUTTON
1904 (vbox1, recvatgetall_checkbtn,
1905 _("'Get Mail' checks for new messages on this account"));
1907 page->pop3_frame = frame1;
1908 page->pop_auth_checkbtn = pop_auth_checkbtn;
1909 page->pop_auth_type_optmenu = optmenu2;
1910 page->rmmail_checkbtn = rmmail_checkbtn;
1911 page->leave_time_spinbtn = leave_time_spinbtn;
1912 page->leave_hour_spinbtn = leave_hour_spinbtn;
1913 page->size_limit_checkbtn = size_limit_checkbtn;
1914 page->size_limit_spinbtn = size_limit_spinbtn;
1915 page->filter_on_recv_checkbtn = filter_on_recv_checkbtn;
1916 page->filterhook_on_recv_checkbtn = filterhook_on_recv_checkbtn;
1917 page->inbox_label = inbox_label;
1918 page->inbox_entry = inbox_entry;
1919 page->inbox_btn = inbox_btn;
1921 page->autochk_frame = frame;
1923 page->imap_frame = imap_frame;
1924 page->imap_auth_type_optmenu = optmenu;
1926 page->imapdir_label = imapdir_label;
1927 page->imapdir_entry = imapdir_entry;
1928 page->subsonly_checkbtn = subsonly_checkbtn;
1929 page->low_bandwidth_checkbtn = low_bandwidth_checkbtn;
1930 page->local_frame = local_frame;
1931 page->local_inbox_label = local_inbox_label;
1932 page->local_inbox_entry = local_inbox_entry;
1933 page->local_inbox_btn = local_inbox_btn;
1935 page->recvatgetall_checkbtn = recvatgetall_checkbtn;
1937 page->frame_maxarticle = frame2;
1938 page->maxarticle_spinbtn = maxarticle_spinbtn;
1939 page->maxarticle_spinbtn_adj = maxarticle_spinbtn_adj;
1941 page->autochk_checkbtn = autochk_checkbtn;
1942 page->autochk_widgets = autochk_widgets;
1943 page->autochk_use_default_checkbtn = autochk_use_default_checkbtn;
1945 tmp_ac_prefs = *ac_prefs;
1947 if (new_account) {
1948 prefs_set_dialog_to_default(receive_param);
1949 } else
1950 prefs_set_dialog(receive_param);
1952 page->vbox = vbox1;
1954 page->page.widget = vbox1;
1957 static void send_create_widget_func(PrefsPage * _page,
1958 GtkWindow * window,
1959 gpointer data)
1961 SendPage *page = (SendPage *) _page;
1962 PrefsAccount *ac_prefs = (PrefsAccount *) data;
1964 GtkWidget *vbox1;
1965 GtkWidget *vbox2;
1966 GtkWidget *frame;
1967 GtkWidget *msgid_checkbtn;
1968 GtkWidget *xmailer_checkbtn;
1969 GtkWidget *hbox;
1970 GtkWidget *customhdr_checkbtn;
1971 GtkWidget *customhdr_edit_btn;
1972 GtkWidget *checkbtn_msgid_with_addr;
1973 GtkWidget *vbox3;
1974 GtkWidget *smtp_auth_checkbtn;
1975 GtkWidget *showpwd_checkbtn;
1976 GtkWidget *optmenu;
1977 GtkListStore *menu;
1978 GtkTreeIter iter;
1979 GtkWidget *vbox4;
1980 GtkWidget *hbox_spc;
1981 GtkWidget *label;
1982 GtkWidget *smtp_uid_entry;
1983 GtkWidget *smtp_pass_entry;
1984 GtkWidget *vbox_spc;
1985 GtkWidget *pop_bfr_smtp_checkbtn;
1986 GtkWidget *pop_bfr_smtp_tm_spinbtn;
1987 GtkWidget *pop_auth_timeout_lbl;
1988 GtkWidget *pop_auth_minutes_lbl;
1989 gchar *buf;
1991 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
1992 gtk_widget_show (vbox1);
1993 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1995 vbox2 = gtkut_get_options_frame(vbox1, &frame, _("Header"));
1997 PACK_CHECK_BUTTON (vbox2, msgid_checkbtn, _("Generate Message-ID"));
1999 PACK_CHECK_BUTTON (vbox2, checkbtn_msgid_with_addr,
2000 _("Send account mail address in Message-ID"));
2002 PACK_CHECK_BUTTON (vbox2, xmailer_checkbtn,
2003 _("Add user agent header"));
2005 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
2006 gtk_widget_show (hbox);
2007 gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2009 PACK_CHECK_BUTTON (hbox, customhdr_checkbtn,
2010 _("Add user-defined header"));
2012 customhdr_edit_btn = gtk_button_new_with_mnemonic("_Edit");
2013 gtk_widget_show (customhdr_edit_btn);
2014 gtk_box_pack_start (GTK_BOX (hbox), customhdr_edit_btn,
2015 FALSE, FALSE, 0);
2016 g_signal_connect (G_OBJECT (customhdr_edit_btn), "clicked",
2017 G_CALLBACK (prefs_account_edit_custom_header),
2018 NULL);
2020 SET_TOGGLE_SENSITIVITY (customhdr_checkbtn, customhdr_edit_btn);
2022 vbox3 = gtkut_get_options_frame(vbox1, &frame, _("Authentication"));
2024 PACK_CHECK_BUTTON (vbox3, smtp_auth_checkbtn,
2025 _("SMTP Authentication (SMTP AUTH)"));
2027 vbox4 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
2028 gtk_widget_show (vbox4);
2029 gtk_box_pack_start (GTK_BOX (vbox3), vbox4, FALSE, FALSE, 0);
2031 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
2032 gtk_widget_show (hbox);
2033 gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
2035 hbox_spc = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
2036 gtk_widget_show (hbox_spc);
2037 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
2038 gtk_widget_set_size_request (hbox_spc, 12, -1);
2040 label = gtk_label_new (_("Authentication method"));
2041 gtk_widget_show (label);
2042 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2044 optmenu = gtkut_sc_combobox_create(NULL, FALSE);
2045 menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu)));
2046 gtk_widget_show (optmenu);
2047 gtk_box_pack_start (GTK_BOX (hbox), optmenu, FALSE, FALSE, 0);
2049 COMBOBOX_ADD (menu, _("Automatic"), 0);
2050 COMBOBOX_ADD (menu, NULL, 0);
2051 COMBOBOX_ADD (menu, "PLAIN", SMTPAUTH_PLAIN);
2052 COMBOBOX_ADD (menu, "LOGIN", SMTPAUTH_LOGIN);
2053 COMBOBOX_ADD (menu, "CRAM-MD5", SMTPAUTH_CRAM_MD5);
2054 COMBOBOX_ADD (menu, "OAUTH2", SMTPAUTH_OAUTH2);
2055 #ifndef USE_OAUTH2
2056 gtk_list_store_set(menu, &iter, COMBOBOX_SENS, FALSE, -1);
2057 #endif
2058 COMBOBOX_ADD (menu, "DIGEST-MD5", SMTPAUTH_DIGEST_MD5);
2059 gtk_list_store_set(menu, &iter, COMBOBOX_SENS, FALSE, -1);
2061 PACK_SPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
2063 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
2064 gtk_widget_show (hbox);
2065 gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
2067 hbox_spc = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
2068 gtk_widget_show (hbox_spc);
2069 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
2070 gtk_widget_set_size_request (hbox_spc, 12, -1);
2072 label = gtk_label_new (_("User ID"));
2073 gtk_widget_show (label);
2074 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2076 smtp_uid_entry = gtk_entry_new ();
2077 gtk_widget_show (smtp_uid_entry);
2078 gtk_widget_set_size_request (smtp_uid_entry, DEFAULT_ENTRY_WIDTH, -1);
2079 gtk_box_pack_start (GTK_BOX (hbox), smtp_uid_entry, TRUE, TRUE, 0);
2080 g_signal_connect(G_OBJECT(smtp_uid_entry), "changed",
2081 G_CALLBACK(prefs_account_entry_changed_newline_check_cb),
2082 GINT_TO_POINTER(ac_prefs->protocol));
2084 #ifdef GENERIC_UMPC
2085 PACK_SPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
2086 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
2087 gtk_widget_show (hbox);
2088 gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
2090 hbox_spc = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
2091 gtk_widget_show (hbox_spc);
2092 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
2093 gtk_widget_set_size_request (hbox_spc, 12, -1);
2094 #endif
2095 label = gtk_label_new (_("Password"));
2096 gtk_widget_show (label);
2097 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2099 smtp_pass_entry = gtk_entry_new ();
2100 gtk_widget_show (smtp_pass_entry);
2101 gtk_widget_set_size_request (smtp_pass_entry, DEFAULT_ENTRY_WIDTH, -1);
2102 gtk_box_pack_start (GTK_BOX (hbox), smtp_pass_entry, TRUE, TRUE, 0);
2103 gtk_entry_set_visibility (GTK_ENTRY (smtp_pass_entry), FALSE);
2104 g_signal_connect(G_OBJECT(smtp_pass_entry), "changed",
2105 G_CALLBACK(prefs_account_entry_changed_newline_check_cb),
2106 GINT_TO_POINTER(ac_prefs->protocol));
2108 showpwd_checkbtn = gtk_check_button_new_with_label (_("Show password"));
2109 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn), FALSE);
2110 gtk_widget_show(showpwd_checkbtn);
2111 gtk_box_pack_start(GTK_BOX (hbox), showpwd_checkbtn, FALSE, FALSE, 0);
2112 g_signal_connect(G_OBJECT(showpwd_checkbtn), "toggled",
2113 G_CALLBACK(prefs_account_showpwd_checkbtn_toggled), smtp_pass_entry);
2115 PACK_SPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
2117 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
2118 gtk_widget_show (hbox);
2119 gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
2121 hbox_spc = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
2122 gtk_widget_show (hbox_spc);
2123 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
2124 gtk_widget_set_size_request (hbox_spc, 12, -1);
2126 label = gtk_label_new
2127 (_("If you leave these entries empty, the same "
2128 "user ID and password as receiving will be used."));
2129 gtk_widget_show (label);
2130 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2131 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2132 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2133 gtkut_widget_set_small_font_size (label);
2135 SET_TOGGLE_SENSITIVITY (smtp_auth_checkbtn, vbox4);
2137 PACK_CHECK_BUTTON (vbox3, pop_bfr_smtp_checkbtn,
2138 _("Authenticate with POP before sending"));
2140 g_signal_connect (G_OBJECT (pop_bfr_smtp_checkbtn), "clicked",
2141 G_CALLBACK (pop_bfr_smtp_tm_set_sens),
2142 NULL);
2144 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
2145 gtk_widget_show (hbox);
2146 gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
2148 hbox_spc = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
2149 gtk_widget_show (hbox_spc);
2150 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
2151 gtk_widget_set_size_request (hbox_spc, 12, -1);
2153 pop_auth_timeout_lbl = gtk_label_new(_("POP authentication timeout"));
2154 gtk_widget_show (pop_auth_timeout_lbl);
2155 gtk_box_pack_start (GTK_BOX (hbox), pop_auth_timeout_lbl, FALSE, FALSE, 0);
2157 pop_bfr_smtp_tm_spinbtn = gtk_spin_button_new_with_range(0, 1440, 1);
2158 gtk_widget_show (pop_bfr_smtp_tm_spinbtn);
2159 gtk_box_pack_start (GTK_BOX (hbox), pop_bfr_smtp_tm_spinbtn, FALSE, FALSE, 0);
2161 pop_auth_minutes_lbl = gtk_label_new(_("minutes"));
2162 gtk_widget_show (pop_auth_minutes_lbl);
2163 gtk_box_pack_start (GTK_BOX (hbox), pop_auth_minutes_lbl, FALSE, FALSE, 0);
2165 page->msgid_checkbtn = msgid_checkbtn;
2166 page->xmailer_checkbtn = xmailer_checkbtn;
2167 page->customhdr_checkbtn = customhdr_checkbtn;
2168 page->msgid_with_addr_checkbtn = checkbtn_msgid_with_addr;
2170 page->smtp_auth_checkbtn = smtp_auth_checkbtn;
2171 page->smtp_auth_type_optmenu = optmenu;
2172 page->smtp_uid_entry = smtp_uid_entry;
2173 page->smtp_pass_entry = smtp_pass_entry;
2174 page->pop_bfr_smtp_checkbtn = pop_bfr_smtp_checkbtn;
2175 page->pop_bfr_smtp_tm_spinbtn = pop_bfr_smtp_tm_spinbtn;
2176 page->pop_auth_timeout_lbl = pop_auth_timeout_lbl;
2177 page->pop_auth_minutes_lbl = pop_auth_minutes_lbl;
2179 tmp_ac_prefs = *ac_prefs;
2181 if (new_account) {
2182 prefs_set_dialog_to_default(send_param);
2183 } else {
2184 prefs_set_dialog(send_param);
2186 /* Passwords are handled outside of PrefParams. */
2187 buf = passwd_store_get_account(ac_prefs->account_id,
2188 PWS_ACCOUNT_SEND);
2189 gtk_entry_set_text(GTK_ENTRY(page->smtp_pass_entry), buf != NULL ? buf : "");
2190 if (buf != NULL) {
2191 memset(buf, 0, strlen(buf));
2192 g_free(buf);
2196 pop_bfr_smtp_tm_set_sens (NULL, NULL);
2198 page->vbox = vbox1;
2200 page->page.widget = vbox1;
2203 #ifdef USE_OAUTH2
2204 static void oauth2_create_widget_func(PrefsPage * _page,
2205 GtkWindow * window,
2206 gpointer data)
2208 Oauth2Page *page = (Oauth2Page *) _page;
2209 PrefsAccount *ac_prefs = (PrefsAccount *) data;
2211 GtkWidget *vbox1, *vbox2, *vbox3;
2212 GtkWidget *hbox;
2213 GtkWidget *hbox_spc;
2214 GtkWidget *oauth2_authorise_btn;
2215 GtkWidget *auth_vbox, *auth_frame;
2216 GtkWidget *label;
2217 GtkWidget *oauth2_authcode_entry;
2218 GtkWidget *oauth2_auth_optmenu;
2219 GtkWidget *oauth2_link_button;
2220 GtkWidget *oauth2_link_copy_button;
2221 GtkWidget *oauth2_client_id_entry;
2222 GtkWidget *oauth2_client_secret_entry;
2223 GtkWidget *table1;
2224 GtkListStore *menu;
2225 GtkTreeIter iter;
2226 char *buf;
2227 struct BasicProtocol *protocol_optmenu;
2229 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
2230 gtk_widget_show (vbox1);
2231 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2233 auth_vbox = gtkut_get_options_frame(vbox1, &auth_frame,
2234 _("Authorization"));
2236 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
2237 gtk_widget_show (hbox);
2238 gtk_box_pack_start (GTK_BOX (auth_vbox), hbox, FALSE, FALSE, 0);
2240 hbox_spc = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
2241 gtk_widget_show (hbox_spc);
2242 gtk_widget_set_size_request (hbox_spc, 12, -1);
2243 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
2245 /* Email service provider */
2247 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
2248 gtk_widget_show (hbox);
2249 gtk_box_pack_start (GTK_BOX (auth_vbox), hbox, FALSE, FALSE, 0);
2251 label = gtk_label_new (_("Select OAuth2 Email Service Provider"));
2252 gtk_widget_show (label);
2253 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2255 oauth2_auth_optmenu = gtkut_sc_combobox_create(NULL, FALSE);
2256 menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(oauth2_auth_optmenu)));
2257 gtk_widget_show (oauth2_auth_optmenu);
2258 gtk_box_pack_start (GTK_BOX (hbox), oauth2_auth_optmenu, FALSE, FALSE, 0);
2260 COMBOBOX_ADD (menu, _("Select"), NULL);
2261 COMBOBOX_ADD (menu, NULL, 0);
2262 COMBOBOX_ADD (menu, "Google/Gmail", OAUTH2AUTH_GOOGLE);
2263 COMBOBOX_ADD (menu, "MS Outlook", OAUTH2AUTH_OUTLOOK);
2264 COMBOBOX_ADD (menu, "MS Exchange", OAUTH2AUTH_EXCHANGE);
2265 COMBOBOX_ADD (menu, "Yahoo", OAUTH2AUTH_YAHOO);
2267 protocol_optmenu = g_new(struct BasicProtocol, 1);
2268 protocol_optmenu->combobox = oauth2_auth_optmenu;
2269 protocol_optmenu->label = label;
2270 protocol_optmenu->descrlabel = label;
2272 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
2273 gtk_widget_show (hbox);
2274 gtk_box_pack_start (GTK_BOX (auth_vbox), hbox, FALSE, FALSE, 0);
2276 vbox3 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
2277 gtk_widget_show (vbox3);
2278 gtk_box_pack_start (GTK_BOX (auth_vbox), vbox3, FALSE, FALSE, 0);
2280 vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
2281 gtk_widget_show (vbox2);
2282 gtk_box_pack_start (GTK_BOX (vbox3), vbox2, FALSE, FALSE, 0);
2284 table1 = gtk_grid_new();
2285 gtk_widget_show (table1);
2286 gtk_container_add (GTK_CONTAINER (vbox2), table1);
2287 gtk_container_set_border_width (GTK_CONTAINER (table1), 8);
2288 gtk_grid_set_row_spacing(GTK_GRID(table1), VSPACING_NARROW);
2289 gtk_grid_set_column_spacing(GTK_GRID(table1), 8);
2291 label = gtk_label_new (_("Client ID"));
2292 gtk_widget_show (label);
2293 gtk_label_set_xalign(GTK_LABEL (label), 1.0);
2294 gtk_grid_attach(GTK_GRID(table1), label, 0, 0, 1, 1);
2296 oauth2_client_id_entry = gtk_entry_new();
2297 gtk_widget_show (oauth2_client_id_entry);
2298 gtk_grid_attach(GTK_GRID(table1), oauth2_client_id_entry, 1, 0, 1, 1);
2299 gtk_widget_set_hexpand(oauth2_client_id_entry, TRUE);
2300 gtk_widget_set_halign(oauth2_client_id_entry, GTK_ALIGN_FILL);
2302 label = gtk_label_new (_("Client secret"));
2303 gtk_widget_show (label);
2304 gtk_label_set_xalign(GTK_LABEL (label), 1.0);
2305 gtk_grid_attach(GTK_GRID(table1), label, 0, 1, 1, 1);
2307 oauth2_client_secret_entry = gtk_entry_new ();
2308 gtk_widget_show (oauth2_client_secret_entry);
2309 gtk_grid_attach(GTK_GRID(table1), oauth2_client_secret_entry, 1, 1, 1, 1);
2310 gtk_widget_set_hexpand(oauth2_client_secret_entry, TRUE);
2311 gtk_widget_set_halign(oauth2_client_secret_entry, GTK_ALIGN_FILL);
2313 hbox_spc = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
2314 gtk_widget_show (hbox_spc);
2315 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
2316 //gtk_widget_set_size_request (hbox_spc, 12, -1);
2318 hbox_spc = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
2319 gtk_widget_show (hbox_spc);
2320 gtk_box_pack_start (GTK_BOX (vbox2), hbox_spc, FALSE, FALSE, 0);
2321 //gtk_widget_set_size_request (hbox_spc, 12, 10);
2323 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
2324 gtk_widget_show (hbox);
2325 gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
2327 label = gtk_label_new (_("Obtain authorization code"));
2328 gtk_widget_show (label);
2329 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2331 oauth2_link_button = gtk_button_new_with_label(_("Open default browser with request"));
2332 g_signal_connect(G_OBJECT(oauth2_link_button), "clicked", G_CALLBACK(prefs_account_oauth2_copy_url), NULL);
2333 gtk_widget_set_sensitive(oauth2_link_button, TRUE);
2334 gtk_widget_set_margin_bottom(oauth2_link_button, 8);
2335 gtk_widget_show (oauth2_link_button);
2336 gtk_box_pack_start (GTK_BOX (hbox), oauth2_link_button, FALSE, FALSE, 0);
2338 oauth2_link_copy_button = gtk_button_new_with_label(_("Copy link"));
2339 g_signal_connect(G_OBJECT(oauth2_link_copy_button), "clicked", G_CALLBACK(prefs_account_oauth2_copy_url), NULL);
2340 gtk_widget_set_sensitive(oauth2_link_copy_button, TRUE);
2341 gtk_widget_set_margin_bottom(oauth2_link_copy_button, 8);
2342 gtk_widget_show (oauth2_link_copy_button);
2343 gtk_box_pack_start (GTK_BOX (hbox), oauth2_link_copy_button, FALSE, FALSE, 0);
2345 /* Authorisation code */
2346 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
2347 gtk_widget_show (hbox);
2348 gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
2349 //gtk_widget_set_size_request (hbox, -1, 50);
2351 label = gtk_label_new (_("Authorization code"));
2352 gtk_widget_show (label);
2353 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2355 oauth2_authcode_entry = gtk_entry_new ();
2356 gtk_widget_show (oauth2_authcode_entry);
2357 gtk_widget_set_margin_bottom(oauth2_authcode_entry, 8);
2358 //gtk_widget_set_size_request (oauth2_authcode_entry, DEFAULT_ENTRY_WIDTH, -1);
2359 gtk_widget_set_tooltip_text(oauth2_authcode_entry,
2360 _("Paste complete URL from browser or the provided authorization token"));
2361 gtk_box_pack_start (GTK_BOX (hbox), oauth2_authcode_entry, TRUE, TRUE, 0);
2363 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
2364 gtk_widget_show (hbox);
2365 gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
2367 label = gtk_label_new (_("Complete authorization"));
2368 gtk_widget_show (label);
2369 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2371 oauth2_authorise_btn = gtk_button_new_with_label(_("Authorize"));
2372 gtk_box_pack_start(GTK_BOX(hbox), oauth2_authorise_btn, FALSE, FALSE, 0);
2373 g_signal_connect(G_OBJECT(oauth2_authorise_btn), "clicked",
2374 G_CALLBACK(prefs_account_oauth2_obtain_tokens), NULL);
2375 gtk_widget_show(oauth2_authorise_btn);
2377 /* Add items to page struct */
2379 page->oauth2_link_button = oauth2_link_button;
2380 page->oauth2_link_copy_button = oauth2_link_copy_button;
2381 page->oauth2_authcode_entry = oauth2_authcode_entry;
2382 page->oauth2_auth_optmenu = oauth2_auth_optmenu;
2383 page->protocol_optmenu = (gpointer)protocol_optmenu;
2384 page->oauth2_authorise_btn = oauth2_authorise_btn;
2385 page->oauth2_client_id_entry = oauth2_client_id_entry;
2386 page->oauth2_client_secret_entry = oauth2_client_secret_entry;
2387 page->vbox = vbox1;
2388 page->page.widget = vbox1;
2389 page->oauth2_sensitive = vbox3;
2391 tmp_ac_prefs = *ac_prefs;
2393 g_signal_connect(G_OBJECT(oauth2_auth_optmenu), "changed",
2394 G_CALLBACK(prefs_account_oauth2_set_sensitivity), NULL);
2395 g_signal_connect(G_OBJECT(oauth2_authcode_entry), "changed",
2396 G_CALLBACK(prefs_account_oauth2_set_auth_sensitivity), NULL);
2397 prefs_account_oauth2_set_auth_sensitivity();
2399 if (new_account) {
2400 prefs_set_dialog_to_default(oauth2_param);
2401 } else {
2402 prefs_set_dialog(oauth2_param);
2404 /* Passwords are handled outside of PrefParams. */
2405 buf = passwd_store_get_account(ac_prefs->account_id,
2406 PWS_ACCOUNT_OAUTH2_AUTH);
2407 gtk_entry_set_text(GTK_ENTRY(page->oauth2_authcode_entry), buf != NULL ? buf : "");
2408 if (buf != NULL) {
2409 memset(buf, 0, strlen(buf));
2410 g_free(buf);
2414 /* For testing */
2415 /* oauth2_encode(OAUTH2info[0][OA2_CLIENT_ID]); */
2418 #endif
2420 static void compose_create_widget_func(PrefsPage * _page,
2421 GtkWindow * window,
2422 gpointer data)
2424 ComposePage *page = (ComposePage *) _page;
2425 PrefsAccount *ac_prefs = (PrefsAccount *) data;
2427 GtkWidget *vbox1;
2428 GtkWidget *sig_hbox;
2429 GtkWidget *hbox1;
2430 GtkWidget *hbox2;
2431 GtkWidget *frame_sig;
2432 GtkWidget *vbox_sig;
2433 GtkWidget *label_sigpath;
2434 GtkWidget *checkbtn_autosig;
2435 GtkWidget *label_sigsep;
2436 GtkWidget *entry_sigsep;
2437 GtkWidget *frame;
2438 GtkWidget *table;
2439 GtkWidget *autocc_checkbtn;
2440 GtkWidget *autocc_entry;
2441 GtkWidget *autobcc_checkbtn;
2442 GtkWidget *autobcc_entry;
2443 GtkWidget *autoreplyto_checkbtn;
2444 GtkWidget *autoreplyto_entry;
2445 #if USE_ENCHANT
2446 GtkWidget *frame_dict;
2447 GtkWidget *table_dict;
2448 GtkWidget *checkbtn_enable_default_dictionary = NULL;
2449 GtkWidget *combo_default_dictionary = NULL;
2450 GtkWidget *checkbtn_enable_default_alt_dictionary = NULL;
2451 GtkWidget *combo_default_alt_dictionary = NULL;
2452 #endif
2454 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
2455 gtk_widget_show (vbox1);
2456 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2458 vbox_sig = gtkut_get_options_frame(vbox1, &frame_sig, _("Signature"));
2460 PACK_CHECK_BUTTON (vbox_sig, checkbtn_autosig,
2461 _("Automatically insert signature"));
2463 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
2464 gtk_widget_show (hbox1);
2465 gtk_box_pack_start (GTK_BOX (vbox_sig), hbox1, TRUE, TRUE, 0);
2466 label_sigsep = gtk_label_new (_("Signature separator"));
2467 gtk_widget_show (label_sigsep);
2468 gtk_box_pack_start (GTK_BOX (hbox1), label_sigsep, FALSE, FALSE, 0);
2470 entry_sigsep = gtk_entry_new ();
2471 gtk_widget_show (entry_sigsep);
2472 gtk_box_pack_start (GTK_BOX (hbox1), entry_sigsep, FALSE, FALSE, 0);
2474 gtk_widget_set_size_request (entry_sigsep, 64, -1);
2476 sig_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
2477 gtk_widget_show (sig_hbox);
2478 gtk_box_pack_start (GTK_BOX (vbox_sig), sig_hbox, FALSE, FALSE, 0);
2480 sigfile_radiobtn = gtk_radio_button_new_with_label (NULL, _("File"));
2481 gtk_widget_show (sigfile_radiobtn);
2482 gtk_box_pack_start (GTK_BOX (sig_hbox), sigfile_radiobtn,
2483 FALSE, FALSE, 0);
2484 g_object_set_data (G_OBJECT (sigfile_radiobtn),
2485 MENU_VAL_ID,
2486 GINT_TO_POINTER (SIG_FILE));
2487 g_signal_connect(G_OBJECT(sigfile_radiobtn), "clicked",
2488 G_CALLBACK(prefs_account_sigfile_radiobtn_cb), NULL);
2490 sigcmd_radiobtn = gtk_radio_button_new_with_label_from_widget
2491 (GTK_RADIO_BUTTON(sigfile_radiobtn), _("Command output"));
2492 gtk_widget_show (sigcmd_radiobtn);
2493 gtk_box_pack_start (GTK_BOX (sig_hbox), sigcmd_radiobtn,
2494 FALSE, FALSE, 0);
2495 g_object_set_data (G_OBJECT (sigcmd_radiobtn),
2496 MENU_VAL_ID,
2497 GINT_TO_POINTER (SIG_COMMAND));
2498 g_signal_connect(G_OBJECT(sigcmd_radiobtn), "clicked",
2499 G_CALLBACK(prefs_account_sigcmd_radiobtn_cb), NULL);
2501 hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
2502 gtk_widget_show (hbox2);
2503 gtk_box_pack_start (GTK_BOX (vbox_sig), hbox2, TRUE, TRUE, 0);
2504 label_sigpath = gtk_label_new (_("Signature"));
2505 gtk_widget_show (label_sigpath);
2506 gtk_box_pack_start (GTK_BOX (hbox2), label_sigpath, FALSE, FALSE, 0);
2508 entry_sigpath = gtk_entry_new ();
2509 gtk_widget_show (entry_sigpath);
2510 gtk_box_pack_start (GTK_BOX (hbox2), entry_sigpath, TRUE, TRUE, 0);
2512 signature_browse_button = gtkut_get_browse_file_btn(_("Bro_wse"));
2513 gtk_widget_show (signature_browse_button);
2514 gtk_box_pack_start (GTK_BOX (hbox2), signature_browse_button, FALSE, FALSE, 0);
2515 g_signal_connect(G_OBJECT(signature_browse_button), "clicked",
2516 G_CALLBACK(prefs_account_signature_browse_cb), NULL);
2518 signature_edit_button = gtk_button_new_with_mnemonic("_Edit");
2519 gtk_widget_show (signature_edit_button);
2520 gtk_box_pack_start (GTK_BOX (hbox2), signature_edit_button, FALSE, FALSE, 0);
2521 g_signal_connect(G_OBJECT(signature_edit_button), "clicked",
2522 G_CALLBACK(prefs_account_signature_edit_cb), entry_sigpath);
2524 PACK_FRAME (vbox1, frame, _("Automatically set the following addresses"));
2526 table = gtk_grid_new();
2527 gtk_widget_show (table);
2528 gtk_container_add (GTK_CONTAINER (frame), table);
2529 gtk_container_set_border_width (GTK_CONTAINER (table), 8);
2530 gtk_grid_set_row_spacing(GTK_GRID(table), VSPACING_NARROW_2);
2531 gtk_grid_set_column_spacing(GTK_GRID(table), 8);
2533 autocc_checkbtn = gtk_check_button_new_with_label (
2534 prefs_common_translated_header_name("Cc:"));
2535 gtk_widget_show (autocc_checkbtn);
2536 gtk_grid_attach(GTK_GRID(table), autocc_checkbtn, 0, 0, 1, 1);
2538 autocc_entry = gtk_entry_new ();
2539 gtk_widget_show (autocc_entry);
2540 gtk_grid_attach(GTK_GRID(table), autocc_entry, 1, 0, 1, 1);
2541 gtk_widget_set_hexpand(autocc_entry, TRUE);
2542 gtk_widget_set_halign(autocc_entry, GTK_ALIGN_FILL);
2544 SET_TOGGLE_SENSITIVITY (autocc_checkbtn, autocc_entry);
2546 autobcc_checkbtn = gtk_check_button_new_with_label (
2547 prefs_common_translated_header_name("Bcc:"));
2548 gtk_widget_show (autobcc_checkbtn);
2549 gtk_grid_attach(GTK_GRID(table), autobcc_checkbtn, 0, 1, 1, 1);
2551 autobcc_entry = gtk_entry_new ();
2552 gtk_widget_show (autobcc_entry);
2553 gtk_grid_attach(GTK_GRID(table), autobcc_entry, 1, 1, 1, 1);
2554 gtk_widget_set_hexpand(autobcc_entry, TRUE);
2555 gtk_widget_set_halign(autobcc_entry, GTK_ALIGN_FILL);
2557 SET_TOGGLE_SENSITIVITY (autobcc_checkbtn, autobcc_entry);
2559 autoreplyto_checkbtn = gtk_check_button_new_with_label (
2560 prefs_common_translated_header_name("Reply-To:"));
2561 gtk_widget_show (autoreplyto_checkbtn);
2562 gtk_grid_attach(GTK_GRID(table), autoreplyto_checkbtn, 0, 2, 1, 1);
2564 autoreplyto_entry = gtk_entry_new ();
2565 gtk_widget_show (autoreplyto_entry);
2566 gtk_grid_attach(GTK_GRID(table), autoreplyto_entry, 1, 2, 1, 1);
2567 gtk_widget_set_hexpand(autoreplyto_entry, TRUE);
2568 gtk_widget_set_halign(autoreplyto_entry, GTK_ALIGN_FILL);
2570 SET_TOGGLE_SENSITIVITY (autoreplyto_checkbtn, autoreplyto_entry);
2572 #if USE_ENCHANT
2573 PACK_FRAME (vbox1, frame_dict, _("Spell check dictionaries"));
2575 table_dict = gtk_grid_new();
2576 gtk_widget_show (table_dict);
2577 gtk_container_add (GTK_CONTAINER (frame_dict), table_dict);
2578 gtk_container_set_border_width (GTK_CONTAINER (table_dict), 8);
2579 gtk_grid_set_row_spacing(GTK_GRID(table_dict), VSPACING_NARROW_2);
2580 gtk_grid_set_column_spacing(GTK_GRID(table_dict), 8);
2582 /* Default dictionary */
2583 checkbtn_enable_default_dictionary = gtk_check_button_new_with_label(_("Default dictionary"));
2584 gtk_grid_attach(GTK_GRID(table_dict), checkbtn_enable_default_dictionary, 0, 0, 1, 1);
2586 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary),
2587 tmp_ac_prefs.enable_default_dictionary);
2589 combo_default_dictionary = gtkaspell_dictionary_combo_new(TRUE);
2590 gtk_grid_attach(GTK_GRID(table_dict), combo_default_dictionary, 1, 0, 1, 1);
2592 SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, combo_default_dictionary);
2594 /* Default dictionary */
2595 checkbtn_enable_default_alt_dictionary = gtk_check_button_new_with_label(_("Default alternate dictionary"));
2596 gtk_grid_attach(GTK_GRID(table_dict), checkbtn_enable_default_alt_dictionary, 0, 1, 1, 1);
2598 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_alt_dictionary),
2599 tmp_ac_prefs.enable_default_alt_dictionary);
2601 combo_default_alt_dictionary = gtkaspell_dictionary_combo_new(FALSE);
2602 gtk_grid_attach(GTK_GRID(table_dict), combo_default_alt_dictionary, 1, 1, 1, 1);
2604 SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary, combo_default_alt_dictionary);
2606 gtk_widget_show_all(table_dict);
2607 #endif
2609 page->sigfile_radiobtn = sigfile_radiobtn;
2610 page->entry_sigpath = entry_sigpath;
2611 page->checkbtn_autosig = checkbtn_autosig;
2612 page->entry_sigsep = entry_sigsep;
2614 page->autocc_checkbtn = autocc_checkbtn;
2615 page->autocc_entry = autocc_entry;
2616 page->autobcc_checkbtn = autobcc_checkbtn;
2617 page->autobcc_entry = autobcc_entry;
2618 page->autoreplyto_checkbtn = autoreplyto_checkbtn;
2619 page->autoreplyto_entry = autoreplyto_entry;
2620 #ifdef USE_ENCHANT
2621 page->checkbtn_enable_default_dictionary = checkbtn_enable_default_dictionary;
2622 page->combo_default_dictionary = combo_default_dictionary;
2623 page->checkbtn_enable_default_alt_dictionary = checkbtn_enable_default_alt_dictionary;
2624 page->combo_default_alt_dictionary = combo_default_alt_dictionary;
2625 #endif
2627 #ifdef USE_ENCHANT
2628 /* reset gtkaspell menus */
2629 if (compose_page.combo_default_dictionary != NULL) {
2630 gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page.combo_default_dictionary),
2631 gtkaspell_dictionary_store_new());
2632 gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page.combo_default_alt_dictionary),
2633 gtkaspell_dictionary_store_new_with_refresh(
2634 FALSE));
2636 #endif
2638 tmp_ac_prefs = *ac_prefs;
2640 if (new_account) {
2641 prefs_set_dialog_to_default(compose_param);
2642 } else
2643 prefs_set_dialog(compose_param);
2645 page->vbox = vbox1;
2647 page->page.widget = vbox1;
2650 static void templates_create_widget_func(PrefsPage * _page,
2651 GtkWindow * window,
2652 gpointer data)
2654 TemplatesPage *page = (TemplatesPage *) _page;
2655 PrefsAccount *ac_prefs = (PrefsAccount *) data;
2656 GtkWidget *vbox;
2657 GtkWidget *vbox2;
2658 GtkWidget *notebook;
2660 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
2661 gtk_widget_show(vbox);
2663 notebook = gtk_notebook_new();
2664 gtk_widget_show(notebook);
2665 gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
2667 /* compose format */
2668 vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
2669 gtk_widget_show (vbox2);
2670 gtk_container_set_border_width (GTK_CONTAINER (vbox2), VBOX_BORDER);
2672 quotefmt_create_new_msg_fmt_widgets(
2673 window,
2674 vbox2,
2675 &page->checkbtn_compose_with_format,
2676 NULL,
2677 &page->compose_subject_format,
2678 &page->compose_body_format,
2679 TRUE, NULL);
2680 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Compose")));
2682 /* reply format */
2683 vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
2684 gtk_widget_show (vbox2);
2685 gtk_container_set_border_width (GTK_CONTAINER (vbox2), VBOX_BORDER);
2687 quotefmt_create_reply_fmt_widgets(
2688 window,
2689 vbox2,
2690 &page->checkbtn_reply_with_format,
2691 NULL,
2692 &page->reply_quotemark,
2693 &page->reply_body_format,
2694 TRUE, NULL);
2695 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Reply")));
2697 /* forward format */
2698 vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
2699 gtk_widget_show (vbox2);
2700 gtk_container_set_border_width (GTK_CONTAINER (vbox2), VBOX_BORDER);
2702 quotefmt_create_forward_fmt_widgets(
2703 window,
2704 vbox2,
2705 &page->checkbtn_forward_with_format,
2706 NULL,
2707 &page->forward_quotemark,
2708 &page->forward_body_format,
2709 TRUE, NULL);
2710 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Forward")));
2712 tmp_ac_prefs = *ac_prefs;
2714 if (new_account) {
2715 prefs_set_dialog_to_default(templates_param);
2716 } else
2717 prefs_set_dialog(templates_param);
2719 page->vbox = vbox;
2721 page->page.widget = vbox;
2724 static void privacy_create_widget_func(PrefsPage * _page,
2725 GtkWindow * window,
2726 gpointer data)
2728 PrivacyPage *page = (PrivacyPage *) _page;
2729 PrefsAccount *ac_prefs = (PrefsAccount *) data;
2731 GtkWidget *vbox1;
2732 GtkWidget *vbox2;
2733 GtkWidget *hbox1;
2734 GtkWidget *label;
2735 GtkWidget *default_privacy_system;
2736 GtkListStore *menu;
2737 GtkCellRenderer *rend;
2738 GtkWidget *default_encrypt_checkbtn;
2739 GtkWidget *default_encrypt_reply_checkbtn;
2740 GtkWidget *default_sign_checkbtn;
2741 GtkWidget *default_sign_reply_checkbtn;
2742 GtkWidget *save_clear_text_checkbtn;
2743 GtkWidget *encrypt_to_self_checkbtn;
2745 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
2746 gtk_widget_show (vbox1);
2747 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2749 vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
2750 gtk_widget_show (vbox2);
2751 gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2753 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
2754 gtk_widget_show (hbox1);
2755 gtk_container_add (GTK_CONTAINER(vbox2), hbox1);
2757 label = gtk_label_new(_("Default privacy system"));
2758 gtk_widget_show(label);
2759 gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2761 /* Can't use gtkut_sc_combobox_create() here, because model for this
2762 * combobox needs an extra string column to store privacy plugin id. */
2763 menu = gtk_list_store_new(4,
2764 G_TYPE_STRING,
2765 G_TYPE_INT,
2766 G_TYPE_BOOLEAN,
2767 G_TYPE_STRING); /* This is where we store the privacy plugin id. */
2768 default_privacy_system = gtk_combo_box_new_with_model(GTK_TREE_MODEL(menu));
2770 rend = gtk_cell_renderer_text_new();
2771 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(default_privacy_system), rend, TRUE);
2772 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(default_privacy_system), rend,
2773 "text", COMBOBOX_TEXT,
2774 "sensitive", COMBOBOX_SENS,
2775 NULL);
2776 gtk_widget_set_focus_on_click(GTK_WIDGET(default_privacy_system), FALSE);
2778 gtk_widget_show (default_privacy_system);
2779 gtk_box_pack_start (GTK_BOX(hbox1), default_privacy_system, FALSE, TRUE, 0);
2781 g_signal_connect(G_OBJECT(default_privacy_system), "changed",
2782 G_CALLBACK(privacy_system_activated),
2783 NULL);
2785 PACK_CHECK_BUTTON (vbox2, default_sign_checkbtn,
2786 _("Always sign messages"));
2787 PACK_CHECK_BUTTON (vbox2, default_encrypt_checkbtn,
2788 _("Always encrypt messages"));
2789 PACK_CHECK_BUTTON (vbox2, default_sign_reply_checkbtn,
2790 _("Always sign messages when replying to a "
2791 "signed message"));
2792 PACK_CHECK_BUTTON (vbox2, default_encrypt_reply_checkbtn,
2793 _("Always encrypt messages when replying to an "
2794 "encrypted message"));
2795 PACK_CHECK_BUTTON (vbox2, encrypt_to_self_checkbtn,
2796 _("Encrypt sent messages with your own key in addition to recipient's"));
2797 PACK_CHECK_BUTTON (vbox2, save_clear_text_checkbtn,
2798 _("Save sent encrypted messages as clear text"));
2800 SET_TOGGLE_SENSITIVITY_REVERSE(encrypt_to_self_checkbtn, save_clear_text_checkbtn);
2801 SET_TOGGLE_SENSITIVITY_REVERSE(save_clear_text_checkbtn, encrypt_to_self_checkbtn);
2803 page->default_privacy_system = default_privacy_system;
2804 page->default_encrypt_checkbtn = default_encrypt_checkbtn;
2805 page->default_encrypt_reply_checkbtn = default_encrypt_reply_checkbtn;
2806 page->default_sign_reply_checkbtn = default_sign_reply_checkbtn;
2807 page->default_sign_checkbtn = default_sign_checkbtn;
2808 page->save_clear_text_checkbtn = save_clear_text_checkbtn;
2809 page->encrypt_to_self_checkbtn = encrypt_to_self_checkbtn;
2811 update_privacy_system_menu();
2813 tmp_ac_prefs = *ac_prefs;
2815 if (new_account) {
2816 prefs_set_dialog_to_default(privacy_param);
2817 } else
2818 prefs_set_dialog(privacy_param);
2820 page->vbox = vbox1;
2822 page->page.widget = vbox1;
2825 #define CREATE_RADIO_BUTTON(box, btn, btn_p, label, data) \
2827 btn = gtk_radio_button_new_with_label_from_widget \
2828 (GTK_RADIO_BUTTON (btn_p), label); \
2829 gtk_widget_show (btn); \
2830 gtk_box_pack_start (GTK_BOX (box), btn, FALSE, FALSE, 0); \
2831 g_object_set_data (G_OBJECT (btn), \
2832 MENU_VAL_ID, \
2833 GINT_TO_POINTER (data)); \
2836 #ifdef USE_GNUTLS
2838 #define CREATE_RADIO_BUTTONS(box, \
2839 btn1, btn1_label, btn1_data, \
2840 btn2, btn2_label, btn2_data, \
2841 btn3, btn3_label, btn3_data) \
2843 btn1 = gtk_radio_button_new_with_label(NULL, btn1_label); \
2844 gtk_widget_show (btn1); \
2845 gtk_box_pack_start (GTK_BOX (box), btn1, FALSE, FALSE, 0); \
2846 g_object_set_data (G_OBJECT (btn1), \
2847 MENU_VAL_ID, \
2848 GINT_TO_POINTER (btn1_data)); \
2850 CREATE_RADIO_BUTTON(box, btn2, btn1, btn2_label, btn2_data); \
2851 CREATE_RADIO_BUTTON(box, btn3, btn1, btn3_label, btn3_data); \
2854 static void pop_ssltunnel_toggled(GtkToggleButton *button,
2855 gpointer data)
2857 gboolean active = gtk_toggle_button_get_active(button);
2859 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2860 advanced_page.popport_checkbtn)) == TRUE)
2861 return;
2862 gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page.popport_spinbtn),
2863 active ? 995 : 110);
2866 static void imap_ssltunnel_toggled(GtkToggleButton *button,
2867 gpointer data)
2869 gboolean active = gtk_toggle_button_get_active(button);
2871 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2872 advanced_page.imapport_checkbtn)) == TRUE)
2873 return;
2874 gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page.imapport_spinbtn),
2875 active ? 993 : 143);
2878 static void nntp_ssltunnel_toggled(GtkToggleButton *button,
2879 gpointer data)
2881 gboolean active = gtk_toggle_button_get_active(button);
2883 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2884 advanced_page.nntpport_checkbtn)) == TRUE)
2885 return;
2886 gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page.nntpport_spinbtn),
2887 active ? 563 : 119);
2890 static void smtp_ssltunnel_toggled(GtkToggleButton *button,
2891 gpointer data)
2893 gboolean active = gtk_toggle_button_get_active(button);
2895 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2896 advanced_page.smtpport_checkbtn)) == TRUE)
2897 return;
2898 gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page.smtpport_spinbtn),
2899 active ? 465 : 25);
2902 static void ssl_create_widget_func(PrefsPage * _page,
2903 GtkWindow * window,
2904 gpointer data)
2906 SSLPage *page = (SSLPage *) _page;
2907 PrefsAccount *ac_prefs = (PrefsAccount *) data;
2909 GtkWidget *vbox1;
2911 GtkWidget *pop_frame;
2912 GtkWidget *vbox2;
2913 GtkWidget *pop_nossl_radiobtn;
2914 GtkWidget *pop_ssltunnel_radiobtn;
2915 GtkWidget *pop_starttls_radiobtn;
2917 GtkWidget *imap_frame;
2918 GtkWidget *vbox3;
2919 GtkWidget *imap_nossl_radiobtn;
2920 GtkWidget *imap_ssltunnel_radiobtn;
2921 GtkWidget *imap_starttls_radiobtn;
2923 GtkWidget *nntp_frame;
2924 GtkWidget *vbox4;
2925 GtkWidget *nntp_nossl_radiobtn;
2926 GtkWidget *nntp_ssltunnel_radiobtn;
2928 GtkWidget *send_frame;
2929 GtkWidget *vbox5;
2930 GtkWidget *smtp_nossl_radiobtn;
2931 GtkWidget *smtp_ssltunnel_radiobtn;
2932 GtkWidget *smtp_starttls_radiobtn;
2934 GtkWidget *cert_frame;
2935 GtkWidget *cert_table;
2936 GtkWidget *entry_in_cert_pass;
2937 GtkWidget *entry_out_cert_pass;
2938 GtkWidget *showpwd_checkbtn;
2940 GtkWidget *vbox7;
2941 GtkWidget *ssl_certs_auto_accept_checkbtn;
2942 GtkWidget *use_nonblocking_ssl_checkbtn;
2943 GtkWidget *hbox;
2944 GtkWidget *hbox_spc;
2945 GtkWidget *label;
2946 gchar *buf;
2948 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
2949 gtk_widget_show (vbox1);
2950 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2952 vbox2 = gtkut_get_options_frame(vbox1, &pop_frame, _("POP"));
2954 CREATE_RADIO_BUTTONS(vbox2,
2955 pop_nossl_radiobtn,
2956 _("Don't use TLS"),
2957 SSL_NONE,
2958 pop_ssltunnel_radiobtn,
2959 _("Use TLS"),
2960 SSL_TUNNEL,
2961 pop_starttls_radiobtn,
2962 _("Use STARTTLS command to start encrypted session"),
2963 SSL_STARTTLS);
2964 g_signal_connect(G_OBJECT(pop_ssltunnel_radiobtn), "toggled",
2965 G_CALLBACK(pop_ssltunnel_toggled), NULL);
2967 vbox3 = gtkut_get_options_frame(vbox1, &imap_frame, _("IMAP"));
2969 CREATE_RADIO_BUTTONS(vbox3,
2970 imap_nossl_radiobtn,
2971 _("Don't use TLS"),
2972 SSL_NONE,
2973 imap_ssltunnel_radiobtn,
2974 _("Use TLS"),
2975 SSL_TUNNEL,
2976 imap_starttls_radiobtn,
2977 _("Use STARTTLS command to start encrypted session"),
2978 SSL_STARTTLS);
2979 g_signal_connect(G_OBJECT(imap_ssltunnel_radiobtn), "toggled",
2980 G_CALLBACK(imap_ssltunnel_toggled), NULL);
2982 vbox4 = gtkut_get_options_frame(vbox1, &nntp_frame, _("NNTP"));
2984 nntp_nossl_radiobtn =
2985 gtk_radio_button_new_with_label (NULL, _("Don't use TLS"));
2986 gtk_widget_show (nntp_nossl_radiobtn);
2987 gtk_box_pack_start (GTK_BOX (vbox4), nntp_nossl_radiobtn,
2988 FALSE, FALSE, 0);
2989 g_object_set_data (G_OBJECT (nntp_nossl_radiobtn),
2990 MENU_VAL_ID,
2991 GINT_TO_POINTER (SSL_NONE));
2993 CREATE_RADIO_BUTTON(vbox4, nntp_ssltunnel_radiobtn, nntp_nossl_radiobtn,
2994 _("Use TLS"), SSL_TUNNEL);
2995 g_signal_connect(G_OBJECT(nntp_ssltunnel_radiobtn), "toggled",
2996 G_CALLBACK(nntp_ssltunnel_toggled), NULL);
2998 vbox5 = gtkut_get_options_frame(vbox1, &send_frame, _("Send (SMTP)"));
3000 CREATE_RADIO_BUTTONS(vbox5,
3001 smtp_nossl_radiobtn,
3002 _("Don't use TLS (but, if necessary, use STARTTLS)"),
3003 SSL_NONE,
3004 smtp_ssltunnel_radiobtn,
3005 _("Use TLS"),
3006 SSL_TUNNEL,
3007 smtp_starttls_radiobtn,
3008 _("Use STARTTLS command to start encrypted session"),
3009 SSL_STARTTLS);
3010 g_signal_connect(G_OBJECT(smtp_ssltunnel_radiobtn), "toggled",
3011 G_CALLBACK(smtp_ssltunnel_toggled), NULL);
3013 PACK_FRAME(vbox1, cert_frame, _("Client certificates"));
3015 cert_table = gtk_grid_new();
3016 gtk_container_add(GTK_CONTAINER(cert_frame), cert_table);
3017 gtk_container_set_border_width(GTK_CONTAINER(cert_table), 8);
3018 gtk_grid_set_row_spacing(GTK_GRID(cert_table), VSPACING_NARROW_2);
3019 gtk_grid_set_column_spacing(GTK_GRID(cert_table), 8);
3021 label = gtk_label_new(_("Certificate for receiving"));
3022 gtk_label_set_xalign(GTK_LABEL(label), 1.0);
3023 entry_in_cert_file = gtk_entry_new();
3024 in_ssl_cert_browse_button = gtkut_get_browse_file_btn(_("Browse"));
3025 CLAWS_SET_TIP(label,
3026 _("Client certificate file as a PKCS12 or PEM file"));
3027 CLAWS_SET_TIP(entry_in_cert_file,
3028 _("Client certificate file as a PKCS12 or PEM file"));
3029 gtk_grid_attach(GTK_GRID(cert_table), label, 0, 0, 1, 1);
3030 gtk_grid_attach(GTK_GRID(cert_table), entry_in_cert_file, 1, 0, 1, 1);
3031 gtk_widget_set_hexpand(entry_in_cert_file, TRUE);
3032 gtk_widget_set_halign(entry_in_cert_file, GTK_ALIGN_FILL);
3033 gtk_grid_attach(GTK_GRID(cert_table), in_ssl_cert_browse_button, 2, 0, 1, 1);
3035 label = gtk_label_new(_("Password"));
3036 gtk_label_set_xalign(GTK_LABEL(label), 1.0);
3037 entry_in_cert_pass = gtk_entry_new();
3038 gtk_entry_set_visibility(GTK_ENTRY(entry_in_cert_pass), FALSE);
3039 showpwd_checkbtn = gtk_check_button_new_with_label (_("Show password"));
3040 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn), FALSE);
3041 g_signal_connect(G_OBJECT(showpwd_checkbtn), "toggled",
3042 G_CALLBACK(prefs_account_showpwd_checkbtn_toggled), entry_in_cert_pass);
3043 gtk_grid_attach(GTK_GRID(cert_table), label, 0, 1, 1, 1);
3044 gtk_grid_attach(GTK_GRID(cert_table), entry_in_cert_pass, 1, 1, 1, 1);
3045 gtk_widget_set_hexpand(entry_in_cert_pass, TRUE);
3046 gtk_widget_set_halign(entry_in_cert_pass, GTK_ALIGN_FILL);
3047 gtk_grid_attach(GTK_GRID(cert_table), showpwd_checkbtn, 2, 1, 1, 1);
3049 label = gtk_label_new(_("Certificate for sending"));
3050 gtk_label_set_xalign(GTK_LABEL(label), 1.0);
3051 entry_out_cert_file = gtk_entry_new();
3052 out_ssl_cert_browse_button = gtkut_get_browse_file_btn(_("Browse"));
3053 CLAWS_SET_TIP(label,
3054 _("Client certificate file as a PKCS12 or PEM file"));
3055 CLAWS_SET_TIP(entry_out_cert_file,
3056 _("Client certificate file as a PKCS12 or PEM file"));
3057 gtk_grid_attach(GTK_GRID(cert_table), label, 0, 2, 1, 1);
3058 gtk_grid_attach(GTK_GRID(cert_table), entry_out_cert_file, 1, 2, 1, 1);
3059 gtk_widget_set_hexpand(entry_out_cert_file, TRUE);
3060 gtk_widget_set_halign(entry_out_cert_file, GTK_ALIGN_FILL);
3061 gtk_grid_attach(GTK_GRID(cert_table), out_ssl_cert_browse_button, 2, 2, 1, 1);
3063 label = gtk_label_new(_("Password"));
3064 gtk_label_set_xalign(GTK_LABEL(label), 1.0);
3065 entry_out_cert_pass = gtk_entry_new();
3066 gtk_entry_set_visibility(GTK_ENTRY(entry_out_cert_pass), FALSE);
3067 showpwd_checkbtn = gtk_check_button_new_with_label (_("Show password"));
3068 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn), FALSE);
3069 g_signal_connect(G_OBJECT(showpwd_checkbtn), "toggled",
3070 G_CALLBACK(prefs_account_showpwd_checkbtn_toggled), entry_out_cert_pass);
3071 gtk_grid_attach(GTK_GRID(cert_table), label, 0, 3, 1, 1);
3072 gtk_grid_attach(GTK_GRID(cert_table), entry_out_cert_pass, 1, 3, 1, 1);
3073 gtk_widget_set_hexpand(entry_out_cert_pass, TRUE);
3074 gtk_widget_set_halign(entry_out_cert_pass, GTK_ALIGN_FILL);
3075 gtk_grid_attach(GTK_GRID(cert_table), showpwd_checkbtn, 2, 3, 1, 1);
3077 gtk_widget_show_all(cert_table);
3079 g_signal_connect(G_OBJECT(in_ssl_cert_browse_button), "clicked",
3080 G_CALLBACK(prefs_account_in_cert_browse_cb), NULL);
3081 g_signal_connect(G_OBJECT(out_ssl_cert_browse_button), "clicked",
3082 G_CALLBACK(prefs_account_out_cert_browse_cb), NULL);
3084 vbox7 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
3085 gtk_widget_show (vbox7);
3086 gtk_box_pack_start (GTK_BOX (vbox1), vbox7, FALSE, FALSE, 0);
3088 PACK_CHECK_BUTTON(vbox7, ssl_certs_auto_accept_checkbtn,
3089 _("Automatically accept valid TLS certificates"));
3091 PACK_CHECK_BUTTON(vbox7, use_nonblocking_ssl_checkbtn,
3092 _("Use non-blocking TLS"));
3094 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
3095 gtk_widget_show (hbox);
3096 gtk_box_pack_start (GTK_BOX (vbox7), hbox, FALSE, FALSE, 0);
3098 hbox_spc = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
3099 gtk_widget_show (hbox_spc);
3100 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
3101 gtk_widget_set_size_request (hbox_spc, 16, -1);
3103 label = gtk_label_new
3104 (_("Turn this off if you have TLS connection problems"));
3105 gtk_widget_show (label);
3106 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
3107 gtkut_widget_set_small_font_size (label);
3109 page->pop_frame = pop_frame;
3110 page->pop_nossl_radiobtn = pop_nossl_radiobtn;
3111 page->pop_ssltunnel_radiobtn = pop_ssltunnel_radiobtn;
3112 page->pop_starttls_radiobtn = pop_starttls_radiobtn;
3114 page->imap_frame = imap_frame;
3115 page->imap_nossl_radiobtn = imap_nossl_radiobtn;
3116 page->imap_ssltunnel_radiobtn = imap_ssltunnel_radiobtn;
3117 page->imap_starttls_radiobtn = imap_starttls_radiobtn;
3119 page->nntp_frame = nntp_frame;
3120 page->nntp_nossl_radiobtn = nntp_nossl_radiobtn;
3121 page->nntp_ssltunnel_radiobtn = nntp_ssltunnel_radiobtn;
3123 page->send_frame = send_frame;
3124 page->smtp_nossl_radiobtn = smtp_nossl_radiobtn;
3125 page->smtp_ssltunnel_radiobtn = smtp_ssltunnel_radiobtn;
3126 page->smtp_starttls_radiobtn = smtp_starttls_radiobtn;
3128 page->entry_in_cert_file = entry_in_cert_file;
3129 page->entry_in_cert_pass = entry_in_cert_pass;
3130 page->entry_out_cert_file = entry_out_cert_file;
3131 page->entry_out_cert_pass = entry_out_cert_pass;
3133 page->ssl_certs_auto_accept_checkbtn = ssl_certs_auto_accept_checkbtn;
3134 page->use_nonblocking_ssl_checkbtn = use_nonblocking_ssl_checkbtn;
3136 tmp_ac_prefs = *ac_prefs;
3138 if (new_account) {
3139 prefs_set_dialog_to_default(ssl_param);
3140 } else {
3141 prefs_set_dialog(ssl_param);
3143 /* Passwords are handled outside of PrefParams. */
3144 buf = passwd_store_get_account(ac_prefs->account_id,
3145 PWS_ACCOUNT_RECV_CERT);
3146 gtk_entry_set_text(GTK_ENTRY(page->entry_in_cert_pass), buf != NULL ? buf : "");
3147 if (buf != NULL) {
3148 memset(buf, 0, strlen(buf));
3149 g_free(buf);
3152 buf = passwd_store_get_account(ac_prefs->account_id,
3153 PWS_ACCOUNT_SEND_CERT);
3154 gtk_entry_set_text(GTK_ENTRY(page->entry_out_cert_pass), buf != NULL ? buf : "");
3155 if (buf != NULL) {
3156 memset(buf, 0, strlen(buf));
3157 g_free(buf);
3161 page->vbox = vbox1;
3163 page->page.widget = vbox1;
3166 #undef CREATE_RADIO_BUTTONS
3167 #endif /* USE_GNUTLS */
3169 static void proxy_create_widget_func(PrefsPage * _page,
3170 GtkWindow * window,
3171 gpointer data)
3173 ProxyPage *page = (ProxyPage *) _page;
3174 PrefsAccount *ac_prefs = (PrefsAccount *) data;
3175 GtkWidget *vbox1, *vbox2, *vbox3, *vbox4;
3176 GtkWidget *proxy_frame;
3177 GtkWidget *proxy_checkbtn;
3178 GtkWidget *default_proxy_checkbtn;
3179 GtkWidget *hbox;
3180 GtkWidget *label;
3181 GtkWidget *socks4_radiobtn;
3182 GtkWidget *socks5_radiobtn;
3183 GtkWidget *proxy_host_entry;
3184 GtkWidget *proxy_port_spinbtn;
3185 GtkWidget *proxy_auth_checkbtn;
3186 GtkWidget *proxy_name_entry;
3187 GtkWidget *proxy_pass_entry;
3188 GtkWidget *proxy_send_checkbtn;
3189 GtkWidget *table;
3190 GtkWidget *button;
3191 gchar *buf;
3193 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
3194 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
3196 proxy_checkbtn = gtk_check_button_new_with_label (_("Use proxy server"));
3197 PACK_FRAME (vbox1, proxy_frame, NULL);
3198 gtk_frame_set_label_widget (GTK_FRAME(proxy_frame), proxy_checkbtn);
3200 vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING_NARROW);
3201 gtk_container_add (GTK_CONTAINER (proxy_frame), vbox2);
3202 gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
3204 default_proxy_checkbtn =
3205 gtk_check_button_new_with_label (C_("In account preferences, referring to whether or not use proxy settings from common preferences", "Use default settings"));
3206 CLAWS_SET_TIP(default_proxy_checkbtn,
3207 _("Use global proxy server settings"));
3208 gtk_box_pack_start (GTK_BOX (vbox2), default_proxy_checkbtn, FALSE, FALSE, 0);
3210 vbox3 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING_NARROW);
3211 gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
3213 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
3214 gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
3216 socks4_radiobtn = gtk_radio_button_new_with_label(NULL, "SOCKS4");
3217 gtk_box_pack_start (GTK_BOX (hbox), socks4_radiobtn, FALSE, FALSE, 0);
3218 g_object_set_data(G_OBJECT(socks4_radiobtn), MENU_VAL_ID,
3219 GINT_TO_POINTER(PROXY_SOCKS4));
3221 CREATE_RADIO_BUTTON(hbox, socks5_radiobtn, socks4_radiobtn, "SOCKS5",
3222 PROXY_SOCKS5);
3224 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
3225 gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
3227 label = gtk_label_new(_("Hostname"));
3228 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
3230 proxy_host_entry = gtk_entry_new();
3231 gtk_widget_set_size_request(proxy_host_entry, DEFAULT_ENTRY_WIDTH, -1);
3232 gtk_box_pack_start(GTK_BOX(hbox), proxy_host_entry, TRUE, TRUE, 0);
3234 label = gtk_label_new(_("Port"));
3235 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
3237 proxy_port_spinbtn = gtk_spin_button_new_with_range(0, 65535, 1080);
3238 gtk_widget_set_size_request(proxy_port_spinbtn, 64, -1);
3239 gtk_box_pack_start(GTK_BOX(hbox), proxy_port_spinbtn, FALSE, FALSE, 0);
3241 vbox4 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING_NARROW);
3242 gtk_box_pack_start(GTK_BOX(vbox3), vbox4, FALSE, FALSE, 0);
3244 PACK_CHECK_BUTTON (vbox4, proxy_auth_checkbtn, _("Use authentication"));
3246 table = gtk_grid_new();
3247 gtk_box_pack_start (GTK_BOX (vbox4), table, FALSE, FALSE, 0);
3249 label = gtk_label_new(_("Username"));
3250 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
3252 proxy_name_entry = gtk_entry_new();
3253 gtk_widget_set_size_request(proxy_name_entry, DEFAULT_ENTRY_WIDTH, -1);
3254 gtk_grid_attach(GTK_GRID(table), proxy_name_entry, 1, 0, 1, 1);
3255 gtk_widget_set_hexpand(proxy_name_entry, TRUE);
3256 gtk_widget_set_halign(proxy_name_entry, GTK_ALIGN_FILL);
3258 label = gtk_label_new(_("Password"));
3259 gtk_grid_attach(GTK_GRID(table), label, 2, 0, 1, 1);
3261 proxy_pass_entry = gtk_entry_new();
3262 gtk_widget_set_size_request(proxy_pass_entry, DEFAULT_ENTRY_WIDTH, -1);
3263 gtk_entry_set_visibility(GTK_ENTRY(proxy_pass_entry), FALSE);
3264 gtk_grid_attach(GTK_GRID(table), proxy_pass_entry, 3, 0, 1, 1);
3265 gtk_widget_set_hexpand(proxy_pass_entry, TRUE);
3266 gtk_widget_set_halign(proxy_pass_entry, GTK_ALIGN_FILL);
3268 button = gtk_check_button_new_with_label(_("Show password"));
3269 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
3270 gtk_grid_attach(GTK_GRID(table), button, 3, 1, 1, 1);
3272 g_signal_connect(G_OBJECT(button), "toggled",
3273 G_CALLBACK(prefs_account_showpwd_checkbtn_toggled), proxy_pass_entry);
3275 gtk_box_pack_start(GTK_BOX(vbox2), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 0);
3277 PACK_CHECK_BUTTON(vbox2, proxy_send_checkbtn,
3278 _("Use proxy server for sending"));
3279 CLAWS_SET_TIP(proxy_send_checkbtn,
3280 _("If disabled, messages will be sent using direct connection to configured outgoing server, bypassing any configured proxy server."));
3282 SET_TOGGLE_SENSITIVITY(proxy_auth_checkbtn, table);
3283 SET_TOGGLE_SENSITIVITY(socks5_radiobtn, vbox4);
3284 SET_TOGGLE_SENSITIVITY(proxy_checkbtn, vbox2);
3285 SET_TOGGLE_SENSITIVITY_REVERSE(default_proxy_checkbtn, vbox3);
3287 gtk_widget_show_all(vbox1);
3289 page->proxy_checkbtn = proxy_checkbtn;
3290 page->default_proxy_checkbtn = default_proxy_checkbtn;
3291 page->socks4_radiobtn = socks4_radiobtn;
3292 page->socks5_radiobtn = socks5_radiobtn;
3293 page->proxy_host_entry = proxy_host_entry;
3294 page->proxy_port_spinbtn = proxy_port_spinbtn;
3295 page->proxy_auth_checkbtn = proxy_auth_checkbtn;
3296 page->proxy_name_entry = proxy_name_entry;
3297 page->proxy_pass_entry = proxy_pass_entry;
3298 page->proxy_send_checkbtn = proxy_send_checkbtn;
3299 page->vbox = vbox1;
3300 page->page.widget = vbox1;
3302 tmp_ac_prefs = *ac_prefs;
3304 if (new_account) {
3305 prefs_set_dialog_to_default(proxy_param);
3306 } else {
3307 prefs_set_dialog(proxy_param);
3309 /* Passwords are handled outside of PrefParams. */
3310 buf = passwd_store_get_account(ac_prefs->account_id,
3311 PWS_ACCOUNT_PROXY_PASS);
3312 gtk_entry_set_text(GTK_ENTRY(page->proxy_pass_entry),
3313 buf != NULL ? buf : "");
3314 if (buf != NULL) {
3315 memset(buf, 0, strlen(buf));
3316 g_free(buf);
3320 page->vbox = vbox1;
3322 page->page.widget = vbox1;
3325 static void advanced_create_widget_func(PrefsPage * _page,
3326 GtkWindow * window,
3327 gpointer data)
3329 AdvancedPage *page = (AdvancedPage *) _page;
3330 PrefsAccount *ac_prefs = (PrefsAccount *) data;
3332 GtkWidget *vbox1;
3333 GtkWidget *vbox2;
3334 GtkWidget *hbox1;
3335 GtkWidget *checkbtn_smtpport;
3336 GtkWidget *spinbtn_smtpport;
3337 GtkWidget *hbox_popport;
3338 GtkWidget *checkbtn_popport;
3339 GtkWidget *spinbtn_popport;
3340 GtkWidget *hbox_imapport;
3341 GtkWidget *checkbtn_imapport;
3342 GtkWidget *spinbtn_imapport;
3343 GtkWidget *hbox_nntpport;
3344 GtkWidget *checkbtn_nntpport;
3345 GtkWidget *spinbtn_nntpport;
3346 GtkWidget *checkbtn_domain;
3347 GtkWidget *entry_domain;
3348 gchar *tip_domain;
3349 GtkWidget *checkbtn_crosspost;
3350 GtkWidget *colormenu_crosspost;
3351 #ifndef G_OS_WIN32
3352 GtkWidget *checkbtn_tunnelcmd;
3353 GtkWidget *entry_tunnelcmd;
3354 #endif
3355 GtkWidget *folder_frame;
3356 GtkWidget *vbox3;
3357 GtkWidget *table;
3358 GtkWidget *sent_folder_checkbtn;
3359 GtkWidget *sent_folder_entry;
3360 GtkWidget *queue_folder_checkbtn;
3361 GtkWidget *queue_folder_entry;
3362 GtkWidget *draft_folder_checkbtn;
3363 GtkWidget *draft_folder_entry;
3364 GtkWidget *trash_folder_checkbtn;
3365 GtkWidget *trash_folder_entry;
3366 GtkSizeGroup *size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
3368 #define PACK_HBOX(hbox) \
3370 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); \
3371 gtk_widget_show (hbox); \
3372 gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); \
3375 #define PACK_PORT_SPINBTN(box, spinbtn) \
3377 spinbtn = gtk_spin_button_new_with_range(0, 65535, 1); \
3378 gtk_widget_show (spinbtn); \
3379 gtk_box_pack_start (GTK_BOX (box), spinbtn, FALSE, FALSE, 0); \
3382 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
3383 gtk_widget_show (vbox1);
3384 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
3386 vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING_NARROW_2);
3387 gtk_widget_show (vbox2);
3388 gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
3390 PACK_HBOX (hbox1);
3391 PACK_CHECK_BUTTON (hbox1, checkbtn_smtpport, _("SMTP port"));
3392 PACK_PORT_SPINBTN (hbox1, spinbtn_smtpport);
3393 SET_TOGGLE_SENSITIVITY (checkbtn_smtpport, spinbtn_smtpport);
3394 gtk_size_group_add_widget(size_group, checkbtn_smtpport);
3396 PACK_HBOX (hbox_popport);
3397 PACK_CHECK_BUTTON (hbox_popport, checkbtn_popport,
3398 _("POP port"));
3399 PACK_PORT_SPINBTN (hbox_popport, spinbtn_popport);
3400 SET_TOGGLE_SENSITIVITY (checkbtn_popport, spinbtn_popport);
3401 gtk_size_group_add_widget(size_group, checkbtn_popport);
3403 PACK_HBOX (hbox_imapport);
3404 PACK_CHECK_BUTTON (hbox_imapport, checkbtn_imapport,
3405 _("IMAP port"));
3406 PACK_PORT_SPINBTN (hbox_imapport, spinbtn_imapport);
3407 SET_TOGGLE_SENSITIVITY (checkbtn_imapport, spinbtn_imapport);
3408 gtk_size_group_add_widget(size_group, checkbtn_imapport);
3410 PACK_HBOX (hbox_nntpport);
3411 PACK_CHECK_BUTTON (hbox_nntpport, checkbtn_nntpport,
3412 _("NNTP port"));
3413 PACK_PORT_SPINBTN (hbox_nntpport, spinbtn_nntpport);
3414 SET_TOGGLE_SENSITIVITY (checkbtn_nntpport, spinbtn_nntpport);
3415 gtk_size_group_add_widget(size_group, checkbtn_nntpport);
3417 PACK_HBOX (hbox1);
3418 PACK_CHECK_BUTTON (hbox1, checkbtn_domain, _("Domain name"));
3419 gtk_size_group_add_widget(size_group, checkbtn_domain);
3421 tip_domain = _("The domain name will be used in the generated "
3422 "Message-ID, and when connecting to SMTP servers.");
3424 CLAWS_SET_TIP(checkbtn_domain, tip_domain);
3426 entry_domain = gtk_entry_new ();
3427 gtk_widget_show (entry_domain);
3428 gtk_box_pack_start (GTK_BOX (hbox1), entry_domain, TRUE, TRUE, 0);
3429 SET_TOGGLE_SENSITIVITY (checkbtn_domain, entry_domain);
3430 CLAWS_SET_TIP(entry_domain, tip_domain);
3432 #ifndef G_OS_WIN32
3433 PACK_HBOX (hbox1);
3434 PACK_CHECK_BUTTON (hbox1, checkbtn_tunnelcmd,
3435 _("Use command to communicate with server"));
3436 entry_tunnelcmd = gtk_entry_new ();
3437 gtk_widget_show (entry_tunnelcmd);
3438 gtk_box_pack_start (GTK_BOX (hbox1), entry_tunnelcmd, TRUE, TRUE, 0);
3439 SET_TOGGLE_SENSITIVITY (checkbtn_tunnelcmd, entry_tunnelcmd);
3440 #endif
3442 PACK_HBOX (hbox1);
3443 PACK_CHECK_BUTTON (hbox1, checkbtn_crosspost,
3444 _("Mark cross-posted messages as read and color:"));
3445 g_signal_connect (G_OBJECT (checkbtn_crosspost), "toggled",
3446 G_CALLBACK (crosspost_color_toggled),
3447 NULL);
3449 colormenu_crosspost = colorlabel_create_combobox_colormenu();
3450 gtk_widget_show (colormenu_crosspost);
3451 gtk_box_pack_start (GTK_BOX (hbox1), colormenu_crosspost, FALSE, FALSE, 0);
3453 SET_TOGGLE_SENSITIVITY(checkbtn_crosspost, colormenu_crosspost);
3454 #undef PACK_HBOX
3455 #undef PACK_PORT_SPINBTN
3457 /* special folder setting (maybe these options are redundant) */
3459 vbox3 = gtkut_get_options_frame(vbox1, &folder_frame, _("Folder"));
3461 table = gtk_grid_new();
3462 gtk_widget_show (table);
3463 gtk_container_add (GTK_CONTAINER (vbox3), table);
3464 gtk_grid_set_row_spacing(GTK_GRID(table), VSPACING_NARROW_2);
3465 gtk_grid_set_column_spacing(GTK_GRID(table), 4);
3467 #define SET_CHECK_BTN_AND_ENTRY(label, checkbtn, entry, n) \
3469 GtkWidget *button; \
3471 checkbtn = gtk_check_button_new_with_label (label); \
3472 gtk_widget_show (checkbtn); \
3473 gtk_grid_attach(GTK_GRID(table), checkbtn, 0, n, 1, 1); \
3475 entry = gtk_entry_new (); \
3476 gtk_widget_show (entry); \
3477 gtk_grid_attach(GTK_GRID(table), entry, 1, n, 1, 1); \
3478 gtk_widget_set_hexpand(entry, TRUE); \
3479 gtk_widget_set_halign(entry, GTK_ALIGN_FILL); \
3481 button = gtkut_get_browse_file_btn(_("Browse")); \
3482 gtk_widget_show (button); \
3483 gtk_grid_attach(GTK_GRID(table), button, 2, n, 1, 1); \
3484 g_signal_connect \
3485 (G_OBJECT (button), "clicked", \
3486 G_CALLBACK (prefs_account_select_folder_cb), \
3487 entry); \
3489 SET_TOGGLE_SENSITIVITY (checkbtn, entry); \
3490 SET_TOGGLE_SENSITIVITY (checkbtn, button); \
3493 SET_CHECK_BTN_AND_ENTRY(_("Put sent messages in"),
3494 sent_folder_checkbtn, sent_folder_entry, 0);
3495 SET_CHECK_BTN_AND_ENTRY(_("Put queued messages in"),
3496 queue_folder_checkbtn, queue_folder_entry, 1);
3497 SET_CHECK_BTN_AND_ENTRY(_("Put draft messages in"),
3498 draft_folder_checkbtn, draft_folder_entry, 2);
3499 SET_CHECK_BTN_AND_ENTRY(_("Put deleted messages in"),
3500 trash_folder_checkbtn, trash_folder_entry, 3);
3502 page->smtpport_checkbtn = checkbtn_smtpport;
3503 page->smtpport_spinbtn = spinbtn_smtpport;
3504 page->popport_hbox = hbox_popport;
3505 page->popport_checkbtn = checkbtn_popport;
3506 page->popport_spinbtn = spinbtn_popport;
3507 page->imapport_hbox = hbox_imapport;
3508 page->imapport_checkbtn = checkbtn_imapport;
3509 page->imapport_spinbtn = spinbtn_imapport;
3510 page->nntpport_hbox = hbox_nntpport;
3511 page->nntpport_checkbtn = checkbtn_nntpport;
3512 page->nntpport_spinbtn = spinbtn_nntpport;
3513 page->domain_checkbtn = checkbtn_domain;
3514 page->domain_entry = entry_domain;
3515 page->crosspost_checkbtn = checkbtn_crosspost;
3516 page->crosspost_colormenu = colormenu_crosspost;
3518 #ifndef G_OS_WIN32
3519 page->tunnelcmd_checkbtn = checkbtn_tunnelcmd;
3520 page->tunnelcmd_entry = entry_tunnelcmd;
3521 #endif
3522 page->sent_folder_checkbtn = sent_folder_checkbtn;
3523 page->sent_folder_entry = sent_folder_entry;
3524 page->queue_folder_checkbtn = queue_folder_checkbtn;
3525 page->queue_folder_entry = queue_folder_entry;
3526 page->draft_folder_checkbtn = draft_folder_checkbtn;
3527 page->draft_folder_entry = draft_folder_entry;
3528 page->trash_folder_checkbtn = trash_folder_checkbtn;
3529 page->trash_folder_entry = trash_folder_entry;
3531 tmp_ac_prefs = *ac_prefs;
3533 if (new_account) {
3534 prefs_set_dialog_to_default(advanced_param);
3535 } else
3536 prefs_set_dialog(advanced_param);
3538 page->vbox = vbox1;
3540 page->page.widget = vbox1;
3542 g_object_unref(G_OBJECT(size_group));
3545 static gint prefs_basic_apply(void)
3547 RecvProtocol protocol;
3548 gchar *old_id = NULL;
3549 gchar *new_id = NULL;
3550 struct BasicProtocol *protocol_optmenu = (struct BasicProtocol *) basic_page.protocol_optmenu;
3551 GtkWidget *optmenu = protocol_optmenu->combobox;
3553 protocol = combobox_get_active_data(GTK_COMBO_BOX(optmenu));
3555 if (*gtk_entry_get_text(GTK_ENTRY(basic_page.acname_entry)) == '\0') {
3556 alertpanel_error(_("Account name is not entered."));
3557 return -1;
3559 if (*gtk_entry_get_text(GTK_ENTRY(basic_page.addr_entry)) == '\0') {
3560 alertpanel_error(_("Mail address is not entered."));
3561 return -1;
3564 if (((protocol == A_POP3) ||
3565 (protocol == A_LOCAL && !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(basic_page.mailcmd_checkbtn))) ||
3566 (protocol == A_NONE)) &&
3567 *gtk_entry_get_text(GTK_ENTRY(basic_page.smtpserv_entry)) == '\0') {
3568 alertpanel_error(_("SMTP server is not entered."));
3569 return -1;
3571 if ((protocol == A_POP3 || protocol == A_IMAP4) &&
3572 *gtk_entry_get_text(GTK_ENTRY(basic_page.uid_entry)) == '\0') {
3573 alertpanel_error(_("User ID is not entered."));
3574 return -1;
3576 if (protocol == A_POP3 &&
3577 *gtk_entry_get_text(GTK_ENTRY(basic_page.recvserv_entry)) == '\0') {
3578 alertpanel_error(_("POP server is not entered."));
3579 return -1;
3581 if (protocol == A_POP3 || protocol == A_LOCAL) {
3582 GtkWidget *inbox_entry = (protocol == A_POP3 ? receive_page.inbox_entry : receive_page.local_inbox_entry );
3583 const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(inbox_entry));
3584 FolderItem *inbox = folder_find_item_from_identifier(mailbox);
3585 if (!inbox) {
3586 gchar *id = NULL;
3587 setup_write_mailbox_path(mainwindow_get_mainwindow(), "Mail");
3588 id = folder_item_get_identifier(folder_get_default_inbox_for_class(F_MH));
3589 gtk_entry_set_text(GTK_ENTRY(receive_page.inbox_entry),
3590 id);
3591 gtk_entry_set_text(GTK_ENTRY(receive_page.local_inbox_entry),
3592 id);
3593 g_free(id);
3594 mailbox = gtk_entry_get_text(GTK_ENTRY(inbox_entry));
3595 inbox = folder_find_item_from_identifier(mailbox);
3597 if (inbox == NULL) {
3598 alertpanel_error(_("The default Inbox folder doesn't exist."));
3599 return -1;
3602 if (protocol == A_IMAP4 &&
3603 *gtk_entry_get_text(GTK_ENTRY(basic_page.recvserv_entry)) == '\0') {
3604 alertpanel_error(_("IMAP server is not entered."));
3605 return -1;
3607 if (protocol == A_NNTP &&
3608 *gtk_entry_get_text(GTK_ENTRY(basic_page.nntpserv_entry)) == '\0') {
3609 alertpanel_error(_("NNTP server is not entered."));
3610 return -1;
3613 if (protocol == A_LOCAL &&
3614 *gtk_entry_get_text(GTK_ENTRY(basic_page.localmbox_entry)) == '\0') {
3615 alertpanel_error(_("local mailbox filename is not entered."));
3616 return -1;
3619 if (protocol == A_LOCAL &&
3620 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(basic_page.mailcmd_checkbtn)) && *gtk_entry_get_text(GTK_ENTRY(basic_page.mailcmd_entry)) == '\0') {
3621 alertpanel_error(_("mail command is not entered."));
3622 return -1;
3625 if (protocol == A_IMAP4 || protocol == A_NNTP)
3626 old_id = g_strdup_printf("#%s/%s",
3627 protocol == A_IMAP4 ? "imap":"news",
3628 tmp_ac_prefs.account_name ? tmp_ac_prefs.account_name : "(null)");
3630 if (strchr(gtk_entry_get_text(GTK_ENTRY(basic_page.uid_entry)), '\n') != NULL) {
3631 alertpanel_error(_("User ID cannot contain a newline character."));
3632 if (old_id)
3633 g_free(old_id);
3634 return -1;
3637 if (strchr(gtk_entry_get_text(GTK_ENTRY(basic_page.pass_entry)), '\n') != NULL) {
3638 alertpanel_error(_("Password cannot contain a newline character."));
3639 if (old_id)
3640 g_free(old_id);
3641 return -1;
3644 prefs_set_data_from_dialog(basic_param);
3646 /* Passwords are stored outside of PrefParams. */
3647 passwd_store_set_account(tmp_ac_prefs.account_id,
3648 PWS_ACCOUNT_RECV,
3649 gtk_entry_get_text(GTK_ENTRY(basic_page.pass_entry)),
3650 FALSE);
3652 #ifdef USE_OAUTH2
3653 /* Manual password change - reset expiry on OAUTH2 tokens*/
3654 passwd_store_set_account(tmp_ac_prefs.account_id, PWS_ACCOUNT_OAUTH2_EXPIRY, "0", FALSE);
3655 #endif
3657 if (protocol == A_IMAP4 || protocol == A_NNTP) {
3658 new_id = g_strdup_printf("#%s/%s",
3659 protocol == A_IMAP4 ? "imap":"news",
3660 tmp_ac_prefs.account_name);
3661 if (old_id != NULL && new_id != NULL)
3662 prefs_filtering_rename_path(old_id, new_id);
3663 if (old_id)
3664 g_free(old_id);
3665 if (new_id)
3666 g_free(new_id);
3669 return 0;
3672 static gint prefs_receive_apply(void)
3674 if (strchr(gtk_entry_get_text(GTK_ENTRY(send_page.smtp_uid_entry)), '\n') != NULL) {
3675 alertpanel_error(_("SMTP user ID cannot contain a newline character."));
3676 return -1;
3679 if (strchr(gtk_entry_get_text(GTK_ENTRY(send_page.smtp_pass_entry)), '\n') != NULL) {
3680 alertpanel_error(_("SMTP password cannot contain a newline character."));
3681 return -1;
3684 prefs_set_data_from_dialog(receive_param);
3686 return 0;
3689 static gint prefs_send_apply(void)
3691 prefs_set_data_from_dialog(send_param);
3693 /* Passwords are stored outside of PrefParams. */
3694 passwd_store_set_account(tmp_ac_prefs.account_id,
3695 PWS_ACCOUNT_SEND,
3696 gtk_entry_get_text(GTK_ENTRY(send_page.smtp_pass_entry)),
3697 FALSE);
3698 #ifdef USE_OAUTH2
3699 /* Manual password change - reset expiry on OAUTH2 tokens*/
3700 passwd_store_set_account(tmp_ac_prefs.account_id, PWS_ACCOUNT_OAUTH2_EXPIRY, "0", FALSE);
3701 #endif
3703 return 0;
3706 #ifdef USE_OAUTH2
3707 static gint prefs_oauth2_apply(void)
3709 prefs_set_data_from_dialog(oauth2_param);
3711 /* Passwords are stored outside of PrefParams. */
3712 passwd_store_set_account(tmp_ac_prefs.account_id,
3713 PWS_ACCOUNT_OAUTH2_AUTH,
3714 gtk_entry_get_text(GTK_ENTRY(oauth2_page.oauth2_authcode_entry)),
3715 FALSE);
3717 return 0;
3719 #endif
3721 static gint prefs_compose_apply(void)
3723 prefs_set_data_from_dialog(compose_param);
3724 return 0;
3727 static gint prefs_templates_apply(void)
3729 prefs_set_data_from_dialog(templates_param);
3730 return 0;
3733 static gint prefs_privacy_apply(void)
3735 prefs_set_data_from_dialog(privacy_param);
3736 return 0;
3739 #ifdef USE_GNUTLS
3740 static gint prefs_ssl_apply(void)
3742 prefs_set_data_from_dialog(ssl_param);
3744 /* Passwords are stored outside of PrefParams. */
3745 passwd_store_set_account(tmp_ac_prefs.account_id,
3746 PWS_ACCOUNT_RECV_CERT,
3747 gtk_entry_get_text(GTK_ENTRY(ssl_page.entry_in_cert_pass)),
3748 FALSE);
3749 passwd_store_set_account(tmp_ac_prefs.account_id,
3750 PWS_ACCOUNT_SEND_CERT,
3751 gtk_entry_get_text(GTK_ENTRY(ssl_page.entry_out_cert_pass)),
3752 FALSE);
3754 return 0;
3756 #endif
3758 static gint prefs_proxy_apply(void)
3760 prefs_set_data_from_dialog(proxy_param);
3762 /* Passwords are stored outside of PrefParams. */
3763 passwd_store_set_account(tmp_ac_prefs.account_id,
3764 PWS_ACCOUNT_PROXY_PASS,
3765 gtk_entry_get_text(GTK_ENTRY(proxy_page.proxy_pass_entry)),
3766 FALSE);
3768 return 0;
3771 static gint prefs_advanced_apply(void)
3773 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(advanced_page.domain_checkbtn)) &&
3774 *gtk_entry_get_text(GTK_ENTRY(advanced_page.domain_entry)) == '\0') {
3775 alertpanel_error(_("domain is not specified."));
3776 return -1;
3778 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(advanced_page.sent_folder_checkbtn)) &&
3779 *gtk_entry_get_text(GTK_ENTRY(advanced_page.sent_folder_entry)) == '\0') {
3780 alertpanel_error(_("sent folder is not selected."));
3781 return -1;
3783 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(advanced_page.queue_folder_checkbtn)) &&
3784 *gtk_entry_get_text(GTK_ENTRY(advanced_page.queue_folder_entry)) == '\0') {
3785 alertpanel_error(_("queue folder is not selected."));
3786 return -1;
3788 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(advanced_page.draft_folder_checkbtn)) &&
3789 *gtk_entry_get_text(GTK_ENTRY(advanced_page.draft_folder_entry)) == '\0') {
3790 alertpanel_error(_("draft folder is not selected."));
3791 return -1;
3793 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(advanced_page.trash_folder_checkbtn)) &&
3794 *gtk_entry_get_text(GTK_ENTRY(advanced_page.trash_folder_entry)) == '\0') {
3795 alertpanel_error(_("trash folder is not selected."));
3796 return -1;
3799 prefs_set_data_from_dialog(advanced_param);
3800 return 0;
3803 static void basic_destroy_widget_func(PrefsPage *_page)
3805 /* BasicPage *page = (BasicPage *) _page; */
3808 static void receive_destroy_widget_func(PrefsPage *_page)
3810 /* ReceivePage *page = (ReceivePage *) _page; */
3813 static void send_destroy_widget_func(PrefsPage *_page)
3815 /* SendPage *page = (SendPage *) _page; */
3818 #ifdef USE_OAUTH2
3819 static void oauth2_destroy_widget_func(PrefsPage *_page)
3821 /* Oauth2Page *page = (Oauth2Page *) _page; */
3823 if(oauth2_listener_task){
3824 debug_print("Closing oauth2 listener task\n");
3825 oauth2_listener_cancel = 1;
3828 #endif
3830 static void compose_destroy_widget_func(PrefsPage *_page)
3832 /* ComposePage *page = (ComposePage *) _page; */
3835 static void templates_destroy_widget_func(PrefsPage *_page)
3837 /* TemplatesPage *page = (TemplatesPage *) _page; */
3840 static void privacy_destroy_widget_func(PrefsPage *_page)
3842 /* PrivacyPage *page = (PrivacyPage *) _page; */
3845 #ifdef USE_GNUTLS
3846 static void ssl_destroy_widget_func(PrefsPage *_page)
3848 /* SSLPage *page = (SSLPage *) _page; */
3850 #endif
3852 static void proxy_destroy_widget_func(PrefsPage *_page)
3854 /* ProxyPage *page = (ProxyPage *) _page; */
3857 static void advanced_destroy_widget_func(PrefsPage *_page)
3859 /* AdvancedPage *page = (AdvancedPage *) _page; */
3862 static gboolean basic_can_close_func(PrefsPage *_page)
3864 BasicPage *page = (BasicPage *) _page;
3866 if (!page->page.page_open)
3867 return TRUE;
3869 return prefs_basic_apply() >= 0;
3872 static gboolean receive_can_close_func(PrefsPage *_page)
3874 ReceivePage *page = (ReceivePage *) _page;
3876 if (!page->page.page_open)
3877 return TRUE;
3879 return prefs_receive_apply() >= 0;
3882 static gboolean send_can_close_func(PrefsPage *_page)
3884 SendPage *page = (SendPage *) _page;
3886 if (!page->page.page_open)
3887 return TRUE;
3889 return prefs_send_apply() >= 0;
3892 #ifdef USE_OAUTH2
3893 static gboolean oauth2_can_close_func(PrefsPage *_page)
3895 Oauth2Page *page = (Oauth2Page *) _page;
3897 if (!page->page.page_open)
3898 return TRUE;
3900 return prefs_oauth2_apply() >= 0;
3902 #endif
3904 static gboolean compose_can_close_func(PrefsPage *_page)
3906 ComposePage *page = (ComposePage *) _page;
3908 if (!page->page.page_open)
3909 return TRUE;
3911 return prefs_compose_apply() >= 0;
3914 static gboolean templates_can_close_func(PrefsPage *_page)
3916 TemplatesPage *page = (TemplatesPage *) _page;
3918 if (!page->page.page_open)
3919 return TRUE;
3921 return prefs_templates_apply() >= 0;
3924 static gboolean privacy_can_close_func(PrefsPage *_page)
3926 PrivacyPage *page = (PrivacyPage *) _page;
3928 if (!page->page.page_open)
3929 return TRUE;
3931 return prefs_privacy_apply() >= 0;
3934 #ifdef USE_GNUTLS
3935 static gboolean ssl_can_close_func(PrefsPage *_page)
3937 SSLPage *page = (SSLPage *) _page;
3939 if (!page->page.page_open)
3940 return TRUE;
3942 return prefs_ssl_apply() >= 0;
3944 #endif
3946 static gboolean proxy_can_close_func(PrefsPage *_page)
3948 ProxyPage *page = (ProxyPage *) _page;
3950 if (!page->page.page_open)
3951 return TRUE;
3953 return prefs_proxy_apply() >= 0;
3956 static gboolean advanced_can_close_func(PrefsPage *_page)
3958 AdvancedPage *page = (AdvancedPage *) _page;
3960 if (!page->page.page_open)
3961 return TRUE;
3963 return prefs_advanced_apply() >= 0;
3966 static void basic_save_func(PrefsPage *_page)
3968 BasicPage *page = (BasicPage *) _page;
3970 if (!page->page.page_open)
3971 return;
3973 if (prefs_basic_apply() >= 0)
3974 cancelled = FALSE;
3977 static void receive_save_func(PrefsPage *_page)
3979 ReceivePage *page = (ReceivePage *) _page;
3981 if (!page->page.page_open)
3982 return;
3984 if (prefs_receive_apply() >= 0)
3985 cancelled = FALSE;
3988 static void send_save_func(PrefsPage *_page)
3990 SendPage *page = (SendPage *) _page;
3992 if (!page->page.page_open)
3993 return;
3995 if (prefs_send_apply() >= 0)
3996 cancelled = FALSE;
3999 #ifdef USE_OAUTH2
4000 static void oauth2_save_func(PrefsPage *_page)
4002 Oauth2Page *page = (Oauth2Page *) _page;
4004 if (!page->page.page_open)
4005 return;
4007 if (prefs_oauth2_apply() >= 0)
4008 cancelled = FALSE;
4010 #endif
4012 static void compose_save_func(PrefsPage *_page)
4014 ComposePage *page = (ComposePage *) _page;
4016 if (!page->page.page_open)
4017 return;
4019 if (prefs_compose_apply() >= 0)
4020 cancelled = FALSE;
4023 static void templates_save_func(PrefsPage *_page)
4025 TemplatesPage *page = (TemplatesPage *) _page;
4027 if (!page->page.page_open)
4028 return;
4030 quotefmt_check_new_msg_formats(tmp_ac_prefs.compose_with_format,
4031 NULL,
4032 tmp_ac_prefs.compose_subject_format,
4033 tmp_ac_prefs.compose_body_format);
4034 quotefmt_check_reply_formats(tmp_ac_prefs.reply_with_format,
4035 NULL,
4036 tmp_ac_prefs.reply_quotemark,
4037 tmp_ac_prefs.reply_body_format);
4038 quotefmt_check_forward_formats(tmp_ac_prefs.forward_with_format,
4039 NULL,
4040 tmp_ac_prefs.forward_quotemark,
4041 tmp_ac_prefs.forward_body_format);
4042 if (prefs_templates_apply() >= 0)
4043 cancelled = FALSE;
4046 static void privacy_save_func(PrefsPage *_page)
4048 PrivacyPage *page = (PrivacyPage *) _page;
4050 if (!page->page.page_open)
4051 return;
4053 if (prefs_privacy_apply() >= 0)
4054 cancelled = FALSE;
4057 #ifdef USE_GNUTLS
4058 static void ssl_save_func(PrefsPage *_page)
4060 SSLPage *page = (SSLPage *) _page;
4062 if (!page->page.page_open)
4063 return;
4065 if (prefs_ssl_apply() >= 0)
4066 cancelled = FALSE;
4068 #endif
4070 static void proxy_save_func(PrefsPage *_page)
4072 ProxyPage *page = (ProxyPage *) _page;
4074 if (!page->page.page_open)
4075 return;
4077 if (prefs_proxy_apply() >= 0)
4078 cancelled = FALSE;
4081 static void advanced_save_func(PrefsPage *_page)
4083 AdvancedPage *page = (AdvancedPage *) _page;
4085 if (!page->page.page_open)
4086 return;
4088 if (prefs_advanced_apply() >= 0)
4089 cancelled = FALSE;
4092 static void register_basic_page(void)
4094 static gchar *path[3];
4096 path[0] = _("Account");
4097 path[1] = _("Basic");
4098 path[2] = NULL;
4100 basic_page.page.path = path;
4101 basic_page.page.weight = 1000.0;
4102 basic_page.page.create_widget = basic_create_widget_func;
4103 basic_page.page.destroy_widget = basic_destroy_widget_func;
4104 basic_page.page.save_page = basic_save_func;
4105 basic_page.page.can_close = basic_can_close_func;
4107 prefs_account_register_page((PrefsPage *) &basic_page);
4110 static void register_receive_page(void)
4112 static gchar *path[3];
4114 path[0] = _("Account");
4115 path[1] = _("Receive");
4116 path[2] = NULL;
4118 receive_page.page.path = path;
4119 receive_page.page.weight = 1000.0;
4120 receive_page.page.create_widget = receive_create_widget_func;
4121 receive_page.page.destroy_widget = receive_destroy_widget_func;
4122 receive_page.page.save_page = receive_save_func;
4123 receive_page.page.can_close = receive_can_close_func;
4125 prefs_account_register_page((PrefsPage *) &receive_page);
4128 static void register_send_page(void)
4130 static gchar *path[3];
4132 path[0] = _("Account");
4133 path[1] = _("Send");
4134 path[2] = NULL;
4136 send_page.page.path = path;
4137 send_page.page.weight = 1000.0;
4138 send_page.page.create_widget = send_create_widget_func;
4139 send_page.page.destroy_widget = send_destroy_widget_func;
4140 send_page.page.save_page = send_save_func;
4141 send_page.page.can_close = send_can_close_func;
4143 prefs_account_register_page((PrefsPage *) &send_page);
4146 #ifdef USE_OAUTH2
4147 static void register_oauth2_page(void)
4149 static gchar *path[3];
4151 path[0] = _("Account");
4152 path[1] = _("OAuth2");
4153 path[2] = NULL;
4155 oauth2_page.page.path = path;
4156 oauth2_page.page.weight = 1000.0;
4157 oauth2_page.page.create_widget = oauth2_create_widget_func;
4158 oauth2_page.page.destroy_widget = oauth2_destroy_widget_func;
4159 oauth2_page.page.save_page = oauth2_save_func;
4160 oauth2_page.page.can_close = oauth2_can_close_func;
4162 prefs_account_register_page((PrefsPage *) &oauth2_page);
4164 #endif
4166 static void register_compose_page(void)
4168 static gchar *path[3];
4170 path[0] = _("Account");
4171 path[1] = _("Compose");
4172 path[2] = NULL;
4174 compose_page.page.path = path;
4175 compose_page.page.weight = 1000.0;
4176 compose_page.page.create_widget = compose_create_widget_func;
4177 compose_page.page.destroy_widget = compose_destroy_widget_func;
4178 compose_page.page.save_page = compose_save_func;
4179 compose_page.page.can_close = compose_can_close_func;
4181 prefs_account_register_page((PrefsPage *) &compose_page);
4184 static void register_templates_page(void)
4186 static gchar *path[3];
4188 path[0] = _("Account");
4189 path[1] = _("Templates");
4190 path[2] = NULL;
4192 templates_page.page.path = path;
4193 templates_page.page.weight = 1000.0;
4194 templates_page.page.create_widget = templates_create_widget_func;
4195 templates_page.page.destroy_widget = templates_destroy_widget_func;
4196 templates_page.page.save_page = templates_save_func;
4197 templates_page.page.can_close = templates_can_close_func;
4199 prefs_account_register_page((PrefsPage *) &templates_page);
4202 static void register_privacy_page(void)
4204 static gchar *path[3];
4206 path[0] = _("Account");
4207 path[1] = _("Privacy");
4208 path[2] = NULL;
4210 privacy_page.page.path = path;
4211 privacy_page.page.weight = 1000.0;
4212 privacy_page.page.create_widget = privacy_create_widget_func;
4213 privacy_page.page.destroy_widget = privacy_destroy_widget_func;
4214 privacy_page.page.save_page = privacy_save_func;
4215 privacy_page.page.can_close = privacy_can_close_func;
4217 prefs_account_register_page((PrefsPage *) &privacy_page);
4220 #ifdef USE_GNUTLS
4221 static void register_ssl_page(void)
4223 static gchar *path[3];
4225 path[0] = _("Account");
4226 path[1] = _("TLS");
4227 path[2] = NULL;
4229 ssl_page.page.path = path;
4230 ssl_page.page.weight = 1000.0;
4231 ssl_page.page.create_widget = ssl_create_widget_func;
4232 ssl_page.page.destroy_widget = ssl_destroy_widget_func;
4233 ssl_page.page.save_page = ssl_save_func;
4234 ssl_page.page.can_close = ssl_can_close_func;
4236 prefs_account_register_page((PrefsPage *) &ssl_page);
4239 static gboolean sslcert_get_client_cert_hook(gpointer source, gpointer data)
4241 SSLClientCertHookData *hookdata = (SSLClientCertHookData *)source;
4242 PrefsAccount *account = (PrefsAccount *)hookdata->account;
4243 gchar *pwd_id;
4245 hookdata->cert_path = NULL;
4246 hookdata->password = NULL;
4248 if (!g_list_find(account_get_list(), account)) {
4249 g_warning("can't find account");
4250 return TRUE;
4253 if (hookdata->is_smtp) {
4254 if (account->out_ssl_client_cert_file && *account->out_ssl_client_cert_file)
4255 hookdata->cert_path = account->out_ssl_client_cert_file;
4256 pwd_id = PWS_ACCOUNT_SEND_CERT;
4257 } else {
4258 if (account->in_ssl_client_cert_file && *account->in_ssl_client_cert_file)
4259 hookdata->cert_path = account->in_ssl_client_cert_file;
4260 pwd_id = PWS_ACCOUNT_RECV_CERT;
4263 hookdata->password = passwd_store_get_account(account->account_id, pwd_id);
4264 return TRUE;
4267 struct GetPassData {
4268 GCond cond;
4269 GMutex mutex;
4270 gchar **pass;
4274 static gboolean do_get_pass(gpointer data)
4276 struct GetPassData *pass_data = (struct GetPassData *)data;
4277 g_mutex_lock(&pass_data->mutex);
4278 *(pass_data->pass) = input_dialog_query_password("the PKCS12 client certificate", NULL);
4279 g_cond_signal(&pass_data->cond);
4280 g_mutex_unlock(&pass_data->mutex);
4281 return FALSE;
4283 static gboolean sslcert_get_password(gpointer source, gpointer data)
4285 struct GetPassData pass_data;
4286 /* do complicated stuff to be able to call GTK from the mainloop */
4287 g_cond_init(&pass_data.cond);
4288 g_mutex_init(&pass_data.mutex);
4289 pass_data.pass = (gchar **)source;
4291 g_mutex_lock(&pass_data.mutex);
4293 g_idle_add(do_get_pass, &pass_data);
4295 g_cond_wait(&pass_data.cond, &pass_data.mutex);
4296 g_cond_clear(&pass_data.cond);
4297 g_mutex_unlock(&pass_data.mutex);
4298 g_mutex_clear(&pass_data.mutex);
4300 return TRUE;
4302 #endif
4304 static void register_proxy_page(void)
4306 static gchar *path[3];
4308 path[0] = _("Account");
4309 path[1] = _("Proxy");
4310 path[2] = NULL;
4312 proxy_page.page.path = path;
4313 proxy_page.page.weight = 1000.0;
4314 proxy_page.page.create_widget = proxy_create_widget_func;
4315 proxy_page.page.destroy_widget = proxy_destroy_widget_func;
4316 proxy_page.page.save_page = proxy_save_func;
4317 proxy_page.page.can_close = proxy_can_close_func;
4319 prefs_account_register_page((PrefsPage *) &proxy_page);
4322 static void register_advanced_page(void)
4324 static gchar *path[3];
4326 path[0] = _("Account");
4327 path[1] = _("Advanced");
4328 path[2] = NULL;
4330 advanced_page.page.path = path;
4331 advanced_page.page.weight = 1000.0;
4332 advanced_page.page.create_widget = advanced_create_widget_func;
4333 advanced_page.page.destroy_widget = advanced_destroy_widget_func;
4334 advanced_page.page.save_page = advanced_save_func;
4335 advanced_page.page.can_close = advanced_can_close_func;
4337 prefs_account_register_page((PrefsPage *) &advanced_page);
4340 void prefs_account_init()
4342 register_basic_page();
4343 register_receive_page();
4344 register_send_page();
4345 register_compose_page();
4346 register_templates_page();
4347 register_privacy_page();
4348 #ifdef USE_GNUTLS
4349 register_ssl_page();
4350 hooks_register_hook(SSLCERT_GET_CLIENT_CERT_HOOKLIST, sslcert_get_client_cert_hook, NULL);
4351 hooks_register_hook(SSL_CERT_GET_PASSWORD, sslcert_get_password, NULL);
4352 #endif
4353 register_proxy_page();
4354 #ifdef USE_OAUTH2
4355 register_oauth2_page();
4356 #endif
4357 register_advanced_page();
4360 PrefsAccount *prefs_account_new(void)
4362 PrefsAccount *ac_prefs;
4364 ac_prefs = g_new0(PrefsAccount, 1);
4365 memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
4366 prefs_set_default(basic_param);
4367 prefs_set_default(receive_param);
4368 prefs_set_default(send_param);
4369 prefs_set_default(oauth2_param);
4370 prefs_set_default(compose_param);
4371 prefs_set_default(templates_param);
4372 prefs_set_default(privacy_param);
4373 prefs_set_default(ssl_param);
4374 prefs_set_default(proxy_param);
4375 prefs_set_default(advanced_param);
4376 *ac_prefs = tmp_ac_prefs;
4377 ac_prefs->account_id = prefs_account_get_new_id();
4379 ac_prefs->privacy_prefs = g_hash_table_new(g_str_hash, g_str_equal);
4381 return ac_prefs;
4384 PrefsAccount *prefs_account_new_from_config(const gchar *label)
4386 const gchar *p = label;
4387 gchar *rcpath;
4388 gint id;
4389 gchar **strv, **cur;
4390 gsize len;
4391 PrefsAccount *ac_prefs;
4393 cm_return_val_if_fail(label != NULL, NULL);
4395 ac_prefs = g_new0(PrefsAccount, 1);
4397 /* Load default values to tmp_ac_prefs first, ... */
4398 memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
4399 prefs_set_default(basic_param);
4400 prefs_set_default(receive_param);
4401 prefs_set_default(send_param);
4402 prefs_set_default(oauth2_param);
4403 prefs_set_default(compose_param);
4404 prefs_set_default(templates_param);
4405 prefs_set_default(privacy_param);
4406 prefs_set_default(ssl_param);
4407 prefs_set_default(advanced_param);
4409 /* ... overriding them with values from stored config file. */
4410 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
4411 prefs_read_config(basic_param, label, rcpath, NULL);
4412 prefs_read_config(receive_param, label, rcpath, NULL);
4413 prefs_read_config(send_param, label, rcpath, NULL);
4414 prefs_read_config(oauth2_param, label, rcpath, NULL);
4415 prefs_read_config(compose_param, label, rcpath, NULL);
4416 prefs_read_config(templates_param, label, rcpath, NULL);
4417 prefs_read_config(privacy_param, label, rcpath, NULL);
4418 prefs_read_config(ssl_param, label, rcpath, NULL);
4419 prefs_read_config(proxy_param, label, rcpath, NULL);
4420 prefs_read_config(advanced_param, label, rcpath, NULL);
4421 g_free(rcpath);
4423 *ac_prefs = tmp_ac_prefs;
4425 while (*p && !g_ascii_isdigit(*p)) p++;
4426 id = atoi(p);
4427 if (id < 0) g_warning("wrong account id: %d", id);
4428 ac_prefs->account_id = id;
4430 /* Now parse privacy_prefs. */
4431 ac_prefs->privacy_prefs = g_hash_table_new(g_str_hash, g_str_equal);
4432 if (privacy_prefs != NULL) {
4433 strv = g_strsplit(privacy_prefs, ",", 0);
4434 for (cur = strv; *cur != NULL; cur++) {
4435 gchar *encvalue, *tmp;
4437 encvalue = strchr(*cur, '=');
4438 if (encvalue == NULL)
4439 continue;
4440 encvalue[0] = '\0';
4441 encvalue++;
4443 tmp = g_base64_decode_zero(encvalue, &len);
4444 if (len > 0)
4445 g_hash_table_insert(ac_prefs->privacy_prefs, g_strdup(*cur), tmp);
4446 else
4447 g_free(tmp);
4449 g_strfreev(strv);
4450 g_free(privacy_prefs);
4451 privacy_prefs = NULL;
4454 /* For older configurations, move stored passwords into the
4455 * password store. */
4456 gboolean passwords_migrated = FALSE;
4458 if (ac_prefs->passwd != NULL && strlen(ac_prefs->passwd) > 1) {
4459 passwd_store_set_account(ac_prefs->account_id,
4460 PWS_ACCOUNT_RECV, ac_prefs->passwd, TRUE);
4461 passwords_migrated = TRUE;
4463 if (ac_prefs->smtp_passwd != NULL && strlen(ac_prefs->smtp_passwd) > 1) {
4464 passwd_store_set_account(ac_prefs->account_id,
4465 PWS_ACCOUNT_SEND, ac_prefs->smtp_passwd, TRUE);
4466 passwords_migrated = TRUE;
4468 if (ac_prefs->in_ssl_client_cert_pass != NULL
4469 && strlen(ac_prefs->in_ssl_client_cert_pass) > 1) {
4470 passwd_store_set_account(ac_prefs->account_id,
4471 PWS_ACCOUNT_RECV_CERT, ac_prefs->in_ssl_client_cert_pass, TRUE);
4472 passwords_migrated = TRUE;
4474 if (ac_prefs->out_ssl_client_cert_pass != NULL
4475 && strlen(ac_prefs->out_ssl_client_cert_pass) > 1) {
4476 passwd_store_set_account(ac_prefs->account_id,
4477 PWS_ACCOUNT_SEND_CERT, ac_prefs->out_ssl_client_cert_pass, TRUE);
4478 passwords_migrated = TRUE;
4481 /* Write out password store to file immediately, to prevent
4482 * their loss. */
4483 if (passwords_migrated)
4484 passwd_store_write_config();
4486 ac_prefs->receive_in_progress = FALSE;
4488 prefs_custom_header_read_config(ac_prefs);
4490 /* Start the auto-check interval, if needed. */
4491 if (!ac_prefs->autochk_use_default && ac_prefs->autochk_use_custom
4492 && ac_prefs->autochk_itv > PREFS_RECV_AUTOCHECK_MIN_INTERVAL) {
4493 inc_account_autocheck_timer_set_interval(ac_prefs);
4496 return ac_prefs;
4499 static void create_privacy_prefs(gpointer key, gpointer _value, gpointer user_data)
4501 GString *str = (GString *) user_data;
4502 gchar *encvalue;
4503 gchar *value = (gchar *) _value;
4505 if (str->len > 0)
4506 g_string_append_c(str, ',');
4508 encvalue = g_base64_encode(value, strlen(value));
4509 g_string_append_printf(str, "%s=%s", (gchar *) key, encvalue);
4510 g_free(encvalue);
4513 #define WRITE_PARAM(PARAM_TABLE) \
4514 if (prefs_write_param(PARAM_TABLE, pfile->fp) < 0) { \
4515 g_warning("failed to write configuration to file"); \
4516 prefs_file_close_revert(pfile); \
4517 g_free(privacy_prefs); \
4518 privacy_prefs = NULL; \
4519 g_free(rcpath); \
4520 return; \
4523 void prefs_account_write_config_all(GList *account_list)
4525 GList *cur;
4526 gchar *rcpath;
4527 PrefFile *pfile;
4529 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
4530 if ((pfile = prefs_write_open(rcpath)) == NULL) {
4531 g_free(rcpath);
4532 return;
4535 for (cur = account_list; cur != NULL; cur = cur->next) {
4536 GString *str;
4538 tmp_ac_prefs = *(PrefsAccount *)cur->data;
4539 if (fprintf(pfile->fp, "[Account: %d]\n",
4540 tmp_ac_prefs.account_id) <= 0) {
4541 g_free(pfile);
4542 g_free(rcpath);
4543 return;
4546 str = g_string_sized_new(32);
4547 g_hash_table_foreach(tmp_ac_prefs.privacy_prefs, create_privacy_prefs, str);
4548 privacy_prefs = str->str;
4549 g_string_free(str, FALSE);
4551 WRITE_PARAM(basic_param)
4552 WRITE_PARAM(receive_param)
4553 WRITE_PARAM(send_param)
4554 WRITE_PARAM(oauth2_param)
4555 WRITE_PARAM(compose_param)
4556 WRITE_PARAM(templates_param)
4557 WRITE_PARAM(privacy_param)
4558 WRITE_PARAM(ssl_param)
4559 WRITE_PARAM(proxy_param)
4560 WRITE_PARAM(advanced_param)
4562 g_free(privacy_prefs);
4563 privacy_prefs = NULL;
4565 if (cur->next) {
4566 if (claws_fputc('\n', pfile->fp) == EOF) {
4567 FILE_OP_ERROR(rcpath, "claws_fputc");
4568 prefs_file_close_revert(pfile);
4569 g_free(rcpath);
4570 return;
4574 g_free(rcpath);
4576 if (prefs_file_close(pfile) < 0)
4577 g_warning("failed to write configuration to file");
4579 passwd_store_write_config();
4581 #undef WRITE_PARAM
4583 static gboolean free_privacy_prefs(gpointer key, gpointer value, gpointer user_data)
4585 g_free(key);
4586 g_free(value);
4588 return TRUE;
4591 void prefs_account_free(PrefsAccount *ac_prefs)
4593 if (!ac_prefs) return;
4595 g_hash_table_foreach_remove(ac_prefs->privacy_prefs, free_privacy_prefs, NULL);
4597 tmp_ac_prefs = *ac_prefs;
4598 prefs_free(basic_param);
4599 prefs_free(receive_param);
4600 prefs_free(send_param);
4601 prefs_free(oauth2_param);
4602 prefs_free(compose_param);
4603 prefs_free(templates_param);
4604 prefs_free(privacy_param);
4605 prefs_free(ssl_param);
4606 prefs_free(proxy_param);
4607 prefs_free(advanced_param);
4610 const gchar *prefs_account_get_privacy_prefs(PrefsAccount *account, gchar *id)
4612 return g_hash_table_lookup(account->privacy_prefs, id);
4615 void prefs_account_set_privacy_prefs(PrefsAccount *account, gchar *id, gchar *new_value)
4617 gchar *orig_key = NULL, *value;
4619 if (g_hash_table_lookup_extended(account->privacy_prefs, id, (gpointer *)(gchar *) &orig_key, (gpointer *)(gchar *) &value)) {
4620 g_hash_table_remove(account->privacy_prefs, id);
4622 g_free(orig_key);
4623 g_free(value);
4626 if (new_value != NULL)
4627 g_hash_table_insert(account->privacy_prefs, g_strdup(id), g_strdup(new_value));
4630 static gint prefs_account_get_new_id(void)
4632 GList *ac_list;
4633 PrefsAccount *ac;
4634 static gint last_id = 0;
4636 for (ac_list = account_get_list(); ac_list != NULL;
4637 ac_list = ac_list->next) {
4638 ac = (PrefsAccount *)ac_list->data;
4639 if (last_id < ac->account_id)
4640 last_id = ac->account_id;
4643 return last_id + 1;
4646 static void destroy_dialog(gpointer data)
4648 PrefsAccount *ac_prefs = (PrefsAccount *) data;
4649 if (!cancelled) {
4650 gboolean update_fld_list = FALSE;
4651 if (ac_prefs->protocol == A_IMAP4 && !new_account) {
4652 if ((&tmp_ac_prefs)->imap_subsonly != ac_prefs->imap_subsonly) {
4653 update_fld_list = TRUE;
4656 *ac_prefs = tmp_ac_prefs;
4657 if (update_fld_list)
4658 folderview_rescan_tree(ac_prefs->folder, FALSE);
4660 inc_account_autocheck_timer_set_interval(ac_prefs);
4662 } else /* the customhdr_list may have changed, update it anyway */
4663 ac_prefs->customhdr_list = (&tmp_ac_prefs)->customhdr_list;
4666 gtk_main_quit();
4669 PrefsAccount *prefs_account_open(PrefsAccount *ac_prefs, gboolean *dirty)
4671 gchar *title;
4673 if (prefs_rc_is_readonly(ACCOUNT_RC))
4674 return ac_prefs;
4676 debug_print("Opening account preferences window...\n");
4678 inc_lock();
4680 cancelled = TRUE;
4682 if (!ac_prefs) {
4683 ac_prefs = prefs_account_new();
4684 new_account = TRUE;
4685 } else
4686 new_account = FALSE;
4688 if (new_account)
4689 title = g_strdup (_("Preferences for new account"));
4690 else
4691 title = g_strdup_printf (_("%s - Account preferences"),
4692 ac_prefs->account_name);
4694 prefswindow_open_full(title, prefs_pages, ac_prefs, destroy_dialog,
4695 &prefs_common.editaccountwin_width, &prefs_common.editaccountwin_height,
4696 TRUE, NULL, NULL, NULL);
4697 g_free(title);
4698 gtk_main();
4700 inc_unlock();
4702 if (!cancelled && dirty != NULL)
4703 *dirty = TRUE;
4704 if (cancelled && new_account)
4705 return NULL;
4706 else {
4707 if (ac_prefs->recv_server)
4708 g_strstrip(ac_prefs->recv_server);
4709 if (ac_prefs->smtp_server)
4710 g_strstrip(ac_prefs->smtp_server);
4711 if (ac_prefs->nntp_server)
4712 g_strstrip(ac_prefs->nntp_server);
4714 return ac_prefs;
4718 static void crosspost_color_toggled(void)
4720 gboolean is_active;
4722 is_active = gtk_toggle_button_get_active
4723 (GTK_TOGGLE_BUTTON(advanced_page.crosspost_checkbtn));
4724 gtk_widget_set_sensitive(advanced_page.crosspost_colormenu, is_active);
4727 static void prefs_account_crosspost_set_data_from_colormenu(PrefParam *pparam)
4729 gint color;
4730 GtkWidget *combobox = *pparam->widget;
4732 color = colorlabel_get_combobox_colormenu_active(GTK_COMBO_BOX(combobox));
4733 *((gint *)pparam->data) = color;
4736 static void prefs_account_crosspost_set_colormenu(PrefParam *pparam)
4738 gint color = *((gint *)pparam->data);
4739 GtkWidget *combobox = *pparam->widget;
4741 colorlabel_set_combobox_colormenu_active(GTK_COMBO_BOX(combobox), color);
4744 static void pop_bfr_smtp_tm_set_sens(GtkWidget *widget, gpointer data)
4746 gtk_widget_set_sensitive(send_page.pop_bfr_smtp_tm_spinbtn,
4747 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(send_page.pop_bfr_smtp_checkbtn)));
4748 gtk_widget_set_sensitive(send_page.pop_auth_timeout_lbl,
4749 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(send_page.pop_bfr_smtp_checkbtn)));
4750 gtk_widget_set_sensitive(send_page.pop_auth_minutes_lbl,
4751 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(send_page.pop_bfr_smtp_checkbtn)));
4754 static void prefs_account_select_folder_cb(GtkWidget *widget, gpointer data)
4756 FolderItem *item;
4757 gchar *id;
4759 item = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL, FALSE, NULL);
4760 if (item && item->path) {
4761 id = folder_item_get_identifier(item);
4762 if (id) {
4763 gtk_entry_set_text(GTK_ENTRY(data), id);
4764 g_free(id);
4769 #if (defined USE_GNUTLS)
4770 static void auto_configure_cb (GtkWidget *widget, gpointer data)
4772 gchar *address = NULL;
4773 AutoConfigureData *recv_data;
4774 AutoConfigureData *send_data;
4775 static GCancellable *recv_cancel = NULL;
4776 static GCancellable *send_cancel = NULL;
4777 RecvProtocol protocol;
4778 struct BasicProtocol *protocol_optmenu = (struct BasicProtocol *) basic_page.protocol_optmenu;
4779 GtkWidget *optmenu = protocol_optmenu->combobox;
4781 if (!recv_cancel) {
4782 recv_cancel = g_cancellable_new();
4783 send_cancel = g_cancellable_new();
4786 if (widget == basic_page.auto_configure_cancel_btn) {
4787 g_cancellable_cancel(recv_cancel);
4788 g_cancellable_cancel(send_cancel);
4789 g_object_unref(recv_cancel);
4790 g_object_unref(send_cancel);
4791 recv_cancel = NULL;
4792 send_cancel = NULL;
4793 return;
4796 protocol = combobox_get_active_data(GTK_COMBO_BOX(optmenu));
4798 address = gtk_editable_get_chars(GTK_EDITABLE(basic_page.addr_entry), 0, -1);
4800 if (strchr(address, '@') == NULL) {
4801 g_free(address);
4802 gtk_label_set_text(GTK_LABEL(basic_page.auto_configure_lbl),
4803 _("Failed (wrong address)"));
4804 return;
4807 if (protocol == A_POP3 || protocol == A_IMAP4) {
4808 recv_data = g_new0(AutoConfigureData, 1);
4809 recv_data->configure_button = GTK_BUTTON(basic_page.auto_configure_btn);
4810 recv_data->cancel_button = GTK_BUTTON(basic_page.auto_configure_cancel_btn);
4811 recv_data->info_label = GTK_LABEL(basic_page.auto_configure_lbl);
4812 recv_data->cancel = recv_cancel;
4813 switch(protocol) {
4814 case A_POP3:
4815 recv_data->ssl_service = "pop3s";
4816 recv_data->tls_service = "pop3";
4817 recv_data->address = g_strdup(address);
4818 recv_data->hostname_entry = GTK_ENTRY(basic_page.recvserv_entry);
4819 recv_data->set_port = GTK_TOGGLE_BUTTON(advanced_page.popport_checkbtn);
4820 recv_data->port = GTK_SPIN_BUTTON(advanced_page.popport_spinbtn);
4821 recv_data->tls_checkbtn = GTK_TOGGLE_BUTTON(ssl_page.pop_starttls_radiobtn);
4822 recv_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(ssl_page.pop_ssltunnel_radiobtn);
4823 recv_data->default_port = 110;
4824 recv_data->default_ssl_port = 995;
4825 recv_data->uid_entry = GTK_ENTRY(basic_page.uid_entry);
4826 break;
4827 case A_IMAP4:
4828 recv_data->ssl_service = "imaps";
4829 recv_data->tls_service = "imap";
4830 recv_data->address = g_strdup(address);
4831 recv_data->hostname_entry = GTK_ENTRY(basic_page.recvserv_entry);
4832 recv_data->set_port = GTK_TOGGLE_BUTTON(advanced_page.imapport_checkbtn);
4833 recv_data->port = GTK_SPIN_BUTTON(advanced_page.imapport_spinbtn);
4834 recv_data->tls_checkbtn = GTK_TOGGLE_BUTTON(ssl_page.imap_starttls_radiobtn);
4835 recv_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(ssl_page.imap_ssltunnel_radiobtn);
4836 recv_data->default_port = 143;
4837 recv_data->default_ssl_port = 993;
4838 recv_data->uid_entry = GTK_ENTRY(basic_page.uid_entry);
4839 break;
4840 default:
4841 cm_return_if_fail(FALSE);
4843 auto_configure_service(recv_data);
4846 send_data = g_new0(AutoConfigureData, 1);
4847 send_data->configure_button = GTK_BUTTON(basic_page.auto_configure_btn);
4848 send_data->cancel_button = GTK_BUTTON(basic_page.auto_configure_cancel_btn);
4849 send_data->info_label = GTK_LABEL(basic_page.auto_configure_lbl);
4850 send_data->cancel = send_cancel;
4852 send_data->ssl_service = NULL;
4853 send_data->tls_service = "submission";
4854 send_data->address = g_strdup(address);
4855 send_data->hostname_entry = GTK_ENTRY(basic_page.smtpserv_entry);
4856 send_data->set_port = GTK_TOGGLE_BUTTON(advanced_page.smtpport_checkbtn);
4857 send_data->port = GTK_SPIN_BUTTON(advanced_page.smtpport_spinbtn);
4858 send_data->tls_checkbtn = GTK_TOGGLE_BUTTON(ssl_page.smtp_starttls_radiobtn);
4859 send_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(ssl_page.smtp_ssltunnel_radiobtn);
4860 send_data->default_port = 25;
4861 send_data->default_ssl_port = -1;
4862 send_data->uid_entry = NULL;
4863 send_data->auth_checkbtn = GTK_TOGGLE_BUTTON(send_page.smtp_auth_checkbtn);
4865 auto_configure_service(send_data);
4867 g_free(address);
4869 #endif
4871 static void prefs_account_sigfile_radiobtn_cb(GtkWidget *widget, gpointer data)
4873 gtk_widget_set_sensitive(GTK_WIDGET(signature_browse_button), TRUE);
4874 gtk_widget_set_sensitive(GTK_WIDGET(signature_edit_button), TRUE);
4877 static void prefs_account_sigcmd_radiobtn_cb(GtkWidget *widget, gpointer data)
4879 gtk_widget_set_sensitive(GTK_WIDGET(signature_browse_button), FALSE);
4880 gtk_widget_set_sensitive(GTK_WIDGET(signature_edit_button), FALSE);
4883 static void prefs_account_signature_browse_cb(GtkWidget *widget, gpointer data)
4885 gchar *filename;
4886 gchar *utf8_filename;
4888 filename = filesel_select_file_open(_("Select signature file"), NULL);
4889 if (!filename) return;
4891 utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
4892 if (!utf8_filename) {
4893 g_warning("prefs_account_signature_browse_cb(): failed to convert character set");
4894 utf8_filename = g_strdup(filename);
4896 gtk_entry_set_text(GTK_ENTRY(entry_sigpath), utf8_filename);
4897 g_free(utf8_filename);
4900 #ifdef USE_GNUTLS
4901 static void prefs_account_in_cert_browse_cb(GtkWidget *widget, gpointer data)
4903 gchar *filename;
4904 gchar *utf8_filename;
4906 filename = filesel_select_file_open(_("Select certificate file"), NULL);
4907 if (!filename) return;
4909 utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
4910 if (!utf8_filename) {
4911 g_warning("prefs_account_cert_browse_cb(): failed to convert character set");
4912 utf8_filename = g_strdup(filename);
4914 gtk_entry_set_text(GTK_ENTRY(entry_in_cert_file), utf8_filename);
4915 g_free(utf8_filename);
4918 static void prefs_account_out_cert_browse_cb(GtkWidget *widget, gpointer data)
4920 gchar *filename;
4921 gchar *utf8_filename;
4923 filename = filesel_select_file_open(_("Select certificate file"), NULL);
4924 if (!filename) return;
4926 utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
4927 if (!utf8_filename) {
4928 g_warning("prefs_account_cert_browse_cb(): failed to convert character set");
4929 utf8_filename = g_strdup(filename);
4931 gtk_entry_set_text(GTK_ENTRY(entry_out_cert_file), utf8_filename);
4932 g_free(utf8_filename);
4934 #endif
4936 static void prefs_account_signature_edit_cb(GtkWidget *widget, gpointer data)
4938 const gchar *sigpath = gtk_entry_get_text(GTK_ENTRY(data));
4939 if (!is_file_exist(sigpath))
4940 str_write_to_file(sigpath, "", TRUE);
4941 open_txt_editor(sigpath, prefs_common_get_ext_editor_cmd());
4944 static void prefs_account_edit_custom_header(void)
4946 prefs_custom_header_open(&tmp_ac_prefs);
4949 static void prefs_account_enum_set_data_from_radiobtn(PrefParam *pparam)
4951 GtkRadioButton *radiobtn;
4952 GSList *group;
4954 radiobtn = GTK_RADIO_BUTTON (*pparam->widget);
4955 group = gtk_radio_button_get_group (radiobtn);
4956 while (group != NULL) {
4957 GtkToggleButton *btn = GTK_TOGGLE_BUTTON (group->data);
4958 if (gtk_toggle_button_get_active (btn)) {
4959 *((gint *)pparam->data) = GPOINTER_TO_INT
4960 (g_object_get_data (G_OBJECT (btn), MENU_VAL_ID));
4961 break;
4963 group = group->next;
4967 static void prefs_account_enum_set_radiobtn(PrefParam *pparam)
4969 GtkRadioButton *radiobtn;
4970 GSList *group;
4971 gpointer data;
4973 data = GINT_TO_POINTER (*((gint *)pparam->data));
4974 radiobtn = GTK_RADIO_BUTTON (*pparam->widget);
4975 group = gtk_radio_button_get_group (radiobtn);
4976 while (group != NULL) {
4977 GtkToggleButton *btn = GTK_TOGGLE_BUTTON (group->data);
4978 gpointer data1 = g_object_get_data (G_OBJECT (btn), MENU_VAL_ID);
4979 if (data1 == data) {
4980 gtk_toggle_button_set_active (btn, TRUE);
4981 break;
4983 group = group->next;
4987 static void prefs_account_protocol_set_data_from_optmenu(PrefParam *pparam)
4989 struct BasicProtocol *protocol_optmenu =
4990 (struct BasicProtocol *)*pparam->widget;
4991 GtkWidget *optmenu = protocol_optmenu->combobox;
4993 *((RecvProtocol *)pparam->data) =
4994 combobox_get_active_data(GTK_COMBO_BOX(optmenu));
4997 static void prefs_account_protocol_set_optmenu(PrefParam *pparam)
4999 RecvProtocol protocol;
5000 struct BasicProtocol *protocol_optmenu =
5001 (struct BasicProtocol *)*pparam->widget;
5002 GtkWidget *optmenu = protocol_optmenu->combobox;
5003 GtkWidget *optlabel = protocol_optmenu->label;
5004 GtkWidget *descrlabel = protocol_optmenu->descrlabel;
5005 gchar *label = NULL;
5007 protocol = *((RecvProtocol *)pparam->data);
5009 /* Set combobox to correct value even if it will be hidden, so
5010 * we won't break existing accounts when saving. */
5011 combobox_select_by_data(GTK_COMBO_BOX(optmenu), protocol);
5013 /* Set up widgets accordingly */
5014 if( new_account ) {
5015 gtk_label_set_text(GTK_LABEL(descrlabel), _("Protocol"));
5016 gtk_widget_hide(optlabel);
5017 gtk_widget_show(optmenu);
5018 } else {
5019 gtk_label_set_text(GTK_LABEL(descrlabel), _("Protocol:"));
5020 label = g_markup_printf_escaped("<b>%s</b>", protocol_names[protocol]);
5021 gtk_label_set_markup(GTK_LABEL(optlabel), label);
5022 g_free(label);
5023 gtk_widget_hide(optmenu);
5024 gtk_widget_show(optlabel);
5025 #ifndef HAVE_LIBETPAN
5026 if (protocol == A_IMAP4 || protocol == A_NNTP) {
5027 gtk_widget_show(protocol_optmenu->no_imap_warn_icon);
5028 gtk_widget_show(protocol_optmenu->no_imap_warn_label);
5029 } else {
5030 gtk_widget_hide(protocol_optmenu->no_imap_warn_icon);
5031 gtk_widget_hide(protocol_optmenu->no_imap_warn_label);
5033 #endif
5034 if (protocol == A_IMAP4) {
5035 if (new_account)
5036 gtk_toggle_button_set_active(
5037 GTK_TOGGLE_BUTTON(send_page.msgid_checkbtn),
5038 TRUE);
5039 gtk_widget_hide(send_page.msgid_checkbtn);
5040 } else
5041 gtk_widget_show(send_page.msgid_checkbtn);
5043 gtk_widget_show(send_page.xmailer_checkbtn);
5047 static void prefs_account_imap_auth_type_set_data_from_optmenu(PrefParam *pparam)
5049 *((RecvProtocol *)pparam->data) =
5050 combobox_get_active_data(GTK_COMBO_BOX(*pparam->widget));
5053 static void prefs_account_imap_auth_type_set_optmenu(PrefParam *pparam)
5055 IMAPAuthType type = *((IMAPAuthType *)pparam->data);
5056 GtkComboBox *optmenu = GTK_COMBO_BOX(*pparam->widget);
5058 combobox_select_by_data(optmenu, type);
5061 static void prefs_account_smtp_auth_type_set_data_from_optmenu(PrefParam *pparam)
5063 *((RecvProtocol *)pparam->data) =
5064 combobox_get_active_data(GTK_COMBO_BOX(*pparam->widget));
5067 static void prefs_account_smtp_auth_type_set_optmenu(PrefParam *pparam)
5069 SMTPAuthType type = *((SMTPAuthType *)pparam->data);
5070 GtkComboBox *optmenu = GTK_COMBO_BOX(*pparam->widget);
5072 combobox_select_by_data(optmenu, type);
5075 static void prefs_account_set_autochk_interval_from_widgets(PrefParam *pparam)
5077 struct AutocheckWidgets *autochk_widgets =
5078 (struct AutocheckWidgets *)*pparam->widget;
5080 *(gint *)pparam->data =
5081 (3600 * gtk_spin_button_get_value_as_int(
5082 GTK_SPIN_BUTTON(autochk_widgets->autochk_hour_spinbtn)))
5083 + (60 * gtk_spin_button_get_value_as_int(
5084 GTK_SPIN_BUTTON(autochk_widgets->autochk_min_spinbtn)))
5085 + gtk_spin_button_get_value_as_int(
5086 GTK_SPIN_BUTTON(autochk_widgets->autochk_sec_spinbtn));
5089 static void prefs_account_pop_auth_type_set_data_from_optmenu(PrefParam *pparam)
5091 *((RecvProtocol *)pparam->data) =
5092 combobox_get_active_data(GTK_COMBO_BOX(*pparam->widget));
5095 static void prefs_account_pop_auth_type_set_optmenu(PrefParam *pparam)
5097 POPAuthType type = *((POPAuthType *)pparam->data);
5098 GtkComboBox *optmenu = GTK_COMBO_BOX(*pparam->widget);
5100 combobox_select_by_data(optmenu, type);
5103 #ifdef USE_OAUTH2
5104 static void prefs_account_oauth2_provider_set_data_from_optmenu(PrefParam *pparam)
5106 *((Oauth2Service *)pparam->data) =
5107 combobox_get_active_data(GTK_COMBO_BOX(*pparam->widget));
5110 static void prefs_account_oauth2_provider_set_optmenu(PrefParam *pparam)
5112 Oauth2Service type = *((Oauth2Service *)pparam->data);
5113 GtkComboBox *optmenu = GTK_COMBO_BOX(*pparam->widget);
5115 combobox_select_by_data(optmenu, type);
5118 static void prefs_account_oauth2_set_auth_sensitivity(void)
5120 const gchar *authcode = gtk_entry_get_text((GtkEntry *)oauth2_page.oauth2_authcode_entry);
5121 gchar *trim_text = g_strdup(authcode);
5122 g_strstrip(trim_text);
5123 gtk_widget_set_sensitive(oauth2_page.oauth2_authorise_btn, (*trim_text != 0));
5124 g_free(trim_text);
5127 static void prefs_account_oauth2_set_sensitivity(void)
5129 struct BasicProtocol *protocol_optmenu = (struct BasicProtocol *)oauth2_page.protocol_optmenu;
5130 GtkWidget *optmenu = protocol_optmenu->combobox;
5131 Oauth2Service service;
5133 service = combobox_get_active_data(GTK_COMBO_BOX(optmenu));
5135 if(service == OAUTH2AUTH_NONE)
5136 gtk_widget_set_sensitive(oauth2_page.oauth2_sensitive, FALSE);
5137 else
5138 gtk_widget_set_sensitive(oauth2_page.oauth2_sensitive, TRUE);
5141 static void prefs_account_oauth2_copy_url(GtkButton *button, gpointer data)
5143 struct BasicProtocol *protocol_optmenu = (struct BasicProtocol *)oauth2_page.protocol_optmenu;
5145 GtkWidget *optmenu = protocol_optmenu->combobox;
5147 GtkWidget *win;
5148 GtkClipboard *clip, *clip2;
5149 gint len;
5150 gchar *url;
5151 url = g_malloc(OAUTH2BUFSIZE+1);
5152 Oauth2Service service;
5153 const gchar * custom_client_id = NULL;
5154 struct Oauth2Listener *oauth2_listener_data;
5156 service = combobox_get_active_data(GTK_COMBO_BOX(optmenu));
5157 custom_client_id = gtk_entry_get_text((GtkEntry *)oauth2_page.oauth2_client_id_entry);
5159 oauth2_authorisation_url(service, &url, custom_client_id);
5161 win = gtk_widget_get_toplevel (optmenu);
5162 len = strlen(url);
5164 clip = gtk_widget_get_clipboard (win, GDK_SELECTION_PRIMARY);
5165 clip2 = gtk_widget_get_clipboard (win, GDK_SELECTION_CLIPBOARD);
5166 gtk_clipboard_set_text (clip, url, len);
5167 gtk_clipboard_set_text (clip2, url, len);
5169 if (strcmp(gtk_button_get_label(button), "Copy link") != 0)
5170 open_uri(url, prefs_common_get_uri_cmd());
5172 g_free(url);
5174 //Start listener task for authorisation reply using a separate task
5175 //Avoids hanging while we wait, and to allow cancellation of the process
5176 //If task already exists gracefully close it
5177 if(oauth2_listener_task){
5178 debug_print("Closing oauth2 listener task\n");
5179 oauth2_listener_cancel = 1;
5180 while (oauth2_listener_closed == 0)
5181 gtk_main_iteration();
5184 debug_print("Starting oauth2 listener task\n");
5186 oauth2_listener_data = g_new(struct Oauth2Listener, 1);
5187 oauth2_listener_data->success = FALSE;
5188 oauth2_listener_data->trim_text = NULL;
5189 oauth2_listener_data->service = combobox_get_active_data(GTK_COMBO_BOX(optmenu));
5190 oauth2_listener_data->OAUTH2Data = g_malloc(sizeof(* oauth2_listener_data->OAUTH2Data));
5191 oauth2_init (oauth2_listener_data->OAUTH2Data);
5192 oauth2_listener_data->OAUTH2Data->custom_client_secret =
5193 g_strdup(gtk_entry_get_text((GtkEntry *)oauth2_page.oauth2_client_secret_entry));
5194 oauth2_listener_data->OAUTH2Data->custom_client_id =
5195 g_strdup(gtk_entry_get_text((GtkEntry *)oauth2_page.oauth2_client_id_entry));
5197 oauth2_listener_cancel = 0;
5198 oauth2_listener_closed = 0;
5200 oauth2_listener_task = g_task_new(NULL, NULL, prefs_account_oauth2_callback, oauth2_listener_data);
5201 g_task_set_task_data(oauth2_listener_task, oauth2_listener_data, NULL);
5202 g_task_run_in_thread(oauth2_listener_task, prefs_account_oauth2_listener);
5205 static void prefs_account_oauth2_obtain_tokens(GtkButton *button, gpointer data)
5207 struct BasicProtocol *protocol_optmenu = (struct BasicProtocol *)oauth2_page.protocol_optmenu;
5209 GtkWidget *optmenu = protocol_optmenu->combobox;
5210 Oauth2Service service;
5211 OAUTH2Data *OAUTH2Data = g_malloc(sizeof(* OAUTH2Data));
5212 const gchar *authcode = gtk_entry_get_text ((GtkEntry *)oauth2_page.oauth2_authcode_entry);
5213 gchar *trim_text = g_strdup(authcode);
5214 g_strstrip(trim_text);
5215 gint ret;
5217 oauth2_init (OAUTH2Data);
5220 OAUTH2Data->custom_client_secret =
5221 g_strdup(gtk_entry_get_text((GtkEntry *)oauth2_page.oauth2_client_secret_entry));
5222 OAUTH2Data->custom_client_id =
5223 g_strdup(gtk_entry_get_text((GtkEntry *)oauth2_page.oauth2_client_id_entry));
5226 service = combobox_get_active_data(GTK_COMBO_BOX(optmenu));
5227 ret = oauth2_obtain_tokens (service, OAUTH2Data, trim_text);
5229 if(!ret){
5230 if(OAUTH2Data->refresh_token != NULL){
5231 passwd_store_set_account(tmp_ac_prefs.account_id,
5232 PWS_ACCOUNT_OAUTH2_REFRESH, OAUTH2Data->refresh_token, FALSE);
5233 log_message(LOG_PROTOCOL, "OAuth2 refresh token stored\n");
5236 if(OAUTH2Data->access_token != NULL){
5237 passwd_store_set_account(tmp_ac_prefs.account_id,
5238 PWS_ACCOUNT_RECV, OAUTH2Data->access_token, FALSE);
5240 passwd_store_set_account(tmp_ac_prefs.account_id,
5241 PWS_ACCOUNT_SEND, OAUTH2Data->access_token, FALSE);
5242 log_message(LOG_PROTOCOL, "OAuth2 access token stored\n");
5244 gtk_entry_set_text(GTK_ENTRY(basic_page.pass_entry), OAUTH2Data->access_token);
5245 gtk_entry_set_text(GTK_ENTRY(send_page.smtp_pass_entry), OAUTH2Data->access_token);
5248 if(OAUTH2Data->expiry_str != NULL){
5249 passwd_store_set_account(tmp_ac_prefs.account_id,
5250 PWS_ACCOUNT_OAUTH2_EXPIRY, OAUTH2Data->expiry_str, FALSE);
5251 log_message(LOG_PROTOCOL, "OAuth2 access token expiry stored\n");
5254 tmp_ac_prefs.oauth2_date = g_get_real_time () / G_USEC_PER_SEC;
5256 g_free(trim_text);
5257 g_free(OAUTH2Data);
5259 #endif
5261 static void prefs_account_set_autochk_interval_to_widgets(PrefParam *pparam)
5263 gint val = *((gint *)pparam->data);
5264 struct AutocheckWidgets *autochk_widgets =
5265 (struct AutocheckWidgets *)*pparam->widget;
5267 gtk_spin_button_set_value(
5268 GTK_SPIN_BUTTON(autochk_widgets->autochk_hour_spinbtn),
5269 val / 3600);
5270 gtk_spin_button_set_value(
5271 GTK_SPIN_BUTTON(autochk_widgets->autochk_min_spinbtn),
5272 (val % 3600) / 60);
5273 gtk_spin_button_set_value(
5274 GTK_SPIN_BUTTON(autochk_widgets->autochk_sec_spinbtn),
5275 (val % 3600) % 60);
5278 static void prefs_account_set_string_from_combobox(PrefParam *pparam)
5280 GtkWidget *combobox;
5281 GtkListStore *menu;
5282 GtkTreeIter iter;
5283 gchar **str;
5285 cm_return_if_fail(*pparam->widget != NULL);
5287 combobox = *pparam->widget;
5288 cm_return_if_fail(gtk_combo_box_get_active_iter(
5289 GTK_COMBO_BOX(combobox), &iter));
5291 str = (gchar **)pparam->data;
5292 g_free(*str);
5293 menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combobox)));
5294 gtk_tree_model_get(GTK_TREE_MODEL(menu), &iter,
5295 COMBOBOX_PRIVACY_PLUGIN_ID, &(*str),
5296 -1);
5299 /* Context struct and internal function called by gtk_tree_model_foreach().
5300 * This is used in prefs_account_set_privacy_combobox_from_string() to find
5301 * correct combobox entry to activate when account preferences are displayed
5302 * and their values are set according to preferences. */
5303 typedef struct _privacy_system_set_ctx {
5304 GtkWidget *combobox;
5305 gchar *prefsid;
5306 gboolean found;
5307 } PrivacySystemSetCtx;
5309 static gboolean _privacy_system_set_func(GtkTreeModel *model, GtkTreePath *path,
5310 GtkTreeIter *iter, PrivacySystemSetCtx *ctx)
5312 GtkWidget *combobox = ctx->combobox;
5313 gchar *prefsid = ctx->prefsid;
5314 gchar *curid;
5316 /* We're searching for correct privacy plugin ID. */
5317 gtk_tree_model_get(model, iter, COMBOBOX_PRIVACY_PLUGIN_ID, &curid, -1);
5318 if( strcmp(prefsid, curid) == 0 ) {
5319 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combobox), iter);
5320 g_free(curid);
5321 ctx->found = TRUE;
5322 return TRUE;
5325 g_free(curid);
5326 return FALSE;
5329 static void prefs_account_set_privacy_combobox_from_string(PrefParam *pparam)
5331 GtkWidget *optionmenu;
5332 GtkListStore *menu;
5333 GtkTreeIter iter;
5334 gboolean found = FALSE;
5335 gchar *prefsid;
5336 PrivacySystemSetCtx *ctx = NULL;
5338 cm_return_if_fail(*pparam->widget != NULL);
5340 prefsid = *((gchar **) pparam->data);
5341 if (prefsid == NULL)
5342 return;
5344 optionmenu = *pparam->widget;
5345 menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optionmenu)));
5347 ctx = g_new(PrivacySystemSetCtx, sizeof(PrivacySystemSetCtx));
5348 ctx->combobox = optionmenu;
5349 ctx->prefsid = prefsid;
5350 ctx->found = FALSE;
5352 gtk_tree_model_foreach(GTK_TREE_MODEL(menu),
5353 (GtkTreeModelForeachFunc)_privacy_system_set_func, ctx);
5354 found = ctx->found;
5355 g_free(ctx);
5357 /* If chosen privacy system is not available, add a dummy entry with
5358 * "not loaded" note and make it active. */
5359 if (!found) {
5360 gchar *name;
5362 name = g_strdup_printf(_("%s (plugin not loaded)"), prefsid);
5363 gtk_list_store_append(menu, &iter);
5364 gtk_list_store_set(menu, &iter,
5365 COMBOBOX_TEXT, name,
5366 COMBOBOX_DATA, 0,
5367 COMBOBOX_SENS, TRUE,
5368 COMBOBOX_PRIVACY_PLUGIN_ID, prefsid,
5369 -1);
5370 g_free(name);
5372 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(optionmenu), &iter);
5376 static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data)
5378 RecvProtocol protocol;
5379 struct BasicProtocol *protocol_optmenu = (struct BasicProtocol *)basic_page.protocol_optmenu;
5381 protocol = combobox_get_active_data(combobox);
5383 gtk_widget_hide(protocol_optmenu->no_imap_warn_icon);
5384 gtk_widget_hide(protocol_optmenu->no_imap_warn_label);
5386 switch(protocol) {
5387 case A_NNTP:
5388 #ifndef HAVE_LIBETPAN
5389 gtk_widget_show(protocol_optmenu->no_imap_warn_icon);
5390 gtk_widget_show(protocol_optmenu->no_imap_warn_label);
5391 #else
5392 gtk_widget_hide(protocol_optmenu->no_imap_warn_icon);
5393 gtk_widget_hide(protocol_optmenu->no_imap_warn_label);
5394 #endif
5395 gtk_widget_show(send_page.msgid_checkbtn);
5396 gtk_widget_show(send_page.xmailer_checkbtn);
5397 gtk_widget_show(basic_page.nntpserv_label);
5398 gtk_widget_show(basic_page.nntpserv_entry);
5399 gtk_grid_set_row_spacing(GTK_GRID(basic_page.serv_table), VSPACING_NARROW);
5401 gtk_widget_set_sensitive(basic_page.nntpauth_checkbtn, TRUE);
5402 gtk_widget_show(basic_page.nntpauth_checkbtn);
5404 gtk_widget_set_sensitive(basic_page.nntpauth_onconnect_checkbtn, TRUE);
5405 gtk_widget_show(basic_page.nntpauth_onconnect_checkbtn);
5407 gtk_widget_hide(basic_page.recvserv_label);
5408 gtk_widget_hide(basic_page.recvserv_entry);
5409 gtk_widget_show(basic_page.smtpserv_label);
5410 gtk_widget_show(basic_page.smtpserv_entry);
5411 gtk_widget_hide(basic_page.localmbox_label);
5412 gtk_widget_hide(basic_page.localmbox_entry);
5413 gtk_widget_hide(basic_page.mailcmd_label);
5414 gtk_widget_hide(basic_page.mailcmd_entry);
5415 gtk_widget_hide(basic_page.mailcmd_checkbtn);
5416 gtk_widget_show(basic_page.uid_label);
5417 gtk_widget_show(basic_page.pass_label);
5418 gtk_widget_show(basic_page.uid_entry);
5419 gtk_widget_show(basic_page.pass_entry);
5420 gtk_widget_show(basic_page.showpwd_checkbtn);
5422 gtk_widget_set_sensitive(basic_page.uid_label, TRUE);
5423 gtk_widget_set_sensitive(basic_page.pass_label, TRUE);
5424 gtk_widget_set_sensitive(basic_page.uid_entry, TRUE);
5425 gtk_widget_set_sensitive(basic_page.pass_entry, TRUE);
5426 gtk_widget_set_sensitive(basic_page.showpwd_checkbtn, TRUE);
5428 /* update userid/passwd sensitive state */
5430 prefs_account_nntpauth_toggled
5431 (GTK_TOGGLE_BUTTON(basic_page.nntpauth_checkbtn), NULL);
5432 gtk_widget_hide(receive_page.pop3_frame);
5433 gtk_widget_hide(receive_page.imap_frame);
5434 gtk_widget_hide(receive_page.local_frame);
5435 gtk_widget_show(receive_page.autochk_frame);
5436 gtk_widget_show(receive_page.frame_maxarticle);
5437 gtk_widget_set_sensitive(receive_page.filter_on_recv_checkbtn, TRUE);
5438 prefs_account_filter_on_recv_toggled
5439 (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn), NULL);
5440 gtk_widget_set_sensitive(receive_page.recvatgetall_checkbtn, TRUE);
5441 /* update pop_before_smtp sensitivity */
5442 gtk_toggle_button_set_active
5443 (GTK_TOGGLE_BUTTON(send_page.pop_bfr_smtp_checkbtn), FALSE);
5444 gtk_widget_set_sensitive(send_page.pop_bfr_smtp_checkbtn, FALSE);
5445 gtk_widget_set_sensitive(send_page.pop_bfr_smtp_tm_spinbtn, FALSE);
5447 if (!tmp_ac_prefs.account_name) {
5448 gtk_toggle_button_set_active
5449 (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn),
5450 TRUE);
5451 gtk_toggle_button_set_active
5452 (GTK_TOGGLE_BUTTON(receive_page.filterhook_on_recv_checkbtn),
5453 TRUE);
5454 gtk_toggle_button_set_active
5455 (GTK_TOGGLE_BUTTON(receive_page.recvatgetall_checkbtn),
5456 FALSE);
5459 #ifdef USE_GNUTLS
5460 gtk_widget_hide(ssl_page.pop_frame);
5461 gtk_widget_hide(ssl_page.imap_frame);
5462 gtk_widget_show(ssl_page.nntp_frame);
5463 gtk_widget_show(ssl_page.send_frame);
5464 #endif
5465 gtk_widget_hide(advanced_page.popport_hbox);
5466 gtk_widget_hide(advanced_page.imapport_hbox);
5467 gtk_widget_show(advanced_page.nntpport_hbox);
5468 gtk_widget_show(advanced_page.crosspost_checkbtn);
5469 gtk_widget_show(advanced_page.crosspost_colormenu);
5470 #ifndef G_OS_WIN32
5471 gtk_widget_hide(advanced_page.tunnelcmd_checkbtn);
5472 gtk_widget_hide(advanced_page.tunnelcmd_entry);
5473 #endif
5474 gtk_widget_hide(receive_page.imapdir_label);
5475 gtk_widget_hide(receive_page.imapdir_entry);
5476 gtk_widget_hide(receive_page.subsonly_checkbtn);
5477 gtk_widget_hide(receive_page.low_bandwidth_checkbtn);
5478 break;
5479 case A_LOCAL:
5480 gtk_widget_show(send_page.msgid_checkbtn);
5481 gtk_widget_show(send_page.xmailer_checkbtn);
5482 gtk_widget_hide(protocol_optmenu->no_imap_warn_icon);
5483 gtk_widget_hide(protocol_optmenu->no_imap_warn_label);
5484 gtk_widget_hide(basic_page.nntpserv_label);
5485 gtk_widget_hide(basic_page.nntpserv_entry);
5486 gtk_widget_set_sensitive(basic_page.nntpauth_checkbtn, FALSE);
5487 gtk_widget_hide(basic_page.nntpauth_checkbtn);
5488 gtk_grid_set_row_spacing(GTK_GRID(basic_page.serv_table), VSPACING_NARROW);
5490 gtk_widget_set_sensitive(basic_page.nntpauth_onconnect_checkbtn, FALSE);
5491 gtk_widget_hide(basic_page.nntpauth_onconnect_checkbtn);
5492 gtk_widget_hide(basic_page.recvserv_label);
5493 gtk_widget_hide(basic_page.recvserv_entry);
5494 gtk_widget_show(basic_page.smtpserv_label);
5495 gtk_widget_show(basic_page.smtpserv_entry);
5496 gtk_widget_show(basic_page.localmbox_label);
5497 gtk_widget_show(basic_page.localmbox_entry);
5498 gtk_widget_show(basic_page.mailcmd_label);
5499 gtk_widget_show(basic_page.mailcmd_entry);
5500 gtk_widget_show(basic_page.mailcmd_checkbtn);
5501 gtk_widget_hide(basic_page.uid_label);
5502 gtk_widget_hide(basic_page.pass_label);
5503 gtk_widget_hide(basic_page.uid_entry);
5504 gtk_widget_hide(basic_page.pass_entry);
5505 gtk_widget_hide(basic_page.showpwd_checkbtn);
5507 gtk_widget_set_sensitive(basic_page.uid_label, TRUE);
5508 gtk_widget_set_sensitive(basic_page.pass_label, TRUE);
5509 gtk_widget_set_sensitive(basic_page.uid_entry, TRUE);
5510 gtk_widget_set_sensitive(basic_page.pass_entry, TRUE);
5511 gtk_widget_set_sensitive(basic_page.showpwd_checkbtn, TRUE);
5512 gtk_widget_hide(receive_page.pop3_frame);
5513 gtk_widget_hide(receive_page.imap_frame);
5514 gtk_widget_show(receive_page.local_frame);
5515 gtk_widget_show(receive_page.autochk_frame);
5516 gtk_widget_hide(receive_page.frame_maxarticle);
5517 gtk_widget_set_sensitive(receive_page.filter_on_recv_checkbtn, TRUE);
5518 prefs_account_filter_on_recv_toggled
5519 (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn), NULL);
5520 gtk_widget_set_sensitive(receive_page.recvatgetall_checkbtn, TRUE);
5521 prefs_account_mailcmd_toggled
5522 (GTK_TOGGLE_BUTTON(basic_page.mailcmd_checkbtn), NULL);
5524 /* update pop_before_smtp sensitivity */
5525 gtk_toggle_button_set_active
5526 (GTK_TOGGLE_BUTTON(send_page.pop_bfr_smtp_checkbtn), FALSE);
5527 gtk_widget_set_sensitive(send_page.pop_bfr_smtp_checkbtn, FALSE);
5528 gtk_widget_set_sensitive(send_page.pop_bfr_smtp_tm_spinbtn, FALSE);
5530 if (!tmp_ac_prefs.account_name) {
5531 gtk_toggle_button_set_active
5532 (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn),
5533 TRUE);
5534 gtk_toggle_button_set_active
5535 (GTK_TOGGLE_BUTTON(receive_page.filterhook_on_recv_checkbtn),
5536 TRUE);
5537 gtk_toggle_button_set_active
5538 (GTK_TOGGLE_BUTTON(receive_page.recvatgetall_checkbtn),
5539 TRUE);
5542 #ifdef USE_GNUTLS
5543 gtk_widget_hide(ssl_page.pop_frame);
5544 gtk_widget_hide(ssl_page.imap_frame);
5545 gtk_widget_hide(ssl_page.nntp_frame);
5546 gtk_widget_show(ssl_page.send_frame);
5547 #endif
5548 gtk_widget_hide(advanced_page.popport_hbox);
5549 gtk_widget_hide(advanced_page.imapport_hbox);
5550 gtk_widget_hide(advanced_page.nntpport_hbox);
5551 gtk_widget_hide(advanced_page.crosspost_checkbtn);
5552 gtk_widget_hide(advanced_page.crosspost_colormenu);
5553 #ifndef G_OS_WIN32
5554 gtk_widget_hide(advanced_page.tunnelcmd_checkbtn);
5555 gtk_widget_hide(advanced_page.tunnelcmd_entry);
5556 #endif
5557 gtk_widget_hide(receive_page.imapdir_label);
5558 gtk_widget_hide(receive_page.imapdir_entry);
5559 gtk_widget_hide(receive_page.subsonly_checkbtn);
5560 gtk_widget_hide(receive_page.low_bandwidth_checkbtn);
5561 break;
5562 case A_IMAP4:
5563 #ifndef HAVE_LIBETPAN
5564 gtk_widget_show(protocol_optmenu->no_imap_warn_icon);
5565 gtk_widget_show(protocol_optmenu->no_imap_warn_label);
5566 #endif
5567 if (new_account)
5568 gtk_toggle_button_set_active(
5569 GTK_TOGGLE_BUTTON(send_page.msgid_checkbtn),
5570 TRUE);
5571 gtk_widget_hide(send_page.msgid_checkbtn);
5572 gtk_widget_show(send_page.xmailer_checkbtn);
5573 gtk_widget_hide(basic_page.nntpserv_label);
5574 gtk_widget_hide(basic_page.nntpserv_entry);
5575 gtk_grid_set_row_spacing(GTK_GRID(basic_page.serv_table), VSPACING_NARROW);
5576 gtk_widget_set_sensitive(basic_page.nntpauth_checkbtn, FALSE);
5577 gtk_widget_hide(basic_page.nntpauth_checkbtn);
5579 gtk_widget_set_sensitive(basic_page.nntpauth_onconnect_checkbtn, FALSE);
5580 gtk_widget_hide(basic_page.nntpauth_onconnect_checkbtn);
5582 gtk_widget_set_sensitive(basic_page.recvserv_label, TRUE);
5583 gtk_widget_set_sensitive(basic_page.recvserv_entry, TRUE);
5584 gtk_widget_show(basic_page.recvserv_label);
5585 gtk_widget_show(basic_page.recvserv_entry);
5586 gtk_widget_show(basic_page.smtpserv_label);
5587 gtk_widget_show(basic_page.smtpserv_entry);
5588 gtk_widget_hide(basic_page.localmbox_label);
5589 gtk_widget_hide(basic_page.localmbox_entry);
5590 gtk_widget_hide(basic_page.mailcmd_label);
5591 gtk_widget_hide(basic_page.mailcmd_entry);
5592 gtk_widget_hide(basic_page.mailcmd_checkbtn);
5593 gtk_widget_show(basic_page.uid_label);
5594 gtk_widget_show(basic_page.pass_label);
5595 gtk_widget_show(basic_page.uid_entry);
5596 gtk_widget_show(basic_page.pass_entry);
5597 gtk_widget_show(basic_page.showpwd_checkbtn);
5599 gtk_widget_set_sensitive(basic_page.uid_label, TRUE);
5600 gtk_widget_set_sensitive(basic_page.pass_label, TRUE);
5601 gtk_widget_set_sensitive(basic_page.uid_entry, TRUE);
5602 gtk_widget_set_sensitive(basic_page.pass_entry, TRUE);
5603 gtk_widget_set_sensitive(basic_page.showpwd_checkbtn, TRUE);
5604 gtk_widget_hide(receive_page.pop3_frame);
5605 gtk_widget_show(receive_page.imap_frame);
5606 gtk_widget_hide(receive_page.local_frame);
5607 gtk_widget_show(receive_page.autochk_frame);
5608 gtk_widget_hide(receive_page.frame_maxarticle);
5609 gtk_widget_set_sensitive(receive_page.filter_on_recv_checkbtn, TRUE);
5610 prefs_account_filter_on_recv_toggled
5611 (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn), NULL);
5612 gtk_widget_set_sensitive(receive_page.recvatgetall_checkbtn, TRUE);
5613 gtk_widget_set_sensitive(basic_page.smtpserv_entry, TRUE);
5614 gtk_widget_set_sensitive(basic_page.smtpserv_label, TRUE);
5616 /* update pop_before_smtp sensitivity */
5617 gtk_toggle_button_set_active
5618 (GTK_TOGGLE_BUTTON(send_page.pop_bfr_smtp_checkbtn), FALSE);
5619 gtk_widget_set_sensitive(send_page.pop_bfr_smtp_checkbtn, FALSE);
5620 gtk_widget_set_sensitive(send_page.pop_bfr_smtp_tm_spinbtn, FALSE);
5622 if (!tmp_ac_prefs.account_name) {
5623 gtk_toggle_button_set_active
5624 (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn),
5625 TRUE);
5626 gtk_toggle_button_set_active
5627 (GTK_TOGGLE_BUTTON(receive_page.filterhook_on_recv_checkbtn),
5628 TRUE);
5629 gtk_toggle_button_set_active
5630 (GTK_TOGGLE_BUTTON(receive_page.recvatgetall_checkbtn),
5631 FALSE);
5634 #ifdef USE_GNUTLS
5635 gtk_widget_hide(ssl_page.pop_frame);
5636 gtk_widget_show(ssl_page.imap_frame);
5637 gtk_widget_hide(ssl_page.nntp_frame);
5638 gtk_widget_show(ssl_page.send_frame);
5639 #endif
5640 gtk_widget_hide(advanced_page.popport_hbox);
5641 gtk_widget_show(advanced_page.imapport_hbox);
5642 gtk_widget_hide(advanced_page.nntpport_hbox);
5643 gtk_widget_hide(advanced_page.crosspost_checkbtn);
5644 gtk_widget_hide(advanced_page.crosspost_colormenu);
5645 #ifndef G_OS_WIN32
5646 gtk_widget_show(advanced_page.tunnelcmd_checkbtn);
5647 gtk_widget_show(advanced_page.tunnelcmd_entry);
5648 #endif
5649 gtk_widget_show(receive_page.imapdir_label);
5650 gtk_widget_show(receive_page.imapdir_entry);
5651 gtk_widget_show(receive_page.subsonly_checkbtn);
5652 gtk_widget_show(receive_page.low_bandwidth_checkbtn);
5653 break;
5654 case A_NONE:
5655 gtk_widget_show(send_page.msgid_checkbtn);
5656 gtk_widget_show(send_page.xmailer_checkbtn);
5657 gtk_widget_hide(protocol_optmenu->no_imap_warn_icon);
5658 gtk_widget_hide(protocol_optmenu->no_imap_warn_label);
5659 gtk_widget_hide(basic_page.nntpserv_label);
5660 gtk_widget_hide(basic_page.nntpserv_entry);
5661 gtk_grid_set_row_spacing(GTK_GRID(basic_page.serv_table), VSPACING_NARROW);
5662 gtk_widget_set_sensitive(basic_page.nntpauth_checkbtn, FALSE);
5663 gtk_widget_hide(basic_page.nntpauth_checkbtn);
5665 gtk_widget_set_sensitive(basic_page.nntpauth_onconnect_checkbtn, FALSE);
5666 gtk_widget_hide(basic_page.nntpauth_onconnect_checkbtn);
5668 gtk_widget_set_sensitive(basic_page.recvserv_label, FALSE);
5669 gtk_widget_set_sensitive(basic_page.recvserv_entry, FALSE);
5670 gtk_widget_hide(basic_page.recvserv_label);
5671 gtk_widget_hide(basic_page.recvserv_entry);
5672 gtk_widget_show(basic_page.smtpserv_label);
5673 gtk_widget_show(basic_page.smtpserv_entry);
5674 gtk_widget_hide(basic_page.localmbox_label);
5675 gtk_widget_hide(basic_page.localmbox_entry);
5676 gtk_widget_hide(basic_page.mailcmd_label);
5677 gtk_widget_hide(basic_page.mailcmd_entry);
5678 gtk_widget_hide(basic_page.mailcmd_checkbtn);
5679 gtk_widget_hide(basic_page.uid_label);
5680 gtk_widget_hide(basic_page.pass_label);
5681 gtk_widget_hide(basic_page.uid_entry);
5682 gtk_widget_hide(basic_page.pass_entry);
5683 gtk_widget_hide(basic_page.showpwd_checkbtn);
5685 gtk_widget_set_sensitive(basic_page.uid_label, FALSE);
5686 gtk_widget_set_sensitive(basic_page.pass_label, FALSE);
5687 gtk_widget_set_sensitive(basic_page.uid_entry, FALSE);
5688 gtk_widget_set_sensitive(basic_page.pass_entry, FALSE);
5689 gtk_widget_set_sensitive(basic_page.showpwd_checkbtn, FALSE);
5690 gtk_widget_set_sensitive(receive_page.pop3_frame, FALSE);
5691 gtk_widget_hide(receive_page.pop3_frame);
5692 gtk_widget_hide(receive_page.imap_frame);
5693 gtk_widget_hide(receive_page.local_frame);
5694 gtk_widget_hide(receive_page.autochk_frame);
5695 gtk_widget_hide(receive_page.frame_maxarticle);
5696 gtk_widget_set_sensitive(receive_page.filter_on_recv_checkbtn, FALSE);
5697 prefs_account_filter_on_recv_toggled
5698 (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn), NULL);
5699 gtk_widget_set_sensitive(receive_page.recvatgetall_checkbtn, FALSE);
5701 gtk_widget_set_sensitive(basic_page.smtpserv_entry, TRUE);
5702 gtk_widget_set_sensitive(basic_page.smtpserv_label, TRUE);
5704 /* update pop_before_smtp sensitivity */
5705 gtk_widget_set_sensitive(send_page.pop_bfr_smtp_checkbtn, FALSE);
5706 pop_bfr_smtp_tm_set_sens(NULL, NULL);
5708 gtk_toggle_button_set_active
5709 (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn), FALSE);
5710 gtk_toggle_button_set_active
5711 (GTK_TOGGLE_BUTTON(receive_page.filterhook_on_recv_checkbtn), FALSE);
5712 gtk_toggle_button_set_active
5713 (GTK_TOGGLE_BUTTON(receive_page.recvatgetall_checkbtn), FALSE);
5715 #ifdef USE_GNUTLS
5716 gtk_widget_hide(ssl_page.pop_frame);
5717 gtk_widget_hide(ssl_page.imap_frame);
5718 gtk_widget_hide(ssl_page.nntp_frame);
5719 gtk_widget_show(ssl_page.send_frame);
5720 #endif
5721 gtk_widget_hide(advanced_page.popport_hbox);
5722 gtk_widget_hide(advanced_page.imapport_hbox);
5723 gtk_widget_hide(advanced_page.nntpport_hbox);
5724 gtk_widget_hide(advanced_page.crosspost_checkbtn);
5725 gtk_widget_hide(advanced_page.crosspost_colormenu);
5726 #ifndef G_OS_WIN32
5727 gtk_widget_hide(advanced_page.tunnelcmd_checkbtn);
5728 gtk_widget_hide(advanced_page.tunnelcmd_entry);
5729 #endif
5730 gtk_widget_hide(receive_page.imapdir_label);
5731 gtk_widget_hide(receive_page.imapdir_entry);
5732 gtk_widget_hide(receive_page.subsonly_checkbtn);
5733 gtk_widget_hide(receive_page.low_bandwidth_checkbtn);
5734 break;
5735 case A_POP3:
5736 /* continue to default: */
5737 default:
5738 gtk_widget_show(send_page.msgid_checkbtn);
5739 gtk_widget_show(send_page.xmailer_checkbtn);
5740 gtk_widget_hide(protocol_optmenu->no_imap_warn_icon);
5741 gtk_widget_hide(protocol_optmenu->no_imap_warn_label);
5742 gtk_widget_hide(basic_page.nntpserv_label);
5743 gtk_widget_hide(basic_page.nntpserv_entry);
5744 gtk_grid_set_row_spacing(GTK_GRID(basic_page.serv_table), VSPACING_NARROW);
5745 gtk_widget_set_sensitive(basic_page.nntpauth_checkbtn, FALSE);
5746 gtk_widget_hide(basic_page.nntpauth_checkbtn);
5748 gtk_widget_set_sensitive(basic_page.nntpauth_onconnect_checkbtn, FALSE);
5749 gtk_widget_hide(basic_page.nntpauth_onconnect_checkbtn);
5751 gtk_widget_set_sensitive(basic_page.recvserv_label, TRUE);
5752 gtk_widget_set_sensitive(basic_page.recvserv_entry, TRUE);
5753 gtk_widget_show(basic_page.recvserv_label);
5754 gtk_widget_show(basic_page.recvserv_entry);
5755 gtk_widget_show(basic_page.smtpserv_label);
5756 gtk_widget_show(basic_page.smtpserv_entry);
5757 gtk_widget_hide(basic_page.localmbox_label);
5758 gtk_widget_hide(basic_page.localmbox_entry);
5759 gtk_widget_hide(basic_page.mailcmd_label);
5760 gtk_widget_hide(basic_page.mailcmd_entry);
5761 gtk_widget_hide(basic_page.mailcmd_checkbtn);
5762 gtk_widget_show(basic_page.uid_label);
5763 gtk_widget_show(basic_page.pass_label);
5764 gtk_widget_show(basic_page.uid_entry);
5765 gtk_widget_show(basic_page.pass_entry);
5766 gtk_widget_show(basic_page.showpwd_checkbtn);
5768 gtk_widget_set_sensitive(basic_page.uid_label, TRUE);
5769 gtk_widget_set_sensitive(basic_page.pass_label, TRUE);
5770 gtk_widget_set_sensitive(basic_page.uid_entry, TRUE);
5771 gtk_widget_set_sensitive(basic_page.pass_entry, TRUE);
5772 gtk_widget_set_sensitive(basic_page.showpwd_checkbtn, TRUE);
5773 gtk_widget_set_sensitive(receive_page.pop3_frame, TRUE);
5774 gtk_widget_show(receive_page.pop3_frame);
5775 gtk_widget_hide(receive_page.imap_frame);
5776 gtk_widget_hide(receive_page.local_frame);
5777 gtk_widget_show(receive_page.autochk_frame);
5778 gtk_widget_hide(receive_page.frame_maxarticle);
5779 gtk_widget_set_sensitive(receive_page.filter_on_recv_checkbtn, TRUE);
5780 prefs_account_filter_on_recv_toggled
5781 (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn), NULL);
5782 gtk_widget_set_sensitive(receive_page.recvatgetall_checkbtn, TRUE);
5784 gtk_widget_set_sensitive(basic_page.smtpserv_entry, TRUE);
5785 gtk_widget_set_sensitive(basic_page.smtpserv_label, TRUE);
5787 /* update pop_before_smtp sensitivity */
5788 gtk_widget_set_sensitive(send_page.pop_bfr_smtp_checkbtn, TRUE);
5789 pop_bfr_smtp_tm_set_sens(NULL, NULL);
5791 if (!tmp_ac_prefs.account_name) {
5792 gtk_toggle_button_set_active
5793 (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn),
5794 TRUE);
5795 gtk_toggle_button_set_active
5796 (GTK_TOGGLE_BUTTON(receive_page.filterhook_on_recv_checkbtn),
5797 TRUE);
5798 gtk_toggle_button_set_active
5799 (GTK_TOGGLE_BUTTON(receive_page.recvatgetall_checkbtn),
5800 TRUE);
5803 #ifdef USE_GNUTLS
5804 gtk_widget_show(ssl_page.pop_frame);
5805 gtk_widget_hide(ssl_page.imap_frame);
5806 gtk_widget_hide(ssl_page.nntp_frame);
5807 gtk_widget_show(ssl_page.send_frame);
5808 #endif
5809 gtk_widget_show(advanced_page.popport_hbox);
5810 gtk_widget_hide(advanced_page.imapport_hbox);
5811 gtk_widget_hide(advanced_page.nntpport_hbox);
5812 gtk_widget_hide(advanced_page.crosspost_checkbtn);
5813 gtk_widget_hide(advanced_page.crosspost_colormenu);
5814 #ifndef G_OS_WIN32
5815 gtk_widget_hide(advanced_page.tunnelcmd_checkbtn);
5816 gtk_widget_hide(advanced_page.tunnelcmd_entry);
5817 #endif
5818 gtk_widget_hide(receive_page.imapdir_label);
5819 gtk_widget_hide(receive_page.imapdir_entry);
5820 gtk_widget_hide(receive_page.subsonly_checkbtn);
5821 gtk_widget_hide(receive_page.low_bandwidth_checkbtn);
5822 break;
5825 gtk_widget_queue_resize(basic_page.serv_frame);
5828 static void prefs_account_nntpauth_toggled(GtkToggleButton *button,
5829 gpointer user_data)
5831 gboolean auth;
5833 if (!gtk_widget_get_sensitive (GTK_WIDGET (button)))
5834 return;
5835 auth = gtk_toggle_button_get_active (button);
5836 gtk_widget_set_sensitive(basic_page.uid_label, auth);
5837 gtk_widget_set_sensitive(basic_page.pass_label, auth);
5838 gtk_widget_set_sensitive(basic_page.uid_entry, auth);
5839 gtk_widget_set_sensitive(basic_page.pass_entry, auth);
5840 gtk_widget_set_sensitive(basic_page.showpwd_checkbtn, auth);
5841 gtk_widget_set_sensitive(basic_page.nntpauth_onconnect_checkbtn, auth);
5844 static void prefs_account_mailcmd_toggled(GtkToggleButton *button,
5845 gpointer user_data)
5847 gboolean use_mailcmd;
5849 use_mailcmd = gtk_toggle_button_get_active (button);
5851 gtk_widget_set_sensitive(basic_page.mailcmd_entry, use_mailcmd);
5852 gtk_widget_set_sensitive(basic_page.mailcmd_label, use_mailcmd);
5853 gtk_widget_set_sensitive(basic_page.smtpserv_entry, !use_mailcmd);
5854 gtk_widget_set_sensitive(basic_page.smtpserv_label, !use_mailcmd);
5855 gtk_widget_set_sensitive(basic_page.uid_entry, !use_mailcmd);
5856 gtk_widget_set_sensitive(basic_page.pass_entry, !use_mailcmd);
5857 gtk_widget_set_sensitive(basic_page.showpwd_checkbtn, !use_mailcmd);
5860 static void prefs_account_showpwd_checkbtn_toggled(GtkToggleButton *button,
5861 gpointer user_data)
5863 gboolean active = gtk_toggle_button_get_active(button);
5864 GtkWidget *entry = GTK_WIDGET(user_data);
5866 gtk_entry_set_visibility(GTK_ENTRY(entry), active);
5869 static void prefs_account_entry_changed_newline_check_cb(GtkWidget *entry,
5870 gpointer user_data)
5872 static GdkColor red = { (guint32)0, (guint16)0xff, (guint16)0x70, (guint16)0x70 };
5874 if (strchr(gtk_entry_get_text(GTK_ENTRY(entry)), '\n') != NULL) {
5875 /* Entry contains a newline, light it up. */
5876 debug_print("found newline in string, painting entry red\n");
5877 gtk_widget_modify_base(entry, GTK_STATE_NORMAL, &red);
5878 } else {
5879 gtk_widget_modify_base(entry, GTK_STATE_NORMAL, NULL);
5883 static void prefs_account_filter_on_recv_toggled(GtkToggleButton *button,
5884 gpointer user_data)
5886 gboolean do_filter;
5888 do_filter = gtk_toggle_button_get_active (button);
5889 gtk_widget_set_sensitive(receive_page.filterhook_on_recv_checkbtn, do_filter);
5892 #if USE_ENCHANT
5893 static void prefs_account_compose_default_dictionary_set_string_from_optmenu
5894 (PrefParam *pparam)
5896 GtkWidget *combo;
5897 gchar **str;
5899 cm_return_if_fail(*pparam->widget != NULL);
5901 combo = *pparam->widget;
5902 str = (gchar **) pparam->data;
5904 g_free(*str);
5905 *str = gtkaspell_get_dictionary_menu_active_item(GTK_COMBO_BOX(combo));
5908 static void prefs_account_compose_default_dictionary_set_optmenu_from_string
5909 (PrefParam *pparam)
5911 GtkWidget *combo;
5912 gchar *dictionary;
5914 cm_return_if_fail(*pparam->widget != NULL);
5916 dictionary = *((gchar **) pparam->data);
5917 if (dictionary != NULL) {
5918 if (strrchr(dictionary, '/')) {
5919 dictionary = g_strdup(strrchr(dictionary, '/')+1);
5922 if (strchr(dictionary, '-')) {
5923 *(strchr(dictionary, '-')) = '\0';
5926 combo = *pparam->widget;
5927 if (dictionary && *dictionary)
5928 gtkaspell_set_dictionary_menu_active_item(GTK_COMBO_BOX(combo),
5929 dictionary);
5930 else {
5931 GtkTreeModel *model;
5932 GtkTreeIter iter;
5933 if((model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo))) == NULL)
5934 return;
5935 if((gtk_tree_model_get_iter_first(model, &iter)) == FALSE)
5936 return;
5937 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo), &iter);
5940 #endif
5942 gchar *prefs_account_generate_msgid(PrefsAccount *account)
5944 gchar *addr, *tmbuf, *buf = NULL;
5945 GDateTime *now;
5946 gchar *user_addr = account->msgid_with_addr ? g_strdup(account->address) : NULL;
5948 if (account->set_domain && account->domain) {
5949 buf = g_strdup(account->domain);
5950 } else if (!strncmp(get_domain_name(), "localhost", strlen("localhost"))) {
5951 buf = g_strdup(
5952 strchr(account->address, '@') ?
5953 strchr(account->address, '@')+1 :
5954 account->address);
5957 if (user_addr != NULL) {
5958 addr = g_strdup_printf(".%s", user_addr);
5959 } else {
5960 addr = g_strdup_printf("@%s",
5961 buf != NULL && strlen(buf) > 0 ?
5962 buf : get_domain_name());
5965 if (buf != NULL)
5966 g_free(buf);
5967 if (user_addr != NULL)
5968 g_free(user_addr);
5970 /* Replace all @ but the last one in addr, with underscores.
5971 * RFC 2822 States that msg-id syntax only allows one @.
5973 while (strchr(addr, '@') != NULL && strchr(addr, '@') != strrchr(addr, '@'))
5974 *(strchr(addr, '@')) = '_';
5976 now = (prefs_common.hide_timezone)? g_date_time_new_now_utc() :
5977 g_date_time_new_now_local();
5978 tmbuf = g_date_time_format(now, "%Y%m%d%H%M%S");
5979 buf = g_strdup_printf("%s.%08x%s",
5980 tmbuf, (guint)rand(), addr);
5981 g_date_time_unref(now);
5982 g_free(tmbuf);
5983 g_free(addr);
5985 debug_print("Generated Message-ID string '%s'\n", buf);
5986 return buf;
5989 void prefs_account_register_page(PrefsPage *page)
5991 prefs_pages = g_slist_append(prefs_pages, page);
5995 void prefs_account_unregister_page(PrefsPage *page)
5997 prefs_pages = g_slist_remove(prefs_pages, page);
6000 gchar *prefs_account_cache_dir(PrefsAccount *ac_prefs, gboolean for_server)
6002 gchar *dir = NULL;
6003 #ifdef G_OS_WIN32
6004 gchar *sanitized_server;
6005 #endif
6007 if (ac_prefs->protocol == A_IMAP4) {
6008 #ifdef G_OS_WIN32
6009 sanitized_server = g_strdup(ac_prefs->recv_server);
6010 g_strdelimit(sanitized_server, ":", ',');
6011 #endif
6012 if (for_server) {
6013 dir = g_strconcat(get_imap_cache_dir(),
6014 G_DIR_SEPARATOR_S,
6015 #ifdef G_OS_WIN32
6016 sanitized_server,
6017 #else
6018 ac_prefs->recv_server,
6019 #endif
6020 NULL);
6021 } else {
6022 dir = g_strconcat(get_imap_cache_dir(),
6023 G_DIR_SEPARATOR_S,
6024 #ifdef G_OS_WIN32
6025 sanitized_server,
6026 #else
6027 ac_prefs->recv_server,
6028 #endif
6029 G_DIR_SEPARATOR_S,
6030 ac_prefs->userid,
6031 NULL);
6033 #ifdef G_OS_WIN32
6034 g_free(sanitized_server);
6035 #endif
6038 return dir;
6041 static void prefs_account_receive_itv_spinbutton_value_changed_cb(GtkWidget *w, gpointer data)
6043 ReceivePage *page = (ReceivePage *)data;
6044 gint seconds = gtk_spin_button_get_value_as_int (
6045 GTK_SPIN_BUTTON (page->autochk_widgets->autochk_sec_spinbtn));
6046 gint minutes = gtk_spin_button_get_value_as_int (
6047 GTK_SPIN_BUTTON (page->autochk_widgets->autochk_min_spinbtn));
6048 gint hours = gtk_spin_button_get_value_as_int (
6049 GTK_SPIN_BUTTON(page->autochk_widgets->autochk_hour_spinbtn));
6050 if (seconds < PREFS_RECV_AUTOCHECK_MIN_INTERVAL && minutes == 0 && hours == 0) {
6051 gtk_spin_button_set_value (
6052 GTK_SPIN_BUTTON (page->autochk_widgets->autochk_sec_spinbtn),
6053 PREFS_RECV_AUTOCHECK_MIN_INTERVAL);
6057 #ifdef USE_OAUTH2
6058 //Automation of the oauth2 authorisation process to receive loopback callback generated by redirect in browser
6059 static void prefs_account_oauth2_listener(GTask *task, gpointer source, gpointer task_data, GCancellable *cancellable)
6061 struct Oauth2Listener *oauth2_listener_data = (struct Oauth2Listener *)task_data;
6062 unsigned int socket_desc;
6063 int client_sock, c;
6064 struct sockaddr_in server , client;
6065 char client_message[2000];
6066 char *reply;
6067 char *reply_message;
6068 char *title;
6069 char *body;
6070 fd_set rfds;
6071 gint ret = 1;
6072 struct timeval timeout;
6074 debug_print("oauth2 listener task running\n");
6076 //Create socket
6077 socket_desc = socket(AF_INET , SOCK_STREAM , 0);
6078 if (socket_desc == -1)
6080 debug_print("oauth2 listener could not create socket\n");
6081 g_task_return_boolean (task, TRUE);
6082 g_object_unref (task);
6083 return;
6085 debug_print("oauth2 listener socket created\n");
6087 //Prepare the sockaddr_in structure
6088 server.sin_family = AF_INET;
6089 server.sin_addr.s_addr = INADDR_ANY;
6090 server.sin_port = htons( 8888 );
6092 //Bind
6093 if( bind(socket_desc,(struct sockaddr *)&server , sizeof(server)) < 0)
6095 close(socket_desc);
6096 debug_print("oauth2 listener bind failed\n");
6097 g_task_return_boolean (task, TRUE);
6098 g_object_unref (task);
6099 return;
6101 debug_print("oauth2 listener bind done\n");
6103 listen(socket_desc , 1);
6105 //Accept and incoming connection
6106 debug_print("oauth2 listener waiting for incoming connections...\n");
6107 c = sizeof(struct sockaddr_in);
6110 FD_ZERO(&rfds);
6111 FD_SET(socket_desc, &rfds);
6112 timeout.tv_sec = 1;
6113 timeout.tv_usec = 0;
6115 select(socket_desc+1, &rfds, NULL, NULL, &timeout);
6117 //select woke up, maybe accept connection from an incoming client
6118 if(FD_ISSET(socket_desc, &rfds)){
6119 client_sock = accept(socket_desc, (struct sockaddr *)&client, (socklen_t*)&c);
6120 if (client_sock < 0){
6121 debug_print("oauth2 listener accept failed\n");
6122 g_task_return_boolean (task, TRUE);
6123 g_object_unref (task);
6124 return;
6126 debug_print("oauth2 listener connection accepted\n");
6128 //Receive message sent to the loopback address by the authorisation page
6129 prefs_account_oauth2_get_line(client_sock, client_message, sizeof(client_message));
6130 oauth2_listener_data->trim_text = g_strdup(client_message);
6131 g_strstrip(oauth2_listener_data->trim_text);
6133 ret = oauth2_obtain_tokens (oauth2_listener_data->service, oauth2_listener_data->OAUTH2Data, oauth2_listener_data->trim_text);
6135 if(!ret){
6136 oauth2_listener_data->success = TRUE;
6137 title = _("Authorisation complete");
6138 body = _("Your OAuth2 authorisation code has been received by Claws Mail");
6139 }else{
6140 //Something went wrong
6141 title = _("Authorisation NOT completed");
6142 body = _("Your OAuth2 authorisation code was not received by Claws Mail");
6143 log_message(LOG_PROTOCOL, "OAuth2 authorisation code not received\n");
6145 reply_message = g_strconcat("<html><head><title>", title,
6146 "</title><meta charset=\"utf-8\"></head><body><h1>", title,
6147 "</h1><p>", body, "</p></body></html>", NULL);
6148 reply = g_strdup_printf(
6149 "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nContent-Length: %lu\r\n\r\n%s",
6150 strlen(reply_message), reply_message);
6151 g_free(reply_message);
6152 write(client_sock, reply, strlen(reply));
6153 g_free(reply);
6154 close(client_sock);
6156 }while(ret && !oauth2_listener_cancel);
6158 close(socket_desc);
6159 debug_print("oauth2 closing task\n");
6160 g_task_return_boolean (task, TRUE);
6161 g_object_unref (task);
6164 static void prefs_account_oauth2_callback(GObject *source, GAsyncResult *res, gpointer user_data)
6166 struct Oauth2Listener *oauth2_listener_data = (struct Oauth2Listener *)user_data;
6168 if(oauth2_listener_data->success){
6169 debug_print("oauth2 listener callback storing data and updating GUI\n");
6171 if(oauth2_listener_data->OAUTH2Data->refresh_token != NULL){
6172 passwd_store_set_account(tmp_ac_prefs.account_id,
6173 PWS_ACCOUNT_OAUTH2_REFRESH,
6174 oauth2_listener_data->OAUTH2Data->refresh_token,
6175 FALSE);
6176 log_message(LOG_PROTOCOL, "OAuth2 refresh token stored\n");
6179 if(oauth2_listener_data->OAUTH2Data->access_token != NULL){
6180 passwd_store_set_account(tmp_ac_prefs.account_id,
6181 PWS_ACCOUNT_RECV,
6182 oauth2_listener_data->OAUTH2Data->access_token,
6183 FALSE);
6184 passwd_store_set_account(tmp_ac_prefs.account_id,
6185 PWS_ACCOUNT_SEND,
6186 oauth2_listener_data->OAUTH2Data->access_token,
6187 FALSE);
6188 log_message(LOG_PROTOCOL, "OAuth2 access token stored\n");
6191 if(oauth2_listener_data->OAUTH2Data->expiry_str != NULL){
6192 passwd_store_set_account(tmp_ac_prefs.account_id,
6193 PWS_ACCOUNT_OAUTH2_EXPIRY,
6194 oauth2_listener_data->OAUTH2Data->expiry_str,
6195 FALSE);
6196 log_message(LOG_PROTOCOL, "OAuth2 access token expiry stored\n");
6199 tmp_ac_prefs.oauth2_date = g_get_real_time () / G_USEC_PER_SEC;
6201 gtk_entry_set_text(GTK_ENTRY(oauth2_page.oauth2_authcode_entry), oauth2_listener_data->trim_text != NULL ? oauth2_listener_data->trim_text : "");
6202 gtk_widget_set_sensitive(oauth2_page.oauth2_authcode_entry, FALSE);
6203 gtk_widget_set_sensitive(oauth2_page.oauth2_authorise_btn, FALSE);
6204 gtk_entry_set_text(GTK_ENTRY(basic_page.pass_entry), oauth2_listener_data->OAUTH2Data->access_token);
6205 gtk_entry_set_text(GTK_ENTRY(send_page.smtp_pass_entry), oauth2_listener_data->OAUTH2Data->access_token);
6208 debug_print("oauth2 listener callback freeing resources\n");
6209 g_free(oauth2_listener_data->trim_text);
6210 g_free(oauth2_listener_data->OAUTH2Data);
6211 g_free(oauth2_listener_data);
6212 oauth2_listener_cancel = 0;
6213 oauth2_listener_closed = 1;
6216 static int prefs_account_oauth2_get_line(int sock, char *buf, int size)
6218 int i = 0;
6219 char c = '\0';
6220 int n;
6222 while ((i < size - 1) && (c != '\n')) {
6223 n = recv(sock, &c, 1, 0);
6224 //printf("%02X\n", c);
6225 if (n > 0) {
6226 if (c == '\r') {
6227 n = recv(sock, &c, 1, MSG_PEEK);
6228 //printf("%02X\n", c);
6229 if ((n > 0) && (c == '\n')) {
6230 n = recv(sock, &c, 1, 0);
6231 if (n < 0)
6232 log_message(LOG_PROTOCOL, "Receiving from pipe failed\n");
6234 else
6235 c = '\n';
6237 buf[i] = c;
6238 i++;
6240 else
6241 c = '\n';
6243 buf[i] = '\0';
6245 return (i);
6247 #endif