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/>.
21 #include "claws-features.h"
30 #include <sys/socket.h>
31 #include <netinet/in.h>
35 #include <glib/gi18n.h>
37 #include <gdk/gdkkeysyms.h>
38 #include <gtk/filesel.h>
40 #include <sys/types.h>
46 #include "prefs_gtk.h"
47 #include "prefs_account.h"
48 #include "prefs_receive.h"
49 #include "prefs_common.h"
50 #include "prefs_customheader.h"
52 #include "mainwindow.h"
53 #include "manage_window.h"
55 #include "foldersel.h"
60 #include "alertpanel.h"
61 #include "colorlabel.h"
68 #include "remotefolder.h"
71 #include "quote_fmt.h"
74 #include "inputdialog.h"
75 #include "ssl_certificate.h"
76 #include "passwordstore.h"
77 #include "file-utils.h"
79 #include <gnutls/gnutls.h>
82 static gboolean cancelled
;
83 static gboolean new_account
;
85 static PrefsAccount tmp_ac_prefs
;
87 static GtkWidget
*sigfile_radiobtn
;
88 static GtkWidget
*sigcmd_radiobtn
;
89 static GtkWidget
*entry_sigpath
;
90 static GtkWidget
*signature_browse_button
;
91 static GtkWidget
*signature_edit_button
;
94 static GtkWidget
*entry_in_cert_file
;
95 static GtkWidget
*entry_out_cert_file
;
96 static GtkWidget
*in_ssl_cert_browse_button
;
97 static GtkWidget
*out_ssl_cert_browse_button
;
100 struct AutocheckWidgets
{
101 GtkWidget
*autochk_hour_spinbtn
;
102 GtkWidget
*autochk_min_spinbtn
;
103 GtkWidget
*autochk_sec_spinbtn
;
106 static GSList
*prefs_pages
= NULL
;
109 static GTask
*oauth2_listener_task
;
110 static int oauth2_listener_cancel
= 0;
111 static int oauth2_listener_closed
= 0;
114 typedef struct BasicPage
120 GtkWidget
*acname_entry
;
121 GtkWidget
*default_checkbtn
;
123 GtkWidget
*name_entry
;
124 GtkWidget
*addr_entry
;
125 GtkWidget
*org_entry
;
127 GtkWidget
*serv_frame
;
128 GtkWidget
*serv_table
;
129 gpointer
*protocol_optmenu
;
130 GtkWidget
*recvserv_label
;
131 GtkWidget
*smtpserv_label
;
132 GtkWidget
*nntpserv_label
;
133 GtkWidget
*localmbox_label
;
134 GtkWidget
*mailcmd_label
;
135 GtkWidget
*recvserv_entry
;
136 GtkWidget
*smtpserv_entry
;
137 GtkWidget
*nntpserv_entry
;
138 GtkWidget
*nntpauth_checkbtn
;
139 GtkWidget
*nntpauth_onconnect_checkbtn
;
140 GtkWidget
*localmbox_entry
;
141 GtkWidget
*mailcmd_checkbtn
;
142 GtkWidget
*mailcmd_entry
;
143 GtkWidget
*uid_label
;
144 GtkWidget
*pass_label
;
145 GtkWidget
*uid_entry
;
146 GtkWidget
*pass_entry
;
147 GtkWidget
*showpwd_checkbtn
;
148 GtkWidget
*auto_configure_btn
;
149 GtkWidget
*auto_configure_cancel_btn
;
150 GtkWidget
*auto_configure_lbl
;
153 typedef struct ReceivePage
159 GtkWidget
*pop3_frame
;
160 GtkWidget
*pop_auth_checkbtn
;
161 GtkWidget
*pop_auth_type_optmenu
;
162 GtkWidget
*rmmail_checkbtn
;
163 GtkWidget
*leave_time_spinbtn
;
164 GtkWidget
*leave_hour_spinbtn
;
165 GtkWidget
*size_limit_checkbtn
;
166 GtkWidget
*size_limit_spinbtn
;
167 GtkWidget
*inbox_label
;
168 GtkWidget
*inbox_entry
;
169 GtkWidget
*inbox_btn
;
171 GtkWidget
*autochk_frame
;
173 GtkWidget
*local_frame
;
174 GtkWidget
*local_inbox_label
;
175 GtkWidget
*local_inbox_entry
;
176 GtkWidget
*local_inbox_btn
;
178 GtkWidget
*filter_on_recv_checkbtn
;
179 GtkWidget
*filterhook_on_recv_checkbtn
;
180 GtkWidget
*recvatgetall_checkbtn
;
182 GtkWidget
*imap_frame
;
183 GtkWidget
*imap_auth_type_optmenu
;
184 GtkWidget
*imapdir_label
;
185 GtkWidget
*imapdir_entry
;
186 GtkWidget
*subsonly_checkbtn
;
187 GtkWidget
*low_bandwidth_checkbtn
;
189 GtkWidget
*frame_maxarticle
;
190 GtkWidget
*maxarticle_label
;
191 GtkWidget
*maxarticle_spinbtn
;
192 GtkAdjustment
*maxarticle_spinbtn_adj
;
194 GtkWidget
*autochk_checkbtn
;
195 GtkWidget
*autochk_use_default_checkbtn
;
196 struct AutocheckWidgets
*autochk_widgets
;
199 typedef struct SendPage
205 GtkWidget
*msgid_checkbtn
;
206 GtkWidget
*xmailer_checkbtn
;
207 GtkWidget
*customhdr_checkbtn
;
208 GtkWidget
*msgid_with_addr_checkbtn
;
209 GtkWidget
*smtp_auth_checkbtn
;
210 GtkWidget
*smtp_auth_type_optmenu
;
211 GtkWidget
*smtp_uid_entry
;
212 GtkWidget
*smtp_pass_entry
;
213 GtkWidget
*pop_bfr_smtp_checkbtn
;
214 GtkWidget
*pop_bfr_smtp_tm_spinbtn
;
215 GtkWidget
*pop_auth_timeout_lbl
;
216 GtkWidget
*pop_auth_minutes_lbl
;
220 typedef struct Oauth2Page
225 GtkWidget
*oauth2_sensitive
;
227 GtkWidget
*oauth2_authorise_btn
;
228 GtkWidget
*oauth2_deauthorise_btn
;
229 GtkWidget
*oauth2_authcode_entry
;
230 GtkWidget
*oauth2_auth_optmenu
;
231 GtkWidget
*oauth2_link_button
;
232 GtkWidget
*oauth2_link_copy_button
;
233 gpointer
*protocol_optmenu
;
234 GtkWidget
*oauth2_client_id_entry
;
235 GtkWidget
*oauth2_client_secret_entry
;
243 } AuthCodeQueryButtonData
;
245 typedef struct ComposePage
251 GtkWidget
*sigfile_radiobtn
;
252 GtkWidget
*entry_sigpath
;
253 GtkWidget
*checkbtn_autosig
;
254 GtkWidget
*entry_sigsep
;
255 GtkWidget
*autocc_checkbtn
;
256 GtkWidget
*autocc_entry
;
257 GtkWidget
*autobcc_checkbtn
;
258 GtkWidget
*autobcc_entry
;
259 GtkWidget
*autoreplyto_checkbtn
;
260 GtkWidget
*autoreplyto_entry
;
262 GtkWidget
*checkbtn_enable_default_dictionary
;
263 GtkWidget
*combo_default_dictionary
;
264 GtkWidget
*checkbtn_enable_default_alt_dictionary
;
265 GtkWidget
*combo_default_alt_dictionary
;
269 typedef struct TemplatesPage
275 GtkWidget
*checkbtn_compose_with_format
;
276 GtkWidget
*compose_subject_format
;
277 GtkWidget
*compose_body_format
;
278 GtkWidget
*checkbtn_reply_with_format
;
279 GtkWidget
*reply_quotemark
;
280 GtkWidget
*reply_body_format
;
281 GtkWidget
*checkbtn_forward_with_format
;
282 GtkWidget
*forward_quotemark
;
283 GtkWidget
*forward_body_format
;
286 typedef struct PrivacyPage
292 GtkWidget
*default_privacy_system
;
293 GtkWidget
*default_encrypt_checkbtn
;
294 GtkWidget
*default_encrypt_reply_checkbtn
;
295 GtkWidget
*default_sign_checkbtn
;
296 GtkWidget
*default_sign_reply_checkbtn
;
297 GtkWidget
*save_clear_text_checkbtn
;
298 GtkWidget
*encrypt_to_self_checkbtn
;
301 typedef struct SSLPage
307 GtkWidget
*pop_frame
;
308 GtkWidget
*pop_nossl_radiobtn
;
309 GtkWidget
*pop_ssltunnel_radiobtn
;
310 GtkWidget
*pop_starttls_radiobtn
;
312 GtkWidget
*imap_frame
;
313 GtkWidget
*imap_nossl_radiobtn
;
314 GtkWidget
*imap_ssltunnel_radiobtn
;
315 GtkWidget
*imap_starttls_radiobtn
;
317 GtkWidget
*nntp_frame
;
318 GtkWidget
*nntp_nossl_radiobtn
;
319 GtkWidget
*nntp_ssltunnel_radiobtn
;
321 GtkWidget
*send_frame
;
322 GtkWidget
*smtp_nossl_radiobtn
;
323 GtkWidget
*smtp_ssltunnel_radiobtn
;
324 GtkWidget
*smtp_starttls_radiobtn
;
326 GtkWidget
*entry_in_cert_file
;
327 GtkWidget
*entry_in_cert_pass
;
328 GtkWidget
*entry_out_cert_file
;
329 GtkWidget
*entry_out_cert_pass
;
331 GtkWidget
*ssl_certs_auto_accept_checkbtn
;
332 GtkWidget
*use_nonblocking_ssl_checkbtn
;
335 typedef struct ProxyPage
341 GtkWidget
*proxy_checkbtn
;
342 GtkWidget
*default_proxy_checkbtn
;
343 GtkWidget
*socks4_radiobtn
;
344 GtkWidget
*socks5_radiobtn
;
345 GtkWidget
*proxy_host_entry
;
346 GtkWidget
*proxy_port_spinbtn
;
347 GtkWidget
*proxy_auth_checkbtn
;
348 GtkWidget
*proxy_name_entry
;
349 GtkWidget
*proxy_pass_entry
;
350 GtkWidget
*proxy_send_checkbtn
;
353 typedef struct AdvancedPage
359 GtkWidget
*smtpport_checkbtn
;
360 GtkWidget
*smtpport_spinbtn
;
361 GtkWidget
*popport_hbox
;
362 GtkWidget
*popport_checkbtn
;
363 GtkWidget
*popport_spinbtn
;
364 GtkWidget
*imapport_hbox
;
365 GtkWidget
*imapport_checkbtn
;
366 GtkWidget
*imapport_spinbtn
;
367 GtkWidget
*nntpport_hbox
;
368 GtkWidget
*nntpport_checkbtn
;
369 GtkWidget
*nntpport_spinbtn
;
370 GtkWidget
*domain_checkbtn
;
371 GtkWidget
*domain_entry
;
372 GtkWidget
*crosspost_checkbtn
;
373 GtkWidget
*crosspost_colormenu
;
376 GtkWidget
*tunnelcmd_checkbtn
;
377 GtkWidget
*tunnelcmd_entry
;
380 GtkWidget
*sent_folder_checkbtn
;
381 GtkWidget
*sent_folder_entry
;
382 GtkWidget
*queue_folder_checkbtn
;
383 GtkWidget
*queue_folder_entry
;
384 GtkWidget
*draft_folder_checkbtn
;
385 GtkWidget
*draft_folder_entry
;
386 GtkWidget
*trash_folder_checkbtn
;
387 GtkWidget
*trash_folder_entry
;
390 static BasicPage basic_page
;
391 static ReceivePage receive_page
;
392 static SendPage send_page
;
394 static Oauth2Page oauth2_page
;
396 static ComposePage compose_page
;
397 static TemplatesPage templates_page
;
398 static PrivacyPage privacy_page
;
400 static SSLPage ssl_page
;
402 static ProxyPage proxy_page
;
403 static AdvancedPage advanced_page
;
405 struct BasicProtocol
{
408 GtkWidget
*descrlabel
;
409 GtkWidget
*no_imap_warn_icon
;
410 GtkWidget
*no_imap_warn_label
;
413 static char *protocol_names
[] = {
417 N_("Local mbox file"),
418 N_("None (SMTP only)")
422 struct Oauth2Listener
{
424 Oauth2Service service
;
425 OAUTH2Data
*OAUTH2Data
;
430 static void prefs_account_protocol_set_data_from_optmenu(PrefParam
*pparam
);
431 static void prefs_account_protocol_set_optmenu (PrefParam
*pparam
);
432 static void prefs_account_protocol_changed (GtkComboBox
*combobox
, gpointer data
);
434 static void prefs_account_set_string_from_combobox (PrefParam
*pparam
);
435 static void prefs_account_set_privacy_combobox_from_string (PrefParam
*pparam
);
437 static void prefs_account_imap_auth_type_set_data_from_optmenu (PrefParam
*pparam
);
438 static void prefs_account_imap_auth_type_set_optmenu (PrefParam
*pparam
);
439 static void prefs_account_smtp_auth_type_set_data_from_optmenu (PrefParam
*pparam
);
440 static void prefs_account_smtp_auth_type_set_optmenu (PrefParam
*pparam
);
441 static void prefs_account_pop_auth_type_set_data_from_optmenu (PrefParam
*pparam
);
442 static void prefs_account_pop_auth_type_set_optmenu (PrefParam
*pparam
);
444 static void prefs_account_oauth2_provider_set_data_from_optmenu (PrefParam
*pparam
);
445 static void prefs_account_oauth2_provider_set_optmenu (PrefParam
*pparam
);
446 static void prefs_account_oauth2_copy_url (GtkButton
*button
, gpointer data
);
447 static void prefs_account_oauth2_listener(GTask
*task
, gpointer source
, gpointer task_data
, GCancellable
*cancellable
);
448 static void prefs_account_oauth2_callback(GObject
*source
, GAsyncResult
*res
, gpointer user_data
);
449 static int prefs_account_oauth2_get_line(int sock
, char *buf
, int size
);
450 static void prefs_account_oauth2_set_sensitivity(void);
451 static void prefs_account_oauth2_set_auth_sensitivity(void);
452 static void prefs_account_oauth2_obtain_tokens(GtkButton
*button
, gpointer data
);
454 static void prefs_account_set_autochk_interval_from_widgets(PrefParam
*pparam
);
455 static void prefs_account_set_autochk_interval_to_widgets(PrefParam
*pparam
);
457 static void prefs_account_enum_set_data_from_radiobtn (PrefParam
*pparam
);
458 static void prefs_account_enum_set_radiobtn (PrefParam
*pparam
);
460 static void crosspost_color_toggled(void);
461 static void prefs_account_crosspost_set_data_from_colormenu(PrefParam
*pparam
);
462 static void prefs_account_crosspost_set_colormenu(PrefParam
*pparam
);
464 static void prefs_account_nntpauth_toggled(GtkToggleButton
*button
, gpointer user_data
);
465 static void prefs_account_mailcmd_toggled(GtkToggleButton
*button
, gpointer user_data
);
466 static void prefs_account_showpwd_checkbtn_toggled(GtkToggleButton
*button
, gpointer user_data
);
467 static void prefs_account_entry_changed_newline_check_cb(GtkWidget
*entry
, gpointer user_data
);
468 static void prefs_account_filter_on_recv_toggled(GtkToggleButton
*button
, gpointer user_data
);
471 static void prefs_account_compose_default_dictionary_set_string_from_optmenu (PrefParam
*pparam
);
472 static void prefs_account_compose_default_dictionary_set_optmenu_from_string (PrefParam
*pparam
);
475 static gchar
*privacy_prefs
;
477 static PrefParam basic_param
[] = {
478 {"account_name", NULL
, &tmp_ac_prefs
.account_name
, P_STRING
,
479 &basic_page
.acname_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
481 {"is_default", "FALSE", &tmp_ac_prefs
.is_default
, P_BOOL
,
482 &basic_page
.default_checkbtn
,
483 prefs_set_data_from_toggle
, prefs_set_toggle
},
485 {"name", NULL
, &tmp_ac_prefs
.name
, P_STRING
,
486 &basic_page
.name_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
488 {"address", NULL
, &tmp_ac_prefs
.address
, P_STRING
,
489 &basic_page
.addr_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
491 {"organization", NULL
, &tmp_ac_prefs
.organization
, P_STRING
,
492 &basic_page
.org_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
494 {"protocol", NULL
, &tmp_ac_prefs
.protocol
, P_ENUM
,
495 (GtkWidget
**)&basic_page
.protocol_optmenu
,
496 prefs_account_protocol_set_data_from_optmenu
,
497 prefs_account_protocol_set_optmenu
},
499 {"receive_server", NULL
, &tmp_ac_prefs
.recv_server
, P_STRING
,
500 &basic_page
.recvserv_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
502 {"smtp_server", NULL
, &tmp_ac_prefs
.smtp_server
, P_STRING
,
503 &basic_page
.smtpserv_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
505 {"nntp_server", NULL
, &tmp_ac_prefs
.nntp_server
, P_STRING
,
506 &basic_page
.nntpserv_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
508 {"local_mbox", "/var/mail", &tmp_ac_prefs
.local_mbox
, P_STRING
,
509 &basic_page
.localmbox_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
511 {"use_mail_command", "FALSE", &tmp_ac_prefs
.use_mail_command
, P_BOOL
,
512 &basic_page
.mailcmd_checkbtn
, prefs_set_data_from_toggle
, prefs_set_toggle
},
514 {"mail_command", DEFAULT_SENDMAIL_CMD
, &tmp_ac_prefs
.mail_command
, P_STRING
,
515 &basic_page
.mailcmd_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
517 {"use_nntp_auth", "FALSE", &tmp_ac_prefs
.use_nntp_auth
, P_BOOL
,
518 &basic_page
.nntpauth_checkbtn
,
519 prefs_set_data_from_toggle
, prefs_set_toggle
},
521 {"use_nntp_auth_onconnect", "FALSE", &tmp_ac_prefs
.use_nntp_auth_onconnect
, P_BOOL
,
522 &basic_page
.nntpauth_onconnect_checkbtn
,
523 prefs_set_data_from_toggle
, prefs_set_toggle
},
525 {"user_id", NULL
, &tmp_ac_prefs
.userid
, P_STRING
,
526 &basic_page
.uid_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
528 {"password", NULL
, &tmp_ac_prefs
.passwd
, P_PASSWORD
,
531 {"config_version", "-1", &tmp_ac_prefs
.config_version
, P_INT
,
534 {NULL
, NULL
, NULL
, P_OTHER
, NULL
, NULL
, NULL
}
537 static PrefParam receive_param
[] = {
538 {"use_apop_auth", "FALSE", &tmp_ac_prefs
.use_apop_auth
, P_BOOL
,
539 NULL
, NULL
}, /* deprecated */
541 {"use_pop_auth", "FALSE", &tmp_ac_prefs
.use_pop_auth
, P_BOOL
,
542 &receive_page
.pop_auth_checkbtn
,
543 prefs_set_data_from_toggle
, prefs_set_toggle
},
545 {"pop_auth_method", "0", &tmp_ac_prefs
.pop_auth_type
, P_ENUM
,
546 &receive_page
.pop_auth_type_optmenu
,
547 prefs_account_pop_auth_type_set_data_from_optmenu
,
548 prefs_account_pop_auth_type_set_optmenu
},
550 {"remove_mail", "TRUE", &tmp_ac_prefs
.rmmail
, P_BOOL
,
551 &receive_page
.rmmail_checkbtn
,
552 prefs_set_data_from_toggle
, prefs_set_toggle
},
555 {"message_leave_time", "7", &tmp_ac_prefs
.msg_leave_time
, P_INT
,
556 &receive_page
.leave_time_spinbtn
,
557 prefs_set_data_from_spinbtn
, prefs_set_spinbtn
},
559 {"message_leave_time", "30", &tmp_ac_prefs
.msg_leave_time
, P_INT
,
560 &receive_page
.leave_time_spinbtn
,
561 prefs_set_data_from_spinbtn
, prefs_set_spinbtn
},
563 {"message_leave_hour", "0", &tmp_ac_prefs
.msg_leave_hour
, P_INT
,
564 &receive_page
.leave_hour_spinbtn
,
565 prefs_set_data_from_spinbtn
, prefs_set_spinbtn
},
567 {"enable_size_limit", "FALSE", &tmp_ac_prefs
.enable_size_limit
, P_BOOL
,
568 &receive_page
.size_limit_checkbtn
,
569 prefs_set_data_from_toggle
, prefs_set_toggle
},
570 {"size_limit", "1024", &tmp_ac_prefs
.size_limit
, P_INT
,
571 &receive_page
.size_limit_spinbtn
,
572 prefs_set_data_from_spinbtn
, prefs_set_spinbtn
},
574 {"filter_on_receive", "TRUE", &tmp_ac_prefs
.filter_on_recv
, P_BOOL
,
575 &receive_page
.filter_on_recv_checkbtn
,
576 prefs_set_data_from_toggle
, prefs_set_toggle
},
578 {"filterhook_on_receive", "TRUE", &tmp_ac_prefs
.filterhook_on_recv
, P_BOOL
,
579 &receive_page
.filterhook_on_recv_checkbtn
,
580 prefs_set_data_from_toggle
, prefs_set_toggle
},
582 {"imap_auth_method", "0", &tmp_ac_prefs
.imap_auth_type
, P_ENUM
,
583 &receive_page
.imap_auth_type_optmenu
,
584 prefs_account_imap_auth_type_set_data_from_optmenu
,
585 prefs_account_imap_auth_type_set_optmenu
},
587 {"receive_at_get_all", "TRUE", &tmp_ac_prefs
.recv_at_getall
, P_BOOL
,
588 &receive_page
.recvatgetall_checkbtn
,
589 prefs_set_data_from_toggle
, prefs_set_toggle
},
591 {"max_news_articles", "300", &tmp_ac_prefs
.max_articles
, P_INT
,
592 &receive_page
.maxarticle_spinbtn
,
593 prefs_set_data_from_spinbtn
, prefs_set_spinbtn
},
595 {"inbox", "#mh/Mailbox/inbox", &tmp_ac_prefs
.inbox
, P_STRING
,
596 &receive_page
.inbox_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
598 {"local_inbox", "#mh/Mailbox/inbox", &tmp_ac_prefs
.local_inbox
, P_STRING
,
599 &receive_page
.local_inbox_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
601 {"imap_directory", NULL
, &tmp_ac_prefs
.imap_dir
, P_STRING
,
602 &receive_page
.imapdir_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
604 {"imap_subsonly", "TRUE", &tmp_ac_prefs
.imap_subsonly
, P_BOOL
,
605 &receive_page
.subsonly_checkbtn
,
606 prefs_set_data_from_toggle
, prefs_set_toggle
},
608 {"low_bandwidth", "FALSE", &tmp_ac_prefs
.low_bandwidth
, P_BOOL
,
609 &receive_page
.low_bandwidth_checkbtn
,
610 prefs_set_data_from_toggle
, prefs_set_toggle
},
612 {"autochk_use_default", "TRUE", &tmp_ac_prefs
.autochk_use_default
, P_BOOL
,
613 &receive_page
.autochk_use_default_checkbtn
,
614 prefs_set_data_from_toggle
, prefs_set_toggle
},
616 {"autochk_use_custom", "FALSE", &tmp_ac_prefs
.autochk_use_custom
, P_BOOL
,
617 &receive_page
.autochk_checkbtn
,
618 prefs_set_data_from_toggle
, prefs_set_toggle
},
620 /* Here we lie a bit, passing a pointer to our custom struct,
621 * disguised as a GtkWidget pointer, to get around the
622 * inflexibility of PrefParam system. */
623 {"autochk_interval", "600", &tmp_ac_prefs
.autochk_itv
, P_INT
,
624 (GtkWidget
**)&receive_page
.autochk_widgets
,
625 prefs_account_set_autochk_interval_from_widgets
,
626 prefs_account_set_autochk_interval_to_widgets
},
628 {NULL
, NULL
, NULL
, P_OTHER
, NULL
, NULL
, NULL
}
631 static PrefParam send_param
[] = {
632 {"generate_msgid", "TRUE", &tmp_ac_prefs
.gen_msgid
, P_BOOL
,
633 &send_page
.msgid_checkbtn
,
634 prefs_set_data_from_toggle
, prefs_set_toggle
},
636 {"generate_xmailer", "TRUE", &tmp_ac_prefs
.gen_xmailer
, P_BOOL
,
637 &send_page
.xmailer_checkbtn
,
638 prefs_set_data_from_toggle
, prefs_set_toggle
},
640 {"add_custom_header", "FALSE", &tmp_ac_prefs
.add_customhdr
, P_BOOL
,
641 &send_page
.customhdr_checkbtn
,
642 prefs_set_data_from_toggle
, prefs_set_toggle
},
644 {"msgid_with_addr", "FALSE", &tmp_ac_prefs
.msgid_with_addr
, P_BOOL
,
645 &send_page
.msgid_with_addr_checkbtn
,
646 prefs_set_data_from_toggle
, prefs_set_toggle
},
648 {"use_smtp_auth", "FALSE", &tmp_ac_prefs
.use_smtp_auth
, P_BOOL
,
649 &send_page
.smtp_auth_checkbtn
,
650 prefs_set_data_from_toggle
, prefs_set_toggle
},
652 {"smtp_auth_method", "0", &tmp_ac_prefs
.smtp_auth_type
, P_ENUM
,
653 &send_page
.smtp_auth_type_optmenu
,
654 prefs_account_smtp_auth_type_set_data_from_optmenu
,
655 prefs_account_smtp_auth_type_set_optmenu
},
657 {"smtp_user_id", NULL
, &tmp_ac_prefs
.smtp_userid
, P_STRING
,
658 &send_page
.smtp_uid_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
659 {"smtp_password", NULL
, &tmp_ac_prefs
.smtp_passwd
, P_PASSWORD
,
662 {"pop_before_smtp", "FALSE", &tmp_ac_prefs
.pop_before_smtp
, P_BOOL
,
663 &send_page
.pop_bfr_smtp_checkbtn
,
664 prefs_set_data_from_toggle
, prefs_set_toggle
},
666 {"pop_before_smtp_timeout", "5", &tmp_ac_prefs
.pop_before_smtp_timeout
, P_INT
,
667 &send_page
.pop_bfr_smtp_tm_spinbtn
,
668 prefs_set_data_from_spinbtn
, prefs_set_spinbtn
},
670 {NULL
, NULL
, NULL
, P_OTHER
, NULL
, NULL
, NULL
}
673 static PrefParam oauth2_param
[] = {
675 {"oauth2_auth_provider", "0", &tmp_ac_prefs
.oauth2_provider
, P_ENUM
,
676 &oauth2_page
.oauth2_auth_optmenu
,
677 prefs_account_oauth2_provider_set_data_from_optmenu
,
678 prefs_account_oauth2_provider_set_optmenu
},
680 {"oauth2_date", 0, &tmp_ac_prefs
.oauth2_date
, P_INT
,
683 {"oauth2_authcode", NULL
, &tmp_ac_prefs
.oauth2_authcode
, P_PASSWORD
,
686 {"oauth2_client_id", NULL
, &tmp_ac_prefs
.oauth2_client_id
, P_STRING
,
687 &oauth2_page
.oauth2_client_id_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
689 {"oauth2_client_secret", NULL
, &tmp_ac_prefs
.oauth2_client_secret
, P_STRING
,
690 &oauth2_page
.oauth2_client_secret_entry
, prefs_set_data_from_entry
, prefs_set_entry
},
692 {"oauth2_auth_provider", "0", &tmp_ac_prefs
.oauth2_provider
, P_ENUM
,
695 {"oauth2_date", 0, &tmp_ac_prefs
.oauth2_date
, P_INT
,
698 {"oauth2_authcode", NULL
, &tmp_ac_prefs
.oauth2_authcode
, P_PASSWORD
,
701 {"oauth2_client_id", NULL
, &tmp_ac_prefs
.oauth2_client_id
, P_STRING
,
704 {"oauth2_client_secret", NULL
, &tmp_ac_prefs
.oauth2_client_secret
, P_STRING
,
709 {NULL
, NULL
, NULL
, P_OTHER
, NULL
, NULL
, NULL
}
712 static PrefParam compose_param
[] = {
713 {"signature_type", "0", &tmp_ac_prefs
.sig_type
, P_ENUM
,
714 &compose_page
.sigfile_radiobtn
,
715 prefs_account_enum_set_data_from_radiobtn
,
716 prefs_account_enum_set_radiobtn
},
717 {"signature_path", "~" G_DIR_SEPARATOR_S DEFAULT_SIGNATURE
,
718 &tmp_ac_prefs
.sig_path
, P_STRING
, &compose_page
.entry_sigpath
,
719 prefs_set_data_from_entry
, prefs_set_entry
},
721 {"auto_signature", "TRUE", &tmp_ac_prefs
.auto_sig
, P_BOOL
,
722 &compose_page
.checkbtn_autosig
,
723 prefs_set_data_from_toggle
, prefs_set_toggle
},
725 {"signature_separator", "-- ", &tmp_ac_prefs
.sig_sep
, P_STRING
,
726 &compose_page
.entry_sigsep
,
727 prefs_set_data_from_entry
, prefs_set_entry
},
729 {"set_autocc", "FALSE", &tmp_ac_prefs
.set_autocc
, P_BOOL
,
730 &compose_page
.autocc_checkbtn
,
731 prefs_set_data_from_toggle
, prefs_set_toggle
},
733 {"auto_cc", NULL
, &tmp_ac_prefs
.auto_cc
, P_STRING
,
734 &compose_page
.autocc_entry
,
735 prefs_set_data_from_entry
, prefs_set_entry
},
737 {"set_autobcc", "FALSE", &tmp_ac_prefs
.set_autobcc
, P_BOOL
,
738 &compose_page
.autobcc_checkbtn
,
739 prefs_set_data_from_toggle
, prefs_set_toggle
},
741 {"auto_bcc", NULL
, &tmp_ac_prefs
.auto_bcc
, P_STRING
,
742 &compose_page
.autobcc_entry
,
743 prefs_set_data_from_entry
, prefs_set_entry
},
745 {"set_autoreplyto", "FALSE", &tmp_ac_prefs
.set_autoreplyto
, P_BOOL
,
746 &compose_page
.autoreplyto_checkbtn
,
747 prefs_set_data_from_toggle
, prefs_set_toggle
},
749 {"auto_replyto", NULL
, &tmp_ac_prefs
.auto_replyto
, P_STRING
,
750 &compose_page
.autoreplyto_entry
,
751 prefs_set_data_from_entry
, prefs_set_entry
},
754 {"enable_default_dictionary", "", &tmp_ac_prefs
.enable_default_dictionary
, P_BOOL
,
755 &compose_page
.checkbtn_enable_default_dictionary
,
756 prefs_set_data_from_toggle
, prefs_set_toggle
},
758 {"default_dictionary", NULL
, &tmp_ac_prefs
.default_dictionary
, P_STRING
,
759 &compose_page
.combo_default_dictionary
,
760 prefs_account_compose_default_dictionary_set_string_from_optmenu
,
761 prefs_account_compose_default_dictionary_set_optmenu_from_string
},
763 {"enable_default_alt_dictionary", "", &tmp_ac_prefs
.enable_default_alt_dictionary
, P_BOOL
,
764 &compose_page
.checkbtn_enable_default_alt_dictionary
,
765 prefs_set_data_from_toggle
, prefs_set_toggle
},
767 {"default_alt_dictionary", NULL
, &tmp_ac_prefs
.default_alt_dictionary
, P_STRING
,
768 &compose_page
.combo_default_alt_dictionary
,
769 prefs_account_compose_default_dictionary_set_string_from_optmenu
,
770 prefs_account_compose_default_dictionary_set_optmenu_from_string
},
772 {"enable_default_dictionary", "", &tmp_ac_prefs
.enable_default_dictionary
, P_BOOL
,
775 {"default_dictionary", NULL
, &tmp_ac_prefs
.default_dictionary
, P_STRING
,
778 {"enable_default_alt_dictionary", "", &tmp_ac_prefs
.enable_default_alt_dictionary
, P_BOOL
,
781 {"default_alt_dictionary", NULL
, &tmp_ac_prefs
.default_alt_dictionary
, P_STRING
,
785 {NULL
, NULL
, NULL
, P_OTHER
, NULL
, NULL
, NULL
}
788 static PrefParam templates_param
[] = {
789 {"compose_with_format", "FALSE", &tmp_ac_prefs
.compose_with_format
, P_BOOL
,
790 &templates_page
.checkbtn_compose_with_format
,
791 prefs_set_data_from_toggle
, prefs_set_toggle
},
793 {"compose_subject_format", NULL
, &tmp_ac_prefs
.compose_subject_format
, P_STRING
,
794 &templates_page
.compose_subject_format
,
795 prefs_set_escaped_data_from_entry
, prefs_set_entry_from_escaped
},
797 {"compose_body_format", NULL
, &tmp_ac_prefs
.compose_body_format
, P_STRING
,
798 &templates_page
.compose_body_format
,
799 prefs_set_escaped_data_from_text
, prefs_set_text_from_escaped
},
801 {"reply_with_format", "FALSE", &tmp_ac_prefs
.reply_with_format
, P_BOOL
,
802 &templates_page
.checkbtn_reply_with_format
,
803 prefs_set_data_from_toggle
, prefs_set_toggle
},
805 {"reply_quotemark", NULL
, &tmp_ac_prefs
.reply_quotemark
, P_STRING
,
806 &templates_page
.reply_quotemark
,
807 prefs_set_data_from_entry
, prefs_set_entry_from_escaped
},
809 {"reply_body_format", NULL
, &tmp_ac_prefs
.reply_body_format
, P_STRING
,
810 &templates_page
.reply_body_format
,
811 prefs_set_escaped_data_from_text
, prefs_set_text_from_escaped
},
813 {"forward_with_format", "FALSE", &tmp_ac_prefs
.forward_with_format
, P_BOOL
,
814 &templates_page
.checkbtn_forward_with_format
,
815 prefs_set_data_from_toggle
, prefs_set_toggle
},
817 {"forward_quotemark", NULL
, &tmp_ac_prefs
.forward_quotemark
, P_STRING
,
818 &templates_page
.forward_quotemark
,
819 prefs_set_data_from_entry
, prefs_set_entry_from_escaped
},
821 {"forward_body_format", NULL
, &tmp_ac_prefs
.forward_body_format
, P_STRING
,
822 &templates_page
.forward_body_format
,
823 prefs_set_escaped_data_from_text
, prefs_set_text_from_escaped
},
825 {NULL
, NULL
, NULL
, P_OTHER
, NULL
, NULL
, NULL
}
828 static PrefParam privacy_param
[] = {
829 {"default_privacy_system", "", &tmp_ac_prefs
.default_privacy_system
, P_STRING
,
830 &privacy_page
.default_privacy_system
,
831 prefs_account_set_string_from_combobox
,
832 prefs_account_set_privacy_combobox_from_string
},
834 {"default_encrypt", "FALSE", &tmp_ac_prefs
.default_encrypt
, P_BOOL
,
835 &privacy_page
.default_encrypt_checkbtn
,
836 prefs_set_data_from_toggle
, prefs_set_toggle
},
838 {"default_encrypt_reply", "TRUE", &tmp_ac_prefs
.default_encrypt_reply
, P_BOOL
,
839 &privacy_page
.default_encrypt_reply_checkbtn
,
840 prefs_set_data_from_toggle
, prefs_set_toggle
},
842 {"default_sign", "FALSE", &tmp_ac_prefs
.default_sign
, P_BOOL
,
843 &privacy_page
.default_sign_checkbtn
,
844 prefs_set_data_from_toggle
, prefs_set_toggle
},
846 {"default_sign_reply", "TRUE", &tmp_ac_prefs
.default_sign_reply
, P_BOOL
,
847 &privacy_page
.default_sign_reply_checkbtn
,
848 prefs_set_data_from_toggle
, prefs_set_toggle
},
850 /* Bug 2367: disturbing for Win32 users with no keypair */
851 {"default_sign_reply", "FALSE", &tmp_ac_prefs
.default_sign_reply
, P_BOOL
,
852 &privacy_page
.default_sign_reply_checkbtn
,
853 prefs_set_data_from_toggle
, prefs_set_toggle
},
855 {"save_clear_text", "FALSE", &tmp_ac_prefs
.save_encrypted_as_clear_text
, P_BOOL
,
856 &privacy_page
.save_clear_text_checkbtn
,
857 prefs_set_data_from_toggle
, prefs_set_toggle
},
859 {"encrypt_to_self", "FALSE", &tmp_ac_prefs
.encrypt_to_self
, P_BOOL
,
860 &privacy_page
.encrypt_to_self_checkbtn
,
861 prefs_set_data_from_toggle
, prefs_set_toggle
},
863 {"privacy_prefs", "", &privacy_prefs
, P_STRING
,
866 {NULL
, NULL
, NULL
, P_OTHER
, NULL
, NULL
, NULL
}
869 static PrefParam ssl_param
[] = {
871 {"ssl_pop", "0", &tmp_ac_prefs
.ssl_pop
, P_ENUM
,
872 &ssl_page
.pop_nossl_radiobtn
,
873 prefs_account_enum_set_data_from_radiobtn
,
874 prefs_account_enum_set_radiobtn
},
876 {"ssl_imap", "0", &tmp_ac_prefs
.ssl_imap
, P_ENUM
,
877 &ssl_page
.imap_nossl_radiobtn
,
878 prefs_account_enum_set_data_from_radiobtn
,
879 prefs_account_enum_set_radiobtn
},
881 {"ssl_nntp", "0", &tmp_ac_prefs
.ssl_nntp
, P_ENUM
,
882 &ssl_page
.nntp_nossl_radiobtn
,
883 prefs_account_enum_set_data_from_radiobtn
,
884 prefs_account_enum_set_radiobtn
},
886 {"ssl_smtp", "0", &tmp_ac_prefs
.ssl_smtp
, P_ENUM
,
887 &ssl_page
.smtp_nossl_radiobtn
,
888 prefs_account_enum_set_data_from_radiobtn
,
889 prefs_account_enum_set_radiobtn
},
891 {"ssl_certs_auto_accept", "0", &tmp_ac_prefs
.ssl_certs_auto_accept
, P_BOOL
,
892 &ssl_page
.ssl_certs_auto_accept_checkbtn
,
893 prefs_set_data_from_toggle
, prefs_set_toggle
},
895 {"use_nonblocking_ssl", "1", &tmp_ac_prefs
.use_nonblocking_ssl
, P_BOOL
,
896 &ssl_page
.use_nonblocking_ssl_checkbtn
,
897 prefs_set_data_from_toggle
, prefs_set_toggle
},
899 {"use_tls_sni", "1", &tmp_ac_prefs
.use_tls_sni
, P_BOOL
,
902 {"in_ssl_client_cert_file", "", &tmp_ac_prefs
.in_ssl_client_cert_file
, P_STRING
,
903 &ssl_page
.entry_in_cert_file
, prefs_set_data_from_entry
, prefs_set_entry
},
905 {"in_ssl_client_cert_pass", "", &tmp_ac_prefs
.in_ssl_client_cert_pass
, P_PASSWORD
,
908 {"out_ssl_client_cert_file", "", &tmp_ac_prefs
.out_ssl_client_cert_file
, P_STRING
,
909 &ssl_page
.entry_out_cert_file
, prefs_set_data_from_entry
, prefs_set_entry
},
911 {"out_ssl_client_cert_pass", "", &tmp_ac_prefs
.out_ssl_client_cert_pass
, P_PASSWORD
,
914 {"ssl_pop", "0", &tmp_ac_prefs
.ssl_pop
, P_ENUM
,
917 {"ssl_imap", "0", &tmp_ac_prefs
.ssl_imap
, P_ENUM
,
920 {"ssl_nntp", "0", &tmp_ac_prefs
.ssl_nntp
, P_ENUM
,
923 {"ssl_smtp", "0", &tmp_ac_prefs
.ssl_smtp
, P_ENUM
,
926 {"in_ssl_client_cert_file", "", &tmp_ac_prefs
.in_ssl_client_cert_file
, P_STRING
,
929 {"in_ssl_client_cert_pass", "", &tmp_ac_prefs
.in_ssl_client_cert_pass
, P_PASSWORD
,
932 {"out_ssl_client_cert_file", "", &tmp_ac_prefs
.out_ssl_client_cert_file
, P_STRING
,
935 {"out_ssl_client_cert_pass", "", &tmp_ac_prefs
.out_ssl_client_cert_pass
, P_PASSWORD
,
938 {"ssl_certs_auto_accept", "0", &tmp_ac_prefs
.ssl_certs_auto_accept
, P_BOOL
,
941 {"use_nonblocking_ssl", "1", &tmp_ac_prefs
.use_nonblocking_ssl
, P_BOOL
,
943 #endif /* USE_GNUTLS */
945 {NULL
, NULL
, NULL
, P_OTHER
, NULL
, NULL
, NULL
}
948 static PrefParam proxy_param
[] = {
950 {"use_proxy", "FALSE", &tmp_ac_prefs
.use_proxy
, P_BOOL
,
951 &proxy_page
.proxy_checkbtn
,
952 prefs_set_data_from_toggle
, prefs_set_toggle
},
954 {"use_default_proxy", "TRUE", &tmp_ac_prefs
.use_default_proxy
, P_BOOL
,
955 &proxy_page
.default_proxy_checkbtn
,
956 prefs_set_data_from_toggle
, prefs_set_toggle
},
958 {"use_proxy_for_send", "TRUE", &tmp_ac_prefs
.use_proxy_for_send
, P_BOOL
,
959 &proxy_page
.proxy_send_checkbtn
,
960 prefs_set_data_from_toggle
, prefs_set_toggle
},
962 {"proxy_type", "1", &tmp_ac_prefs
.proxy_info
.proxy_type
, P_ENUM
,
963 &proxy_page
.socks4_radiobtn
,
964 prefs_account_enum_set_data_from_radiobtn
,
965 prefs_account_enum_set_radiobtn
},
967 {"proxy_host", "localhost", &tmp_ac_prefs
.proxy_info
.proxy_host
, P_STRING
,
968 &proxy_page
.proxy_host_entry
,
969 prefs_set_data_from_entry
, prefs_set_entry
},
971 {"proxy_port", "1080", &tmp_ac_prefs
.proxy_info
.proxy_port
, P_USHORT
,
972 &proxy_page
.proxy_port_spinbtn
,
973 prefs_set_data_from_spinbtn
, prefs_set_spinbtn
},
975 {"use_proxy_auth", "FALSE", &tmp_ac_prefs
.proxy_info
.use_proxy_auth
, P_BOOL
,
976 &proxy_page
.proxy_auth_checkbtn
,
977 prefs_set_data_from_toggle
, prefs_set_toggle
},
979 {"proxy_name", "", &tmp_ac_prefs
.proxy_info
.proxy_name
, P_STRING
,
980 &proxy_page
.proxy_name_entry
,
981 prefs_set_data_from_entry
, prefs_set_entry
},
983 {"proxy_pass", NULL
, &tmp_ac_prefs
.proxy_info
.proxy_pass
, P_PASSWORD
,
987 {NULL
, NULL
, NULL
, P_OTHER
, NULL
, NULL
, NULL
}
990 static PrefParam advanced_param
[] = {
991 {"set_smtpport", "FALSE", &tmp_ac_prefs
.set_smtpport
, P_BOOL
,
992 &advanced_page
.smtpport_checkbtn
,
993 prefs_set_data_from_toggle
, prefs_set_toggle
},
995 {"smtp_port", "25", &tmp_ac_prefs
.smtpport
, P_USHORT
,
996 &advanced_page
.smtpport_spinbtn
,
997 prefs_set_data_from_spinbtn
, prefs_set_spinbtn
},
999 {"set_popport", "FALSE", &tmp_ac_prefs
.set_popport
, P_BOOL
,
1000 &advanced_page
.popport_checkbtn
,
1001 prefs_set_data_from_toggle
, prefs_set_toggle
},
1003 {"pop_port", "110", &tmp_ac_prefs
.popport
, P_USHORT
,
1004 &advanced_page
.popport_spinbtn
,
1005 prefs_set_data_from_spinbtn
, prefs_set_spinbtn
},
1007 {"set_imapport", "FALSE", &tmp_ac_prefs
.set_imapport
, P_BOOL
,
1008 &advanced_page
.imapport_checkbtn
,
1009 prefs_set_data_from_toggle
, prefs_set_toggle
},
1011 {"imap_port", "143", &tmp_ac_prefs
.imapport
, P_USHORT
,
1012 &advanced_page
.imapport_spinbtn
,
1013 prefs_set_data_from_spinbtn
, prefs_set_spinbtn
},
1015 {"set_nntpport", "FALSE", &tmp_ac_prefs
.set_nntpport
, P_BOOL
,
1016 &advanced_page
.nntpport_checkbtn
,
1017 prefs_set_data_from_toggle
, prefs_set_toggle
},
1019 {"nntp_port", "119", &tmp_ac_prefs
.nntpport
, P_USHORT
,
1020 &advanced_page
.nntpport_spinbtn
,
1021 prefs_set_data_from_spinbtn
, prefs_set_spinbtn
},
1023 {"set_domain", "FALSE", &tmp_ac_prefs
.set_domain
, P_BOOL
,
1024 &advanced_page
.domain_checkbtn
,
1025 prefs_set_data_from_toggle
, prefs_set_toggle
},
1027 {"domain", NULL
, &tmp_ac_prefs
.domain
, P_STRING
,
1028 &advanced_page
.domain_entry
,
1029 prefs_set_data_from_entry
, prefs_set_entry
},
1032 {"gnutls_set_priority", "FALSE", &tmp_ac_prefs
.set_gnutls_priority
, P_BOOL
,
1035 {"gnutls_priority", NULL
, &tmp_ac_prefs
.gnutls_priority
, P_STRING
,
1040 {"set_tunnelcmd", "FALSE", &tmp_ac_prefs
.set_tunnelcmd
, P_BOOL
,
1041 &advanced_page
.tunnelcmd_checkbtn
,
1042 prefs_set_data_from_toggle
, prefs_set_toggle
},
1044 {"tunnelcmd", NULL
, &tmp_ac_prefs
.tunnelcmd
, P_STRING
,
1045 &advanced_page
.tunnelcmd_entry
,
1046 prefs_set_data_from_entry
, prefs_set_entry
},
1048 {"mark_crosspost_read", "FALSE", &tmp_ac_prefs
.mark_crosspost_read
, P_BOOL
,
1049 &advanced_page
.crosspost_checkbtn
,
1050 prefs_set_data_from_toggle
, prefs_set_toggle
},
1052 {"crosspost_color", NULL
, &tmp_ac_prefs
.crosspost_col
, P_ENUM
,
1053 &advanced_page
.crosspost_colormenu
,
1054 prefs_account_crosspost_set_data_from_colormenu
,
1055 prefs_account_crosspost_set_colormenu
},
1057 {"set_sent_folder", "FALSE", &tmp_ac_prefs
.set_sent_folder
, P_BOOL
,
1058 &advanced_page
.sent_folder_checkbtn
,
1059 prefs_set_data_from_toggle
, prefs_set_toggle
},
1060 {"sent_folder", NULL
, &tmp_ac_prefs
.sent_folder
, P_STRING
,
1061 &advanced_page
.sent_folder_entry
,
1062 prefs_set_data_from_entry
, prefs_set_entry
},
1064 {"set_queue_folder", "FALSE", &tmp_ac_prefs
.set_queue_folder
, P_BOOL
,
1065 &advanced_page
.queue_folder_checkbtn
,
1066 prefs_set_data_from_toggle
, prefs_set_toggle
},
1067 {"queue_folder", NULL
, &tmp_ac_prefs
.queue_folder
, P_STRING
,
1068 &advanced_page
.queue_folder_entry
,
1069 prefs_set_data_from_entry
, prefs_set_entry
},
1071 {"set_draft_folder", "FALSE", &tmp_ac_prefs
.set_draft_folder
, P_BOOL
,
1072 &advanced_page
.draft_folder_checkbtn
,
1073 prefs_set_data_from_toggle
, prefs_set_toggle
},
1074 {"draft_folder", NULL
, &tmp_ac_prefs
.draft_folder
, P_STRING
,
1075 &advanced_page
.draft_folder_entry
,
1076 prefs_set_data_from_entry
, prefs_set_entry
},
1078 {"set_trash_folder", "FALSE", &tmp_ac_prefs
.set_trash_folder
, P_BOOL
,
1079 &advanced_page
.trash_folder_checkbtn
,
1080 prefs_set_data_from_toggle
, prefs_set_toggle
},
1081 {"trash_folder", NULL
, &tmp_ac_prefs
.trash_folder
, P_STRING
,
1082 &advanced_page
.trash_folder_entry
,
1083 prefs_set_data_from_entry
, prefs_set_entry
},
1086 {NULL
, NULL
, NULL
, P_OTHER
, NULL
, NULL
, NULL
}
1089 static gint
prefs_account_get_new_id (void);
1091 static void prefs_account_select_folder_cb (GtkWidget
*widget
, gpointer data
);
1093 static void prefs_account_sigfile_radiobtn_cb (GtkWidget
*widget
, gpointer data
);
1095 static void prefs_account_sigcmd_radiobtn_cb (GtkWidget
*widget
, gpointer data
);
1097 static void prefs_account_signature_browse_cb (GtkWidget
*widget
, gpointer data
);
1099 static void prefs_account_in_cert_browse_cb (GtkWidget
*widget
, gpointer data
);
1101 static void prefs_account_out_cert_browse_cb (GtkWidget
*widget
, gpointer data
);
1103 static void prefs_account_signature_edit_cb (GtkWidget
*widget
, gpointer data
);
1105 static void pop_bfr_smtp_tm_set_sens (GtkWidget
*widget
, gpointer data
);
1107 #if (defined USE_GNUTLS)
1108 static void auto_configure_cb (GtkWidget
*widget
, gpointer data
);
1111 static void prefs_account_edit_custom_header (void);
1113 static void prefs_account_receive_itv_spinbutton_value_changed_cb(GtkWidget
*w
, gpointer data
);
1115 #define COMBOBOX_PRIVACY_PLUGIN_ID 3
1117 /* Enable/disable necessary preference widgets based on current privacy
1119 static void privacy_system_activated(GtkWidget
*combobox
)
1121 gtk_widget_set_sensitive (privacy_page
.save_clear_text_checkbtn
,
1122 !gtk_toggle_button_get_active(
1123 GTK_TOGGLE_BUTTON(privacy_page
.encrypt_to_self_checkbtn
)));
1126 /* Populate the privacy system choice combobox with valid choices */
1127 static void update_privacy_system_menu() {
1130 GSList
*system_ids
, *cur
;
1132 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(
1133 GTK_COMBO_BOX(privacy_page
.default_privacy_system
)));
1135 /* First add "None", as that one is always available. :) */
1136 gtk_list_store_append(menu
, &iter
);
1137 gtk_list_store_set(menu
, &iter
,
1138 COMBOBOX_TEXT
, _("None"),
1140 COMBOBOX_SENS
, TRUE
,
1141 COMBOBOX_PRIVACY_PLUGIN_ID
, "",
1144 /* Now go through list of available privacy systems and add an entry
1146 system_ids
= privacy_get_system_ids();
1147 for (cur
= system_ids
; cur
!= NULL
; cur
= g_slist_next(cur
)) {
1148 gchar
*id
= (gchar
*) cur
->data
;
1151 name
= privacy_system_get_name(id
);
1152 gtk_list_store_append(menu
, &iter
);
1153 gtk_list_store_set(menu
, &iter
,
1154 COMBOBOX_TEXT
, name
,
1156 COMBOBOX_SENS
, TRUE
,
1157 COMBOBOX_PRIVACY_PLUGIN_ID
, id
,
1161 g_slist_free(system_ids
);
1165 #define TABLE_YPAD 2
1167 static void basic_create_widget_func(PrefsPage
* _page
,
1171 BasicPage
*page
= (BasicPage
*) _page
;
1172 PrefsAccount
*ac_prefs
= (PrefsAccount
*) data
;
1177 GtkWidget
*acname_entry
;
1178 GtkWidget
*default_checkbtn
;
1181 GtkWidget
*name_entry
;
1182 GtkWidget
*addr_entry
;
1183 GtkWidget
*org_entry
;
1185 GtkWidget
*serv_frame
;
1187 GtkWidget
*optmenubox
;
1189 GtkWidget
*optlabel
;
1190 GtkWidget
*no_imap_warn_icon
;
1191 GtkWidget
*no_imap_warn_label
;
1192 GtkWidget
*serv_table
;
1193 GtkWidget
*recvserv_label
;
1194 GtkWidget
*smtpserv_label
;
1195 GtkWidget
*nntpserv_label
;
1196 GtkWidget
*localmbox_label
;
1197 GtkWidget
*mailcmd_label
;
1198 GtkWidget
*recvserv_entry
;
1199 GtkWidget
*smtpserv_entry
;
1200 GtkWidget
*nntpserv_entry
;
1201 GtkWidget
*nntpauth_checkbtn
;
1202 GtkWidget
*nntpauth_onconnect_checkbtn
;
1203 GtkWidget
*localmbox_entry
;
1204 GtkWidget
*mailcmd_checkbtn
;
1205 GtkWidget
*mailcmd_entry
;
1206 GtkWidget
*uid_label
;
1207 GtkWidget
*pass_label
;
1208 GtkWidget
*uid_entry
;
1209 GtkWidget
*pass_entry
;
1210 GtkWidget
*auto_configure_btn
;
1211 GtkWidget
*auto_configure_cancel_btn
;
1212 GtkWidget
*auto_configure_lbl
;
1213 GtkWidget
*showpwd_checkbtn
;
1218 struct BasicProtocol
*protocol_optmenu
;
1221 vbox1
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING
);
1222 gtk_widget_show (vbox1
);
1223 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), VBOX_BORDER
);
1225 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
1226 gtk_widget_show (hbox
);
1227 gtk_box_pack_start (GTK_BOX (vbox1
), hbox
, FALSE
, FALSE
, 0);
1229 label
= gtk_label_new (_("Name of account"));
1230 gtk_widget_show (label
);
1231 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1233 acname_entry
= gtk_entry_new ();
1234 gtk_widget_show (acname_entry
);
1235 gtk_widget_set_size_request (acname_entry
, DEFAULT_ENTRY_WIDTH
, -1);
1236 gtk_box_pack_start (GTK_BOX (hbox
), acname_entry
, TRUE
, TRUE
, 0);
1238 default_checkbtn
= gtk_check_button_new_with_label (_("Set as default"));
1239 gtk_widget_show (default_checkbtn
);
1240 #ifndef GENERIC_UMPC
1241 gtk_box_pack_end (GTK_BOX (hbox
), default_checkbtn
, TRUE
, FALSE
, 0);
1243 gtk_box_pack_start (GTK_BOX (vbox1
), default_checkbtn
, FALSE
, FALSE
, 0);
1246 PACK_FRAME (vbox1
, frame1
, _("Personal information"));
1248 table1
= gtk_grid_new();
1249 gtk_widget_show (table1
);
1250 gtk_container_add (GTK_CONTAINER (frame1
), table1
);
1251 gtk_container_set_border_width (GTK_CONTAINER (table1
), 8);
1252 gtk_grid_set_row_spacing(GTK_GRID(table1
), VSPACING_NARROW
);
1253 gtk_grid_set_column_spacing(GTK_GRID(table1
), 8);
1255 label
= gtk_label_new (_("Full name"));
1256 gtk_widget_show (label
);
1257 gtk_label_set_xalign(GTK_LABEL (label
), 1.0);
1258 gtk_grid_attach(GTK_GRID(table1
), label
, 0, 0, 1, 1);
1260 label
= gtk_label_new (_("Mail address"));
1261 gtk_widget_show (label
);
1262 gtk_label_set_xalign(GTK_LABEL (label
), 1.0);
1263 gtk_grid_attach(GTK_GRID(table1
), label
, 0, 1, 1, 1);
1265 label
= gtk_label_new (_("Organization"));
1266 gtk_widget_show (label
);
1267 gtk_label_set_xalign(GTK_LABEL (label
), 1.0);
1268 gtk_grid_attach(GTK_GRID(table1
), label
, 0, 2, 1, 1);
1270 name_entry
= gtk_entry_new ();
1271 gtk_widget_show (name_entry
);
1272 gtk_grid_attach(GTK_GRID(table1
), name_entry
, 1, 0, 1, 1);
1273 gtk_widget_set_hexpand(name_entry
, TRUE
);
1274 gtk_widget_set_halign(name_entry
, GTK_ALIGN_FILL
);
1276 addr_entry
= gtk_entry_new ();
1277 gtk_widget_show (addr_entry
);
1278 gtk_grid_attach(GTK_GRID(table1
), addr_entry
, 1, 1, 1, 1);
1279 gtk_widget_set_hexpand(addr_entry
, TRUE
);
1280 gtk_widget_set_halign(addr_entry
, GTK_ALIGN_FILL
);
1282 org_entry
= gtk_entry_new ();
1283 gtk_widget_show (org_entry
);
1284 gtk_grid_attach(GTK_GRID(table1
), org_entry
, 1, 2, 1, 1);
1285 gtk_widget_set_hexpand(org_entry
, TRUE
);
1286 gtk_widget_set_halign(org_entry
, GTK_ALIGN_FILL
);
1288 vbox2
= gtkut_get_options_frame(vbox1
, &serv_frame
, _("Server information"));
1290 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
1291 gtk_widget_show (hbox
);
1292 gtk_box_pack_start (GTK_BOX (vbox2
), hbox
, FALSE
, FALSE
, 0);
1294 label
= gtk_label_new (_("Protocol"));
1295 gtk_widget_show (label
);
1296 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1298 /* Create GtkHBox for protocol combobox and label */
1299 optmenubox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 20);
1300 gtk_widget_show(optmenubox
);
1301 gtk_box_pack_start (GTK_BOX (hbox
), optmenubox
, FALSE
, FALSE
, 0);
1303 /* Create and populate the combobox */
1304 optmenu
= gtkut_sc_combobox_create(NULL
, FALSE
);
1305 gtk_box_pack_start(GTK_BOX (optmenubox
), optmenu
, FALSE
, FALSE
, 0);
1307 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu
)));
1308 for( i
= 0; i
< NUM_RECV_PROTOCOLS
; i
++ )
1309 if( protocol_names
[i
] != NULL
)
1310 COMBOBOX_ADD (menu
, _(protocol_names
[i
]), i
);
1312 g_signal_connect(G_OBJECT(optmenu
), "changed",
1313 G_CALLBACK(prefs_account_protocol_changed
), NULL
);
1315 /* Create protocol label, empty for now */
1316 optlabel
= gtk_label_new("");
1317 gtk_label_set_use_markup(GTK_LABEL(optlabel
), TRUE
);
1318 gtk_label_set_justify(GTK_LABEL(optlabel
), GTK_JUSTIFY_CENTER
);
1319 gtk_box_pack_start(GTK_BOX (optmenubox
), optlabel
, FALSE
, FALSE
, 0);
1321 auto_configure_btn
= gtk_button_new_with_label(_("Auto-configure"));
1322 gtk_box_pack_start(GTK_BOX (optmenubox
), auto_configure_btn
, FALSE
, FALSE
, 0);
1323 auto_configure_cancel_btn
= gtk_button_new_with_label(_("Cancel"));
1324 gtk_box_pack_start(GTK_BOX (optmenubox
), auto_configure_cancel_btn
, FALSE
, FALSE
, 0);
1325 auto_configure_lbl
= gtk_label_new("");
1326 gtk_label_set_justify(GTK_LABEL(auto_configure_lbl
), GTK_JUSTIFY_LEFT
);
1327 gtk_box_pack_start(GTK_BOX (optmenubox
), auto_configure_lbl
, FALSE
, FALSE
, 0);
1328 #if (defined USE_GNUTLS)
1329 gtk_widget_show(auto_configure_btn
);
1330 gtk_widget_show(auto_configure_lbl
);
1331 g_signal_connect (G_OBJECT (auto_configure_btn
), "clicked",
1332 G_CALLBACK (auto_configure_cb
), NULL
);
1333 g_signal_connect (G_OBJECT (auto_configure_cancel_btn
), "clicked",
1334 G_CALLBACK (auto_configure_cb
), NULL
);
1337 no_imap_warn_icon
= gtk_image_new_from_icon_name
1338 ("dialog-warning", GTK_ICON_SIZE_SMALL_TOOLBAR
);
1339 buf
= g_strconcat("<span weight=\"bold\">",
1340 _("Warning: this version of Claws Mail\n"
1341 "has been built without IMAP and News support."), "</span>", NULL
);
1342 no_imap_warn_label
= gtk_label_new(buf
);
1344 gtk_label_set_use_markup(GTK_LABEL(no_imap_warn_label
), TRUE
);
1346 gtk_box_pack_start(GTK_BOX (optmenubox
), no_imap_warn_icon
, FALSE
, FALSE
, 0);
1347 gtk_box_pack_start(GTK_BOX (optmenubox
), no_imap_warn_label
, FALSE
, FALSE
, 0);
1348 /* Set up a struct to store pointers to necessary widgets */
1349 protocol_optmenu
= g_new(struct BasicProtocol
, 1);
1350 protocol_optmenu
->combobox
= optmenu
;
1351 protocol_optmenu
->label
= optlabel
;
1352 protocol_optmenu
->descrlabel
= label
;
1353 protocol_optmenu
->no_imap_warn_icon
= no_imap_warn_icon
;
1354 protocol_optmenu
->no_imap_warn_label
= no_imap_warn_label
;
1356 serv_table
= gtk_grid_new ();
1357 gtk_widget_show (serv_table
);
1358 gtk_grid_set_row_spacing(GTK_GRID(serv_table
), VSPACING_NARROW
);
1359 gtk_grid_set_column_spacing(GTK_GRID(serv_table
), 8);
1360 gtk_box_pack_start (GTK_BOX (vbox2
), serv_table
, FALSE
, FALSE
, 0);
1362 nntpserv_entry
= gtk_entry_new ();
1363 gtk_widget_show (nntpserv_entry
);
1364 gtk_grid_attach(GTK_GRID(serv_table
), nntpserv_entry
, 1, 0, 2, 1);
1365 gtk_widget_set_hexpand(nntpserv_entry
, TRUE
);
1366 gtk_widget_set_halign(nntpserv_entry
, GTK_ALIGN_FILL
);
1368 nntpauth_checkbtn
= gtk_check_button_new_with_label
1369 (_("This server requires authentication"));
1370 gtk_widget_show (nntpauth_checkbtn
);
1372 gtk_grid_attach(GTK_GRID(serv_table
), nntpauth_checkbtn
, 0, 6, 2, 1);
1374 nntpauth_onconnect_checkbtn
= gtk_check_button_new_with_label
1375 (_("Authenticate on connect"));
1376 gtk_widget_show (nntpauth_onconnect_checkbtn
);
1378 gtk_grid_attach(GTK_GRID(serv_table
), nntpauth_onconnect_checkbtn
, 2, 6, 1, 1);
1380 recvserv_entry
= gtk_entry_new ();
1381 gtk_widget_show (recvserv_entry
);
1382 gtk_grid_attach(GTK_GRID(serv_table
), recvserv_entry
, 1, 2, 2, 1);
1383 gtk_widget_set_hexpand(recvserv_entry
, TRUE
);
1384 gtk_widget_set_halign(recvserv_entry
, GTK_ALIGN_FILL
);
1386 localmbox_entry
= gtk_entry_new ();
1387 gtk_widget_show (localmbox_entry
);
1388 gtk_grid_attach(GTK_GRID(serv_table
), localmbox_entry
, 1, 3, 2, 1);
1389 gtk_widget_set_hexpand(localmbox_entry
, TRUE
);
1390 gtk_widget_set_halign(localmbox_entry
, GTK_ALIGN_FILL
);
1392 smtpserv_entry
= gtk_entry_new ();
1393 gtk_widget_show (smtpserv_entry
);
1394 gtk_grid_attach(GTK_GRID(serv_table
), smtpserv_entry
, 1, 4, 2, 1);
1395 gtk_widget_set_hexpand(smtpserv_entry
, TRUE
);
1396 gtk_widget_set_halign(smtpserv_entry
, GTK_ALIGN_FILL
);
1398 mailcmd_entry
= gtk_entry_new ();
1399 gtk_widget_show (mailcmd_entry
);
1400 gtk_grid_attach(GTK_GRID(serv_table
), mailcmd_entry
, 1, 6, 2, 1);
1401 gtk_widget_set_hexpand(mailcmd_entry
, TRUE
);
1402 gtk_widget_set_halign(mailcmd_entry
, GTK_ALIGN_FILL
);
1404 uid_entry
= gtk_entry_new ();
1405 gtk_widget_show (uid_entry
);
1406 gtk_widget_set_size_request (uid_entry
, DEFAULT_ENTRY_WIDTH
, -1);
1407 gtk_grid_attach(GTK_GRID(serv_table
), uid_entry
, 1, 7, 1, 1);
1408 gtk_widget_set_hexpand(uid_entry
, TRUE
);
1409 gtk_widget_set_halign(uid_entry
, GTK_ALIGN_FILL
);
1410 g_signal_connect(G_OBJECT(uid_entry
), "changed",
1411 G_CALLBACK(prefs_account_entry_changed_newline_check_cb
),
1412 GINT_TO_POINTER(ac_prefs
->protocol
));
1414 pass_entry
= gtk_entry_new ();
1415 gtk_widget_show (pass_entry
);
1416 gtk_widget_set_size_request (pass_entry
, DEFAULT_ENTRY_WIDTH
, -1);
1417 gtk_grid_attach(GTK_GRID(serv_table
), pass_entry
, 1, 8, 1, 1);
1418 gtk_widget_set_hexpand(pass_entry
, TRUE
);
1419 gtk_widget_set_halign(pass_entry
, GTK_ALIGN_FILL
);
1420 gtk_entry_set_visibility (GTK_ENTRY (pass_entry
), FALSE
);
1421 g_signal_connect(G_OBJECT(pass_entry
), "changed",
1422 G_CALLBACK(prefs_account_entry_changed_newline_check_cb
),
1423 GINT_TO_POINTER(ac_prefs
->protocol
));
1425 nntpserv_label
= gtk_label_new (_("News server"));
1426 gtk_widget_show (nntpserv_label
);
1427 gtk_label_set_xalign(GTK_LABEL (nntpserv_label
), 1.0);
1428 gtk_grid_attach(GTK_GRID(serv_table
), nntpserv_label
, 0, 0, 1, 1);
1430 recvserv_label
= gtk_label_new (_("Server for receiving"));
1431 gtk_widget_show (recvserv_label
);
1432 gtk_label_set_xalign(GTK_LABEL (recvserv_label
), 1.0);
1433 gtk_grid_attach(GTK_GRID(serv_table
), recvserv_label
, 0, 2, 1, 1);
1435 localmbox_label
= gtk_label_new (_("Local mailbox"));
1436 gtk_widget_show (localmbox_label
);
1437 gtk_label_set_xalign(GTK_LABEL (localmbox_label
), 1.0);
1438 gtk_grid_attach(GTK_GRID(serv_table
), localmbox_label
, 0, 3, 1, 1);
1440 smtpserv_label
= gtk_label_new (_("SMTP server (send)"));
1441 gtk_widget_show (smtpserv_label
);
1442 gtk_label_set_xalign(GTK_LABEL (smtpserv_label
), 1.0);
1443 gtk_grid_attach(GTK_GRID(serv_table
), smtpserv_label
, 0, 4, 1, 1);
1445 mailcmd_checkbtn
= gtk_check_button_new_with_label
1446 (_("Use mail command rather than SMTP server"));
1447 gtk_widget_show (mailcmd_checkbtn
);
1448 gtk_grid_attach(GTK_GRID(serv_table
), mailcmd_checkbtn
, 0, 5, 2, 1);
1450 g_signal_connect(G_OBJECT(mailcmd_checkbtn
), "toggled",
1451 G_CALLBACK(prefs_account_mailcmd_toggled
),
1454 mailcmd_label
= gtk_label_new (_("command to send mails"));
1455 gtk_widget_show (mailcmd_label
);
1456 gtk_label_set_xalign(GTK_LABEL (mailcmd_label
), 1.0);
1457 gtk_grid_attach(GTK_GRID(serv_table
), mailcmd_label
, 0, 6, 1, 1);
1459 uid_label
= gtk_label_new (_("User ID"));
1460 gtk_widget_show (uid_label
);
1461 gtk_label_set_xalign(GTK_LABEL (uid_label
), 1.0);
1462 gtk_grid_attach(GTK_GRID(serv_table
), uid_label
, 0, 7, 1, 1);
1464 pass_label
= gtk_label_new (_("Password"));
1465 gtk_widget_show (pass_label
);
1467 gtk_label_set_xalign(GTK_LABEL (pass_label
), 1.0);
1469 gtk_grid_attach(GTK_GRID(serv_table
), pass_label
, 0, 8, 1, 1);
1471 showpwd_checkbtn
= gtk_check_button_new_with_label (_("Show password"));
1472 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn
), FALSE
);
1473 gtk_widget_show(showpwd_checkbtn
);
1474 gtk_grid_attach(GTK_GRID(serv_table
), showpwd_checkbtn
, 2, 8, 1, 1);
1475 g_signal_connect(G_OBJECT(showpwd_checkbtn
), "toggled",
1476 G_CALLBACK(prefs_account_showpwd_checkbtn_toggled
), pass_entry
);
1478 SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn
, uid_label
);
1479 SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn
, pass_label
);
1480 SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn
, uid_entry
);
1481 SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn
, pass_entry
);
1482 SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn
, showpwd_checkbtn
);
1483 SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn
, nntpauth_onconnect_checkbtn
);
1485 page
->acname_entry
= acname_entry
;
1486 page
->default_checkbtn
= default_checkbtn
;
1488 page
->name_entry
= name_entry
;
1489 page
->addr_entry
= addr_entry
;
1490 page
->org_entry
= org_entry
;
1492 page
->serv_frame
= serv_frame
;
1493 page
->serv_table
= serv_table
;
1494 page
->protocol_optmenu
= (gpointer
)protocol_optmenu
;
1495 page
->recvserv_label
= recvserv_label
;
1496 page
->recvserv_entry
= recvserv_entry
;
1497 page
->smtpserv_label
= smtpserv_label
;
1498 page
->smtpserv_entry
= smtpserv_entry
;
1499 page
->nntpserv_label
= nntpserv_label
;
1500 page
->nntpserv_entry
= nntpserv_entry
;
1501 page
->nntpauth_checkbtn
= nntpauth_checkbtn
;
1502 page
->nntpauth_onconnect_checkbtn
= nntpauth_onconnect_checkbtn
;
1503 page
->localmbox_label
= localmbox_label
;
1504 page
->localmbox_entry
= localmbox_entry
;
1505 page
->mailcmd_checkbtn
= mailcmd_checkbtn
;
1506 page
->mailcmd_label
= mailcmd_label
;
1507 page
->mailcmd_entry
= mailcmd_entry
;
1508 page
->uid_label
= uid_label
;
1509 page
->pass_label
= pass_label
;
1510 page
->uid_entry
= uid_entry
;
1511 page
->pass_entry
= pass_entry
;
1512 page
->showpwd_checkbtn
= showpwd_checkbtn
;
1513 page
->auto_configure_btn
= auto_configure_btn
;
1514 page
->auto_configure_cancel_btn
= auto_configure_cancel_btn
;
1515 page
->auto_configure_lbl
= auto_configure_lbl
;
1518 prefs_set_dialog_to_default(basic_param
);
1519 buf
= g_strdup_printf(_("Account%d"), ac_prefs
->account_id
);
1520 gtk_entry_set_text(GTK_ENTRY(basic_page
.acname_entry
), buf
);
1523 prefs_set_dialog(basic_param
);
1525 /* Passwords are handled outside of PrefParams. */
1526 buf
= passwd_store_get_account(ac_prefs
->account_id
,
1528 gtk_entry_set_text(GTK_ENTRY(page
->pass_entry
), buf
!= NULL
? buf
: "");
1530 memset(buf
, 0, strlen(buf
));
1537 page
->page
.widget
= vbox1
;
1540 static void receive_create_widget_func(PrefsPage
* _page
,
1544 ReceivePage
*page
= (ReceivePage
*) _page
;
1545 PrefsAccount
*ac_prefs
= (PrefsAccount
*) data
;
1547 GtkWidget
*vbox1
, *vbox2
, *vbox3
, *vbox4
, *vbox5
;
1548 GtkWidget
*hbox1
, *hbox2
, *hbox3
;
1550 GtkWidget
*pop_auth_checkbtn
;
1551 GtkWidget
*rmmail_checkbtn
;
1552 GtkWidget
*hbox_spc
;
1553 GtkWidget
*leave_time_label
;
1554 GtkWidget
*leave_time_spinbtn
;
1555 GtkWidget
*leave_hour_label
;
1556 GtkWidget
*leave_hour_spinbtn
;
1557 GtkWidget
*size_limit_checkbtn
;
1558 GtkWidget
*size_limit_spinbtn
;
1560 GtkWidget
*filter_on_recv_checkbtn
;
1561 GtkWidget
*filterhook_on_recv_checkbtn
;
1562 GtkWidget
*inbox_label
;
1563 GtkWidget
*inbox_entry
;
1564 GtkWidget
*inbox_btn
;
1565 GtkWidget
*imap_frame
;
1566 GtkWidget
*imapdir_label
;
1567 GtkWidget
*imapdir_entry
;
1568 GtkWidget
*subsonly_checkbtn
;
1569 GtkWidget
*low_bandwidth_checkbtn
;
1570 GtkWidget
*local_frame
;
1571 GtkWidget
*local_vbox
;
1572 GtkWidget
*local_hbox
;
1573 GtkWidget
*local_inbox_label
;
1574 GtkWidget
*local_inbox_entry
;
1575 GtkWidget
*local_inbox_btn
;
1576 GtkWidget
*autochk_checkbtn
;
1577 GtkWidget
*autochk_hour_spinbtn
, *autochk_hour_label
;
1578 GtkWidget
*autochk_min_spinbtn
, *autochk_min_label
;
1579 GtkWidget
*autochk_sec_spinbtn
, *autochk_sec_label
;
1580 GtkWidget
*autochk_use_default_checkbtn
;
1582 struct AutocheckWidgets
*autochk_widgets
;
1584 GtkWidget
*optmenu
, *optmenu2
;
1585 GtkListStore
*menu
, *menu2
;
1587 GtkWidget
*recvatgetall_checkbtn
;
1589 GtkWidget
*frame
, *frame2
;
1590 GtkWidget
*maxarticle_label
;
1591 GtkWidget
*maxarticle_spinbtn
;
1592 GtkAdjustment
*maxarticle_spinbtn_adj
;
1594 vbox1
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING
);
1595 gtk_widget_show (vbox1
);
1596 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), VBOX_BORDER
);
1598 local_vbox
= gtkut_get_options_frame(vbox1
, &local_frame
, _("Local"));
1600 local_hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
1601 gtk_widget_show (local_hbox
);
1602 gtk_box_pack_start (GTK_BOX (local_vbox
), local_hbox
, TRUE
, TRUE
, 0);
1604 local_inbox_label
= gtk_label_new (_("Default Inbox"));
1605 gtk_widget_show (local_inbox_label
);
1606 gtk_box_pack_start (GTK_BOX (local_hbox
), local_inbox_label
, FALSE
, FALSE
, 0);
1608 local_inbox_entry
= gtk_entry_new ();
1609 gtk_widget_show (local_inbox_entry
);
1610 CLAWS_SET_TIP(local_inbox_entry
,
1611 _("Unfiltered messages will be stored in this folder"));
1612 gtk_box_pack_start (GTK_BOX (local_hbox
), local_inbox_entry
, TRUE
, TRUE
, 0);
1614 local_inbox_btn
= gtkut_get_browse_file_btn(_("Bro_wse"));
1615 gtk_widget_show (local_inbox_btn
);
1616 CLAWS_SET_TIP(local_inbox_btn
,
1617 _("Unfiltered messages will be stored in this folder"));
1618 gtk_box_pack_start (GTK_BOX (local_hbox
), local_inbox_btn
, FALSE
, FALSE
, 0);
1619 g_signal_connect (G_OBJECT (local_inbox_btn
), "clicked",
1620 G_CALLBACK (prefs_account_select_folder_cb
),
1623 vbox2
= gtkut_get_options_frame(vbox1
, &frame1
, _("POP"));
1625 PACK_CHECK_BUTTON (vbox2
, pop_auth_checkbtn
,
1626 _("Authenticate before POP connection"));
1628 //vbox5 = gtk_vbox_new (FALSE, 0);
1629 vbox5
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 8);
1630 gtk_widget_show (vbox5
);
1631 gtk_box_pack_start (GTK_BOX (vbox2
), vbox5
, FALSE
, FALSE
, 0);
1633 hbox3
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
1634 gtk_widget_show (hbox3
);
1635 gtk_box_pack_start (GTK_BOX (vbox5
), hbox3
, FALSE
, FALSE
, 0);
1637 hbox_spc
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1638 gtk_widget_show (hbox_spc
);
1639 gtk_box_pack_start (GTK_BOX (hbox3
), hbox_spc
, FALSE
, FALSE
, 0);
1640 gtk_widget_set_size_request (hbox_spc
, 12, -1);
1642 label
= gtk_label_new (_("Authentication method"));
1643 gtk_widget_show (label
);
1644 gtk_box_pack_start (GTK_BOX (hbox3
), label
, FALSE
, FALSE
, 0);
1646 optmenu2
= gtkut_sc_combobox_create(NULL
, FALSE
);
1647 menu2
= GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu2
)));
1648 gtk_widget_show (optmenu2
);
1649 gtk_box_pack_start (GTK_BOX (hbox3
), optmenu2
, FALSE
, FALSE
, 0);
1651 COMBOBOX_ADD (menu2
, _("Select"), 0);
1652 COMBOBOX_ADD (menu2
, NULL
, 0);
1653 COMBOBOX_ADD (menu2
, "APOP", POPAUTH_APOP
);
1654 COMBOBOX_ADD (menu2
, "OAuth2", POPAUTH_OAUTH2
);
1656 gtk_list_store_set(menu2
, &iter
, COMBOBOX_SENS
, FALSE
, -1);
1659 SET_TOGGLE_SENSITIVITY (pop_auth_checkbtn
, vbox5
);
1661 PACK_CHECK_BUTTON (vbox2
, rmmail_checkbtn
,
1662 _("Remove messages on server when received"));
1664 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
1665 gtk_widget_show (hbox1
);
1666 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 0);
1668 hbox_spc
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1669 gtk_widget_show (hbox_spc
);
1670 gtk_box_pack_start (GTK_BOX (hbox1
), hbox_spc
, FALSE
, FALSE
, 0);
1671 gtk_widget_set_size_request (hbox_spc
, 12, -1);
1673 leave_time_label
= gtk_label_new (_("Remove after"));
1674 gtk_widget_show (leave_time_label
);
1675 gtk_box_pack_start (GTK_BOX (hbox1
), leave_time_label
, FALSE
, FALSE
, 0);
1677 leave_time_spinbtn
= gtk_spin_button_new_with_range(0, 365, 1);
1678 gtk_widget_show (leave_time_spinbtn
);
1679 CLAWS_SET_TIP(leave_time_spinbtn
,
1680 _("0 days and 0 hours : remove immediately"));
1681 gtk_box_pack_start (GTK_BOX (hbox1
), leave_time_spinbtn
, FALSE
, FALSE
, 0);
1683 leave_time_label
= gtk_label_new (_("days"));
1684 gtk_widget_show (leave_time_label
);
1685 gtk_box_pack_start (GTK_BOX (hbox1
), leave_time_label
, FALSE
, FALSE
, 0);
1687 leave_hour_spinbtn
= gtk_spin_button_new_with_range(0, 23, 1);
1688 gtk_widget_show (leave_hour_spinbtn
);
1689 CLAWS_SET_TIP(leave_hour_spinbtn
,
1690 _("0 days and 0 hours : remove immediately"));
1691 gtk_box_pack_start (GTK_BOX (hbox1
), leave_hour_spinbtn
, FALSE
, FALSE
, 0);
1693 leave_hour_label
= gtk_label_new (_("hours"));
1694 gtk_widget_show (leave_hour_label
);
1695 gtk_box_pack_start (GTK_BOX (hbox1
), leave_hour_label
, FALSE
, FALSE
, 0);
1697 SET_TOGGLE_SENSITIVITY (rmmail_checkbtn
, hbox1
);
1699 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
1700 gtk_widget_show (hbox1
);
1701 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 0);
1703 PACK_CHECK_BUTTON (hbox1
, size_limit_checkbtn
, _("Receive size limit"));
1705 CLAWS_SET_TIP(size_limit_checkbtn
,
1706 _("Messages over this limit will be partially retrieved. "
1707 "When selecting them you will be able to download them fully "
1708 "or delete them."));
1710 size_limit_spinbtn
= gtk_spin_button_new_with_range(0, 100000, 1);
1711 gtk_widget_show (size_limit_spinbtn
);
1712 gtk_box_pack_start (GTK_BOX (hbox1
), size_limit_spinbtn
, FALSE
, FALSE
, 0);
1714 label
= gtk_label_new (_("KiB"));
1715 gtk_widget_show (label
);
1716 gtk_box_pack_start (GTK_BOX (hbox1
), label
, FALSE
, FALSE
, 0);
1718 SET_TOGGLE_SENSITIVITY (size_limit_checkbtn
, size_limit_spinbtn
);
1720 PACK_SPACER(vbox2
, vbox3
, VSPACING_NARROW_2
);
1722 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
1723 gtk_widget_show (hbox1
);
1724 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, TRUE
, TRUE
, 0);
1726 inbox_label
= gtk_label_new (_("Default Inbox"));
1727 gtk_widget_show (inbox_label
);
1728 gtk_box_pack_start (GTK_BOX (hbox1
), inbox_label
, FALSE
, FALSE
, 0);
1730 inbox_entry
= gtk_entry_new ();
1731 gtk_widget_show (inbox_entry
);
1732 CLAWS_SET_TIP(inbox_entry
,
1733 _("Unfiltered messages will be stored in this folder"));
1734 gtk_box_pack_start (GTK_BOX (hbox1
), inbox_entry
, TRUE
, TRUE
, 0);
1736 inbox_btn
= gtkut_get_browse_file_btn(_("Bro_wse"));
1737 gtk_widget_show (inbox_btn
);
1738 CLAWS_SET_TIP(inbox_btn
,
1739 _("Unfiltered messages will be stored in this folder"));
1740 gtk_box_pack_start (GTK_BOX (hbox1
), inbox_btn
, FALSE
, FALSE
, 0);
1741 g_signal_connect (G_OBJECT (inbox_btn
), "clicked",
1742 G_CALLBACK (prefs_account_select_folder_cb
),
1745 vbox2
= gtkut_get_options_frame(vbox1
, &frame2
, _("NNTP"));
1747 hbox2
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
1748 gtk_widget_show (hbox2
);
1749 gtk_box_pack_start (GTK_BOX (vbox2
), hbox2
, FALSE
, FALSE
, 0);
1751 maxarticle_label
= gtk_label_new
1752 (_("Maximum number of articles to download"));
1753 gtk_widget_show (maxarticle_label
);
1754 gtk_box_pack_start (GTK_BOX (hbox2
), maxarticle_label
, FALSE
, FALSE
, 0);
1756 maxarticle_spinbtn_adj
=
1757 GTK_ADJUSTMENT(gtk_adjustment_new (300, 0, 10000, 10, 100, 0));
1758 maxarticle_spinbtn
= gtk_spin_button_new
1759 (GTK_ADJUSTMENT (maxarticle_spinbtn_adj
), 10, 0);
1760 gtk_widget_show (maxarticle_spinbtn
);
1761 CLAWS_SET_TIP(maxarticle_spinbtn
,
1762 _("unlimited if 0 is specified"));
1763 gtk_box_pack_start (GTK_BOX (hbox2
), maxarticle_spinbtn
,
1765 gtk_widget_set_size_request (maxarticle_spinbtn
, 64, -1);
1766 gtk_spin_button_set_numeric
1767 (GTK_SPIN_BUTTON (maxarticle_spinbtn
), TRUE
);
1769 vbox2
= gtkut_get_options_frame(vbox1
, &imap_frame
, _("IMAP"));
1771 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
1772 gtk_widget_show (hbox1
);
1773 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 0);
1775 label
= gtk_label_new (_("Authentication method"));
1776 gtk_widget_show (label
);
1777 gtk_box_pack_start (GTK_BOX (hbox1
), label
, FALSE
, FALSE
, 0);
1780 optmenu
= gtkut_sc_combobox_create(NULL
, FALSE
);
1781 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu
)));
1782 gtk_widget_show (optmenu
);
1783 gtk_box_pack_start (GTK_BOX (hbox1
), optmenu
, FALSE
, FALSE
, 0);
1785 COMBOBOX_ADD (menu
, _("Automatic"), 0);
1786 COMBOBOX_ADD (menu
, NULL
, 0);
1787 COMBOBOX_ADD (menu
, _("Plain text"), IMAP_AUTH_PLAINTEXT
);
1788 COMBOBOX_ADD (menu
, "CRAM-MD5", IMAP_AUTH_CRAM_MD5
);
1789 COMBOBOX_ADD (menu
, "ANONYMOUS", IMAP_AUTH_ANON
);
1790 COMBOBOX_ADD (menu
, "GSSAPI", IMAP_AUTH_GSSAPI
);
1791 COMBOBOX_ADD (menu
, "DIGEST-MD5", IMAP_AUTH_DIGEST_MD5
);
1792 COMBOBOX_ADD (menu
, "SCRAM-SHA-1", IMAP_AUTH_SCRAM_SHA1
);
1793 COMBOBOX_ADD (menu
, "PLAIN", IMAP_AUTH_PLAIN
);
1794 COMBOBOX_ADD (menu
, "LOGIN", IMAP_AUTH_LOGIN
);
1795 COMBOBOX_ADD (menu
, "OAUTH2", IMAP_AUTH_OAUTH2
);
1797 gtk_list_store_set(menu
, &iter
, COMBOBOX_SENS
, FALSE
, -1);
1800 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
1801 gtk_widget_show (hbox1
);
1802 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 4);
1804 imapdir_label
= gtk_label_new (_("IMAP server directory"));
1805 gtk_widget_show (imapdir_label
);
1806 gtk_box_pack_start (GTK_BOX (hbox1
), imapdir_label
, FALSE
, FALSE
, 0);
1808 imapdir_label
= gtk_label_new(_("(usually empty)"));
1809 gtk_widget_show (imapdir_label
);
1810 gtkut_widget_set_small_font_size (imapdir_label
);
1811 gtk_box_pack_start (GTK_BOX (hbox1
), imapdir_label
, FALSE
, FALSE
, 0);
1813 imapdir_entry
= gtk_entry_new();
1814 gtk_widget_show (imapdir_entry
);
1815 gtk_box_pack_start (GTK_BOX (hbox1
), imapdir_entry
, FALSE
, FALSE
, 0);
1817 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
1818 gtk_widget_show (hbox1
);
1819 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 4);
1821 PACK_CHECK_BUTTON (hbox1
, subsonly_checkbtn
,
1822 _("Show subscribed folders only"));
1824 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
1825 gtk_widget_show (hbox1
);
1826 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 4);
1828 PACK_CHECK_BUTTON (hbox1
, low_bandwidth_checkbtn
,
1829 _("Bandwidth-efficient mode (prevents retrieving remote tags)"));
1830 CLAWS_SET_TIP(low_bandwidth_checkbtn
,
1831 _("This mode uses less bandwidth, but can be slower with some servers."));
1833 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
1834 gtk_widget_show (hbox1
);
1835 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 4);
1838 vbox4
= gtkut_get_options_frame(vbox1
, &frame
, _("Automatic checking"));
1840 PACK_CHECK_BUTTON(vbox4
, autochk_use_default_checkbtn
,
1841 _("Use global settings"));
1843 hbox2
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
1844 gtk_box_pack_start(GTK_BOX(vbox4
), hbox2
, FALSE
, FALSE
, 0);
1846 PACK_CHECK_BUTTON(hbox2
, autochk_checkbtn
,
1847 _("Check for new mail every"));
1849 adj
= gtk_adjustment_new(5, 0, 99, 1, 10, 0);
1850 autochk_hour_spinbtn
= gtk_spin_button_new(GTK_ADJUSTMENT(adj
), 1, 0);
1851 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(autochk_hour_spinbtn
), TRUE
);
1852 gtk_box_pack_start(GTK_BOX(hbox2
), autochk_hour_spinbtn
, FALSE
, FALSE
, 0);
1853 autochk_hour_label
= gtk_label_new(_("hours"));
1854 gtk_box_pack_start(GTK_BOX(hbox2
), autochk_hour_label
, FALSE
, FALSE
, 0);
1856 adj
= gtk_adjustment_new(5, 0, 99, 1, 10, 0);
1857 autochk_min_spinbtn
= gtk_spin_button_new(GTK_ADJUSTMENT(adj
), 1, 0);
1858 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(autochk_min_spinbtn
), TRUE
);
1859 gtk_box_pack_start(GTK_BOX(hbox2
), autochk_min_spinbtn
, FALSE
, FALSE
, 0);
1860 autochk_min_label
= gtk_label_new(_("minutes"));
1861 gtk_box_pack_start(GTK_BOX(hbox2
), autochk_min_label
, FALSE
, FALSE
, 0);
1863 adj
= gtk_adjustment_new(5, 0, 99, 1, 10, 0);
1864 autochk_sec_spinbtn
= gtk_spin_button_new(GTK_ADJUSTMENT(adj
), 1, 0);
1865 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(autochk_sec_spinbtn
), TRUE
);
1866 gtk_box_pack_start(GTK_BOX(hbox2
), autochk_sec_spinbtn
, FALSE
, FALSE
, 0);
1867 autochk_sec_label
= gtk_label_new(_("seconds"));
1868 gtk_box_pack_start(GTK_BOX(hbox2
), autochk_sec_label
, FALSE
, FALSE
, 0);
1870 autochk_widgets
= g_new0(struct AutocheckWidgets
, 1);
1871 autochk_widgets
->autochk_hour_spinbtn
= autochk_hour_spinbtn
;
1872 autochk_widgets
->autochk_min_spinbtn
= autochk_min_spinbtn
;
1873 autochk_widgets
->autochk_sec_spinbtn
= autochk_sec_spinbtn
;
1875 gtk_widget_show_all(vbox4
);
1877 SET_TOGGLE_SENSITIVITY_REVERSE(autochk_use_default_checkbtn
, hbox2
);
1878 SET_TOGGLE_SENSITIVITY(autochk_checkbtn
, autochk_hour_spinbtn
);
1879 SET_TOGGLE_SENSITIVITY(autochk_checkbtn
, autochk_min_spinbtn
);
1880 SET_TOGGLE_SENSITIVITY(autochk_checkbtn
, autochk_sec_spinbtn
);
1881 SET_TOGGLE_SENSITIVITY(autochk_checkbtn
, autochk_hour_label
);
1882 SET_TOGGLE_SENSITIVITY(autochk_checkbtn
, autochk_min_label
);
1883 SET_TOGGLE_SENSITIVITY(autochk_checkbtn
, autochk_sec_label
);
1885 PACK_CHECK_BUTTON (vbox1
, filter_on_recv_checkbtn
,
1886 _("Filter messages on receiving"));
1888 g_signal_connect(G_OBJECT(filter_on_recv_checkbtn
), "toggled",
1889 G_CALLBACK(prefs_account_filter_on_recv_toggled
),
1891 g_signal_connect(G_OBJECT(autochk_hour_spinbtn
), "value-changed",
1892 G_CALLBACK(prefs_account_receive_itv_spinbutton_value_changed_cb
),
1894 g_signal_connect(G_OBJECT(autochk_min_spinbtn
), "value-changed",
1895 G_CALLBACK(prefs_account_receive_itv_spinbutton_value_changed_cb
),
1897 g_signal_connect(G_OBJECT(autochk_sec_spinbtn
), "value-changed",
1898 G_CALLBACK(prefs_account_receive_itv_spinbutton_value_changed_cb
),
1901 PACK_CHECK_BUTTON (vbox1
, filterhook_on_recv_checkbtn
,
1902 _("Allow filtering using plugins on receiving"));
1905 (vbox1
, recvatgetall_checkbtn
,
1906 _("'Get Mail' checks for new messages on this account"));
1908 page
->pop3_frame
= frame1
;
1909 page
->pop_auth_checkbtn
= pop_auth_checkbtn
;
1910 page
->pop_auth_type_optmenu
= optmenu2
;
1911 page
->rmmail_checkbtn
= rmmail_checkbtn
;
1912 page
->leave_time_spinbtn
= leave_time_spinbtn
;
1913 page
->leave_hour_spinbtn
= leave_hour_spinbtn
;
1914 page
->size_limit_checkbtn
= size_limit_checkbtn
;
1915 page
->size_limit_spinbtn
= size_limit_spinbtn
;
1916 page
->filter_on_recv_checkbtn
= filter_on_recv_checkbtn
;
1917 page
->filterhook_on_recv_checkbtn
= filterhook_on_recv_checkbtn
;
1918 page
->inbox_label
= inbox_label
;
1919 page
->inbox_entry
= inbox_entry
;
1920 page
->inbox_btn
= inbox_btn
;
1922 page
->autochk_frame
= frame
;
1924 page
->imap_frame
= imap_frame
;
1925 page
->imap_auth_type_optmenu
= optmenu
;
1927 page
->imapdir_label
= imapdir_label
;
1928 page
->imapdir_entry
= imapdir_entry
;
1929 page
->subsonly_checkbtn
= subsonly_checkbtn
;
1930 page
->low_bandwidth_checkbtn
= low_bandwidth_checkbtn
;
1931 page
->local_frame
= local_frame
;
1932 page
->local_inbox_label
= local_inbox_label
;
1933 page
->local_inbox_entry
= local_inbox_entry
;
1934 page
->local_inbox_btn
= local_inbox_btn
;
1936 page
->recvatgetall_checkbtn
= recvatgetall_checkbtn
;
1938 page
->frame_maxarticle
= frame2
;
1939 page
->maxarticle_spinbtn
= maxarticle_spinbtn
;
1940 page
->maxarticle_spinbtn_adj
= maxarticle_spinbtn_adj
;
1942 page
->autochk_checkbtn
= autochk_checkbtn
;
1943 page
->autochk_widgets
= autochk_widgets
;
1944 page
->autochk_use_default_checkbtn
= autochk_use_default_checkbtn
;
1946 tmp_ac_prefs
= *ac_prefs
;
1949 prefs_set_dialog_to_default(receive_param
);
1951 prefs_set_dialog(receive_param
);
1955 page
->page
.widget
= vbox1
;
1958 static void send_create_widget_func(PrefsPage
* _page
,
1962 SendPage
*page
= (SendPage
*) _page
;
1963 PrefsAccount
*ac_prefs
= (PrefsAccount
*) data
;
1968 GtkWidget
*msgid_checkbtn
;
1969 GtkWidget
*xmailer_checkbtn
;
1971 GtkWidget
*customhdr_checkbtn
;
1972 GtkWidget
*customhdr_edit_btn
;
1973 GtkWidget
*checkbtn_msgid_with_addr
;
1975 GtkWidget
*smtp_auth_checkbtn
;
1976 GtkWidget
*showpwd_checkbtn
;
1981 GtkWidget
*hbox_spc
;
1983 GtkWidget
*smtp_uid_entry
;
1984 GtkWidget
*smtp_pass_entry
;
1985 GtkWidget
*vbox_spc
;
1986 GtkWidget
*pop_bfr_smtp_checkbtn
;
1987 GtkWidget
*pop_bfr_smtp_tm_spinbtn
;
1988 GtkWidget
*pop_auth_timeout_lbl
;
1989 GtkWidget
*pop_auth_minutes_lbl
;
1992 vbox1
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING
);
1993 gtk_widget_show (vbox1
);
1994 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), VBOX_BORDER
);
1996 vbox2
= gtkut_get_options_frame(vbox1
, &frame
, _("Header"));
1998 PACK_CHECK_BUTTON (vbox2
, msgid_checkbtn
, _("Generate Message-ID"));
2000 PACK_CHECK_BUTTON (vbox2
, checkbtn_msgid_with_addr
,
2001 _("Send account mail address in Message-ID"));
2003 PACK_CHECK_BUTTON (vbox2
, xmailer_checkbtn
,
2004 _("Add user agent header"));
2006 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 12);
2007 gtk_widget_show (hbox
);
2008 gtk_box_pack_start (GTK_BOX (vbox2
), hbox
, FALSE
, FALSE
, 0);
2010 PACK_CHECK_BUTTON (hbox
, customhdr_checkbtn
,
2011 _("Add user-defined header"));
2013 customhdr_edit_btn
= gtk_button_new_with_mnemonic("_Edit");
2014 gtk_widget_show (customhdr_edit_btn
);
2015 gtk_box_pack_start (GTK_BOX (hbox
), customhdr_edit_btn
,
2017 g_signal_connect (G_OBJECT (customhdr_edit_btn
), "clicked",
2018 G_CALLBACK (prefs_account_edit_custom_header
),
2021 SET_TOGGLE_SENSITIVITY (customhdr_checkbtn
, customhdr_edit_btn
);
2023 vbox3
= gtkut_get_options_frame(vbox1
, &frame
, _("Authentication"));
2025 PACK_CHECK_BUTTON (vbox3
, smtp_auth_checkbtn
,
2026 _("SMTP Authentication (SMTP AUTH)"));
2028 vbox4
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 0);
2029 gtk_widget_show (vbox4
);
2030 gtk_box_pack_start (GTK_BOX (vbox3
), vbox4
, FALSE
, FALSE
, 0);
2032 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
2033 gtk_widget_show (hbox
);
2034 gtk_box_pack_start (GTK_BOX (vbox4
), hbox
, FALSE
, FALSE
, 0);
2036 hbox_spc
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
2037 gtk_widget_show (hbox_spc
);
2038 gtk_box_pack_start (GTK_BOX (hbox
), hbox_spc
, FALSE
, FALSE
, 0);
2039 gtk_widget_set_size_request (hbox_spc
, 12, -1);
2041 label
= gtk_label_new (_("Authentication method"));
2042 gtk_widget_show (label
);
2043 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2045 optmenu
= gtkut_sc_combobox_create(NULL
, FALSE
);
2046 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu
)));
2047 gtk_widget_show (optmenu
);
2048 gtk_box_pack_start (GTK_BOX (hbox
), optmenu
, FALSE
, FALSE
, 0);
2050 COMBOBOX_ADD (menu
, _("Automatic"), 0);
2051 COMBOBOX_ADD (menu
, NULL
, 0);
2052 COMBOBOX_ADD (menu
, "PLAIN", SMTPAUTH_PLAIN
);
2053 COMBOBOX_ADD (menu
, "LOGIN", SMTPAUTH_LOGIN
);
2054 COMBOBOX_ADD (menu
, "CRAM-MD5", SMTPAUTH_CRAM_MD5
);
2055 COMBOBOX_ADD (menu
, "OAUTH2", SMTPAUTH_OAUTH2
);
2057 gtk_list_store_set(menu
, &iter
, COMBOBOX_SENS
, FALSE
, -1);
2059 COMBOBOX_ADD (menu
, "DIGEST-MD5", SMTPAUTH_DIGEST_MD5
);
2060 gtk_list_store_set(menu
, &iter
, COMBOBOX_SENS
, FALSE
, -1);
2062 PACK_SPACER(vbox4
, vbox_spc
, VSPACING_NARROW_2
);
2064 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
2065 gtk_widget_show (hbox
);
2066 gtk_box_pack_start (GTK_BOX (vbox4
), hbox
, FALSE
, FALSE
, 0);
2068 hbox_spc
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
2069 gtk_widget_show (hbox_spc
);
2070 gtk_box_pack_start (GTK_BOX (hbox
), hbox_spc
, FALSE
, FALSE
, 0);
2071 gtk_widget_set_size_request (hbox_spc
, 12, -1);
2073 label
= gtk_label_new (_("User ID"));
2074 gtk_widget_show (label
);
2075 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2077 smtp_uid_entry
= gtk_entry_new ();
2078 gtk_widget_show (smtp_uid_entry
);
2079 gtk_widget_set_size_request (smtp_uid_entry
, DEFAULT_ENTRY_WIDTH
, -1);
2080 gtk_box_pack_start (GTK_BOX (hbox
), smtp_uid_entry
, TRUE
, TRUE
, 0);
2081 g_signal_connect(G_OBJECT(smtp_uid_entry
), "changed",
2082 G_CALLBACK(prefs_account_entry_changed_newline_check_cb
),
2083 GINT_TO_POINTER(ac_prefs
->protocol
));
2086 PACK_SPACER(vbox4
, vbox_spc
, VSPACING_NARROW_2
);
2087 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
2088 gtk_widget_show (hbox
);
2089 gtk_box_pack_start (GTK_BOX (vbox4
), hbox
, FALSE
, FALSE
, 0);
2091 hbox_spc
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
2092 gtk_widget_show (hbox_spc
);
2093 gtk_box_pack_start (GTK_BOX (hbox
), hbox_spc
, FALSE
, FALSE
, 0);
2094 gtk_widget_set_size_request (hbox_spc
, 12, -1);
2096 label
= gtk_label_new (_("Password"));
2097 gtk_widget_show (label
);
2098 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2100 smtp_pass_entry
= gtk_entry_new ();
2101 gtk_widget_show (smtp_pass_entry
);
2102 gtk_widget_set_size_request (smtp_pass_entry
, DEFAULT_ENTRY_WIDTH
, -1);
2103 gtk_box_pack_start (GTK_BOX (hbox
), smtp_pass_entry
, TRUE
, TRUE
, 0);
2104 gtk_entry_set_visibility (GTK_ENTRY (smtp_pass_entry
), FALSE
);
2105 g_signal_connect(G_OBJECT(smtp_pass_entry
), "changed",
2106 G_CALLBACK(prefs_account_entry_changed_newline_check_cb
),
2107 GINT_TO_POINTER(ac_prefs
->protocol
));
2109 showpwd_checkbtn
= gtk_check_button_new_with_label (_("Show password"));
2110 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn
), FALSE
);
2111 gtk_widget_show(showpwd_checkbtn
);
2112 gtk_box_pack_start(GTK_BOX (hbox
), showpwd_checkbtn
, FALSE
, FALSE
, 0);
2113 g_signal_connect(G_OBJECT(showpwd_checkbtn
), "toggled",
2114 G_CALLBACK(prefs_account_showpwd_checkbtn_toggled
), smtp_pass_entry
);
2116 PACK_SPACER(vbox4
, vbox_spc
, VSPACING_NARROW_2
);
2118 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
2119 gtk_widget_show (hbox
);
2120 gtk_box_pack_start (GTK_BOX (vbox4
), hbox
, FALSE
, FALSE
, 0);
2122 hbox_spc
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
2123 gtk_widget_show (hbox_spc
);
2124 gtk_box_pack_start (GTK_BOX (hbox
), hbox_spc
, FALSE
, FALSE
, 0);
2125 gtk_widget_set_size_request (hbox_spc
, 12, -1);
2127 label
= gtk_label_new
2128 (_("If you leave these entries empty, the same "
2129 "user ID and password as receiving will be used."));
2130 gtk_widget_show (label
);
2131 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2132 gtk_label_set_justify (GTK_LABEL (label
), GTK_JUSTIFY_LEFT
);
2133 gtk_label_set_line_wrap (GTK_LABEL (label
), TRUE
);
2134 gtkut_widget_set_small_font_size (label
);
2136 SET_TOGGLE_SENSITIVITY (smtp_auth_checkbtn
, vbox4
);
2138 PACK_CHECK_BUTTON (vbox3
, pop_bfr_smtp_checkbtn
,
2139 _("Authenticate with POP before sending"));
2141 g_signal_connect (G_OBJECT (pop_bfr_smtp_checkbtn
), "clicked",
2142 G_CALLBACK (pop_bfr_smtp_tm_set_sens
),
2145 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
2146 gtk_widget_show (hbox
);
2147 gtk_box_pack_start (GTK_BOX (vbox3
), hbox
, FALSE
, FALSE
, 0);
2149 hbox_spc
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
2150 gtk_widget_show (hbox_spc
);
2151 gtk_box_pack_start (GTK_BOX (hbox
), hbox_spc
, FALSE
, FALSE
, 0);
2152 gtk_widget_set_size_request (hbox_spc
, 12, -1);
2154 pop_auth_timeout_lbl
= gtk_label_new(_("POP authentication timeout"));
2155 gtk_widget_show (pop_auth_timeout_lbl
);
2156 gtk_box_pack_start (GTK_BOX (hbox
), pop_auth_timeout_lbl
, FALSE
, FALSE
, 0);
2158 pop_bfr_smtp_tm_spinbtn
= gtk_spin_button_new_with_range(0, 1440, 1);
2159 gtk_widget_show (pop_bfr_smtp_tm_spinbtn
);
2160 gtk_box_pack_start (GTK_BOX (hbox
), pop_bfr_smtp_tm_spinbtn
, FALSE
, FALSE
, 0);
2162 pop_auth_minutes_lbl
= gtk_label_new(_("minutes"));
2163 gtk_widget_show (pop_auth_minutes_lbl
);
2164 gtk_box_pack_start (GTK_BOX (hbox
), pop_auth_minutes_lbl
, FALSE
, FALSE
, 0);
2166 page
->msgid_checkbtn
= msgid_checkbtn
;
2167 page
->xmailer_checkbtn
= xmailer_checkbtn
;
2168 page
->customhdr_checkbtn
= customhdr_checkbtn
;
2169 page
->msgid_with_addr_checkbtn
= checkbtn_msgid_with_addr
;
2171 page
->smtp_auth_checkbtn
= smtp_auth_checkbtn
;
2172 page
->smtp_auth_type_optmenu
= optmenu
;
2173 page
->smtp_uid_entry
= smtp_uid_entry
;
2174 page
->smtp_pass_entry
= smtp_pass_entry
;
2175 page
->pop_bfr_smtp_checkbtn
= pop_bfr_smtp_checkbtn
;
2176 page
->pop_bfr_smtp_tm_spinbtn
= pop_bfr_smtp_tm_spinbtn
;
2177 page
->pop_auth_timeout_lbl
= pop_auth_timeout_lbl
;
2178 page
->pop_auth_minutes_lbl
= pop_auth_minutes_lbl
;
2180 tmp_ac_prefs
= *ac_prefs
;
2183 prefs_set_dialog_to_default(send_param
);
2185 prefs_set_dialog(send_param
);
2187 /* Passwords are handled outside of PrefParams. */
2188 buf
= passwd_store_get_account(ac_prefs
->account_id
,
2190 gtk_entry_set_text(GTK_ENTRY(page
->smtp_pass_entry
), buf
!= NULL
? buf
: "");
2192 memset(buf
, 0, strlen(buf
));
2197 pop_bfr_smtp_tm_set_sens (NULL
, NULL
);
2201 page
->page
.widget
= vbox1
;
2205 static void oauth2_create_widget_func(PrefsPage
* _page
,
2209 Oauth2Page
*page
= (Oauth2Page
*) _page
;
2210 PrefsAccount
*ac_prefs
= (PrefsAccount
*) data
;
2212 GtkWidget
*vbox1
, *vbox2
, *vbox3
;
2214 GtkWidget
*hbox_spc
;
2215 GtkWidget
*oauth2_authorise_btn
;
2216 GtkWidget
*auth_vbox
, *auth_frame
;
2218 GtkWidget
*oauth2_authcode_entry
;
2219 GtkWidget
*oauth2_auth_optmenu
;
2220 GtkWidget
*oauth2_link_button
;
2221 GtkWidget
*oauth2_link_copy_button
;
2222 GtkWidget
*oauth2_client_id_entry
;
2223 GtkWidget
*oauth2_client_secret_entry
;
2228 struct BasicProtocol
*protocol_optmenu
;
2230 vbox1
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING
);
2231 gtk_widget_show (vbox1
);
2232 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), VBOX_BORDER
);
2234 auth_vbox
= gtkut_get_options_frame(vbox1
, &auth_frame
,
2235 _("Authorization"));
2237 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
2238 gtk_widget_show (hbox
);
2239 gtk_box_pack_start (GTK_BOX (auth_vbox
), hbox
, FALSE
, FALSE
, 0);
2241 hbox_spc
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
2242 gtk_widget_show (hbox_spc
);
2243 gtk_widget_set_size_request (hbox_spc
, 12, -1);
2244 gtk_box_pack_start (GTK_BOX (hbox
), hbox_spc
, FALSE
, FALSE
, 0);
2246 /* Email service provider */
2248 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
2249 gtk_widget_show (hbox
);
2250 gtk_box_pack_start (GTK_BOX (auth_vbox
), hbox
, FALSE
, FALSE
, 0);
2252 label
= gtk_label_new (_("Select OAuth2 Email Service Provider"));
2253 gtk_widget_show (label
);
2254 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2256 oauth2_auth_optmenu
= gtkut_sc_combobox_create(NULL
, FALSE
);
2257 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(oauth2_auth_optmenu
)));
2258 gtk_widget_show (oauth2_auth_optmenu
);
2259 gtk_box_pack_start (GTK_BOX (hbox
), oauth2_auth_optmenu
, FALSE
, FALSE
, 0);
2261 COMBOBOX_ADD (menu
, _("Select"), NULL
);
2262 COMBOBOX_ADD (menu
, NULL
, 0);
2263 COMBOBOX_ADD (menu
, "Google/Gmail", OAUTH2AUTH_GOOGLE
);
2264 COMBOBOX_ADD (menu
, "MS Outlook", OAUTH2AUTH_OUTLOOK
);
2265 COMBOBOX_ADD (menu
, "MS Exchange", OAUTH2AUTH_EXCHANGE
);
2266 COMBOBOX_ADD (menu
, "Yahoo", OAUTH2AUTH_YAHOO
);
2268 protocol_optmenu
= g_new(struct BasicProtocol
, 1);
2269 protocol_optmenu
->combobox
= oauth2_auth_optmenu
;
2270 protocol_optmenu
->label
= label
;
2271 protocol_optmenu
->descrlabel
= label
;
2273 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
2274 gtk_widget_show (hbox
);
2275 gtk_box_pack_start (GTK_BOX (auth_vbox
), hbox
, FALSE
, FALSE
, 0);
2277 vbox3
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 0);
2278 gtk_widget_show (vbox3
);
2279 gtk_box_pack_start (GTK_BOX (auth_vbox
), vbox3
, FALSE
, FALSE
, 0);
2281 vbox2
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 0);
2282 gtk_widget_show (vbox2
);
2283 gtk_box_pack_start (GTK_BOX (vbox3
), vbox2
, FALSE
, FALSE
, 0);
2285 table1
= gtk_grid_new();
2286 gtk_widget_show (table1
);
2287 gtk_container_add (GTK_CONTAINER (vbox2
), table1
);
2288 gtk_container_set_border_width (GTK_CONTAINER (table1
), 8);
2289 gtk_grid_set_row_spacing(GTK_GRID(table1
), VSPACING_NARROW
);
2290 gtk_grid_set_column_spacing(GTK_GRID(table1
), 8);
2292 label
= gtk_label_new (_("Client ID"));
2293 gtk_widget_show (label
);
2294 gtk_label_set_xalign(GTK_LABEL (label
), 1.0);
2295 gtk_grid_attach(GTK_GRID(table1
), label
, 0, 0, 1, 1);
2297 oauth2_client_id_entry
= gtk_entry_new();
2298 gtk_widget_show (oauth2_client_id_entry
);
2299 gtk_grid_attach(GTK_GRID(table1
), oauth2_client_id_entry
, 1, 0, 1, 1);
2300 gtk_widget_set_hexpand(oauth2_client_id_entry
, TRUE
);
2301 gtk_widget_set_halign(oauth2_client_id_entry
, GTK_ALIGN_FILL
);
2303 label
= gtk_label_new (_("Client secret"));
2304 gtk_widget_show (label
);
2305 gtk_label_set_xalign(GTK_LABEL (label
), 1.0);
2306 gtk_grid_attach(GTK_GRID(table1
), label
, 0, 1, 1, 1);
2308 oauth2_client_secret_entry
= gtk_entry_new ();
2309 gtk_widget_show (oauth2_client_secret_entry
);
2310 gtk_grid_attach(GTK_GRID(table1
), oauth2_client_secret_entry
, 1, 1, 1, 1);
2311 gtk_widget_set_hexpand(oauth2_client_secret_entry
, TRUE
);
2312 gtk_widget_set_halign(oauth2_client_secret_entry
, GTK_ALIGN_FILL
);
2314 hbox_spc
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
2315 gtk_widget_show (hbox_spc
);
2316 gtk_box_pack_start (GTK_BOX (hbox
), hbox_spc
, FALSE
, FALSE
, 0);
2317 //gtk_widget_set_size_request (hbox_spc, 12, -1);
2319 hbox_spc
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
2320 gtk_widget_show (hbox_spc
);
2321 gtk_box_pack_start (GTK_BOX (vbox2
), hbox_spc
, FALSE
, FALSE
, 0);
2322 //gtk_widget_set_size_request (hbox_spc, 12, 10);
2324 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
2325 gtk_widget_show (hbox
);
2326 gtk_box_pack_start (GTK_BOX (vbox3
), hbox
, FALSE
, FALSE
, 0);
2328 label
= gtk_label_new (_("Obtain authorization code"));
2329 gtk_widget_show (label
);
2330 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2332 oauth2_link_button
= gtk_button_new_with_label(_("Open default browser with request"));
2333 g_signal_connect(G_OBJECT(oauth2_link_button
), "clicked", G_CALLBACK(prefs_account_oauth2_copy_url
), NULL
);
2334 gtk_widget_set_sensitive(oauth2_link_button
, TRUE
);
2335 gtk_widget_set_margin_bottom(oauth2_link_button
, 8);
2336 gtk_widget_show (oauth2_link_button
);
2337 gtk_box_pack_start (GTK_BOX (hbox
), oauth2_link_button
, FALSE
, FALSE
, 0);
2339 oauth2_link_copy_button
= gtk_button_new_with_label(_("Copy link"));
2340 g_signal_connect(G_OBJECT(oauth2_link_copy_button
), "clicked", G_CALLBACK(prefs_account_oauth2_copy_url
), NULL
);
2341 gtk_widget_set_sensitive(oauth2_link_copy_button
, TRUE
);
2342 gtk_widget_set_margin_bottom(oauth2_link_copy_button
, 8);
2343 gtk_widget_show (oauth2_link_copy_button
);
2344 gtk_box_pack_start (GTK_BOX (hbox
), oauth2_link_copy_button
, FALSE
, FALSE
, 0);
2346 /* Authorisation code */
2347 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
2348 gtk_widget_show (hbox
);
2349 gtk_box_pack_start (GTK_BOX (vbox3
), hbox
, FALSE
, FALSE
, 0);
2350 //gtk_widget_set_size_request (hbox, -1, 50);
2352 label
= gtk_label_new (_("Authorization code"));
2353 gtk_widget_show (label
);
2354 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2356 oauth2_authcode_entry
= gtk_entry_new ();
2357 gtk_widget_show (oauth2_authcode_entry
);
2358 gtk_widget_set_margin_bottom(oauth2_authcode_entry
, 8);
2359 //gtk_widget_set_size_request (oauth2_authcode_entry, DEFAULT_ENTRY_WIDTH, -1);
2360 gtk_widget_set_tooltip_text(oauth2_authcode_entry
,
2361 _("Paste complete URL from browser or the provided authorization token"));
2362 gtk_box_pack_start (GTK_BOX (hbox
), oauth2_authcode_entry
, TRUE
, TRUE
, 0);
2364 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
2365 gtk_widget_show (hbox
);
2366 gtk_box_pack_start (GTK_BOX (vbox3
), hbox
, FALSE
, FALSE
, 0);
2368 label
= gtk_label_new (_("Complete authorization"));
2369 gtk_widget_show (label
);
2370 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2372 oauth2_authorise_btn
= gtk_button_new_with_label(_("Authorize"));
2373 gtk_box_pack_start(GTK_BOX(hbox
), oauth2_authorise_btn
, FALSE
, FALSE
, 0);
2374 g_signal_connect(G_OBJECT(oauth2_authorise_btn
), "clicked",
2375 G_CALLBACK(prefs_account_oauth2_obtain_tokens
), NULL
);
2376 gtk_widget_show(oauth2_authorise_btn
);
2378 /* Add items to page struct */
2380 page
->oauth2_link_button
= oauth2_link_button
;
2381 page
->oauth2_link_copy_button
= oauth2_link_copy_button
;
2382 page
->oauth2_authcode_entry
= oauth2_authcode_entry
;
2383 page
->oauth2_auth_optmenu
= oauth2_auth_optmenu
;
2384 page
->protocol_optmenu
= (gpointer
)protocol_optmenu
;
2385 page
->oauth2_authorise_btn
= oauth2_authorise_btn
;
2386 page
->oauth2_client_id_entry
= oauth2_client_id_entry
;
2387 page
->oauth2_client_secret_entry
= oauth2_client_secret_entry
;
2389 page
->page
.widget
= vbox1
;
2390 page
->oauth2_sensitive
= vbox3
;
2392 tmp_ac_prefs
= *ac_prefs
;
2394 g_signal_connect(G_OBJECT(oauth2_auth_optmenu
), "changed",
2395 G_CALLBACK(prefs_account_oauth2_set_sensitivity
), NULL
);
2396 g_signal_connect(G_OBJECT(oauth2_authcode_entry
), "changed",
2397 G_CALLBACK(prefs_account_oauth2_set_auth_sensitivity
), NULL
);
2398 prefs_account_oauth2_set_auth_sensitivity();
2401 prefs_set_dialog_to_default(oauth2_param
);
2403 prefs_set_dialog(oauth2_param
);
2405 /* Passwords are handled outside of PrefParams. */
2406 buf
= passwd_store_get_account(ac_prefs
->account_id
,
2407 PWS_ACCOUNT_OAUTH2_AUTH
);
2408 gtk_entry_set_text(GTK_ENTRY(page
->oauth2_authcode_entry
), buf
!= NULL
? buf
: "");
2410 memset(buf
, 0, strlen(buf
));
2416 /* oauth2_encode(OAUTH2info[0][OA2_CLIENT_ID]); */
2421 static void compose_create_widget_func(PrefsPage
* _page
,
2425 ComposePage
*page
= (ComposePage
*) _page
;
2426 PrefsAccount
*ac_prefs
= (PrefsAccount
*) data
;
2429 GtkWidget
*sig_hbox
;
2432 GtkWidget
*frame_sig
;
2433 GtkWidget
*vbox_sig
;
2434 GtkWidget
*label_sigpath
;
2435 GtkWidget
*checkbtn_autosig
;
2436 GtkWidget
*label_sigsep
;
2437 GtkWidget
*entry_sigsep
;
2440 GtkWidget
*autocc_checkbtn
;
2441 GtkWidget
*autocc_entry
;
2442 GtkWidget
*autobcc_checkbtn
;
2443 GtkWidget
*autobcc_entry
;
2444 GtkWidget
*autoreplyto_checkbtn
;
2445 GtkWidget
*autoreplyto_entry
;
2447 GtkWidget
*frame_dict
;
2448 GtkWidget
*table_dict
;
2449 GtkWidget
*checkbtn_enable_default_dictionary
= NULL
;
2450 GtkWidget
*combo_default_dictionary
= NULL
;
2451 GtkWidget
*checkbtn_enable_default_alt_dictionary
= NULL
;
2452 GtkWidget
*combo_default_alt_dictionary
= NULL
;
2455 vbox1
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING
);
2456 gtk_widget_show (vbox1
);
2457 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), VBOX_BORDER
);
2459 vbox_sig
= gtkut_get_options_frame(vbox1
, &frame_sig
, _("Signature"));
2461 PACK_CHECK_BUTTON (vbox_sig
, checkbtn_autosig
,
2462 _("Automatically insert signature"));
2464 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
2465 gtk_widget_show (hbox1
);
2466 gtk_box_pack_start (GTK_BOX (vbox_sig
), hbox1
, TRUE
, TRUE
, 0);
2467 label_sigsep
= gtk_label_new (_("Signature separator"));
2468 gtk_widget_show (label_sigsep
);
2469 gtk_box_pack_start (GTK_BOX (hbox1
), label_sigsep
, FALSE
, FALSE
, 0);
2471 entry_sigsep
= gtk_entry_new ();
2472 gtk_widget_show (entry_sigsep
);
2473 gtk_box_pack_start (GTK_BOX (hbox1
), entry_sigsep
, FALSE
, FALSE
, 0);
2475 gtk_widget_set_size_request (entry_sigsep
, 64, -1);
2477 sig_hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
2478 gtk_widget_show (sig_hbox
);
2479 gtk_box_pack_start (GTK_BOX (vbox_sig
), sig_hbox
, FALSE
, FALSE
, 0);
2481 sigfile_radiobtn
= gtk_radio_button_new_with_label (NULL
, _("File"));
2482 gtk_widget_show (sigfile_radiobtn
);
2483 gtk_box_pack_start (GTK_BOX (sig_hbox
), sigfile_radiobtn
,
2485 g_object_set_data (G_OBJECT (sigfile_radiobtn
),
2487 GINT_TO_POINTER (SIG_FILE
));
2488 g_signal_connect(G_OBJECT(sigfile_radiobtn
), "clicked",
2489 G_CALLBACK(prefs_account_sigfile_radiobtn_cb
), NULL
);
2491 sigcmd_radiobtn
= gtk_radio_button_new_with_label_from_widget
2492 (GTK_RADIO_BUTTON(sigfile_radiobtn
), _("Command output"));
2493 gtk_widget_show (sigcmd_radiobtn
);
2494 gtk_box_pack_start (GTK_BOX (sig_hbox
), sigcmd_radiobtn
,
2496 g_object_set_data (G_OBJECT (sigcmd_radiobtn
),
2498 GINT_TO_POINTER (SIG_COMMAND
));
2499 g_signal_connect(G_OBJECT(sigcmd_radiobtn
), "clicked",
2500 G_CALLBACK(prefs_account_sigcmd_radiobtn_cb
), NULL
);
2502 hbox2
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
2503 gtk_widget_show (hbox2
);
2504 gtk_box_pack_start (GTK_BOX (vbox_sig
), hbox2
, TRUE
, TRUE
, 0);
2505 label_sigpath
= gtk_label_new (_("Signature"));
2506 gtk_widget_show (label_sigpath
);
2507 gtk_box_pack_start (GTK_BOX (hbox2
), label_sigpath
, FALSE
, FALSE
, 0);
2509 entry_sigpath
= gtk_entry_new ();
2510 gtk_widget_show (entry_sigpath
);
2511 gtk_box_pack_start (GTK_BOX (hbox2
), entry_sigpath
, TRUE
, TRUE
, 0);
2513 signature_browse_button
= gtkut_get_browse_file_btn(_("Bro_wse"));
2514 gtk_widget_show (signature_browse_button
);
2515 gtk_box_pack_start (GTK_BOX (hbox2
), signature_browse_button
, FALSE
, FALSE
, 0);
2516 g_signal_connect(G_OBJECT(signature_browse_button
), "clicked",
2517 G_CALLBACK(prefs_account_signature_browse_cb
), NULL
);
2519 signature_edit_button
= gtk_button_new_with_mnemonic("_Edit");
2520 gtk_widget_show (signature_edit_button
);
2521 gtk_box_pack_start (GTK_BOX (hbox2
), signature_edit_button
, FALSE
, FALSE
, 0);
2522 g_signal_connect(G_OBJECT(signature_edit_button
), "clicked",
2523 G_CALLBACK(prefs_account_signature_edit_cb
), entry_sigpath
);
2525 PACK_FRAME (vbox1
, frame
, _("Automatically set the following addresses"));
2527 table
= gtk_grid_new();
2528 gtk_widget_show (table
);
2529 gtk_container_add (GTK_CONTAINER (frame
), table
);
2530 gtk_container_set_border_width (GTK_CONTAINER (table
), 8);
2531 gtk_grid_set_row_spacing(GTK_GRID(table
), VSPACING_NARROW_2
);
2532 gtk_grid_set_column_spacing(GTK_GRID(table
), 8);
2534 autocc_checkbtn
= gtk_check_button_new_with_label (
2535 prefs_common_translated_header_name("Cc:"));
2536 gtk_widget_show (autocc_checkbtn
);
2537 gtk_grid_attach(GTK_GRID(table
), autocc_checkbtn
, 0, 0, 1, 1);
2539 autocc_entry
= gtk_entry_new ();
2540 gtk_widget_show (autocc_entry
);
2541 gtk_grid_attach(GTK_GRID(table
), autocc_entry
, 1, 0, 1, 1);
2542 gtk_widget_set_hexpand(autocc_entry
, TRUE
);
2543 gtk_widget_set_halign(autocc_entry
, GTK_ALIGN_FILL
);
2545 SET_TOGGLE_SENSITIVITY (autocc_checkbtn
, autocc_entry
);
2547 autobcc_checkbtn
= gtk_check_button_new_with_label (
2548 prefs_common_translated_header_name("Bcc:"));
2549 gtk_widget_show (autobcc_checkbtn
);
2550 gtk_grid_attach(GTK_GRID(table
), autobcc_checkbtn
, 0, 1, 1, 1);
2552 autobcc_entry
= gtk_entry_new ();
2553 gtk_widget_show (autobcc_entry
);
2554 gtk_grid_attach(GTK_GRID(table
), autobcc_entry
, 1, 1, 1, 1);
2555 gtk_widget_set_hexpand(autobcc_entry
, TRUE
);
2556 gtk_widget_set_halign(autobcc_entry
, GTK_ALIGN_FILL
);
2558 SET_TOGGLE_SENSITIVITY (autobcc_checkbtn
, autobcc_entry
);
2560 autoreplyto_checkbtn
= gtk_check_button_new_with_label (
2561 prefs_common_translated_header_name("Reply-To:"));
2562 gtk_widget_show (autoreplyto_checkbtn
);
2563 gtk_grid_attach(GTK_GRID(table
), autoreplyto_checkbtn
, 0, 2, 1, 1);
2565 autoreplyto_entry
= gtk_entry_new ();
2566 gtk_widget_show (autoreplyto_entry
);
2567 gtk_grid_attach(GTK_GRID(table
), autoreplyto_entry
, 1, 2, 1, 1);
2568 gtk_widget_set_hexpand(autoreplyto_entry
, TRUE
);
2569 gtk_widget_set_halign(autoreplyto_entry
, GTK_ALIGN_FILL
);
2571 SET_TOGGLE_SENSITIVITY (autoreplyto_checkbtn
, autoreplyto_entry
);
2574 PACK_FRAME (vbox1
, frame_dict
, _("Spell check dictionaries"));
2576 table_dict
= gtk_grid_new();
2577 gtk_widget_show (table_dict
);
2578 gtk_container_add (GTK_CONTAINER (frame_dict
), table_dict
);
2579 gtk_container_set_border_width (GTK_CONTAINER (table_dict
), 8);
2580 gtk_grid_set_row_spacing(GTK_GRID(table_dict
), VSPACING_NARROW_2
);
2581 gtk_grid_set_column_spacing(GTK_GRID(table_dict
), 8);
2583 /* Default dictionary */
2584 checkbtn_enable_default_dictionary
= gtk_check_button_new_with_label(_("Default dictionary"));
2585 gtk_grid_attach(GTK_GRID(table_dict
), checkbtn_enable_default_dictionary
, 0, 0, 1, 1);
2587 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary
),
2588 tmp_ac_prefs
.enable_default_dictionary
);
2590 combo_default_dictionary
= gtkaspell_dictionary_combo_new(TRUE
);
2591 gtk_grid_attach(GTK_GRID(table_dict
), combo_default_dictionary
, 1, 0, 1, 1);
2593 SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary
, combo_default_dictionary
);
2595 /* Default dictionary */
2596 checkbtn_enable_default_alt_dictionary
= gtk_check_button_new_with_label(_("Default alternate dictionary"));
2597 gtk_grid_attach(GTK_GRID(table_dict
), checkbtn_enable_default_alt_dictionary
, 0, 1, 1, 1);
2599 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_alt_dictionary
),
2600 tmp_ac_prefs
.enable_default_alt_dictionary
);
2602 combo_default_alt_dictionary
= gtkaspell_dictionary_combo_new(FALSE
);
2603 gtk_grid_attach(GTK_GRID(table_dict
), combo_default_alt_dictionary
, 1, 1, 1, 1);
2605 SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary
, combo_default_alt_dictionary
);
2607 gtk_widget_show_all(table_dict
);
2610 page
->sigfile_radiobtn
= sigfile_radiobtn
;
2611 page
->entry_sigpath
= entry_sigpath
;
2612 page
->checkbtn_autosig
= checkbtn_autosig
;
2613 page
->entry_sigsep
= entry_sigsep
;
2615 page
->autocc_checkbtn
= autocc_checkbtn
;
2616 page
->autocc_entry
= autocc_entry
;
2617 page
->autobcc_checkbtn
= autobcc_checkbtn
;
2618 page
->autobcc_entry
= autobcc_entry
;
2619 page
->autoreplyto_checkbtn
= autoreplyto_checkbtn
;
2620 page
->autoreplyto_entry
= autoreplyto_entry
;
2622 page
->checkbtn_enable_default_dictionary
= checkbtn_enable_default_dictionary
;
2623 page
->combo_default_dictionary
= combo_default_dictionary
;
2624 page
->checkbtn_enable_default_alt_dictionary
= checkbtn_enable_default_alt_dictionary
;
2625 page
->combo_default_alt_dictionary
= combo_default_alt_dictionary
;
2629 /* reset gtkaspell menus */
2630 if (compose_page
.combo_default_dictionary
!= NULL
) {
2631 gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page
.combo_default_dictionary
),
2632 gtkaspell_dictionary_store_new());
2633 gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page
.combo_default_alt_dictionary
),
2634 gtkaspell_dictionary_store_new_with_refresh(
2639 tmp_ac_prefs
= *ac_prefs
;
2642 prefs_set_dialog_to_default(compose_param
);
2644 prefs_set_dialog(compose_param
);
2648 page
->page
.widget
= vbox1
;
2651 static void templates_create_widget_func(PrefsPage
* _page
,
2655 TemplatesPage
*page
= (TemplatesPage
*) _page
;
2656 PrefsAccount
*ac_prefs
= (PrefsAccount
*) data
;
2659 GtkWidget
*notebook
;
2661 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 0);
2662 gtk_widget_show(vbox
);
2664 notebook
= gtk_notebook_new();
2665 gtk_widget_show(notebook
);
2666 gtk_box_pack_start(GTK_BOX(vbox
), notebook
, TRUE
, TRUE
, 0);
2668 /* compose format */
2669 vbox2
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING
);
2670 gtk_widget_show (vbox2
);
2671 gtk_container_set_border_width (GTK_CONTAINER (vbox2
), VBOX_BORDER
);
2673 quotefmt_create_new_msg_fmt_widgets(
2676 &page
->checkbtn_compose_with_format
,
2678 &page
->compose_subject_format
,
2679 &page
->compose_body_format
,
2681 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
), vbox2
, gtk_label_new(_("Compose")));
2684 vbox2
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING
);
2685 gtk_widget_show (vbox2
);
2686 gtk_container_set_border_width (GTK_CONTAINER (vbox2
), VBOX_BORDER
);
2688 quotefmt_create_reply_fmt_widgets(
2691 &page
->checkbtn_reply_with_format
,
2693 &page
->reply_quotemark
,
2694 &page
->reply_body_format
,
2696 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
), vbox2
, gtk_label_new(_("Reply")));
2698 /* forward format */
2699 vbox2
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING
);
2700 gtk_widget_show (vbox2
);
2701 gtk_container_set_border_width (GTK_CONTAINER (vbox2
), VBOX_BORDER
);
2703 quotefmt_create_forward_fmt_widgets(
2706 &page
->checkbtn_forward_with_format
,
2708 &page
->forward_quotemark
,
2709 &page
->forward_body_format
,
2711 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
), vbox2
, gtk_label_new(_("Forward")));
2713 tmp_ac_prefs
= *ac_prefs
;
2716 prefs_set_dialog_to_default(templates_param
);
2718 prefs_set_dialog(templates_param
);
2722 page
->page
.widget
= vbox
;
2725 static void privacy_create_widget_func(PrefsPage
* _page
,
2729 PrivacyPage
*page
= (PrivacyPage
*) _page
;
2730 PrefsAccount
*ac_prefs
= (PrefsAccount
*) data
;
2736 GtkWidget
*default_privacy_system
;
2738 GtkCellRenderer
*rend
;
2739 GtkWidget
*default_encrypt_checkbtn
;
2740 GtkWidget
*default_encrypt_reply_checkbtn
;
2741 GtkWidget
*default_sign_checkbtn
;
2742 GtkWidget
*default_sign_reply_checkbtn
;
2743 GtkWidget
*save_clear_text_checkbtn
;
2744 GtkWidget
*encrypt_to_self_checkbtn
;
2746 vbox1
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING
);
2747 gtk_widget_show (vbox1
);
2748 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), VBOX_BORDER
);
2750 vbox2
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 0);
2751 gtk_widget_show (vbox2
);
2752 gtk_box_pack_start (GTK_BOX (vbox1
), vbox2
, FALSE
, FALSE
, 0);
2754 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
2755 gtk_widget_show (hbox1
);
2756 gtk_container_add (GTK_CONTAINER(vbox2
), hbox1
);
2758 label
= gtk_label_new(_("Default privacy system"));
2759 gtk_widget_show(label
);
2760 gtk_box_pack_start (GTK_BOX (hbox1
), label
, FALSE
, FALSE
, 0);
2762 /* Can't use gtkut_sc_combobox_create() here, because model for this
2763 * combobox needs an extra string column to store privacy plugin id. */
2764 menu
= gtk_list_store_new(4,
2768 G_TYPE_STRING
); /* This is where we store the privacy plugin id. */
2769 default_privacy_system
= gtk_combo_box_new_with_model(GTK_TREE_MODEL(menu
));
2771 rend
= gtk_cell_renderer_text_new();
2772 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(default_privacy_system
), rend
, TRUE
);
2773 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(default_privacy_system
), rend
,
2774 "text", COMBOBOX_TEXT
,
2775 "sensitive", COMBOBOX_SENS
,
2777 gtk_widget_set_focus_on_click(GTK_WIDGET(default_privacy_system
), FALSE
);
2779 gtk_widget_show (default_privacy_system
);
2780 gtk_box_pack_start (GTK_BOX(hbox1
), default_privacy_system
, FALSE
, TRUE
, 0);
2782 g_signal_connect(G_OBJECT(default_privacy_system
), "changed",
2783 G_CALLBACK(privacy_system_activated
),
2786 PACK_CHECK_BUTTON (vbox2
, default_sign_checkbtn
,
2787 _("Always sign messages"));
2788 PACK_CHECK_BUTTON (vbox2
, default_encrypt_checkbtn
,
2789 _("Always encrypt messages"));
2790 PACK_CHECK_BUTTON (vbox2
, default_sign_reply_checkbtn
,
2791 _("Always sign messages when replying to a "
2793 PACK_CHECK_BUTTON (vbox2
, default_encrypt_reply_checkbtn
,
2794 _("Always encrypt messages when replying to an "
2795 "encrypted message"));
2796 PACK_CHECK_BUTTON (vbox2
, encrypt_to_self_checkbtn
,
2797 _("Encrypt sent messages with your own key in addition to recipient's"));
2798 PACK_CHECK_BUTTON (vbox2
, save_clear_text_checkbtn
,
2799 _("Save sent encrypted messages as clear text"));
2801 SET_TOGGLE_SENSITIVITY_REVERSE(encrypt_to_self_checkbtn
, save_clear_text_checkbtn
);
2802 SET_TOGGLE_SENSITIVITY_REVERSE(save_clear_text_checkbtn
, encrypt_to_self_checkbtn
);
2804 page
->default_privacy_system
= default_privacy_system
;
2805 page
->default_encrypt_checkbtn
= default_encrypt_checkbtn
;
2806 page
->default_encrypt_reply_checkbtn
= default_encrypt_reply_checkbtn
;
2807 page
->default_sign_reply_checkbtn
= default_sign_reply_checkbtn
;
2808 page
->default_sign_checkbtn
= default_sign_checkbtn
;
2809 page
->save_clear_text_checkbtn
= save_clear_text_checkbtn
;
2810 page
->encrypt_to_self_checkbtn
= encrypt_to_self_checkbtn
;
2812 update_privacy_system_menu();
2814 tmp_ac_prefs
= *ac_prefs
;
2817 prefs_set_dialog_to_default(privacy_param
);
2819 prefs_set_dialog(privacy_param
);
2823 page
->page
.widget
= vbox1
;
2826 #define CREATE_RADIO_BUTTON(box, btn, btn_p, label, data) \
2828 btn = gtk_radio_button_new_with_label_from_widget \
2829 (GTK_RADIO_BUTTON (btn_p), label); \
2830 gtk_widget_show (btn); \
2831 gtk_box_pack_start (GTK_BOX (box), btn, FALSE, FALSE, 0); \
2832 g_object_set_data (G_OBJECT (btn), \
2834 GINT_TO_POINTER (data)); \
2839 #define CREATE_RADIO_BUTTONS(box, \
2840 btn1, btn1_label, btn1_data, \
2841 btn2, btn2_label, btn2_data, \
2842 btn3, btn3_label, btn3_data) \
2844 btn1 = gtk_radio_button_new_with_label(NULL, btn1_label); \
2845 gtk_widget_show (btn1); \
2846 gtk_box_pack_start (GTK_BOX (box), btn1, FALSE, FALSE, 0); \
2847 g_object_set_data (G_OBJECT (btn1), \
2849 GINT_TO_POINTER (btn1_data)); \
2851 CREATE_RADIO_BUTTON(box, btn2, btn1, btn2_label, btn2_data); \
2852 CREATE_RADIO_BUTTON(box, btn3, btn1, btn3_label, btn3_data); \
2855 static void pop_ssltunnel_toggled(GtkToggleButton
*button
,
2858 gboolean active
= gtk_toggle_button_get_active(button
);
2860 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2861 advanced_page
.popport_checkbtn
)) == TRUE
)
2863 gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page
.popport_spinbtn
),
2864 active
? 995 : 110);
2867 static void imap_ssltunnel_toggled(GtkToggleButton
*button
,
2870 gboolean active
= gtk_toggle_button_get_active(button
);
2872 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2873 advanced_page
.imapport_checkbtn
)) == TRUE
)
2875 gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page
.imapport_spinbtn
),
2876 active
? 993 : 143);
2879 static void nntp_ssltunnel_toggled(GtkToggleButton
*button
,
2882 gboolean active
= gtk_toggle_button_get_active(button
);
2884 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2885 advanced_page
.nntpport_checkbtn
)) == TRUE
)
2887 gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page
.nntpport_spinbtn
),
2888 active
? 563 : 119);
2891 static void smtp_ssltunnel_toggled(GtkToggleButton
*button
,
2894 gboolean active
= gtk_toggle_button_get_active(button
);
2896 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2897 advanced_page
.smtpport_checkbtn
)) == TRUE
)
2899 gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page
.smtpport_spinbtn
),
2903 static void ssl_create_widget_func(PrefsPage
* _page
,
2907 SSLPage
*page
= (SSLPage
*) _page
;
2908 PrefsAccount
*ac_prefs
= (PrefsAccount
*) data
;
2912 GtkWidget
*pop_frame
;
2914 GtkWidget
*pop_nossl_radiobtn
;
2915 GtkWidget
*pop_ssltunnel_radiobtn
;
2916 GtkWidget
*pop_starttls_radiobtn
;
2918 GtkWidget
*imap_frame
;
2920 GtkWidget
*imap_nossl_radiobtn
;
2921 GtkWidget
*imap_ssltunnel_radiobtn
;
2922 GtkWidget
*imap_starttls_radiobtn
;
2924 GtkWidget
*nntp_frame
;
2926 GtkWidget
*nntp_nossl_radiobtn
;
2927 GtkWidget
*nntp_ssltunnel_radiobtn
;
2929 GtkWidget
*send_frame
;
2931 GtkWidget
*smtp_nossl_radiobtn
;
2932 GtkWidget
*smtp_ssltunnel_radiobtn
;
2933 GtkWidget
*smtp_starttls_radiobtn
;
2935 GtkWidget
*cert_frame
;
2936 GtkWidget
*cert_table
;
2937 GtkWidget
*entry_in_cert_pass
;
2938 GtkWidget
*entry_out_cert_pass
;
2939 GtkWidget
*showpwd_checkbtn
;
2942 GtkWidget
*ssl_certs_auto_accept_checkbtn
;
2943 GtkWidget
*use_nonblocking_ssl_checkbtn
;
2945 GtkWidget
*hbox_spc
;
2949 vbox1
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING
);
2950 gtk_widget_show (vbox1
);
2951 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), VBOX_BORDER
);
2953 vbox2
= gtkut_get_options_frame(vbox1
, &pop_frame
, _("POP"));
2955 CREATE_RADIO_BUTTONS(vbox2
,
2959 pop_ssltunnel_radiobtn
,
2962 pop_starttls_radiobtn
,
2963 _("Use STARTTLS command to start encrypted session"),
2965 g_signal_connect(G_OBJECT(pop_ssltunnel_radiobtn
), "toggled",
2966 G_CALLBACK(pop_ssltunnel_toggled
), NULL
);
2968 vbox3
= gtkut_get_options_frame(vbox1
, &imap_frame
, _("IMAP"));
2970 CREATE_RADIO_BUTTONS(vbox3
,
2971 imap_nossl_radiobtn
,
2974 imap_ssltunnel_radiobtn
,
2977 imap_starttls_radiobtn
,
2978 _("Use STARTTLS command to start encrypted session"),
2980 g_signal_connect(G_OBJECT(imap_ssltunnel_radiobtn
), "toggled",
2981 G_CALLBACK(imap_ssltunnel_toggled
), NULL
);
2983 vbox4
= gtkut_get_options_frame(vbox1
, &nntp_frame
, _("NNTP"));
2985 nntp_nossl_radiobtn
=
2986 gtk_radio_button_new_with_label (NULL
, _("Don't use TLS"));
2987 gtk_widget_show (nntp_nossl_radiobtn
);
2988 gtk_box_pack_start (GTK_BOX (vbox4
), nntp_nossl_radiobtn
,
2990 g_object_set_data (G_OBJECT (nntp_nossl_radiobtn
),
2992 GINT_TO_POINTER (SSL_NONE
));
2994 CREATE_RADIO_BUTTON(vbox4
, nntp_ssltunnel_radiobtn
, nntp_nossl_radiobtn
,
2995 _("Use TLS"), SSL_TUNNEL
);
2996 g_signal_connect(G_OBJECT(nntp_ssltunnel_radiobtn
), "toggled",
2997 G_CALLBACK(nntp_ssltunnel_toggled
), NULL
);
2999 vbox5
= gtkut_get_options_frame(vbox1
, &send_frame
, _("Send (SMTP)"));
3001 CREATE_RADIO_BUTTONS(vbox5
,
3002 smtp_nossl_radiobtn
,
3003 _("Don't use TLS (but, if necessary, use STARTTLS)"),
3005 smtp_ssltunnel_radiobtn
,
3008 smtp_starttls_radiobtn
,
3009 _("Use STARTTLS command to start encrypted session"),
3011 g_signal_connect(G_OBJECT(smtp_ssltunnel_radiobtn
), "toggled",
3012 G_CALLBACK(smtp_ssltunnel_toggled
), NULL
);
3014 PACK_FRAME(vbox1
, cert_frame
, _("Client certificates"));
3016 cert_table
= gtk_grid_new();
3017 gtk_container_add(GTK_CONTAINER(cert_frame
), cert_table
);
3018 gtk_container_set_border_width(GTK_CONTAINER(cert_table
), 8);
3019 gtk_grid_set_row_spacing(GTK_GRID(cert_table
), VSPACING_NARROW_2
);
3020 gtk_grid_set_column_spacing(GTK_GRID(cert_table
), 8);
3022 label
= gtk_label_new(_("Certificate for receiving"));
3023 gtk_label_set_xalign(GTK_LABEL(label
), 1.0);
3024 entry_in_cert_file
= gtk_entry_new();
3025 in_ssl_cert_browse_button
= gtkut_get_browse_file_btn(_("Browse"));
3026 CLAWS_SET_TIP(label
,
3027 _("Client certificate file as a PKCS12 or PEM file"));
3028 CLAWS_SET_TIP(entry_in_cert_file
,
3029 _("Client certificate file as a PKCS12 or PEM file"));
3030 gtk_grid_attach(GTK_GRID(cert_table
), label
, 0, 0, 1, 1);
3031 gtk_grid_attach(GTK_GRID(cert_table
), entry_in_cert_file
, 1, 0, 1, 1);
3032 gtk_widget_set_hexpand(entry_in_cert_file
, TRUE
);
3033 gtk_widget_set_halign(entry_in_cert_file
, GTK_ALIGN_FILL
);
3034 gtk_grid_attach(GTK_GRID(cert_table
), in_ssl_cert_browse_button
, 2, 0, 1, 1);
3036 label
= gtk_label_new(_("Password"));
3037 gtk_label_set_xalign(GTK_LABEL(label
), 1.0);
3038 entry_in_cert_pass
= gtk_entry_new();
3039 gtk_entry_set_visibility(GTK_ENTRY(entry_in_cert_pass
), FALSE
);
3040 showpwd_checkbtn
= gtk_check_button_new_with_label (_("Show password"));
3041 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn
), FALSE
);
3042 g_signal_connect(G_OBJECT(showpwd_checkbtn
), "toggled",
3043 G_CALLBACK(prefs_account_showpwd_checkbtn_toggled
), entry_in_cert_pass
);
3044 gtk_grid_attach(GTK_GRID(cert_table
), label
, 0, 1, 1, 1);
3045 gtk_grid_attach(GTK_GRID(cert_table
), entry_in_cert_pass
, 1, 1, 1, 1);
3046 gtk_widget_set_hexpand(entry_in_cert_pass
, TRUE
);
3047 gtk_widget_set_halign(entry_in_cert_pass
, GTK_ALIGN_FILL
);
3048 gtk_grid_attach(GTK_GRID(cert_table
), showpwd_checkbtn
, 2, 1, 1, 1);
3050 label
= gtk_label_new(_("Certificate for sending"));
3051 gtk_label_set_xalign(GTK_LABEL(label
), 1.0);
3052 entry_out_cert_file
= gtk_entry_new();
3053 out_ssl_cert_browse_button
= gtkut_get_browse_file_btn(_("Browse"));
3054 CLAWS_SET_TIP(label
,
3055 _("Client certificate file as a PKCS12 or PEM file"));
3056 CLAWS_SET_TIP(entry_out_cert_file
,
3057 _("Client certificate file as a PKCS12 or PEM file"));
3058 gtk_grid_attach(GTK_GRID(cert_table
), label
, 0, 2, 1, 1);
3059 gtk_grid_attach(GTK_GRID(cert_table
), entry_out_cert_file
, 1, 2, 1, 1);
3060 gtk_widget_set_hexpand(entry_out_cert_file
, TRUE
);
3061 gtk_widget_set_halign(entry_out_cert_file
, GTK_ALIGN_FILL
);
3062 gtk_grid_attach(GTK_GRID(cert_table
), out_ssl_cert_browse_button
, 2, 2, 1, 1);
3064 label
= gtk_label_new(_("Password"));
3065 gtk_label_set_xalign(GTK_LABEL(label
), 1.0);
3066 entry_out_cert_pass
= gtk_entry_new();
3067 gtk_entry_set_visibility(GTK_ENTRY(entry_out_cert_pass
), FALSE
);
3068 showpwd_checkbtn
= gtk_check_button_new_with_label (_("Show password"));
3069 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn
), FALSE
);
3070 g_signal_connect(G_OBJECT(showpwd_checkbtn
), "toggled",
3071 G_CALLBACK(prefs_account_showpwd_checkbtn_toggled
), entry_out_cert_pass
);
3072 gtk_grid_attach(GTK_GRID(cert_table
), label
, 0, 3, 1, 1);
3073 gtk_grid_attach(GTK_GRID(cert_table
), entry_out_cert_pass
, 1, 3, 1, 1);
3074 gtk_widget_set_hexpand(entry_out_cert_pass
, TRUE
);
3075 gtk_widget_set_halign(entry_out_cert_pass
, GTK_ALIGN_FILL
);
3076 gtk_grid_attach(GTK_GRID(cert_table
), showpwd_checkbtn
, 2, 3, 1, 1);
3078 gtk_widget_show_all(cert_table
);
3080 g_signal_connect(G_OBJECT(in_ssl_cert_browse_button
), "clicked",
3081 G_CALLBACK(prefs_account_in_cert_browse_cb
), NULL
);
3082 g_signal_connect(G_OBJECT(out_ssl_cert_browse_button
), "clicked",
3083 G_CALLBACK(prefs_account_out_cert_browse_cb
), NULL
);
3085 vbox7
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 0);
3086 gtk_widget_show (vbox7
);
3087 gtk_box_pack_start (GTK_BOX (vbox1
), vbox7
, FALSE
, FALSE
, 0);
3089 PACK_CHECK_BUTTON(vbox7
, ssl_certs_auto_accept_checkbtn
,
3090 _("Automatically accept valid TLS certificates"));
3092 PACK_CHECK_BUTTON(vbox7
, use_nonblocking_ssl_checkbtn
,
3093 _("Use non-blocking TLS"));
3095 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
3096 gtk_widget_show (hbox
);
3097 gtk_box_pack_start (GTK_BOX (vbox7
), hbox
, FALSE
, FALSE
, 0);
3099 hbox_spc
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
3100 gtk_widget_show (hbox_spc
);
3101 gtk_box_pack_start (GTK_BOX (hbox
), hbox_spc
, FALSE
, FALSE
, 0);
3102 gtk_widget_set_size_request (hbox_spc
, 16, -1);
3104 label
= gtk_label_new
3105 (_("Turn this off if you have TLS connection problems"));
3106 gtk_widget_show (label
);
3107 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
3108 gtkut_widget_set_small_font_size (label
);
3110 page
->pop_frame
= pop_frame
;
3111 page
->pop_nossl_radiobtn
= pop_nossl_radiobtn
;
3112 page
->pop_ssltunnel_radiobtn
= pop_ssltunnel_radiobtn
;
3113 page
->pop_starttls_radiobtn
= pop_starttls_radiobtn
;
3115 page
->imap_frame
= imap_frame
;
3116 page
->imap_nossl_radiobtn
= imap_nossl_radiobtn
;
3117 page
->imap_ssltunnel_radiobtn
= imap_ssltunnel_radiobtn
;
3118 page
->imap_starttls_radiobtn
= imap_starttls_radiobtn
;
3120 page
->nntp_frame
= nntp_frame
;
3121 page
->nntp_nossl_radiobtn
= nntp_nossl_radiobtn
;
3122 page
->nntp_ssltunnel_radiobtn
= nntp_ssltunnel_radiobtn
;
3124 page
->send_frame
= send_frame
;
3125 page
->smtp_nossl_radiobtn
= smtp_nossl_radiobtn
;
3126 page
->smtp_ssltunnel_radiobtn
= smtp_ssltunnel_radiobtn
;
3127 page
->smtp_starttls_radiobtn
= smtp_starttls_radiobtn
;
3129 page
->entry_in_cert_file
= entry_in_cert_file
;
3130 page
->entry_in_cert_pass
= entry_in_cert_pass
;
3131 page
->entry_out_cert_file
= entry_out_cert_file
;
3132 page
->entry_out_cert_pass
= entry_out_cert_pass
;
3134 page
->ssl_certs_auto_accept_checkbtn
= ssl_certs_auto_accept_checkbtn
;
3135 page
->use_nonblocking_ssl_checkbtn
= use_nonblocking_ssl_checkbtn
;
3137 tmp_ac_prefs
= *ac_prefs
;
3140 prefs_set_dialog_to_default(ssl_param
);
3142 prefs_set_dialog(ssl_param
);
3144 /* Passwords are handled outside of PrefParams. */
3145 buf
= passwd_store_get_account(ac_prefs
->account_id
,
3146 PWS_ACCOUNT_RECV_CERT
);
3147 gtk_entry_set_text(GTK_ENTRY(page
->entry_in_cert_pass
), buf
!= NULL
? buf
: "");
3149 memset(buf
, 0, strlen(buf
));
3153 buf
= passwd_store_get_account(ac_prefs
->account_id
,
3154 PWS_ACCOUNT_SEND_CERT
);
3155 gtk_entry_set_text(GTK_ENTRY(page
->entry_out_cert_pass
), buf
!= NULL
? buf
: "");
3157 memset(buf
, 0, strlen(buf
));
3164 page
->page
.widget
= vbox1
;
3167 #undef CREATE_RADIO_BUTTONS
3168 #endif /* USE_GNUTLS */
3170 static void proxy_create_widget_func(PrefsPage
* _page
,
3174 ProxyPage
*page
= (ProxyPage
*) _page
;
3175 PrefsAccount
*ac_prefs
= (PrefsAccount
*) data
;
3176 GtkWidget
*vbox1
, *vbox2
, *vbox3
, *vbox4
;
3177 GtkWidget
*proxy_frame
;
3178 GtkWidget
*proxy_checkbtn
;
3179 GtkWidget
*default_proxy_checkbtn
;
3182 GtkWidget
*socks4_radiobtn
;
3183 GtkWidget
*socks5_radiobtn
;
3184 GtkWidget
*proxy_host_entry
;
3185 GtkWidget
*proxy_port_spinbtn
;
3186 GtkWidget
*proxy_auth_checkbtn
;
3187 GtkWidget
*proxy_name_entry
;
3188 GtkWidget
*proxy_pass_entry
;
3189 GtkWidget
*proxy_send_checkbtn
;
3194 vbox1
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING
);
3195 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), VBOX_BORDER
);
3197 proxy_checkbtn
= gtk_check_button_new_with_label (_("Use proxy server"));
3198 PACK_FRAME (vbox1
, proxy_frame
, NULL
);
3199 gtk_frame_set_label_widget (GTK_FRAME(proxy_frame
), proxy_checkbtn
);
3201 vbox2
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING_NARROW
);
3202 gtk_container_add (GTK_CONTAINER (proxy_frame
), vbox2
);
3203 gtk_container_set_border_width (GTK_CONTAINER (vbox2
), 8);
3205 default_proxy_checkbtn
=
3206 gtk_check_button_new_with_label (C_("In account preferences, referring to whether or not use proxy settings from common preferences", "Use default settings"));
3207 CLAWS_SET_TIP(default_proxy_checkbtn
,
3208 _("Use global proxy server settings"));
3209 gtk_box_pack_start (GTK_BOX (vbox2
), default_proxy_checkbtn
, FALSE
, FALSE
, 0);
3211 vbox3
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING_NARROW
);
3212 gtk_box_pack_start (GTK_BOX (vbox2
), vbox3
, FALSE
, FALSE
, 0);
3214 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
3215 gtk_box_pack_start (GTK_BOX (vbox3
), hbox
, FALSE
, FALSE
, 0);
3217 socks4_radiobtn
= gtk_radio_button_new_with_label(NULL
, "SOCKS4");
3218 gtk_box_pack_start (GTK_BOX (hbox
), socks4_radiobtn
, FALSE
, FALSE
, 0);
3219 g_object_set_data(G_OBJECT(socks4_radiobtn
), MENU_VAL_ID
,
3220 GINT_TO_POINTER(PROXY_SOCKS4
));
3222 CREATE_RADIO_BUTTON(hbox
, socks5_radiobtn
, socks4_radiobtn
, "SOCKS5",
3225 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
3226 gtk_box_pack_start (GTK_BOX (vbox3
), hbox
, FALSE
, FALSE
, 0);
3228 label
= gtk_label_new(_("Hostname"));
3229 gtk_box_pack_start(GTK_BOX(hbox
), label
, FALSE
, FALSE
, 0);
3231 proxy_host_entry
= gtk_entry_new();
3232 gtk_widget_set_size_request(proxy_host_entry
, DEFAULT_ENTRY_WIDTH
, -1);
3233 gtk_box_pack_start(GTK_BOX(hbox
), proxy_host_entry
, TRUE
, TRUE
, 0);
3235 label
= gtk_label_new(_("Port"));
3236 gtk_box_pack_start(GTK_BOX(hbox
), label
, FALSE
, FALSE
, 0);
3238 proxy_port_spinbtn
= gtk_spin_button_new_with_range(0, 65535, 1080);
3239 gtk_widget_set_size_request(proxy_port_spinbtn
, 64, -1);
3240 gtk_box_pack_start(GTK_BOX(hbox
), proxy_port_spinbtn
, FALSE
, FALSE
, 0);
3242 vbox4
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING_NARROW
);
3243 gtk_box_pack_start(GTK_BOX(vbox3
), vbox4
, FALSE
, FALSE
, 0);
3245 PACK_CHECK_BUTTON (vbox4
, proxy_auth_checkbtn
, _("Use authentication"));
3247 table
= gtk_grid_new();
3248 gtk_box_pack_start (GTK_BOX (vbox4
), table
, FALSE
, FALSE
, 0);
3250 label
= gtk_label_new(_("Username"));
3251 gtk_grid_attach(GTK_GRID(table
), label
, 0, 0, 1, 1);
3253 proxy_name_entry
= gtk_entry_new();
3254 gtk_widget_set_size_request(proxy_name_entry
, DEFAULT_ENTRY_WIDTH
, -1);
3255 gtk_grid_attach(GTK_GRID(table
), proxy_name_entry
, 1, 0, 1, 1);
3256 gtk_widget_set_hexpand(proxy_name_entry
, TRUE
);
3257 gtk_widget_set_halign(proxy_name_entry
, GTK_ALIGN_FILL
);
3259 label
= gtk_label_new(_("Password"));
3260 gtk_grid_attach(GTK_GRID(table
), label
, 2, 0, 1, 1);
3262 proxy_pass_entry
= gtk_entry_new();
3263 gtk_widget_set_size_request(proxy_pass_entry
, DEFAULT_ENTRY_WIDTH
, -1);
3264 gtk_entry_set_visibility(GTK_ENTRY(proxy_pass_entry
), FALSE
);
3265 gtk_grid_attach(GTK_GRID(table
), proxy_pass_entry
, 3, 0, 1, 1);
3266 gtk_widget_set_hexpand(proxy_pass_entry
, TRUE
);
3267 gtk_widget_set_halign(proxy_pass_entry
, GTK_ALIGN_FILL
);
3269 button
= gtk_check_button_new_with_label(_("Show password"));
3270 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button
), FALSE
);
3271 gtk_grid_attach(GTK_GRID(table
), button
, 3, 1, 1, 1);
3273 g_signal_connect(G_OBJECT(button
), "toggled",
3274 G_CALLBACK(prefs_account_showpwd_checkbtn_toggled
), proxy_pass_entry
);
3276 gtk_box_pack_start(GTK_BOX(vbox2
), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL
), FALSE
, FALSE
, 0);
3278 PACK_CHECK_BUTTON(vbox2
, proxy_send_checkbtn
,
3279 _("Use proxy server for sending"));
3280 CLAWS_SET_TIP(proxy_send_checkbtn
,
3281 _("If disabled, messages will be sent using direct connection to configured outgoing server, bypassing any configured proxy server."));
3283 SET_TOGGLE_SENSITIVITY(proxy_auth_checkbtn
, table
);
3284 SET_TOGGLE_SENSITIVITY(socks5_radiobtn
, vbox4
);
3285 SET_TOGGLE_SENSITIVITY(proxy_checkbtn
, vbox2
);
3286 SET_TOGGLE_SENSITIVITY_REVERSE(default_proxy_checkbtn
, vbox3
);
3288 gtk_widget_show_all(vbox1
);
3290 page
->proxy_checkbtn
= proxy_checkbtn
;
3291 page
->default_proxy_checkbtn
= default_proxy_checkbtn
;
3292 page
->socks4_radiobtn
= socks4_radiobtn
;
3293 page
->socks5_radiobtn
= socks5_radiobtn
;
3294 page
->proxy_host_entry
= proxy_host_entry
;
3295 page
->proxy_port_spinbtn
= proxy_port_spinbtn
;
3296 page
->proxy_auth_checkbtn
= proxy_auth_checkbtn
;
3297 page
->proxy_name_entry
= proxy_name_entry
;
3298 page
->proxy_pass_entry
= proxy_pass_entry
;
3299 page
->proxy_send_checkbtn
= proxy_send_checkbtn
;
3301 page
->page
.widget
= vbox1
;
3303 tmp_ac_prefs
= *ac_prefs
;
3306 prefs_set_dialog_to_default(proxy_param
);
3308 prefs_set_dialog(proxy_param
);
3310 /* Passwords are handled outside of PrefParams. */
3311 buf
= passwd_store_get_account(ac_prefs
->account_id
,
3312 PWS_ACCOUNT_PROXY_PASS
);
3313 gtk_entry_set_text(GTK_ENTRY(page
->proxy_pass_entry
),
3314 buf
!= NULL
? buf
: "");
3316 memset(buf
, 0, strlen(buf
));
3323 page
->page
.widget
= vbox1
;
3326 static void advanced_create_widget_func(PrefsPage
* _page
,
3330 AdvancedPage
*page
= (AdvancedPage
*) _page
;
3331 PrefsAccount
*ac_prefs
= (PrefsAccount
*) data
;
3336 GtkWidget
*checkbtn_smtpport
;
3337 GtkWidget
*spinbtn_smtpport
;
3338 GtkWidget
*hbox_popport
;
3339 GtkWidget
*checkbtn_popport
;
3340 GtkWidget
*spinbtn_popport
;
3341 GtkWidget
*hbox_imapport
;
3342 GtkWidget
*checkbtn_imapport
;
3343 GtkWidget
*spinbtn_imapport
;
3344 GtkWidget
*hbox_nntpport
;
3345 GtkWidget
*checkbtn_nntpport
;
3346 GtkWidget
*spinbtn_nntpport
;
3347 GtkWidget
*checkbtn_domain
;
3348 GtkWidget
*entry_domain
;
3350 GtkWidget
*checkbtn_crosspost
;
3351 GtkWidget
*colormenu_crosspost
;
3353 GtkWidget
*checkbtn_tunnelcmd
;
3354 GtkWidget
*entry_tunnelcmd
;
3356 GtkWidget
*folder_frame
;
3359 GtkWidget
*sent_folder_checkbtn
;
3360 GtkWidget
*sent_folder_entry
;
3361 GtkWidget
*queue_folder_checkbtn
;
3362 GtkWidget
*queue_folder_entry
;
3363 GtkWidget
*draft_folder_checkbtn
;
3364 GtkWidget
*draft_folder_entry
;
3365 GtkWidget
*trash_folder_checkbtn
;
3366 GtkWidget
*trash_folder_entry
;
3367 GtkSizeGroup
*size_group
= gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL
);
3369 #define PACK_HBOX(hbox) \
3371 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); \
3372 gtk_widget_show (hbox); \
3373 gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); \
3376 #define PACK_PORT_SPINBTN(box, spinbtn) \
3378 spinbtn = gtk_spin_button_new_with_range(0, 65535, 1); \
3379 gtk_widget_show (spinbtn); \
3380 gtk_box_pack_start (GTK_BOX (box), spinbtn, FALSE, FALSE, 0); \
3383 vbox1
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING
);
3384 gtk_widget_show (vbox1
);
3385 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), VBOX_BORDER
);
3387 vbox2
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING_NARROW_2
);
3388 gtk_widget_show (vbox2
);
3389 gtk_box_pack_start (GTK_BOX (vbox1
), vbox2
, FALSE
, FALSE
, 0);
3392 PACK_CHECK_BUTTON (hbox1
, checkbtn_smtpport
, _("SMTP port"));
3393 PACK_PORT_SPINBTN (hbox1
, spinbtn_smtpport
);
3394 SET_TOGGLE_SENSITIVITY (checkbtn_smtpport
, spinbtn_smtpport
);
3395 gtk_size_group_add_widget(size_group
, checkbtn_smtpport
);
3397 PACK_HBOX (hbox_popport
);
3398 PACK_CHECK_BUTTON (hbox_popport
, checkbtn_popport
,
3400 PACK_PORT_SPINBTN (hbox_popport
, spinbtn_popport
);
3401 SET_TOGGLE_SENSITIVITY (checkbtn_popport
, spinbtn_popport
);
3402 gtk_size_group_add_widget(size_group
, checkbtn_popport
);
3404 PACK_HBOX (hbox_imapport
);
3405 PACK_CHECK_BUTTON (hbox_imapport
, checkbtn_imapport
,
3407 PACK_PORT_SPINBTN (hbox_imapport
, spinbtn_imapport
);
3408 SET_TOGGLE_SENSITIVITY (checkbtn_imapport
, spinbtn_imapport
);
3409 gtk_size_group_add_widget(size_group
, checkbtn_imapport
);
3411 PACK_HBOX (hbox_nntpport
);
3412 PACK_CHECK_BUTTON (hbox_nntpport
, checkbtn_nntpport
,
3414 PACK_PORT_SPINBTN (hbox_nntpport
, spinbtn_nntpport
);
3415 SET_TOGGLE_SENSITIVITY (checkbtn_nntpport
, spinbtn_nntpport
);
3416 gtk_size_group_add_widget(size_group
, checkbtn_nntpport
);
3419 PACK_CHECK_BUTTON (hbox1
, checkbtn_domain
, _("Domain name"));
3420 gtk_size_group_add_widget(size_group
, checkbtn_domain
);
3422 tip_domain
= _("The domain name will be used in the generated "
3423 "Message-ID, and when connecting to SMTP servers.");
3425 CLAWS_SET_TIP(checkbtn_domain
, tip_domain
);
3427 entry_domain
= gtk_entry_new ();
3428 gtk_widget_show (entry_domain
);
3429 gtk_box_pack_start (GTK_BOX (hbox1
), entry_domain
, TRUE
, TRUE
, 0);
3430 SET_TOGGLE_SENSITIVITY (checkbtn_domain
, entry_domain
);
3431 CLAWS_SET_TIP(entry_domain
, tip_domain
);
3435 PACK_CHECK_BUTTON (hbox1
, checkbtn_tunnelcmd
,
3436 _("Use command to communicate with server"));
3437 entry_tunnelcmd
= gtk_entry_new ();
3438 gtk_widget_show (entry_tunnelcmd
);
3439 gtk_box_pack_start (GTK_BOX (hbox1
), entry_tunnelcmd
, TRUE
, TRUE
, 0);
3440 SET_TOGGLE_SENSITIVITY (checkbtn_tunnelcmd
, entry_tunnelcmd
);
3444 PACK_CHECK_BUTTON (hbox1
, checkbtn_crosspost
,
3445 _("Mark cross-posted messages as read and color:"));
3446 g_signal_connect (G_OBJECT (checkbtn_crosspost
), "toggled",
3447 G_CALLBACK (crosspost_color_toggled
),
3450 colormenu_crosspost
= colorlabel_create_combobox_colormenu();
3451 gtk_widget_show (colormenu_crosspost
);
3452 gtk_box_pack_start (GTK_BOX (hbox1
), colormenu_crosspost
, FALSE
, FALSE
, 0);
3454 SET_TOGGLE_SENSITIVITY(checkbtn_crosspost
, colormenu_crosspost
);
3456 #undef PACK_PORT_SPINBTN
3458 /* special folder setting (maybe these options are redundant) */
3460 vbox3
= gtkut_get_options_frame(vbox1
, &folder_frame
, _("Folder"));
3462 table
= gtk_grid_new();
3463 gtk_widget_show (table
);
3464 gtk_container_add (GTK_CONTAINER (vbox3
), table
);
3465 gtk_grid_set_row_spacing(GTK_GRID(table
), VSPACING_NARROW_2
);
3466 gtk_grid_set_column_spacing(GTK_GRID(table
), 4);
3468 #define SET_CHECK_BTN_AND_ENTRY(label, checkbtn, entry, n) \
3470 GtkWidget *button; \
3472 checkbtn = gtk_check_button_new_with_label (label); \
3473 gtk_widget_show (checkbtn); \
3474 gtk_grid_attach(GTK_GRID(table), checkbtn, 0, n, 1, 1); \
3476 entry = gtk_entry_new (); \
3477 gtk_widget_show (entry); \
3478 gtk_grid_attach(GTK_GRID(table), entry, 1, n, 1, 1); \
3479 gtk_widget_set_hexpand(entry, TRUE); \
3480 gtk_widget_set_halign(entry, GTK_ALIGN_FILL); \
3482 button = gtkut_get_browse_file_btn(_("Browse")); \
3483 gtk_widget_show (button); \
3484 gtk_grid_attach(GTK_GRID(table), button, 2, n, 1, 1); \
3486 (G_OBJECT (button), "clicked", \
3487 G_CALLBACK (prefs_account_select_folder_cb), \
3490 SET_TOGGLE_SENSITIVITY (checkbtn, entry); \
3491 SET_TOGGLE_SENSITIVITY (checkbtn, button); \
3494 SET_CHECK_BTN_AND_ENTRY(_("Put sent messages in"),
3495 sent_folder_checkbtn
, sent_folder_entry
, 0);
3496 SET_CHECK_BTN_AND_ENTRY(_("Put queued messages in"),
3497 queue_folder_checkbtn
, queue_folder_entry
, 1);
3498 SET_CHECK_BTN_AND_ENTRY(_("Put draft messages in"),
3499 draft_folder_checkbtn
, draft_folder_entry
, 2);
3500 SET_CHECK_BTN_AND_ENTRY(_("Put deleted messages in"),
3501 trash_folder_checkbtn
, trash_folder_entry
, 3);
3503 page
->smtpport_checkbtn
= checkbtn_smtpport
;
3504 page
->smtpport_spinbtn
= spinbtn_smtpport
;
3505 page
->popport_hbox
= hbox_popport
;
3506 page
->popport_checkbtn
= checkbtn_popport
;
3507 page
->popport_spinbtn
= spinbtn_popport
;
3508 page
->imapport_hbox
= hbox_imapport
;
3509 page
->imapport_checkbtn
= checkbtn_imapport
;
3510 page
->imapport_spinbtn
= spinbtn_imapport
;
3511 page
->nntpport_hbox
= hbox_nntpport
;
3512 page
->nntpport_checkbtn
= checkbtn_nntpport
;
3513 page
->nntpport_spinbtn
= spinbtn_nntpport
;
3514 page
->domain_checkbtn
= checkbtn_domain
;
3515 page
->domain_entry
= entry_domain
;
3516 page
->crosspost_checkbtn
= checkbtn_crosspost
;
3517 page
->crosspost_colormenu
= colormenu_crosspost
;
3520 page
->tunnelcmd_checkbtn
= checkbtn_tunnelcmd
;
3521 page
->tunnelcmd_entry
= entry_tunnelcmd
;
3523 page
->sent_folder_checkbtn
= sent_folder_checkbtn
;
3524 page
->sent_folder_entry
= sent_folder_entry
;
3525 page
->queue_folder_checkbtn
= queue_folder_checkbtn
;
3526 page
->queue_folder_entry
= queue_folder_entry
;
3527 page
->draft_folder_checkbtn
= draft_folder_checkbtn
;
3528 page
->draft_folder_entry
= draft_folder_entry
;
3529 page
->trash_folder_checkbtn
= trash_folder_checkbtn
;
3530 page
->trash_folder_entry
= trash_folder_entry
;
3532 tmp_ac_prefs
= *ac_prefs
;
3535 prefs_set_dialog_to_default(advanced_param
);
3537 prefs_set_dialog(advanced_param
);
3541 page
->page
.widget
= vbox1
;
3543 g_object_unref(G_OBJECT(size_group
));
3546 static gint
prefs_basic_apply(void)
3548 RecvProtocol protocol
;
3549 gchar
*old_id
= NULL
;
3550 gchar
*new_id
= NULL
;
3551 struct BasicProtocol
*protocol_optmenu
= (struct BasicProtocol
*) basic_page
.protocol_optmenu
;
3552 GtkWidget
*optmenu
= protocol_optmenu
->combobox
;
3554 protocol
= combobox_get_active_data(GTK_COMBO_BOX(optmenu
));
3556 if (*gtk_entry_get_text(GTK_ENTRY(basic_page
.acname_entry
)) == '\0') {
3557 alertpanel_error(_("Account name is not entered."));
3560 if (*gtk_entry_get_text(GTK_ENTRY(basic_page
.addr_entry
)) == '\0') {
3561 alertpanel_error(_("Mail address is not entered."));
3565 if (((protocol
== A_POP3
) ||
3566 (protocol
== A_LOCAL
&& !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(basic_page
.mailcmd_checkbtn
))) ||
3567 (protocol
== A_NONE
)) &&
3568 *gtk_entry_get_text(GTK_ENTRY(basic_page
.smtpserv_entry
)) == '\0') {
3569 alertpanel_error(_("SMTP server is not entered."));
3572 if ((protocol
== A_POP3
|| protocol
== A_IMAP4
) &&
3573 *gtk_entry_get_text(GTK_ENTRY(basic_page
.uid_entry
)) == '\0') {
3574 alertpanel_error(_("User ID is not entered."));
3577 if (protocol
== A_POP3
&&
3578 *gtk_entry_get_text(GTK_ENTRY(basic_page
.recvserv_entry
)) == '\0') {
3579 alertpanel_error(_("POP server is not entered."));
3582 if (protocol
== A_POP3
|| protocol
== A_LOCAL
) {
3583 GtkWidget
*inbox_entry
= (protocol
== A_POP3
? receive_page
.inbox_entry
: receive_page
.local_inbox_entry
);
3584 const gchar
*mailbox
= gtk_entry_get_text(GTK_ENTRY(inbox_entry
));
3585 FolderItem
*inbox
= folder_find_item_from_identifier(mailbox
);
3588 setup_write_mailbox_path(mainwindow_get_mainwindow(), "Mail");
3589 id
= folder_item_get_identifier(folder_get_default_inbox_for_class(F_MH
));
3590 gtk_entry_set_text(GTK_ENTRY(receive_page
.inbox_entry
),
3592 gtk_entry_set_text(GTK_ENTRY(receive_page
.local_inbox_entry
),
3595 mailbox
= gtk_entry_get_text(GTK_ENTRY(inbox_entry
));
3596 inbox
= folder_find_item_from_identifier(mailbox
);
3598 if (inbox
== NULL
) {
3599 alertpanel_error(_("The default Inbox folder doesn't exist."));
3603 if (protocol
== A_IMAP4
&&
3604 *gtk_entry_get_text(GTK_ENTRY(basic_page
.recvserv_entry
)) == '\0') {
3605 alertpanel_error(_("IMAP server is not entered."));
3608 if (protocol
== A_NNTP
&&
3609 *gtk_entry_get_text(GTK_ENTRY(basic_page
.nntpserv_entry
)) == '\0') {
3610 alertpanel_error(_("NNTP server is not entered."));
3614 if (protocol
== A_LOCAL
&&
3615 *gtk_entry_get_text(GTK_ENTRY(basic_page
.localmbox_entry
)) == '\0') {
3616 alertpanel_error(_("local mailbox filename is not entered."));
3620 if (protocol
== A_LOCAL
&&
3621 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(basic_page
.mailcmd_checkbtn
)) && *gtk_entry_get_text(GTK_ENTRY(basic_page
.mailcmd_entry
)) == '\0') {
3622 alertpanel_error(_("mail command is not entered."));
3626 if (protocol
== A_IMAP4
|| protocol
== A_NNTP
)
3627 old_id
= g_strdup_printf("#%s/%s",
3628 protocol
== A_IMAP4
? "imap":"news",
3629 tmp_ac_prefs
.account_name
? tmp_ac_prefs
.account_name
: "(null)");
3631 if (strchr(gtk_entry_get_text(GTK_ENTRY(basic_page
.uid_entry
)), '\n') != NULL
) {
3632 alertpanel_error(_("User ID cannot contain a newline character."));
3638 if (strchr(gtk_entry_get_text(GTK_ENTRY(basic_page
.pass_entry
)), '\n') != NULL
) {
3639 alertpanel_error(_("Password cannot contain a newline character."));
3645 prefs_set_data_from_dialog(basic_param
);
3647 /* Passwords are stored outside of PrefParams. */
3648 passwd_store_set_account(tmp_ac_prefs
.account_id
,
3650 gtk_entry_get_text(GTK_ENTRY(basic_page
.pass_entry
)),
3654 /* Manual password change - reset expiry on OAUTH2 tokens*/
3655 passwd_store_set_account(tmp_ac_prefs
.account_id
, PWS_ACCOUNT_OAUTH2_EXPIRY
, "0", FALSE
);
3658 if (protocol
== A_IMAP4
|| protocol
== A_NNTP
) {
3659 new_id
= g_strdup_printf("#%s/%s",
3660 protocol
== A_IMAP4
? "imap":"news",
3661 tmp_ac_prefs
.account_name
);
3662 if (old_id
!= NULL
&& new_id
!= NULL
)
3663 prefs_filtering_rename_path(old_id
, new_id
);
3673 static gint
prefs_receive_apply(void)
3675 if (strchr(gtk_entry_get_text(GTK_ENTRY(send_page
.smtp_uid_entry
)), '\n') != NULL
) {
3676 alertpanel_error(_("SMTP user ID cannot contain a newline character."));
3680 if (strchr(gtk_entry_get_text(GTK_ENTRY(send_page
.smtp_pass_entry
)), '\n') != NULL
) {
3681 alertpanel_error(_("SMTP password cannot contain a newline character."));
3685 prefs_set_data_from_dialog(receive_param
);
3690 static gint
prefs_send_apply(void)
3692 prefs_set_data_from_dialog(send_param
);
3694 /* Passwords are stored outside of PrefParams. */
3695 passwd_store_set_account(tmp_ac_prefs
.account_id
,
3697 gtk_entry_get_text(GTK_ENTRY(send_page
.smtp_pass_entry
)),
3700 /* Manual password change - reset expiry on OAUTH2 tokens*/
3701 passwd_store_set_account(tmp_ac_prefs
.account_id
, PWS_ACCOUNT_OAUTH2_EXPIRY
, "0", FALSE
);
3708 static gint
prefs_oauth2_apply(void)
3710 prefs_set_data_from_dialog(oauth2_param
);
3712 /* Passwords are stored outside of PrefParams. */
3713 passwd_store_set_account(tmp_ac_prefs
.account_id
,
3714 PWS_ACCOUNT_OAUTH2_AUTH
,
3715 gtk_entry_get_text(GTK_ENTRY(oauth2_page
.oauth2_authcode_entry
)),
3722 static gint
prefs_compose_apply(void)
3724 prefs_set_data_from_dialog(compose_param
);
3728 static gint
prefs_templates_apply(void)
3730 prefs_set_data_from_dialog(templates_param
);
3734 static gint
prefs_privacy_apply(void)
3736 prefs_set_data_from_dialog(privacy_param
);
3741 static gint
prefs_ssl_apply(void)
3743 prefs_set_data_from_dialog(ssl_param
);
3745 /* Passwords are stored outside of PrefParams. */
3746 passwd_store_set_account(tmp_ac_prefs
.account_id
,
3747 PWS_ACCOUNT_RECV_CERT
,
3748 gtk_entry_get_text(GTK_ENTRY(ssl_page
.entry_in_cert_pass
)),
3750 passwd_store_set_account(tmp_ac_prefs
.account_id
,
3751 PWS_ACCOUNT_SEND_CERT
,
3752 gtk_entry_get_text(GTK_ENTRY(ssl_page
.entry_out_cert_pass
)),
3759 static gint
prefs_proxy_apply(void)
3761 prefs_set_data_from_dialog(proxy_param
);
3763 /* Passwords are stored outside of PrefParams. */
3764 passwd_store_set_account(tmp_ac_prefs
.account_id
,
3765 PWS_ACCOUNT_PROXY_PASS
,
3766 gtk_entry_get_text(GTK_ENTRY(proxy_page
.proxy_pass_entry
)),
3772 static gint
prefs_advanced_apply(void)
3774 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(advanced_page
.domain_checkbtn
)) &&
3775 *gtk_entry_get_text(GTK_ENTRY(advanced_page
.domain_entry
)) == '\0') {
3776 alertpanel_error(_("domain is not specified."));
3779 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(advanced_page
.sent_folder_checkbtn
)) &&
3780 *gtk_entry_get_text(GTK_ENTRY(advanced_page
.sent_folder_entry
)) == '\0') {
3781 alertpanel_error(_("sent folder is not selected."));
3784 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(advanced_page
.queue_folder_checkbtn
)) &&
3785 *gtk_entry_get_text(GTK_ENTRY(advanced_page
.queue_folder_entry
)) == '\0') {
3786 alertpanel_error(_("queue folder is not selected."));
3789 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(advanced_page
.draft_folder_checkbtn
)) &&
3790 *gtk_entry_get_text(GTK_ENTRY(advanced_page
.draft_folder_entry
)) == '\0') {
3791 alertpanel_error(_("draft folder is not selected."));
3794 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(advanced_page
.trash_folder_checkbtn
)) &&
3795 *gtk_entry_get_text(GTK_ENTRY(advanced_page
.trash_folder_entry
)) == '\0') {
3796 alertpanel_error(_("trash folder is not selected."));
3800 prefs_set_data_from_dialog(advanced_param
);
3804 static void basic_destroy_widget_func(PrefsPage
*_page
)
3806 /* BasicPage *page = (BasicPage *) _page; */
3809 static void receive_destroy_widget_func(PrefsPage
*_page
)
3811 /* ReceivePage *page = (ReceivePage *) _page; */
3814 static void send_destroy_widget_func(PrefsPage
*_page
)
3816 /* SendPage *page = (SendPage *) _page; */
3820 static void oauth2_destroy_widget_func(PrefsPage
*_page
)
3822 /* Oauth2Page *page = (Oauth2Page *) _page; */
3824 if(oauth2_listener_task
){
3825 debug_print("Closing oauth2 listener task\n");
3826 oauth2_listener_cancel
= 1;
3831 static void compose_destroy_widget_func(PrefsPage
*_page
)
3833 /* ComposePage *page = (ComposePage *) _page; */
3836 static void templates_destroy_widget_func(PrefsPage
*_page
)
3838 /* TemplatesPage *page = (TemplatesPage *) _page; */
3841 static void privacy_destroy_widget_func(PrefsPage
*_page
)
3843 /* PrivacyPage *page = (PrivacyPage *) _page; */
3847 static void ssl_destroy_widget_func(PrefsPage
*_page
)
3849 /* SSLPage *page = (SSLPage *) _page; */
3853 static void proxy_destroy_widget_func(PrefsPage
*_page
)
3855 /* ProxyPage *page = (ProxyPage *) _page; */
3858 static void advanced_destroy_widget_func(PrefsPage
*_page
)
3860 /* AdvancedPage *page = (AdvancedPage *) _page; */
3863 static gboolean
basic_can_close_func(PrefsPage
*_page
)
3865 BasicPage
*page
= (BasicPage
*) _page
;
3867 if (!page
->page
.page_open
)
3870 return prefs_basic_apply() >= 0;
3873 static gboolean
receive_can_close_func(PrefsPage
*_page
)
3875 ReceivePage
*page
= (ReceivePage
*) _page
;
3877 if (!page
->page
.page_open
)
3880 return prefs_receive_apply() >= 0;
3883 static gboolean
send_can_close_func(PrefsPage
*_page
)
3885 SendPage
*page
= (SendPage
*) _page
;
3887 if (!page
->page
.page_open
)
3890 return prefs_send_apply() >= 0;
3894 static gboolean
oauth2_can_close_func(PrefsPage
*_page
)
3896 Oauth2Page
*page
= (Oauth2Page
*) _page
;
3898 if (!page
->page
.page_open
)
3901 return prefs_oauth2_apply() >= 0;
3905 static gboolean
compose_can_close_func(PrefsPage
*_page
)
3907 ComposePage
*page
= (ComposePage
*) _page
;
3909 if (!page
->page
.page_open
)
3912 return prefs_compose_apply() >= 0;
3915 static gboolean
templates_can_close_func(PrefsPage
*_page
)
3917 TemplatesPage
*page
= (TemplatesPage
*) _page
;
3919 if (!page
->page
.page_open
)
3922 return prefs_templates_apply() >= 0;
3925 static gboolean
privacy_can_close_func(PrefsPage
*_page
)
3927 PrivacyPage
*page
= (PrivacyPage
*) _page
;
3929 if (!page
->page
.page_open
)
3932 return prefs_privacy_apply() >= 0;
3936 static gboolean
ssl_can_close_func(PrefsPage
*_page
)
3938 SSLPage
*page
= (SSLPage
*) _page
;
3940 if (!page
->page
.page_open
)
3943 return prefs_ssl_apply() >= 0;
3947 static gboolean
proxy_can_close_func(PrefsPage
*_page
)
3949 ProxyPage
*page
= (ProxyPage
*) _page
;
3951 if (!page
->page
.page_open
)
3954 return prefs_proxy_apply() >= 0;
3957 static gboolean
advanced_can_close_func(PrefsPage
*_page
)
3959 AdvancedPage
*page
= (AdvancedPage
*) _page
;
3961 if (!page
->page
.page_open
)
3964 return prefs_advanced_apply() >= 0;
3967 static void basic_save_func(PrefsPage
*_page
)
3969 BasicPage
*page
= (BasicPage
*) _page
;
3971 if (!page
->page
.page_open
)
3974 if (prefs_basic_apply() >= 0)
3978 static void receive_save_func(PrefsPage
*_page
)
3980 ReceivePage
*page
= (ReceivePage
*) _page
;
3982 if (!page
->page
.page_open
)
3985 if (prefs_receive_apply() >= 0)
3989 static void send_save_func(PrefsPage
*_page
)
3991 SendPage
*page
= (SendPage
*) _page
;
3993 if (!page
->page
.page_open
)
3996 if (prefs_send_apply() >= 0)
4001 static void oauth2_save_func(PrefsPage
*_page
)
4003 Oauth2Page
*page
= (Oauth2Page
*) _page
;
4005 if (!page
->page
.page_open
)
4008 if (prefs_oauth2_apply() >= 0)
4013 static void compose_save_func(PrefsPage
*_page
)
4015 ComposePage
*page
= (ComposePage
*) _page
;
4017 if (!page
->page
.page_open
)
4020 if (prefs_compose_apply() >= 0)
4024 static void templates_save_func(PrefsPage
*_page
)
4026 TemplatesPage
*page
= (TemplatesPage
*) _page
;
4028 if (!page
->page
.page_open
)
4031 quotefmt_check_new_msg_formats(tmp_ac_prefs
.compose_with_format
,
4033 tmp_ac_prefs
.compose_subject_format
,
4034 tmp_ac_prefs
.compose_body_format
);
4035 quotefmt_check_reply_formats(tmp_ac_prefs
.reply_with_format
,
4037 tmp_ac_prefs
.reply_quotemark
,
4038 tmp_ac_prefs
.reply_body_format
);
4039 quotefmt_check_forward_formats(tmp_ac_prefs
.forward_with_format
,
4041 tmp_ac_prefs
.forward_quotemark
,
4042 tmp_ac_prefs
.forward_body_format
);
4043 if (prefs_templates_apply() >= 0)
4047 static void privacy_save_func(PrefsPage
*_page
)
4049 PrivacyPage
*page
= (PrivacyPage
*) _page
;
4051 if (!page
->page
.page_open
)
4054 if (prefs_privacy_apply() >= 0)
4059 static void ssl_save_func(PrefsPage
*_page
)
4061 SSLPage
*page
= (SSLPage
*) _page
;
4063 if (!page
->page
.page_open
)
4066 if (prefs_ssl_apply() >= 0)
4071 static void proxy_save_func(PrefsPage
*_page
)
4073 ProxyPage
*page
= (ProxyPage
*) _page
;
4075 if (!page
->page
.page_open
)
4078 if (prefs_proxy_apply() >= 0)
4082 static void advanced_save_func(PrefsPage
*_page
)
4084 AdvancedPage
*page
= (AdvancedPage
*) _page
;
4086 if (!page
->page
.page_open
)
4089 if (prefs_advanced_apply() >= 0)
4093 static void register_basic_page(void)
4095 static gchar
*path
[3];
4097 path
[0] = _("Account");
4098 path
[1] = _("Basic");
4101 basic_page
.page
.path
= path
;
4102 basic_page
.page
.weight
= 1000.0;
4103 basic_page
.page
.create_widget
= basic_create_widget_func
;
4104 basic_page
.page
.destroy_widget
= basic_destroy_widget_func
;
4105 basic_page
.page
.save_page
= basic_save_func
;
4106 basic_page
.page
.can_close
= basic_can_close_func
;
4108 prefs_account_register_page((PrefsPage
*) &basic_page
);
4111 static void register_receive_page(void)
4113 static gchar
*path
[3];
4115 path
[0] = _("Account");
4116 path
[1] = _("Receive");
4119 receive_page
.page
.path
= path
;
4120 receive_page
.page
.weight
= 1000.0;
4121 receive_page
.page
.create_widget
= receive_create_widget_func
;
4122 receive_page
.page
.destroy_widget
= receive_destroy_widget_func
;
4123 receive_page
.page
.save_page
= receive_save_func
;
4124 receive_page
.page
.can_close
= receive_can_close_func
;
4126 prefs_account_register_page((PrefsPage
*) &receive_page
);
4129 static void register_send_page(void)
4131 static gchar
*path
[3];
4133 path
[0] = _("Account");
4134 path
[1] = C_("Preferences menu item", "Send");
4137 send_page
.page
.path
= path
;
4138 send_page
.page
.weight
= 1000.0;
4139 send_page
.page
.create_widget
= send_create_widget_func
;
4140 send_page
.page
.destroy_widget
= send_destroy_widget_func
;
4141 send_page
.page
.save_page
= send_save_func
;
4142 send_page
.page
.can_close
= send_can_close_func
;
4144 prefs_account_register_page((PrefsPage
*) &send_page
);
4148 static void register_oauth2_page(void)
4150 static gchar
*path
[3];
4152 path
[0] = _("Account");
4153 path
[1] = _("OAuth2");
4156 oauth2_page
.page
.path
= path
;
4157 oauth2_page
.page
.weight
= 1000.0;
4158 oauth2_page
.page
.create_widget
= oauth2_create_widget_func
;
4159 oauth2_page
.page
.destroy_widget
= oauth2_destroy_widget_func
;
4160 oauth2_page
.page
.save_page
= oauth2_save_func
;
4161 oauth2_page
.page
.can_close
= oauth2_can_close_func
;
4163 prefs_account_register_page((PrefsPage
*) &oauth2_page
);
4167 static void register_compose_page(void)
4169 static gchar
*path
[3];
4171 path
[0] = _("Account");
4172 path
[1] = _("Compose");
4175 compose_page
.page
.path
= path
;
4176 compose_page
.page
.weight
= 1000.0;
4177 compose_page
.page
.create_widget
= compose_create_widget_func
;
4178 compose_page
.page
.destroy_widget
= compose_destroy_widget_func
;
4179 compose_page
.page
.save_page
= compose_save_func
;
4180 compose_page
.page
.can_close
= compose_can_close_func
;
4182 prefs_account_register_page((PrefsPage
*) &compose_page
);
4185 static void register_templates_page(void)
4187 static gchar
*path
[3];
4189 path
[0] = _("Account");
4190 path
[1] = _("Templates");
4193 templates_page
.page
.path
= path
;
4194 templates_page
.page
.weight
= 1000.0;
4195 templates_page
.page
.create_widget
= templates_create_widget_func
;
4196 templates_page
.page
.destroy_widget
= templates_destroy_widget_func
;
4197 templates_page
.page
.save_page
= templates_save_func
;
4198 templates_page
.page
.can_close
= templates_can_close_func
;
4200 prefs_account_register_page((PrefsPage
*) &templates_page
);
4203 static void register_privacy_page(void)
4205 static gchar
*path
[3];
4207 path
[0] = _("Account");
4208 path
[1] = _("Privacy");
4211 privacy_page
.page
.path
= path
;
4212 privacy_page
.page
.weight
= 1000.0;
4213 privacy_page
.page
.create_widget
= privacy_create_widget_func
;
4214 privacy_page
.page
.destroy_widget
= privacy_destroy_widget_func
;
4215 privacy_page
.page
.save_page
= privacy_save_func
;
4216 privacy_page
.page
.can_close
= privacy_can_close_func
;
4218 prefs_account_register_page((PrefsPage
*) &privacy_page
);
4222 static void register_ssl_page(void)
4224 static gchar
*path
[3];
4226 path
[0] = _("Account");
4230 ssl_page
.page
.path
= path
;
4231 ssl_page
.page
.weight
= 1000.0;
4232 ssl_page
.page
.create_widget
= ssl_create_widget_func
;
4233 ssl_page
.page
.destroy_widget
= ssl_destroy_widget_func
;
4234 ssl_page
.page
.save_page
= ssl_save_func
;
4235 ssl_page
.page
.can_close
= ssl_can_close_func
;
4237 prefs_account_register_page((PrefsPage
*) &ssl_page
);
4240 static gboolean
sslcert_get_client_cert_hook(gpointer source
, gpointer data
)
4242 SSLClientCertHookData
*hookdata
= (SSLClientCertHookData
*)source
;
4243 PrefsAccount
*account
= (PrefsAccount
*)hookdata
->account
;
4246 hookdata
->cert_path
= NULL
;
4247 hookdata
->password
= NULL
;
4249 if (!g_list_find(account_get_list(), account
)) {
4250 g_warning("can't find account");
4254 if (hookdata
->is_smtp
) {
4255 if (account
->out_ssl_client_cert_file
&& *account
->out_ssl_client_cert_file
)
4256 hookdata
->cert_path
= account
->out_ssl_client_cert_file
;
4257 pwd_id
= PWS_ACCOUNT_SEND_CERT
;
4259 if (account
->in_ssl_client_cert_file
&& *account
->in_ssl_client_cert_file
)
4260 hookdata
->cert_path
= account
->in_ssl_client_cert_file
;
4261 pwd_id
= PWS_ACCOUNT_RECV_CERT
;
4264 hookdata
->password
= passwd_store_get_account(account
->account_id
, pwd_id
);
4268 struct GetPassData
{
4275 static gboolean
do_get_pass(gpointer data
)
4277 struct GetPassData
*pass_data
= (struct GetPassData
*)data
;
4278 g_mutex_lock(&pass_data
->mutex
);
4279 *(pass_data
->pass
) = input_dialog_query_password("the PKCS12 client certificate", NULL
);
4280 g_cond_signal(&pass_data
->cond
);
4281 g_mutex_unlock(&pass_data
->mutex
);
4284 static gboolean
sslcert_get_password(gpointer source
, gpointer data
)
4286 struct GetPassData pass_data
;
4287 /* do complicated stuff to be able to call GTK from the mainloop */
4288 g_cond_init(&pass_data
.cond
);
4289 g_mutex_init(&pass_data
.mutex
);
4290 pass_data
.pass
= (gchar
**)source
;
4292 g_mutex_lock(&pass_data
.mutex
);
4294 g_idle_add(do_get_pass
, &pass_data
);
4296 g_cond_wait(&pass_data
.cond
, &pass_data
.mutex
);
4297 g_cond_clear(&pass_data
.cond
);
4298 g_mutex_unlock(&pass_data
.mutex
);
4299 g_mutex_clear(&pass_data
.mutex
);
4305 static void register_proxy_page(void)
4307 static gchar
*path
[3];
4309 path
[0] = _("Account");
4310 path
[1] = _("Proxy");
4313 proxy_page
.page
.path
= path
;
4314 proxy_page
.page
.weight
= 1000.0;
4315 proxy_page
.page
.create_widget
= proxy_create_widget_func
;
4316 proxy_page
.page
.destroy_widget
= proxy_destroy_widget_func
;
4317 proxy_page
.page
.save_page
= proxy_save_func
;
4318 proxy_page
.page
.can_close
= proxy_can_close_func
;
4320 prefs_account_register_page((PrefsPage
*) &proxy_page
);
4323 static void register_advanced_page(void)
4325 static gchar
*path
[3];
4327 path
[0] = _("Account");
4328 path
[1] = _("Advanced");
4331 advanced_page
.page
.path
= path
;
4332 advanced_page
.page
.weight
= 1000.0;
4333 advanced_page
.page
.create_widget
= advanced_create_widget_func
;
4334 advanced_page
.page
.destroy_widget
= advanced_destroy_widget_func
;
4335 advanced_page
.page
.save_page
= advanced_save_func
;
4336 advanced_page
.page
.can_close
= advanced_can_close_func
;
4338 prefs_account_register_page((PrefsPage
*) &advanced_page
);
4341 void prefs_account_init()
4343 register_basic_page();
4344 register_receive_page();
4345 register_send_page();
4346 register_compose_page();
4347 register_templates_page();
4348 register_privacy_page();
4350 register_ssl_page();
4351 hooks_register_hook(SSLCERT_GET_CLIENT_CERT_HOOKLIST
, sslcert_get_client_cert_hook
, NULL
);
4352 hooks_register_hook(SSL_CERT_GET_PASSWORD
, sslcert_get_password
, NULL
);
4354 register_proxy_page();
4356 register_oauth2_page();
4358 register_advanced_page();
4361 PrefsAccount
*prefs_account_new(void)
4363 PrefsAccount
*ac_prefs
;
4365 ac_prefs
= g_new0(PrefsAccount
, 1);
4366 memset(&tmp_ac_prefs
, 0, sizeof(PrefsAccount
));
4367 prefs_set_default(basic_param
);
4368 prefs_set_default(receive_param
);
4369 prefs_set_default(send_param
);
4370 prefs_set_default(oauth2_param
);
4371 prefs_set_default(compose_param
);
4372 prefs_set_default(templates_param
);
4373 prefs_set_default(privacy_param
);
4374 prefs_set_default(ssl_param
);
4375 prefs_set_default(proxy_param
);
4376 prefs_set_default(advanced_param
);
4377 *ac_prefs
= tmp_ac_prefs
;
4378 ac_prefs
->account_id
= prefs_account_get_new_id();
4380 ac_prefs
->privacy_prefs
= g_hash_table_new(g_str_hash
, g_str_equal
);
4385 PrefsAccount
*prefs_account_new_from_config(const gchar
*label
)
4387 const gchar
*p
= label
;
4390 gchar
**strv
, **cur
;
4392 PrefsAccount
*ac_prefs
;
4394 cm_return_val_if_fail(label
!= NULL
, NULL
);
4396 ac_prefs
= g_new0(PrefsAccount
, 1);
4398 /* Load default values to tmp_ac_prefs first, ... */
4399 memset(&tmp_ac_prefs
, 0, sizeof(PrefsAccount
));
4400 prefs_set_default(basic_param
);
4401 prefs_set_default(receive_param
);
4402 prefs_set_default(send_param
);
4403 prefs_set_default(oauth2_param
);
4404 prefs_set_default(compose_param
);
4405 prefs_set_default(templates_param
);
4406 prefs_set_default(privacy_param
);
4407 prefs_set_default(ssl_param
);
4408 prefs_set_default(advanced_param
);
4410 /* ... overriding them with values from stored config file. */
4411 rcpath
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
, ACCOUNT_RC
, NULL
);
4412 prefs_read_config(basic_param
, label
, rcpath
, NULL
);
4413 prefs_read_config(receive_param
, label
, rcpath
, NULL
);
4414 prefs_read_config(send_param
, label
, rcpath
, NULL
);
4415 prefs_read_config(oauth2_param
, label
, rcpath
, NULL
);
4416 prefs_read_config(compose_param
, label
, rcpath
, NULL
);
4417 prefs_read_config(templates_param
, label
, rcpath
, NULL
);
4418 prefs_read_config(privacy_param
, label
, rcpath
, NULL
);
4419 prefs_read_config(ssl_param
, label
, rcpath
, NULL
);
4420 prefs_read_config(proxy_param
, label
, rcpath
, NULL
);
4421 prefs_read_config(advanced_param
, label
, rcpath
, NULL
);
4424 *ac_prefs
= tmp_ac_prefs
;
4426 while (*p
&& !g_ascii_isdigit(*p
)) p
++;
4428 if (id
< 0) g_warning("wrong account id: %d", id
);
4429 ac_prefs
->account_id
= id
;
4431 /* Now parse privacy_prefs. */
4432 ac_prefs
->privacy_prefs
= g_hash_table_new(g_str_hash
, g_str_equal
);
4433 if (privacy_prefs
!= NULL
) {
4434 strv
= g_strsplit(privacy_prefs
, ",", 0);
4435 for (cur
= strv
; *cur
!= NULL
; cur
++) {
4436 gchar
*encvalue
, *tmp
;
4438 encvalue
= strchr(*cur
, '=');
4439 if (encvalue
== NULL
)
4444 tmp
= g_base64_decode_zero(encvalue
, &len
);
4446 g_hash_table_insert(ac_prefs
->privacy_prefs
, g_strdup(*cur
), tmp
);
4451 g_free(privacy_prefs
);
4452 privacy_prefs
= NULL
;
4455 /* For older configurations, move stored passwords into the
4456 * password store. */
4457 gboolean passwords_migrated
= FALSE
;
4459 if (ac_prefs
->passwd
!= NULL
&& strlen(ac_prefs
->passwd
) > 1) {
4460 passwd_store_set_account(ac_prefs
->account_id
,
4461 PWS_ACCOUNT_RECV
, ac_prefs
->passwd
, TRUE
);
4462 passwords_migrated
= TRUE
;
4464 if (ac_prefs
->smtp_passwd
!= NULL
&& strlen(ac_prefs
->smtp_passwd
) > 1) {
4465 passwd_store_set_account(ac_prefs
->account_id
,
4466 PWS_ACCOUNT_SEND
, ac_prefs
->smtp_passwd
, TRUE
);
4467 passwords_migrated
= TRUE
;
4469 if (ac_prefs
->in_ssl_client_cert_pass
!= NULL
4470 && strlen(ac_prefs
->in_ssl_client_cert_pass
) > 1) {
4471 passwd_store_set_account(ac_prefs
->account_id
,
4472 PWS_ACCOUNT_RECV_CERT
, ac_prefs
->in_ssl_client_cert_pass
, TRUE
);
4473 passwords_migrated
= TRUE
;
4475 if (ac_prefs
->out_ssl_client_cert_pass
!= NULL
4476 && strlen(ac_prefs
->out_ssl_client_cert_pass
) > 1) {
4477 passwd_store_set_account(ac_prefs
->account_id
,
4478 PWS_ACCOUNT_SEND_CERT
, ac_prefs
->out_ssl_client_cert_pass
, TRUE
);
4479 passwords_migrated
= TRUE
;
4482 /* Write out password store to file immediately, to prevent
4484 if (passwords_migrated
)
4485 passwd_store_write_config();
4487 ac_prefs
->receive_in_progress
= FALSE
;
4489 prefs_custom_header_read_config(ac_prefs
);
4491 /* Start the auto-check interval, if needed. */
4492 if (!ac_prefs
->autochk_use_default
&& ac_prefs
->autochk_use_custom
4493 && ac_prefs
->autochk_itv
> PREFS_RECV_AUTOCHECK_MIN_INTERVAL
) {
4494 inc_account_autocheck_timer_set_interval(ac_prefs
);
4500 static void create_privacy_prefs(gpointer key
, gpointer _value
, gpointer user_data
)
4502 GString
*str
= (GString
*) user_data
;
4504 gchar
*value
= (gchar
*) _value
;
4507 g_string_append_c(str
, ',');
4509 encvalue
= g_base64_encode(value
, strlen(value
));
4510 g_string_append_printf(str
, "%s=%s", (gchar
*) key
, encvalue
);
4514 #define WRITE_PARAM(PARAM_TABLE) \
4515 if (prefs_write_param(PARAM_TABLE, pfile->fp) < 0) { \
4516 g_warning("failed to write configuration to file"); \
4517 prefs_file_close_revert(pfile); \
4518 g_free(privacy_prefs); \
4519 privacy_prefs = NULL; \
4524 void prefs_account_write_config_all(GList
*account_list
)
4530 rcpath
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
, ACCOUNT_RC
, NULL
);
4531 if ((pfile
= prefs_write_open(rcpath
)) == NULL
) {
4536 for (cur
= account_list
; cur
!= NULL
; cur
= cur
->next
) {
4539 tmp_ac_prefs
= *(PrefsAccount
*)cur
->data
;
4540 if (fprintf(pfile
->fp
, "[Account: %d]\n",
4541 tmp_ac_prefs
.account_id
) <= 0) {
4547 str
= g_string_sized_new(32);
4548 g_hash_table_foreach(tmp_ac_prefs
.privacy_prefs
, create_privacy_prefs
, str
);
4549 privacy_prefs
= str
->str
;
4550 g_string_free(str
, FALSE
);
4552 WRITE_PARAM(basic_param
)
4553 WRITE_PARAM(receive_param
)
4554 WRITE_PARAM(send_param
)
4555 WRITE_PARAM(oauth2_param
)
4556 WRITE_PARAM(compose_param
)
4557 WRITE_PARAM(templates_param
)
4558 WRITE_PARAM(privacy_param
)
4559 WRITE_PARAM(ssl_param
)
4560 WRITE_PARAM(proxy_param
)
4561 WRITE_PARAM(advanced_param
)
4563 g_free(privacy_prefs
);
4564 privacy_prefs
= NULL
;
4567 if (claws_fputc('\n', pfile
->fp
) == EOF
) {
4568 FILE_OP_ERROR(rcpath
, "claws_fputc");
4569 prefs_file_close_revert(pfile
);
4577 if (prefs_file_close(pfile
) < 0)
4578 g_warning("failed to write configuration to file");
4580 passwd_store_write_config();
4584 static gboolean
free_privacy_prefs(gpointer key
, gpointer value
, gpointer user_data
)
4592 void prefs_account_free(PrefsAccount
*ac_prefs
)
4594 if (!ac_prefs
) return;
4596 g_hash_table_foreach_remove(ac_prefs
->privacy_prefs
, free_privacy_prefs
, NULL
);
4598 tmp_ac_prefs
= *ac_prefs
;
4599 prefs_free(basic_param
);
4600 prefs_free(receive_param
);
4601 prefs_free(send_param
);
4602 prefs_free(oauth2_param
);
4603 prefs_free(compose_param
);
4604 prefs_free(templates_param
);
4605 prefs_free(privacy_param
);
4606 prefs_free(ssl_param
);
4607 prefs_free(proxy_param
);
4608 prefs_free(advanced_param
);
4611 const gchar
*prefs_account_get_privacy_prefs(PrefsAccount
*account
, gchar
*id
)
4613 return g_hash_table_lookup(account
->privacy_prefs
, id
);
4616 void prefs_account_set_privacy_prefs(PrefsAccount
*account
, gchar
*id
, gchar
*new_value
)
4618 gchar
*orig_key
= NULL
, *value
;
4620 if (g_hash_table_lookup_extended(account
->privacy_prefs
, id
, (gpointer
*)(gchar
*) &orig_key
, (gpointer
*)(gchar
*) &value
)) {
4621 g_hash_table_remove(account
->privacy_prefs
, id
);
4627 if (new_value
!= NULL
)
4628 g_hash_table_insert(account
->privacy_prefs
, g_strdup(id
), g_strdup(new_value
));
4631 static gint
prefs_account_get_new_id(void)
4635 static gint last_id
= 0;
4637 for (ac_list
= account_get_list(); ac_list
!= NULL
;
4638 ac_list
= ac_list
->next
) {
4639 ac
= (PrefsAccount
*)ac_list
->data
;
4640 if (last_id
< ac
->account_id
)
4641 last_id
= ac
->account_id
;
4647 static void destroy_dialog(gpointer data
)
4649 PrefsAccount
*ac_prefs
= (PrefsAccount
*) data
;
4651 gboolean update_fld_list
= FALSE
;
4652 if (ac_prefs
->protocol
== A_IMAP4
&& !new_account
) {
4653 if ((&tmp_ac_prefs
)->imap_subsonly
!= ac_prefs
->imap_subsonly
) {
4654 update_fld_list
= TRUE
;
4657 *ac_prefs
= tmp_ac_prefs
;
4658 if (update_fld_list
)
4659 folderview_rescan_tree(ac_prefs
->folder
, FALSE
);
4661 inc_account_autocheck_timer_set_interval(ac_prefs
);
4663 } else /* the customhdr_list may have changed, update it anyway */
4664 ac_prefs
->customhdr_list
= (&tmp_ac_prefs
)->customhdr_list
;
4670 PrefsAccount
*prefs_account_open(PrefsAccount
*ac_prefs
, gboolean
*dirty
)
4674 if (prefs_rc_is_readonly(ACCOUNT_RC
))
4677 debug_print("Opening account preferences window...\n");
4684 ac_prefs
= prefs_account_new();
4687 new_account
= FALSE
;
4690 title
= g_strdup (_("Preferences for new account"));
4692 title
= g_strdup_printf (_("%s - Account preferences"),
4693 ac_prefs
->account_name
);
4695 prefswindow_open_full(title
, prefs_pages
, ac_prefs
, destroy_dialog
,
4696 &prefs_common
.editaccountwin_width
, &prefs_common
.editaccountwin_height
,
4697 TRUE
, NULL
, NULL
, NULL
);
4703 if (!cancelled
&& dirty
!= NULL
)
4705 if (cancelled
&& new_account
)
4708 if (ac_prefs
->recv_server
)
4709 g_strstrip(ac_prefs
->recv_server
);
4710 if (ac_prefs
->smtp_server
)
4711 g_strstrip(ac_prefs
->smtp_server
);
4712 if (ac_prefs
->nntp_server
)
4713 g_strstrip(ac_prefs
->nntp_server
);
4719 static void crosspost_color_toggled(void)
4723 is_active
= gtk_toggle_button_get_active
4724 (GTK_TOGGLE_BUTTON(advanced_page
.crosspost_checkbtn
));
4725 gtk_widget_set_sensitive(advanced_page
.crosspost_colormenu
, is_active
);
4728 static void prefs_account_crosspost_set_data_from_colormenu(PrefParam
*pparam
)
4731 GtkWidget
*combobox
= *pparam
->widget
;
4733 color
= colorlabel_get_combobox_colormenu_active(GTK_COMBO_BOX(combobox
));
4734 *((gint
*)pparam
->data
) = color
;
4737 static void prefs_account_crosspost_set_colormenu(PrefParam
*pparam
)
4739 gint color
= *((gint
*)pparam
->data
);
4740 GtkWidget
*combobox
= *pparam
->widget
;
4742 colorlabel_set_combobox_colormenu_active(GTK_COMBO_BOX(combobox
), color
);
4745 static void pop_bfr_smtp_tm_set_sens(GtkWidget
*widget
, gpointer data
)
4747 gtk_widget_set_sensitive(send_page
.pop_bfr_smtp_tm_spinbtn
,
4748 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(send_page
.pop_bfr_smtp_checkbtn
)));
4749 gtk_widget_set_sensitive(send_page
.pop_auth_timeout_lbl
,
4750 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(send_page
.pop_bfr_smtp_checkbtn
)));
4751 gtk_widget_set_sensitive(send_page
.pop_auth_minutes_lbl
,
4752 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(send_page
.pop_bfr_smtp_checkbtn
)));
4755 static void prefs_account_select_folder_cb(GtkWidget
*widget
, gpointer data
)
4760 item
= foldersel_folder_sel(NULL
, FOLDER_SEL_COPY
, NULL
, FALSE
, NULL
);
4761 if (item
&& item
->path
) {
4762 id
= folder_item_get_identifier(item
);
4764 gtk_entry_set_text(GTK_ENTRY(data
), id
);
4770 #if (defined USE_GNUTLS)
4771 static void auto_configure_cb (GtkWidget
*widget
, gpointer data
)
4773 gchar
*address
= NULL
;
4774 AutoConfigureData
*recv_data
;
4775 AutoConfigureData
*send_data
;
4776 static GCancellable
*recv_cancel
= NULL
;
4777 static GCancellable
*send_cancel
= NULL
;
4778 RecvProtocol protocol
;
4779 struct BasicProtocol
*protocol_optmenu
= (struct BasicProtocol
*) basic_page
.protocol_optmenu
;
4780 GtkWidget
*optmenu
= protocol_optmenu
->combobox
;
4783 recv_cancel
= g_cancellable_new();
4784 send_cancel
= g_cancellable_new();
4787 if (widget
== basic_page
.auto_configure_cancel_btn
) {
4788 g_cancellable_cancel(recv_cancel
);
4789 g_cancellable_cancel(send_cancel
);
4790 g_object_unref(recv_cancel
);
4791 g_object_unref(send_cancel
);
4797 protocol
= combobox_get_active_data(GTK_COMBO_BOX(optmenu
));
4799 address
= gtk_editable_get_chars(GTK_EDITABLE(basic_page
.addr_entry
), 0, -1);
4801 if (strchr(address
, '@') == NULL
) {
4803 gtk_label_set_text(GTK_LABEL(basic_page
.auto_configure_lbl
),
4804 _("Failed (wrong address)"));
4808 if (protocol
== A_POP3
|| protocol
== A_IMAP4
) {
4809 recv_data
= g_new0(AutoConfigureData
, 1);
4810 recv_data
->configure_button
= GTK_BUTTON(basic_page
.auto_configure_btn
);
4811 recv_data
->cancel_button
= GTK_BUTTON(basic_page
.auto_configure_cancel_btn
);
4812 recv_data
->info_label
= GTK_LABEL(basic_page
.auto_configure_lbl
);
4813 recv_data
->cancel
= recv_cancel
;
4816 recv_data
->ssl_service
= "pop3s";
4817 recv_data
->tls_service
= "pop3";
4818 recv_data
->address
= g_strdup(address
);
4819 recv_data
->hostname_entry
= GTK_ENTRY(basic_page
.recvserv_entry
);
4820 recv_data
->set_port
= GTK_TOGGLE_BUTTON(advanced_page
.popport_checkbtn
);
4821 recv_data
->port
= GTK_SPIN_BUTTON(advanced_page
.popport_spinbtn
);
4822 recv_data
->tls_checkbtn
= GTK_TOGGLE_BUTTON(ssl_page
.pop_starttls_radiobtn
);
4823 recv_data
->ssl_checkbtn
= GTK_TOGGLE_BUTTON(ssl_page
.pop_ssltunnel_radiobtn
);
4824 recv_data
->default_port
= 110;
4825 recv_data
->default_ssl_port
= 995;
4826 recv_data
->uid_entry
= GTK_ENTRY(basic_page
.uid_entry
);
4829 recv_data
->ssl_service
= "imaps";
4830 recv_data
->tls_service
= "imap";
4831 recv_data
->address
= g_strdup(address
);
4832 recv_data
->hostname_entry
= GTK_ENTRY(basic_page
.recvserv_entry
);
4833 recv_data
->set_port
= GTK_TOGGLE_BUTTON(advanced_page
.imapport_checkbtn
);
4834 recv_data
->port
= GTK_SPIN_BUTTON(advanced_page
.imapport_spinbtn
);
4835 recv_data
->tls_checkbtn
= GTK_TOGGLE_BUTTON(ssl_page
.imap_starttls_radiobtn
);
4836 recv_data
->ssl_checkbtn
= GTK_TOGGLE_BUTTON(ssl_page
.imap_ssltunnel_radiobtn
);
4837 recv_data
->default_port
= 143;
4838 recv_data
->default_ssl_port
= 993;
4839 recv_data
->uid_entry
= GTK_ENTRY(basic_page
.uid_entry
);
4842 cm_return_if_fail(FALSE
);
4844 auto_configure_service(recv_data
);
4847 send_data
= g_new0(AutoConfigureData
, 1);
4848 send_data
->configure_button
= GTK_BUTTON(basic_page
.auto_configure_btn
);
4849 send_data
->cancel_button
= GTK_BUTTON(basic_page
.auto_configure_cancel_btn
);
4850 send_data
->info_label
= GTK_LABEL(basic_page
.auto_configure_lbl
);
4851 send_data
->cancel
= send_cancel
;
4853 send_data
->ssl_service
= NULL
;
4854 send_data
->tls_service
= "submission";
4855 send_data
->address
= g_strdup(address
);
4856 send_data
->hostname_entry
= GTK_ENTRY(basic_page
.smtpserv_entry
);
4857 send_data
->set_port
= GTK_TOGGLE_BUTTON(advanced_page
.smtpport_checkbtn
);
4858 send_data
->port
= GTK_SPIN_BUTTON(advanced_page
.smtpport_spinbtn
);
4859 send_data
->tls_checkbtn
= GTK_TOGGLE_BUTTON(ssl_page
.smtp_starttls_radiobtn
);
4860 send_data
->ssl_checkbtn
= GTK_TOGGLE_BUTTON(ssl_page
.smtp_ssltunnel_radiobtn
);
4861 send_data
->default_port
= 25;
4862 send_data
->default_ssl_port
= -1;
4863 send_data
->uid_entry
= NULL
;
4864 send_data
->auth_checkbtn
= GTK_TOGGLE_BUTTON(send_page
.smtp_auth_checkbtn
);
4866 auto_configure_service(send_data
);
4872 static void prefs_account_sigfile_radiobtn_cb(GtkWidget
*widget
, gpointer data
)
4874 gtk_widget_set_sensitive(GTK_WIDGET(signature_browse_button
), TRUE
);
4875 gtk_widget_set_sensitive(GTK_WIDGET(signature_edit_button
), TRUE
);
4878 static void prefs_account_sigcmd_radiobtn_cb(GtkWidget
*widget
, gpointer data
)
4880 gtk_widget_set_sensitive(GTK_WIDGET(signature_browse_button
), FALSE
);
4881 gtk_widget_set_sensitive(GTK_WIDGET(signature_edit_button
), FALSE
);
4884 static void prefs_account_signature_browse_cb(GtkWidget
*widget
, gpointer data
)
4887 gchar
*utf8_filename
;
4889 filename
= filesel_select_file_open(_("Select signature file"), NULL
);
4890 if (!filename
) return;
4892 utf8_filename
= g_filename_to_utf8(filename
, -1, NULL
, NULL
, NULL
);
4893 if (!utf8_filename
) {
4894 g_warning("prefs_account_signature_browse_cb(): failed to convert character set");
4895 utf8_filename
= g_strdup(filename
);
4897 gtk_entry_set_text(GTK_ENTRY(entry_sigpath
), utf8_filename
);
4898 g_free(utf8_filename
);
4902 static void prefs_account_in_cert_browse_cb(GtkWidget
*widget
, gpointer data
)
4905 gchar
*utf8_filename
;
4907 filename
= filesel_select_file_open(_("Select certificate file"), NULL
);
4908 if (!filename
) return;
4910 utf8_filename
= g_filename_to_utf8(filename
, -1, NULL
, NULL
, NULL
);
4911 if (!utf8_filename
) {
4912 g_warning("prefs_account_cert_browse_cb(): failed to convert character set");
4913 utf8_filename
= g_strdup(filename
);
4915 gtk_entry_set_text(GTK_ENTRY(entry_in_cert_file
), utf8_filename
);
4916 g_free(utf8_filename
);
4919 static void prefs_account_out_cert_browse_cb(GtkWidget
*widget
, gpointer data
)
4922 gchar
*utf8_filename
;
4924 filename
= filesel_select_file_open(_("Select certificate file"), NULL
);
4925 if (!filename
) return;
4927 utf8_filename
= g_filename_to_utf8(filename
, -1, NULL
, NULL
, NULL
);
4928 if (!utf8_filename
) {
4929 g_warning("prefs_account_cert_browse_cb(): failed to convert character set");
4930 utf8_filename
= g_strdup(filename
);
4932 gtk_entry_set_text(GTK_ENTRY(entry_out_cert_file
), utf8_filename
);
4933 g_free(utf8_filename
);
4937 static void prefs_account_signature_edit_cb(GtkWidget
*widget
, gpointer data
)
4939 const gchar
*sigpath
= gtk_entry_get_text(GTK_ENTRY(data
));
4940 if (!is_file_exist(sigpath
))
4941 str_write_to_file(sigpath
, "", TRUE
);
4942 open_txt_editor(sigpath
, prefs_common_get_ext_editor_cmd());
4945 static void prefs_account_edit_custom_header(void)
4947 prefs_custom_header_open(&tmp_ac_prefs
);
4950 static void prefs_account_enum_set_data_from_radiobtn(PrefParam
*pparam
)
4952 GtkRadioButton
*radiobtn
;
4955 radiobtn
= GTK_RADIO_BUTTON (*pparam
->widget
);
4956 group
= gtk_radio_button_get_group (radiobtn
);
4957 while (group
!= NULL
) {
4958 GtkToggleButton
*btn
= GTK_TOGGLE_BUTTON (group
->data
);
4959 if (gtk_toggle_button_get_active (btn
)) {
4960 *((gint
*)pparam
->data
) = GPOINTER_TO_INT
4961 (g_object_get_data (G_OBJECT (btn
), MENU_VAL_ID
));
4964 group
= group
->next
;
4968 static void prefs_account_enum_set_radiobtn(PrefParam
*pparam
)
4970 GtkRadioButton
*radiobtn
;
4974 data
= GINT_TO_POINTER (*((gint
*)pparam
->data
));
4975 radiobtn
= GTK_RADIO_BUTTON (*pparam
->widget
);
4976 group
= gtk_radio_button_get_group (radiobtn
);
4977 while (group
!= NULL
) {
4978 GtkToggleButton
*btn
= GTK_TOGGLE_BUTTON (group
->data
);
4979 gpointer data1
= g_object_get_data (G_OBJECT (btn
), MENU_VAL_ID
);
4980 if (data1
== data
) {
4981 gtk_toggle_button_set_active (btn
, TRUE
);
4984 group
= group
->next
;
4988 static void prefs_account_protocol_set_data_from_optmenu(PrefParam
*pparam
)
4990 struct BasicProtocol
*protocol_optmenu
=
4991 (struct BasicProtocol
*)*pparam
->widget
;
4992 GtkWidget
*optmenu
= protocol_optmenu
->combobox
;
4994 *((RecvProtocol
*)pparam
->data
) =
4995 combobox_get_active_data(GTK_COMBO_BOX(optmenu
));
4998 static void prefs_account_protocol_set_optmenu(PrefParam
*pparam
)
5000 RecvProtocol protocol
;
5001 struct BasicProtocol
*protocol_optmenu
=
5002 (struct BasicProtocol
*)*pparam
->widget
;
5003 GtkWidget
*optmenu
= protocol_optmenu
->combobox
;
5004 GtkWidget
*optlabel
= protocol_optmenu
->label
;
5005 GtkWidget
*descrlabel
= protocol_optmenu
->descrlabel
;
5006 gchar
*label
= NULL
;
5008 protocol
= *((RecvProtocol
*)pparam
->data
);
5010 /* Set combobox to correct value even if it will be hidden, so
5011 * we won't break existing accounts when saving. */
5012 combobox_select_by_data(GTK_COMBO_BOX(optmenu
), protocol
);
5014 /* Set up widgets accordingly */
5016 gtk_label_set_text(GTK_LABEL(descrlabel
), _("Protocol"));
5017 gtk_widget_hide(optlabel
);
5018 gtk_widget_show(optmenu
);
5020 gtk_label_set_text(GTK_LABEL(descrlabel
), _("Protocol:"));
5021 label
= g_markup_printf_escaped("<b>%s</b>", protocol_names
[protocol
]);
5022 gtk_label_set_markup(GTK_LABEL(optlabel
), label
);
5024 gtk_widget_hide(optmenu
);
5025 gtk_widget_show(optlabel
);
5026 #ifndef HAVE_LIBETPAN
5027 if (protocol
== A_IMAP4
|| protocol
== A_NNTP
) {
5028 gtk_widget_show(protocol_optmenu
->no_imap_warn_icon
);
5029 gtk_widget_show(protocol_optmenu
->no_imap_warn_label
);
5031 gtk_widget_hide(protocol_optmenu
->no_imap_warn_icon
);
5032 gtk_widget_hide(protocol_optmenu
->no_imap_warn_label
);
5035 if (protocol
== A_IMAP4
) {
5037 gtk_toggle_button_set_active(
5038 GTK_TOGGLE_BUTTON(send_page
.msgid_checkbtn
),
5040 gtk_widget_hide(send_page
.msgid_checkbtn
);
5042 gtk_widget_show(send_page
.msgid_checkbtn
);
5044 gtk_widget_show(send_page
.xmailer_checkbtn
);
5048 static void prefs_account_imap_auth_type_set_data_from_optmenu(PrefParam
*pparam
)
5050 *((RecvProtocol
*)pparam
->data
) =
5051 combobox_get_active_data(GTK_COMBO_BOX(*pparam
->widget
));
5054 static void prefs_account_imap_auth_type_set_optmenu(PrefParam
*pparam
)
5056 IMAPAuthType type
= *((IMAPAuthType
*)pparam
->data
);
5057 GtkComboBox
*optmenu
= GTK_COMBO_BOX(*pparam
->widget
);
5059 combobox_select_by_data(optmenu
, type
);
5062 static void prefs_account_smtp_auth_type_set_data_from_optmenu(PrefParam
*pparam
)
5064 *((RecvProtocol
*)pparam
->data
) =
5065 combobox_get_active_data(GTK_COMBO_BOX(*pparam
->widget
));
5068 static void prefs_account_smtp_auth_type_set_optmenu(PrefParam
*pparam
)
5070 SMTPAuthType type
= *((SMTPAuthType
*)pparam
->data
);
5071 GtkComboBox
*optmenu
= GTK_COMBO_BOX(*pparam
->widget
);
5073 combobox_select_by_data(optmenu
, type
);
5076 static void prefs_account_set_autochk_interval_from_widgets(PrefParam
*pparam
)
5078 struct AutocheckWidgets
*autochk_widgets
=
5079 (struct AutocheckWidgets
*)*pparam
->widget
;
5081 *(gint
*)pparam
->data
=
5082 (3600 * gtk_spin_button_get_value_as_int(
5083 GTK_SPIN_BUTTON(autochk_widgets
->autochk_hour_spinbtn
)))
5084 + (60 * gtk_spin_button_get_value_as_int(
5085 GTK_SPIN_BUTTON(autochk_widgets
->autochk_min_spinbtn
)))
5086 + gtk_spin_button_get_value_as_int(
5087 GTK_SPIN_BUTTON(autochk_widgets
->autochk_sec_spinbtn
));
5090 static void prefs_account_pop_auth_type_set_data_from_optmenu(PrefParam
*pparam
)
5092 *((RecvProtocol
*)pparam
->data
) =
5093 combobox_get_active_data(GTK_COMBO_BOX(*pparam
->widget
));
5096 static void prefs_account_pop_auth_type_set_optmenu(PrefParam
*pparam
)
5098 POPAuthType type
= *((POPAuthType
*)pparam
->data
);
5099 GtkComboBox
*optmenu
= GTK_COMBO_BOX(*pparam
->widget
);
5101 combobox_select_by_data(optmenu
, type
);
5105 static void prefs_account_oauth2_provider_set_data_from_optmenu(PrefParam
*pparam
)
5107 *((Oauth2Service
*)pparam
->data
) =
5108 combobox_get_active_data(GTK_COMBO_BOX(*pparam
->widget
));
5111 static void prefs_account_oauth2_provider_set_optmenu(PrefParam
*pparam
)
5113 Oauth2Service type
= *((Oauth2Service
*)pparam
->data
);
5114 GtkComboBox
*optmenu
= GTK_COMBO_BOX(*pparam
->widget
);
5116 combobox_select_by_data(optmenu
, type
);
5119 static void prefs_account_oauth2_set_auth_sensitivity(void)
5121 const gchar
*authcode
= gtk_entry_get_text((GtkEntry
*)oauth2_page
.oauth2_authcode_entry
);
5122 gchar
*trim_text
= g_strdup(authcode
);
5123 g_strstrip(trim_text
);
5124 gtk_widget_set_sensitive(oauth2_page
.oauth2_authorise_btn
, (*trim_text
!= 0));
5128 static void prefs_account_oauth2_set_sensitivity(void)
5130 struct BasicProtocol
*protocol_optmenu
= (struct BasicProtocol
*)oauth2_page
.protocol_optmenu
;
5131 GtkWidget
*optmenu
= protocol_optmenu
->combobox
;
5132 Oauth2Service service
;
5134 service
= combobox_get_active_data(GTK_COMBO_BOX(optmenu
));
5136 if(service
== OAUTH2AUTH_NONE
)
5137 gtk_widget_set_sensitive(oauth2_page
.oauth2_sensitive
, FALSE
);
5139 gtk_widget_set_sensitive(oauth2_page
.oauth2_sensitive
, TRUE
);
5142 static void prefs_account_oauth2_copy_url(GtkButton
*button
, gpointer data
)
5144 struct BasicProtocol
*protocol_optmenu
= (struct BasicProtocol
*)oauth2_page
.protocol_optmenu
;
5146 GtkWidget
*optmenu
= protocol_optmenu
->combobox
;
5149 GtkClipboard
*clip
, *clip2
;
5152 url
= g_malloc(OAUTH2BUFSIZE
+1);
5153 Oauth2Service service
;
5154 const gchar
* custom_client_id
= NULL
;
5155 struct Oauth2Listener
*oauth2_listener_data
;
5157 service
= combobox_get_active_data(GTK_COMBO_BOX(optmenu
));
5158 custom_client_id
= gtk_entry_get_text((GtkEntry
*)oauth2_page
.oauth2_client_id_entry
);
5160 oauth2_authorisation_url(service
, &url
, custom_client_id
);
5162 win
= gtk_widget_get_toplevel (optmenu
);
5165 clip
= gtk_widget_get_clipboard (win
, GDK_SELECTION_PRIMARY
);
5166 clip2
= gtk_widget_get_clipboard (win
, GDK_SELECTION_CLIPBOARD
);
5167 gtk_clipboard_set_text (clip
, url
, len
);
5168 gtk_clipboard_set_text (clip2
, url
, len
);
5170 if (strcmp(gtk_button_get_label(button
), "Copy link") != 0)
5171 open_uri(url
, prefs_common_get_uri_cmd());
5175 //Start listener task for authorisation reply using a separate task
5176 //Avoids hanging while we wait, and to allow cancellation of the process
5177 //If task already exists gracefully close it
5178 if(oauth2_listener_task
){
5179 debug_print("Closing oauth2 listener task\n");
5180 oauth2_listener_cancel
= 1;
5181 while (oauth2_listener_closed
== 0)
5182 gtk_main_iteration();
5185 debug_print("Starting oauth2 listener task\n");
5187 oauth2_listener_data
= g_new(struct Oauth2Listener
, 1);
5188 oauth2_listener_data
->success
= FALSE
;
5189 oauth2_listener_data
->trim_text
= NULL
;
5190 oauth2_listener_data
->service
= combobox_get_active_data(GTK_COMBO_BOX(optmenu
));
5191 oauth2_listener_data
->OAUTH2Data
= g_malloc(sizeof(* oauth2_listener_data
->OAUTH2Data
));
5192 oauth2_init (oauth2_listener_data
->OAUTH2Data
);
5193 oauth2_listener_data
->OAUTH2Data
->custom_client_secret
=
5194 g_strdup(gtk_entry_get_text((GtkEntry
*)oauth2_page
.oauth2_client_secret_entry
));
5195 oauth2_listener_data
->OAUTH2Data
->custom_client_id
=
5196 g_strdup(gtk_entry_get_text((GtkEntry
*)oauth2_page
.oauth2_client_id_entry
));
5198 oauth2_listener_cancel
= 0;
5199 oauth2_listener_closed
= 0;
5201 oauth2_listener_task
= g_task_new(NULL
, NULL
, prefs_account_oauth2_callback
, oauth2_listener_data
);
5202 g_task_set_task_data(oauth2_listener_task
, oauth2_listener_data
, NULL
);
5203 g_task_run_in_thread(oauth2_listener_task
, prefs_account_oauth2_listener
);
5206 static void prefs_account_oauth2_obtain_tokens(GtkButton
*button
, gpointer data
)
5208 struct BasicProtocol
*protocol_optmenu
= (struct BasicProtocol
*)oauth2_page
.protocol_optmenu
;
5210 GtkWidget
*optmenu
= protocol_optmenu
->combobox
;
5211 Oauth2Service service
;
5212 OAUTH2Data
*OAUTH2Data
= g_malloc(sizeof(* OAUTH2Data
));
5213 const gchar
*authcode
= gtk_entry_get_text ((GtkEntry
*)oauth2_page
.oauth2_authcode_entry
);
5214 gchar
*trim_text
= g_strdup(authcode
);
5215 g_strstrip(trim_text
);
5218 oauth2_init (OAUTH2Data
);
5221 OAUTH2Data
->custom_client_secret
=
5222 g_strdup(gtk_entry_get_text((GtkEntry
*)oauth2_page
.oauth2_client_secret_entry
));
5223 OAUTH2Data
->custom_client_id
=
5224 g_strdup(gtk_entry_get_text((GtkEntry
*)oauth2_page
.oauth2_client_id_entry
));
5227 service
= combobox_get_active_data(GTK_COMBO_BOX(optmenu
));
5228 ret
= oauth2_obtain_tokens (service
, OAUTH2Data
, trim_text
);
5231 if(OAUTH2Data
->refresh_token
!= NULL
){
5232 passwd_store_set_account(tmp_ac_prefs
.account_id
,
5233 PWS_ACCOUNT_OAUTH2_REFRESH
, OAUTH2Data
->refresh_token
, FALSE
);
5234 log_message(LOG_PROTOCOL
, "OAuth2 refresh token stored\n");
5237 if(OAUTH2Data
->access_token
!= NULL
){
5238 passwd_store_set_account(tmp_ac_prefs
.account_id
,
5239 PWS_ACCOUNT_RECV
, OAUTH2Data
->access_token
, FALSE
);
5241 passwd_store_set_account(tmp_ac_prefs
.account_id
,
5242 PWS_ACCOUNT_SEND
, OAUTH2Data
->access_token
, FALSE
);
5243 log_message(LOG_PROTOCOL
, "OAuth2 access token stored\n");
5245 gtk_entry_set_text(GTK_ENTRY(basic_page
.pass_entry
), OAUTH2Data
->access_token
);
5246 gtk_entry_set_text(GTK_ENTRY(send_page
.smtp_pass_entry
), OAUTH2Data
->access_token
);
5249 if(OAUTH2Data
->expiry_str
!= NULL
){
5250 passwd_store_set_account(tmp_ac_prefs
.account_id
,
5251 PWS_ACCOUNT_OAUTH2_EXPIRY
, OAUTH2Data
->expiry_str
, FALSE
);
5252 log_message(LOG_PROTOCOL
, "OAuth2 access token expiry stored\n");
5255 tmp_ac_prefs
.oauth2_date
= g_get_real_time () / G_USEC_PER_SEC
;
5262 static void prefs_account_set_autochk_interval_to_widgets(PrefParam
*pparam
)
5264 gint val
= *((gint
*)pparam
->data
);
5265 struct AutocheckWidgets
*autochk_widgets
=
5266 (struct AutocheckWidgets
*)*pparam
->widget
;
5268 gtk_spin_button_set_value(
5269 GTK_SPIN_BUTTON(autochk_widgets
->autochk_hour_spinbtn
),
5271 gtk_spin_button_set_value(
5272 GTK_SPIN_BUTTON(autochk_widgets
->autochk_min_spinbtn
),
5274 gtk_spin_button_set_value(
5275 GTK_SPIN_BUTTON(autochk_widgets
->autochk_sec_spinbtn
),
5279 static void prefs_account_set_string_from_combobox(PrefParam
*pparam
)
5281 GtkWidget
*combobox
;
5286 cm_return_if_fail(*pparam
->widget
!= NULL
);
5288 combobox
= *pparam
->widget
;
5289 cm_return_if_fail(gtk_combo_box_get_active_iter(
5290 GTK_COMBO_BOX(combobox
), &iter
));
5292 str
= (gchar
**)pparam
->data
;
5294 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combobox
)));
5295 gtk_tree_model_get(GTK_TREE_MODEL(menu
), &iter
,
5296 COMBOBOX_PRIVACY_PLUGIN_ID
, &(*str
),
5300 /* Context struct and internal function called by gtk_tree_model_foreach().
5301 * This is used in prefs_account_set_privacy_combobox_from_string() to find
5302 * correct combobox entry to activate when account preferences are displayed
5303 * and their values are set according to preferences. */
5304 typedef struct _privacy_system_set_ctx
{
5305 GtkWidget
*combobox
;
5308 } PrivacySystemSetCtx
;
5310 static gboolean
_privacy_system_set_func(GtkTreeModel
*model
, GtkTreePath
*path
,
5311 GtkTreeIter
*iter
, PrivacySystemSetCtx
*ctx
)
5313 GtkWidget
*combobox
= ctx
->combobox
;
5314 gchar
*prefsid
= ctx
->prefsid
;
5317 /* We're searching for correct privacy plugin ID. */
5318 gtk_tree_model_get(model
, iter
, COMBOBOX_PRIVACY_PLUGIN_ID
, &curid
, -1);
5319 if( strcmp(prefsid
, curid
) == 0 ) {
5320 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combobox
), iter
);
5330 static void prefs_account_set_privacy_combobox_from_string(PrefParam
*pparam
)
5332 GtkWidget
*optionmenu
;
5335 gboolean found
= FALSE
;
5337 PrivacySystemSetCtx
*ctx
= NULL
;
5339 cm_return_if_fail(*pparam
->widget
!= NULL
);
5341 prefsid
= *((gchar
**) pparam
->data
);
5342 if (prefsid
== NULL
)
5345 optionmenu
= *pparam
->widget
;
5346 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optionmenu
)));
5348 ctx
= g_new(PrivacySystemSetCtx
, sizeof(PrivacySystemSetCtx
));
5349 ctx
->combobox
= optionmenu
;
5350 ctx
->prefsid
= prefsid
;
5353 gtk_tree_model_foreach(GTK_TREE_MODEL(menu
),
5354 (GtkTreeModelForeachFunc
)_privacy_system_set_func
, ctx
);
5358 /* If chosen privacy system is not available, add a dummy entry with
5359 * "not loaded" note and make it active. */
5363 name
= g_strdup_printf(_("%s (plugin not loaded)"), prefsid
);
5364 gtk_list_store_append(menu
, &iter
);
5365 gtk_list_store_set(menu
, &iter
,
5366 COMBOBOX_TEXT
, name
,
5368 COMBOBOX_SENS
, TRUE
,
5369 COMBOBOX_PRIVACY_PLUGIN_ID
, prefsid
,
5373 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(optionmenu
), &iter
);
5377 static void prefs_account_protocol_changed(GtkComboBox
*combobox
, gpointer data
)
5379 RecvProtocol protocol
;
5380 struct BasicProtocol
*protocol_optmenu
= (struct BasicProtocol
*)basic_page
.protocol_optmenu
;
5382 protocol
= combobox_get_active_data(combobox
);
5384 gtk_widget_hide(protocol_optmenu
->no_imap_warn_icon
);
5385 gtk_widget_hide(protocol_optmenu
->no_imap_warn_label
);
5389 #ifndef HAVE_LIBETPAN
5390 gtk_widget_show(protocol_optmenu
->no_imap_warn_icon
);
5391 gtk_widget_show(protocol_optmenu
->no_imap_warn_label
);
5393 gtk_widget_hide(protocol_optmenu
->no_imap_warn_icon
);
5394 gtk_widget_hide(protocol_optmenu
->no_imap_warn_label
);
5396 gtk_widget_show(send_page
.msgid_checkbtn
);
5397 gtk_widget_show(send_page
.xmailer_checkbtn
);
5398 gtk_widget_show(basic_page
.nntpserv_label
);
5399 gtk_widget_show(basic_page
.nntpserv_entry
);
5400 gtk_grid_set_row_spacing(GTK_GRID(basic_page
.serv_table
), VSPACING_NARROW
);
5402 gtk_widget_set_sensitive(basic_page
.nntpauth_checkbtn
, TRUE
);
5403 gtk_widget_show(basic_page
.nntpauth_checkbtn
);
5405 gtk_widget_set_sensitive(basic_page
.nntpauth_onconnect_checkbtn
, TRUE
);
5406 gtk_widget_show(basic_page
.nntpauth_onconnect_checkbtn
);
5408 gtk_widget_hide(basic_page
.recvserv_label
);
5409 gtk_widget_hide(basic_page
.recvserv_entry
);
5410 gtk_widget_show(basic_page
.smtpserv_label
);
5411 gtk_widget_show(basic_page
.smtpserv_entry
);
5412 gtk_widget_hide(basic_page
.localmbox_label
);
5413 gtk_widget_hide(basic_page
.localmbox_entry
);
5414 gtk_widget_hide(basic_page
.mailcmd_label
);
5415 gtk_widget_hide(basic_page
.mailcmd_entry
);
5416 gtk_widget_hide(basic_page
.mailcmd_checkbtn
);
5417 gtk_widget_show(basic_page
.uid_label
);
5418 gtk_widget_show(basic_page
.pass_label
);
5419 gtk_widget_show(basic_page
.uid_entry
);
5420 gtk_widget_show(basic_page
.pass_entry
);
5421 gtk_widget_show(basic_page
.showpwd_checkbtn
);
5423 gtk_widget_set_sensitive(basic_page
.uid_label
, TRUE
);
5424 gtk_widget_set_sensitive(basic_page
.pass_label
, TRUE
);
5425 gtk_widget_set_sensitive(basic_page
.uid_entry
, TRUE
);
5426 gtk_widget_set_sensitive(basic_page
.pass_entry
, TRUE
);
5427 gtk_widget_set_sensitive(basic_page
.showpwd_checkbtn
, TRUE
);
5429 /* update userid/passwd sensitive state */
5431 prefs_account_nntpauth_toggled
5432 (GTK_TOGGLE_BUTTON(basic_page
.nntpauth_checkbtn
), NULL
);
5433 gtk_widget_hide(receive_page
.pop3_frame
);
5434 gtk_widget_hide(receive_page
.imap_frame
);
5435 gtk_widget_hide(receive_page
.local_frame
);
5436 gtk_widget_show(receive_page
.autochk_frame
);
5437 gtk_widget_show(receive_page
.frame_maxarticle
);
5438 gtk_widget_set_sensitive(receive_page
.filter_on_recv_checkbtn
, TRUE
);
5439 prefs_account_filter_on_recv_toggled
5440 (GTK_TOGGLE_BUTTON(receive_page
.filter_on_recv_checkbtn
), NULL
);
5441 gtk_widget_set_sensitive(receive_page
.recvatgetall_checkbtn
, TRUE
);
5442 /* update pop_before_smtp sensitivity */
5443 gtk_toggle_button_set_active
5444 (GTK_TOGGLE_BUTTON(send_page
.pop_bfr_smtp_checkbtn
), FALSE
);
5445 gtk_widget_set_sensitive(send_page
.pop_bfr_smtp_checkbtn
, FALSE
);
5446 gtk_widget_set_sensitive(send_page
.pop_bfr_smtp_tm_spinbtn
, FALSE
);
5448 if (!tmp_ac_prefs
.account_name
) {
5449 gtk_toggle_button_set_active
5450 (GTK_TOGGLE_BUTTON(receive_page
.filter_on_recv_checkbtn
),
5452 gtk_toggle_button_set_active
5453 (GTK_TOGGLE_BUTTON(receive_page
.filterhook_on_recv_checkbtn
),
5455 gtk_toggle_button_set_active
5456 (GTK_TOGGLE_BUTTON(receive_page
.recvatgetall_checkbtn
),
5461 gtk_widget_hide(ssl_page
.pop_frame
);
5462 gtk_widget_hide(ssl_page
.imap_frame
);
5463 gtk_widget_show(ssl_page
.nntp_frame
);
5464 gtk_widget_show(ssl_page
.send_frame
);
5466 gtk_widget_hide(advanced_page
.popport_hbox
);
5467 gtk_widget_hide(advanced_page
.imapport_hbox
);
5468 gtk_widget_show(advanced_page
.nntpport_hbox
);
5469 gtk_widget_show(advanced_page
.crosspost_checkbtn
);
5470 gtk_widget_show(advanced_page
.crosspost_colormenu
);
5472 gtk_widget_hide(advanced_page
.tunnelcmd_checkbtn
);
5473 gtk_widget_hide(advanced_page
.tunnelcmd_entry
);
5475 gtk_widget_hide(receive_page
.imapdir_label
);
5476 gtk_widget_hide(receive_page
.imapdir_entry
);
5477 gtk_widget_hide(receive_page
.subsonly_checkbtn
);
5478 gtk_widget_hide(receive_page
.low_bandwidth_checkbtn
);
5481 gtk_widget_show(send_page
.msgid_checkbtn
);
5482 gtk_widget_show(send_page
.xmailer_checkbtn
);
5483 gtk_widget_hide(protocol_optmenu
->no_imap_warn_icon
);
5484 gtk_widget_hide(protocol_optmenu
->no_imap_warn_label
);
5485 gtk_widget_hide(basic_page
.nntpserv_label
);
5486 gtk_widget_hide(basic_page
.nntpserv_entry
);
5487 gtk_widget_set_sensitive(basic_page
.nntpauth_checkbtn
, FALSE
);
5488 gtk_widget_hide(basic_page
.nntpauth_checkbtn
);
5489 gtk_grid_set_row_spacing(GTK_GRID(basic_page
.serv_table
), VSPACING_NARROW
);
5491 gtk_widget_set_sensitive(basic_page
.nntpauth_onconnect_checkbtn
, FALSE
);
5492 gtk_widget_hide(basic_page
.nntpauth_onconnect_checkbtn
);
5493 gtk_widget_hide(basic_page
.recvserv_label
);
5494 gtk_widget_hide(basic_page
.recvserv_entry
);
5495 gtk_widget_show(basic_page
.smtpserv_label
);
5496 gtk_widget_show(basic_page
.smtpserv_entry
);
5497 gtk_widget_show(basic_page
.localmbox_label
);
5498 gtk_widget_show(basic_page
.localmbox_entry
);
5499 gtk_widget_show(basic_page
.mailcmd_label
);
5500 gtk_widget_show(basic_page
.mailcmd_entry
);
5501 gtk_widget_show(basic_page
.mailcmd_checkbtn
);
5502 gtk_widget_hide(basic_page
.uid_label
);
5503 gtk_widget_hide(basic_page
.pass_label
);
5504 gtk_widget_hide(basic_page
.uid_entry
);
5505 gtk_widget_hide(basic_page
.pass_entry
);
5506 gtk_widget_hide(basic_page
.showpwd_checkbtn
);
5508 gtk_widget_set_sensitive(basic_page
.uid_label
, TRUE
);
5509 gtk_widget_set_sensitive(basic_page
.pass_label
, TRUE
);
5510 gtk_widget_set_sensitive(basic_page
.uid_entry
, TRUE
);
5511 gtk_widget_set_sensitive(basic_page
.pass_entry
, TRUE
);
5512 gtk_widget_set_sensitive(basic_page
.showpwd_checkbtn
, TRUE
);
5513 gtk_widget_hide(receive_page
.pop3_frame
);
5514 gtk_widget_hide(receive_page
.imap_frame
);
5515 gtk_widget_show(receive_page
.local_frame
);
5516 gtk_widget_show(receive_page
.autochk_frame
);
5517 gtk_widget_hide(receive_page
.frame_maxarticle
);
5518 gtk_widget_set_sensitive(receive_page
.filter_on_recv_checkbtn
, TRUE
);
5519 prefs_account_filter_on_recv_toggled
5520 (GTK_TOGGLE_BUTTON(receive_page
.filter_on_recv_checkbtn
), NULL
);
5521 gtk_widget_set_sensitive(receive_page
.recvatgetall_checkbtn
, TRUE
);
5522 prefs_account_mailcmd_toggled
5523 (GTK_TOGGLE_BUTTON(basic_page
.mailcmd_checkbtn
), NULL
);
5525 /* update pop_before_smtp sensitivity */
5526 gtk_toggle_button_set_active
5527 (GTK_TOGGLE_BUTTON(send_page
.pop_bfr_smtp_checkbtn
), FALSE
);
5528 gtk_widget_set_sensitive(send_page
.pop_bfr_smtp_checkbtn
, FALSE
);
5529 gtk_widget_set_sensitive(send_page
.pop_bfr_smtp_tm_spinbtn
, FALSE
);
5531 if (!tmp_ac_prefs
.account_name
) {
5532 gtk_toggle_button_set_active
5533 (GTK_TOGGLE_BUTTON(receive_page
.filter_on_recv_checkbtn
),
5535 gtk_toggle_button_set_active
5536 (GTK_TOGGLE_BUTTON(receive_page
.filterhook_on_recv_checkbtn
),
5538 gtk_toggle_button_set_active
5539 (GTK_TOGGLE_BUTTON(receive_page
.recvatgetall_checkbtn
),
5544 gtk_widget_hide(ssl_page
.pop_frame
);
5545 gtk_widget_hide(ssl_page
.imap_frame
);
5546 gtk_widget_hide(ssl_page
.nntp_frame
);
5547 gtk_widget_show(ssl_page
.send_frame
);
5549 gtk_widget_hide(advanced_page
.popport_hbox
);
5550 gtk_widget_hide(advanced_page
.imapport_hbox
);
5551 gtk_widget_hide(advanced_page
.nntpport_hbox
);
5552 gtk_widget_hide(advanced_page
.crosspost_checkbtn
);
5553 gtk_widget_hide(advanced_page
.crosspost_colormenu
);
5555 gtk_widget_hide(advanced_page
.tunnelcmd_checkbtn
);
5556 gtk_widget_hide(advanced_page
.tunnelcmd_entry
);
5558 gtk_widget_hide(receive_page
.imapdir_label
);
5559 gtk_widget_hide(receive_page
.imapdir_entry
);
5560 gtk_widget_hide(receive_page
.subsonly_checkbtn
);
5561 gtk_widget_hide(receive_page
.low_bandwidth_checkbtn
);
5564 #ifndef HAVE_LIBETPAN
5565 gtk_widget_show(protocol_optmenu
->no_imap_warn_icon
);
5566 gtk_widget_show(protocol_optmenu
->no_imap_warn_label
);
5569 gtk_toggle_button_set_active(
5570 GTK_TOGGLE_BUTTON(send_page
.msgid_checkbtn
),
5572 gtk_widget_hide(send_page
.msgid_checkbtn
);
5573 gtk_widget_show(send_page
.xmailer_checkbtn
);
5574 gtk_widget_hide(basic_page
.nntpserv_label
);
5575 gtk_widget_hide(basic_page
.nntpserv_entry
);
5576 gtk_grid_set_row_spacing(GTK_GRID(basic_page
.serv_table
), VSPACING_NARROW
);
5577 gtk_widget_set_sensitive(basic_page
.nntpauth_checkbtn
, FALSE
);
5578 gtk_widget_hide(basic_page
.nntpauth_checkbtn
);
5580 gtk_widget_set_sensitive(basic_page
.nntpauth_onconnect_checkbtn
, FALSE
);
5581 gtk_widget_hide(basic_page
.nntpauth_onconnect_checkbtn
);
5583 gtk_widget_set_sensitive(basic_page
.recvserv_label
, TRUE
);
5584 gtk_widget_set_sensitive(basic_page
.recvserv_entry
, TRUE
);
5585 gtk_widget_show(basic_page
.recvserv_label
);
5586 gtk_widget_show(basic_page
.recvserv_entry
);
5587 gtk_widget_show(basic_page
.smtpserv_label
);
5588 gtk_widget_show(basic_page
.smtpserv_entry
);
5589 gtk_widget_hide(basic_page
.localmbox_label
);
5590 gtk_widget_hide(basic_page
.localmbox_entry
);
5591 gtk_widget_hide(basic_page
.mailcmd_label
);
5592 gtk_widget_hide(basic_page
.mailcmd_entry
);
5593 gtk_widget_hide(basic_page
.mailcmd_checkbtn
);
5594 gtk_widget_show(basic_page
.uid_label
);
5595 gtk_widget_show(basic_page
.pass_label
);
5596 gtk_widget_show(basic_page
.uid_entry
);
5597 gtk_widget_show(basic_page
.pass_entry
);
5598 gtk_widget_show(basic_page
.showpwd_checkbtn
);
5600 gtk_widget_set_sensitive(basic_page
.uid_label
, TRUE
);
5601 gtk_widget_set_sensitive(basic_page
.pass_label
, TRUE
);
5602 gtk_widget_set_sensitive(basic_page
.uid_entry
, TRUE
);
5603 gtk_widget_set_sensitive(basic_page
.pass_entry
, TRUE
);
5604 gtk_widget_set_sensitive(basic_page
.showpwd_checkbtn
, TRUE
);
5605 gtk_widget_hide(receive_page
.pop3_frame
);
5606 gtk_widget_show(receive_page
.imap_frame
);
5607 gtk_widget_hide(receive_page
.local_frame
);
5608 gtk_widget_show(receive_page
.autochk_frame
);
5609 gtk_widget_hide(receive_page
.frame_maxarticle
);
5610 gtk_widget_set_sensitive(receive_page
.filter_on_recv_checkbtn
, TRUE
);
5611 prefs_account_filter_on_recv_toggled
5612 (GTK_TOGGLE_BUTTON(receive_page
.filter_on_recv_checkbtn
), NULL
);
5613 gtk_widget_set_sensitive(receive_page
.recvatgetall_checkbtn
, TRUE
);
5614 gtk_widget_set_sensitive(basic_page
.smtpserv_entry
, TRUE
);
5615 gtk_widget_set_sensitive(basic_page
.smtpserv_label
, TRUE
);
5617 /* update pop_before_smtp sensitivity */
5618 gtk_toggle_button_set_active
5619 (GTK_TOGGLE_BUTTON(send_page
.pop_bfr_smtp_checkbtn
), FALSE
);
5620 gtk_widget_set_sensitive(send_page
.pop_bfr_smtp_checkbtn
, FALSE
);
5621 gtk_widget_set_sensitive(send_page
.pop_bfr_smtp_tm_spinbtn
, FALSE
);
5623 if (!tmp_ac_prefs
.account_name
) {
5624 gtk_toggle_button_set_active
5625 (GTK_TOGGLE_BUTTON(receive_page
.filter_on_recv_checkbtn
),
5627 gtk_toggle_button_set_active
5628 (GTK_TOGGLE_BUTTON(receive_page
.filterhook_on_recv_checkbtn
),
5630 gtk_toggle_button_set_active
5631 (GTK_TOGGLE_BUTTON(receive_page
.recvatgetall_checkbtn
),
5636 gtk_widget_hide(ssl_page
.pop_frame
);
5637 gtk_widget_show(ssl_page
.imap_frame
);
5638 gtk_widget_hide(ssl_page
.nntp_frame
);
5639 gtk_widget_show(ssl_page
.send_frame
);
5641 gtk_widget_hide(advanced_page
.popport_hbox
);
5642 gtk_widget_show(advanced_page
.imapport_hbox
);
5643 gtk_widget_hide(advanced_page
.nntpport_hbox
);
5644 gtk_widget_hide(advanced_page
.crosspost_checkbtn
);
5645 gtk_widget_hide(advanced_page
.crosspost_colormenu
);
5647 gtk_widget_show(advanced_page
.tunnelcmd_checkbtn
);
5648 gtk_widget_show(advanced_page
.tunnelcmd_entry
);
5650 gtk_widget_show(receive_page
.imapdir_label
);
5651 gtk_widget_show(receive_page
.imapdir_entry
);
5652 gtk_widget_show(receive_page
.subsonly_checkbtn
);
5653 gtk_widget_show(receive_page
.low_bandwidth_checkbtn
);
5656 gtk_widget_show(send_page
.msgid_checkbtn
);
5657 gtk_widget_show(send_page
.xmailer_checkbtn
);
5658 gtk_widget_hide(protocol_optmenu
->no_imap_warn_icon
);
5659 gtk_widget_hide(protocol_optmenu
->no_imap_warn_label
);
5660 gtk_widget_hide(basic_page
.nntpserv_label
);
5661 gtk_widget_hide(basic_page
.nntpserv_entry
);
5662 gtk_grid_set_row_spacing(GTK_GRID(basic_page
.serv_table
), VSPACING_NARROW
);
5663 gtk_widget_set_sensitive(basic_page
.nntpauth_checkbtn
, FALSE
);
5664 gtk_widget_hide(basic_page
.nntpauth_checkbtn
);
5666 gtk_widget_set_sensitive(basic_page
.nntpauth_onconnect_checkbtn
, FALSE
);
5667 gtk_widget_hide(basic_page
.nntpauth_onconnect_checkbtn
);
5669 gtk_widget_set_sensitive(basic_page
.recvserv_label
, FALSE
);
5670 gtk_widget_set_sensitive(basic_page
.recvserv_entry
, FALSE
);
5671 gtk_widget_hide(basic_page
.recvserv_label
);
5672 gtk_widget_hide(basic_page
.recvserv_entry
);
5673 gtk_widget_show(basic_page
.smtpserv_label
);
5674 gtk_widget_show(basic_page
.smtpserv_entry
);
5675 gtk_widget_hide(basic_page
.localmbox_label
);
5676 gtk_widget_hide(basic_page
.localmbox_entry
);
5677 gtk_widget_hide(basic_page
.mailcmd_label
);
5678 gtk_widget_hide(basic_page
.mailcmd_entry
);
5679 gtk_widget_hide(basic_page
.mailcmd_checkbtn
);
5680 gtk_widget_hide(basic_page
.uid_label
);
5681 gtk_widget_hide(basic_page
.pass_label
);
5682 gtk_widget_hide(basic_page
.uid_entry
);
5683 gtk_widget_hide(basic_page
.pass_entry
);
5684 gtk_widget_hide(basic_page
.showpwd_checkbtn
);
5686 gtk_widget_set_sensitive(basic_page
.uid_label
, FALSE
);
5687 gtk_widget_set_sensitive(basic_page
.pass_label
, FALSE
);
5688 gtk_widget_set_sensitive(basic_page
.uid_entry
, FALSE
);
5689 gtk_widget_set_sensitive(basic_page
.pass_entry
, FALSE
);
5690 gtk_widget_set_sensitive(basic_page
.showpwd_checkbtn
, FALSE
);
5691 gtk_widget_set_sensitive(receive_page
.pop3_frame
, FALSE
);
5692 gtk_widget_hide(receive_page
.pop3_frame
);
5693 gtk_widget_hide(receive_page
.imap_frame
);
5694 gtk_widget_hide(receive_page
.local_frame
);
5695 gtk_widget_hide(receive_page
.autochk_frame
);
5696 gtk_widget_hide(receive_page
.frame_maxarticle
);
5697 gtk_widget_set_sensitive(receive_page
.filter_on_recv_checkbtn
, FALSE
);
5698 prefs_account_filter_on_recv_toggled
5699 (GTK_TOGGLE_BUTTON(receive_page
.filter_on_recv_checkbtn
), NULL
);
5700 gtk_widget_set_sensitive(receive_page
.recvatgetall_checkbtn
, FALSE
);
5702 gtk_widget_set_sensitive(basic_page
.smtpserv_entry
, TRUE
);
5703 gtk_widget_set_sensitive(basic_page
.smtpserv_label
, TRUE
);
5705 /* update pop_before_smtp sensitivity */
5706 gtk_widget_set_sensitive(send_page
.pop_bfr_smtp_checkbtn
, FALSE
);
5707 pop_bfr_smtp_tm_set_sens(NULL
, NULL
);
5709 gtk_toggle_button_set_active
5710 (GTK_TOGGLE_BUTTON(receive_page
.filter_on_recv_checkbtn
), FALSE
);
5711 gtk_toggle_button_set_active
5712 (GTK_TOGGLE_BUTTON(receive_page
.filterhook_on_recv_checkbtn
), FALSE
);
5713 gtk_toggle_button_set_active
5714 (GTK_TOGGLE_BUTTON(receive_page
.recvatgetall_checkbtn
), FALSE
);
5717 gtk_widget_hide(ssl_page
.pop_frame
);
5718 gtk_widget_hide(ssl_page
.imap_frame
);
5719 gtk_widget_hide(ssl_page
.nntp_frame
);
5720 gtk_widget_show(ssl_page
.send_frame
);
5722 gtk_widget_hide(advanced_page
.popport_hbox
);
5723 gtk_widget_hide(advanced_page
.imapport_hbox
);
5724 gtk_widget_hide(advanced_page
.nntpport_hbox
);
5725 gtk_widget_hide(advanced_page
.crosspost_checkbtn
);
5726 gtk_widget_hide(advanced_page
.crosspost_colormenu
);
5728 gtk_widget_hide(advanced_page
.tunnelcmd_checkbtn
);
5729 gtk_widget_hide(advanced_page
.tunnelcmd_entry
);
5731 gtk_widget_hide(receive_page
.imapdir_label
);
5732 gtk_widget_hide(receive_page
.imapdir_entry
);
5733 gtk_widget_hide(receive_page
.subsonly_checkbtn
);
5734 gtk_widget_hide(receive_page
.low_bandwidth_checkbtn
);
5737 /* continue to default: */
5739 gtk_widget_show(send_page
.msgid_checkbtn
);
5740 gtk_widget_show(send_page
.xmailer_checkbtn
);
5741 gtk_widget_hide(protocol_optmenu
->no_imap_warn_icon
);
5742 gtk_widget_hide(protocol_optmenu
->no_imap_warn_label
);
5743 gtk_widget_hide(basic_page
.nntpserv_label
);
5744 gtk_widget_hide(basic_page
.nntpserv_entry
);
5745 gtk_grid_set_row_spacing(GTK_GRID(basic_page
.serv_table
), VSPACING_NARROW
);
5746 gtk_widget_set_sensitive(basic_page
.nntpauth_checkbtn
, FALSE
);
5747 gtk_widget_hide(basic_page
.nntpauth_checkbtn
);
5749 gtk_widget_set_sensitive(basic_page
.nntpauth_onconnect_checkbtn
, FALSE
);
5750 gtk_widget_hide(basic_page
.nntpauth_onconnect_checkbtn
);
5752 gtk_widget_set_sensitive(basic_page
.recvserv_label
, TRUE
);
5753 gtk_widget_set_sensitive(basic_page
.recvserv_entry
, TRUE
);
5754 gtk_widget_show(basic_page
.recvserv_label
);
5755 gtk_widget_show(basic_page
.recvserv_entry
);
5756 gtk_widget_show(basic_page
.smtpserv_label
);
5757 gtk_widget_show(basic_page
.smtpserv_entry
);
5758 gtk_widget_hide(basic_page
.localmbox_label
);
5759 gtk_widget_hide(basic_page
.localmbox_entry
);
5760 gtk_widget_hide(basic_page
.mailcmd_label
);
5761 gtk_widget_hide(basic_page
.mailcmd_entry
);
5762 gtk_widget_hide(basic_page
.mailcmd_checkbtn
);
5763 gtk_widget_show(basic_page
.uid_label
);
5764 gtk_widget_show(basic_page
.pass_label
);
5765 gtk_widget_show(basic_page
.uid_entry
);
5766 gtk_widget_show(basic_page
.pass_entry
);
5767 gtk_widget_show(basic_page
.showpwd_checkbtn
);
5769 gtk_widget_set_sensitive(basic_page
.uid_label
, TRUE
);
5770 gtk_widget_set_sensitive(basic_page
.pass_label
, TRUE
);
5771 gtk_widget_set_sensitive(basic_page
.uid_entry
, TRUE
);
5772 gtk_widget_set_sensitive(basic_page
.pass_entry
, TRUE
);
5773 gtk_widget_set_sensitive(basic_page
.showpwd_checkbtn
, TRUE
);
5774 gtk_widget_set_sensitive(receive_page
.pop3_frame
, TRUE
);
5775 gtk_widget_show(receive_page
.pop3_frame
);
5776 gtk_widget_hide(receive_page
.imap_frame
);
5777 gtk_widget_hide(receive_page
.local_frame
);
5778 gtk_widget_show(receive_page
.autochk_frame
);
5779 gtk_widget_hide(receive_page
.frame_maxarticle
);
5780 gtk_widget_set_sensitive(receive_page
.filter_on_recv_checkbtn
, TRUE
);
5781 prefs_account_filter_on_recv_toggled
5782 (GTK_TOGGLE_BUTTON(receive_page
.filter_on_recv_checkbtn
), NULL
);
5783 gtk_widget_set_sensitive(receive_page
.recvatgetall_checkbtn
, TRUE
);
5785 gtk_widget_set_sensitive(basic_page
.smtpserv_entry
, TRUE
);
5786 gtk_widget_set_sensitive(basic_page
.smtpserv_label
, TRUE
);
5788 /* update pop_before_smtp sensitivity */
5789 gtk_widget_set_sensitive(send_page
.pop_bfr_smtp_checkbtn
, TRUE
);
5790 pop_bfr_smtp_tm_set_sens(NULL
, NULL
);
5792 if (!tmp_ac_prefs
.account_name
) {
5793 gtk_toggle_button_set_active
5794 (GTK_TOGGLE_BUTTON(receive_page
.filter_on_recv_checkbtn
),
5796 gtk_toggle_button_set_active
5797 (GTK_TOGGLE_BUTTON(receive_page
.filterhook_on_recv_checkbtn
),
5799 gtk_toggle_button_set_active
5800 (GTK_TOGGLE_BUTTON(receive_page
.recvatgetall_checkbtn
),
5805 gtk_widget_show(ssl_page
.pop_frame
);
5806 gtk_widget_hide(ssl_page
.imap_frame
);
5807 gtk_widget_hide(ssl_page
.nntp_frame
);
5808 gtk_widget_show(ssl_page
.send_frame
);
5810 gtk_widget_show(advanced_page
.popport_hbox
);
5811 gtk_widget_hide(advanced_page
.imapport_hbox
);
5812 gtk_widget_hide(advanced_page
.nntpport_hbox
);
5813 gtk_widget_hide(advanced_page
.crosspost_checkbtn
);
5814 gtk_widget_hide(advanced_page
.crosspost_colormenu
);
5816 gtk_widget_hide(advanced_page
.tunnelcmd_checkbtn
);
5817 gtk_widget_hide(advanced_page
.tunnelcmd_entry
);
5819 gtk_widget_hide(receive_page
.imapdir_label
);
5820 gtk_widget_hide(receive_page
.imapdir_entry
);
5821 gtk_widget_hide(receive_page
.subsonly_checkbtn
);
5822 gtk_widget_hide(receive_page
.low_bandwidth_checkbtn
);
5826 gtk_widget_queue_resize(basic_page
.serv_frame
);
5829 static void prefs_account_nntpauth_toggled(GtkToggleButton
*button
,
5834 if (!gtk_widget_get_sensitive (GTK_WIDGET (button
)))
5836 auth
= gtk_toggle_button_get_active (button
);
5837 gtk_widget_set_sensitive(basic_page
.uid_label
, auth
);
5838 gtk_widget_set_sensitive(basic_page
.pass_label
, auth
);
5839 gtk_widget_set_sensitive(basic_page
.uid_entry
, auth
);
5840 gtk_widget_set_sensitive(basic_page
.pass_entry
, auth
);
5841 gtk_widget_set_sensitive(basic_page
.showpwd_checkbtn
, auth
);
5842 gtk_widget_set_sensitive(basic_page
.nntpauth_onconnect_checkbtn
, auth
);
5845 static void prefs_account_mailcmd_toggled(GtkToggleButton
*button
,
5848 gboolean use_mailcmd
;
5850 use_mailcmd
= gtk_toggle_button_get_active (button
);
5852 gtk_widget_set_sensitive(basic_page
.mailcmd_entry
, use_mailcmd
);
5853 gtk_widget_set_sensitive(basic_page
.mailcmd_label
, use_mailcmd
);
5854 gtk_widget_set_sensitive(basic_page
.smtpserv_entry
, !use_mailcmd
);
5855 gtk_widget_set_sensitive(basic_page
.smtpserv_label
, !use_mailcmd
);
5856 gtk_widget_set_sensitive(basic_page
.uid_entry
, !use_mailcmd
);
5857 gtk_widget_set_sensitive(basic_page
.pass_entry
, !use_mailcmd
);
5858 gtk_widget_set_sensitive(basic_page
.showpwd_checkbtn
, !use_mailcmd
);
5861 static void prefs_account_showpwd_checkbtn_toggled(GtkToggleButton
*button
,
5864 gboolean active
= gtk_toggle_button_get_active(button
);
5865 GtkWidget
*entry
= GTK_WIDGET(user_data
);
5867 gtk_entry_set_visibility(GTK_ENTRY(entry
), active
);
5870 static void prefs_account_entry_changed_newline_check_cb(GtkWidget
*entry
,
5873 static GdkColor red
= { (guint32
)0, (guint16
)0xff, (guint16
)0x70, (guint16
)0x70 };
5875 if (strchr(gtk_entry_get_text(GTK_ENTRY(entry
)), '\n') != NULL
) {
5876 /* Entry contains a newline, light it up. */
5877 debug_print("found newline in string, painting entry red\n");
5878 gtk_widget_modify_base(entry
, GTK_STATE_NORMAL
, &red
);
5880 gtk_widget_modify_base(entry
, GTK_STATE_NORMAL
, NULL
);
5884 static void prefs_account_filter_on_recv_toggled(GtkToggleButton
*button
,
5889 do_filter
= gtk_toggle_button_get_active (button
);
5890 gtk_widget_set_sensitive(receive_page
.filterhook_on_recv_checkbtn
, do_filter
);
5894 static void prefs_account_compose_default_dictionary_set_string_from_optmenu
5900 cm_return_if_fail(*pparam
->widget
!= NULL
);
5902 combo
= *pparam
->widget
;
5903 str
= (gchar
**) pparam
->data
;
5906 *str
= gtkaspell_get_dictionary_menu_active_item(GTK_COMBO_BOX(combo
));
5909 static void prefs_account_compose_default_dictionary_set_optmenu_from_string
5915 cm_return_if_fail(*pparam
->widget
!= NULL
);
5917 dictionary
= *((gchar
**) pparam
->data
);
5918 if (dictionary
!= NULL
) {
5919 if (strrchr(dictionary
, '/')) {
5920 dictionary
= g_strdup(strrchr(dictionary
, '/')+1);
5923 if (strchr(dictionary
, '-')) {
5924 *(strchr(dictionary
, '-')) = '\0';
5927 combo
= *pparam
->widget
;
5928 if (dictionary
&& *dictionary
)
5929 gtkaspell_set_dictionary_menu_active_item(GTK_COMBO_BOX(combo
),
5932 GtkTreeModel
*model
;
5934 if((model
= gtk_combo_box_get_model(GTK_COMBO_BOX(combo
))) == NULL
)
5936 if((gtk_tree_model_get_iter_first(model
, &iter
)) == FALSE
)
5938 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo
), &iter
);
5943 gchar
*prefs_account_generate_msgid(PrefsAccount
*account
)
5945 gchar
*addr
, *tmbuf
, *buf
= NULL
;
5947 gchar
*user_addr
= account
->msgid_with_addr
? g_strdup(account
->address
) : NULL
;
5949 if (account
->set_domain
&& account
->domain
) {
5950 buf
= g_strdup(account
->domain
);
5951 } else if (!strncmp(get_domain_name(), "localhost", strlen("localhost"))) {
5953 strchr(account
->address
, '@') ?
5954 strchr(account
->address
, '@')+1 :
5958 if (user_addr
!= NULL
) {
5959 addr
= g_strdup_printf(".%s", user_addr
);
5961 addr
= g_strdup_printf("@%s",
5962 buf
!= NULL
&& strlen(buf
) > 0 ?
5963 buf
: get_domain_name());
5968 if (user_addr
!= NULL
)
5971 /* Replace all @ but the last one in addr, with underscores.
5972 * RFC 2822 States that msg-id syntax only allows one @.
5974 while (strchr(addr
, '@') != NULL
&& strchr(addr
, '@') != strrchr(addr
, '@'))
5975 *(strchr(addr
, '@')) = '_';
5977 now
= (prefs_common
.hide_timezone
)? g_date_time_new_now_utc() :
5978 g_date_time_new_now_local();
5979 tmbuf
= g_date_time_format(now
, "%Y%m%d%H%M%S");
5980 buf
= g_strdup_printf("%s.%08x%s",
5981 tmbuf
, (guint
)rand(), addr
);
5982 g_date_time_unref(now
);
5986 debug_print("Generated Message-ID string '%s'\n", buf
);
5990 void prefs_account_register_page(PrefsPage
*page
)
5992 prefs_pages
= g_slist_append(prefs_pages
, page
);
5996 void prefs_account_unregister_page(PrefsPage
*page
)
5998 prefs_pages
= g_slist_remove(prefs_pages
, page
);
6001 gchar
*prefs_account_cache_dir(PrefsAccount
*ac_prefs
, gboolean for_server
)
6005 gchar
*sanitized_server
;
6008 if (ac_prefs
->protocol
== A_IMAP4
) {
6010 sanitized_server
= g_strdup(ac_prefs
->recv_server
);
6011 g_strdelimit(sanitized_server
, ":", ',');
6014 dir
= g_strconcat(get_imap_cache_dir(),
6019 ac_prefs
->recv_server
,
6023 dir
= g_strconcat(get_imap_cache_dir(),
6028 ac_prefs
->recv_server
,
6035 g_free(sanitized_server
);
6042 static void prefs_account_receive_itv_spinbutton_value_changed_cb(GtkWidget
*w
, gpointer data
)
6044 ReceivePage
*page
= (ReceivePage
*)data
;
6045 gint seconds
= gtk_spin_button_get_value_as_int (
6046 GTK_SPIN_BUTTON (page
->autochk_widgets
->autochk_sec_spinbtn
));
6047 gint minutes
= gtk_spin_button_get_value_as_int (
6048 GTK_SPIN_BUTTON (page
->autochk_widgets
->autochk_min_spinbtn
));
6049 gint hours
= gtk_spin_button_get_value_as_int (
6050 GTK_SPIN_BUTTON(page
->autochk_widgets
->autochk_hour_spinbtn
));
6051 if (seconds
< PREFS_RECV_AUTOCHECK_MIN_INTERVAL
&& minutes
== 0 && hours
== 0) {
6052 gtk_spin_button_set_value (
6053 GTK_SPIN_BUTTON (page
->autochk_widgets
->autochk_sec_spinbtn
),
6054 PREFS_RECV_AUTOCHECK_MIN_INTERVAL
);
6059 //Automation of the oauth2 authorisation process to receive loopback callback generated by redirect in browser
6060 static void prefs_account_oauth2_listener(GTask
*task
, gpointer source
, gpointer task_data
, GCancellable
*cancellable
)
6062 struct Oauth2Listener
*oauth2_listener_data
= (struct Oauth2Listener
*)task_data
;
6063 unsigned int socket_desc
;
6065 struct sockaddr_in server
, client
;
6066 char client_message
[2000];
6068 char *reply_message
;
6073 struct timeval timeout
;
6075 debug_print("oauth2 listener task running\n");
6078 socket_desc
= socket(AF_INET
, SOCK_STREAM
, 0);
6079 if (socket_desc
== -1)
6081 debug_print("oauth2 listener could not create socket\n");
6082 g_task_return_boolean (task
, TRUE
);
6083 g_object_unref (task
);
6086 debug_print("oauth2 listener socket created\n");
6088 //Prepare the sockaddr_in structure
6089 server
.sin_family
= AF_INET
;
6090 server
.sin_addr
.s_addr
= INADDR_ANY
;
6091 server
.sin_port
= htons( 8888 );
6094 if( bind(socket_desc
,(struct sockaddr
*)&server
, sizeof(server
)) < 0)
6097 debug_print("oauth2 listener bind failed\n");
6098 g_task_return_boolean (task
, TRUE
);
6099 g_object_unref (task
);
6102 debug_print("oauth2 listener bind done\n");
6104 listen(socket_desc
, 1);
6106 //Accept and incoming connection
6107 debug_print("oauth2 listener waiting for incoming connections...\n");
6108 c
= sizeof(struct sockaddr_in
);
6112 FD_SET(socket_desc
, &rfds
);
6114 timeout
.tv_usec
= 0;
6116 select(socket_desc
+1, &rfds
, NULL
, NULL
, &timeout
);
6118 //select woke up, maybe accept connection from an incoming client
6119 if(FD_ISSET(socket_desc
, &rfds
)){
6120 client_sock
= accept(socket_desc
, (struct sockaddr
*)&client
, (socklen_t
*)&c
);
6121 if (client_sock
< 0){
6122 debug_print("oauth2 listener accept failed\n");
6123 g_task_return_boolean (task
, TRUE
);
6124 g_object_unref (task
);
6127 debug_print("oauth2 listener connection accepted\n");
6129 //Receive message sent to the loopback address by the authorisation page
6130 prefs_account_oauth2_get_line(client_sock
, client_message
, sizeof(client_message
));
6131 oauth2_listener_data
->trim_text
= g_strdup(client_message
);
6132 g_strstrip(oauth2_listener_data
->trim_text
);
6134 ret
= oauth2_obtain_tokens (oauth2_listener_data
->service
, oauth2_listener_data
->OAUTH2Data
, oauth2_listener_data
->trim_text
);
6137 oauth2_listener_data
->success
= TRUE
;
6138 title
= _("Authorisation complete");
6139 body
= _("Your OAuth2 authorisation code has been received by Claws Mail");
6141 //Something went wrong
6142 title
= _("Authorisation NOT completed");
6143 body
= _("Your OAuth2 authorisation code was not received by Claws Mail");
6144 log_message(LOG_PROTOCOL
, "OAuth2 authorisation code not received\n");
6146 reply_message
= g_strconcat("<html><head><title>", title
,
6147 "</title><meta charset=\"utf-8\"></head><body><h1>", title
,
6148 "</h1><p>", body
, "</p></body></html>", NULL
);
6149 reply
= g_strdup_printf(
6150 "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nContent-Length: %lu\r\n\r\n%s",
6151 strlen(reply_message
), reply_message
);
6152 g_free(reply_message
);
6153 write(client_sock
, reply
, strlen(reply
));
6157 }while(ret
&& !oauth2_listener_cancel
);
6160 debug_print("oauth2 closing task\n");
6161 g_task_return_boolean (task
, TRUE
);
6162 g_object_unref (task
);
6165 static void prefs_account_oauth2_callback(GObject
*source
, GAsyncResult
*res
, gpointer user_data
)
6167 struct Oauth2Listener
*oauth2_listener_data
= (struct Oauth2Listener
*)user_data
;
6169 if(oauth2_listener_data
->success
){
6170 debug_print("oauth2 listener callback storing data and updating GUI\n");
6172 if(oauth2_listener_data
->OAUTH2Data
->refresh_token
!= NULL
){
6173 passwd_store_set_account(tmp_ac_prefs
.account_id
,
6174 PWS_ACCOUNT_OAUTH2_REFRESH
,
6175 oauth2_listener_data
->OAUTH2Data
->refresh_token
,
6177 log_message(LOG_PROTOCOL
, "OAuth2 refresh token stored\n");
6180 if(oauth2_listener_data
->OAUTH2Data
->access_token
!= NULL
){
6181 passwd_store_set_account(tmp_ac_prefs
.account_id
,
6183 oauth2_listener_data
->OAUTH2Data
->access_token
,
6185 passwd_store_set_account(tmp_ac_prefs
.account_id
,
6187 oauth2_listener_data
->OAUTH2Data
->access_token
,
6189 log_message(LOG_PROTOCOL
, "OAuth2 access token stored\n");
6192 if(oauth2_listener_data
->OAUTH2Data
->expiry_str
!= NULL
){
6193 passwd_store_set_account(tmp_ac_prefs
.account_id
,
6194 PWS_ACCOUNT_OAUTH2_EXPIRY
,
6195 oauth2_listener_data
->OAUTH2Data
->expiry_str
,
6197 log_message(LOG_PROTOCOL
, "OAuth2 access token expiry stored\n");
6200 tmp_ac_prefs
.oauth2_date
= g_get_real_time () / G_USEC_PER_SEC
;
6202 gtk_entry_set_text(GTK_ENTRY(oauth2_page
.oauth2_authcode_entry
), oauth2_listener_data
->trim_text
!= NULL
? oauth2_listener_data
->trim_text
: "");
6203 gtk_widget_set_sensitive(oauth2_page
.oauth2_authcode_entry
, FALSE
);
6204 gtk_widget_set_sensitive(oauth2_page
.oauth2_authorise_btn
, FALSE
);
6205 gtk_entry_set_text(GTK_ENTRY(basic_page
.pass_entry
), oauth2_listener_data
->OAUTH2Data
->access_token
);
6206 gtk_entry_set_text(GTK_ENTRY(send_page
.smtp_pass_entry
), oauth2_listener_data
->OAUTH2Data
->access_token
);
6209 debug_print("oauth2 listener callback freeing resources\n");
6210 g_free(oauth2_listener_data
->trim_text
);
6211 g_free(oauth2_listener_data
->OAUTH2Data
);
6212 g_free(oauth2_listener_data
);
6213 oauth2_listener_cancel
= 0;
6214 oauth2_listener_closed
= 1;
6217 static int prefs_account_oauth2_get_line(int sock
, char *buf
, int size
)
6223 while ((i
< size
- 1) && (c
!= '\n')) {
6224 n
= recv(sock
, &c
, 1, 0);
6225 //printf("%02X\n", c);
6228 n
= recv(sock
, &c
, 1, MSG_PEEK
);
6229 //printf("%02X\n", c);
6230 if ((n
> 0) && (c
== '\n')) {
6231 n
= recv(sock
, &c
, 1, 0);
6233 log_message(LOG_PROTOCOL
, "Receiving from pipe failed\n");