2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2009 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/>.
28 #include <glib/gi18n.h>
29 #include <gdk/gdkkeysyms.h>
45 #include "prefs_account.h"
46 #include "mainwindow.h"
47 #include "stock_pixmap.h"
50 #include "alertpanel.h"
55 #include "prefs_common.h"
59 #include <libgnomevfs/gnome-vfs-volume.h>
60 #include <libgnomevfs/gnome-vfs-volume-monitor.h>
61 #include <libgnomevfs/gnome-vfs-utils.h>
72 int WELCOME_PAGE = -1;
76 int MAILBOX_PAGE = -1;
89 GtkWidget *organization;
91 GtkWidget *mailbox_name;
92 GtkWidget *mailbox_label;
94 GtkWidget *smtp_server;
96 GtkWidget *smtp_username;
97 GtkWidget *smtp_password;
98 GtkWidget *smtp_username_label;
99 GtkWidget *smtp_password_label;
101 GtkWidget *recv_type;
102 GtkWidget *recv_label;
103 GtkWidget *recv_server;
104 GtkWidget *recv_username;
105 GtkWidget *recv_password;
106 GtkWidget *recv_username_label;
107 GtkWidget *recv_password_label;
108 GtkWidget *recv_imap_label;
109 GtkWidget *recv_imap_subdir;
110 GtkWidget *subsonly_checkbtn;
111 GtkWidget *no_imap_warning;
113 GtkWidget *smtp_use_ssl;
114 GtkWidget *recv_use_ssl;
115 GtkWidget *smtp_use_tls;
116 GtkWidget *recv_use_tls;
117 GtkWidget *smtp_ssl_cert_file;
118 GtkWidget *recv_ssl_cert_file;
119 GtkWidget *smtp_ssl_cert_pass;
120 GtkWidget *recv_ssl_cert_pass;
121 GtkWidget *smtp_cert_table;
122 GtkWidget *recv_cert_table;
126 GtkWidget *data_root_nokia_radiobtn;
127 GtkWidget *data_root_mmc1_radiobtn;
128 GtkWidget *data_root_mmc2_radiobtn;
129 GnomeVFSVolumeMonitor *volmon;
130 gulong volmon_mount_sigid;
131 gulong volmon_unmount_sigid;
132 GnomeVFSVolume *vol_mmc1;
133 GnomeVFSVolume *vol_mmc2;
135 gboolean create_mailbox;
141 typedef struct _AccountTemplate {
150 RecvProtocol recvtype;
162 gchar *smtpssl_cert_pass;
163 gchar *recvssl_cert_pass;
166 static AccountTemplate tmpl;
168 static PrefParam template_params[] = {
169 {"name", "$USERNAME",
170 &tmpl.name, P_STRING, NULL, NULL, NULL},
171 {"domain", "$DEFAULTDOMAIN",
172 &tmpl.domain, P_STRING, NULL, NULL, NULL},
173 {"email", "$NAME_MAIL@$DOMAIN",
174 &tmpl.email, P_STRING, NULL, NULL, NULL},
176 &tmpl.organization, P_STRING, NULL, NULL, NULL},
177 {"smtpserver", "smtp.$DOMAIN",
178 &tmpl.smtpserver, P_STRING, NULL, NULL, NULL},
179 {"smtpauth", "FALSE",
180 &tmpl.smtpauth, P_BOOL, NULL, NULL, NULL},
182 &tmpl.smtpuser, P_STRING, NULL, NULL, NULL},
184 &tmpl.smtppass, P_STRING, NULL, NULL, NULL},
186 &tmpl.recvtype, P_INT, NULL, NULL, NULL},
187 {"recvserver", "pop.$DOMAIN",
188 &tmpl.recvserver, P_STRING, NULL, NULL, NULL},
189 {"recvuser", "$LOGIN",
190 &tmpl.recvuser, P_STRING, NULL, NULL, NULL},
192 &tmpl.recvpass, P_STRING, NULL, NULL, NULL},
194 &tmpl.imapdir, P_STRING, NULL, NULL, NULL},
196 &tmpl.subsonly, P_BOOL, NULL, NULL, NULL},
197 {"mboxfile", "/var/mail/$LOGIN",
198 &tmpl.mboxfile, P_STRING, NULL, NULL, NULL},
200 &tmpl.mailbox, P_STRING, NULL, NULL, NULL},
202 &tmpl.smtpssl, P_INT, NULL, NULL, NULL},
204 &tmpl.recvssl, P_INT, NULL, NULL, NULL},
206 &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
208 &tmpl.recvssl_cert, P_STRING, NULL, NULL, NULL},
209 {"smtpssl_cert_pass", "",
210 &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
211 {"recvssl_cert_pass", "",
212 &tmpl.recvssl_cert, P_STRING, NULL, NULL, NULL},
213 {NULL, NULL, NULL, P_INT, NULL, NULL, NULL}
217 static gchar *accountrc_tmpl =
218 "[AccountTemplate]\n"
219 "#you can use $DEFAULTDOMAIN here\n"
220 "#domain must be defined before the variables that use it\n"
221 "#by default, domain is extracted from the hostname\n"
224 "#you can use $USERNAME for name (this is the default)\n"
227 "#you can use $LOGIN, $NAME_MAIL and $DOMAIN here \n"
228 "#$NAME_MAIL is the name without uppercase and with dots instead\n"
230 "#the default is $NAME_MAIL@$DOMAIN\n"
233 "#you can use $DOMAIN here\n"
234 "#the default organization is empty\n"
237 "#you can use $DOMAIN here \n"
238 "#the default is smtp.$DOMAIN\n"
241 "#Whether to use smtp authentication\n"
242 "#the default is 0 (no)\n"
246 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
247 "#the default is empty (same as reception username)\n"
251 "#the default is empty (same as reception password)\n"
254 "#recvtype can be:\n"
257 "#5 for a local mbox file\n"
260 "#you can use $DOMAIN here \n"
261 "#the default is {pop,imap}.$DOMAIN\n"
264 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
265 "#default is $LOGIN\n"
268 "#default is empty\n"
271 "#imap dir if imap (relative to the home on the server)\n"
272 "#default is empty\n"
275 "#show subscribed folders only, if imap\n"
279 "#mbox file if local\n"
280 "#you can use $LOGIN here\n"
281 "#default is /var/mail/$LOGIN\n"
284 "#mailbox name if pop3 or local\n"
285 "#relative path from the user's home\n"
286 "#default is \"Mail\"\n"
289 "#whether to use ssl on smtp connections\n"
290 "#default is 0, 1 is ssl, 2 is starttls\n"
293 "#whether to use ssl on pop or imap connections\n"
294 "#default is 0, 1 is ssl, 2 is starttls\n"
297 "#SSL client certificate path for SMTP\n"
298 "#default is empty (no certificate)\n"
301 "#SSL client certificate path for POP/IMAP\n"
302 "#default is empty (no certificate)\n"
305 "#SSL client certificate password for SMTP\n"
306 "#default is empty (no password)\n"
307 "#smtpssl_cert_pass=\n"
309 "#SSL client certificate password for POP/IMAP\n"
310 "#default is empty (no password)\n"
311 "#recvssl_cert_pass=\n"
314 static gchar *wizard_get_default_domain_name(void)
316 static gchar *domain_name = NULL;
318 if (domain_name == NULL) {
319 domain_name = g_strdup(get_domain_name());
320 if (strchr(domain_name, '.') != strrchr(domain_name, '.')
321 && strlen(strchr(domain_name, '.')) > 6) {
322 gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
330 static gchar *get_name_for_mail(void)
333 if (tmpl.name == NULL)
335 name = g_utf8_strdown(tmpl.name, -1);
336 while(strstr(name, " "))
337 *strstr(name, " ")='.';
342 #define PARSE_DEFAULT(str) { \
343 gchar *tmp = NULL, *new = NULL; \
345 tmp = g_strdup(str); \
346 if (strstr(str, "$USERNAME")) { \
347 tmp = g_strdup(str); \
348 *strstr(tmp, "$USERNAME") = '\0'; \
349 new = g_strconcat(tmp, g_get_real_name(), \
350 strstr(str, "$USERNAME")+strlen("$USERNAME"), \
357 if (strstr(str, "$LOGIN")) { \
358 tmp = g_strdup(str); \
359 *strstr(tmp, "$LOGIN") = '\0'; \
360 new = g_strconcat(tmp, g_get_user_name(), \
361 strstr(str, "$LOGIN")+strlen("$LOGIN"), \
368 if (strstr(str, "$EMAIL")) { \
369 tmp = g_strdup(str); \
370 *strstr(tmp, "$EMAIL") = '\0'; \
371 new = g_strconcat(tmp, tmpl.email, \
372 strstr(str, "$EMAIL")+strlen("$EMAIL"), \
379 if (strstr(str, "$NAME_MAIL")) { \
380 tmp = g_strdup(str); \
381 *strstr(tmp, "$NAME_MAIL") = '\0'; \
382 new = g_strconcat(tmp, get_name_for_mail(), \
383 strstr(str, "$NAME_MAIL")+strlen("$NAME_MAIL"), \
390 if (strstr(str, "$DEFAULTDOMAIN")) { \
391 tmp = g_strdup(str); \
392 *strstr(tmp, "$DEFAULTDOMAIN") = '\0'; \
393 new = g_strconcat(tmp, wizard_get_default_domain_name(), \
394 strstr(str, "$DEFAULTDOMAIN")+strlen("$DEFAULTDOMAIN"), \
401 if (strstr(str, "$DOMAIN")) { \
402 tmp = g_strdup(str); \
403 *strstr(tmp, "$DOMAIN") = '\0'; \
404 new = g_strconcat(tmp, tmpl.domain, \
405 strstr(str, "$DOMAIN")+strlen("$DOMAIN"), \
414 static void wizard_read_defaults(void)
418 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "accountrc.tmpl", NULL);
419 if (!is_file_exist(rcpath)) {
420 str_write_to_file(accountrc_tmpl, rcpath);
423 prefs_read_config(template_params, "AccountTemplate", rcpath, NULL);
425 PARSE_DEFAULT(tmpl.domain);
426 PARSE_DEFAULT(tmpl.name);
427 PARSE_DEFAULT(tmpl.email);
428 PARSE_DEFAULT(tmpl.organization);
429 PARSE_DEFAULT(tmpl.smtpserver);
430 PARSE_DEFAULT(tmpl.smtpuser);
431 PARSE_DEFAULT(tmpl.smtppass);
432 PARSE_DEFAULT(tmpl.recvserver);
433 PARSE_DEFAULT(tmpl.recvuser);
434 PARSE_DEFAULT(tmpl.recvpass);
435 PARSE_DEFAULT(tmpl.imapdir);
436 PARSE_DEFAULT(tmpl.mboxfile);
437 PARSE_DEFAULT(tmpl.mailbox);
440 "%s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %s, %s, %d, %d\n",
441 tmpl.name,tmpl.domain,tmpl.email,tmpl.organization,tmpl.smtpserver,
442 tmpl.recvtype,tmpl.recvserver,tmpl.recvuser,tmpl.recvpass,
443 tmpl.imapdir,tmpl.mboxfile,tmpl.mailbox,tmpl.smtpssl,tmpl.recvssl);
448 static void initialize_fonts(WizardWindow *wizard)
450 GtkWidget *widget = wizard->email;
451 gint size = pango_font_description_get_size(
452 widget->style->font_desc)
456 PangoFontDescription *bold_desc;
457 gchar *curfont = pango_font_description_to_string(widget->style->font_desc);
458 g_free(prefs_common.smallfont);
459 g_free(prefs_common.normalfont);
460 g_free(prefs_common.boldfont);
461 prefs_common.smallfont = g_strdup(curfont);
462 prefs_common.normalfont = g_strdup(curfont);
463 bold_desc = pango_font_description_from_string(curfont);
464 pango_font_description_set_weight(bold_desc, PANGO_WEIGHT_BOLD);
465 prefs_common.boldfont = pango_font_description_to_string(bold_desc);
466 pango_font_description_free(bold_desc);
469 tmp = g_strdup(prefs_common.textfont);
470 if (strrchr(tmp, ' ')) {
471 *(strrchr(tmp, ' ')) = '\0';
472 new = g_strdup_printf("%s %d", tmp, size);
473 g_free(prefs_common.textfont);
474 prefs_common.textfont = new;
478 tmp = g_strdup(prefs_common.smallfont);
479 if (strrchr(tmp, ' ')) {
480 *(strrchr(tmp, ' ')) = '\0';
481 new = g_strdup_printf("%s %d", tmp, size);
482 g_free(prefs_common.smallfont);
483 prefs_common.smallfont = new;
487 tmp = g_strdup(prefs_common.normalfont);
488 if (strrchr(tmp, ' ')) {
489 *(strrchr(tmp, ' ')) = '\0';
490 new = g_strdup_printf("%s %d", tmp, size);
491 g_free(prefs_common.normalfont);
492 prefs_common.normalfont = new;
496 tmp = g_strdup(prefs_common.boldfont);
497 if (strrchr(tmp, ' ')) {
498 *(strrchr(tmp, ' ')) = '\0';
499 new = g_strdup_printf("%s %d", tmp, size);
500 g_free(prefs_common.boldfont);
501 prefs_common.boldfont = new;
506 #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"
507 #define FACE "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAM1BMVEUAAAAcJCI\n\
508 ONl1JUi0+Z4daY2NZciPabV9ykS5kj6Wsl2ybmZOBsMjZxK2wzN3Pzczs7OsCAGN0AAAAAXRSTlM\n\
509 AQObYZgAAAAFiS0dEAIgFHUgAAAIVSURBVEjH1ZbtlqMgDIaFECoGhPu/2s0b0Lais/NzN6d1OJ7\n\
510 3yReQzrL8B5Zy3rvl9At52Pf2tv1vSMjtYj8jaa8XUyI/yn3YD6sigj/2Tf5Bn069MIsTPHvx/t5\n\
511 /3rU/6JCIY3YwGe26r/cwUfE3cFe5T28L0K5rJAUHEeYAQxs8DHojjk3M9wECU4xxjXisI8RA0gy\n\
512 oczJZJOjxiTFZVTchAnIRJrgdmEGDyFfAI3UuG5FmYTkR9RDrIC4H0SqV4pzpEcUp0HNLjwBv+jA\n\
513 dikUE5g9iBvzmu3sH2oDk4lnHd829+2Q9gj6kDqDPg7hsGwBzH02fE3ZCt6ZHmlNKIMjMeRwra5I\n\
514 ecgNoBnLGPmzaHPJIwLY8Sq2M/tLUJfj0QcqmfVXAdLSStIYF8dzWjBBb2VgvDa4mO9oc651OiUo\n\
515 BEKbZokdPATF9E9oKAjQJcJOniaPXrVZRAnVWaqIyqRoNC8ZJvgCcW8XN39RqxVP1rS8Yd4WnCdN\n\
516 aRTo2jJRDbg3vtCpEUGffgDPhqKDaSuVqYtOplFIvIcx3HUI5/MuIWl6vKyBjNlqEru8hbFXqBPA\n\
517 5TpHGIUZOePeaIyzfQ/g9Xg0opU1AvdfXM9floYhv92pPAE96OZtkPV8eivgQi9RTfwPUU36I26n\n\
518 Hy+WuCJzAT7efMSeA1TNf2/VugDz+dN139xfA5ffxGZDD+MvcP/uvyB80wzZ76wbz8gAAAABJRU5\n\
521 static void write_welcome_email(WizardWindow *wizard)
527 const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name));
528 Folder *folder = folder_find_from_path(mailbox);
529 FolderItem *inbox = folder ? folder->inbox:NULL;
530 gchar *file = get_tmp_file();
531 gchar enc_from_name[BUFFSIZE], enc_to_name[BUFFSIZE], enc_subject[BUFFSIZE];
533 get_rfc822_date(buf_date, sizeof(buf_date));
535 conv_encode_header_full(enc_subject, sizeof(enc_subject),
536 Q_("Welcome Mail Subject|Welcome to Claws Mail"),
537 strlen("Subject: "), FALSE, CS_INTERNAL);
538 conv_encode_header_full(enc_to_name, sizeof(enc_to_name),
539 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)),
540 strlen("To: "), TRUE, CS_INTERNAL);
541 conv_encode_header_full(enc_from_name, sizeof(enc_from_name),
542 _("The Claws Mail Team"),
543 strlen("From: "), TRUE, CS_INTERNAL);
545 head = g_strdup_printf(
552 "Content-Type: text/plain; charset=UTF-8\n",
556 gtk_entry_get_text(GTK_ENTRY(wizard->email)),
557 buf_date, enc_subject, XFACE, FACE);
558 body = g_strdup_printf(
560 "Welcome to Claws Mail\n"
561 "---------------------\n"
563 "Now that you have set up your account you can fetch your\n"
564 "mail by clicking the 'Get Mail' button at the left of the\n"
567 "Claws Mail has lots of extra features accessible via plugins,\n"
568 "like anti-spam filtering and learning (via the Bogofilter or\n"
569 "SpamAssassin plugins), privacy protection (via PGP/Mime), an RSS\n"
570 "aggregator, a calendar, and much more. You can load them from\n"
571 "the menu entry '/Configuration/Plugins'.\n"
573 "You can change your Account Preferences by using the menu\n"
574 "entry '/Configuration/Preferences for current account'\n"
575 "and change the general Preferences by using\n"
576 "'/Configuration/Preferences'.\n"
578 "You can find further information in the Claws Mail manual,\n"
579 "which can be accessed by using the menu entry '/Help/Manual'\n"
580 "or online at the URL given below.\n"
588 "Mailing Lists: <%s>\n"
592 "Claws Mail is free software, released under the terms\n"
593 "of the GNU General Public License, version 3 or later, as\n"
594 "published by the Free Software Foundation, 51 Franklin Street,\n"
595 "Fifth Floor, Boston, MA 02110-1301, USA. The license can be\n"
600 "If you wish to donate to the Claws Mail project you can do\n"
602 HOMEPAGE_URI, MANUAL_URI, FAQ_URI, THEMES_URI, MAILING_LIST_URI,
603 GPL_URI, DONATE_URI);
605 msg = g_strconcat(head, body, NULL);
607 if (inbox && inbox->total_msgs == 0
608 && str_write_to_file(msg, file) >= 0) {
609 MsgFlags flags = { MSG_UNREAD|MSG_NEW, 0};
610 folder_item_add_msg(inbox, file, &flags, FALSE);
619 static gboolean wizard_write_config(WizardWindow *wizard)
621 static gboolean mailbox_ok = FALSE;
622 PrefsAccount *prefs_account = prefs_account_new();
623 GList *account_list = NULL;
624 gchar *smtp_server, *recv_server;
625 gint smtp_port, recv_port;
627 SSLType smtp_ssl_type, recv_ssl_type;
630 prefs_account->protocol = combobox_get_active_data(
631 GTK_COMBO_BOX(wizard->recv_type));
633 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4 &&
634 !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)))) {
635 alertpanel_error(_("Please enter the mailbox name."));
636 g_free(prefs_account);
637 gtk_notebook_set_current_page (
638 GTK_NOTEBOOK(wizard->notebook),
644 if (wizard->create_mailbox) {
645 g_free(prefs_common.data_root);
646 if (gtk_toggle_button_get_active(
647 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn)))
648 prefs_common.data_root = NULL;
649 else if (gtk_toggle_button_get_active(
650 GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn)))
651 prefs_common.data_root = g_strdup(MMC1_PATH);
652 else if (gtk_toggle_button_get_active(
653 GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn)))
654 prefs_common.data_root = g_strdup(MMC2_PATH);
659 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
660 mailbox_ok = setup_write_mailbox_path(wizard->mainwin,
662 GTK_ENTRY(wizard->mailbox_name)));
668 /* alertpanel done by setup_write_mailbox_path */
669 g_free(prefs_account);
670 gtk_notebook_set_current_page (
671 GTK_NOTEBOOK(wizard->notebook),
676 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->full_name)))
677 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->email)))) {
678 alertpanel_error(_("Please enter your name and email address."));
679 g_free(prefs_account);
680 gtk_notebook_set_current_page (
681 GTK_NOTEBOOK(wizard->notebook),
686 if (prefs_account->protocol != A_LOCAL) {
687 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)))
688 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
689 alertpanel_error(_("Please enter your receiving server "
691 g_free(prefs_account);
692 gtk_notebook_set_current_page (
693 GTK_NOTEBOOK(wizard->notebook),
698 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
699 alertpanel_error(_("Please enter your username."));
700 g_free(prefs_account);
701 gtk_notebook_set_current_page (
702 GTK_NOTEBOOK(wizard->notebook),
708 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)))) {
709 alertpanel_error(_("Please enter your SMTP server."));
710 g_free(prefs_account);
711 gtk_notebook_set_current_page (
712 GTK_NOTEBOOK(wizard->notebook),
717 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
718 if (prefs_account->protocol == A_LOCAL
719 && !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)))) {
720 alertpanel_error(_("Please enter your SMTP username."));
721 g_free(prefs_account);
722 gtk_notebook_set_current_page (
723 GTK_NOTEBOOK(wizard->notebook),
726 } /* if it's not local we'll use the reception server */
729 if (prefs_account->protocol != A_LOCAL)
730 prefs_account->account_name = g_strdup_printf("%s@%s",
731 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)),
732 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
734 prefs_account->account_name = g_strdup_printf("%s",
735 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
737 recv_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
738 smtp_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)));
740 if (prefs_account->protocol != A_LOCAL && strstr(recv_server, ":")) {
741 recv_port = atoi(strstr(recv_server, ":")+1);
742 *(strstr(recv_server, ":")) = '\0';
743 if (prefs_account->protocol == A_IMAP4) {
744 prefs_account->set_imapport = TRUE;
745 prefs_account->imapport = recv_port;
746 } else if (prefs_account->protocol == A_POP3) {
747 prefs_account->set_popport = TRUE;
748 prefs_account->popport = recv_port;
751 if (strstr(smtp_server, ":")) {
752 smtp_port = atoi(strstr(smtp_server, ":")+1);
753 *(strstr(smtp_server, ":")) = '\0';
754 prefs_account->set_smtpport = TRUE;
755 prefs_account->smtpport = smtp_port;
758 prefs_account->name = g_strdup(
759 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)));
760 prefs_account->address = g_strdup(
761 gtk_entry_get_text(GTK_ENTRY(wizard->email)));
762 prefs_account->organization = g_strdup(
763 gtk_entry_get_text(GTK_ENTRY(wizard->organization)));
764 prefs_account->smtp_server = g_strdup(smtp_server);
766 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
768 tmp = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
769 prefs_account->inbox = g_strdup_printf("#mh/%s/inbox",
770 (!strcmp("Mail", gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name))))
773 prefs_account->local_inbox = g_strdup(prefs_account->inbox);
774 } else if (prefs_account->protocol != A_IMAP4) {
775 if (folder_get_default_inbox())
776 prefs_account->local_inbox =
777 folder_item_get_identifier(folder_get_default_inbox());
780 if (prefs_account->protocol != A_LOCAL)
781 prefs_account->recv_server = g_strdup(recv_server);
783 prefs_account->local_mbox = g_strdup(recv_server);
788 prefs_account->userid = g_strdup(
789 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)));
790 prefs_account->passwd = g_strdup(
791 gtk_entry_get_text(GTK_ENTRY(wizard->recv_password)));
793 prefs_account->smtp_userid = g_strdup(
794 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)));
795 prefs_account->smtp_passwd = g_strdup(
796 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_password)));
797 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
798 prefs_account->use_smtp_auth = TRUE;
802 smtp_ssl_type = SSL_NONE;
803 recv_ssl_type = SSL_NONE;
805 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl))) {
806 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls)))
807 smtp_ssl_type = SSL_STARTTLS;
809 smtp_ssl_type = SSL_TUNNEL;
811 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl))) {
812 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls)))
813 recv_ssl_type = SSL_STARTTLS;
815 recv_ssl_type = SSL_TUNNEL;
818 prefs_account->ssl_smtp = smtp_ssl_type;
820 if (prefs_account->protocol == A_IMAP4)
821 prefs_account->ssl_imap = recv_ssl_type;
823 prefs_account->ssl_pop = recv_ssl_type;
825 prefs_account->out_ssl_client_cert_file = g_strdup(
826 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_ssl_cert_file)));
827 prefs_account->out_ssl_client_cert_pass = g_strdup(
828 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_ssl_cert_pass)));
829 prefs_account->in_ssl_client_cert_file = g_strdup(
830 gtk_entry_get_text(GTK_ENTRY(wizard->recv_ssl_cert_file)));
831 prefs_account->in_ssl_client_cert_pass = g_strdup(
832 gtk_entry_get_text(GTK_ENTRY(wizard->recv_ssl_cert_pass)));
834 if (prefs_account->protocol == A_IMAP4) {
835 gchar *directory = gtk_editable_get_chars(
836 GTK_EDITABLE(wizard->recv_imap_subdir), 0, -1);
837 if (directory && strlen(directory)) {
838 prefs_account->imap_dir = g_strdup(directory);
840 prefs_account->imap_subsonly =
841 gtk_toggle_button_get_active(
842 GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn));
846 account_list = g_list_append(account_list, prefs_account);
847 prefs_account_write_config_all(account_list);
848 prefs_account_free(prefs_account);
849 account_read_config_all();
851 initialize_fonts(wizard);
852 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
853 write_welcome_email(wizard);
856 if (wizard->volmon_mount_sigid)
857 g_signal_handler_disconnect(
858 G_OBJECT(wizard->volmon),
859 wizard->volmon_mount_sigid);
860 if (wizard->volmon_unmount_sigid)
861 g_signal_handler_disconnect(
862 G_OBJECT(wizard->volmon),
863 wizard->volmon_unmount_sigid);
867 plugin_load_standard_plugins();
872 static GtkWidget* create_page (WizardWindow *wizard, const char * title)
880 vbox = gtk_vbox_new (FALSE, 6);
881 gtk_container_set_border_width (GTK_CONTAINER(vbox), 10);
883 /* create the titlebar */
884 hbox = gtk_hbox_new (FALSE, 12);
885 image = stock_pixmap_widget(wizard->window,
886 STOCK_PIXMAP_CLAWS_MAIL_ICON);
887 gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 0);
888 title_string = g_strconcat ("<span size=\"xx-large\" weight=\"ultrabold\">", title ? title : "", "</span>", NULL);
889 w = gtk_label_new (title_string);
890 gtk_label_set_use_markup (GTK_LABEL(w), TRUE);
891 g_free (title_string);
892 gtk_box_pack_start (GTK_BOX(hbox), w, FALSE, FALSE, 0);
894 /* pack the titlebar */
895 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
897 /* pack the separator */
898 gtk_box_pack_start (GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
901 w = gtk_alignment_new (0, 0, 0, 0);
902 gtk_widget_set_size_request (w, 0, 6);
903 gtk_box_pack_start (GTK_BOX(vbox), w, FALSE, FALSE, 0);
908 #define PACK_BOX(hbox,text,entry) { \
909 GtkWidget *label = gtk_label_new(text); \
910 gtk_label_set_use_markup(GTK_LABEL(label), TRUE); \
911 if (GTK_IS_MISC(label)) \
912 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); \
913 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); \
914 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); \
917 static gchar *get_default_server(WizardWindow * wizard, const gchar *type)
919 if (!strcmp(type, "smtp")) {
920 if (!tmpl.smtpserver || !strlen(tmpl.smtpserver))
921 return g_strconcat(type, ".", tmpl.domain, NULL);
923 return g_strdup(tmpl.smtpserver);
925 if (!tmpl.recvserver || !strlen(tmpl.recvserver))
926 return g_strconcat(type, ".", tmpl.domain, NULL);
928 return g_strdup(tmpl.recvserver);
932 static gchar *get_default_account(WizardWindow * wizard)
934 gchar *result = NULL;
936 if (!tmpl.recvuser || !strlen(tmpl.recvuser)) {
937 result = gtk_editable_get_chars(
938 GTK_EDITABLE(wizard->email), 0, -1);
940 if (strstr(result, "@")) {
941 *(strstr(result,"@")) = '\0';
944 result = g_strdup(tmpl.recvuser);
949 static gchar *get_default_smtp_account(WizardWindow * wizard)
951 gchar *result = NULL;
953 if (!tmpl.smtpuser || !strlen(tmpl.smtpuser)) {
956 result = g_strdup(tmpl.smtpuser);
961 static void wizard_email_changed(GtkWidget *widget, gpointer data)
963 WizardWindow *wizard = (WizardWindow *)data;
964 RecvProtocol protocol;
966 protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
968 text = get_default_server(wizard, "smtp");
969 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
972 text = get_default_account(wizard);
973 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
976 if (protocol == A_POP3) {
977 text = get_default_server(wizard, "pop");
978 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
980 } else if (protocol == A_IMAP4) {
981 text = get_default_server(wizard, "imap");
982 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
984 } else if (protocol == A_LOCAL) {
985 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
990 static GtkWidget* user_page (WizardWindow * wizard)
992 GtkWidget *table = gtk_table_new(1,1, FALSE);
996 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
997 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
999 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1000 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1002 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1003 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1005 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1006 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1007 wizard->full_name = gtk_entry_new();
1008 gtk_entry_set_text(GTK_ENTRY(wizard->full_name), tmpl.name?tmpl.name:"");
1009 PACK_BOX(hbox, _("<span weight=\"bold\">Your name:</span>"),
1012 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1013 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1014 wizard->email = gtk_entry_new();
1015 gtk_entry_set_text(GTK_ENTRY(wizard->email), tmpl.email?tmpl.email:"");
1016 PACK_BOX(hbox, _("<span weight=\"bold\">Your email address:</span>"),
1019 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1020 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1021 wizard->organization = gtk_entry_new();
1022 gtk_entry_set_text(GTK_ENTRY(wizard->organization), tmpl.organization?tmpl.organization:"");
1023 PACK_BOX(hbox, _("Your organization:"), wizard->organization);
1025 g_signal_connect(G_OBJECT(wizard->email), "changed",
1026 G_CALLBACK(wizard_email_changed),
1032 static void wizard_vol_mount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
1034 gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
1035 gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1038 if(!strcmp(mount_path, MMC1_PATH)) {
1039 gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, TRUE);
1041 if(!strcmp(mount_path, MMC2_PATH)) {
1042 gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, TRUE);
1047 static void wizard_vol_unmount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
1049 gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
1050 gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1053 if(!strcmp(mount_path, MMC1_PATH)) {
1054 gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, FALSE);
1055 if (gtk_toggle_button_get_active(
1056 GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn))) {
1057 gtk_toggle_button_set_active(
1058 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn), TRUE);
1061 if(!strcmp(mount_path, MMC2_PATH)) {
1062 gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, FALSE);
1063 if (gtk_toggle_button_get_active(
1064 GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn))) {
1065 gtk_toggle_button_set_active(
1066 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn), TRUE);
1073 void data_root_changed (GtkToggleButton *toggle_btn,
1074 WizardWindow *wizard)
1076 gchar *name = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
1078 if (gtk_toggle_button_get_active(
1079 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn)))
1080 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), name);
1081 else if (gtk_toggle_button_get_active(
1082 GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn))) {
1083 path = g_strconcat(MMC1_PATH, G_DIR_SEPARATOR_S,
1084 "Claws", G_DIR_SEPARATOR_S,
1085 g_get_user_name(), G_DIR_SEPARATOR_S,
1087 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
1089 } else if (gtk_toggle_button_get_active(
1090 GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn))) {
1091 path = g_strconcat(MMC2_PATH, G_DIR_SEPARATOR_S,
1092 "Claws", G_DIR_SEPARATOR_S,
1093 g_get_user_name(), G_DIR_SEPARATOR_S,
1095 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
1102 static GtkWidget* mailbox_page (WizardWindow * wizard)
1104 GtkWidget *table = gtk_table_new(1,1, FALSE);
1108 gchar *uri, *mount_path;
1113 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1114 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1116 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1117 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1119 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1120 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1122 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1123 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1125 wizard->mailbox_label = gtk_label_new(_("<span weight=\"bold\">Mailbox name:</span>"));
1126 gtk_label_set_use_markup(GTK_LABEL(wizard->mailbox_label), TRUE);
1127 if (GTK_IS_MISC(wizard->mailbox_label))
1128 gtk_misc_set_alignment(GTK_MISC(wizard->mailbox_label), 1, 0.5);
1129 wizard->mailbox_name = gtk_entry_new();
1131 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), tmpl.mailbox?tmpl.mailbox:"");
1133 CLAWS_SET_TIP(wizard->mailbox_name, _("You can also specify an absolute path, for example: "
1134 "\"/home/john/Documents/Mail\""));
1136 gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_label, FALSE, FALSE, 0);
1137 gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_name, TRUE, TRUE, 0);
1140 wizard->data_root_nokia_radiobtn = gtk_radio_button_new_with_label(NULL,
1141 _("on internal memory"));
1142 wizard->data_root_mmc1_radiobtn = gtk_radio_button_new_with_label_from_widget(
1143 GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
1144 _("on external memory card"));
1145 wizard->data_root_mmc2_radiobtn = gtk_radio_button_new_with_label_from_widget(
1146 GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
1147 _("on internal memory card"));
1149 g_signal_connect(G_OBJECT(wizard->data_root_nokia_radiobtn), "toggled",
1150 G_CALLBACK(data_root_changed), wizard);
1151 g_signal_connect(G_OBJECT(wizard->data_root_mmc1_radiobtn), "toggled",
1152 G_CALLBACK(data_root_changed), wizard);
1153 g_signal_connect(G_OBJECT(wizard->data_root_mmc2_radiobtn), "toggled",
1154 G_CALLBACK(data_root_changed), wizard);
1156 wizard->volmon = gnome_vfs_get_volume_monitor();
1157 wizard->vol_mmc1 = gnome_vfs_volume_monitor_get_volume_for_path(wizard->volmon, MMC1_PATH);
1158 wizard->vol_mmc2 = gnome_vfs_volume_monitor_get_volume_for_path(wizard->volmon, MMC2_PATH);
1160 uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc1);
1161 mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1163 if (wizard->vol_mmc1 == NULL || !gnome_vfs_volume_is_mounted(wizard->vol_mmc1)
1164 || strcmp(mount_path, MMC1_PATH)) {
1165 gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, FALSE);
1169 uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc2);
1170 mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1172 if (wizard->vol_mmc2 == NULL || !gnome_vfs_volume_is_mounted(wizard->vol_mmc2)
1173 || strcmp(mount_path, MMC2_PATH)) {
1174 gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, FALSE);
1176 gtk_toggle_button_set_active(wizard->data_root_mmc2_radiobtn, TRUE);
1180 gnome_vfs_volume_unref(wizard->vol_mmc1);
1181 gnome_vfs_volume_unref(wizard->vol_mmc2);
1182 wizard->vol_mmc1 = NULL;
1183 wizard->vol_mmc2 = NULL;
1185 wizard->volmon_mount_sigid = g_signal_connect(G_OBJECT(wizard->volmon),
1186 "volume-mounted", G_CALLBACK(wizard_vol_mount_cb), wizard);
1187 wizard->volmon_unmount_sigid = g_signal_connect(G_OBJECT(wizard->volmon),
1188 "volume-unmounted", G_CALLBACK(wizard_vol_unmount_cb), wizard);
1190 vbox2 = gtk_vbox_new(FALSE, VSPACING_NARROW);
1191 gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_nokia_radiobtn, FALSE, FALSE, 0);
1192 gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_mmc1_radiobtn, FALSE, FALSE, 0);
1193 gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_mmc2_radiobtn, FALSE, FALSE, 0);
1195 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1196 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1197 PACK_BOX(hbox, _("<span weight=\"bold\">Store data</span>"),
1204 static void smtp_auth_changed (GtkWidget *btn, gpointer data)
1206 WizardWindow *wizard = (WizardWindow *)data;
1207 gboolean do_auth = gtk_toggle_button_get_active(
1208 GTK_TOGGLE_BUTTON(wizard->smtp_auth));
1209 gtk_widget_set_sensitive(wizard->smtp_username, do_auth);
1210 gtk_widget_set_sensitive(wizard->smtp_username_label, do_auth);
1211 gtk_widget_set_sensitive(wizard->smtp_password, do_auth);
1212 gtk_widget_set_sensitive(wizard->smtp_password_label, do_auth);
1216 static void cert_browse_cb(GtkWidget *widget, gpointer data)
1218 GtkEntry *dest = GTK_ENTRY(data);
1220 gchar *utf8_filename;
1222 filename = filesel_select_file_open(_("Select certificate file"), NULL);
1223 if (!filename) return;
1225 utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
1226 if (!utf8_filename) {
1227 g_warning("cert_browse_cb(): failed to convert character set.");
1228 utf8_filename = g_strdup(filename);
1230 gtk_entry_set_text(dest, utf8_filename);
1231 g_free(utf8_filename);
1235 static GtkWidget* smtp_page (WizardWindow * wizard)
1237 GtkWidget *table = gtk_table_new(1, 1, FALSE);
1243 GtkWidget *smtp_cert_table;
1248 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1249 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1251 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1252 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1254 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1255 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1257 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1258 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1259 wizard->smtp_server = gtk_entry_new();
1260 text = get_default_server(wizard, "smtp");
1261 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
1264 CLAWS_SET_TIP(wizard->smtp_server,
1265 _("You can specify the port number by appending it at the end: "
1266 "\"mail.example.com:25\""));
1268 PACK_BOX(hbox, _("<span weight=\"bold\">SMTP server address:</span>"),
1269 wizard->smtp_server);
1272 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1273 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1274 wizard->smtp_auth = gtk_check_button_new_with_label(
1275 _("Use authentication"));
1276 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth),
1278 g_signal_connect(G_OBJECT(wizard->smtp_auth), "toggled",
1279 G_CALLBACK(smtp_auth_changed),
1281 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_auth, FALSE, FALSE, 0);
1283 text = get_default_smtp_account(wizard);
1285 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1286 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1287 wizard->smtp_username = gtk_entry_new();
1288 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_username), text);
1290 wizard->smtp_username_label = gtk_label_new(_("SMTP username:\n"
1291 "<span size=\"small\">(empty to use the same as receive)</span>"));
1292 gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_username_label), TRUE);
1293 if (GTK_IS_MISC(wizard->smtp_username_label))
1294 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_username_label), 1, 0.5);
1295 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_username_label, FALSE, FALSE, 0);
1296 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_username, TRUE, TRUE, 0);
1298 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1299 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1300 wizard->smtp_password = gtk_entry_new();
1301 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_password), tmpl.smtppass?tmpl.smtppass:"");
1302 gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_password), FALSE);
1304 hildon_gtk_entry_set_input_mode(GTK_ENTRY(wizard->smtp_password),
1305 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
1307 wizard->smtp_password_label = gtk_label_new(_("SMTP password:\n"
1308 "<span size=\"small\">(empty to use the same as receive)</span>"));
1309 gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_password_label), TRUE);
1310 if (GTK_IS_MISC(wizard->smtp_password_label))
1311 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_password_label), 1, 0.5);
1312 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password_label, FALSE, FALSE, 0);
1313 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password, TRUE, TRUE, 0);
1315 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1316 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1317 wizard->smtp_use_ssl = gtk_check_button_new_with_label(
1318 _("Use SSL to connect to SMTP server"));
1319 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl),
1321 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_ssl, FALSE, FALSE, 0);
1323 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1324 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1325 wizard->smtp_use_tls = gtk_check_button_new_with_label(
1326 _("Use SSL via STARTTLS"));
1327 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls),
1329 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_tls, FALSE, FALSE, 0);
1330 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_use_tls);
1332 smtp_cert_table = gtk_table_new(3,3, FALSE);
1333 gtk_container_set_border_width(GTK_CONTAINER(smtp_cert_table), 8);
1334 gtk_box_pack_start (GTK_BOX(vbox), smtp_cert_table, FALSE, FALSE, 0);
1335 label = gtk_label_new(_("Client SSL certificate (optional)"));
1336 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1337 gtk_table_attach(GTK_TABLE(smtp_cert_table), label, 0, 3, 0, 1, GTK_FILL, 0, 0, 0);
1338 label = gtk_label_new(_("File"));
1339 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1340 gtk_table_attach(GTK_TABLE(smtp_cert_table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1341 wizard->smtp_ssl_cert_file = gtk_entry_new();
1342 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_file), tmpl.smtpssl_cert?tmpl.smtpssl_cert:"");
1343 gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_file, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1344 button = gtkut_get_browse_file_btn(_("Browse"));
1345 gtk_table_attach(GTK_TABLE(smtp_cert_table), button, 2, 3, 1, 2, GTK_FILL, 0, 0, 0);
1346 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, label);
1347 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_ssl_cert_file);
1348 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, button);
1349 g_signal_connect(G_OBJECT(button), "clicked",
1350 G_CALLBACK(cert_browse_cb), wizard->smtp_ssl_cert_file);
1352 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1353 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1354 label = gtk_label_new(_("Password"));
1355 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1356 gtk_table_attach(GTK_TABLE(smtp_cert_table), label, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
1357 wizard->smtp_ssl_cert_pass = gtk_entry_new();
1358 gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_ssl_cert_pass), FALSE);
1359 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_pass), tmpl.smtpssl_cert_pass?tmpl.smtpssl_cert_pass:"");
1360 gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_pass, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1361 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, label);
1362 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_ssl_cert_pass);
1363 wizard->smtp_cert_table = smtp_cert_table;
1365 smtp_auth_changed(NULL, wizard);
1369 static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
1373 if (protocol == A_POP3) {
1374 text = get_default_server(wizard, "pop");
1375 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1376 gtk_widget_hide(wizard->recv_imap_label);
1377 gtk_widget_hide(wizard->recv_imap_subdir);
1378 gtk_widget_hide(wizard->subsonly_checkbtn);
1379 gtk_widget_show(wizard->recv_username);
1380 gtk_widget_show(wizard->recv_password);
1381 gtk_widget_show(wizard->recv_username_label);
1382 gtk_widget_show(wizard->recv_password_label);
1383 gtk_widget_hide(wizard->no_imap_warning);
1385 gtk_widget_show(wizard->recv_use_ssl);
1386 gtk_widget_show(wizard->recv_use_tls);
1387 gtk_widget_show(wizard->recv_cert_table);
1389 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
1390 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1391 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1393 if (wizard->create_mailbox) {
1394 gtk_widget_show(wizard->mailbox_label);
1395 gtk_widget_show(wizard->mailbox_name);
1397 } else if (protocol == A_IMAP4) {
1398 #ifdef HAVE_LIBETPAN
1399 text = get_default_server(wizard, "imap");
1400 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1401 gtk_widget_show(wizard->recv_imap_label);
1402 gtk_widget_show(wizard->recv_imap_subdir);
1403 gtk_widget_show(wizard->subsonly_checkbtn);
1404 gtk_widget_show(wizard->recv_username);
1405 gtk_widget_show(wizard->recv_password);
1406 gtk_widget_show(wizard->recv_username_label);
1407 gtk_widget_show(wizard->recv_password_label);
1408 gtk_widget_hide(wizard->no_imap_warning);
1410 gtk_widget_show(wizard->recv_use_ssl);
1411 gtk_widget_show(wizard->recv_use_tls);
1412 gtk_widget_show(wizard->recv_cert_table);
1414 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
1415 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1416 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1418 if (wizard->create_mailbox) {
1419 gtk_widget_hide(wizard->mailbox_label);
1420 gtk_widget_hide(wizard->mailbox_name);
1423 gtk_widget_hide(wizard->recv_imap_label);
1424 gtk_widget_hide(wizard->recv_imap_subdir);
1425 gtk_widget_hide(wizard->subsonly_checkbtn);
1426 gtk_widget_hide(wizard->recv_username);
1427 gtk_widget_hide(wizard->recv_password);
1428 gtk_widget_hide(wizard->recv_username_label);
1429 gtk_widget_hide(wizard->recv_password_label);
1430 gtk_widget_show(wizard->no_imap_warning);
1431 if (wizard->create_mailbox) {
1432 gtk_widget_hide(wizard->mailbox_label);
1433 gtk_widget_hide(wizard->mailbox_name);
1436 gtk_widget_hide(wizard->recv_use_ssl);
1437 gtk_widget_hide(wizard->recv_use_tls);
1438 gtk_widget_hide(wizard->recv_cert_table);
1440 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, FALSE);
1442 } else if (protocol == A_LOCAL) {
1443 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
1444 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Local mailbox:</span>"));
1445 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1446 gtk_widget_hide(wizard->no_imap_warning);
1447 gtk_widget_hide(wizard->recv_imap_label);
1448 gtk_widget_hide(wizard->recv_imap_subdir);
1449 gtk_widget_hide(wizard->subsonly_checkbtn);
1450 gtk_widget_hide(wizard->recv_username);
1451 gtk_widget_hide(wizard->recv_password);
1452 gtk_widget_hide(wizard->recv_username_label);
1453 gtk_widget_hide(wizard->recv_password_label);
1455 gtk_widget_hide(wizard->recv_use_ssl);
1456 gtk_widget_hide(wizard->recv_use_tls);
1457 gtk_widget_hide(wizard->recv_cert_table);
1459 if (wizard->create_mailbox) {
1460 gtk_widget_show(wizard->mailbox_label);
1461 gtk_widget_show(wizard->mailbox_name);
1463 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1467 static void wizard_protocol_changed(GtkComboBox *combo, gpointer data)
1469 WizardWindow *wizard = (WizardWindow *)data;
1470 RecvProtocol protocol = combobox_get_active_data(combo);
1472 wizard_protocol_change(wizard, protocol);
1475 static GtkWidget* recv_page (WizardWindow * wizard)
1477 GtkWidget *table = gtk_table_new(1,1, FALSE);
1483 GtkWidget *recv_cert_table;
1485 GtkListStore *store;
1491 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1492 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1494 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1495 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1497 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1498 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1500 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1501 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1502 wizard->recv_type = gtkut_sc_combobox_create(NULL, FALSE);
1503 store = GTK_LIST_STORE(gtk_combo_box_get_model(
1504 GTK_COMBO_BOX(wizard->recv_type)));
1506 COMBOBOX_ADD(store, _("POP3"), A_POP3);
1507 COMBOBOX_ADD(store, _("IMAP"), A_IMAP4);
1508 COMBOBOX_ADD(store, _("Local mbox file"), A_LOCAL);
1510 switch(tmpl.recvtype) {
1523 gtk_combo_box_set_active(GTK_COMBO_BOX (wizard->recv_type), index);
1524 g_signal_connect(G_OBJECT(wizard->recv_type), "changed",
1525 G_CALLBACK(wizard_protocol_changed),
1527 PACK_BOX(hbox, _("<span weight=\"bold\">Server type:</span>"),
1530 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1531 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1532 wizard->recv_server = gtk_entry_new();
1533 text = get_default_server(wizard, "pop");
1534 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1537 CLAWS_SET_TIP(wizard->recv_server,
1538 _("You can specify the port number by appending it at the end: "
1539 "\"mail.example.com:110\""));
1541 wizard->recv_label = gtk_label_new(_("<span weight=\"bold\">Server address:</span>"));
1542 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1543 if (GTK_IS_MISC(wizard->recv_label))
1544 gtk_misc_set_alignment(GTK_MISC(wizard->recv_label), 1, 0.5);
1545 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_label, FALSE, FALSE, 0);
1546 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_server, TRUE, TRUE, 0);
1548 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1549 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1550 wizard->recv_username = gtk_entry_new();
1551 wizard->recv_username_label = gtk_label_new(_("<span weight=\"bold\">Username:</span>"));
1552 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_username_label), TRUE);
1553 if (GTK_IS_MISC(wizard->recv_username_label))
1554 gtk_misc_set_alignment(GTK_MISC(wizard->recv_username_label), 1, 0.5);
1555 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_username_label, FALSE, FALSE, 0);
1556 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_username, TRUE, TRUE, 0);
1558 text = get_default_account(wizard);
1559 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
1562 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1563 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1564 wizard->recv_password = gtk_entry_new();
1565 gtk_entry_set_text(GTK_ENTRY(wizard->recv_password), tmpl.recvpass?tmpl.recvpass:"");
1566 wizard->recv_password_label = gtk_label_new(_("Password:"));
1567 if (GTK_IS_MISC(wizard->recv_password_label))
1568 gtk_misc_set_alignment(GTK_MISC(wizard->recv_password_label), 1, 0.5);
1569 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_password), FALSE);
1571 hildon_gtk_entry_set_input_mode(GTK_ENTRY(wizard->recv_password),
1572 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
1574 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_password_label, FALSE, FALSE, 0);
1575 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_password, TRUE, TRUE, 0);
1578 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1579 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1580 wizard->recv_use_ssl = gtk_check_button_new_with_label(
1581 _("Use SSL to connect to receiving server"));
1582 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl),
1584 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_ssl, FALSE, FALSE, 0);
1586 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1587 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1588 wizard->recv_use_tls = gtk_check_button_new_with_label(
1589 _("Use SSL via STARTTLS"));
1590 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls),
1592 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_tls, FALSE, FALSE, 0);
1593 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_use_tls);
1595 recv_cert_table = gtk_table_new(3,3, FALSE);
1596 gtk_container_set_border_width(GTK_CONTAINER(recv_cert_table), 8);
1597 gtk_box_pack_start (GTK_BOX(vbox), recv_cert_table, FALSE, FALSE, 0);
1598 label = gtk_label_new(_("Client SSL certificate (optional)"));
1599 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1600 gtk_table_attach(GTK_TABLE(recv_cert_table), label, 0, 3, 0, 1, GTK_FILL, 0, 0, 0);
1601 label = gtk_label_new(_("File"));
1602 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1603 gtk_table_attach(GTK_TABLE(recv_cert_table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1604 wizard->recv_ssl_cert_file = gtk_entry_new();
1605 gtk_entry_set_text(GTK_ENTRY(wizard->recv_ssl_cert_file), tmpl.recvssl_cert?tmpl.recvssl_cert:"");
1606 gtk_table_attach(GTK_TABLE(recv_cert_table), wizard->recv_ssl_cert_file, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1607 button = gtkut_get_browse_file_btn(_("Browse"));
1608 gtk_table_attach(GTK_TABLE(recv_cert_table), button, 2, 3, 1, 2, GTK_FILL, 0, 0, 0);
1609 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, label);
1610 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_ssl_cert_file);
1611 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, button);
1612 g_signal_connect(G_OBJECT(button), "clicked",
1613 G_CALLBACK(cert_browse_cb), wizard->recv_ssl_cert_file);
1615 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1616 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1617 label = gtk_label_new(_("Password"));
1618 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1619 gtk_table_attach(GTK_TABLE(recv_cert_table), label, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
1620 wizard->recv_ssl_cert_pass = gtk_entry_new();
1621 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_ssl_cert_pass), FALSE);
1622 gtk_entry_set_text(GTK_ENTRY(wizard->recv_ssl_cert_pass), tmpl.recvssl_cert_pass?tmpl.recvssl_cert_pass:"");
1623 gtk_table_attach(GTK_TABLE(recv_cert_table), wizard->recv_ssl_cert_pass, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1624 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, label);
1625 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_ssl_cert_pass);
1626 wizard->recv_cert_table = recv_cert_table;
1628 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1629 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1630 wizard->recv_imap_subdir = gtk_entry_new();
1631 gtk_entry_set_text(GTK_ENTRY(wizard->recv_imap_subdir), tmpl.imapdir?tmpl.imapdir:"");
1632 wizard->recv_imap_label = gtk_label_new(_("IMAP server directory:"));
1633 if (GTK_IS_MISC(wizard->recv_imap_label))
1634 gtk_misc_set_alignment(GTK_MISC(wizard->recv_imap_label), 1, 0.5);
1635 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_label, FALSE, FALSE, 0);
1636 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_subdir, TRUE, TRUE, 0);
1638 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1639 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1640 wizard->subsonly_checkbtn = gtk_check_button_new_with_label(
1641 _("Show only subscribed folders"));
1642 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn),
1644 gtk_box_pack_start(GTK_BOX(hbox), wizard->subsonly_checkbtn, FALSE, FALSE, 0);
1646 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1647 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1648 wizard->no_imap_warning = gtk_label_new(_(
1649 "<span weight=\"bold\">Warning: this version of Claws Mail\n"
1650 "has been built without IMAP support.</span>"));
1651 gtk_label_set_use_markup(GTK_LABEL(wizard->no_imap_warning), TRUE);
1652 gtk_box_pack_start(GTK_BOX(hbox), wizard->no_imap_warning, FALSE, FALSE, 0);
1658 wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
1660 WizardWindow * wizard = (WizardWindow *)data;
1661 int current_page, num_pages;
1662 gboolean skip_mailbox_page = FALSE;
1664 gint protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
1666 if (protocol == A_IMAP4) {
1667 skip_mailbox_page = TRUE;
1671 num_pages = g_slist_length(wizard->pages);
1673 current_page = gtk_notebook_get_current_page (
1674 GTK_NOTEBOOK(wizard->notebook));
1675 if (response == CANCEL)
1677 wizard->result = FALSE;
1678 wizard->finished = TRUE;
1679 gtk_widget_destroy (GTK_WIDGET(dialog));
1681 else if (response == FINISHED)
1683 if (!wizard_write_config(wizard)) {
1684 current_page = gtk_notebook_get_current_page (
1685 GTK_NOTEBOOK(wizard->notebook));
1688 wizard->result = TRUE;
1689 wizard->finished = TRUE;
1690 gtk_widget_destroy (GTK_WIDGET(dialog));
1694 if (response == GO_BACK)
1696 if (current_page > 0) {
1698 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1702 gtk_notebook_set_current_page (
1703 GTK_NOTEBOOK(wizard->notebook),
1707 else if (response == GO_FORWARD)
1709 if (current_page < (num_pages-1)) {
1711 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1715 gtk_notebook_set_current_page (
1716 GTK_NOTEBOOK(wizard->notebook),
1721 gtk_dialog_set_response_sensitive (dialog, GO_BACK,
1723 gtk_dialog_set_response_sensitive (dialog, GO_FORWARD,
1724 current_page < (num_pages - 1));
1725 if (current_page == (num_pages -1)) {
1726 gtk_dialog_set_response_sensitive (dialog, FINISHED, TRUE);
1727 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), FINISHED);
1729 gtk_dialog_set_response_sensitive (dialog, FINISHED, FALSE);
1730 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), GO_FORWARD);
1736 static gint wizard_close_cb(GtkWidget *widget, GdkEventAny *event,
1739 WizardWindow *wizard = (WizardWindow *)data;
1740 wizard->result = FALSE;
1741 wizard->finished = TRUE;
1746 #define PACK_WARNING(text) { \
1747 label = gtk_label_new(text); \
1748 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); \
1749 gtk_box_pack_end(GTK_BOX(widget), label, FALSE, FALSE, 0); \
1752 gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
1753 WizardWindow *wizard = g_new0(WizardWindow, 1);
1757 GtkWidget *scrolled_window;
1762 wizard->mainwin = mainwin;
1763 wizard->create_mailbox = create_mailbox;
1765 gtk_widget_hide(mainwin->window);
1767 wizard_read_defaults();
1769 wizard->window = gtk_dialog_new_with_buttons (_("Claws Mail Setup Wizard"),
1771 GTK_STOCK_GO_BACK, GO_BACK,
1772 GTK_STOCK_GO_FORWARD, GO_FORWARD,
1773 GTK_STOCK_SAVE, FINISHED,
1774 GTK_STOCK_CANCEL, CANCEL,
1776 gtk_widget_set_size_request(wizard->window, -1, 480);
1778 g_signal_connect(wizard->window, "response",
1779 G_CALLBACK(wizard_response_cb), wizard);
1780 gtk_widget_realize(wizard->window);
1781 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window),
1783 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1785 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1787 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1789 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1792 wizard->notebook = gtk_notebook_new();
1793 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(wizard->notebook), FALSE);
1794 gtk_notebook_set_show_border(GTK_NOTEBOOK(wizard->notebook), FALSE);
1795 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(wizard->window)->vbox),
1796 wizard->notebook, TRUE, TRUE, 0);
1798 wizard->pages = NULL;
1800 /*welcome page: 0 */
1802 page = create_page(wizard, _("Welcome to Claws Mail"));
1804 wizard->pages = g_slist_append(wizard->pages, page);
1805 widget = stock_pixmap_widget(wizard->window,
1806 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1808 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1810 text = g_strdup(_("Welcome to the Claws Mail setup wizard.\n\n"
1811 "We will begin by defining some basic "
1812 "information about you and your most common "
1813 "mail options so that you can start to use "
1814 "Claws Mail in less than five minutes."));
1815 widget = gtk_label_new(text);
1816 gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
1818 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1820 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1821 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1822 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1823 gtk_box_pack_start(GTK_BOX(page), scrolled_window, TRUE, TRUE, 0);
1825 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1833 widget = create_page (wizard, _("About You"));
1834 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1835 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1836 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1837 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1839 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1841 PACK_WARNING(_("Bold fields must be completed"));
1843 wizard->pages = g_slist_append(wizard->pages, widget);
1845 /* recv+auth page: 2 */
1848 widget = create_page (wizard, _("Receiving mail"));
1849 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1850 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1851 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1852 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1854 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1856 PACK_WARNING(_("Bold fields must be completed"));
1858 wizard->pages = g_slist_append(wizard->pages, widget);
1863 widget = create_page (wizard, _("Sending mail"));
1864 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1865 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1866 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1867 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1869 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1871 PACK_WARNING(_("Bold fields must be completed"));
1873 wizard->pages = g_slist_append(wizard->pages, widget);
1875 /* mailbox page: 4 */
1876 if (create_mailbox) {
1879 widget = create_page (wizard, _("Saving mail on disk"));
1880 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1881 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1882 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1883 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1885 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1886 mailbox_page(wizard));
1887 PACK_WARNING(_("Bold fields must be completed"));
1889 wizard->pages = g_slist_append(wizard->pages, widget);
1895 page = create_page(wizard, _("Configuration finished"));
1897 wizard->pages = g_slist_append(wizard->pages, page);
1898 widget = stock_pixmap_widget(wizard->window,
1899 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1901 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1903 text = g_strdup(_("Claws Mail is now ready.\n"
1904 "Click Save to start."));
1905 widget = gtk_label_new(text);
1906 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1910 for (cur = wizard->pages; cur && cur->data; cur = cur->next) {
1911 gtk_notebook_append_page (GTK_NOTEBOOK(wizard->notebook),
1912 GTK_WIDGET(cur->data), NULL);
1915 g_signal_connect(G_OBJECT(wizard->window), "delete_event",
1916 G_CALLBACK(wizard_close_cb), wizard);
1917 gtk_widget_show_all (wizard->window);
1919 gtk_widget_hide(wizard->recv_imap_label);
1920 gtk_widget_hide(wizard->recv_imap_subdir);
1921 gtk_widget_hide(wizard->subsonly_checkbtn);
1923 wizard_protocol_change(wizard, tmpl.recvtype);
1925 while (!wizard->finished)
1926 gtk_main_iteration();
1928 result = wizard->result;
1932 gtk_widget_show(mainwin->window);