2008-09-17 [colin] 3.5.0cvs112
[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/gtk.h>
31
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <ctype.h>
36
37 #ifdef HAVE_CONFIG_H
38 #  include "config.h"
39 #endif
40
41 #include "utils.h"
42 #include "gtk/menu.h"
43 #include "plugin.h"
44 #include "account.h"
45 #include "prefs_account.h"
46 #include "mainwindow.h"
47 #include "stock_pixmap.h"
48 #include "setup.h"
49 #include "folder.h"
50 #include "alertpanel.h"
51 #include "filesel.h"
52 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
53 #include "ssl.h"
54 #endif
55 #include "prefs_common.h"
56 #include "combobox.h"
57
58 #ifdef MAEMO
59 #include <libgnomevfs/gnome-vfs-volume.h>
60 #include <libgnomevfs/gnome-vfs-volume-monitor.h>
61 #include <libgnomevfs/gnome-vfs-utils.h>
62 #endif
63
64 typedef enum
65 {
66         GO_BACK,
67         GO_FORWARD,
68         CANCEL,
69         FINISHED
70 } PageNavigation;
71
72 int WELCOME_PAGE = -1;
73 int USER_PAGE = -1;
74 int SMTP_PAGE = -1;
75 int RECV_PAGE = -1;
76 int MAILBOX_PAGE = -1;
77 int DONE_PAGE = -1;
78
79 typedef struct
80 {
81         GtkWidget *window;
82         GSList    *pages;
83         GtkWidget *notebook;
84
85         MainWindow *mainwin;
86         
87         GtkWidget *email;
88         GtkWidget *full_name;
89         GtkWidget *organization;
90
91         GtkWidget *mailbox_name;
92         GtkWidget *mailbox_label;
93         
94         GtkWidget *smtp_server;
95         GtkWidget *smtp_auth;
96         GtkWidget *smtp_username;
97         GtkWidget *smtp_password;
98         GtkWidget *smtp_username_label;
99         GtkWidget *smtp_password_label;
100
101         GtkWidget *recv_type;
102         GtkWidget *recv_label;
103         GtkWidget *recv_server;
104         GtkWidget *recv_username;
105         GtkWidget *recv_password;
106         GtkWidget *recv_username_label;
107         GtkWidget *recv_password_label;
108         GtkWidget *recv_imap_label;
109         GtkWidget *recv_imap_subdir;
110         GtkWidget *subsonly_checkbtn;
111         GtkWidget *no_imap_warning;
112 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
113         GtkWidget *smtp_use_ssl;
114         GtkWidget *recv_use_ssl;
115         GtkWidget *smtp_use_tls;
116         GtkWidget *recv_use_tls;
117         GtkWidget *smtp_ssl_cert_file;
118         GtkWidget *recv_ssl_cert_file;
119         GtkWidget *smtp_ssl_cert_pass;
120         GtkWidget *recv_ssl_cert_pass;
121         GtkWidget *smtp_cert_table;
122         GtkWidget *recv_cert_table;
123 #endif
124
125 #ifdef MAEMO
126         GtkWidget *data_root_nokia_radiobtn;
127         GtkWidget *data_root_mmc1_radiobtn;
128         GtkWidget *data_root_mmc2_radiobtn;
129         GnomeVFSVolumeMonitor *volmon;
130         gulong volmon_mount_sigid;
131         gulong volmon_unmount_sigid;
132         GnomeVFSVolume *vol_mmc1;
133         GnomeVFSVolume *vol_mmc2;
134 #endif  
135         gboolean create_mailbox;
136         gboolean finished;
137         gboolean result;
138
139 } WizardWindow;
140
141 typedef struct _AccountTemplate {
142         gchar *name;
143         gchar *domain;
144         gchar *email;
145         gchar *organization;
146         gchar *smtpserver;
147         gboolean smtpauth;
148         gchar *smtpuser;
149         gchar *smtppass;
150         RecvProtocol recvtype;
151         gchar *recvserver;
152         gchar *recvuser;
153         gchar *recvpass;
154         gchar *imapdir;
155         gboolean subsonly;
156         gchar *mboxfile;
157         gchar *mailbox;
158         gboolean smtpssl;
159         gboolean recvssl;
160         gchar *smtpssl_cert;
161         gchar *recvssl_cert;
162         gchar *smtpssl_cert_pass;
163         gchar *recvssl_cert_pass;
164 } AccountTemplate;
165
166 static AccountTemplate tmpl;
167
168 static PrefParam template_params[] = {
169         {"name", "$USERNAME",
170          &tmpl.name, P_STRING, NULL, NULL, NULL},
171         {"domain", "$DEFAULTDOMAIN",
172          &tmpl.domain, P_STRING, NULL, NULL, NULL},
173         {"email", "$NAME_MAIL@$DOMAIN",
174          &tmpl.email, P_STRING, NULL, NULL, NULL},
175         {"organization", "",
176          &tmpl.organization, P_STRING, NULL, NULL, NULL},
177         {"smtpserver", "smtp.$DOMAIN",
178          &tmpl.smtpserver, P_STRING, NULL, NULL, NULL},
179         {"smtpauth", "FALSE",
180          &tmpl.smtpauth, P_BOOL, NULL, NULL, NULL},
181         {"smtpuser", "",
182          &tmpl.smtpuser, P_STRING, NULL, NULL, NULL},
183         {"smtppass", "",
184          &tmpl.smtppass, P_STRING, NULL, NULL, NULL},
185         {"recvtype", A_POP3,
186          &tmpl.recvtype, P_INT, NULL, NULL, NULL},
187         {"recvserver", "pop.$DOMAIN",
188          &tmpl.recvserver, P_STRING, NULL, NULL, NULL},
189         {"recvuser", "$LOGIN",
190          &tmpl.recvuser, P_STRING, NULL, NULL, NULL},
191         {"recvpass", "",
192          &tmpl.recvpass, P_STRING, NULL, NULL, NULL},
193         {"imapdir", "",
194          &tmpl.imapdir, P_STRING, NULL, NULL, NULL},
195         {"subsonly", "TRUE",
196          &tmpl.subsonly, P_BOOL, NULL, NULL, NULL},
197         {"mboxfile", "/var/mail/$LOGIN",
198          &tmpl.mboxfile, P_STRING, NULL, NULL, NULL},
199         {"mailbox", "Mail",
200          &tmpl.mailbox, P_STRING, NULL, NULL, NULL},
201         {"smtpssl", "0",
202          &tmpl.smtpssl, P_INT, NULL, NULL, NULL},
203         {"recvssl", "0",
204          &tmpl.recvssl, P_INT, NULL, NULL, NULL},
205         {"smtpssl_cert", "",
206          &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
207         {"recvssl_cert", "",
208          &tmpl.recvssl_cert, P_STRING, NULL, NULL, NULL},
209         {"smtpssl_cert_pass", "",
210          &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
211         {"recvssl_cert_pass", "",
212          &tmpl.recvssl_cert, P_STRING, NULL, NULL, NULL},
213         {NULL, NULL, NULL, P_INT, NULL, NULL, NULL}
214 };
215
216
217 static gchar *accountrc_tmpl =
218         "[AccountTemplate]\n"
219         "#you can use $DEFAULTDOMAIN here\n"
220         "#domain must be defined before the variables that use it\n"
221         "#by default, domain is extracted from the hostname\n"
222         "#domain=\n"
223         "\n"
224         "#you can use $USERNAME for name (this is the default)\n"
225         "#name=\n"
226         "\n"
227         "#you can use $LOGIN, $NAME_MAIL and $DOMAIN here \n"
228         "#$NAME_MAIL is the name without uppercase and with dots instead\n"
229         "#of spaces\n"
230         "#the default is $NAME_MAIL@$DOMAIN\n"
231         "#email=\n"
232         "\n"
233         "#you can use $DOMAIN here\n"
234         "#the default organization is empty\n"
235         "#organization=\n"
236         "\n"
237         "#you can use $DOMAIN here \n"
238         "#the default is smtp.$DOMAIN\n"
239         "#smtpserver=\n"
240         "\n"
241         "#Whether to use smtp authentication\n"
242         "#the default is 0 (no)\n"
243         "#smtpauth=\n"
244         "\n"
245         "#SMTP username\n"
246         "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
247         "#the default is empty (same as reception username)\n"
248         "#smtpuser=\n"
249         "\n"
250         "#SMTP password\n"
251         "#the default is empty (same as reception password)\n"
252         "#smtppass=\n"
253         "\n"
254         "#recvtype can be:\n"
255         "#0 for pop3\n"
256         "#3  for imap\n"
257         "#5  for a local mbox file\n"
258         "#recvtype=\n"
259         "\n"
260         "#you can use $DOMAIN here \n"
261         "#the default is {pop,imap}.$DOMAIN\n"
262         "#recvserver=\n"
263         "\n"
264         "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
265         "#default is $LOGIN\n"
266         "#recvuser=\n"
267         "\n"
268         "#default is empty\n"
269         "#recvpass=\n"
270         "\n"
271         "#imap dir if imap (relative to the home on the server)\n"
272         "#default is empty\n"
273         "#imapdir=\n"
274         "\n"
275         "#show subscribed folders only, if imap\n"
276         "#default is TRUE\n"
277         "#subsonly=\n"
278         "\n"
279         "#mbox file if local\n"
280         "#you can use $LOGIN here\n"
281         "#default is /var/mail/$LOGIN\n"
282         "#mboxfile=\n"
283         "\n"
284         "#mailbox name if pop3 or local\n"
285         "#relative path from the user's home\n"
286         "#default is \"Mail\"\n"
287         "#mailbox=\n"
288         "\n"
289         "#whether to use ssl on smtp connections\n"
290         "#default is 0, 1 is ssl, 2 is starttls\n"
291         "#smtpssl=\n"
292         "\n"
293         "#whether to use ssl on pop or imap connections\n"
294         "#default is 0, 1 is ssl, 2 is starttls\n"
295         "#recvssl=\n"
296         "\n"
297         "#SSL client certificate path for SMTP\n"
298         "#default is empty (no certificate)\n"
299         "#smtpssl_cert=\n"
300         "\n"
301         "#SSL client certificate path for POP/IMAP\n"
302         "#default is empty (no certificate)\n"
303         "#recvssl_cert=\n"
304         "\n"
305         "#SSL client certificate password for SMTP\n"
306         "#default is empty (no password)\n"
307         "#smtpssl_cert_pass=\n"
308         "\n"
309         "#SSL client certificate password for POP/IMAP\n"
310         "#default is empty (no password)\n"
311         "#recvssl_cert_pass=\n"
312         ;
313
314 static gchar *wizard_get_default_domain_name(void)
315 {
316         static gchar *domain_name = NULL;
317         
318         if (domain_name == NULL) {
319                 domain_name = g_strdup(get_domain_name());
320                 if (strchr(domain_name, '.') != strrchr(domain_name, '.')
321                 && strlen(strchr(domain_name, '.')) > 6) {
322                         gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
323                         g_free(domain_name);
324                         domain_name = tmp;
325                 }
326         }
327         return domain_name;
328 }
329
330 static gchar *get_name_for_mail(void)
331 {
332         gchar *name = NULL;
333         if (tmpl.name == NULL)
334                 return NULL;
335         name = g_utf8_strdown(tmpl.name, -1);
336         while(strstr(name, " "))
337                 *strstr(name, " ")='.';
338         
339         return name;
340 }
341
342 #define PARSE_DEFAULT(str) {    \
343         gchar *tmp = NULL, *new = NULL; \
344         if (str != NULL) {      \
345                 tmp = g_strdup(str);    \
346                 if (strstr(str, "$USERNAME")) { \
347                         tmp = g_strdup(str);    \
348                         *strstr(tmp, "$USERNAME") = '\0';       \
349                         new = g_strconcat(tmp, g_get_real_name(),       \
350                                 strstr(str, "$USERNAME")+strlen("$USERNAME"),   \
351                                 NULL);  \
352                         g_free(tmp);    \
353                         g_free(str);    \
354                         str = new;      \
355                         new = NULL;     \
356                 }       \
357                 if (strstr(str, "$LOGIN")) {    \
358                         tmp = g_strdup(str);    \
359                         *strstr(tmp, "$LOGIN") = '\0';  \
360                         new = g_strconcat(tmp, g_get_user_name(),       \
361                                 strstr(str, "$LOGIN")+strlen("$LOGIN"),         \
362                                 NULL);  \
363                         g_free(tmp);    \
364                         g_free(str);    \
365                         str = new;      \
366                         new = NULL;     \
367                 }       \
368                 if (strstr(str, "$EMAIL")) {    \
369                         tmp = g_strdup(str);    \
370                         *strstr(tmp, "$EMAIL") = '\0';  \
371                         new = g_strconcat(tmp, tmpl.email,      \
372                                 strstr(str, "$EMAIL")+strlen("$EMAIL"),         \
373                                 NULL);  \
374                         g_free(tmp);    \
375                         g_free(str);    \
376                         str = new;      \
377                         new = NULL;     \
378                 }       \
379                 if (strstr(str, "$NAME_MAIL")) {        \
380                         tmp = g_strdup(str);    \
381                         *strstr(tmp, "$NAME_MAIL") = '\0';      \
382                         new = g_strconcat(tmp, get_name_for_mail(),     \
383                                 strstr(str, "$NAME_MAIL")+strlen("$NAME_MAIL"),         \
384                                 NULL);  \
385                         g_free(tmp);    \
386                         g_free(str);    \
387                         str = new;      \
388                         new = NULL;     \
389                 }       \
390                 if (strstr(str, "$DEFAULTDOMAIN")) {    \
391                         tmp = g_strdup(str);    \
392                         *strstr(tmp, "$DEFAULTDOMAIN") = '\0';  \
393                         new = g_strconcat(tmp, wizard_get_default_domain_name(),        \
394                                 strstr(str, "$DEFAULTDOMAIN")+strlen("$DEFAULTDOMAIN"),         \
395                                 NULL);  \
396                         g_free(tmp);    \
397                         g_free(str);    \
398                         str = new;      \
399                         new = NULL;     \
400                 }       \
401                 if (strstr(str, "$DOMAIN")) {   \
402                         tmp = g_strdup(str);    \
403                         *strstr(tmp, "$DOMAIN") = '\0'; \
404                         new = g_strconcat(tmp, tmpl.domain,     \
405                                 strstr(str, "$DOMAIN")+strlen("$DOMAIN"),       \
406                                 NULL);  \
407                         g_free(tmp);    \
408                         g_free(str);    \
409                         str = new;      \
410                         new = NULL;     \
411                 }       \
412         }       \
413 }
414 static void wizard_read_defaults(void)
415 {
416         gchar *rcpath;
417
418         rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "accountrc.tmpl", NULL);
419         if (!is_file_exist(rcpath)) {
420                 str_write_to_file(accountrc_tmpl, rcpath);
421         }
422
423         prefs_read_config(template_params, "AccountTemplate", rcpath, NULL);
424
425         PARSE_DEFAULT(tmpl.domain);
426         PARSE_DEFAULT(tmpl.name);
427         PARSE_DEFAULT(tmpl.email);
428         PARSE_DEFAULT(tmpl.organization);
429         PARSE_DEFAULT(tmpl.smtpserver);
430         PARSE_DEFAULT(tmpl.smtpuser);
431         PARSE_DEFAULT(tmpl.smtppass);
432         PARSE_DEFAULT(tmpl.recvserver);
433         PARSE_DEFAULT(tmpl.recvuser);
434         PARSE_DEFAULT(tmpl.recvpass);
435         PARSE_DEFAULT(tmpl.imapdir);
436         PARSE_DEFAULT(tmpl.mboxfile);
437         PARSE_DEFAULT(tmpl.mailbox);
438 /*
439         g_print("defaults:"
440         "%s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %s, %s, %d, %d\n",
441         tmpl.name,tmpl.domain,tmpl.email,tmpl.organization,tmpl.smtpserver,
442         tmpl.recvtype,tmpl.recvserver,tmpl.recvuser,tmpl.recvpass,
443         tmpl.imapdir,tmpl.mboxfile,tmpl.mailbox,tmpl.smtpssl,tmpl.recvssl);
444 */
445         g_free(rcpath);
446 }
447
448 static void initialize_fonts(WizardWindow *wizard)
449 {
450         GtkWidget *widget = wizard->email;
451         gint size = pango_font_description_get_size(
452                         widget->style->font_desc)
453                       /PANGO_SCALE;
454         gchar *tmp, *new;
455         
456         tmp = g_strdup(prefs_common.textfont);
457         if (strrchr(tmp, ' ')) {
458                 *(strrchr(tmp, ' ')) = '\0';
459                 new = g_strdup_printf("%s %d", tmp, size);
460                 g_free(prefs_common.textfont);
461                 prefs_common.textfont = new;
462         }
463         g_free(tmp);
464         
465         tmp = g_strdup(prefs_common.smallfont);
466         if (strrchr(tmp, ' ')) {
467                 *(strrchr(tmp, ' ')) = '\0';
468                 new = g_strdup_printf("%s %d", tmp, size);
469                 g_free(prefs_common.smallfont);
470                 prefs_common.smallfont = new;
471         }
472         g_free(tmp);
473         
474         tmp = g_strdup(prefs_common.normalfont);
475         if (strrchr(tmp, ' ')) {
476                 *(strrchr(tmp, ' ')) = '\0';
477                 new = g_strdup_printf("%s %d", tmp, size);
478                 g_free(prefs_common.normalfont);
479                 prefs_common.normalfont = new;
480         }
481         g_free(tmp);
482
483         tmp = g_strdup(prefs_common.boldfont);
484         if (strrchr(tmp, ' ')) {
485                 *(strrchr(tmp, ' ')) = '\0';
486                 new = g_strdup_printf("%s %d", tmp, size);
487                 g_free(prefs_common.boldfont);
488                 prefs_common.boldfont = new;
489         }
490         g_free(tmp);
491 }
492
493 #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"
494 #define FACE "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAM1BMVEUAAAAcJCI\n\
495  ONl1JUi0+Z4daY2NZciPabV9ykS5kj6Wsl2ybmZOBsMjZxK2wzN3Pzczs7OsCAGN0AAAAAXRSTlM\n\
496  AQObYZgAAAAFiS0dEAIgFHUgAAAIVSURBVEjH1ZbtlqMgDIaFECoGhPu/2s0b0Lais/NzN6d1OJ7\n\
497  3yReQzrL8B5Zy3rvl9At52Pf2tv1vSMjtYj8jaa8XUyI/yn3YD6sigj/2Tf5Bn069MIsTPHvx/t5\n\
498  /3rU/6JCIY3YwGe26r/cwUfE3cFe5T28L0K5rJAUHEeYAQxs8DHojjk3M9wECU4xxjXisI8RA0gy\n\
499  oczJZJOjxiTFZVTchAnIRJrgdmEGDyFfAI3UuG5FmYTkR9RDrIC4H0SqV4pzpEcUp0HNLjwBv+jA\n\
500  dikUE5g9iBvzmu3sH2oDk4lnHd829+2Q9gj6kDqDPg7hsGwBzH02fE3ZCt6ZHmlNKIMjMeRwra5I\n\
501  ecgNoBnLGPmzaHPJIwLY8Sq2M/tLUJfj0QcqmfVXAdLSStIYF8dzWjBBb2VgvDa4mO9oc651OiUo\n\
502  BEKbZokdPATF9E9oKAjQJcJOniaPXrVZRAnVWaqIyqRoNC8ZJvgCcW8XN39RqxVP1rS8Yd4WnCdN\n\
503  aRTo2jJRDbg3vtCpEUGffgDPhqKDaSuVqYtOplFIvIcx3HUI5/MuIWl6vKyBjNlqEru8hbFXqBPA\n\
504  5TpHGIUZOePeaIyzfQ/g9Xg0opU1AvdfXM9floYhv92pPAE96OZtkPV8eivgQi9RTfwPUU36I26n\n\
505  Hy+WuCJzAT7efMSeA1TNf2/VugDz+dN139xfA5ffxGZDD+MvcP/uvyB80wzZ76wbz8gAAAABJRU5\n\
506  ErkJggg=="
507
508 static void write_welcome_email(WizardWindow *wizard)
509 {
510         gchar buf_date[64];
511         gchar *head=NULL;
512         gchar *body=NULL;
513         gchar *msg=NULL;
514         const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name));
515         Folder *folder = folder_find_from_path(mailbox);
516         FolderItem *inbox = folder ? folder->inbox:NULL;
517         gchar *file = get_tmp_file();
518         gchar enc_from_name[BUFFSIZE], enc_to_name[BUFFSIZE], enc_subject[BUFFSIZE];
519         
520         get_rfc822_date(buf_date, sizeof(buf_date));
521
522         conv_encode_header_full(enc_subject, sizeof(enc_subject), 
523                         Q_("Welcome Mail Subject|Welcome to Claws Mail"),
524                         strlen("Subject: "), FALSE, CS_INTERNAL);
525         conv_encode_header_full(enc_to_name, sizeof(enc_to_name), 
526                         gtk_entry_get_text(GTK_ENTRY(wizard->full_name)),
527                         strlen("To: "), TRUE, CS_INTERNAL);
528         conv_encode_header_full(enc_from_name, sizeof(enc_from_name), 
529                         _("The Claws Mail Team"),
530                         strlen("From: "), TRUE, CS_INTERNAL);
531
532         head = g_strdup_printf(
533                 "From: %s <%s>\n"
534                 "To: %s <%s>\n"
535                 "Date: %s\n"
536                 "Subject: %s\n"
537                 "X-Face: %s\n"
538                 "Face: %s\n"
539                 "Content-Type: text/plain; charset=UTF-8\n",
540                 enc_from_name,
541                 USERS_ML_ADDR,
542                 enc_to_name,
543                 gtk_entry_get_text(GTK_ENTRY(wizard->email)),
544                 buf_date, enc_subject, XFACE, FACE);
545         body = g_strdup_printf(
546                 _("\n"
547                 "Welcome to Claws Mail\n"
548                 "---------------------\n"
549                 "\n"
550                 "Now that you have set up your account you can fetch your\n"
551                 "mail by clicking the 'Get Mail' button at the left of the\n"
552                 "toolbar.\n"
553                 "\n"
554                 "Claws Mail has lots of extra features accessible via plugins,\n"
555                 "like anti-spam filtering and learning (via the Bogofilter or\n"
556                 "SpamAssassin plugins), privacy protection (via PGP/Mime), an RSS\n"
557                 "aggregator, a calendar, and much more. You can load them from\n"
558                 "the menu entry '/Configuration/Plugins'.\n"
559                 "\n"
560                 "You can change your Account Preferences by using the menu\n"
561                 "entry '/Configuration/Preferences for current account'\n"
562                 "and change the general Preferences by using\n"
563                 "'/Configuration/Preferences'.\n"
564                 "\n"
565                 "You can find further information in the Claws Mail manual,\n"
566                 "which can be accessed by using the menu entry '/Help/Manual'\n"
567                 "or online at the URL given below.\n"
568                 "\n"
569                 "Useful URLs\n"
570                 "-----------\n"
571                 "Homepage:      <%s>\n"
572                 "Manual:        <%s>\n"
573                 "FAQ:          <%s>\n"
574                 "Themes:        <%s>\n"
575                 "Mailing Lists: <%s>\n"
576                 "\n"
577                 "LICENSE\n"
578                 "-------\n"
579                 "Claws Mail is free software, released under the terms\n"
580                 "of the GNU General Public License, version 3 or later, as\n"
581                 "published by the Free Software Foundation, 51 Franklin Street,\n"
582                 "Fifth Floor, Boston, MA 02110-1301, USA. The license can be\n"
583                 "found at <%s>.\n"
584                 "\n"
585                 "DONATIONS\n"
586                 "---------\n"
587                 "If you wish to donate to the Claws Mail project you can do\n"
588                 "so at <%s>.\n\n"),
589                 HOMEPAGE_URI, MANUAL_URI, FAQ_URI, THEMES_URI, MAILING_LIST_URI,
590                 GPL_URI, DONATE_URI);
591         
592         msg = g_strconcat(head, body, NULL);
593
594         if (inbox && inbox->total_msgs == 0
595          && str_write_to_file(msg, file) >= 0) {
596                 MsgFlags flags = { MSG_UNREAD|MSG_NEW, 0};
597                 folder_item_add_msg(inbox, file, &flags, FALSE);
598         }
599         g_free(head);
600         g_free(body);
601         g_free(msg);
602         claws_unlink(file);
603 }
604 #undef XFACE
605
606 static gboolean wizard_write_config(WizardWindow *wizard)
607 {
608         static gboolean mailbox_ok = FALSE;
609         PrefsAccount *prefs_account = prefs_account_new();
610         GList *account_list = NULL;
611         gchar *smtp_server, *recv_server;
612         gint smtp_port, recv_port;
613 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
614         SSLType smtp_ssl_type, recv_ssl_type;
615 #endif
616
617         prefs_account->protocol = combobox_get_active_data(
618                                         GTK_COMBO_BOX(wizard->recv_type));
619         
620         if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4 && 
621             !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)))) {
622                 alertpanel_error(_("Please enter the mailbox name."));
623                 g_free(prefs_account);
624                 gtk_notebook_set_current_page (
625                         GTK_NOTEBOOK(wizard->notebook), 
626                         MAILBOX_PAGE);
627                 return FALSE;
628         }
629
630 #ifdef MAEMO
631         if (wizard->create_mailbox) {
632                 g_free(prefs_common.data_root);
633                 if (gtk_toggle_button_get_active(
634                         GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn)))
635                         prefs_common.data_root = NULL;
636                 else if (gtk_toggle_button_get_active(
637                         GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn)))
638                         prefs_common.data_root = g_strdup(MMC1_PATH);
639                 else if (gtk_toggle_button_get_active(
640                         GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn)))
641                         prefs_common.data_root = g_strdup(MMC2_PATH);
642         }
643 #endif
644
645         if (!mailbox_ok) {
646                 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
647                         mailbox_ok = setup_write_mailbox_path(wizard->mainwin, 
648                                         gtk_entry_get_text(
649                                                 GTK_ENTRY(wizard->mailbox_name)));
650                 } else
651                         mailbox_ok = TRUE;
652         }
653
654         if (!mailbox_ok) {
655                 /* alertpanel done by setup_write_mailbox_path */
656                 g_free(prefs_account);
657                 gtk_notebook_set_current_page (
658                         GTK_NOTEBOOK(wizard->notebook), 
659                         MAILBOX_PAGE);
660                 return FALSE;
661         }
662         
663         if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->full_name)))
664         ||  !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->email)))) {
665                 alertpanel_error(_("Please enter your name and email address."));
666                 g_free(prefs_account);
667                 gtk_notebook_set_current_page (
668                         GTK_NOTEBOOK(wizard->notebook), 
669                         USER_PAGE);
670                 return FALSE;
671         }
672         
673         if (prefs_account->protocol != A_LOCAL) {
674                 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)))
675                 ||  !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
676                         alertpanel_error(_("Please enter your receiving server "
677                                            "and username."));
678                         g_free(prefs_account);
679                         gtk_notebook_set_current_page (
680                                 GTK_NOTEBOOK(wizard->notebook), 
681                                 RECV_PAGE);
682                         return FALSE;
683                 }
684         } else {
685                 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
686                         alertpanel_error(_("Please enter your 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         }
694         
695         if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)))) {
696                 alertpanel_error(_("Please enter your SMTP server."));
697                 g_free(prefs_account);
698                 gtk_notebook_set_current_page (
699                         GTK_NOTEBOOK(wizard->notebook), 
700                         SMTP_PAGE);
701                 return FALSE;
702         }
703
704         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
705                 if (prefs_account->protocol == A_LOCAL
706                 &&  !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)))) {
707                         alertpanel_error(_("Please enter your SMTP username."));
708                         g_free(prefs_account);
709                         gtk_notebook_set_current_page (
710                                 GTK_NOTEBOOK(wizard->notebook), 
711                                 SMTP_PAGE);
712                         return FALSE;           
713                 } /* if it's not local we'll use the reception server */
714         }
715
716         if (prefs_account->protocol != A_LOCAL)
717                 prefs_account->account_name = g_strdup_printf("%s@%s",
718                                 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)),
719                                 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
720         else
721                 prefs_account->account_name = g_strdup_printf("%s",
722                                 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
723
724         recv_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
725         smtp_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)));
726
727         if (prefs_account->protocol != A_LOCAL && strstr(recv_server, ":")) {
728                 recv_port = atoi(strstr(recv_server, ":")+1);
729                 *(strstr(recv_server, ":")) = '\0';
730                 if (prefs_account->protocol == A_IMAP4) {
731                         prefs_account->set_imapport = TRUE;
732                         prefs_account->imapport = recv_port;
733                 } else if (prefs_account->protocol == A_POP3) {
734                         prefs_account->set_popport = TRUE;
735                         prefs_account->popport = recv_port;
736                 }
737         }
738         if (strstr(smtp_server, ":")) {
739                 smtp_port = atoi(strstr(smtp_server, ":")+1);
740                 *(strstr(smtp_server, ":")) = '\0';
741                 prefs_account->set_smtpport = TRUE;
742                 prefs_account->smtpport = smtp_port;
743         }
744         
745         prefs_account->name = g_strdup(
746                                 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)));
747         prefs_account->address = g_strdup(
748                                 gtk_entry_get_text(GTK_ENTRY(wizard->email)));
749         prefs_account->organization = g_strdup(
750                                 gtk_entry_get_text(GTK_ENTRY(wizard->organization)));
751         prefs_account->smtp_server = g_strdup(smtp_server);
752
753         if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
754                 gchar *tmp;
755                 tmp = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
756                 prefs_account->inbox = g_strdup_printf("#mh/%s/inbox",
757                         (!strcmp("Mail", gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name))))
758                                 ?_("Mailbox"):tmp);
759                 g_free(tmp);
760                 prefs_account->local_inbox = g_strdup(prefs_account->inbox);
761         } else if (prefs_account->protocol != A_IMAP4) {
762                 if (folder_get_default_inbox())
763                         prefs_account->local_inbox = 
764                                 folder_item_get_identifier(folder_get_default_inbox());
765         }
766
767         if (prefs_account->protocol != A_LOCAL)
768                 prefs_account->recv_server = g_strdup(recv_server);
769         else
770                 prefs_account->local_mbox = g_strdup(recv_server);
771
772         g_free(recv_server);
773         g_free(smtp_server);
774
775         prefs_account->userid = g_strdup(
776                                 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)));
777         prefs_account->passwd = g_strdup(
778                                 gtk_entry_get_text(GTK_ENTRY(wizard->recv_password)));
779
780         prefs_account->smtp_userid = g_strdup(
781                                 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)));
782         prefs_account->smtp_passwd = g_strdup(
783                                 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_password)));
784         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
785                 prefs_account->use_smtp_auth = TRUE;
786         }
787
788 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
789         smtp_ssl_type = SSL_NONE;
790         recv_ssl_type = SSL_NONE;       
791
792         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl))) {
793                 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls)))
794                         smtp_ssl_type = SSL_STARTTLS;
795                 else
796                         smtp_ssl_type = SSL_TUNNEL;
797         }
798         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl))) {
799                 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls)))
800                         recv_ssl_type = SSL_STARTTLS;
801                 else
802                         recv_ssl_type = SSL_TUNNEL;
803         }
804
805         prefs_account->ssl_smtp = smtp_ssl_type;
806
807         if (prefs_account->protocol == A_IMAP4)
808                 prefs_account->ssl_imap = recv_ssl_type;
809         else
810                 prefs_account->ssl_pop = recv_ssl_type;
811
812         prefs_account->out_ssl_client_cert_file = g_strdup(
813                                 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_ssl_cert_file)));
814         prefs_account->out_ssl_client_cert_pass = g_strdup(
815                                 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_ssl_cert_pass)));
816         prefs_account->in_ssl_client_cert_file = g_strdup(
817                                 gtk_entry_get_text(GTK_ENTRY(wizard->recv_ssl_cert_file)));
818         prefs_account->in_ssl_client_cert_pass = g_strdup(
819                                 gtk_entry_get_text(GTK_ENTRY(wizard->recv_ssl_cert_pass)));
820 #endif
821         if (prefs_account->protocol == A_IMAP4) {
822                 gchar *directory = gtk_editable_get_chars(
823                         GTK_EDITABLE(wizard->recv_imap_subdir), 0, -1);
824                 if (directory && strlen(directory)) {
825                         prefs_account->imap_dir = g_strdup(directory);
826                 }
827                 prefs_account->imap_subsonly = 
828                         gtk_toggle_button_get_active(
829                                 GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn));
830                 g_free(directory);
831         }
832
833         account_list = g_list_append(account_list, prefs_account);
834         prefs_account_write_config_all(account_list);
835         prefs_account_free(prefs_account);
836         account_read_config_all();
837
838         initialize_fonts(wizard);
839         if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
840                 write_welcome_email(wizard);
841
842 #ifdef MAEMO
843         if (wizard->volmon_mount_sigid)
844                 g_signal_handler_disconnect(
845                                         G_OBJECT(wizard->volmon),
846                                         wizard->volmon_mount_sigid);
847         if (wizard->volmon_unmount_sigid)
848                 g_signal_handler_disconnect(
849                                         G_OBJECT(wizard->volmon),
850                                         wizard->volmon_unmount_sigid);
851 #endif
852
853 #ifndef G_OS_WIN32 
854         plugin_load_standard_plugins();
855 #endif
856         return TRUE;
857 }
858
859 static GtkWidget* create_page (WizardWindow *wizard, const char * title)
860 {
861         GtkWidget *w;
862         GtkWidget *vbox;
863         GtkWidget *hbox;
864         GtkWidget *image;
865         char *title_string;
866
867         vbox = gtk_vbox_new (FALSE, 6);
868         gtk_container_set_border_width  (GTK_CONTAINER(vbox), 10);
869
870         /* create the titlebar */
871         hbox = gtk_hbox_new (FALSE, 12);
872         image = stock_pixmap_widget(wizard->window, 
873                                 STOCK_PIXMAP_CLAWS_MAIL_ICON);
874         gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 0);
875         title_string = g_strconcat ("<span size=\"xx-large\" weight=\"ultrabold\">", title ? title : "", "</span>", NULL);
876         w = gtk_label_new (title_string);
877         gtk_label_set_use_markup (GTK_LABEL(w), TRUE);
878         g_free (title_string);
879         gtk_box_pack_start (GTK_BOX(hbox), w, FALSE, FALSE, 0);
880
881         /* pack the titlebar */
882         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
883
884         /* pack the separator */
885         gtk_box_pack_start (GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
886
887         /* pack space */
888         w = gtk_alignment_new (0, 0, 0, 0);
889         gtk_widget_set_size_request (w, 0, 6);
890         gtk_box_pack_start (GTK_BOX(vbox), w, FALSE, FALSE, 0);
891
892         return vbox;
893 }
894
895 #define PACK_BOX(hbox,text,entry) {                                     \
896         GtkWidget *label = gtk_label_new(text);                         \
897         gtk_label_set_use_markup(GTK_LABEL(label), TRUE);               \
898         if (GTK_IS_MISC(label))                                         \
899                 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);        \
900         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);      \
901         gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);        \
902 }
903
904 static gchar *get_default_server(WizardWindow * wizard, const gchar *type)
905 {
906         if (!strcmp(type, "smtp")) {
907                 if (!tmpl.smtpserver || !strlen(tmpl.smtpserver))
908                         return g_strconcat(type, ".", tmpl.domain, NULL);
909                 else 
910                         return g_strdup(tmpl.smtpserver);
911         } else {
912                 if (!tmpl.recvserver || !strlen(tmpl.recvserver))
913                         return g_strconcat(type, ".", tmpl.domain, NULL);
914                 else 
915                         return g_strdup(tmpl.recvserver);
916         }
917 }
918
919 static gchar *get_default_account(WizardWindow * wizard)
920 {
921         gchar *result = NULL;
922         
923         if (!tmpl.recvuser || !strlen(tmpl.recvuser)) {
924                 result = gtk_editable_get_chars(
925                                 GTK_EDITABLE(wizard->email), 0, -1);
926
927                 if (strstr(result, "@")) {
928                         *(strstr(result,"@")) = '\0';
929                 } 
930         } else {
931                 result = g_strdup(tmpl.recvuser);
932         }
933         return result;
934 }
935
936 static gchar *get_default_smtp_account(WizardWindow * wizard)
937 {
938         gchar *result = NULL;
939         
940         if (!tmpl.smtpuser || !strlen(tmpl.smtpuser)) {
941                 return g_strdup("");
942         } else {
943                 result = g_strdup(tmpl.smtpuser);
944         }
945         return result;
946 }
947
948 static void wizard_email_changed(GtkWidget *widget, gpointer data)
949 {
950         WizardWindow *wizard = (WizardWindow *)data;
951         RecvProtocol protocol;
952         gchar *text;
953         protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
954         
955         text = get_default_server(wizard, "smtp");
956         gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
957         g_free(text);
958
959         text = get_default_account(wizard);
960         gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
961         g_free(text);
962
963         if (protocol == A_POP3) {
964                 text = get_default_server(wizard, "pop");
965                 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
966                 g_free(text);
967         } else if (protocol == A_IMAP4) {
968                 text = get_default_server(wizard, "imap");
969                 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
970                 g_free(text);
971         } else if (protocol == A_LOCAL) {
972                 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
973         }
974         
975 }
976
977 static GtkWidget* user_page (WizardWindow * wizard)
978 {
979         GtkWidget *table = gtk_table_new(1,1, FALSE);
980         GtkWidget *vbox;
981         GtkWidget *hbox;
982         
983         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
984         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
985
986         vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
987         gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
988
989         gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
990                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
991
992         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
993         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
994         wizard->full_name = gtk_entry_new();
995         gtk_entry_set_text(GTK_ENTRY(wizard->full_name), tmpl.name?tmpl.name:"");
996         PACK_BOX(hbox, _("<span weight=\"bold\">Your name:</span>"),
997                  wizard->full_name);
998         
999         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1000         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1001         wizard->email = gtk_entry_new();
1002         gtk_entry_set_text(GTK_ENTRY(wizard->email), tmpl.email?tmpl.email:"");
1003         PACK_BOX(hbox, _("<span weight=\"bold\">Your email address:</span>"),
1004                  wizard->email);
1005         
1006         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1007         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);      
1008         wizard->organization = gtk_entry_new();
1009         gtk_entry_set_text(GTK_ENTRY(wizard->organization), tmpl.organization?tmpl.organization:"");
1010         PACK_BOX(hbox, _("Your organization:"), wizard->organization);
1011         
1012         g_signal_connect(G_OBJECT(wizard->email), "changed",
1013                          G_CALLBACK(wizard_email_changed),
1014                          wizard);
1015         return table;
1016 }
1017
1018 #ifdef MAEMO
1019 static void wizard_vol_mount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
1020 {
1021         gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
1022         gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1023         g_free (uri);
1024         if (mount_path) {
1025                 if(!strcmp(mount_path, MMC1_PATH)) {
1026                         gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, TRUE);
1027                 }
1028                 if(!strcmp(mount_path, MMC2_PATH)) {
1029                         gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, TRUE);
1030                 }
1031         }
1032         g_free(mount_path);
1033 }
1034 static void wizard_vol_unmount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
1035 {
1036         gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
1037         gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1038         g_free (uri);
1039         if (mount_path) {
1040                 if(!strcmp(mount_path, MMC1_PATH)) {
1041                         gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, FALSE);
1042                         if (gtk_toggle_button_get_active(
1043                                 GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn))) {
1044                                 gtk_toggle_button_set_active(
1045                                         GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn), TRUE);
1046                         }
1047                 }
1048                 if(!strcmp(mount_path, MMC2_PATH)) {
1049                         gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, FALSE);
1050                         if (gtk_toggle_button_get_active(
1051                                 GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn))) {
1052                                 gtk_toggle_button_set_active(
1053                                         GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn), TRUE);
1054                         }
1055                 }
1056         }
1057         g_free(mount_path);
1058 }
1059
1060 void data_root_changed          (GtkToggleButton        *toggle_btn,
1061                                  WizardWindow *wizard)
1062 {
1063         gchar *name = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
1064         gchar *path = NULL;
1065         if (gtk_toggle_button_get_active(
1066                 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn)))
1067                 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), name);
1068         else if (gtk_toggle_button_get_active(
1069                 GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn))) {
1070                 path = g_strconcat(MMC1_PATH, G_DIR_SEPARATOR_S, 
1071                                   "Claws", G_DIR_SEPARATOR_S, 
1072                                   g_get_user_name(), G_DIR_SEPARATOR_S,
1073                                   name, NULL);
1074                 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
1075                 g_free(path);
1076         } else if (gtk_toggle_button_get_active(
1077                 GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn))) {
1078                 path = g_strconcat(MMC2_PATH, G_DIR_SEPARATOR_S, 
1079                                   "Claws", G_DIR_SEPARATOR_S, 
1080                                   g_get_user_name(), G_DIR_SEPARATOR_S,
1081                                   name, NULL);
1082                 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
1083                 g_free(path);
1084         }
1085         g_free(name);
1086 }
1087 #endif
1088
1089 static GtkWidget* mailbox_page (WizardWindow * wizard)
1090 {
1091         GtkWidget *table = gtk_table_new(1,1, FALSE);
1092         GtkWidget *vbox;
1093 #ifdef MAEMO
1094         GtkWidget *vbox2;
1095         gchar *uri, *mount_path;
1096 #endif
1097         GtkWidget *hbox;
1098         CLAWS_TIP_DECL();
1099
1100         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1101         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1102
1103         vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1104         gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1105
1106         gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
1107                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
1108
1109         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1110         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1111
1112         wizard->mailbox_label = gtk_label_new(_("<span weight=\"bold\">Mailbox name:</span>"));
1113         gtk_label_set_use_markup(GTK_LABEL(wizard->mailbox_label), TRUE);
1114         if (GTK_IS_MISC(wizard->mailbox_label))                                               
1115                 gtk_misc_set_alignment(GTK_MISC(wizard->mailbox_label), 1, 0.5);              
1116         wizard->mailbox_name = gtk_entry_new();
1117
1118         gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), tmpl.mailbox?tmpl.mailbox:"");
1119
1120         CLAWS_SET_TIP(wizard->mailbox_name, _("You can also specify an absolute path, for example: "
1121                                "\"/home/john/Documents/Mail\""));
1122
1123         gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_label, FALSE, FALSE, 0);
1124         gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_name, TRUE, TRUE, 0);
1125
1126 #ifdef MAEMO
1127         wizard->data_root_nokia_radiobtn = gtk_radio_button_new_with_label(NULL,
1128                 _("on internal memory"));
1129         wizard->data_root_mmc1_radiobtn = gtk_radio_button_new_with_label_from_widget(
1130                 GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
1131                 _("on external memory card"));
1132         wizard->data_root_mmc2_radiobtn = gtk_radio_button_new_with_label_from_widget(
1133                 GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
1134                 _("on internal memory card"));
1135                 
1136         g_signal_connect(G_OBJECT(wizard->data_root_nokia_radiobtn), "toggled",
1137                          G_CALLBACK(data_root_changed), wizard);
1138         g_signal_connect(G_OBJECT(wizard->data_root_mmc1_radiobtn), "toggled",
1139                          G_CALLBACK(data_root_changed), wizard);
1140         g_signal_connect(G_OBJECT(wizard->data_root_mmc2_radiobtn), "toggled",
1141                          G_CALLBACK(data_root_changed), wizard);
1142
1143         wizard->volmon = gnome_vfs_get_volume_monitor();
1144         wizard->vol_mmc1 = gnome_vfs_volume_monitor_get_volume_for_path(wizard->volmon, MMC1_PATH);
1145         wizard->vol_mmc2 = gnome_vfs_volume_monitor_get_volume_for_path(wizard->volmon, MMC2_PATH);
1146
1147         uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc1);
1148         mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1149         g_free(uri);
1150         if (wizard->vol_mmc1 == NULL || !gnome_vfs_volume_is_mounted(wizard->vol_mmc1)
1151             || strcmp(mount_path, MMC1_PATH)) {
1152                 gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, FALSE);
1153         }
1154         g_free(mount_path);
1155
1156         uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc2);
1157         mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1158         g_free(uri);
1159         if (wizard->vol_mmc2 == NULL || !gnome_vfs_volume_is_mounted(wizard->vol_mmc2)
1160             || strcmp(mount_path, MMC2_PATH)) {
1161                 gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, FALSE);
1162         } else {
1163                 gtk_toggle_button_set_active(wizard->data_root_mmc2_radiobtn, TRUE);
1164         }
1165         g_free(mount_path);
1166         
1167         gnome_vfs_volume_unref(wizard->vol_mmc1);
1168         gnome_vfs_volume_unref(wizard->vol_mmc2);
1169         wizard->vol_mmc1 = NULL;
1170         wizard->vol_mmc2 = NULL;
1171
1172         wizard->volmon_mount_sigid = g_signal_connect(G_OBJECT(wizard->volmon), 
1173                                         "volume-mounted", G_CALLBACK(wizard_vol_mount_cb), wizard);
1174         wizard->volmon_unmount_sigid = g_signal_connect(G_OBJECT(wizard->volmon), 
1175                                         "volume-unmounted", G_CALLBACK(wizard_vol_unmount_cb), wizard);
1176
1177         vbox2 = gtk_vbox_new(FALSE, VSPACING_NARROW);
1178         gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_nokia_radiobtn, FALSE, FALSE, 0);
1179         gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_mmc1_radiobtn, FALSE, FALSE, 0);
1180         gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_mmc2_radiobtn, FALSE, FALSE, 0);
1181
1182         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1183         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1184         PACK_BOX(hbox, _("<span weight=\"bold\">Store data</span>"),
1185                  vbox2);
1186 #endif
1187
1188         return table;
1189 }
1190
1191 static void smtp_auth_changed (GtkWidget *btn, gpointer data)
1192 {
1193         WizardWindow *wizard = (WizardWindow *)data;
1194         gboolean do_auth = gtk_toggle_button_get_active(
1195                 GTK_TOGGLE_BUTTON(wizard->smtp_auth));
1196         gtk_widget_set_sensitive(wizard->smtp_username, do_auth);
1197         gtk_widget_set_sensitive(wizard->smtp_username_label, do_auth);
1198         gtk_widget_set_sensitive(wizard->smtp_password, do_auth);
1199         gtk_widget_set_sensitive(wizard->smtp_password_label, do_auth);
1200 }
1201
1202 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1203 static void cert_browse_cb(GtkWidget *widget, gpointer data)
1204 {
1205         GtkEntry *dest = GTK_ENTRY(data);
1206         gchar *filename;
1207         gchar *utf8_filename;
1208
1209         filename = filesel_select_file_open(_("Select certificate file"), NULL);
1210         if (!filename) return;
1211
1212         utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
1213         if (!utf8_filename) {
1214                 g_warning("cert_browse_cb(): failed to convert character set.");
1215                 utf8_filename = g_strdup(filename);
1216         }
1217         gtk_entry_set_text(dest, utf8_filename);
1218         g_free(utf8_filename);
1219 }
1220 #endif
1221
1222 static GtkWidget* smtp_page (WizardWindow * wizard)
1223 {
1224         GtkWidget *table = gtk_table_new(1, 1, FALSE);
1225         GtkWidget *vbox;
1226         GtkWidget *hbox;
1227 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1228         GtkWidget *label;
1229         GtkWidget *button;
1230         GtkWidget *smtp_cert_table;
1231 #endif
1232         gchar *text;
1233         CLAWS_TIP_DECL();
1234         
1235         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1236         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1237
1238         vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1239         gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1240
1241         gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
1242                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
1243
1244         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1245         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1246         wizard->smtp_server = gtk_entry_new();
1247         text = get_default_server(wizard, "smtp");
1248         gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
1249         g_free(text);
1250
1251         CLAWS_SET_TIP(wizard->smtp_server,
1252                              _("You can specify the port number by appending it at the end: "
1253                                "\"mail.example.com:25\""));
1254
1255         PACK_BOX(hbox, _("<span weight=\"bold\">SMTP server address:</span>"),
1256                  wizard->smtp_server);
1257
1258
1259         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1260         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1261         wizard->smtp_auth = gtk_check_button_new_with_label(
1262                                         _("Use authentication"));
1263         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth),
1264                         tmpl.smtpauth);
1265         g_signal_connect(G_OBJECT(wizard->smtp_auth), "toggled",
1266                          G_CALLBACK(smtp_auth_changed),
1267                          wizard);
1268         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_auth, FALSE, FALSE, 0);
1269
1270         text = get_default_smtp_account(wizard);
1271
1272         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1273         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1274         wizard->smtp_username = gtk_entry_new();
1275         gtk_entry_set_text(GTK_ENTRY(wizard->smtp_username), text);
1276         g_free(text);
1277         wizard->smtp_username_label = gtk_label_new(_("SMTP username:\n"
1278                                         "<span size=\"small\">(empty to use the same as receive)</span>"));
1279         gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_username_label), TRUE);
1280         if (GTK_IS_MISC(wizard->smtp_username_label))                                                 
1281                 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_username_label), 1, 0.5);        
1282         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_username_label, FALSE, FALSE, 0);
1283         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_username, TRUE, TRUE, 0);
1284
1285         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1286         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1287         wizard->smtp_password = gtk_entry_new();
1288         gtk_entry_set_text(GTK_ENTRY(wizard->smtp_password), tmpl.smtppass?tmpl.smtppass:""); 
1289         gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_password), FALSE);
1290 #ifdef MAEMO
1291         hildon_gtk_entry_set_input_mode(GTK_ENTRY(wizard->smtp_password), 
1292                 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
1293 #endif
1294         wizard->smtp_password_label = gtk_label_new(_("SMTP password:\n"
1295                                         "<span size=\"small\">(empty to use the same as receive)</span>"));
1296         gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_password_label), TRUE);
1297         if (GTK_IS_MISC(wizard->smtp_password_label))                                                 
1298                 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_password_label), 1, 0.5);        
1299         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password_label, FALSE, FALSE, 0);
1300         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password, TRUE, TRUE, 0);
1301 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1302         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1303         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1304         wizard->smtp_use_ssl = gtk_check_button_new_with_label(
1305                                         _("Use SSL to connect to SMTP server"));
1306         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl),
1307                         tmpl.smtpssl != 0);
1308         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_ssl, FALSE, FALSE, 0);
1309
1310         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1311         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1312         wizard->smtp_use_tls = gtk_check_button_new_with_label(
1313                                         _("Use SSL via STARTTLS"));
1314         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls),
1315                         tmpl.smtpssl == 2);
1316         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_tls, FALSE, FALSE, 0);
1317         SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_use_tls);
1318         
1319         smtp_cert_table = gtk_table_new(3,3, FALSE);
1320         gtk_container_set_border_width(GTK_CONTAINER(smtp_cert_table), 8);
1321         gtk_box_pack_start (GTK_BOX(vbox), smtp_cert_table, FALSE, FALSE, 0);
1322         label = gtk_label_new(_("Client SSL certificate (optional)"));
1323         gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1324         gtk_table_attach(GTK_TABLE(smtp_cert_table), label, 0, 3, 0, 1, GTK_FILL, 0, 0, 0);
1325         label = gtk_label_new(_("File"));
1326         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1327         gtk_table_attach(GTK_TABLE(smtp_cert_table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1328         wizard->smtp_ssl_cert_file = gtk_entry_new();
1329         gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_file), tmpl.smtpssl_cert?tmpl.smtpssl_cert:"");
1330         gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_file, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1331         button = gtkut_get_browse_file_btn(_("Browse"));
1332         gtk_table_attach(GTK_TABLE(smtp_cert_table), button, 2, 3, 1, 2, GTK_FILL, 0, 0, 0);
1333         SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, label);
1334         SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_ssl_cert_file);
1335         SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, button);
1336         g_signal_connect(G_OBJECT(button), "clicked",
1337                          G_CALLBACK(cert_browse_cb), wizard->smtp_ssl_cert_file);
1338
1339         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1340         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1341         label = gtk_label_new(_("Password"));
1342         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1343         gtk_table_attach(GTK_TABLE(smtp_cert_table), label, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
1344         wizard->smtp_ssl_cert_pass = gtk_entry_new();
1345         gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_ssl_cert_pass), FALSE);
1346         gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_pass), tmpl.smtpssl_cert_pass?tmpl.smtpssl_cert_pass:"");
1347         gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_pass, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1348         SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, label);
1349         SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_ssl_cert_pass);
1350         wizard->smtp_cert_table = smtp_cert_table;
1351 #endif
1352         smtp_auth_changed(NULL, wizard);
1353         return table;
1354 }
1355
1356 static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
1357 {
1358         gchar *text;
1359         
1360         if (protocol == A_POP3) {
1361                 text = get_default_server(wizard, "pop");
1362                 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1363                 gtk_widget_hide(wizard->recv_imap_label);
1364                 gtk_widget_hide(wizard->recv_imap_subdir);
1365                 gtk_widget_hide(wizard->subsonly_checkbtn);
1366                 gtk_widget_show(wizard->recv_username);
1367                 gtk_widget_show(wizard->recv_password);
1368                 gtk_widget_show(wizard->recv_username_label);
1369                 gtk_widget_show(wizard->recv_password_label);
1370                 gtk_widget_hide(wizard->no_imap_warning);
1371 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1372                 gtk_widget_show(wizard->recv_use_ssl);
1373                 gtk_widget_show(wizard->recv_use_tls);
1374                 gtk_widget_show(wizard->recv_cert_table);
1375 #endif
1376                 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
1377                 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1378                 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1379                 g_free(text);
1380                 if (wizard->create_mailbox) {
1381                         gtk_widget_show(wizard->mailbox_label);
1382                         gtk_widget_show(wizard->mailbox_name);
1383                 }
1384         } else if (protocol == A_IMAP4) {
1385 #ifdef HAVE_LIBETPAN
1386                 text = get_default_server(wizard, "imap");
1387                 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1388                 gtk_widget_show(wizard->recv_imap_label);
1389                 gtk_widget_show(wizard->recv_imap_subdir);
1390                 gtk_widget_show(wizard->subsonly_checkbtn);
1391                 gtk_widget_show(wizard->recv_username);
1392                 gtk_widget_show(wizard->recv_password);
1393                 gtk_widget_show(wizard->recv_username_label);
1394                 gtk_widget_show(wizard->recv_password_label);
1395                 gtk_widget_hide(wizard->no_imap_warning);
1396 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1397                 gtk_widget_show(wizard->recv_use_ssl);
1398                 gtk_widget_show(wizard->recv_use_tls);
1399                 gtk_widget_show(wizard->recv_cert_table);
1400 #endif
1401                 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
1402                 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1403                 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1404                 g_free(text);
1405                 if (wizard->create_mailbox) {
1406                         gtk_widget_hide(wizard->mailbox_label);
1407                         gtk_widget_hide(wizard->mailbox_name);
1408                 }
1409 #else
1410                 gtk_widget_hide(wizard->recv_imap_label);
1411                 gtk_widget_hide(wizard->recv_imap_subdir);
1412                 gtk_widget_hide(wizard->subsonly_checkbtn);
1413                 gtk_widget_hide(wizard->recv_username);
1414                 gtk_widget_hide(wizard->recv_password);
1415                 gtk_widget_hide(wizard->recv_username_label);
1416                 gtk_widget_hide(wizard->recv_password_label);
1417                 gtk_widget_show(wizard->no_imap_warning);
1418                 if (wizard->create_mailbox) {
1419                         gtk_widget_hide(wizard->mailbox_label);
1420                         gtk_widget_hide(wizard->mailbox_name);
1421                 }
1422 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1423                 gtk_widget_hide(wizard->recv_use_ssl);
1424                 gtk_widget_hide(wizard->recv_use_tls);
1425                 gtk_widget_hide(wizard->recv_cert_table);
1426 #endif
1427                 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, FALSE);
1428 #endif
1429         } else if (protocol == A_LOCAL) {
1430                 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
1431                 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Local mailbox:</span>"));
1432                 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1433                 gtk_widget_hide(wizard->no_imap_warning);
1434                 gtk_widget_hide(wizard->recv_imap_label);
1435                 gtk_widget_hide(wizard->recv_imap_subdir);
1436                 gtk_widget_hide(wizard->subsonly_checkbtn);
1437                 gtk_widget_hide(wizard->recv_username);
1438                 gtk_widget_hide(wizard->recv_password);
1439                 gtk_widget_hide(wizard->recv_username_label);
1440                 gtk_widget_hide(wizard->recv_password_label);
1441 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1442                 gtk_widget_hide(wizard->recv_use_ssl);
1443                 gtk_widget_hide(wizard->recv_use_tls);
1444                 gtk_widget_hide(wizard->recv_cert_table);
1445 #endif
1446                 if (wizard->create_mailbox) {
1447                         gtk_widget_show(wizard->mailbox_label);
1448                         gtk_widget_show(wizard->mailbox_name);
1449                 }
1450                 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1451         }
1452 }
1453
1454 static void wizard_protocol_changed(GtkComboBox *combo, gpointer data)
1455 {
1456         WizardWindow *wizard = (WizardWindow *)data;
1457         RecvProtocol protocol = combobox_get_active_data(combo);
1458
1459         wizard_protocol_change(wizard, protocol);       
1460 }
1461
1462 static GtkWidget* recv_page (WizardWindow * wizard)
1463 {
1464         GtkWidget *table = gtk_table_new(1,1, FALSE);
1465         GtkWidget *vbox;
1466         GtkWidget *hbox;
1467 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1468         GtkWidget *label;
1469         GtkWidget *button;
1470         GtkWidget *recv_cert_table;
1471 #endif
1472         GtkListStore *store;
1473         GtkTreeIter iter;
1474         gchar *text;
1475         gint index = 0;
1476         CLAWS_TIP_DECL();
1477
1478         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1479         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1480
1481         vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1482         gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1483
1484         gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
1485                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
1486
1487         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1488         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1489         wizard->recv_type = gtkut_sc_combobox_create(NULL, FALSE);
1490         store = GTK_LIST_STORE(gtk_combo_box_get_model(
1491                         GTK_COMBO_BOX(wizard->recv_type)));
1492
1493         COMBOBOX_ADD(store, _("POP3"), A_POP3);
1494         COMBOBOX_ADD(store, _("IMAP"), A_IMAP4);
1495         COMBOBOX_ADD(store, _("Local mbox file"), A_LOCAL);
1496
1497         switch(tmpl.recvtype) {
1498         case A_POP3: 
1499                 index = 0;
1500                 break;
1501         case A_IMAP4:
1502                 index = 1;
1503                 break;
1504         case A_LOCAL:
1505                 index = 2;
1506                 break;
1507         default:
1508                 index = 0;
1509         }
1510         gtk_combo_box_set_active(GTK_COMBO_BOX (wizard->recv_type), index);
1511         g_signal_connect(G_OBJECT(wizard->recv_type), "changed",
1512                          G_CALLBACK(wizard_protocol_changed),
1513                          wizard);
1514         PACK_BOX(hbox, _("<span weight=\"bold\">Server type:</span>"),
1515                  wizard->recv_type);
1516
1517         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1518         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1519         wizard->recv_server = gtk_entry_new();
1520         text = get_default_server(wizard, "pop");
1521         gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1522         g_free(text);
1523         
1524         CLAWS_SET_TIP(wizard->recv_server,
1525                              _("You can specify the port number by appending it at the end: "
1526                                "\"mail.example.com:110\""));
1527
1528         wizard->recv_label = gtk_label_new(_("<span weight=\"bold\">Server address:</span>"));
1529         gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1530         if (GTK_IS_MISC(wizard->recv_label))                                                  
1531                 gtk_misc_set_alignment(GTK_MISC(wizard->recv_label), 1, 0.5);         
1532         gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_label, FALSE, FALSE, 0);
1533         gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_server, TRUE, TRUE, 0);
1534         
1535         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1536         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1537         wizard->recv_username = gtk_entry_new();
1538         wizard->recv_username_label = gtk_label_new(_("<span weight=\"bold\">Username:</span>"));
1539         gtk_label_set_use_markup(GTK_LABEL(wizard->recv_username_label), TRUE);
1540         if (GTK_IS_MISC(wizard->recv_username_label))                                                 
1541                 gtk_misc_set_alignment(GTK_MISC(wizard->recv_username_label), 1, 0.5);        
1542         gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_username_label, FALSE, FALSE, 0);
1543         gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_username, TRUE, TRUE, 0);
1544         
1545         text = get_default_account(wizard);
1546         gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
1547         g_free(text);
1548
1549         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1550         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1551         wizard->recv_password = gtk_entry_new();
1552         gtk_entry_set_text(GTK_ENTRY(wizard->recv_password), tmpl.recvpass?tmpl.recvpass:"");
1553         wizard->recv_password_label = gtk_label_new(_("Password:"));
1554         if (GTK_IS_MISC(wizard->recv_password_label))                                                 
1555                 gtk_misc_set_alignment(GTK_MISC(wizard->recv_password_label), 1, 0.5);        
1556         gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_password), FALSE);
1557 #ifdef MAEMO
1558         hildon_gtk_entry_set_input_mode(GTK_ENTRY(wizard->recv_password), 
1559                 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
1560 #endif
1561         gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_password_label, FALSE, FALSE, 0);
1562         gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_password, TRUE, TRUE, 0);
1563         
1564 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1565         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1566         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1567         wizard->recv_use_ssl = gtk_check_button_new_with_label(
1568                                         _("Use SSL to connect to receiving server"));
1569         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl),
1570                         tmpl.recvssl != 0);
1571         gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_ssl, FALSE, FALSE, 0);
1572
1573         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1574         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1575         wizard->recv_use_tls = gtk_check_button_new_with_label(
1576                                         _("Use SSL via STARTTLS"));
1577         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls),
1578                         tmpl.recvssl == 2);
1579         gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_tls, FALSE, FALSE, 0);
1580         SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_use_tls);
1581
1582         recv_cert_table = gtk_table_new(3,3, FALSE);
1583         gtk_container_set_border_width(GTK_CONTAINER(recv_cert_table), 8);
1584         gtk_box_pack_start (GTK_BOX(vbox), recv_cert_table, FALSE, FALSE, 0);
1585         label = gtk_label_new(_("Client SSL certificate (optional)"));
1586         gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1587         gtk_table_attach(GTK_TABLE(recv_cert_table), label, 0, 3, 0, 1, GTK_FILL, 0, 0, 0);
1588         label = gtk_label_new(_("File"));
1589         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1590         gtk_table_attach(GTK_TABLE(recv_cert_table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1591         wizard->recv_ssl_cert_file = gtk_entry_new();
1592         gtk_entry_set_text(GTK_ENTRY(wizard->recv_ssl_cert_file), tmpl.recvssl_cert?tmpl.recvssl_cert:"");
1593         gtk_table_attach(GTK_TABLE(recv_cert_table), wizard->recv_ssl_cert_file, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1594         button = gtkut_get_browse_file_btn(_("Browse"));
1595         gtk_table_attach(GTK_TABLE(recv_cert_table), button, 2, 3, 1, 2, GTK_FILL, 0, 0, 0);
1596         SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, label);
1597         SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_ssl_cert_file);
1598         SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, button);
1599         g_signal_connect(G_OBJECT(button), "clicked",
1600                          G_CALLBACK(cert_browse_cb), wizard->recv_ssl_cert_file);
1601
1602         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1603         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1604         label = gtk_label_new(_("Password"));
1605         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1606         gtk_table_attach(GTK_TABLE(recv_cert_table), label, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
1607         wizard->recv_ssl_cert_pass = gtk_entry_new();
1608         gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_ssl_cert_pass), FALSE);
1609         gtk_entry_set_text(GTK_ENTRY(wizard->recv_ssl_cert_pass), tmpl.recvssl_cert_pass?tmpl.recvssl_cert_pass:"");
1610         gtk_table_attach(GTK_TABLE(recv_cert_table), wizard->recv_ssl_cert_pass, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1611         SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, label);
1612         SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_ssl_cert_pass);
1613         wizard->recv_cert_table = recv_cert_table;
1614 #endif  
1615         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1616         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1617         wizard->recv_imap_subdir = gtk_entry_new();
1618         gtk_entry_set_text(GTK_ENTRY(wizard->recv_imap_subdir), tmpl.imapdir?tmpl.imapdir:"");
1619         wizard->recv_imap_label = gtk_label_new(_("IMAP server directory:"));
1620         if (GTK_IS_MISC(wizard->recv_imap_label))                                                     
1621                 gtk_misc_set_alignment(GTK_MISC(wizard->recv_imap_label), 1, 0.5);            
1622         gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_label, FALSE, FALSE, 0);
1623         gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_subdir, TRUE, TRUE, 0);
1624         
1625         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1626         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1627         wizard->subsonly_checkbtn = gtk_check_button_new_with_label(
1628                         _("Show only subscribed folders"));
1629         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn),
1630                         tmpl.subsonly);
1631         gtk_box_pack_start(GTK_BOX(hbox), wizard->subsonly_checkbtn, FALSE, FALSE, 0);
1632         
1633         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1634         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1635         wizard->no_imap_warning = gtk_label_new(_(
1636                           "<span weight=\"bold\">Warning: this version of Claws Mail\n"
1637                           "has been built without IMAP support.</span>"));
1638         gtk_label_set_use_markup(GTK_LABEL(wizard->no_imap_warning), TRUE);
1639         gtk_box_pack_start(GTK_BOX(hbox), wizard->no_imap_warning, FALSE, FALSE, 0);
1640
1641         return table;
1642 }
1643
1644 static void
1645 wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
1646 {
1647         WizardWindow * wizard = (WizardWindow *)data;
1648         int current_page, num_pages;
1649         gboolean skip_mailbox_page = FALSE;
1650 #ifndef MAEMO
1651         gint protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
1652
1653         if (protocol == A_IMAP4) {
1654                 skip_mailbox_page = TRUE;
1655         }
1656 #endif
1657
1658         num_pages = g_slist_length(wizard->pages);
1659
1660         current_page = gtk_notebook_get_current_page (
1661                                 GTK_NOTEBOOK(wizard->notebook));
1662         if (response == CANCEL)
1663         {
1664                 wizard->result = FALSE;
1665                 wizard->finished = TRUE;
1666                 gtk_widget_destroy (GTK_WIDGET(dialog));
1667         }
1668         else if (response == FINISHED)
1669         {
1670                 if (!wizard_write_config(wizard)) {
1671                         current_page = gtk_notebook_get_current_page (
1672                                         GTK_NOTEBOOK(wizard->notebook));
1673                         goto set_sens;
1674                 }
1675                 wizard->result = TRUE;
1676                 wizard->finished = TRUE;
1677                 gtk_widget_destroy (GTK_WIDGET(dialog));
1678         }
1679         else
1680         {
1681                 if (response == GO_BACK)
1682                 {
1683                         if (current_page > 0) {
1684                                 current_page--;
1685                                 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1686                                         /* mailbox */
1687                                         current_page--;
1688                                 }
1689                                 gtk_notebook_set_current_page (
1690                                         GTK_NOTEBOOK(wizard->notebook), 
1691                                         current_page);
1692                         }
1693                 }
1694                 else if (response == GO_FORWARD)
1695                 {
1696                         if (current_page < (num_pages-1)) {
1697                                 current_page++;
1698                                 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1699                                         /* mailbox */
1700                                         current_page++;
1701                                 }
1702                                 gtk_notebook_set_current_page (
1703                                         GTK_NOTEBOOK(wizard->notebook), 
1704                                         current_page);
1705                         }
1706                 }
1707 set_sens:
1708                 gtk_dialog_set_response_sensitive (dialog, GO_BACK, 
1709                                 current_page > 0);
1710                 gtk_dialog_set_response_sensitive (dialog, GO_FORWARD, 
1711                                 current_page < (num_pages - 1));
1712                 if (current_page == (num_pages -1)) {
1713                         gtk_dialog_set_response_sensitive (dialog, FINISHED, TRUE);
1714                         gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), FINISHED);
1715                 } else {
1716                         gtk_dialog_set_response_sensitive (dialog, FINISHED, FALSE);
1717                         gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), GO_FORWARD);
1718                 }
1719
1720         }
1721 }
1722
1723 static gint wizard_close_cb(GtkWidget *widget, GdkEventAny *event,
1724                                  gpointer data)
1725 {
1726         WizardWindow *wizard = (WizardWindow *)data;
1727         wizard->result = FALSE;
1728         wizard->finished = TRUE;
1729         
1730         return FALSE;
1731 }
1732
1733 #define PACK_WARNING(text) {                                            \
1734         label = gtk_label_new(text);                                    \
1735         gtk_misc_set_alignment(GTK_MISC(label), 0, 0);                  \
1736         gtk_box_pack_end(GTK_BOX(widget), label, FALSE, FALSE, 0);      \
1737 }
1738
1739 gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
1740         WizardWindow *wizard = g_new0(WizardWindow, 1);
1741         GtkWidget *page;
1742         GtkWidget *widget;
1743         GtkWidget *label;
1744         GtkWidget *scrolled_window;
1745         gchar     *text;
1746         GSList    *cur;
1747         gboolean   result;
1748         gint i = 0;
1749         wizard->mainwin = mainwin;
1750         wizard->create_mailbox = create_mailbox;
1751         
1752         gtk_widget_hide(mainwin->window);
1753         
1754         wizard_read_defaults();
1755         
1756         wizard->window = gtk_dialog_new_with_buttons (_("Claws Mail Setup Wizard"),
1757                         NULL, 0, 
1758                         GTK_STOCK_GO_BACK, GO_BACK,
1759                         GTK_STOCK_GO_FORWARD, GO_FORWARD,
1760                         GTK_STOCK_SAVE, FINISHED,
1761                         GTK_STOCK_CANCEL, CANCEL,
1762                         NULL);
1763         gtk_widget_set_size_request(wizard->window, -1, 480);
1764
1765         g_signal_connect(wizard->window, "response", 
1766                           G_CALLBACK(wizard_response_cb), wizard);
1767         gtk_widget_realize(wizard->window);
1768         gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), 
1769                         GO_FORWARD);
1770         gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window), 
1771                         GO_BACK, FALSE);
1772         gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window), 
1773                         GO_FORWARD, TRUE);
1774         gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window), 
1775                         FINISHED, FALSE);
1776         gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window), 
1777                         CANCEL, TRUE);
1778         
1779         wizard->notebook = gtk_notebook_new();
1780         gtk_notebook_set_show_tabs(GTK_NOTEBOOK(wizard->notebook), FALSE);
1781         gtk_notebook_set_show_border(GTK_NOTEBOOK(wizard->notebook), FALSE);
1782         gtk_box_pack_start(GTK_BOX(GTK_DIALOG(wizard->window)->vbox), 
1783                             wizard->notebook, TRUE, TRUE, 0);
1784         
1785         wizard->pages = NULL;
1786         
1787 /*welcome page: 0 */
1788         WELCOME_PAGE = i;
1789         page = create_page(wizard, _("Welcome to Claws Mail"));
1790         
1791         wizard->pages = g_slist_append(wizard->pages, page);
1792         widget = stock_pixmap_widget(wizard->window, 
1793                                 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1794
1795         gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1796         
1797         text = g_strdup(_("Welcome to the Claws Mail setup wizard.\n\n"
1798                           "We will begin by defining some basic "
1799                           "information about you and your most common "
1800                           "mail options so that you can start to use "
1801                           "Claws Mail in less than five minutes."));
1802         widget = gtk_label_new(text);
1803         gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
1804 #ifndef MAEMO
1805         gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1806 #else
1807         scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1808         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1809                                         GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1810         gtk_box_pack_start(GTK_BOX(page), scrolled_window, TRUE, TRUE, 0);
1811
1812         gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1813                                               widget);
1814 #endif
1815         g_free(text);
1816
1817 /* user page: 1 */
1818         i++;
1819         USER_PAGE = i;
1820         widget = create_page (wizard, _("About You"));
1821         scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1822         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1823                                         GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1824         gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1825
1826         gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1827                                               user_page(wizard));
1828         PACK_WARNING(_("Bold fields must be completed"));
1829         
1830         wizard->pages = g_slist_append(wizard->pages, widget);
1831
1832 /* recv+auth page: 2 */
1833         i++;
1834         RECV_PAGE = i;
1835         widget = create_page (wizard, _("Receiving mail"));
1836         scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1837         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1838                                         GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1839         gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1840
1841         gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1842                                               recv_page(wizard));
1843         PACK_WARNING(_("Bold fields must be completed"));
1844         
1845         wizard->pages = g_slist_append(wizard->pages, widget);
1846
1847 /*smtp page: 3 */
1848         i++;
1849         SMTP_PAGE = i;
1850         widget = create_page (wizard, _("Sending mail"));
1851         scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1852         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1853                                         GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1854         gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1855
1856         gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1857                                               smtp_page(wizard));
1858         PACK_WARNING(_("Bold fields must be completed"));
1859         
1860         wizard->pages = g_slist_append(wizard->pages, widget);
1861
1862 /* mailbox page: 4 */
1863         if (create_mailbox) {
1864                 i++;
1865                 MAILBOX_PAGE = i;
1866                 widget = create_page (wizard, _("Saving mail on disk"));
1867                 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1868                 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1869                                         GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1870                 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1871
1872                 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1873                                               mailbox_page(wizard));
1874                 PACK_WARNING(_("Bold fields must be completed"));
1875         
1876                 wizard->pages = g_slist_append(wizard->pages, widget);
1877         }
1878
1879 /* done page: 6 */
1880         i++;
1881         DONE_PAGE = i;
1882         page = create_page(wizard, _("Configuration finished"));
1883         
1884         wizard->pages = g_slist_append(wizard->pages, page);
1885         widget = stock_pixmap_widget(wizard->window, 
1886                                 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1887
1888         gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1889         
1890         text = g_strdup(_("Claws Mail is now ready.\n"
1891                           "Click Save to start."));
1892         widget = gtk_label_new(text);
1893         gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1894         g_free(text);
1895
1896
1897         for (cur = wizard->pages; cur && cur->data; cur = cur->next) {
1898                 gtk_notebook_append_page (GTK_NOTEBOOK(wizard->notebook), 
1899                                           GTK_WIDGET(cur->data), NULL);
1900         }
1901         
1902         g_signal_connect(G_OBJECT(wizard->window), "delete_event",
1903                          G_CALLBACK(wizard_close_cb), wizard);
1904         gtk_widget_show_all (wizard->window);
1905
1906         gtk_widget_hide(wizard->recv_imap_label);
1907         gtk_widget_hide(wizard->recv_imap_subdir);
1908         gtk_widget_hide(wizard->subsonly_checkbtn);
1909
1910         wizard_protocol_change(wizard, tmpl.recvtype);
1911
1912         while (!wizard->finished)
1913                 gtk_main_iteration();
1914
1915         result = wizard->result;
1916         
1917         GTK_EVENTS_FLUSH();
1918
1919         gtk_widget_show(mainwin->window);
1920         g_free(wizard);
1921
1922         return result;
1923 }