2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2015 Colin Leroy <colin@colino.net>
4 * and the Claws Mail team
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "claws-features.h"
28 #include <glib/gi18n.h>
29 #include <gdk/gdkkeysyms.h>
41 #include "prefs_account.h"
42 #include "mainwindow.h"
43 #include "stock_pixmap.h"
46 #include "alertpanel.h"
51 #include "prefs_common.h"
62 int WELCOME_PAGE = -1;
66 int MAILBOX_PAGE = -1;
79 GtkWidget *organization;
81 GtkWidget *mailbox_name;
82 GtkWidget *mailbox_label;
84 GtkWidget *smtp_server;
86 GtkWidget *smtp_username;
87 GtkWidget *smtp_password;
88 GtkWidget *smtp_username_label;
89 GtkWidget *smtp_password_label;
92 GtkWidget *recv_label;
93 GtkWidget *recv_server;
94 GtkWidget *recv_username;
95 GtkWidget *recv_password;
96 GtkWidget *recv_username_label;
97 GtkWidget *recv_password_label;
98 GtkWidget *recv_imap_label;
99 GtkWidget *recv_imap_subdir;
100 GtkWidget *subsonly_checkbtn;
101 GtkWidget *no_imap_warning;
103 GtkWidget *smtp_use_ssl;
104 GtkWidget *recv_use_ssl;
105 GtkWidget *smtp_use_tls;
106 GtkWidget *recv_use_tls;
107 GtkWidget *smtp_ssl_cert_file;
108 GtkWidget *recv_ssl_cert_file;
109 GtkWidget *smtp_ssl_cert_pass;
110 GtkWidget *recv_ssl_cert_pass;
111 GtkWidget *smtp_cert_table;
112 GtkWidget *recv_cert_table;
114 #if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
115 GtkWidget *auto_configure_lbl;
116 GtkWidget *auto_configure_btn;
117 GtkWidget *auto_configure_cancel_btn;
119 gboolean create_mailbox;
125 typedef struct _AccountTemplate {
134 RecvProtocol recvtype;
146 gchar *smtpssl_cert_pass;
147 gchar *recvssl_cert_pass;
150 static AccountTemplate tmpl;
152 static PrefParam template_params[] = {
153 {"name", "$USERNAME",
154 &tmpl.name, P_STRING, NULL, NULL, NULL},
155 {"domain", "$DEFAULTDOMAIN",
156 &tmpl.domain, P_STRING, NULL, NULL, NULL},
157 {"email", "$NAME_MAIL@$DOMAIN",
158 &tmpl.email, P_STRING, NULL, NULL, NULL},
160 &tmpl.organization, P_STRING, NULL, NULL, NULL},
161 {"smtpserver", "smtp.$DOMAIN",
162 &tmpl.smtpserver, P_STRING, NULL, NULL, NULL},
163 {"smtpauth", "FALSE",
164 &tmpl.smtpauth, P_BOOL, NULL, NULL, NULL},
166 &tmpl.smtpuser, P_STRING, NULL, NULL, NULL},
168 &tmpl.smtppass, P_STRING, NULL, NULL, NULL},
170 &tmpl.recvtype, P_INT, NULL, NULL, NULL},
171 {"recvserver", "pop.$DOMAIN",
172 &tmpl.recvserver, P_STRING, NULL, NULL, NULL},
173 {"recvuser", "$LOGIN",
174 &tmpl.recvuser, P_STRING, NULL, NULL, NULL},
176 &tmpl.recvpass, P_STRING, NULL, NULL, NULL},
178 &tmpl.imapdir, P_STRING, NULL, NULL, NULL},
180 &tmpl.subsonly, P_BOOL, NULL, NULL, NULL},
181 {"mboxfile", "/var/mail/$LOGIN",
182 &tmpl.mboxfile, P_STRING, NULL, NULL, NULL},
184 &tmpl.mailbox, P_STRING, NULL, NULL, NULL},
186 &tmpl.smtpssl, P_INT, NULL, NULL, NULL},
188 &tmpl.recvssl, P_INT, NULL, NULL, NULL},
190 &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
192 &tmpl.recvssl_cert, P_STRING, NULL, NULL, NULL},
193 {"smtpssl_cert_pass", "",
194 &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
195 {"recvssl_cert_pass", "",
196 &tmpl.recvssl_cert, P_STRING, NULL, NULL, NULL},
197 {NULL, NULL, NULL, P_INT, NULL, NULL, NULL}
201 static gchar *accountrc_tmpl =
202 "[AccountTemplate]\n"
203 "#you can use $DEFAULTDOMAIN here\n"
204 "#domain must be defined before the variables that use it\n"
205 "#by default, domain is extracted from the hostname\n"
208 "#you can use $USERNAME for name (this is the default)\n"
211 "#you can use $LOGIN, $NAME_MAIL and $DOMAIN here \n"
212 "#$NAME_MAIL is the name without uppercase and with dots instead\n"
214 "#the default is $NAME_MAIL@$DOMAIN\n"
217 "#you can use $DOMAIN here\n"
218 "#the default organization is empty\n"
221 "#you can use $DOMAIN here \n"
222 "#the default is smtp.$DOMAIN\n"
225 "#Whether to use smtp authentication\n"
226 "#the default is 0 (no)\n"
230 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
231 "#the default is empty (same as reception username)\n"
235 "#the default is empty (same as reception password)\n"
238 "#recvtype can be:\n"
241 "#5 for a local mbox file\n"
244 "#you can use $DOMAIN here \n"
245 "#the default is {pop,imap}.$DOMAIN\n"
248 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
249 "#default is $LOGIN\n"
252 "#default is empty\n"
255 "#imap dir if imap (relative to the home on the server)\n"
256 "#default is empty\n"
259 "#show subscribed folders only, if imap\n"
263 "#mbox file if local\n"
264 "#you can use $LOGIN here\n"
265 "#default is /var/mail/$LOGIN\n"
268 "#mailbox name if pop3 or local\n"
269 "#relative path from the user's home\n"
270 "#default is \"Mail\"\n"
273 "#whether to use ssl on smtp connections\n"
274 "#default is 0, 1 is ssl, 2 is starttls\n"
277 "#whether to use ssl on pop or imap connections\n"
278 "#default is 0, 1 is ssl, 2 is starttls\n"
281 "#SSL client certificate path for SMTP\n"
282 "#default is empty (no certificate)\n"
285 "#SSL client certificate path for POP/IMAP\n"
286 "#default is empty (no certificate)\n"
289 "#SSL client certificate password for SMTP\n"
290 "#default is empty (no password)\n"
291 "#smtpssl_cert_pass=\n"
293 "#SSL client certificate password for POP/IMAP\n"
294 "#default is empty (no password)\n"
295 "#recvssl_cert_pass=\n"
298 static gchar *wizard_get_default_domain_name(void)
300 static gchar *domain_name = NULL;
302 if (domain_name == NULL) {
303 domain_name = g_strdup(get_domain_name());
304 if (strchr(domain_name, '.') != NULL
305 && strchr(domain_name, '.') != strrchr(domain_name, '.')
306 && strlen(strchr(domain_name, '.')) > 6) {
307 gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
315 static gchar *get_name_for_mail(void)
318 if (tmpl.name == NULL)
320 name = g_utf8_strdown(tmpl.name, -1);
321 while(strstr(name, " "))
322 *strstr(name, " ")='.';
327 #define PARSE_DEFAULT(str) { \
328 gchar *tmp = NULL, *new = NULL; \
330 if (strstr(str, "$USERNAME")) { \
331 tmp = g_strdup(str); \
332 *strstr(tmp, "$USERNAME") = '\0'; \
333 new = g_strconcat(tmp, g_get_real_name(), \
334 strstr(str, "$USERNAME")+strlen("$USERNAME"), \
341 if (strstr(str, "$LOGIN")) { \
342 tmp = g_strdup(str); \
343 *strstr(tmp, "$LOGIN") = '\0'; \
344 new = g_strconcat(tmp, g_get_user_name(), \
345 strstr(str, "$LOGIN")+strlen("$LOGIN"), \
352 if (strstr(str, "$EMAIL")) { \
353 tmp = g_strdup(str); \
354 *strstr(tmp, "$EMAIL") = '\0'; \
355 new = g_strconcat(tmp, tmpl.email, \
356 strstr(str, "$EMAIL")+strlen("$EMAIL"), \
363 if (strstr(str, "$NAME_MAIL")) { \
364 tmp = g_strdup(str); \
365 *strstr(tmp, "$NAME_MAIL") = '\0'; \
366 new = g_strconcat(tmp, get_name_for_mail(), \
367 strstr(str, "$NAME_MAIL")+strlen("$NAME_MAIL"), \
374 if (strstr(str, "$DEFAULTDOMAIN")) { \
375 tmp = g_strdup(str); \
376 *strstr(tmp, "$DEFAULTDOMAIN") = '\0'; \
377 new = g_strconcat(tmp, wizard_get_default_domain_name(), \
378 strstr(str, "$DEFAULTDOMAIN")+strlen("$DEFAULTDOMAIN"), \
385 if (strstr(str, "$DOMAIN")) { \
386 tmp = g_strdup(str); \
387 *strstr(tmp, "$DOMAIN") = '\0'; \
388 new = g_strconcat(tmp, tmpl.domain, \
389 strstr(str, "$DOMAIN")+strlen("$DOMAIN"), \
398 static void wizard_read_defaults(void)
402 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "accountrc.tmpl", NULL);
403 if (!is_file_exist(rcpath)) {
404 str_write_to_file(accountrc_tmpl, rcpath);
407 prefs_read_config(template_params, "AccountTemplate", rcpath, NULL);
409 PARSE_DEFAULT(tmpl.domain);
410 PARSE_DEFAULT(tmpl.name);
411 PARSE_DEFAULT(tmpl.email);
412 PARSE_DEFAULT(tmpl.organization);
413 PARSE_DEFAULT(tmpl.smtpserver);
414 PARSE_DEFAULT(tmpl.smtpuser);
415 PARSE_DEFAULT(tmpl.smtppass);
416 PARSE_DEFAULT(tmpl.recvserver);
417 PARSE_DEFAULT(tmpl.recvuser);
418 PARSE_DEFAULT(tmpl.recvpass);
419 PARSE_DEFAULT(tmpl.imapdir);
420 PARSE_DEFAULT(tmpl.mboxfile);
421 PARSE_DEFAULT(tmpl.mailbox);
424 "%s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %s, %s, %d, %d\n",
425 tmpl.name,tmpl.domain,tmpl.email,tmpl.organization,tmpl.smtpserver,
426 tmpl.recvtype,tmpl.recvserver,tmpl.recvuser,tmpl.recvpass,
427 tmpl.imapdir,tmpl.mboxfile,tmpl.mailbox,tmpl.smtpssl,tmpl.recvssl);
432 static void initialize_fonts(WizardWindow *wizard)
434 GtkWidget *widget = wizard->email;
435 gint size = pango_font_description_get_size(
436 gtk_widget_get_style(widget)->font_desc)
440 PangoFontDescription *bold_desc;
441 gchar *curfont = pango_font_description_to_string(widget->style->font_desc);
442 g_free(prefs_common.smallfont);
443 g_free(prefs_common.normalfont);
444 g_free(prefs_common.boldfont);
445 prefs_common.smallfont = g_strdup(curfont);
446 prefs_common.normalfont = g_strdup(curfont);
447 bold_desc = pango_font_description_from_string(curfont);
448 pango_font_description_set_weight(bold_desc, PANGO_WEIGHT_BOLD);
449 prefs_common.boldfont = pango_font_description_to_string(bold_desc);
450 pango_font_description_free(bold_desc);
453 tmp = g_strdup(prefs_common.textfont);
454 if (strrchr(tmp, ' ')) {
455 *(strrchr(tmp, ' ')) = '\0';
456 new = g_strdup_printf("%s %d", tmp, size);
457 g_free(prefs_common.textfont);
458 prefs_common.textfont = new;
462 tmp = g_strdup(prefs_common.smallfont);
463 if (strrchr(tmp, ' ')) {
464 *(strrchr(tmp, ' ')) = '\0';
465 new = g_strdup_printf("%s %d", tmp, size);
466 g_free(prefs_common.smallfont);
467 prefs_common.smallfont = new;
471 tmp = g_strdup(prefs_common.normalfont);
472 if (strrchr(tmp, ' ')) {
473 *(strrchr(tmp, ' ')) = '\0';
474 new = g_strdup_printf("%s %d", tmp, size);
475 g_free(prefs_common.normalfont);
476 prefs_common.normalfont = new;
480 tmp = g_strdup(prefs_common.boldfont);
481 if (strrchr(tmp, ' ')) {
482 *(strrchr(tmp, ' ')) = '\0';
483 new = g_strdup_printf("%s %d", tmp, size);
484 g_free(prefs_common.boldfont);
485 prefs_common.boldfont = new;
490 #define XFACE "+}Axz@~a,-Yx?0Ysa|q}CLRH=89Y]\"')DSX^<6p\"d)'81yx5%G#u^o*7JG&[aPU0h1Ux.vb2yIjH83{5`/bVo|~nn/i83vE^E)qk-4W)_E.4Y=D*qvf/,Ci_=P<iY<M6"
491 #define FACE "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAM1BMVEUAAAAcJCI\n\
492 ONl1JUi0+Z4daY2NZciPabV9ykS5kj6Wsl2ybmZOBsMjZxK2wzN3Pzczs7OsCAGN0AAAAAXRSTlM\n\
493 AQObYZgAAAAFiS0dEAIgFHUgAAAIVSURBVEjH1ZbtlqMgDIaFECoGhPu/2s0b0Lais/NzN6d1OJ7\n\
494 3yReQzrL8B5Zy3rvl9At52Pf2tv1vSMjtYj8jaa8XUyI/yn3YD6sigj/2Tf5Bn069MIsTPHvx/t5\n\
495 /3rU/6JCIY3YwGe26r/cwUfE3cFe5T28L0K5rJAUHEeYAQxs8DHojjk3M9wECU4xxjXisI8RA0gy\n\
496 oczJZJOjxiTFZVTchAnIRJrgdmEGDyFfAI3UuG5FmYTkR9RDrIC4H0SqV4pzpEcUp0HNLjwBv+jA\n\
497 dikUE5g9iBvzmu3sH2oDk4lnHd829+2Q9gj6kDqDPg7hsGwBzH02fE3ZCt6ZHmlNKIMjMeRwra5I\n\
498 ecgNoBnLGPmzaHPJIwLY8Sq2M/tLUJfj0QcqmfVXAdLSStIYF8dzWjBBb2VgvDa4mO9oc651OiUo\n\
499 BEKbZokdPATF9E9oKAjQJcJOniaPXrVZRAnVWaqIyqRoNC8ZJvgCcW8XN39RqxVP1rS8Yd4WnCdN\n\
500 aRTo2jJRDbg3vtCpEUGffgDPhqKDaSuVqYtOplFIvIcx3HUI5/MuIWl6vKyBjNlqEru8hbFXqBPA\n\
501 5TpHGIUZOePeaIyzfQ/g9Xg0opU1AvdfXM9floYhv92pPAE96OZtkPV8eivgQi9RTfwPUU36I26n\n\
502 Hy+WuCJzAT7efMSeA1TNf2/VugDz+dN139xfA5ffxGZDD+MvcP/uvyB80wzZ76wbz8gAAAABJRU5\n\
505 static void write_welcome_email(WizardWindow *wizard)
511 const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name));
512 Folder *folder = folder_find_from_path(mailbox);
513 FolderItem *inbox = folder ? folder->inbox:NULL;
514 gchar *file = get_tmp_file();
515 gchar enc_from_name[BUFFSIZE], enc_to_name[BUFFSIZE], enc_subject[BUFFSIZE];
517 get_rfc822_date(buf_date, sizeof(buf_date));
519 conv_encode_header_full(enc_subject, sizeof(enc_subject),
520 C_("Welcome Mail Subject", "Welcome to Claws Mail"),
521 strlen("Subject: "), FALSE, CS_INTERNAL);
522 conv_encode_header_full(enc_to_name, sizeof(enc_to_name),
523 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)),
524 strlen("To: "), TRUE, CS_INTERNAL);
525 conv_encode_header_full(enc_from_name, sizeof(enc_from_name),
526 _("The Claws Mail Team"),
527 strlen("From: "), TRUE, CS_INTERNAL);
529 head = g_strdup_printf(
536 "Content-Type: text/plain; charset=UTF-8\n",
540 gtk_entry_get_text(GTK_ENTRY(wizard->email)),
541 buf_date, enc_subject, XFACE, FACE);
542 body = g_strdup_printf(
544 "Welcome to Claws Mail\n"
545 "---------------------\n"
547 "Now that you have set up your account you can fetch your\n"
548 "mail by clicking the 'Get Mail' button at the left of the\n"
551 "Claws Mail has lots of extra features accessible via plugins,\n"
552 "like anti-spam filtering and learning (via the Bogofilter or\n"
553 "SpamAssassin plugins), privacy protection (via PGP/Mime), an RSS\n"
554 "aggregator, a calendar, and much more. You can load them from\n"
555 "the menu entry '/Configuration/Plugins'.\n"
557 "You can change your Account Preferences by using the menu\n"
558 "entry '/Configuration/Preferences for current account'\n"
559 "and change the general Preferences by using\n"
560 "'/Configuration/Preferences'.\n"
562 "You can find further information in the Claws Mail manual,\n"
563 "which can be accessed by using the menu entry '/Help/Manual'\n"
564 "or online at the URL given below.\n"
572 "Mailing Lists: <%s>\n"
576 "Claws Mail is free software, released under the terms\n"
577 "of the GNU General Public License, version 3 or later, as\n"
578 "published by the Free Software Foundation, 51 Franklin Street,\n"
579 "Fifth Floor, Boston, MA 02110-1301, USA. The license can be\n"
584 "If you wish to donate to the Claws Mail project you can do\n"
586 HOMEPAGE_URI, MANUAL_URI, FAQ_URI, THEMES_URI, MAILING_LIST_URI,
587 GPL_URI, DONATE_URI);
589 msg = g_strconcat(head, body, NULL);
591 if (inbox && inbox->total_msgs == 0
592 && str_write_to_file(msg, file) >= 0) {
593 MsgFlags flags = { MSG_UNREAD|MSG_NEW, 0};
594 folder_item_add_msg(inbox, file, &flags, FALSE);
603 static gboolean wizard_write_config(WizardWindow *wizard)
605 static gboolean mailbox_ok = FALSE;
606 PrefsAccount *prefs_account = prefs_account_new();
607 GList *account_list = NULL;
608 gchar *smtp_server, *recv_server;
609 gint smtp_port, recv_port;
611 SSLType smtp_ssl_type, recv_ssl_type;
614 prefs_account->protocol = combobox_get_active_data(
615 GTK_COMBO_BOX(wizard->recv_type));
617 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4 &&
618 !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)))) {
619 alertpanel_error(_("Please enter the mailbox name."));
620 g_free(prefs_account);
621 gtk_notebook_set_current_page (
622 GTK_NOTEBOOK(wizard->notebook),
628 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
629 mailbox_ok = setup_write_mailbox_path(wizard->mainwin,
631 GTK_ENTRY(wizard->mailbox_name)));
637 /* alertpanel done by setup_write_mailbox_path */
638 g_free(prefs_account);
639 gtk_notebook_set_current_page (
640 GTK_NOTEBOOK(wizard->notebook),
645 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->full_name)))
646 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->email)))) {
647 alertpanel_error(_("Please enter your name and email address."));
648 g_free(prefs_account);
649 gtk_notebook_set_current_page (
650 GTK_NOTEBOOK(wizard->notebook),
655 if (prefs_account->protocol != A_LOCAL) {
656 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)))
657 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
658 alertpanel_error(_("Please enter your receiving server "
660 g_free(prefs_account);
661 gtk_notebook_set_current_page (
662 GTK_NOTEBOOK(wizard->notebook),
667 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
668 alertpanel_error(_("Please enter your username."));
669 g_free(prefs_account);
670 gtk_notebook_set_current_page (
671 GTK_NOTEBOOK(wizard->notebook),
677 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)))) {
678 alertpanel_error(_("Please enter your SMTP server."));
679 g_free(prefs_account);
680 gtk_notebook_set_current_page (
681 GTK_NOTEBOOK(wizard->notebook),
686 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
687 if (prefs_account->protocol == A_LOCAL
688 && !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)))) {
689 alertpanel_error(_("Please enter your SMTP username."));
690 g_free(prefs_account);
691 gtk_notebook_set_current_page (
692 GTK_NOTEBOOK(wizard->notebook),
695 } /* if it's not local we'll use the reception server */
698 if (prefs_account->protocol != A_LOCAL)
699 prefs_account->account_name = g_strdup_printf("%s@%s",
700 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)),
701 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
703 prefs_account->account_name = g_strdup_printf("%s",
704 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
706 recv_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
707 smtp_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)));
709 if (prefs_account->protocol != A_LOCAL && strstr(recv_server, ":")) {
710 recv_port = atoi(strstr(recv_server, ":")+1);
711 *(strstr(recv_server, ":")) = '\0';
712 if (prefs_account->protocol == A_IMAP4) {
713 prefs_account->set_imapport = TRUE;
714 prefs_account->imapport = recv_port;
715 } else if (prefs_account->protocol == A_POP3) {
716 prefs_account->set_popport = TRUE;
717 prefs_account->popport = recv_port;
720 if (strstr(smtp_server, ":")) {
721 smtp_port = atoi(strstr(smtp_server, ":")+1);
722 *(strstr(smtp_server, ":")) = '\0';
723 prefs_account->set_smtpport = TRUE;
724 prefs_account->smtpport = smtp_port;
727 prefs_account->name = g_strdup(
728 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)));
729 prefs_account->address = g_strdup(
730 gtk_entry_get_text(GTK_ENTRY(wizard->email)));
731 prefs_account->organization = g_strdup(
732 gtk_entry_get_text(GTK_ENTRY(wizard->organization)));
733 prefs_account->smtp_server = g_strdup(smtp_server);
735 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
737 tmp = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
738 prefs_account->inbox = g_strdup_printf("#mh/%s/inbox",
739 (!strcmp("Mail", gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name))))
742 prefs_account->local_inbox = g_strdup(prefs_account->inbox);
743 } else if (prefs_account->protocol != A_IMAP4) {
744 if (folder_get_default_inbox())
745 prefs_account->local_inbox =
746 folder_item_get_identifier(folder_get_default_inbox());
749 if (prefs_account->protocol != A_LOCAL)
750 prefs_account->recv_server = g_strdup(recv_server);
752 prefs_account->local_mbox = g_strdup(recv_server);
757 prefs_account->userid = g_strdup(
758 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)));
759 prefs_account->passwd = g_strdup(
760 gtk_entry_get_text(GTK_ENTRY(wizard->recv_password)));
762 prefs_account->smtp_userid = g_strdup(
763 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)));
764 prefs_account->smtp_passwd = g_strdup(
765 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_password)));
766 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
767 prefs_account->use_smtp_auth = TRUE;
771 smtp_ssl_type = SSL_NONE;
772 recv_ssl_type = SSL_NONE;
774 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl))) {
775 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls)))
776 smtp_ssl_type = SSL_STARTTLS;
778 smtp_ssl_type = SSL_TUNNEL;
780 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl))) {
781 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls)))
782 recv_ssl_type = SSL_STARTTLS;
784 recv_ssl_type = SSL_TUNNEL;
787 prefs_account->ssl_smtp = smtp_ssl_type;
789 if (prefs_account->protocol == A_IMAP4)
790 prefs_account->ssl_imap = recv_ssl_type;
792 prefs_account->ssl_pop = recv_ssl_type;
794 prefs_account->out_ssl_client_cert_file = g_strdup(
795 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_ssl_cert_file)));
796 prefs_account->out_ssl_client_cert_pass = g_strdup(
797 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_ssl_cert_pass)));
798 prefs_account->in_ssl_client_cert_file = g_strdup(
799 gtk_entry_get_text(GTK_ENTRY(wizard->recv_ssl_cert_file)));
800 prefs_account->in_ssl_client_cert_pass = g_strdup(
801 gtk_entry_get_text(GTK_ENTRY(wizard->recv_ssl_cert_pass)));
803 if (prefs_account->protocol == A_IMAP4) {
804 gchar *directory = gtk_editable_get_chars(
805 GTK_EDITABLE(wizard->recv_imap_subdir), 0, -1);
806 if (directory && strlen(directory)) {
807 prefs_account->imap_dir = g_strdup(directory);
809 prefs_account->imap_subsonly =
810 gtk_toggle_button_get_active(
811 GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn));
815 account_list = g_list_append(account_list, prefs_account);
816 prefs_account_write_config_all(account_list);
817 prefs_account_free(prefs_account);
818 account_read_config_all();
820 initialize_fonts(wizard);
821 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
822 write_welcome_email(wizard);
825 plugin_load_standard_plugins();
830 static GtkWidget* create_page (WizardWindow *wizard, const char * title)
838 vbox = gtk_vbox_new (FALSE, 6);
839 gtk_container_set_border_width (GTK_CONTAINER(vbox), 10);
841 /* create the titlebar */
842 hbox = gtk_hbox_new (FALSE, 12);
843 image = stock_pixmap_widget(wizard->window,
844 STOCK_PIXMAP_CLAWS_MAIL_ICON);
845 gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 0);
846 title_string = g_strconcat ("<span size=\"xx-large\" weight=\"ultrabold\">", title ? title : "", "</span>", NULL);
847 w = gtk_label_new (title_string);
848 gtk_label_set_use_markup (GTK_LABEL(w), TRUE);
849 g_free (title_string);
850 gtk_box_pack_start (GTK_BOX(hbox), w, FALSE, FALSE, 0);
852 /* pack the titlebar */
853 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
855 /* pack the separator */
856 gtk_box_pack_start (GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
859 w = gtk_alignment_new (0, 0, 0, 0);
860 gtk_widget_set_size_request (w, 0, 6);
861 gtk_box_pack_start (GTK_BOX(vbox), w, FALSE, FALSE, 0);
866 #define PACK_BOX(hbox,text,entry) { \
867 GtkWidget *label = gtk_label_new(text); \
868 gtk_label_set_use_markup(GTK_LABEL(label), TRUE); \
869 if (GTK_IS_MISC(label)) \
870 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); \
871 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); \
872 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); \
875 static gchar *get_default_server(WizardWindow * wizard, const gchar *type)
877 if (!strcmp(type, "smtp")) {
878 if (!tmpl.smtpserver || !strlen(tmpl.smtpserver))
879 return g_strconcat(type, ".", tmpl.domain, NULL);
881 return g_strdup(tmpl.smtpserver);
883 if (!tmpl.recvserver || !strlen(tmpl.recvserver))
884 return g_strconcat(type, ".", tmpl.domain, NULL);
886 return g_strdup(tmpl.recvserver);
890 static gchar *get_default_account(WizardWindow * wizard)
892 gchar *result = NULL;
894 if (!tmpl.recvuser || !strlen(tmpl.recvuser)) {
895 result = gtk_editable_get_chars(
896 GTK_EDITABLE(wizard->email), 0, -1);
898 if (strstr(result, "@")) {
899 *(strstr(result,"@")) = '\0';
902 result = g_strdup(tmpl.recvuser);
907 static gchar *get_default_smtp_account(WizardWindow * wizard)
909 gchar *result = NULL;
911 if (!tmpl.smtpuser || !strlen(tmpl.smtpuser)) {
914 result = g_strdup(tmpl.smtpuser);
919 static void wizard_email_changed(GtkWidget *widget, gpointer data)
921 WizardWindow *wizard = (WizardWindow *)data;
922 RecvProtocol protocol;
924 protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
926 text = get_default_server(wizard, "smtp");
927 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
930 text = get_default_account(wizard);
931 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
934 if (protocol == A_POP3) {
935 text = get_default_server(wizard, "pop");
936 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
938 } else if (protocol == A_IMAP4) {
939 text = get_default_server(wizard, "imap");
940 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
942 } else if (protocol == A_LOCAL) {
943 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
948 static GtkWidget* user_page (WizardWindow * wizard)
950 GtkWidget *table = gtk_table_new(1,1, FALSE);
953 GtkWidget *user_table;
955 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
956 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
958 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
959 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
961 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
962 GTK_EXPAND|GTK_FILL, 0, 0, 0);
964 user_table = gtk_table_new(3, 2, FALSE);
965 gtk_table_set_row_spacings(GTK_TABLE(user_table), VSPACING_NARROW);
966 gtk_box_pack_start(GTK_BOX(vbox), user_table, FALSE, FALSE, 0);
968 label = gtk_label_new(g_strconcat("<span weight=\"bold\">", _("Your name:"),
970 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
971 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
972 gtk_table_attach(GTK_TABLE(user_table), label, 0,1,0,1,
973 GTK_FILL, 0, VSPACING_NARROW, 0);
974 wizard->full_name = gtk_entry_new();
975 gtk_entry_set_text(GTK_ENTRY(wizard->full_name), tmpl.name?tmpl.name:"");
976 gtk_table_attach(GTK_TABLE(user_table), wizard->full_name, 1,2,0,1,
977 GTK_EXPAND|GTK_FILL, 0, 0, 0);
979 label = gtk_label_new(g_strconcat("<span weight=\"bold\">", _("Your email address:"),
981 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
982 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
983 gtk_table_attach(GTK_TABLE(user_table), label, 0,1,1,2,
984 GTK_FILL, 0, VSPACING_NARROW, 0);
985 wizard->email = gtk_entry_new();
986 gtk_entry_set_text(GTK_ENTRY(wizard->email), tmpl.email?tmpl.email:"");
987 gtk_table_attach(GTK_TABLE(user_table), wizard->email, 1,2,1,2,
988 GTK_EXPAND|GTK_FILL, 0, 0, 0);
990 label = gtk_label_new(_("Your organization:"));
991 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
992 gtk_table_attach(GTK_TABLE(user_table), label, 0,1,2,3,
993 GTK_FILL, 0, VSPACING_NARROW, 0);
994 wizard->organization = gtk_entry_new();
995 gtk_entry_set_text(GTK_ENTRY(wizard->organization), tmpl.organization?tmpl.organization:"");
996 gtk_table_attach(GTK_TABLE(user_table), wizard->organization, 1,2,2,3,
997 GTK_EXPAND|GTK_FILL, 0, 0, 0);
999 g_signal_connect(G_OBJECT(wizard->email), "changed",
1000 G_CALLBACK(wizard_email_changed),
1005 static GtkWidget* mailbox_page (WizardWindow * wizard)
1007 GtkWidget *table = gtk_table_new(1,1, FALSE);
1011 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1012 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1014 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1015 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1017 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1018 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1020 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1021 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1023 wizard->mailbox_label = gtk_label_new(g_strconcat("<span weight=\"bold\">",
1024 _("Mailbox name:"), "</span>", NULL));
1025 gtk_label_set_use_markup(GTK_LABEL(wizard->mailbox_label), TRUE);
1026 if (GTK_IS_MISC(wizard->mailbox_label))
1027 gtk_misc_set_alignment(GTK_MISC(wizard->mailbox_label), 1, 0.5);
1028 wizard->mailbox_name = gtk_entry_new();
1030 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), tmpl.mailbox?tmpl.mailbox:"");
1032 CLAWS_SET_TIP(wizard->mailbox_name, _("You can also specify an absolute path, for example: "
1033 "\"/home/john/Documents/Mail\""));
1035 gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_label, FALSE, FALSE, 0);
1036 gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_name, TRUE, TRUE, 0);
1041 static void smtp_auth_changed (GtkWidget *btn, gpointer data)
1043 WizardWindow *wizard = (WizardWindow *)data;
1044 gboolean do_auth = gtk_toggle_button_get_active(
1045 GTK_TOGGLE_BUTTON(wizard->smtp_auth));
1046 gtk_widget_set_sensitive(wizard->smtp_username, do_auth);
1047 gtk_widget_set_sensitive(wizard->smtp_username_label, do_auth);
1048 gtk_widget_set_sensitive(wizard->smtp_password, do_auth);
1049 gtk_widget_set_sensitive(wizard->smtp_password_label, do_auth);
1053 static void cert_browse_cb(GtkWidget *widget, gpointer data)
1055 GtkEntry *dest = GTK_ENTRY(data);
1057 gchar *utf8_filename;
1059 filename = filesel_select_file_open(_("Select certificate file"), NULL);
1060 if (!filename) return;
1062 utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
1063 if (!utf8_filename) {
1064 g_warning("cert_browse_cb(): failed to convert character set.");
1065 utf8_filename = g_strdup(filename);
1067 gtk_entry_set_text(dest, utf8_filename);
1068 g_free(utf8_filename);
1072 static GtkWidget* smtp_page (WizardWindow * wizard)
1074 GtkWidget *table = gtk_table_new(1, 1, FALSE);
1077 GtkWidget *hbox_spc;
1078 GtkWidget *smtp_auth_table;
1082 GtkWidget *smtp_cert_table;
1086 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1087 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1089 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1090 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1092 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1093 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1095 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1096 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1097 wizard->smtp_server = gtk_entry_new();
1098 text = get_default_server(wizard, "smtp");
1099 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
1102 CLAWS_SET_TIP(wizard->smtp_server,
1103 _("You can specify the port number by appending it at the end: "
1104 "\"mail.example.com:25\""));
1106 PACK_BOX(hbox, g_strconcat("<span weight=\"bold\">", _("SMTP server address:"),
1107 "</span>", NULL), wizard->smtp_server);
1109 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1110 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1111 wizard->smtp_auth = gtk_check_button_new_with_label(
1112 _("Use authentication"));
1113 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth),
1115 g_signal_connect(G_OBJECT(wizard->smtp_auth), "toggled",
1116 G_CALLBACK(smtp_auth_changed),
1118 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_auth, FALSE, FALSE, 0);
1120 label = gtk_label_new(g_strconcat("<span size=\"small\">",
1121 _("(empty to use the same as receive)"), "</span>", NULL));
1122 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
1123 SET_TOGGLE_SENSITIVITY (wizard->smtp_auth, label);
1124 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1126 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1127 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1128 hbox_spc = gtk_hbox_new (FALSE, 0);
1129 gtk_widget_set_size_request (hbox_spc, 12, -1);
1130 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1131 smtp_auth_table = gtk_table_new(2, 2, FALSE);
1132 SET_TOGGLE_SENSITIVITY (wizard->smtp_auth, smtp_auth_table);
1133 gtk_box_pack_start(GTK_BOX(hbox), smtp_auth_table, TRUE, TRUE, 0);
1135 wizard->smtp_username_label = gtk_label_new(_("SMTP username:"));
1136 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_username_label), 1, 0.5);
1137 gtk_table_attach(GTK_TABLE(smtp_auth_table), wizard->smtp_username_label, 0,1,0,1,
1138 GTK_FILL, 0, VSPACING_NARROW, 0);
1139 text = get_default_smtp_account(wizard);
1140 wizard->smtp_username = gtk_entry_new();
1141 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_username), text);
1143 gtk_table_attach(GTK_TABLE(smtp_auth_table), wizard->smtp_username, 1,2,0,1,
1144 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1146 wizard->smtp_password_label = gtk_label_new(_("SMTP password:"));
1147 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_password_label), 1, 0.5);
1148 gtk_table_attach(GTK_TABLE(smtp_auth_table), wizard->smtp_password_label, 0,1,1,2,
1149 GTK_FILL, 0, VSPACING_NARROW, 0);
1150 wizard->smtp_password = gtk_entry_new();
1151 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_password), tmpl.smtppass?tmpl.smtppass:"");
1152 gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_password), FALSE);
1153 gtk_table_attach(GTK_TABLE(smtp_auth_table), wizard->smtp_password, 1,2,1,2,
1154 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1156 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1157 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1158 wizard->smtp_use_ssl = gtk_check_button_new_with_label(
1159 _("Use SSL to connect to SMTP server"));
1160 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl),
1162 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_ssl, FALSE, FALSE, 0);
1164 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1165 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1166 hbox_spc = gtk_hbox_new (FALSE, 0);
1167 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1168 gtk_widget_set_size_request (hbox_spc, 12, -1);
1169 wizard->smtp_use_tls = gtk_check_button_new_with_label(
1170 _("Use SSL via STARTTLS"));
1171 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls),
1173 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_tls, FALSE, FALSE, 0);
1174 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_use_tls);
1176 smtp_cert_table = gtk_table_new(3,3, FALSE);
1177 gtk_box_pack_start (GTK_BOX(vbox), smtp_cert_table, FALSE, FALSE, 4);
1178 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1179 hbox_spc = gtk_hbox_new (FALSE, 0);
1180 gtk_widget_set_size_request (hbox_spc, 12, -1);
1181 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1182 label = gtk_label_new(_("Client SSL certificate (optional)"));
1183 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1184 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1185 gtk_table_attach(GTK_TABLE(smtp_cert_table), hbox, 0, 3, 0, 1, GTK_FILL, 0, 0, 0);
1186 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1187 hbox_spc = gtk_hbox_new (FALSE, 0);
1188 gtk_widget_set_size_request (hbox_spc, 12, -1);
1189 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1190 label = gtk_label_new(_("File"));
1191 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1192 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
1193 gtk_table_attach(GTK_TABLE(smtp_cert_table), hbox, 0, 1, 1, 2,
1194 GTK_FILL, 0, VSPACING_NARROW, 0);
1195 wizard->smtp_ssl_cert_file = gtk_entry_new();
1196 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_file), tmpl.smtpssl_cert?tmpl.smtpssl_cert:"");
1197 gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_file, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1198 button = gtkut_get_browse_file_btn(_("Browse"));
1199 gtk_table_attach(GTK_TABLE(smtp_cert_table), button, 2, 3, 1, 2,
1200 GTK_FILL, 0, VSPACING_NARROW, 0);
1201 g_signal_connect(G_OBJECT(button), "clicked",
1202 G_CALLBACK(cert_browse_cb), wizard->smtp_ssl_cert_file);
1204 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1205 hbox_spc = gtk_hbox_new (FALSE, 0);
1206 gtk_widget_set_size_request (hbox_spc, 12, -1);
1207 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1208 label = gtk_label_new(_("Password"));
1209 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1210 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
1211 gtk_table_attach(GTK_TABLE(smtp_cert_table), hbox, 0, 1, 2, 3,
1212 GTK_FILL, 0, VSPACING_NARROW, 0);
1213 wizard->smtp_ssl_cert_pass = gtk_entry_new();
1214 gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_ssl_cert_pass), FALSE);
1215 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_pass), tmpl.smtpssl_cert_pass?tmpl.smtpssl_cert_pass:"");
1216 gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_pass, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1217 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, smtp_cert_table);
1218 wizard->smtp_cert_table = smtp_cert_table;
1220 smtp_auth_changed(NULL, wizard);
1224 static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
1228 if (protocol == A_POP3) {
1229 text = get_default_server(wizard, "pop");
1230 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1231 gtk_widget_hide(wizard->recv_imap_label);
1232 gtk_widget_hide(wizard->recv_imap_subdir);
1233 gtk_widget_hide(wizard->subsonly_checkbtn);
1234 gtk_widget_show(wizard->recv_username);
1235 gtk_widget_show(wizard->recv_password);
1236 gtk_widget_show(wizard->recv_username_label);
1237 gtk_widget_show(wizard->recv_password_label);
1238 gtk_widget_hide(wizard->no_imap_warning);
1240 gtk_widget_show(wizard->recv_use_ssl);
1241 gtk_widget_show(wizard->recv_use_tls);
1242 gtk_widget_show(wizard->recv_cert_table);
1244 #if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
1245 gtk_widget_show(wizard->auto_configure_btn);
1246 gtk_widget_hide(wizard->auto_configure_cancel_btn);
1247 gtk_widget_show(wizard->auto_configure_lbl);
1249 gtk_label_set_text(GTK_LABEL(wizard->recv_label),
1250 g_strconcat("<span weight=\"bold\">", _("Server address:"),
1252 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1253 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1255 if (wizard->create_mailbox) {
1256 gtk_widget_show(wizard->mailbox_label);
1257 gtk_widget_show(wizard->mailbox_name);
1259 } else if (protocol == A_IMAP4) {
1260 #ifdef HAVE_LIBETPAN
1261 text = get_default_server(wizard, "imap");
1262 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1263 gtk_widget_show(wizard->recv_imap_label);
1264 gtk_widget_show(wizard->recv_imap_subdir);
1265 gtk_widget_show(wizard->subsonly_checkbtn);
1266 gtk_widget_show(wizard->recv_username);
1267 gtk_widget_show(wizard->recv_password);
1268 gtk_widget_show(wizard->recv_username_label);
1269 gtk_widget_show(wizard->recv_password_label);
1270 gtk_widget_hide(wizard->no_imap_warning);
1272 gtk_widget_show(wizard->recv_use_ssl);
1273 gtk_widget_show(wizard->recv_use_tls);
1274 gtk_widget_show(wizard->recv_cert_table);
1276 #if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
1277 gtk_widget_show(wizard->auto_configure_btn);
1278 gtk_widget_hide(wizard->auto_configure_cancel_btn);
1279 gtk_widget_show(wizard->auto_configure_lbl);
1281 gtk_label_set_text(GTK_LABEL(wizard->recv_label),
1282 g_strconcat("<span weight=\"bold\">", _("Server address:"),
1284 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1285 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1287 if (wizard->create_mailbox) {
1288 gtk_widget_hide(wizard->mailbox_label);
1289 gtk_widget_hide(wizard->mailbox_name);
1292 gtk_widget_hide(wizard->recv_imap_label);
1293 gtk_widget_hide(wizard->recv_imap_subdir);
1294 gtk_widget_hide(wizard->subsonly_checkbtn);
1295 gtk_widget_hide(wizard->recv_username);
1296 gtk_widget_hide(wizard->recv_password);
1297 gtk_widget_hide(wizard->recv_username_label);
1298 gtk_widget_hide(wizard->recv_password_label);
1299 gtk_widget_show(wizard->no_imap_warning);
1300 if (wizard->create_mailbox) {
1301 gtk_widget_hide(wizard->mailbox_label);
1302 gtk_widget_hide(wizard->mailbox_name);
1305 gtk_widget_hide(wizard->recv_use_ssl);
1306 gtk_widget_hide(wizard->recv_use_tls);
1307 gtk_widget_hide(wizard->recv_cert_table);
1309 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, FALSE);
1311 } else if (protocol == A_LOCAL) {
1312 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
1313 gtk_label_set_text(GTK_LABEL(wizard->recv_label),
1314 g_strconcat("<span weight=\"bold\">", _("Local mailbox:"),
1316 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1317 gtk_widget_hide(wizard->no_imap_warning);
1318 gtk_widget_hide(wizard->recv_imap_label);
1319 gtk_widget_hide(wizard->recv_imap_subdir);
1320 gtk_widget_hide(wizard->subsonly_checkbtn);
1321 gtk_widget_hide(wizard->recv_username);
1322 gtk_widget_hide(wizard->recv_password);
1323 gtk_widget_hide(wizard->recv_username_label);
1324 gtk_widget_hide(wizard->recv_password_label);
1325 #if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
1326 gtk_widget_hide(wizard->auto_configure_btn);
1327 gtk_widget_hide(wizard->auto_configure_cancel_btn);
1328 gtk_widget_hide(wizard->auto_configure_lbl);
1331 gtk_widget_hide(wizard->recv_use_ssl);
1332 gtk_widget_hide(wizard->recv_use_tls);
1333 gtk_widget_hide(wizard->recv_cert_table);
1335 if (wizard->create_mailbox) {
1336 gtk_widget_show(wizard->mailbox_label);
1337 gtk_widget_show(wizard->mailbox_name);
1339 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1343 static void wizard_protocol_changed(GtkComboBox *combo, gpointer data)
1345 WizardWindow *wizard = (WizardWindow *)data;
1346 RecvProtocol protocol = combobox_get_active_data(combo);
1348 wizard_protocol_change(wizard, protocol);
1351 #if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
1352 static void auto_configure_cb (GtkWidget *widget, gpointer data)
1354 gchar *address = NULL;
1355 AutoConfigureData *recv_data;
1356 AutoConfigureData *send_data;
1357 static GCancellable *recv_cancel = NULL;
1358 static GCancellable *send_cancel = NULL;
1359 WizardWindow *wizard = (WizardWindow *)data;
1360 RecvProtocol protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
1363 recv_cancel = g_cancellable_new();
1364 send_cancel = g_cancellable_new();
1367 if (widget == wizard->auto_configure_cancel_btn) {
1368 g_cancellable_cancel(recv_cancel);
1369 g_cancellable_cancel(send_cancel);
1370 g_object_unref(recv_cancel);
1371 g_object_unref(send_cancel);
1377 address = gtk_editable_get_chars(GTK_EDITABLE(wizard->email), 0, -1);
1379 if (strchr(address, '@') == NULL) {
1381 gtk_label_set_text(GTK_LABEL(wizard->auto_configure_lbl),
1382 _("Failed (wrong address)"));
1386 if (protocol == A_POP3 || protocol == A_IMAP4) {
1387 recv_data = g_new0(AutoConfigureData, 1);
1388 recv_data->configure_button = GTK_BUTTON(wizard->auto_configure_btn);
1389 recv_data->cancel_button = GTK_BUTTON(wizard->auto_configure_cancel_btn);
1390 recv_data->info_label = GTK_LABEL(wizard->auto_configure_lbl);
1391 recv_data->uid_entry = GTK_ENTRY(wizard->recv_username);
1392 recv_data->cancel = recv_cancel;
1395 recv_data->ssl_service = "pop3s";
1396 recv_data->tls_service = "pop3";
1397 recv_data->address = g_strdup(address);
1398 recv_data->hostname_entry = GTK_ENTRY(wizard->recv_server);
1399 recv_data->set_port = NULL;
1400 recv_data->port = NULL;
1401 recv_data->tls_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_tls);
1402 recv_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_ssl);
1403 recv_data->default_port = 110;
1404 recv_data->default_ssl_port = 995;
1407 recv_data->ssl_service = "imaps";
1408 recv_data->tls_service = "imap";
1409 recv_data->address = g_strdup(address);
1410 recv_data->hostname_entry = GTK_ENTRY(wizard->recv_server);
1411 recv_data->set_port = NULL;
1412 recv_data->port = NULL;
1413 recv_data->tls_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_tls);
1414 recv_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_ssl);
1415 recv_data->default_port = 143;
1416 recv_data->default_ssl_port = 993;
1419 cm_return_if_fail(FALSE);
1421 auto_configure_service(recv_data);
1424 send_data = g_new0(AutoConfigureData, 1);
1425 send_data->configure_button = GTK_BUTTON(wizard->auto_configure_btn);
1426 send_data->cancel_button = GTK_BUTTON(wizard->auto_configure_cancel_btn);
1427 send_data->info_label = GTK_LABEL(wizard->auto_configure_lbl);
1428 send_data->cancel = send_cancel;
1430 send_data->ssl_service = NULL;
1431 send_data->tls_service = "submission";
1432 send_data->address = g_strdup(address);
1433 send_data->hostname_entry = GTK_ENTRY(wizard->smtp_server);
1434 send_data->set_port = NULL;
1435 send_data->port = NULL;
1436 send_data->tls_checkbtn = GTK_TOGGLE_BUTTON(wizard->smtp_use_tls);
1437 send_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl);
1438 send_data->default_port = 25;
1439 send_data->default_ssl_port = -1;
1440 send_data->auth_checkbtn = GTK_TOGGLE_BUTTON(wizard->smtp_auth);
1442 auto_configure_service(send_data);
1448 static GtkWidget* recv_page (WizardWindow * wizard)
1450 GtkWidget *table = gtk_table_new(1,1, FALSE);
1453 GtkWidget *hbox_spc;
1454 GtkWidget *recv_table;
1458 GtkWidget *recv_cert_table;
1460 #if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
1461 GtkWidget *auto_configure_btn;
1462 GtkWidget *auto_configure_cancel_btn;
1463 GtkWidget *auto_configure_lbl;
1465 GtkListStore *store;
1470 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1471 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1473 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1474 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1476 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1477 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1479 recv_table = gtk_table_new(4, 2, FALSE);
1481 gtk_box_pack_start(GTK_BOX(vbox), recv_table, FALSE, FALSE, 0);
1483 label = gtk_label_new(g_strconcat("<span weight=\"bold\">", _("Server type:"), "</span>", NULL));
1484 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1485 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
1486 gtk_table_attach(GTK_TABLE(recv_table), label, 0,1,0,1,
1487 GTK_FILL, 0, VSPACING_NARROW, 0);
1488 wizard->recv_type = gtkut_sc_combobox_create(NULL, FALSE);
1489 store = GTK_LIST_STORE(gtk_combo_box_get_model(
1490 GTK_COMBO_BOX(wizard->recv_type)));
1492 COMBOBOX_ADD(store, _("POP3"), A_POP3);
1493 COMBOBOX_ADD(store, _("IMAP"), A_IMAP4);
1494 COMBOBOX_ADD(store, _("Local mbox file"), A_LOCAL);
1496 switch(tmpl.recvtype) {
1509 gtk_combo_box_set_active(GTK_COMBO_BOX (wizard->recv_type), index);
1510 g_signal_connect(G_OBJECT(wizard->recv_type), "changed",
1511 G_CALLBACK(wizard_protocol_changed),
1513 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_type, 1,2,0,1,
1514 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1516 #if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
1517 auto_configure_btn = gtk_button_new_with_label(_("Auto-configure"));
1518 auto_configure_cancel_btn = gtk_button_new_with_label(_("Cancel"));
1519 gtk_table_attach(GTK_TABLE(recv_table), auto_configure_btn, 0,1,1,2,
1520 GTK_FILL, 0, VSPACING_NARROW, 0);
1521 auto_configure_lbl = gtk_label_new("");
1522 gtk_misc_set_alignment(GTK_MISC(auto_configure_lbl), 0, 0.5);
1523 gtk_table_attach(GTK_TABLE(recv_table), auto_configure_lbl, 1,2,1,2,
1524 GTK_FILL, 0, VSPACING_NARROW, 0);
1525 gtk_widget_show(auto_configure_btn);
1526 gtk_widget_show(auto_configure_lbl);
1527 wizard->auto_configure_lbl = auto_configure_lbl;
1528 wizard->auto_configure_btn = auto_configure_btn;
1529 wizard->auto_configure_cancel_btn = auto_configure_cancel_btn;
1530 g_signal_connect (G_OBJECT (auto_configure_btn), "clicked",
1531 G_CALLBACK (auto_configure_cb), wizard);
1532 g_signal_connect (G_OBJECT (auto_configure_cancel_btn), "clicked",
1533 G_CALLBACK (auto_configure_cb), wizard);
1536 wizard->recv_label = gtk_label_new(g_strconcat("<span weight=\"bold\">",
1537 _("Server address:"), "</span>", NULL));
1538 gtk_misc_set_alignment(GTK_MISC(wizard->recv_label), 1, 0.5);
1539 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1540 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_label, 0,1,2,3,
1541 GTK_FILL, 0, VSPACING_NARROW, 0);
1542 wizard->recv_server = gtk_entry_new();
1543 text = get_default_server(wizard, "pop");
1544 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1547 CLAWS_SET_TIP(wizard->recv_server,
1548 _("You can specify the port number by appending it at the end: "
1549 "\"mail.example.com:110\""));
1550 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_server, 1,2,2,3,
1551 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1553 wizard->recv_username_label = gtk_label_new(g_strconcat("<span weight=\"bold\">",
1554 _("Username:"),"</span>", NULL));
1555 gtk_misc_set_alignment(GTK_MISC(wizard->recv_username_label), 1, 0.5);
1556 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_username_label), TRUE);
1557 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_username_label, 0,1,3,4,
1558 GTK_FILL, 0, VSPACING_NARROW, 0);
1559 wizard->recv_username = gtk_entry_new();
1560 text = get_default_account(wizard);
1561 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
1563 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_username, 1,2,3,4,
1564 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1566 wizard->recv_password_label = gtk_label_new(_("Password:"));
1567 gtk_misc_set_alignment(GTK_MISC(wizard->recv_password_label), 1, 0.5);
1568 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_password_label, 0,1,4,5,
1569 GTK_FILL, 0, VSPACING_NARROW, 0);
1570 wizard->recv_password = gtk_entry_new();
1571 gtk_entry_set_text(GTK_ENTRY(wizard->recv_password), tmpl.recvpass?tmpl.recvpass:"");
1572 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_password), FALSE);
1573 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_password, 1,2,4,5,
1574 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1576 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1577 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1578 wizard->recv_use_ssl = gtk_check_button_new_with_label(
1579 _("Use SSL to connect to receiving server"));
1580 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl),
1582 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_ssl, FALSE, FALSE, 0);
1584 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1585 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1586 hbox_spc = gtk_hbox_new (FALSE, 0);
1587 gtk_widget_set_size_request (hbox_spc, 12, -1);
1588 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1589 wizard->recv_use_tls = gtk_check_button_new_with_label(
1590 _("Use SSL via STARTTLS"));
1591 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls),
1593 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_tls, FALSE, FALSE, 0);
1594 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_use_tls);
1596 recv_cert_table = gtk_table_new(3,3, FALSE);
1597 gtk_box_pack_start (GTK_BOX(vbox), recv_cert_table, FALSE, FALSE, 4);
1598 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1599 hbox_spc = gtk_hbox_new (FALSE, 0);
1600 gtk_widget_set_size_request (hbox_spc, 12, -1);
1601 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1602 label = gtk_label_new(_("Client SSL certificate (optional)"));
1603 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1604 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1605 gtk_table_attach(GTK_TABLE(recv_cert_table), hbox, 0, 3, 0, 1, GTK_FILL, 0, 0, 0);
1606 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1607 hbox_spc = gtk_hbox_new (FALSE, 0);
1608 gtk_widget_set_size_request (hbox_spc, 12, -1);
1609 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1610 label = gtk_label_new(_("File"));
1611 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1612 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
1613 gtk_table_attach(GTK_TABLE(recv_cert_table), hbox, 0, 1, 1, 2,
1614 GTK_FILL, 0, VSPACING_NARROW, 0);
1615 wizard->recv_ssl_cert_file = gtk_entry_new();
1616 gtk_entry_set_text(GTK_ENTRY(wizard->recv_ssl_cert_file), tmpl.recvssl_cert?tmpl.recvssl_cert:"");
1617 gtk_table_attach(GTK_TABLE(recv_cert_table), wizard->recv_ssl_cert_file, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1618 button = gtkut_get_browse_file_btn(_("Browse"));
1619 gtk_table_attach(GTK_TABLE(recv_cert_table), button, 2, 3, 1, 2,
1620 GTK_FILL, 0, VSPACING_NARROW, 0);
1621 g_signal_connect(G_OBJECT(button), "clicked",
1622 G_CALLBACK(cert_browse_cb), wizard->recv_ssl_cert_file);
1624 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1625 hbox_spc = gtk_hbox_new (FALSE, 0);
1626 gtk_widget_set_size_request (hbox_spc, 12, -1);
1627 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1628 label = gtk_label_new(_("Password"));
1629 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1630 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
1631 gtk_table_attach(GTK_TABLE(recv_cert_table), hbox, 0, 1, 2, 3,
1632 GTK_FILL, 0, VSPACING_NARROW, 0);
1633 wizard->recv_ssl_cert_pass = gtk_entry_new();
1634 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_ssl_cert_pass), FALSE);
1635 gtk_entry_set_text(GTK_ENTRY(wizard->recv_ssl_cert_pass), tmpl.recvssl_cert_pass?tmpl.recvssl_cert_pass:"");
1636 gtk_table_attach(GTK_TABLE(recv_cert_table), wizard->recv_ssl_cert_pass, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1637 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, recv_cert_table);
1638 wizard->recv_cert_table = recv_cert_table;
1640 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1641 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1642 wizard->recv_imap_subdir = gtk_entry_new();
1643 gtk_entry_set_text(GTK_ENTRY(wizard->recv_imap_subdir), tmpl.imapdir?tmpl.imapdir:"");
1644 wizard->recv_imap_label = gtk_label_new(_("IMAP server directory:"));
1645 gtk_misc_set_alignment(GTK_MISC(wizard->recv_imap_label), 1, 0.5);
1646 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_label, FALSE, FALSE, 0);
1647 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_subdir, TRUE, TRUE, 0);
1649 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1650 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1651 hbox_spc = gtk_hbox_new (FALSE, 0);
1652 gtk_widget_set_size_request (hbox_spc, 12, -1);
1653 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1654 wizard->subsonly_checkbtn = gtk_check_button_new_with_label(
1655 _("Show only subscribed folders"));
1656 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn),
1658 gtk_box_pack_start(GTK_BOX(hbox), wizard->subsonly_checkbtn, FALSE, FALSE, 0);
1660 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1661 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1662 wizard->no_imap_warning = gtk_label_new(g_strconcat("<span weight=\"bold\">",
1663 _("Warning: this version of Claws Mail\n"
1664 "has been built without IMAP support."), "</span>", NULL));
1665 gtk_label_set_use_markup(GTK_LABEL(wizard->no_imap_warning), TRUE);
1666 gtk_box_pack_start(GTK_BOX(hbox), wizard->no_imap_warning, FALSE, FALSE, 0);
1672 wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
1674 WizardWindow * wizard = (WizardWindow *)data;
1675 int current_page, num_pages;
1676 gboolean skip_mailbox_page = FALSE;
1677 gint protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
1679 if (protocol == A_IMAP4) {
1680 skip_mailbox_page = TRUE;
1683 num_pages = g_slist_length(wizard->pages);
1685 current_page = gtk_notebook_get_current_page (
1686 GTK_NOTEBOOK(wizard->notebook));
1687 if (response == CANCEL)
1689 wizard->result = FALSE;
1690 wizard->finished = TRUE;
1691 gtk_widget_destroy (GTK_WIDGET(dialog));
1693 else if (response == FINISHED)
1695 if (!wizard_write_config(wizard)) {
1696 current_page = gtk_notebook_get_current_page (
1697 GTK_NOTEBOOK(wizard->notebook));
1700 wizard->result = TRUE;
1701 wizard->finished = TRUE;
1702 gtk_widget_destroy (GTK_WIDGET(dialog));
1706 if (response == GO_BACK)
1708 if (current_page > 0) {
1710 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1714 gtk_notebook_set_current_page (
1715 GTK_NOTEBOOK(wizard->notebook),
1719 else if (response == GO_FORWARD)
1721 if (current_page < (num_pages-1)) {
1723 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1727 gtk_notebook_set_current_page (
1728 GTK_NOTEBOOK(wizard->notebook),
1733 gtk_dialog_set_response_sensitive (dialog, GO_BACK,
1735 gtk_dialog_set_response_sensitive (dialog, GO_FORWARD,
1736 current_page < (num_pages - 1));
1737 if (current_page == (num_pages -1)) {
1738 gtk_dialog_set_response_sensitive (dialog, FINISHED, TRUE);
1739 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), FINISHED);
1741 gtk_dialog_set_response_sensitive (dialog, FINISHED, FALSE);
1742 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), GO_FORWARD);
1748 static gint wizard_close_cb(GtkWidget *widget, GdkEventAny *event,
1751 WizardWindow *wizard = (WizardWindow *)data;
1752 wizard->result = FALSE;
1753 wizard->finished = TRUE;
1758 #define PACK_WARNING(text) { \
1759 label = gtk_label_new(text); \
1760 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); \
1761 gtk_box_pack_end(GTK_BOX(widget), label, FALSE, FALSE, 0); \
1764 gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
1765 WizardWindow *wizard = g_new0(WizardWindow, 1);
1769 GtkWidget *scrolled_window;
1774 wizard->mainwin = mainwin;
1775 wizard->create_mailbox = create_mailbox;
1777 gtk_widget_hide(mainwin->window);
1779 wizard_read_defaults();
1781 wizard->window = gtk_dialog_new_with_buttons (_("Claws Mail Setup Wizard"),
1783 GTK_STOCK_GO_BACK, GO_BACK,
1784 GTK_STOCK_GO_FORWARD, GO_FORWARD,
1785 GTK_STOCK_SAVE, FINISHED,
1786 GTK_STOCK_CANCEL, CANCEL,
1788 gtk_widget_set_size_request(wizard->window, -1, 480);
1789 gtk_window_set_position(GTK_WINDOW(wizard->window), GTK_WIN_POS_CENTER);
1791 g_signal_connect(wizard->window, "response",
1792 G_CALLBACK(wizard_response_cb), wizard);
1793 gtk_widget_realize(wizard->window);
1794 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window),
1796 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1798 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1800 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1802 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1805 wizard->notebook = gtk_notebook_new();
1806 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(wizard->notebook), FALSE);
1807 gtk_notebook_set_show_border(GTK_NOTEBOOK(wizard->notebook), FALSE);
1808 gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(wizard->window))),
1809 wizard->notebook, TRUE, TRUE, 0);
1811 wizard->pages = NULL;
1813 /*welcome page: 0 */
1815 page = create_page(wizard, _("Welcome to Claws Mail"));
1817 wizard->pages = g_slist_append(wizard->pages, page);
1818 widget = stock_pixmap_widget(wizard->window,
1819 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1821 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1823 text = g_strdup(_("Welcome to the Claws Mail setup wizard.\n\n"
1824 "We will begin by defining some basic "
1825 "information about you and your most common "
1826 "mail options so that you can start to use "
1827 "Claws Mail in less than five minutes."));
1828 widget = gtk_label_new(text);
1829 gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
1830 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1836 widget = create_page (wizard, _("About You"));
1837 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1838 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1839 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1840 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1842 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1844 PACK_WARNING(_("Bold fields must be completed"));
1846 wizard->pages = g_slist_append(wizard->pages, widget);
1848 /* recv+auth page: 2 */
1851 widget = create_page (wizard, _("Receiving mail"));
1852 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1853 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1854 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1855 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1857 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1859 PACK_WARNING(_("Bold fields must be completed"));
1861 wizard->pages = g_slist_append(wizard->pages, widget);
1866 widget = create_page (wizard, _("Sending mail"));
1867 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1868 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1869 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1870 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1872 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1874 PACK_WARNING(_("Bold fields must be completed"));
1876 wizard->pages = g_slist_append(wizard->pages, widget);
1878 /* mailbox page: 4 */
1879 if (create_mailbox) {
1882 widget = create_page (wizard, _("Saving mail on disk"));
1883 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1884 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1885 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1886 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1888 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1889 mailbox_page(wizard));
1890 PACK_WARNING(_("Bold fields must be completed"));
1892 wizard->pages = g_slist_append(wizard->pages, widget);
1898 page = create_page(wizard, _("Configuration finished"));
1900 wizard->pages = g_slist_append(wizard->pages, page);
1901 widget = stock_pixmap_widget(wizard->window,
1902 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1904 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1906 text = g_strdup(_("Claws Mail is now ready.\n"
1907 "Click Save to start."));
1908 widget = gtk_label_new(text);
1909 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1913 for (cur = wizard->pages; cur && cur->data; cur = cur->next) {
1914 gtk_notebook_append_page (GTK_NOTEBOOK(wizard->notebook),
1915 GTK_WIDGET(cur->data), NULL);
1918 g_signal_connect(G_OBJECT(wizard->window), "delete_event",
1919 G_CALLBACK(wizard_close_cb), wizard);
1920 gtk_widget_show_all (wizard->window);
1922 gtk_widget_hide(wizard->recv_imap_label);
1923 gtk_widget_hide(wizard->recv_imap_subdir);
1924 gtk_widget_hide(wizard->subsonly_checkbtn);
1925 #if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
1926 gtk_widget_hide(wizard->auto_configure_cancel_btn);
1928 wizard_protocol_change(wizard, tmpl.recvtype);
1930 while (!wizard->finished)
1931 gtk_main_iteration();
1933 result = wizard->result;
1937 gtk_widget_show(mainwin->window);