2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2007 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>
30 #include <gtk/gtkwidget.h>
31 #include <gtk/gtkvbox.h>
32 #include <gtk/gtkbox.h>
33 #include <gtk/gtktable.h>
34 #include <gtk/gtkentry.h>
35 #include <gtk/gtklabel.h>
36 #include <gtk/gtknotebook.h>
37 #include <gtk/gtktogglebutton.h>
38 #include <gtk/gtkcheckbutton.h>
54 #include "prefs_account.h"
55 #include "mainwindow.h"
56 #include "stock_pixmap.h"
59 #include "alertpanel.h"
61 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
64 #include "prefs_common.h"
68 #include <libgnomevfs/gnome-vfs-volume.h>
69 #include <libgnomevfs/gnome-vfs-volume-monitor.h>
70 #include <libgnomevfs/gnome-vfs-utils.h>
81 int WELCOME_PAGE = -1;
85 int MAILBOX_PAGE = -1;
98 GtkWidget *organization;
100 GtkWidget *mailbox_name;
101 GtkWidget *mailbox_label;
103 GtkWidget *smtp_server;
104 GtkWidget *smtp_auth;
105 GtkWidget *smtp_username;
106 GtkWidget *smtp_password;
107 GtkWidget *smtp_username_label;
108 GtkWidget *smtp_password_label;
110 GtkWidget *recv_type;
111 GtkWidget *recv_label;
112 GtkWidget *recv_server;
113 GtkWidget *recv_username;
114 GtkWidget *recv_password;
115 GtkWidget *recv_username_label;
116 GtkWidget *recv_password_label;
117 GtkWidget *recv_imap_label;
118 GtkWidget *recv_imap_subdir;
119 GtkWidget *subsonly_checkbtn;
120 GtkWidget *no_imap_warning;
121 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
122 GtkWidget *smtp_use_ssl;
123 GtkWidget *recv_use_ssl;
124 GtkWidget *smtp_use_tls;
125 GtkWidget *recv_use_tls;
126 GtkWidget *smtp_ssl_cert_file;
127 GtkWidget *recv_ssl_cert_file;
128 GtkWidget *smtp_ssl_cert_pass;
129 GtkWidget *recv_ssl_cert_pass;
130 GtkWidget *smtp_cert_table;
131 GtkWidget *recv_cert_table;
135 GtkWidget *data_root_nokia_radiobtn;
136 GtkWidget *data_root_mmc1_radiobtn;
137 GtkWidget *data_root_mmc2_radiobtn;
138 GnomeVFSVolumeMonitor *volmon;
139 gulong volmon_mount_sigid;
140 gulong volmon_unmount_sigid;
141 GnomeVFSVolume *vol_mmc1;
142 GnomeVFSVolume *vol_mmc2;
144 gboolean create_mailbox;
150 typedef struct _AccountTemplate {
159 RecvProtocol recvtype;
171 gchar *smtpssl_cert_pass;
172 gchar *recvssl_cert_pass;
175 static AccountTemplate tmpl;
177 static PrefParam template_params[] = {
178 {"name", "$USERNAME",
179 &tmpl.name, P_STRING, NULL, NULL, NULL},
180 {"domain", "$DEFAULTDOMAIN",
181 &tmpl.domain, P_STRING, NULL, NULL, NULL},
182 {"email", "$NAME_MAIL@$DOMAIN",
183 &tmpl.email, P_STRING, NULL, NULL, NULL},
185 &tmpl.organization, P_STRING, NULL, NULL, NULL},
186 {"smtpserver", "smtp.$DOMAIN",
187 &tmpl.smtpserver, P_STRING, NULL, NULL, NULL},
188 {"smtpauth", "FALSE",
189 &tmpl.smtpauth, P_BOOL, NULL, NULL, NULL},
191 &tmpl.smtpuser, P_STRING, NULL, NULL, NULL},
193 &tmpl.smtppass, P_STRING, NULL, NULL, NULL},
195 &tmpl.recvtype, P_INT, NULL, NULL, NULL},
196 {"recvserver", "pop.$DOMAIN",
197 &tmpl.recvserver, P_STRING, NULL, NULL, NULL},
198 {"recvuser", "$LOGIN",
199 &tmpl.recvuser, P_STRING, NULL, NULL, NULL},
201 &tmpl.recvpass, P_STRING, NULL, NULL, NULL},
203 &tmpl.imapdir, P_STRING, NULL, NULL, NULL},
205 &tmpl.subsonly, P_BOOL, NULL, NULL, NULL},
206 {"mboxfile", "/var/mail/$LOGIN",
207 &tmpl.mboxfile, P_STRING, NULL, NULL, NULL},
209 &tmpl.mailbox, P_STRING, NULL, NULL, NULL},
211 &tmpl.smtpssl, P_INT, NULL, NULL, NULL},
213 &tmpl.recvssl, P_INT, NULL, NULL, NULL},
215 &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
217 &tmpl.recvssl_cert, P_STRING, NULL, NULL, NULL},
218 {"smtpssl_cert_pass", "",
219 &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
220 {"recvssl_cert_pass", "",
221 &tmpl.recvssl_cert, P_STRING, NULL, NULL, NULL},
222 {NULL, NULL, NULL, P_INT, NULL, NULL, NULL}
226 static gchar *accountrc_tmpl =
227 "[AccountTemplate]\n"
228 "#you can use $DEFAULTDOMAIN here\n"
229 "#domain must be defined before the variables that use it\n"
230 "#by default, domain is extracted from the hostname\n"
233 "#you can use $USERNAME for name (this is the default)\n"
236 "#you can use $LOGIN, $NAME_MAIL and $DOMAIN here \n"
237 "#$NAME_MAIL is the name without uppercase and with dots instead\n"
239 "#the default is $NAME_MAIL@$DOMAIN\n"
242 "#you can use $DOMAIN here\n"
243 "#the default organization is empty\n"
246 "#you can use $DOMAIN here \n"
247 "#the default is smtp.$DOMAIN\n"
250 "#Whether to use smtp authentication\n"
251 "#the default is 0 (no)\n"
255 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
256 "#the default is empty (same as reception username)\n"
260 "#the default is empty (same as reception password)\n"
263 "#recvtype can be:\n"
266 "#5 for a local mbox file\n"
269 "#you can use $DOMAIN here \n"
270 "#the default is {pop,imap}.$DOMAIN\n"
273 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
274 "#default is $LOGIN\n"
277 "#default is empty\n"
280 "#imap dir if imap (relative to the home on the server)\n"
281 "#default is empty\n"
284 "#show subscribed folders only, if imap\n"
288 "#mbox file if local\n"
289 "#you can use $LOGIN here\n"
290 "#default is /var/mail/$LOGIN\n"
293 "#mailbox name if pop3 or local\n"
294 "#relative path from the user's home\n"
295 "#default is \"Mail\"\n"
298 "#whether to use ssl on smtp connections\n"
299 "#default is 0, 1 is ssl, 2 is starttls\n"
302 "#whether to use ssl on pop or imap connections\n"
303 "#default is 0, 1 is ssl, 2 is starttls\n"
306 "#SSL client certificate path for SMTP\n"
307 "#default is empty (no certificate)\n"
310 "#SSL client certificate path for POP/IMAP\n"
311 "#default is empty (no certificate)\n"
314 "#SSL client certificate password for SMTP\n"
315 "#default is empty (no password)\n"
316 "#smtpssl_cert_pass=\n"
318 "#SSL client certificate password for POP/IMAP\n"
319 "#default is empty (no password)\n"
320 "#recvssl_cert_pass=\n"
323 static gchar *wizard_get_default_domain_name(void)
325 static gchar *domain_name = NULL;
327 if (domain_name == NULL) {
328 domain_name = g_strdup(get_domain_name());
329 if (strchr(domain_name, '.') != strrchr(domain_name, '.')
330 && strlen(strchr(domain_name, '.')) > 6) {
331 gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
339 static gchar *get_name_for_mail(void)
342 if (tmpl.name == NULL)
344 name = g_utf8_strdown(tmpl.name, -1);
345 while(strstr(name, " "))
346 *strstr(name, " ")='.';
351 #define PARSE_DEFAULT(str) { \
352 gchar *tmp = NULL, *new = NULL; \
354 tmp = g_strdup(str); \
355 if (strstr(str, "$USERNAME")) { \
356 tmp = g_strdup(str); \
357 *strstr(tmp, "$USERNAME") = '\0'; \
358 new = g_strconcat(tmp, g_get_real_name(), \
359 strstr(str, "$USERNAME")+strlen("$USERNAME"), \
366 if (strstr(str, "$LOGIN")) { \
367 tmp = g_strdup(str); \
368 *strstr(tmp, "$LOGIN") = '\0'; \
369 new = g_strconcat(tmp, g_get_user_name(), \
370 strstr(str, "$LOGIN")+strlen("$LOGIN"), \
377 if (strstr(str, "$EMAIL")) { \
378 tmp = g_strdup(str); \
379 *strstr(tmp, "$EMAIL") = '\0'; \
380 new = g_strconcat(tmp, tmpl.email, \
381 strstr(str, "$EMAIL")+strlen("$EMAIL"), \
388 if (strstr(str, "$NAME_MAIL")) { \
389 tmp = g_strdup(str); \
390 *strstr(tmp, "$NAME_MAIL") = '\0'; \
391 new = g_strconcat(tmp, get_name_for_mail(), \
392 strstr(str, "$NAME_MAIL")+strlen("$NAME_MAIL"), \
399 if (strstr(str, "$DEFAULTDOMAIN")) { \
400 tmp = g_strdup(str); \
401 *strstr(tmp, "$DEFAULTDOMAIN") = '\0'; \
402 new = g_strconcat(tmp, wizard_get_default_domain_name(), \
403 strstr(str, "$DEFAULTDOMAIN")+strlen("$DEFAULTDOMAIN"), \
410 if (strstr(str, "$DOMAIN")) { \
411 tmp = g_strdup(str); \
412 *strstr(tmp, "$DOMAIN") = '\0'; \
413 new = g_strconcat(tmp, tmpl.domain, \
414 strstr(str, "$DOMAIN")+strlen("$DOMAIN"), \
423 static void wizard_read_defaults(void)
427 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "accountrc.tmpl", NULL);
428 if (!is_file_exist(rcpath)) {
429 str_write_to_file(accountrc_tmpl, rcpath);
432 prefs_read_config(template_params, "AccountTemplate", rcpath, NULL);
434 PARSE_DEFAULT(tmpl.domain);
435 PARSE_DEFAULT(tmpl.name);
436 PARSE_DEFAULT(tmpl.email);
437 PARSE_DEFAULT(tmpl.organization);
438 PARSE_DEFAULT(tmpl.smtpserver);
439 PARSE_DEFAULT(tmpl.smtpuser);
440 PARSE_DEFAULT(tmpl.smtppass);
441 PARSE_DEFAULT(tmpl.recvserver);
442 PARSE_DEFAULT(tmpl.recvuser);
443 PARSE_DEFAULT(tmpl.recvpass);
444 PARSE_DEFAULT(tmpl.imapdir);
445 PARSE_DEFAULT(tmpl.mboxfile);
446 PARSE_DEFAULT(tmpl.mailbox);
449 "%s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %s, %s, %d, %d\n",
450 tmpl.name,tmpl.domain,tmpl.email,tmpl.organization,tmpl.smtpserver,
451 tmpl.recvtype,tmpl.recvserver,tmpl.recvuser,tmpl.recvpass,
452 tmpl.imapdir,tmpl.mboxfile,tmpl.mailbox,tmpl.smtpssl,tmpl.recvssl);
457 static void initialize_fonts(WizardWindow *wizard)
459 GtkWidget *widget = wizard->email;
460 gint size = pango_font_description_get_size(
461 widget->style->font_desc)
465 tmp = g_strdup(prefs_common.textfont);
466 if (strrchr(tmp, ' ')) {
467 *(strrchr(tmp, ' ')) = '\0';
468 new = g_strdup_printf("%s %d", tmp, size);
469 g_free(prefs_common.textfont);
470 prefs_common.textfont = new;
474 tmp = g_strdup(prefs_common.smallfont);
475 if (strrchr(tmp, ' ')) {
476 *(strrchr(tmp, ' ')) = '\0';
477 new = g_strdup_printf("%s %d", tmp, size);
478 g_free(prefs_common.smallfont);
479 prefs_common.smallfont = new;
483 tmp = g_strdup(prefs_common.normalfont);
484 if (strrchr(tmp, ' ')) {
485 *(strrchr(tmp, ' ')) = '\0';
486 new = g_strdup_printf("%s %d", tmp, size);
487 g_free(prefs_common.normalfont);
488 prefs_common.normalfont = new;
492 tmp = g_strdup(prefs_common.boldfont);
493 if (strrchr(tmp, ' ')) {
494 *(strrchr(tmp, ' ')) = '\0';
495 new = g_strdup_printf("%s %d", tmp, size);
496 g_free(prefs_common.boldfont);
497 prefs_common.boldfont = new;
502 #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"
503 #define FACE "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAM1BMVEUAAAAcJCI\n\
504 ONl1JUi0+Z4daY2NZciPabV9ykS5kj6Wsl2ybmZOBsMjZxK2wzN3Pzczs7OsCAGN0AAAAAXRSTlM\n\
505 AQObYZgAAAAFiS0dEAIgFHUgAAAIVSURBVEjH1ZbtlqMgDIaFECoGhPu/2s0b0Lais/NzN6d1OJ7\n\
506 3yReQzrL8B5Zy3rvl9At52Pf2tv1vSMjtYj8jaa8XUyI/yn3YD6sigj/2Tf5Bn069MIsTPHvx/t5\n\
507 /3rU/6JCIY3YwGe26r/cwUfE3cFe5T28L0K5rJAUHEeYAQxs8DHojjk3M9wECU4xxjXisI8RA0gy\n\
508 oczJZJOjxiTFZVTchAnIRJrgdmEGDyFfAI3UuG5FmYTkR9RDrIC4H0SqV4pzpEcUp0HNLjwBv+jA\n\
509 dikUE5g9iBvzmu3sH2oDk4lnHd829+2Q9gj6kDqDPg7hsGwBzH02fE3ZCt6ZHmlNKIMjMeRwra5I\n\
510 ecgNoBnLGPmzaHPJIwLY8Sq2M/tLUJfj0QcqmfVXAdLSStIYF8dzWjBBb2VgvDa4mO9oc651OiUo\n\
511 BEKbZokdPATF9E9oKAjQJcJOniaPXrVZRAnVWaqIyqRoNC8ZJvgCcW8XN39RqxVP1rS8Yd4WnCdN\n\
512 aRTo2jJRDbg3vtCpEUGffgDPhqKDaSuVqYtOplFIvIcx3HUI5/MuIWl6vKyBjNlqEru8hbFXqBPA\n\
513 5TpHGIUZOePeaIyzfQ/g9Xg0opU1AvdfXM9floYhv92pPAE96OZtkPV8eivgQi9RTfwPUU36I26n\n\
514 Hy+WuCJzAT7efMSeA1TNf2/VugDz+dN139xfA5ffxGZDD+MvcP/uvyB80wzZ76wbz8gAAAABJRU5\n\
517 static void write_welcome_email(WizardWindow *wizard)
523 const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name));
524 Folder *folder = folder_find_from_path(mailbox);
525 FolderItem *inbox = folder ? folder->inbox:NULL;
526 gchar *file = get_tmp_file();
527 gchar enc_from_name[BUFFSIZE], enc_to_name[BUFFSIZE], enc_subject[BUFFSIZE];
529 get_rfc822_date(buf_date, sizeof(buf_date));
531 conv_encode_header_full(enc_subject, sizeof(enc_subject),
532 Q_("Welcome Mail Subject|Welcome to Claws Mail"),
533 strlen("Subject: "), FALSE, CS_INTERNAL);
534 conv_encode_header_full(enc_to_name, sizeof(enc_to_name),
535 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)),
536 strlen("To: "), TRUE, CS_INTERNAL);
537 conv_encode_header_full(enc_from_name, sizeof(enc_from_name),
538 _("The Claws Mail Team"),
539 strlen("From: "), TRUE, CS_INTERNAL);
541 head = g_strdup_printf(
548 "Content-Type: text/plain; charset=UTF-8\n",
552 gtk_entry_get_text(GTK_ENTRY(wizard->email)),
553 buf_date, enc_subject, XFACE, FACE);
554 body = g_strdup_printf(
556 "Welcome to Claws Mail\n"
557 "---------------------\n"
559 "Now that you have set up your account you can fetch your\n"
560 "mail by clicking the 'Get Mail' button at the left of the\n"
563 "Claws Mail has lots of extra features accessible via plugins,\n"
564 "like anti-spam filtering and learning (via the Bogofilter or\n"
565 "SpamAssassin plugins), privacy protection (via PGP/Mime), an RSS\n"
566 "aggregator, a calendar, and much more. You can load them from\n"
567 "the menu entry '/Configuration/Plugins'.\n"
569 "You can change your Account Preferences by using the menu\n"
570 "entry '/Configuration/Preferences for current account'\n"
571 "and change the general Preferences by using\n"
572 "'/Configuration/Preferences'.\n"
574 "You can find further information in the Claws Mail manual,\n"
575 "which can be accessed by using the menu entry '/Help/Manual'\n"
576 "or online at the URL given below.\n"
584 "Mailing Lists: <%s>\n"
588 "Claws Mail is free software, released under the terms\n"
589 "of the GNU General Public License, version 3 or later, as\n"
590 "published by the Free Software Foundation, 51 Franklin Street,\n"
591 "Fifth Floor, Boston, MA 02110-1301, USA. The license can be\n"
596 "If you wish to donate to the Claws Mail project you can do\n"
598 HOMEPAGE_URI, MANUAL_URI, FAQ_URI, THEMES_URI, MAILING_LIST_URI,
599 GPL_URI, DONATE_URI);
601 msg = g_strconcat(head, body, NULL);
603 if (inbox && inbox->total_msgs == 0
604 && str_write_to_file(msg, file) >= 0) {
605 MsgFlags flags = { MSG_UNREAD|MSG_NEW, 0};
606 folder_item_add_msg(inbox, file, &flags, FALSE);
615 static gboolean wizard_write_config(WizardWindow *wizard)
617 static gboolean mailbox_ok = FALSE;
618 PrefsAccount *prefs_account = prefs_account_new();
619 GList *account_list = NULL;
620 gchar *smtp_server, *recv_server;
621 gint smtp_port, recv_port;
622 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
623 SSLType smtp_ssl_type, recv_ssl_type;
626 prefs_account->protocol = combobox_get_active_data(
627 GTK_COMBO_BOX(wizard->recv_type));
629 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4 &&
630 !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)))) {
631 alertpanel_error(_("Please enter the mailbox name."));
632 g_free(prefs_account);
633 gtk_notebook_set_current_page (
634 GTK_NOTEBOOK(wizard->notebook),
640 if (wizard->create_mailbox) {
641 g_free(prefs_common.data_root);
642 if (gtk_toggle_button_get_active(
643 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn)))
644 prefs_common.data_root = NULL;
645 else if (gtk_toggle_button_get_active(
646 GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn)))
647 prefs_common.data_root = g_strdup(MMC1_PATH);
648 else if (gtk_toggle_button_get_active(
649 GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn)))
650 prefs_common.data_root = g_strdup(MMC2_PATH);
655 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
656 mailbox_ok = setup_write_mailbox_path(wizard->mainwin,
658 GTK_ENTRY(wizard->mailbox_name)));
664 /* alertpanel done by setup_write_mailbox_path */
665 g_free(prefs_account);
666 gtk_notebook_set_current_page (
667 GTK_NOTEBOOK(wizard->notebook),
672 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->full_name)))
673 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->email)))) {
674 alertpanel_error(_("Please enter your name and email address."));
675 g_free(prefs_account);
676 gtk_notebook_set_current_page (
677 GTK_NOTEBOOK(wizard->notebook),
682 if (prefs_account->protocol != A_LOCAL) {
683 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)))
684 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
685 alertpanel_error(_("Please enter your receiving server "
687 g_free(prefs_account);
688 gtk_notebook_set_current_page (
689 GTK_NOTEBOOK(wizard->notebook),
694 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
695 alertpanel_error(_("Please enter your username."));
696 g_free(prefs_account);
697 gtk_notebook_set_current_page (
698 GTK_NOTEBOOK(wizard->notebook),
704 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)))) {
705 alertpanel_error(_("Please enter your SMTP server."));
706 g_free(prefs_account);
707 gtk_notebook_set_current_page (
708 GTK_NOTEBOOK(wizard->notebook),
713 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
714 if (prefs_account->protocol == A_LOCAL
715 && !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)))) {
716 alertpanel_error(_("Please enter your SMTP username."));
717 g_free(prefs_account);
718 gtk_notebook_set_current_page (
719 GTK_NOTEBOOK(wizard->notebook),
722 } /* if it's not local we'll use the reception server */
725 if (prefs_account->protocol != A_LOCAL)
726 prefs_account->account_name = g_strdup_printf("%s@%s",
727 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)),
728 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
730 prefs_account->account_name = g_strdup_printf("%s",
731 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
733 recv_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
734 smtp_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)));
736 if (prefs_account->protocol != A_LOCAL && strstr(recv_server, ":")) {
737 recv_port = atoi(strstr(recv_server, ":")+1);
738 *(strstr(recv_server, ":")) = '\0';
739 if (prefs_account->protocol == A_IMAP4) {
740 prefs_account->set_imapport = TRUE;
741 prefs_account->imapport = recv_port;
742 } else if (prefs_account->protocol == A_POP3) {
743 prefs_account->set_popport = TRUE;
744 prefs_account->popport = recv_port;
747 if (strstr(smtp_server, ":")) {
748 smtp_port = atoi(strstr(smtp_server, ":")+1);
749 *(strstr(smtp_server, ":")) = '\0';
750 prefs_account->set_smtpport = TRUE;
751 prefs_account->smtpport = smtp_port;
754 prefs_account->name = g_strdup(
755 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)));
756 prefs_account->address = g_strdup(
757 gtk_entry_get_text(GTK_ENTRY(wizard->email)));
758 prefs_account->organization = g_strdup(
759 gtk_entry_get_text(GTK_ENTRY(wizard->organization)));
760 prefs_account->smtp_server = g_strdup(smtp_server);
762 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
764 tmp = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
765 prefs_account->inbox = g_strdup_printf("#mh/%s/inbox",
766 (!strcmp("Mail", gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name))))
769 prefs_account->local_inbox = g_strdup(prefs_account->inbox);
770 } else if (prefs_account->protocol != A_IMAP4) {
771 if (folder_get_default_inbox())
772 prefs_account->local_inbox =
773 folder_item_get_identifier(folder_get_default_inbox());
776 if (prefs_account->protocol != A_LOCAL)
777 prefs_account->recv_server = g_strdup(recv_server);
779 prefs_account->local_mbox = g_strdup(recv_server);
784 prefs_account->userid = g_strdup(
785 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)));
786 prefs_account->passwd = g_strdup(
787 gtk_entry_get_text(GTK_ENTRY(wizard->recv_password)));
789 prefs_account->smtp_userid = g_strdup(
790 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)));
791 prefs_account->smtp_passwd = g_strdup(
792 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_password)));
793 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
794 prefs_account->use_smtp_auth = TRUE;
797 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
798 smtp_ssl_type = SSL_NONE;
799 recv_ssl_type = SSL_NONE;
801 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl))) {
802 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls)))
803 smtp_ssl_type = SSL_STARTTLS;
805 smtp_ssl_type = SSL_TUNNEL;
807 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl))) {
808 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls)))
809 recv_ssl_type = SSL_STARTTLS;
811 recv_ssl_type = SSL_TUNNEL;
814 prefs_account->ssl_smtp = smtp_ssl_type;
816 if (prefs_account->protocol == A_IMAP4)
817 prefs_account->ssl_imap = recv_ssl_type;
819 prefs_account->ssl_pop = recv_ssl_type;
821 prefs_account->out_ssl_client_cert_file = g_strdup(
822 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_ssl_cert_file)));
823 prefs_account->out_ssl_client_cert_pass = g_strdup(
824 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_ssl_cert_pass)));
825 prefs_account->in_ssl_client_cert_file = g_strdup(
826 gtk_entry_get_text(GTK_ENTRY(wizard->recv_ssl_cert_file)));
827 prefs_account->in_ssl_client_cert_pass = g_strdup(
828 gtk_entry_get_text(GTK_ENTRY(wizard->recv_ssl_cert_pass)));
830 if (prefs_account->protocol == A_IMAP4) {
831 gchar *directory = gtk_editable_get_chars(
832 GTK_EDITABLE(wizard->recv_imap_subdir), 0, -1);
833 if (directory && strlen(directory)) {
834 prefs_account->imap_dir = g_strdup(directory);
836 prefs_account->imap_subsonly =
837 gtk_toggle_button_get_active(
838 GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn));
842 account_list = g_list_append(account_list, prefs_account);
843 prefs_account_write_config_all(account_list);
844 prefs_account_free(prefs_account);
845 account_read_config_all();
847 initialize_fonts(wizard);
848 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
849 write_welcome_email(wizard);
852 if (wizard->volmon_mount_sigid)
853 g_signal_handler_disconnect(
854 G_OBJECT(wizard->volmon),
855 wizard->volmon_mount_sigid);
856 if (wizard->volmon_unmount_sigid)
857 g_signal_handler_disconnect(
858 G_OBJECT(wizard->volmon),
859 wizard->volmon_unmount_sigid);
863 plugin_load_standard_plugins();
868 static GtkWidget* create_page (WizardWindow *wizard, const char * title)
876 vbox = gtk_vbox_new (FALSE, 6);
877 gtk_container_set_border_width (GTK_CONTAINER(vbox), 10);
879 /* create the titlebar */
880 hbox = gtk_hbox_new (FALSE, 12);
881 image = stock_pixmap_widget(wizard->window,
882 STOCK_PIXMAP_CLAWS_MAIL_ICON);
883 gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 0);
884 title_string = g_strconcat ("<span size=\"xx-large\" weight=\"ultrabold\">", title ? title : "", "</span>", NULL);
885 w = gtk_label_new (title_string);
886 gtk_label_set_use_markup (GTK_LABEL(w), TRUE);
887 g_free (title_string);
888 gtk_box_pack_start (GTK_BOX(hbox), w, FALSE, FALSE, 0);
890 /* pack the titlebar */
891 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
893 /* pack the separator */
894 gtk_box_pack_start (GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
897 w = gtk_alignment_new (0, 0, 0, 0);
898 gtk_widget_set_size_request (w, 0, 6);
899 gtk_box_pack_start (GTK_BOX(vbox), w, FALSE, FALSE, 0);
904 #define PACK_BOX(hbox,text,entry) { \
905 GtkWidget *label = gtk_label_new(text); \
906 gtk_label_set_use_markup(GTK_LABEL(label), TRUE); \
907 if (GTK_IS_MISC(label)) \
908 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); \
909 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); \
910 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); \
913 static gchar *get_default_server(WizardWindow * wizard, const gchar *type)
915 if (!strcmp(type, "smtp")) {
916 if (!tmpl.smtpserver || !strlen(tmpl.smtpserver))
917 return g_strconcat(type, ".", tmpl.domain, NULL);
919 return g_strdup(tmpl.smtpserver);
921 if (!tmpl.recvserver || !strlen(tmpl.recvserver))
922 return g_strconcat(type, ".", tmpl.domain, NULL);
924 return g_strdup(tmpl.recvserver);
928 static gchar *get_default_account(WizardWindow * wizard)
930 gchar *result = NULL;
932 if (!tmpl.recvuser || !strlen(tmpl.recvuser)) {
933 result = gtk_editable_get_chars(
934 GTK_EDITABLE(wizard->email), 0, -1);
936 if (strstr(result, "@")) {
937 *(strstr(result,"@")) = '\0';
940 result = g_strdup(tmpl.recvuser);
945 static gchar *get_default_smtp_account(WizardWindow * wizard)
947 gchar *result = NULL;
949 if (!tmpl.smtpuser || !strlen(tmpl.smtpuser)) {
952 result = g_strdup(tmpl.smtpuser);
957 static void wizard_email_changed(GtkWidget *widget, gpointer data)
959 WizardWindow *wizard = (WizardWindow *)data;
960 RecvProtocol protocol;
962 protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
964 text = get_default_server(wizard, "smtp");
965 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
968 text = get_default_account(wizard);
969 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
972 if (protocol == A_POP3) {
973 text = get_default_server(wizard, "pop");
974 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
976 } else if (protocol == A_IMAP4) {
977 text = get_default_server(wizard, "imap");
978 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
980 } else if (protocol == A_LOCAL) {
981 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
986 static GtkWidget* user_page (WizardWindow * wizard)
988 GtkWidget *table = gtk_table_new(1,1, FALSE);
992 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
993 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
995 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
996 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
998 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
999 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1001 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1002 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1003 wizard->full_name = gtk_entry_new();
1004 gtk_entry_set_text(GTK_ENTRY(wizard->full_name), tmpl.name?tmpl.name:"");
1005 PACK_BOX(hbox, _("<span weight=\"bold\">Your name:</span>"),
1008 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1009 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1010 wizard->email = gtk_entry_new();
1011 gtk_entry_set_text(GTK_ENTRY(wizard->email), tmpl.email?tmpl.email:"");
1012 PACK_BOX(hbox, _("<span weight=\"bold\">Your email address:</span>"),
1015 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1016 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1017 wizard->organization = gtk_entry_new();
1018 gtk_entry_set_text(GTK_ENTRY(wizard->organization), tmpl.organization?tmpl.organization:"");
1019 PACK_BOX(hbox, _("Your organization:"), wizard->organization);
1021 g_signal_connect(G_OBJECT(wizard->email), "changed",
1022 G_CALLBACK(wizard_email_changed),
1028 static void wizard_vol_mount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
1030 gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
1031 gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1034 if(!strcmp(mount_path, MMC1_PATH)) {
1035 gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, TRUE);
1037 if(!strcmp(mount_path, MMC2_PATH)) {
1038 gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, TRUE);
1043 static void wizard_vol_unmount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
1045 gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
1046 gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1049 if(!strcmp(mount_path, MMC1_PATH)) {
1050 gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, FALSE);
1051 if (gtk_toggle_button_get_active(
1052 GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn))) {
1053 gtk_toggle_button_set_active(
1054 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn), TRUE);
1057 if(!strcmp(mount_path, MMC2_PATH)) {
1058 gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, FALSE);
1059 if (gtk_toggle_button_get_active(
1060 GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn))) {
1061 gtk_toggle_button_set_active(
1062 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn), TRUE);
1069 void data_root_changed (GtkToggleButton *toggle_btn,
1070 WizardWindow *wizard)
1072 gchar *name = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
1074 if (gtk_toggle_button_get_active(
1075 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn)))
1076 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), name);
1077 else if (gtk_toggle_button_get_active(
1078 GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn))) {
1079 path = g_strconcat(MMC1_PATH, G_DIR_SEPARATOR_S,
1080 "Claws", G_DIR_SEPARATOR_S,
1081 g_get_user_name(), G_DIR_SEPARATOR_S,
1083 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
1085 } else if (gtk_toggle_button_get_active(
1086 GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn))) {
1087 path = g_strconcat(MMC2_PATH, G_DIR_SEPARATOR_S,
1088 "Claws", G_DIR_SEPARATOR_S,
1089 g_get_user_name(), G_DIR_SEPARATOR_S,
1091 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
1098 static GtkWidget* mailbox_page (WizardWindow * wizard)
1100 GtkWidget *table = gtk_table_new(1,1, FALSE);
1104 gchar *uri, *mount_path;
1109 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1110 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1112 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1113 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1115 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1116 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1118 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1119 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1121 wizard->mailbox_label = gtk_label_new(_("<span weight=\"bold\">Mailbox name:</span>"));
1122 gtk_label_set_use_markup(GTK_LABEL(wizard->mailbox_label), TRUE);
1123 if (GTK_IS_MISC(wizard->mailbox_label))
1124 gtk_misc_set_alignment(GTK_MISC(wizard->mailbox_label), 1, 0.5);
1125 wizard->mailbox_name = gtk_entry_new();
1127 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), tmpl.mailbox?tmpl.mailbox:"");
1129 CLAWS_SET_TIP(wizard->mailbox_name, _("You can also specify an absolute path, for example: "
1130 "\"/home/john/Documents/Mail\""));
1132 gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_label, FALSE, FALSE, 0);
1133 gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_name, TRUE, TRUE, 0);
1136 wizard->data_root_nokia_radiobtn = gtk_radio_button_new_with_label(NULL,
1137 _("on internal memory"));
1138 wizard->data_root_mmc1_radiobtn = gtk_radio_button_new_with_label_from_widget(
1139 GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
1140 _("on external memory card"));
1141 wizard->data_root_mmc2_radiobtn = gtk_radio_button_new_with_label_from_widget(
1142 GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
1143 _("on internal memory card"));
1145 g_signal_connect(G_OBJECT(wizard->data_root_nokia_radiobtn), "toggled",
1146 G_CALLBACK(data_root_changed), wizard);
1147 g_signal_connect(G_OBJECT(wizard->data_root_mmc1_radiobtn), "toggled",
1148 G_CALLBACK(data_root_changed), wizard);
1149 g_signal_connect(G_OBJECT(wizard->data_root_mmc2_radiobtn), "toggled",
1150 G_CALLBACK(data_root_changed), wizard);
1152 wizard->volmon = gnome_vfs_get_volume_monitor();
1153 wizard->vol_mmc1 = gnome_vfs_volume_monitor_get_volume_for_path(wizard->volmon, MMC1_PATH);
1154 wizard->vol_mmc2 = gnome_vfs_volume_monitor_get_volume_for_path(wizard->volmon, MMC2_PATH);
1156 uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc1);
1157 mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1159 if (wizard->vol_mmc1 == NULL || !gnome_vfs_volume_is_mounted(wizard->vol_mmc1)
1160 || strcmp(mount_path, MMC1_PATH)) {
1161 gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, FALSE);
1165 uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc2);
1166 mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1168 if (wizard->vol_mmc2 == NULL || !gnome_vfs_volume_is_mounted(wizard->vol_mmc2)
1169 || strcmp(mount_path, MMC2_PATH)) {
1170 gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, FALSE);
1172 gtk_toggle_button_set_active(wizard->data_root_mmc2_radiobtn, TRUE);
1176 gnome_vfs_volume_unref(wizard->vol_mmc1);
1177 gnome_vfs_volume_unref(wizard->vol_mmc2);
1178 wizard->vol_mmc1 = NULL;
1179 wizard->vol_mmc2 = NULL;
1181 wizard->volmon_mount_sigid = g_signal_connect(G_OBJECT(wizard->volmon),
1182 "volume-mounted", G_CALLBACK(wizard_vol_mount_cb), wizard);
1183 wizard->volmon_unmount_sigid = g_signal_connect(G_OBJECT(wizard->volmon),
1184 "volume-unmounted", G_CALLBACK(wizard_vol_unmount_cb), wizard);
1186 vbox2 = gtk_vbox_new(FALSE, VSPACING_NARROW);
1187 gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_nokia_radiobtn, FALSE, FALSE, 0);
1188 gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_mmc1_radiobtn, FALSE, FALSE, 0);
1189 gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_mmc2_radiobtn, FALSE, FALSE, 0);
1191 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1192 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1193 PACK_BOX(hbox, _("<span weight=\"bold\">Store data</span>"),
1200 static void smtp_auth_changed (GtkWidget *btn, gpointer data)
1202 WizardWindow *wizard = (WizardWindow *)data;
1203 gboolean do_auth = gtk_toggle_button_get_active(
1204 GTK_TOGGLE_BUTTON(wizard->smtp_auth));
1205 gtk_widget_set_sensitive(wizard->smtp_username, do_auth);
1206 gtk_widget_set_sensitive(wizard->smtp_username_label, do_auth);
1207 gtk_widget_set_sensitive(wizard->smtp_password, do_auth);
1208 gtk_widget_set_sensitive(wizard->smtp_password_label, do_auth);
1211 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1212 static void cert_browse_cb(GtkWidget *widget, gpointer data)
1214 GtkEntry *dest = GTK_ENTRY(data);
1216 gchar *utf8_filename;
1218 filename = filesel_select_file_open(_("Select certificate file"), NULL);
1219 if (!filename) return;
1221 utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
1222 if (!utf8_filename) {
1223 g_warning("cert_browse_cb(): failed to convert character set.");
1224 utf8_filename = g_strdup(filename);
1226 gtk_entry_set_text(dest, utf8_filename);
1227 g_free(utf8_filename);
1231 static GtkWidget* smtp_page (WizardWindow * wizard)
1233 GtkWidget *table = gtk_table_new(1, 1, FALSE);
1238 GtkWidget *smtp_cert_table;
1242 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1243 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1245 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1246 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1248 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1249 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1251 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1252 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1253 wizard->smtp_server = gtk_entry_new();
1254 text = get_default_server(wizard, "smtp");
1255 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
1258 CLAWS_SET_TIP(wizard->smtp_server,
1259 _("You can specify the port number by appending it at the end: "
1260 "\"mail.example.com:25\""));
1262 PACK_BOX(hbox, _("<span weight=\"bold\">SMTP server address:</span>"),
1263 wizard->smtp_server);
1266 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1267 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1268 wizard->smtp_auth = gtk_check_button_new_with_label(
1269 _("Use authentication"));
1270 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth),
1272 g_signal_connect(G_OBJECT(wizard->smtp_auth), "toggled",
1273 G_CALLBACK(smtp_auth_changed),
1275 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_auth, FALSE, FALSE, 0);
1277 text = get_default_smtp_account(wizard);
1279 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1280 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1281 wizard->smtp_username = gtk_entry_new();
1282 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_username), text);
1284 wizard->smtp_username_label = gtk_label_new(_("SMTP username:\n"
1285 "<span size=\"small\">(empty to use the same as receive)</span>"));
1286 gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_username_label), TRUE);
1287 if (GTK_IS_MISC(wizard->smtp_username_label))
1288 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_username_label), 1, 0.5);
1289 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_username_label, FALSE, FALSE, 0);
1290 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_username, TRUE, TRUE, 0);
1292 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1293 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1294 wizard->smtp_password = gtk_entry_new();
1295 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_password), tmpl.smtppass?tmpl.smtppass:"");
1296 gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_password), FALSE);
1298 hildon_gtk_entry_set_input_mode(GTK_ENTRY(wizard->smtp_password),
1299 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
1301 wizard->smtp_password_label = gtk_label_new(_("SMTP password:\n"
1302 "<span size=\"small\">(empty to use the same as receive)</span>"));
1303 gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_password_label), TRUE);
1304 if (GTK_IS_MISC(wizard->smtp_password_label))
1305 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_password_label), 1, 0.5);
1306 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password_label, FALSE, FALSE, 0);
1307 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password, TRUE, TRUE, 0);
1308 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1309 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1310 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1311 wizard->smtp_use_ssl = gtk_check_button_new_with_label(
1312 _("Use SSL to connect to SMTP server"));
1313 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl),
1315 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_ssl, FALSE, FALSE, 0);
1317 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1318 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1319 wizard->smtp_use_tls = gtk_check_button_new_with_label(
1320 _("Use SSL via STARTTLS"));
1321 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls),
1323 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_tls, FALSE, FALSE, 0);
1324 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_use_tls);
1326 smtp_cert_table = gtk_table_new(3,3, FALSE);
1327 gtk_container_set_border_width(GTK_CONTAINER(smtp_cert_table), 8);
1328 gtk_box_pack_start (GTK_BOX(vbox), smtp_cert_table, FALSE, FALSE, 0);
1329 label = gtk_label_new(_("Client SSL certificate (optional)"));
1330 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1331 gtk_table_attach(GTK_TABLE(smtp_cert_table), label, 0, 3, 0, 1, GTK_FILL, 0, 0, 0);
1332 label = gtk_label_new(_("File"));
1333 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1334 gtk_table_attach(GTK_TABLE(smtp_cert_table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1335 wizard->smtp_ssl_cert_file = gtk_entry_new();
1336 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_file), tmpl.smtpssl_cert?tmpl.smtpssl_cert:"");
1337 gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_file, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1338 button = gtkut_get_browse_file_btn(_("Browse"));
1339 gtk_table_attach(GTK_TABLE(smtp_cert_table), button, 2, 3, 1, 2, GTK_FILL, 0, 0, 0);
1340 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, label);
1341 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_ssl_cert_file);
1342 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, button);
1343 g_signal_connect(G_OBJECT(button), "clicked",
1344 G_CALLBACK(cert_browse_cb), wizard->smtp_ssl_cert_file);
1346 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1347 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1348 label = gtk_label_new(_("Password"));
1349 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1350 gtk_table_attach(GTK_TABLE(smtp_cert_table), label, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
1351 wizard->smtp_ssl_cert_pass = gtk_entry_new();
1352 gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_ssl_cert_pass), FALSE);
1353 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_pass), tmpl.smtpssl_cert_pass?tmpl.smtpssl_cert_pass:"");
1354 gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_pass, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1355 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, label);
1356 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_ssl_cert_pass);
1357 wizard->smtp_cert_table = smtp_cert_table;
1359 smtp_auth_changed(NULL, wizard);
1363 static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
1367 if (protocol == A_POP3) {
1368 text = get_default_server(wizard, "pop");
1369 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1370 gtk_widget_hide(wizard->recv_imap_label);
1371 gtk_widget_hide(wizard->recv_imap_subdir);
1372 gtk_widget_hide(wizard->subsonly_checkbtn);
1373 gtk_widget_show(wizard->recv_username);
1374 gtk_widget_show(wizard->recv_password);
1375 gtk_widget_show(wizard->recv_username_label);
1376 gtk_widget_show(wizard->recv_password_label);
1377 gtk_widget_hide(wizard->no_imap_warning);
1378 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1379 gtk_widget_show(wizard->recv_use_ssl);
1380 gtk_widget_show(wizard->recv_use_tls);
1381 gtk_widget_show(wizard->recv_cert_table);
1383 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
1384 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1385 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1387 if (wizard->create_mailbox) {
1388 gtk_widget_show(wizard->mailbox_label);
1389 gtk_widget_show(wizard->mailbox_name);
1391 } else if (protocol == A_IMAP4) {
1392 #ifdef HAVE_LIBETPAN
1393 text = get_default_server(wizard, "imap");
1394 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1395 gtk_widget_show(wizard->recv_imap_label);
1396 gtk_widget_show(wizard->recv_imap_subdir);
1397 gtk_widget_show(wizard->subsonly_checkbtn);
1398 gtk_widget_show(wizard->recv_username);
1399 gtk_widget_show(wizard->recv_password);
1400 gtk_widget_show(wizard->recv_username_label);
1401 gtk_widget_show(wizard->recv_password_label);
1402 gtk_widget_hide(wizard->no_imap_warning);
1403 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1404 gtk_widget_show(wizard->recv_use_ssl);
1405 gtk_widget_show(wizard->recv_use_tls);
1406 gtk_widget_show(wizard->recv_cert_table);
1408 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
1409 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1410 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1412 if (wizard->create_mailbox) {
1413 gtk_widget_hide(wizard->mailbox_label);
1414 gtk_widget_hide(wizard->mailbox_name);
1417 gtk_widget_hide(wizard->recv_imap_label);
1418 gtk_widget_hide(wizard->recv_imap_subdir);
1419 gtk_widget_hide(wizard->subsonly_checkbtn);
1420 gtk_widget_hide(wizard->recv_username);
1421 gtk_widget_hide(wizard->recv_password);
1422 gtk_widget_hide(wizard->recv_username_label);
1423 gtk_widget_hide(wizard->recv_password_label);
1424 gtk_widget_show(wizard->no_imap_warning);
1425 if (wizard->create_mailbox) {
1426 gtk_widget_hide(wizard->mailbox_label);
1427 gtk_widget_hide(wizard->mailbox_name);
1429 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1430 gtk_widget_hide(wizard->recv_use_ssl);
1431 gtk_widget_hide(wizard->recv_use_tls);
1432 gtk_widget_hide(wizard->recv_cert_table);
1434 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, FALSE);
1436 } else if (protocol == A_LOCAL) {
1437 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
1438 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Local mailbox:</span>"));
1439 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1440 gtk_widget_hide(wizard->no_imap_warning);
1441 gtk_widget_hide(wizard->recv_imap_label);
1442 gtk_widget_hide(wizard->recv_imap_subdir);
1443 gtk_widget_hide(wizard->subsonly_checkbtn);
1444 gtk_widget_hide(wizard->recv_username);
1445 gtk_widget_hide(wizard->recv_password);
1446 gtk_widget_hide(wizard->recv_username_label);
1447 gtk_widget_hide(wizard->recv_password_label);
1448 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1449 gtk_widget_hide(wizard->recv_use_ssl);
1450 gtk_widget_hide(wizard->recv_use_tls);
1451 gtk_widget_hide(wizard->recv_cert_table);
1453 if (wizard->create_mailbox) {
1454 gtk_widget_show(wizard->mailbox_label);
1455 gtk_widget_show(wizard->mailbox_name);
1457 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1461 static void wizard_protocol_changed(GtkComboBox *combo, gpointer data)
1463 WizardWindow *wizard = (WizardWindow *)data;
1464 RecvProtocol protocol = combobox_get_active_data(combo);
1466 wizard_protocol_change(wizard, protocol);
1469 static GtkWidget* recv_page (WizardWindow * wizard)
1471 GtkWidget *table = gtk_table_new(1,1, FALSE);
1476 GtkWidget *recv_cert_table;
1477 GtkListStore *store;
1483 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1484 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1486 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1487 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1489 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1490 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1492 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1493 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1494 wizard->recv_type = gtkut_sc_combobox_create(NULL, FALSE);
1495 store = GTK_LIST_STORE(gtk_combo_box_get_model(
1496 GTK_COMBO_BOX(wizard->recv_type)));
1498 COMBOBOX_ADD(store, _("POP3"), A_POP3);
1499 COMBOBOX_ADD(store, _("IMAP"), A_IMAP4);
1500 COMBOBOX_ADD(store, _("Local mbox file"), A_LOCAL);
1502 switch(tmpl.recvtype) {
1515 gtk_combo_box_set_active(GTK_COMBO_BOX (wizard->recv_type), index);
1516 g_signal_connect(G_OBJECT(wizard->recv_type), "changed",
1517 G_CALLBACK(wizard_protocol_changed),
1519 PACK_BOX(hbox, _("<span weight=\"bold\">Server type:</span>"),
1522 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1523 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1524 wizard->recv_server = gtk_entry_new();
1525 text = get_default_server(wizard, "pop");
1526 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1529 CLAWS_SET_TIP(wizard->recv_server,
1530 _("You can specify the port number by appending it at the end: "
1531 "\"mail.example.com:110\""));
1533 wizard->recv_label = gtk_label_new(_("<span weight=\"bold\">Server address:</span>"));
1534 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1535 if (GTK_IS_MISC(wizard->recv_label))
1536 gtk_misc_set_alignment(GTK_MISC(wizard->recv_label), 1, 0.5);
1537 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_label, FALSE, FALSE, 0);
1538 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_server, TRUE, TRUE, 0);
1540 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1541 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1542 wizard->recv_username = gtk_entry_new();
1543 wizard->recv_username_label = gtk_label_new(_("<span weight=\"bold\">Username:</span>"));
1544 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_username_label), TRUE);
1545 if (GTK_IS_MISC(wizard->recv_username_label))
1546 gtk_misc_set_alignment(GTK_MISC(wizard->recv_username_label), 1, 0.5);
1547 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_username_label, FALSE, FALSE, 0);
1548 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_username, TRUE, TRUE, 0);
1550 text = get_default_account(wizard);
1551 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
1554 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1555 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1556 wizard->recv_password = gtk_entry_new();
1557 gtk_entry_set_text(GTK_ENTRY(wizard->recv_password), tmpl.recvpass?tmpl.recvpass:"");
1558 wizard->recv_password_label = gtk_label_new(_("Password:"));
1559 if (GTK_IS_MISC(wizard->recv_password_label))
1560 gtk_misc_set_alignment(GTK_MISC(wizard->recv_password_label), 1, 0.5);
1561 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_password), FALSE);
1563 hildon_gtk_entry_set_input_mode(GTK_ENTRY(wizard->recv_password),
1564 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
1566 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_password_label, FALSE, FALSE, 0);
1567 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_password, TRUE, TRUE, 0);
1569 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1570 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1571 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1572 wizard->recv_use_ssl = gtk_check_button_new_with_label(
1573 _("Use SSL to connect to receiving server"));
1574 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl),
1576 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_ssl, FALSE, FALSE, 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_tls = gtk_check_button_new_with_label(
1581 _("Use SSL via STARTTLS"));
1582 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls),
1584 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_tls, FALSE, FALSE, 0);
1585 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_use_tls);
1587 recv_cert_table = gtk_table_new(3,3, FALSE);
1588 gtk_container_set_border_width(GTK_CONTAINER(recv_cert_table), 8);
1589 gtk_box_pack_start (GTK_BOX(vbox), recv_cert_table, FALSE, FALSE, 0);
1590 label = gtk_label_new(_("Client SSL certificate (optional)"));
1591 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1592 gtk_table_attach(GTK_TABLE(recv_cert_table), label, 0, 3, 0, 1, GTK_FILL, 0, 0, 0);
1593 label = gtk_label_new(_("File"));
1594 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1595 gtk_table_attach(GTK_TABLE(recv_cert_table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1596 wizard->recv_ssl_cert_file = gtk_entry_new();
1597 gtk_entry_set_text(GTK_ENTRY(wizard->recv_ssl_cert_file), tmpl.recvssl_cert?tmpl.recvssl_cert:"");
1598 gtk_table_attach(GTK_TABLE(recv_cert_table), wizard->recv_ssl_cert_file, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1599 button = gtkut_get_browse_file_btn(_("Browse"));
1600 gtk_table_attach(GTK_TABLE(recv_cert_table), button, 2, 3, 1, 2, GTK_FILL, 0, 0, 0);
1601 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, label);
1602 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_ssl_cert_file);
1603 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, button);
1604 g_signal_connect(G_OBJECT(button), "clicked",
1605 G_CALLBACK(cert_browse_cb), wizard->recv_ssl_cert_file);
1607 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1608 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1609 label = gtk_label_new(_("Password"));
1610 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1611 gtk_table_attach(GTK_TABLE(recv_cert_table), label, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
1612 wizard->recv_ssl_cert_pass = gtk_entry_new();
1613 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_ssl_cert_pass), FALSE);
1614 gtk_entry_set_text(GTK_ENTRY(wizard->recv_ssl_cert_pass), tmpl.recvssl_cert_pass?tmpl.recvssl_cert_pass:"");
1615 gtk_table_attach(GTK_TABLE(recv_cert_table), wizard->recv_ssl_cert_pass, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1616 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, label);
1617 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_ssl_cert_pass);
1618 wizard->recv_cert_table = recv_cert_table;
1620 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1621 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1622 wizard->recv_imap_subdir = gtk_entry_new();
1623 gtk_entry_set_text(GTK_ENTRY(wizard->recv_imap_subdir), tmpl.imapdir?tmpl.imapdir:"");
1624 wizard->recv_imap_label = gtk_label_new(_("IMAP server directory:"));
1625 if (GTK_IS_MISC(wizard->recv_imap_label))
1626 gtk_misc_set_alignment(GTK_MISC(wizard->recv_imap_label), 1, 0.5);
1627 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_label, FALSE, FALSE, 0);
1628 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_subdir, TRUE, TRUE, 0);
1630 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1631 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1632 wizard->subsonly_checkbtn = gtk_check_button_new_with_label(
1633 _("Show only subscribed folders"));
1634 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn),
1636 gtk_box_pack_start(GTK_BOX(hbox), wizard->subsonly_checkbtn, FALSE, FALSE, 0);
1638 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1639 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1640 wizard->no_imap_warning = gtk_label_new(_(
1641 "<span weight=\"bold\">Warning: this version of Claws Mail\n"
1642 "has been built without IMAP support.</span>"));
1643 gtk_label_set_use_markup(GTK_LABEL(wizard->no_imap_warning), TRUE);
1644 gtk_box_pack_start(GTK_BOX(hbox), wizard->no_imap_warning, FALSE, FALSE, 0);
1650 wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
1652 WizardWindow * wizard = (WizardWindow *)data;
1653 int current_page, num_pages;
1654 gboolean skip_mailbox_page = FALSE;
1656 gint protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
1658 if (protocol == A_IMAP4) {
1659 skip_mailbox_page = TRUE;
1663 num_pages = g_slist_length(wizard->pages);
1665 current_page = gtk_notebook_get_current_page (
1666 GTK_NOTEBOOK(wizard->notebook));
1667 if (response == CANCEL)
1669 wizard->result = FALSE;
1670 wizard->finished = TRUE;
1671 gtk_widget_destroy (GTK_WIDGET(dialog));
1673 else if (response == FINISHED)
1675 if (!wizard_write_config(wizard)) {
1676 current_page = gtk_notebook_get_current_page (
1677 GTK_NOTEBOOK(wizard->notebook));
1680 wizard->result = TRUE;
1681 wizard->finished = TRUE;
1682 gtk_widget_destroy (GTK_WIDGET(dialog));
1686 if (response == GO_BACK)
1688 if (current_page > 0) {
1690 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1694 gtk_notebook_set_current_page (
1695 GTK_NOTEBOOK(wizard->notebook),
1699 else if (response == GO_FORWARD)
1701 if (current_page < (num_pages-1)) {
1703 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1707 gtk_notebook_set_current_page (
1708 GTK_NOTEBOOK(wizard->notebook),
1713 gtk_dialog_set_response_sensitive (dialog, GO_BACK,
1715 gtk_dialog_set_response_sensitive (dialog, GO_FORWARD,
1716 current_page < (num_pages - 1));
1717 if (current_page == (num_pages -1)) {
1718 gtk_dialog_set_response_sensitive (dialog, FINISHED, TRUE);
1719 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), FINISHED);
1721 gtk_dialog_set_response_sensitive (dialog, FINISHED, FALSE);
1722 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), GO_FORWARD);
1728 static gint wizard_close_cb(GtkWidget *widget, GdkEventAny *event,
1731 WizardWindow *wizard = (WizardWindow *)data;
1732 wizard->result = FALSE;
1733 wizard->finished = TRUE;
1738 #define PACK_WARNING(text) { \
1739 label = gtk_label_new(text); \
1740 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); \
1741 gtk_box_pack_end(GTK_BOX(widget), label, FALSE, FALSE, 0); \
1744 gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
1745 WizardWindow *wizard = g_new0(WizardWindow, 1);
1749 GtkWidget *scrolled_window;
1754 wizard->mainwin = mainwin;
1755 wizard->create_mailbox = create_mailbox;
1757 gtk_widget_hide(mainwin->window);
1759 wizard_read_defaults();
1761 wizard->window = gtk_dialog_new_with_buttons (_("Claws Mail Setup Wizard"),
1763 GTK_STOCK_GO_BACK, GO_BACK,
1764 GTK_STOCK_GO_FORWARD, GO_FORWARD,
1765 GTK_STOCK_SAVE, FINISHED,
1766 GTK_STOCK_CANCEL, CANCEL,
1768 gtk_widget_set_size_request(wizard->window, -1, 480);
1770 g_signal_connect(wizard->window, "response",
1771 G_CALLBACK(wizard_response_cb), wizard);
1772 gtk_widget_realize(wizard->window);
1773 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window),
1775 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1777 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1779 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1781 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1784 wizard->notebook = gtk_notebook_new();
1785 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(wizard->notebook), FALSE);
1786 gtk_notebook_set_show_border(GTK_NOTEBOOK(wizard->notebook), FALSE);
1787 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(wizard->window)->vbox),
1788 wizard->notebook, TRUE, TRUE, 0);
1790 wizard->pages = NULL;
1792 /*welcome page: 0 */
1794 page = create_page(wizard, _("Welcome to Claws Mail"));
1796 wizard->pages = g_slist_append(wizard->pages, page);
1797 widget = stock_pixmap_widget(wizard->window,
1798 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1800 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1802 text = g_strdup(_("Welcome to the Claws Mail setup wizard.\n\n"
1803 "We will begin by defining some basic "
1804 "information about you and your most common "
1805 "mail options so that you can start to use "
1806 "Claws Mail in less than five minutes."));
1807 widget = gtk_label_new(text);
1808 gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
1810 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1812 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1813 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1814 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1815 gtk_box_pack_start(GTK_BOX(page), scrolled_window, TRUE, TRUE, 0);
1817 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1825 widget = create_page (wizard, _("About You"));
1826 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1827 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1828 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1829 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1831 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1833 PACK_WARNING(_("Bold fields must be completed"));
1835 wizard->pages = g_slist_append(wizard->pages, widget);
1837 /* recv+auth page: 2 */
1840 widget = create_page (wizard, _("Receiving mail"));
1841 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1842 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1843 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1844 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1846 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1848 PACK_WARNING(_("Bold fields must be completed"));
1850 wizard->pages = g_slist_append(wizard->pages, widget);
1855 widget = create_page (wizard, _("Sending mail"));
1856 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1857 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1858 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1859 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1861 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1863 PACK_WARNING(_("Bold fields must be completed"));
1865 wizard->pages = g_slist_append(wizard->pages, widget);
1867 /* mailbox page: 4 */
1868 if (create_mailbox) {
1871 widget = create_page (wizard, _("Saving mail on disk"));
1872 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1873 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1874 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1875 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1877 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1878 mailbox_page(wizard));
1879 PACK_WARNING(_("Bold fields must be completed"));
1881 wizard->pages = g_slist_append(wizard->pages, widget);
1887 page = create_page(wizard, _("Configuration finished"));
1889 wizard->pages = g_slist_append(wizard->pages, page);
1890 widget = stock_pixmap_widget(wizard->window,
1891 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1893 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1895 text = g_strdup(_("Claws Mail is now ready.\n"
1896 "Click Save to start."));
1897 widget = gtk_label_new(text);
1898 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1902 for (cur = wizard->pages; cur && cur->data; cur = cur->next) {
1903 gtk_notebook_append_page (GTK_NOTEBOOK(wizard->notebook),
1904 GTK_WIDGET(cur->data), NULL);
1907 g_signal_connect(G_OBJECT(wizard->window), "delete_event",
1908 G_CALLBACK(wizard_close_cb), wizard);
1909 gtk_widget_show_all (wizard->window);
1911 gtk_widget_hide(wizard->recv_imap_label);
1912 gtk_widget_hide(wizard->recv_imap_subdir);
1913 gtk_widget_hide(wizard->subsonly_checkbtn);
1915 wizard_protocol_change(wizard, tmpl.recvtype);
1917 while (!wizard->finished)
1918 gtk_main_iteration();
1920 result = wizard->result;
1924 gtk_widget_show(mainwin->window);