2008-08-07 [mones] 3.5.0cvs53
[claws.git] / src / wizard.c
1 /*
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
5  *
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.
10  *
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.
15  *
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/>.
18  * 
19  */
20
21 #ifdef HAVE_CONFIG_H
22 #  include "config.h"
23 #endif
24
25 #include "defs.h"
26
27 #include <glib.h>
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>
39 #include <gtk/gtk.h>
40
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44 #include <ctype.h>
45
46 #ifdef HAVE_CONFIG_H
47 #  include "config.h"
48 #endif
49
50 #include "utils.h"
51 #include "gtk/menu.h"
52 #include "plugin.h"
53 #include "account.h"
54 #include "prefs_account.h"
55 #include "mainwindow.h"
56 #include "stock_pixmap.h"
57 #include "setup.h"
58 #include "folder.h"
59 #include "alertpanel.h"
60 #include "filesel.h"
61 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
62 #include "ssl.h"
63 #endif
64 #include "prefs_common.h"
65 #include "combobox.h"
66
67 #ifdef MAEMO
68 #include <libgnomevfs/gnome-vfs-volume.h>
69 #include <libgnomevfs/gnome-vfs-volume-monitor.h>
70 #include <libgnomevfs/gnome-vfs-utils.h>
71 #endif
72
73 typedef enum
74 {
75         GO_BACK,
76         GO_FORWARD,
77         CANCEL,
78         FINISHED
79 } PageNavigation;
80
81 int WELCOME_PAGE = -1;
82 int USER_PAGE = -1;
83 int SMTP_PAGE = -1;
84 int RECV_PAGE = -1;
85 int MAILBOX_PAGE = -1;
86 int DONE_PAGE = -1;
87
88 typedef struct
89 {
90         GtkWidget *window;
91         GSList    *pages;
92         GtkWidget *notebook;
93
94         MainWindow *mainwin;
95         
96         GtkWidget *email;
97         GtkWidget *full_name;
98         GtkWidget *organization;
99
100         GtkWidget *mailbox_name;
101         GtkWidget *mailbox_label;
102         
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;
109
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;
132 #endif
133
134 #ifdef MAEMO
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;
143 #endif  
144         gboolean create_mailbox;
145         gboolean finished;
146         gboolean result;
147
148 } WizardWindow;
149
150 typedef struct _AccountTemplate {
151         gchar *name;
152         gchar *domain;
153         gchar *email;
154         gchar *organization;
155         gchar *smtpserver;
156         gboolean smtpauth;
157         gchar *smtpuser;
158         gchar *smtppass;
159         RecvProtocol recvtype;
160         gchar *recvserver;
161         gchar *recvuser;
162         gchar *recvpass;
163         gchar *imapdir;
164         gboolean subsonly;
165         gchar *mboxfile;
166         gchar *mailbox;
167         gboolean smtpssl;
168         gboolean recvssl;
169         gchar *smtpssl_cert;
170         gchar *recvssl_cert;
171         gchar *smtpssl_cert_pass;
172         gchar *recvssl_cert_pass;
173 } AccountTemplate;
174
175 static AccountTemplate tmpl;
176
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},
184         {"organization", "",
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},
190         {"smtpuser", "",
191          &tmpl.smtpuser, P_STRING, NULL, NULL, NULL},
192         {"smtppass", "",
193          &tmpl.smtppass, P_STRING, NULL, NULL, NULL},
194         {"recvtype", A_POP3,
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},
200         {"recvpass", "",
201          &tmpl.recvpass, P_STRING, NULL, NULL, NULL},
202         {"imapdir", "",
203          &tmpl.imapdir, P_STRING, NULL, NULL, NULL},
204         {"subsonly", "TRUE",
205          &tmpl.subsonly, P_BOOL, NULL, NULL, NULL},
206         {"mboxfile", "/var/mail/$LOGIN",
207          &tmpl.mboxfile, P_STRING, NULL, NULL, NULL},
208         {"mailbox", "Mail",
209          &tmpl.mailbox, P_STRING, NULL, NULL, NULL},
210         {"smtpssl", "0",
211          &tmpl.smtpssl, P_INT, NULL, NULL, NULL},
212         {"recvssl", "0",
213          &tmpl.recvssl, P_INT, NULL, NULL, NULL},
214         {"smtpssl_cert", "",
215          &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
216         {"recvssl_cert", "",
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}
223 };
224
225
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"
231         "#domain=\n"
232         "\n"
233         "#you can use $USERNAME for name (this is the default)\n"
234         "#name=\n"
235         "\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"
238         "#of spaces\n"
239         "#the default is $NAME_MAIL@$DOMAIN\n"
240         "#email=\n"
241         "\n"
242         "#you can use $DOMAIN here\n"
243         "#the default organization is empty\n"
244         "#organization=\n"
245         "\n"
246         "#you can use $DOMAIN here \n"
247         "#the default is smtp.$DOMAIN\n"
248         "#smtpserver=\n"
249         "\n"
250         "#Whether to use smtp authentication\n"
251         "#the default is 0 (no)\n"
252         "#smtpauth=\n"
253         "\n"
254         "#SMTP username\n"
255         "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
256         "#the default is empty (same as reception username)\n"
257         "#smtpuser=\n"
258         "\n"
259         "#SMTP password\n"
260         "#the default is empty (same as reception password)\n"
261         "#smtppass=\n"
262         "\n"
263         "#recvtype can be:\n"
264         "#0 for pop3\n"
265         "#3  for imap\n"
266         "#5  for a local mbox file\n"
267         "#recvtype=\n"
268         "\n"
269         "#you can use $DOMAIN here \n"
270         "#the default is {pop,imap}.$DOMAIN\n"
271         "#recvserver=\n"
272         "\n"
273         "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
274         "#default is $LOGIN\n"
275         "#recvuser=\n"
276         "\n"
277         "#default is empty\n"
278         "#recvpass=\n"
279         "\n"
280         "#imap dir if imap (relative to the home on the server)\n"
281         "#default is empty\n"
282         "#imapdir=\n"
283         "\n"
284         "#show subscribed folders only, if imap\n"
285         "#default is TRUE\n"
286         "#subsonly=\n"
287         "\n"
288         "#mbox file if local\n"
289         "#you can use $LOGIN here\n"
290         "#default is /var/mail/$LOGIN\n"
291         "#mboxfile=\n"
292         "\n"
293         "#mailbox name if pop3 or local\n"
294         "#relative path from the user's home\n"
295         "#default is \"Mail\"\n"
296         "#mailbox=\n"
297         "\n"
298         "#whether to use ssl on smtp connections\n"
299         "#default is 0, 1 is ssl, 2 is starttls\n"
300         "#smtpssl=\n"
301         "\n"
302         "#whether to use ssl on pop or imap connections\n"
303         "#default is 0, 1 is ssl, 2 is starttls\n"
304         "#recvssl=\n"
305         "\n"
306         "#SSL client certificate path for SMTP\n"
307         "#default is empty (no certificate)\n"
308         "#smtpssl_cert=\n"
309         "\n"
310         "#SSL client certificate path for POP/IMAP\n"
311         "#default is empty (no certificate)\n"
312         "#recvssl_cert=\n"
313         "\n"
314         "#SSL client certificate password for SMTP\n"
315         "#default is empty (no password)\n"
316         "#smtpssl_cert_pass=\n"
317         "\n"
318         "#SSL client certificate password for POP/IMAP\n"
319         "#default is empty (no password)\n"
320         "#recvssl_cert_pass=\n"
321         ;
322
323 static gchar *wizard_get_default_domain_name(void)
324 {
325         static gchar *domain_name = NULL;
326         
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);
332                         g_free(domain_name);
333                         domain_name = tmp;
334                 }
335         }
336         return domain_name;
337 }
338
339 static gchar *get_name_for_mail(void)
340 {
341         gchar *name = NULL;
342         if (tmpl.name == NULL)
343                 return NULL;
344         name = g_utf8_strdown(tmpl.name, -1);
345         while(strstr(name, " "))
346                 *strstr(name, " ")='.';
347         
348         return name;
349 }
350
351 #define PARSE_DEFAULT(str) {    \
352         gchar *tmp = NULL, *new = NULL; \
353         if (str != 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"),   \
360                                 NULL);  \
361                         g_free(tmp);    \
362                         g_free(str);    \
363                         str = new;      \
364                         new = NULL;     \
365                 }       \
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"),         \
371                                 NULL);  \
372                         g_free(tmp);    \
373                         g_free(str);    \
374                         str = new;      \
375                         new = NULL;     \
376                 }       \
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"),         \
382                                 NULL);  \
383                         g_free(tmp);    \
384                         g_free(str);    \
385                         str = new;      \
386                         new = NULL;     \
387                 }       \
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"),         \
393                                 NULL);  \
394                         g_free(tmp);    \
395                         g_free(str);    \
396                         str = new;      \
397                         new = NULL;     \
398                 }       \
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"),         \
404                                 NULL);  \
405                         g_free(tmp);    \
406                         g_free(str);    \
407                         str = new;      \
408                         new = NULL;     \
409                 }       \
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"),       \
415                                 NULL);  \
416                         g_free(tmp);    \
417                         g_free(str);    \
418                         str = new;      \
419                         new = NULL;     \
420                 }       \
421         }       \
422 }
423 static void wizard_read_defaults(void)
424 {
425         gchar *rcpath;
426
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);
430         }
431
432         prefs_read_config(template_params, "AccountTemplate", rcpath, NULL);
433
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);
447 /*
448         g_print("defaults:"
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);
453 */
454         g_free(rcpath);
455 }
456
457 static void initialize_fonts(WizardWindow *wizard)
458 {
459         GtkWidget *widget = wizard->email;
460         gint size = pango_font_description_get_size(
461                         widget->style->font_desc)
462                       /PANGO_SCALE;
463         gchar *tmp, *new;
464         
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;
471         }
472         g_free(tmp);
473         
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;
480         }
481         g_free(tmp);
482         
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;
489         }
490         g_free(tmp);
491
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;
498         }
499         g_free(tmp);
500 }
501
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\
515  ErkJggg=="
516
517 static void write_welcome_email(WizardWindow *wizard)
518 {
519         gchar buf_date[64];
520         gchar *head=NULL;
521         gchar *body=NULL;
522         gchar *msg=NULL;
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];
528         
529         get_rfc822_date(buf_date, sizeof(buf_date));
530
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);
540
541         head = g_strdup_printf(
542                 "From: %s <%s>\n"
543                 "To: %s <%s>\n"
544                 "Date: %s\n"
545                 "Subject: %s\n"
546                 "X-Face: %s\n"
547                 "Face: %s\n"
548                 "Content-Type: text/plain; charset=UTF-8\n",
549                 enc_from_name,
550                 USERS_ML_ADDR,
551                 enc_to_name,
552                 gtk_entry_get_text(GTK_ENTRY(wizard->email)),
553                 buf_date, enc_subject, XFACE, FACE);
554         body = g_strdup_printf(
555                 _("\n"
556                 "Welcome to Claws Mail\n"
557                 "---------------------\n"
558                 "\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"
561                 "toolbar.\n"
562                 "\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"
568                 "\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"
573                 "\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"
577                 "\n"
578                 "Useful URLs\n"
579                 "-----------\n"
580                 "Homepage:      <%s>\n"
581                 "Manual:        <%s>\n"
582                 "FAQ:          <%s>\n"
583                 "Themes:        <%s>\n"
584                 "Mailing Lists: <%s>\n"
585                 "\n"
586                 "LICENSE\n"
587                 "-------\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"
592                 "found at <%s>.\n"
593                 "\n"
594                 "DONATIONS\n"
595                 "---------\n"
596                 "If you wish to donate to the Claws Mail project you can do\n"
597                 "so at <%s>.\n\n"),
598                 HOMEPAGE_URI, MANUAL_URI, FAQ_URI, THEMES_URI, MAILING_LIST_URI,
599                 GPL_URI, DONATE_URI);
600         
601         msg = g_strconcat(head, body, NULL);
602
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);
607         }
608         g_free(head);
609         g_free(body);
610         g_free(msg);
611         claws_unlink(file);
612 }
613 #undef XFACE
614
615 static gboolean wizard_write_config(WizardWindow *wizard)
616 {
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;
624 #endif
625
626         prefs_account->protocol = combobox_get_active_data(
627                                         GTK_COMBO_BOX(wizard->recv_type));
628         
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), 
635                         MAILBOX_PAGE);
636                 return FALSE;
637         }
638
639 #ifdef MAEMO
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);
651         }
652 #endif
653
654         if (!mailbox_ok) {
655                 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
656                         mailbox_ok = setup_write_mailbox_path(wizard->mainwin, 
657                                         gtk_entry_get_text(
658                                                 GTK_ENTRY(wizard->mailbox_name)));
659                 } else
660                         mailbox_ok = TRUE;
661         }
662
663         if (!mailbox_ok) {
664                 /* alertpanel done by setup_write_mailbox_path */
665                 g_free(prefs_account);
666                 gtk_notebook_set_current_page (
667                         GTK_NOTEBOOK(wizard->notebook), 
668                         MAILBOX_PAGE);
669                 return FALSE;
670         }
671         
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), 
678                         USER_PAGE);
679                 return FALSE;
680         }
681         
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 "
686                                            "and username."));
687                         g_free(prefs_account);
688                         gtk_notebook_set_current_page (
689                                 GTK_NOTEBOOK(wizard->notebook), 
690                                 RECV_PAGE);
691                         return FALSE;
692                 }
693         } else {
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), 
699                                 RECV_PAGE);
700                         return FALSE;
701                 }
702         }
703         
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), 
709                         SMTP_PAGE);
710                 return FALSE;
711         }
712
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), 
720                                 SMTP_PAGE);
721                         return FALSE;           
722                 } /* if it's not local we'll use the reception server */
723         }
724
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)));
729         else
730                 prefs_account->account_name = g_strdup_printf("%s",
731                                 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
732
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)));
735
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;
745                 }
746         }
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;
752         }
753         
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);
761
762         if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
763                 gchar *tmp;
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))))
767                                 ?_("Mailbox"):tmp);
768                 g_free(tmp);
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());
774         }
775
776         if (prefs_account->protocol != A_LOCAL)
777                 prefs_account->recv_server = g_strdup(recv_server);
778         else
779                 prefs_account->local_mbox = g_strdup(recv_server);
780
781         g_free(recv_server);
782         g_free(smtp_server);
783
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)));
788
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;
795         }
796
797 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
798         smtp_ssl_type = SSL_NONE;
799         recv_ssl_type = SSL_NONE;       
800
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;
804                 else
805                         smtp_ssl_type = SSL_TUNNEL;
806         }
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;
810                 else
811                         recv_ssl_type = SSL_TUNNEL;
812         }
813
814         prefs_account->ssl_smtp = smtp_ssl_type;
815
816         if (prefs_account->protocol == A_IMAP4)
817                 prefs_account->ssl_imap = recv_ssl_type;
818         else
819                 prefs_account->ssl_pop = recv_ssl_type;
820
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)));
829 #endif
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);
835                 }
836                 prefs_account->imap_subsonly = 
837                         gtk_toggle_button_get_active(
838                                 GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn));
839                 g_free(directory);
840         }
841
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();
846
847         initialize_fonts(wizard);
848         if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
849                 write_welcome_email(wizard);
850
851 #ifdef MAEMO
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);
860 #endif
861
862 #ifndef G_OS_WIN32 
863         plugin_load_standard_plugins();
864 #endif
865         return TRUE;
866 }
867
868 static GtkWidget* create_page (WizardWindow *wizard, const char * title)
869 {
870         GtkWidget *w;
871         GtkWidget *vbox;
872         GtkWidget *hbox;
873         GtkWidget *image;
874         char *title_string;
875
876         vbox = gtk_vbox_new (FALSE, 6);
877         gtk_container_set_border_width  (GTK_CONTAINER(vbox), 10);
878
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);
889
890         /* pack the titlebar */
891         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
892
893         /* pack the separator */
894         gtk_box_pack_start (GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
895
896         /* pack space */
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);
900
901         return vbox;
902 }
903
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);        \
911 }
912
913 static gchar *get_default_server(WizardWindow * wizard, const gchar *type)
914 {
915         if (!strcmp(type, "smtp")) {
916                 if (!tmpl.smtpserver || !strlen(tmpl.smtpserver))
917                         return g_strconcat(type, ".", tmpl.domain, NULL);
918                 else 
919                         return g_strdup(tmpl.smtpserver);
920         } else {
921                 if (!tmpl.recvserver || !strlen(tmpl.recvserver))
922                         return g_strconcat(type, ".", tmpl.domain, NULL);
923                 else 
924                         return g_strdup(tmpl.recvserver);
925         }
926 }
927
928 static gchar *get_default_account(WizardWindow * wizard)
929 {
930         gchar *result = NULL;
931         
932         if (!tmpl.recvuser || !strlen(tmpl.recvuser)) {
933                 result = gtk_editable_get_chars(
934                                 GTK_EDITABLE(wizard->email), 0, -1);
935
936                 if (strstr(result, "@")) {
937                         *(strstr(result,"@")) = '\0';
938                 } 
939         } else {
940                 result = g_strdup(tmpl.recvuser);
941         }
942         return result;
943 }
944
945 static gchar *get_default_smtp_account(WizardWindow * wizard)
946 {
947         gchar *result = NULL;
948         
949         if (!tmpl.smtpuser || !strlen(tmpl.smtpuser)) {
950                 return g_strdup("");
951         } else {
952                 result = g_strdup(tmpl.smtpuser);
953         }
954         return result;
955 }
956
957 static void wizard_email_changed(GtkWidget *widget, gpointer data)
958 {
959         WizardWindow *wizard = (WizardWindow *)data;
960         RecvProtocol protocol;
961         gchar *text;
962         protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
963         
964         text = get_default_server(wizard, "smtp");
965         gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
966         g_free(text);
967
968         text = get_default_account(wizard);
969         gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
970         g_free(text);
971
972         if (protocol == A_POP3) {
973                 text = get_default_server(wizard, "pop");
974                 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
975                 g_free(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);
979                 g_free(text);
980         } else if (protocol == A_LOCAL) {
981                 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
982         }
983         
984 }
985
986 static GtkWidget* user_page (WizardWindow * wizard)
987 {
988         GtkWidget *table = gtk_table_new(1,1, FALSE);
989         GtkWidget *vbox;
990         GtkWidget *hbox;
991         
992         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
993         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
994
995         vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
996         gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
997
998         gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
999                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
1000
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>"),
1006                  wizard->full_name);
1007         
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>"),
1013                  wizard->email);
1014         
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);
1020         
1021         g_signal_connect(G_OBJECT(wizard->email), "changed",
1022                          G_CALLBACK(wizard_email_changed),
1023                          wizard);
1024         return table;
1025 }
1026
1027 #ifdef MAEMO
1028 static void wizard_vol_mount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
1029 {
1030         gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
1031         gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1032         g_free (uri);
1033         if (mount_path) {
1034                 if(!strcmp(mount_path, MMC1_PATH)) {
1035                         gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, TRUE);
1036                 }
1037                 if(!strcmp(mount_path, MMC2_PATH)) {
1038                         gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, TRUE);
1039                 }
1040         }
1041         g_free(mount_path);
1042 }
1043 static void wizard_vol_unmount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
1044 {
1045         gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
1046         gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1047         g_free (uri);
1048         if (mount_path) {
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);
1055                         }
1056                 }
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);
1063                         }
1064                 }
1065         }
1066         g_free(mount_path);
1067 }
1068
1069 void data_root_changed          (GtkToggleButton        *toggle_btn,
1070                                  WizardWindow *wizard)
1071 {
1072         gchar *name = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
1073         gchar *path = NULL;
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,
1082                                   name, NULL);
1083                 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
1084                 g_free(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,
1090                                   name, NULL);
1091                 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
1092                 g_free(path);
1093         }
1094         g_free(name);
1095 }
1096 #endif
1097
1098 static GtkWidget* mailbox_page (WizardWindow * wizard)
1099 {
1100         GtkWidget *table = gtk_table_new(1,1, FALSE);
1101         GtkWidget *vbox;
1102 #ifdef MAEMO
1103         GtkWidget *vbox2;
1104         gchar *uri, *mount_path;
1105 #endif
1106         GtkWidget *hbox;
1107         CLAWS_TIP_DECL();
1108
1109         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1110         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1111
1112         vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1113         gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1114
1115         gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
1116                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
1117
1118         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1119         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1120
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();
1126
1127         gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), tmpl.mailbox?tmpl.mailbox:"");
1128
1129         CLAWS_SET_TIP(wizard->mailbox_name, _("You can also specify an absolute path, for example: "
1130                                "\"/home/john/Documents/Mail\""));
1131
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);
1134
1135 #ifdef MAEMO
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"));
1144                 
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);
1151
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);
1155
1156         uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc1);
1157         mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1158         g_free(uri);
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);
1162         }
1163         g_free(mount_path);
1164
1165         uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc2);
1166         mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1167         g_free(uri);
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);
1171         } else {
1172                 gtk_toggle_button_set_active(wizard->data_root_mmc2_radiobtn, TRUE);
1173         }
1174         g_free(mount_path);
1175         
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;
1180
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);
1185
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);
1190
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>"),
1194                  vbox2);
1195 #endif
1196
1197         return table;
1198 }
1199
1200 static void smtp_auth_changed (GtkWidget *btn, gpointer data)
1201 {
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);
1209 }
1210
1211 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1212 static void cert_browse_cb(GtkWidget *widget, gpointer data)
1213 {
1214         GtkEntry *dest = GTK_ENTRY(data);
1215         gchar *filename;
1216         gchar *utf8_filename;
1217
1218         filename = filesel_select_file_open(_("Select certificate file"), NULL);
1219         if (!filename) return;
1220
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);
1225         }
1226         gtk_entry_set_text(dest, utf8_filename);
1227         g_free(utf8_filename);
1228 }
1229 #endif
1230
1231 static GtkWidget* smtp_page (WizardWindow * wizard)
1232 {
1233         GtkWidget *table = gtk_table_new(1, 1, FALSE);
1234         GtkWidget *vbox;
1235         GtkWidget *hbox;
1236         GtkWidget *label;
1237         GtkWidget *button;
1238         GtkWidget *smtp_cert_table;
1239         gchar *text;
1240         CLAWS_TIP_DECL();
1241         
1242         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1243         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1244
1245         vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1246         gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1247
1248         gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
1249                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
1250
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);
1256         g_free(text);
1257
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\""));
1261
1262         PACK_BOX(hbox, _("<span weight=\"bold\">SMTP server address:</span>"),
1263                  wizard->smtp_server);
1264
1265
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),
1271                         tmpl.smtpauth);
1272         g_signal_connect(G_OBJECT(wizard->smtp_auth), "toggled",
1273                          G_CALLBACK(smtp_auth_changed),
1274                          wizard);
1275         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_auth, FALSE, FALSE, 0);
1276
1277         text = get_default_smtp_account(wizard);
1278
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);
1283         g_free(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);
1291
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);
1297 #ifdef MAEMO
1298         hildon_gtk_entry_set_input_mode(GTK_ENTRY(wizard->smtp_password), 
1299                 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
1300 #endif
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),
1314                         tmpl.smtpssl != 0);
1315         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_ssl, FALSE, FALSE, 0);
1316
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),
1322                         tmpl.smtpssl == 2);
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);
1325         
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);
1345
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;
1358 #endif
1359         smtp_auth_changed(NULL, wizard);
1360         return table;
1361 }
1362
1363 static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
1364 {
1365         gchar *text;
1366         
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);
1382 #endif
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);
1386                 g_free(text);
1387                 if (wizard->create_mailbox) {
1388                         gtk_widget_show(wizard->mailbox_label);
1389                         gtk_widget_show(wizard->mailbox_name);
1390                 }
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);
1407 #endif
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);
1411                 g_free(text);
1412                 if (wizard->create_mailbox) {
1413                         gtk_widget_hide(wizard->mailbox_label);
1414                         gtk_widget_hide(wizard->mailbox_name);
1415                 }
1416 #else
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);
1428                 }
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);
1433 #endif
1434                 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, FALSE);
1435 #endif
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);
1452 #endif
1453                 if (wizard->create_mailbox) {
1454                         gtk_widget_show(wizard->mailbox_label);
1455                         gtk_widget_show(wizard->mailbox_name);
1456                 }
1457                 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1458         }
1459 }
1460
1461 static void wizard_protocol_changed(GtkComboBox *combo, gpointer data)
1462 {
1463         WizardWindow *wizard = (WizardWindow *)data;
1464         RecvProtocol protocol = combobox_get_active_data(combo);
1465
1466         wizard_protocol_change(wizard, protocol);       
1467 }
1468
1469 static GtkWidget* recv_page (WizardWindow * wizard)
1470 {
1471         GtkWidget *table = gtk_table_new(1,1, FALSE);
1472         GtkWidget *vbox;
1473         GtkWidget *hbox;
1474         GtkWidget *label;
1475         GtkWidget *button;
1476         GtkWidget *recv_cert_table;
1477         GtkListStore *store;
1478         GtkTreeIter iter;
1479         gchar *text;
1480         gint index = 0;
1481         CLAWS_TIP_DECL();
1482
1483         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1484         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1485
1486         vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1487         gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1488
1489         gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
1490                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
1491
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)));
1497
1498         COMBOBOX_ADD(store, _("POP3"), A_POP3);
1499         COMBOBOX_ADD(store, _("IMAP"), A_IMAP4);
1500         COMBOBOX_ADD(store, _("Local mbox file"), A_LOCAL);
1501
1502         switch(tmpl.recvtype) {
1503         case A_POP3: 
1504                 index = 0;
1505                 break;
1506         case A_IMAP4:
1507                 index = 1;
1508                 break;
1509         case A_LOCAL:
1510                 index = 2;
1511                 break;
1512         default:
1513                 index = 0;
1514         }
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),
1518                          wizard);
1519         PACK_BOX(hbox, _("<span weight=\"bold\">Server type:</span>"),
1520                  wizard->recv_type);
1521
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);
1527         g_free(text);
1528         
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\""));
1532
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);
1539         
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);
1549         
1550         text = get_default_account(wizard);
1551         gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
1552         g_free(text);
1553
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);
1562 #ifdef MAEMO
1563         hildon_gtk_entry_set_input_mode(GTK_ENTRY(wizard->recv_password), 
1564                 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
1565 #endif
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);
1568         
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),
1575                         tmpl.recvssl != 0);
1576         gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_ssl, FALSE, FALSE, 0);
1577
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),
1583                         tmpl.recvssl == 2);
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);
1586
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);
1606
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;
1619 #endif  
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);
1629         
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),
1635                         tmpl.subsonly);
1636         gtk_box_pack_start(GTK_BOX(hbox), wizard->subsonly_checkbtn, FALSE, FALSE, 0);
1637         
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);
1645
1646         return table;
1647 }
1648
1649 static void
1650 wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
1651 {
1652         WizardWindow * wizard = (WizardWindow *)data;
1653         int current_page, num_pages;
1654         gboolean skip_mailbox_page = FALSE;
1655 #ifndef MAEMO
1656         gint protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
1657
1658         if (protocol == A_IMAP4) {
1659                 skip_mailbox_page = TRUE;
1660         }
1661 #endif
1662
1663         num_pages = g_slist_length(wizard->pages);
1664
1665         current_page = gtk_notebook_get_current_page (
1666                                 GTK_NOTEBOOK(wizard->notebook));
1667         if (response == CANCEL)
1668         {
1669                 wizard->result = FALSE;
1670                 wizard->finished = TRUE;
1671                 gtk_widget_destroy (GTK_WIDGET(dialog));
1672         }
1673         else if (response == FINISHED)
1674         {
1675                 if (!wizard_write_config(wizard)) {
1676                         current_page = gtk_notebook_get_current_page (
1677                                         GTK_NOTEBOOK(wizard->notebook));
1678                         goto set_sens;
1679                 }
1680                 wizard->result = TRUE;
1681                 wizard->finished = TRUE;
1682                 gtk_widget_destroy (GTK_WIDGET(dialog));
1683         }
1684         else
1685         {
1686                 if (response == GO_BACK)
1687                 {
1688                         if (current_page > 0) {
1689                                 current_page--;
1690                                 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1691                                         /* mailbox */
1692                                         current_page--;
1693                                 }
1694                                 gtk_notebook_set_current_page (
1695                                         GTK_NOTEBOOK(wizard->notebook), 
1696                                         current_page);
1697                         }
1698                 }
1699                 else if (response == GO_FORWARD)
1700                 {
1701                         if (current_page < (num_pages-1)) {
1702                                 current_page++;
1703                                 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1704                                         /* mailbox */
1705                                         current_page++;
1706                                 }
1707                                 gtk_notebook_set_current_page (
1708                                         GTK_NOTEBOOK(wizard->notebook), 
1709                                         current_page);
1710                         }
1711                 }
1712 set_sens:
1713                 gtk_dialog_set_response_sensitive (dialog, GO_BACK, 
1714                                 current_page > 0);
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);
1720                 } else {
1721                         gtk_dialog_set_response_sensitive (dialog, FINISHED, FALSE);
1722                         gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), GO_FORWARD);
1723                 }
1724
1725         }
1726 }
1727
1728 static gint wizard_close_cb(GtkWidget *widget, GdkEventAny *event,
1729                                  gpointer data)
1730 {
1731         WizardWindow *wizard = (WizardWindow *)data;
1732         wizard->result = FALSE;
1733         wizard->finished = TRUE;
1734         
1735         return FALSE;
1736 }
1737
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);      \
1742 }
1743
1744 gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
1745         WizardWindow *wizard = g_new0(WizardWindow, 1);
1746         GtkWidget *page;
1747         GtkWidget *widget;
1748         GtkWidget *label;
1749         GtkWidget *scrolled_window;
1750         gchar     *text;
1751         GSList    *cur;
1752         gboolean   result;
1753         gint i = 0;
1754         wizard->mainwin = mainwin;
1755         wizard->create_mailbox = create_mailbox;
1756         
1757         gtk_widget_hide(mainwin->window);
1758         
1759         wizard_read_defaults();
1760         
1761         wizard->window = gtk_dialog_new_with_buttons (_("Claws Mail Setup Wizard"),
1762                         NULL, 0, 
1763                         GTK_STOCK_GO_BACK, GO_BACK,
1764                         GTK_STOCK_GO_FORWARD, GO_FORWARD,
1765                         GTK_STOCK_SAVE, FINISHED,
1766                         GTK_STOCK_CANCEL, CANCEL,
1767                         NULL);
1768         gtk_widget_set_size_request(wizard->window, -1, 480);
1769
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), 
1774                         GO_FORWARD);
1775         gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window), 
1776                         GO_BACK, FALSE);
1777         gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window), 
1778                         GO_FORWARD, TRUE);
1779         gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window), 
1780                         FINISHED, FALSE);
1781         gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window), 
1782                         CANCEL, TRUE);
1783         
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);
1789         
1790         wizard->pages = NULL;
1791         
1792 /*welcome page: 0 */
1793         WELCOME_PAGE = i;
1794         page = create_page(wizard, _("Welcome to Claws Mail"));
1795         
1796         wizard->pages = g_slist_append(wizard->pages, page);
1797         widget = stock_pixmap_widget(wizard->window, 
1798                                 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1799
1800         gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1801         
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);
1809 #ifndef MAEMO
1810         gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1811 #else
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);
1816
1817         gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1818                                               widget);
1819 #endif
1820         g_free(text);
1821
1822 /* user page: 1 */
1823         i++;
1824         USER_PAGE = i;
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);
1830
1831         gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1832                                               user_page(wizard));
1833         PACK_WARNING(_("Bold fields must be completed"));
1834         
1835         wizard->pages = g_slist_append(wizard->pages, widget);
1836
1837 /* recv+auth page: 2 */
1838         i++;
1839         RECV_PAGE = i;
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);
1845
1846         gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1847                                               recv_page(wizard));
1848         PACK_WARNING(_("Bold fields must be completed"));
1849         
1850         wizard->pages = g_slist_append(wizard->pages, widget);
1851
1852 /*smtp page: 3 */
1853         i++;
1854         SMTP_PAGE = i;
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);
1860
1861         gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1862                                               smtp_page(wizard));
1863         PACK_WARNING(_("Bold fields must be completed"));
1864         
1865         wizard->pages = g_slist_append(wizard->pages, widget);
1866
1867 /* mailbox page: 4 */
1868         if (create_mailbox) {
1869                 i++;
1870                 MAILBOX_PAGE = i;
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);
1876
1877                 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1878                                               mailbox_page(wizard));
1879                 PACK_WARNING(_("Bold fields must be completed"));
1880         
1881                 wizard->pages = g_slist_append(wizard->pages, widget);
1882         }
1883
1884 /* done page: 6 */
1885         i++;
1886         DONE_PAGE = i;
1887         page = create_page(wizard, _("Configuration finished"));
1888         
1889         wizard->pages = g_slist_append(wizard->pages, page);
1890         widget = stock_pixmap_widget(wizard->window, 
1891                                 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1892
1893         gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1894         
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);
1899         g_free(text);
1900
1901
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);
1905         }
1906         
1907         g_signal_connect(G_OBJECT(wizard->window), "delete_event",
1908                          G_CALLBACK(wizard_close_cb), wizard);
1909         gtk_widget_show_all (wizard->window);
1910
1911         gtk_widget_hide(wizard->recv_imap_label);
1912         gtk_widget_hide(wizard->recv_imap_subdir);
1913         gtk_widget_hide(wizard->subsonly_checkbtn);
1914
1915         wizard_protocol_change(wizard, tmpl.recvtype);
1916
1917         while (!wizard->finished)
1918                 gtk_main_iteration();
1919
1920         result = wizard->result;
1921         
1922         GTK_EVENTS_FLUSH();
1923
1924         gtk_widget_show(mainwin->window);
1925         g_free(wizard);
1926
1927         return result;
1928 }