root / src / setup.c @ 2537
History | View | Annotate | Download (32.9 kB)
| 1 | /*
|
|---|---|
| 2 | * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client |
| 3 | * Copyright (C) 1999-2010 Hiroyuki Yamamoto |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | */ |
| 19 | |
| 20 | #ifdef HAVE_CONFIG_H
|
| 21 | # include "config.h" |
| 22 | #endif
|
| 23 | |
| 24 | #include <glib.h> |
| 25 | #include <glib/gi18n.h> |
| 26 | #include <gtk/gtk.h> |
| 27 | |
| 28 | #include "inputdialog.h" |
| 29 | #include "alertpanel.h" |
| 30 | #include "mainwindow.h" |
| 31 | #include "folderview.h" |
| 32 | #include "manage_window.h" |
| 33 | #include "account_dialog.h" |
| 34 | #include "gtkutils.h" |
| 35 | #include "filesel.h" |
| 36 | #include "prefs_common.h" |
| 37 | #include "stock_pixmap.h" |
| 38 | #include "account.h" |
| 39 | #if USE_SSL
|
| 40 | # include "ssl.h" |
| 41 | #endif
|
| 42 | |
| 43 | static PangoFontDescription *font_desc;
|
| 44 | |
| 45 | static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data); |
| 46 | |
| 47 | |
| 48 | static void button_toggled(GtkToggleButton *button, GtkWidget *widget) |
| 49 | {
|
| 50 | gboolean is_active; |
| 51 | |
| 52 | is_active = gtk_toggle_button_get_active(button); |
| 53 | gtk_widget_set_sensitive(widget, is_active); |
| 54 | } |
| 55 | |
| 56 | static void sel_btn_clicked(GtkButton *button, GtkWidget *entry) |
| 57 | {
|
| 58 | gchar *folder; |
| 59 | gchar *utf8_folder; |
| 60 | gchar *base; |
| 61 | |
| 62 | folder = filesel_select_dir(NULL);
|
| 63 | if (folder) {
|
| 64 | utf8_folder = conv_filename_to_utf8(folder); |
| 65 | base = g_path_get_basename(utf8_folder); |
| 66 | if (!g_ascii_strcasecmp(base, "Mail")) { |
| 67 | gtk_entry_set_text(GTK_ENTRY(entry), utf8_folder); |
| 68 | } else {
|
| 69 | gchar *text; |
| 70 | |
| 71 | text = g_strconcat(utf8_folder, G_DIR_SEPARATOR_S, "Mail", NULL); |
| 72 | gtk_entry_set_text(GTK_ENTRY(entry), text); |
| 73 | g_free(text); |
| 74 | } |
| 75 | g_free(base); |
| 76 | g_free(utf8_folder); |
| 77 | g_free(folder); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | #ifdef G_OS_WIN32
|
| 82 | #define MODIFY_LABEL_STYLE() \
|
| 83 | { \
|
| 84 | GtkStyle *style; \ |
| 85 | style = gtk_widget_get_style(dialog); \ |
| 86 | gtk_widget_modify_base(label, GTK_STATE_ACTIVE, \ |
| 87 | &style->base[GTK_STATE_SELECTED]); \ |
| 88 | gtk_widget_modify_text(label, GTK_STATE_ACTIVE, \ |
| 89 | &style->text[GTK_STATE_SELECTED]); \ |
| 90 | } |
| 91 | #else
|
| 92 | #define MODIFY_LABEL_STYLE()
|
| 93 | #endif
|
| 94 | |
| 95 | void setup_mailbox(void) |
| 96 | {
|
| 97 | MainWindow *mainwin; |
| 98 | GtkWidget *dialog; |
| 99 | GtkWidget *hbox; |
| 100 | GtkWidget *image; |
| 101 | GtkWidget *vbox; |
| 102 | GtkWidget *label; |
| 103 | GtkWidget *radio; |
| 104 | GtkWidget *entry; |
| 105 | GtkWidget *sel_btn; |
| 106 | GtkWidget *ok_btn; |
| 107 | gchar *path = NULL;
|
| 108 | gchar *fullpath; |
| 109 | Folder *folder; |
| 110 | gint result; |
| 111 | |
| 112 | mainwin = main_window_get(); |
| 113 | manage_window_focus_in(mainwin->window, NULL, NULL); |
| 114 | |
| 115 | dialog = gtk_dialog_new(); |
| 116 | gtk_window_set_title(GTK_WINDOW(dialog), _("Mailbox setting"));
|
| 117 | gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, FALSE, FALSE); |
| 118 | gtk_widget_set_size_request(dialog, 540, -1); |
| 119 | gtk_window_set_position(GTK_WINDOW(dialog), |
| 120 | GTK_WIN_POS_CENTER_ON_PARENT); |
| 121 | gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); |
| 122 | manage_window_set_transient(GTK_WINDOW(dialog)); |
| 123 | gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
| 124 | MANAGE_WINDOW_SIGNALS_CONNECT(dialog); |
| 125 | gtk_widget_realize(dialog); |
| 126 | |
| 127 | hbox = gtk_hbox_new(FALSE, 12);
|
| 128 | gtk_container_set_border_width(GTK_CONTAINER(hbox), 12);
|
| 129 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
| 130 | hbox, FALSE, FALSE, 0);
|
| 131 | |
| 132 | image = stock_pixbuf_widget(dialog, STOCK_PIXMAP_SYLPHEED); |
| 133 | |
| 134 | gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.0); |
| 135 | gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
|
| 136 | |
| 137 | vbox = gtk_vbox_new(FALSE, 12);
|
| 138 | gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
|
| 139 | |
| 140 | label = gtk_label_new(_("Mailbox setting"));
|
| 141 | gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
|
| 142 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); |
| 143 | gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
| 144 | |
| 145 | if (!font_desc) {
|
| 146 | gint size; |
| 147 | |
| 148 | size = pango_font_description_get_size |
| 149 | (label->style->font_desc); |
| 150 | font_desc = pango_font_description_new(); |
| 151 | pango_font_description_set_weight |
| 152 | (font_desc, PANGO_WEIGHT_BOLD); |
| 153 | pango_font_description_set_size |
| 154 | (font_desc, size * PANGO_SCALE_LARGE); |
| 155 | } |
| 156 | if (font_desc)
|
| 157 | gtk_widget_modify_font(label, font_desc); |
| 158 | |
| 159 | label = gtk_label_new(_("This dialog will make initial setup of mailbox."));
|
| 160 | gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
|
| 161 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); |
| 162 | gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
| 163 | gtk_label_set_selectable(GTK_LABEL(label), TRUE); |
| 164 | GTK_WIDGET_UNSET_FLAGS(label, GTK_CAN_FOCUS); |
| 165 | MODIFY_LABEL_STYLE(); |
| 166 | |
| 167 | vbox = gtk_vbox_new(FALSE, 8);
|
| 168 | gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
|
| 169 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), vbox, |
| 170 | TRUE, TRUE, 0);
|
| 171 | |
| 172 | radio = gtk_radio_button_new_with_label |
| 173 | (NULL, _("Create mailbox at the following default location:")); |
| 174 | gtk_box_pack_start(GTK_BOX(vbox), radio, FALSE, FALSE, 0);
|
| 175 | |
| 176 | fullpath = g_strdup_printf("%s%cMail", get_mail_base_dir(),
|
| 177 | G_DIR_SEPARATOR); |
| 178 | |
| 179 | label = gtk_label_new(fullpath); |
| 180 | gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
| 181 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); |
| 182 | gtk_label_set_line_wrap(GTK_LABEL(label), FALSE); |
| 183 | #if GTK_CHECK_VERSION(2, 6, 0) |
| 184 | gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_MIDDLE); |
| 185 | #endif
|
| 186 | gtk_label_set_selectable(GTK_LABEL(label), TRUE); |
| 187 | GTK_WIDGET_UNSET_FLAGS(label, GTK_CAN_FOCUS); |
| 188 | MODIFY_LABEL_STYLE(); |
| 189 | |
| 190 | g_free(fullpath); |
| 191 | |
| 192 | radio = gtk_radio_button_new_with_label_from_widget |
| 193 | (GTK_RADIO_BUTTON(radio), _("Create mailbox at the following location:\n(enter folder name or full folder path)"));
|
| 194 | gtk_box_pack_start(GTK_BOX(vbox), radio, FALSE, FALSE, 0);
|
| 195 | |
| 196 | hbox = gtk_hbox_new(FALSE, 4);
|
| 197 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
| 198 | |
| 199 | entry = gtk_entry_new(); |
| 200 | gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
|
| 201 | |
| 202 | sel_btn = gtk_button_new_with_label("...");
|
| 203 | gtk_box_pack_start(GTK_BOX(hbox), sel_btn, FALSE, FALSE, 0);
|
| 204 | g_signal_connect(G_OBJECT(sel_btn), "clicked",
|
| 205 | G_CALLBACK(sel_btn_clicked), entry); |
| 206 | |
| 207 | gtk_widget_set_sensitive(hbox, FALSE); |
| 208 | g_signal_connect(G_OBJECT(radio), "toggled", G_CALLBACK(button_toggled),
|
| 209 | hbox); |
| 210 | |
| 211 | label = gtk_label_new(_("If you want to add a mailbox at another location afterward, please select 'File - Mailbox - Add mailbox...' in the menu."));
|
| 212 | gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
| 213 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); |
| 214 | gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
| 215 | gtk_label_set_selectable(GTK_LABEL(label), TRUE); |
| 216 | GTK_WIDGET_UNSET_FLAGS(label, GTK_CAN_FOCUS); |
| 217 | MODIFY_LABEL_STYLE(); |
| 218 | |
| 219 | if (prefs_common.comply_gnome_hig) {
|
| 220 | gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); |
| 221 | ok_btn = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_OK, GTK_RESPONSE_OK); |
| 222 | } else {
|
| 223 | ok_btn = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_OK, GTK_RESPONSE_OK); |
| 224 | gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); |
| 225 | } |
| 226 | gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); |
| 227 | gtk_widget_grab_focus(ok_btn); |
| 228 | |
| 229 | gtk_widget_show_all(dialog); |
| 230 | |
| 231 | do {
|
| 232 | result = gtk_dialog_run(GTK_DIALOG(dialog)); |
| 233 | if (result != GTK_RESPONSE_OK) {
|
| 234 | if (alertpanel(_("Cancel"), _("Continue without creating mailbox?"), GTK_STOCK_YES, GTK_STOCK_NO, NULL) == G_ALERTDEFAULT) |
| 235 | break;
|
| 236 | else
|
| 237 | continue;
|
| 238 | } |
| 239 | |
| 240 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio))) {
|
| 241 | path = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); |
| 242 | g_strstrip(path); |
| 243 | if (*path == '\0') { |
| 244 | alertpanel_error(_("Please input folder name or full folder path."));
|
| 245 | g_free(path); |
| 246 | path = NULL;
|
| 247 | } |
| 248 | } else
|
| 249 | path = g_strdup("Mail");
|
| 250 | |
| 251 | if (path) {
|
| 252 | if (folder_find_from_path(path)) {
|
| 253 | alertpanel_error(_("The mailbox '%s' already exists."), path);
|
| 254 | g_warning("The mailbox '%s' already exists.", path);
|
| 255 | g_free(path); |
| 256 | path = NULL;
|
| 257 | } else if (is_path_parent(path, get_rc_dir()) || |
| 258 | is_path_parent(path, get_mail_base_dir())) {
|
| 259 | alertpanel_error(_("The location '%s' includes settings folder. Please specify another location."), path);
|
| 260 | g_warning("The location '%s' includes settings folder.", path);
|
| 261 | g_free(path); |
| 262 | path = NULL;
|
| 263 | } |
| 264 | } |
| 265 | } while (path == NULL); |
| 266 | |
| 267 | gtk_widget_destroy(dialog); |
| 268 | if (path == NULL) |
| 269 | return;
|
| 270 | |
| 271 | if (!strcmp(g_basename(path), "Mail")) |
| 272 | folder = folder_new(F_MH, _("Mailbox"), path);
|
| 273 | else
|
| 274 | folder = folder_new(F_MH, g_basename(path), path); |
| 275 | g_free(path); |
| 276 | |
| 277 | if (folder->klass->create_tree(folder) < 0) { |
| 278 | alertpanel_error(_("Creation of the mailbox failed.\n"
|
| 279 | "Maybe some files already exist, or you don't have the permission to write there."));
|
| 280 | folder_destroy(folder); |
| 281 | return;
|
| 282 | } |
| 283 | |
| 284 | folder_add(folder); |
| 285 | folder_set_ui_func(folder, scan_tree_func, mainwin); |
| 286 | folder->klass->scan_tree(folder); |
| 287 | folder_set_ui_func(folder, NULL, NULL); |
| 288 | |
| 289 | folderview_set(mainwin->folderview); |
| 290 | } |
| 291 | |
| 292 | static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data) |
| 293 | {
|
| 294 | MainWindow *mainwin = (MainWindow *)data; |
| 295 | gchar *str; |
| 296 | |
| 297 | if (item->path)
|
| 298 | str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
|
| 299 | LOCAL_FOLDER(folder)->rootpath, |
| 300 | G_DIR_SEPARATOR, |
| 301 | item->path); |
| 302 | else
|
| 303 | str = g_strdup_printf(_("Scanning folder %s ..."),
|
| 304 | LOCAL_FOLDER(folder)->rootpath); |
| 305 | |
| 306 | gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), |
| 307 | mainwin->mainwin_cid, str); |
| 308 | gtkut_widget_draw_now(mainwin->statusbar); |
| 309 | gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), |
| 310 | mainwin->mainwin_cid); |
| 311 | g_free(str); |
| 312 | } |
| 313 | |
| 314 | static struct |
| 315 | {
|
| 316 | GtkWidget *dialog; |
| 317 | GtkWidget *notebook; |
| 318 | GtkWidget *prev_btn; |
| 319 | GtkWidget *next_btn; |
| 320 | GtkWidget *cancel_btn; |
| 321 | GtkWidget *pop3_radio; |
| 322 | GtkWidget *imap_radio; |
| 323 | #if USE_SSL
|
| 324 | GtkWidget *pop3g_radio; |
| 325 | GtkWidget *imapg_radio; |
| 326 | #endif
|
| 327 | GtkWidget *name_entry; |
| 328 | GtkWidget *addr_entry; |
| 329 | GtkWidget *id_entry; |
| 330 | GtkWidget *serv_entry; |
| 331 | GtkWidget *smtp_entry; |
| 332 | GtkWidget *smtpauth_chkbtn; |
| 333 | #if USE_SSL
|
| 334 | GtkWidget *servssl_chkbtn; |
| 335 | GtkWidget *smtpssl_chkbtn; |
| 336 | #endif
|
| 337 | GtkWidget *serv_label_name1; |
| 338 | GtkWidget *serv_label_name2; |
| 339 | GtkWidget *name_label; |
| 340 | GtkWidget *addr_label; |
| 341 | GtkWidget *id_label; |
| 342 | GtkWidget *serv_label; |
| 343 | GtkWidget *smtp_label; |
| 344 | gboolean finished; |
| 345 | gboolean cancelled; |
| 346 | |
| 347 | gint type; |
| 348 | gchar *name; |
| 349 | gchar *addr; |
| 350 | gchar *userid; |
| 351 | gchar *serv; |
| 352 | gchar *smtpserv; |
| 353 | gushort serv_port; |
| 354 | gushort smtp_port; |
| 355 | #if USE_SSL
|
| 356 | gboolean serv_ssl; |
| 357 | gboolean smtp_ssl; |
| 358 | #endif
|
| 359 | gboolean smtp_auth; |
| 360 | } setupac; |
| 361 | |
| 362 | enum
|
| 363 | {
|
| 364 | SETUP_PAGE_START, |
| 365 | SETUP_PAGE_ADDRESS, |
| 366 | SETUP_PAGE_ACCOUNT, |
| 367 | SETUP_PAGE_FINISH |
| 368 | }; |
| 369 | |
| 370 | enum
|
| 371 | {
|
| 372 | SETUP_TYPE_POP3, |
| 373 | SETUP_TYPE_IMAP, |
| 374 | #if USE_SSL
|
| 375 | SETUP_TYPE_POP3G, |
| 376 | SETUP_TYPE_IMAPG |
| 377 | #endif
|
| 378 | }; |
| 379 | |
| 380 | #define GMAIL_POP3_SERVER "pop.gmail.com" |
| 381 | #define GMAIL_IMAP_SERVER "imap.gmail.com" |
| 382 | #define GMAIL_SMTP_SERVER "smtp.gmail.com" |
| 383 | #define POP3_PORT 110 |
| 384 | #define IMAP_PORT 143 |
| 385 | #define SMTP_PORT 25 |
| 386 | #define POP3S_PORT 995 |
| 387 | #define IMAPS_PORT 993 |
| 388 | #define SMTPS_PORT 465 |
| 389 | |
| 390 | static void entry_changed(GtkEditable *editable, gpointer data) |
| 391 | {
|
| 392 | const gchar *name, *addr, *userid, *serv, *smtp;
|
| 393 | gint page; |
| 394 | gboolean next_enable = FALSE; |
| 395 | |
| 396 | page = gtk_notebook_get_current_page(GTK_NOTEBOOK(setupac.notebook)); |
| 397 | if (page != SETUP_PAGE_ADDRESS && page != SETUP_PAGE_ACCOUNT)
|
| 398 | return;
|
| 399 | |
| 400 | name = gtk_entry_get_text(GTK_ENTRY(setupac.name_entry)); |
| 401 | addr = gtk_entry_get_text(GTK_ENTRY(setupac.addr_entry)); |
| 402 | userid = gtk_entry_get_text(GTK_ENTRY(setupac.id_entry)); |
| 403 | serv = gtk_entry_get_text(GTK_ENTRY(setupac.serv_entry)); |
| 404 | smtp = gtk_entry_get_text(GTK_ENTRY(setupac.smtp_entry)); |
| 405 | |
| 406 | #if USE_SSL
|
| 407 | if (setupac.type == SETUP_TYPE_POP3G ||
|
| 408 | setupac.type == SETUP_TYPE_IMAPG) {
|
| 409 | if (GTK_WIDGET(editable) == setupac.addr_entry)
|
| 410 | gtk_entry_set_text(GTK_ENTRY(setupac.id_entry), addr); |
| 411 | } |
| 412 | #endif
|
| 413 | |
| 414 | if (page == SETUP_PAGE_ADDRESS && name && *name && addr && *addr)
|
| 415 | next_enable = TRUE; |
| 416 | else if (page == SETUP_PAGE_ACCOUNT && |
| 417 | userid && *userid && serv && *serv && smtp && *smtp) |
| 418 | next_enable = TRUE; |
| 419 | |
| 420 | gtk_dialog_set_response_sensitive(GTK_DIALOG(setupac.dialog), |
| 421 | GTK_RESPONSE_ACCEPT, next_enable); |
| 422 | } |
| 423 | |
| 424 | static gboolean entry_is_valid(GtkWidget *entry)
|
| 425 | {
|
| 426 | const gchar *str, *p;
|
| 427 | guchar c; |
| 428 | |
| 429 | p = str = gtk_entry_get_text(GTK_ENTRY(entry)); |
| 430 | if (!str || *p == '\0') |
| 431 | return FALSE;
|
| 432 | if (!strcmp(str, "(username)@gmail.com")) |
| 433 | return FALSE;
|
| 434 | |
| 435 | while (*p) {
|
| 436 | c = *p; |
| 437 | if (g_ascii_isspace(c) || c < 32 || c > 127) |
| 438 | return FALSE;
|
| 439 | p++; |
| 440 | } |
| 441 | |
| 442 | return TRUE;
|
| 443 | } |
| 444 | |
| 445 | #define GET_STR(s, m) \
|
| 446 | { \
|
| 447 | setupac.s = gtk_editable_get_chars(GTK_EDITABLE(setupac.m), 0, -1); \ |
| 448 | g_strstrip(setupac.s); \ |
| 449 | } |
| 450 | |
| 451 | static void setup_account_response_cb(GtkDialog *dialog, gint response_id, |
| 452 | gpointer data) |
| 453 | {
|
| 454 | gint page, prev_page; |
| 455 | gboolean next_enable = TRUE; |
| 456 | gboolean prev_enable = TRUE; |
| 457 | gchar buf[1024];
|
| 458 | |
| 459 | prev_page = page = |
| 460 | gtk_notebook_get_current_page(GTK_NOTEBOOK(setupac.notebook)); |
| 461 | |
| 462 | if (response_id == GTK_RESPONSE_CANCEL ||
|
| 463 | response_id == GTK_RESPONSE_DELETE_EVENT) {
|
| 464 | if (page == SETUP_PAGE_FINISH) {
|
| 465 | setupac.finished = TRUE; |
| 466 | } else {
|
| 467 | if (alertpanel(_("Cancel"), _("Cancel mail account setup?"), GTK_STOCK_YES, GTK_STOCK_NO, NULL) == G_ALERTDEFAULT) { |
| 468 | setupac.finished = TRUE; |
| 469 | setupac.cancelled = TRUE; |
| 470 | } |
| 471 | return;
|
| 472 | } |
| 473 | } else if (response_id == GTK_RESPONSE_ACCEPT) { |
| 474 | if (prev_page == SETUP_PAGE_ADDRESS) {
|
| 475 | if (entry_is_valid(setupac.addr_entry)) {
|
| 476 | #if USE_SSL
|
| 477 | if (setupac.type == SETUP_TYPE_POP3G ||
|
| 478 | setupac.type == SETUP_TYPE_IMAPG) |
| 479 | gtk_notebook_set_current_page |
| 480 | (GTK_NOTEBOOK(setupac.notebook), |
| 481 | SETUP_PAGE_FINISH); |
| 482 | else
|
| 483 | #endif
|
| 484 | gtk_notebook_set_current_page |
| 485 | (GTK_NOTEBOOK(setupac.notebook), page + 1);
|
| 486 | } else
|
| 487 | alertpanel_error(_("Input value is not valid."));
|
| 488 | } else if (prev_page == SETUP_PAGE_ACCOUNT) { |
| 489 | if (entry_is_valid(setupac.id_entry) &&
|
| 490 | entry_is_valid(setupac.serv_entry) && |
| 491 | entry_is_valid(setupac.smtp_entry)) |
| 492 | gtk_notebook_set_current_page |
| 493 | (GTK_NOTEBOOK(setupac.notebook), page + 1);
|
| 494 | else
|
| 495 | alertpanel_error(_("Input value is not valid."));
|
| 496 | } else {
|
| 497 | gtk_notebook_set_current_page |
| 498 | (GTK_NOTEBOOK(setupac.notebook), page + 1);
|
| 499 | } |
| 500 | |
| 501 | if (prev_page == SETUP_PAGE_START) {
|
| 502 | setupac.type = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(setupac.pop3_radio)) ? SETUP_TYPE_POP3 |
| 503 | : gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(setupac.imap_radio)) ? SETUP_TYPE_IMAP |
| 504 | #if USE_SSL
|
| 505 | : gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(setupac.pop3g_radio)) ? SETUP_TYPE_POP3G |
| 506 | : gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(setupac.imapg_radio)) ? SETUP_TYPE_IMAPG |
| 507 | #endif
|
| 508 | : SETUP_TYPE_POP3; |
| 509 | } |
| 510 | } else if (response_id == GTK_RESPONSE_REJECT) { |
| 511 | gtk_notebook_set_current_page(GTK_NOTEBOOK(setupac.notebook), |
| 512 | page - 1);
|
| 513 | } else {
|
| 514 | g_warning("setup_account_response_cb: invalid response_id: %d\n", response_id);
|
| 515 | } |
| 516 | |
| 517 | page = gtk_notebook_get_current_page(GTK_NOTEBOOK(setupac.notebook)); |
| 518 | |
| 519 | if (page == SETUP_PAGE_START)
|
| 520 | prev_enable = FALSE; |
| 521 | else if (page == SETUP_PAGE_ADDRESS || page == SETUP_PAGE_ACCOUNT) { |
| 522 | switch (setupac.type) {
|
| 523 | case SETUP_TYPE_POP3:
|
| 524 | gtk_widget_set_sensitive(setupac.id_entry, TRUE); |
| 525 | gtk_label_set_text(GTK_LABEL(setupac.serv_label_name1), _("POP3 server:"));
|
| 526 | gtk_widget_set_sensitive(setupac.serv_entry, TRUE); |
| 527 | gtk_widget_set_sensitive(setupac.smtp_entry, TRUE); |
| 528 | break;
|
| 529 | case SETUP_TYPE_IMAP:
|
| 530 | gtk_widget_set_sensitive(setupac.id_entry, TRUE); |
| 531 | gtk_label_set_text(GTK_LABEL(setupac.serv_label_name1), _("IMAP4 server:"));
|
| 532 | gtk_widget_set_sensitive(setupac.serv_entry, TRUE); |
| 533 | gtk_widget_set_sensitive(setupac.smtp_entry, TRUE); |
| 534 | break;
|
| 535 | #if USE_SSL
|
| 536 | case SETUP_TYPE_POP3G:
|
| 537 | if (prev_page == SETUP_PAGE_START)
|
| 538 | gtk_entry_set_text(GTK_ENTRY(setupac.addr_entry), "(username)@gmail.com");
|
| 539 | gtk_widget_set_sensitive(setupac.id_entry, FALSE); |
| 540 | gtk_label_set_text(GTK_LABEL(setupac.serv_label_name1), _("POP3 server:"));
|
| 541 | gtk_entry_set_text(GTK_ENTRY(setupac.serv_entry), GMAIL_POP3_SERVER); |
| 542 | gtk_widget_set_sensitive(setupac.serv_entry, FALSE); |
| 543 | gtk_entry_set_text(GTK_ENTRY(setupac.smtp_entry), GMAIL_SMTP_SERVER); |
| 544 | gtk_widget_set_sensitive(setupac.smtp_entry, FALSE); |
| 545 | break;
|
| 546 | case SETUP_TYPE_IMAPG:
|
| 547 | if (prev_page == SETUP_PAGE_START)
|
| 548 | gtk_entry_set_text(GTK_ENTRY(setupac.addr_entry), "(username)@gmail.com");
|
| 549 | gtk_widget_set_sensitive(setupac.id_entry, FALSE); |
| 550 | gtk_label_set_text(GTK_LABEL(setupac.serv_label_name1), _("IMAP4 server:"));
|
| 551 | gtk_entry_set_text(GTK_ENTRY(setupac.serv_entry), GMAIL_IMAP_SERVER); |
| 552 | gtk_widget_set_sensitive(setupac.serv_entry, FALSE); |
| 553 | gtk_entry_set_text(GTK_ENTRY(setupac.smtp_entry), GMAIL_SMTP_SERVER); |
| 554 | gtk_widget_set_sensitive(setupac.smtp_entry, FALSE); |
| 555 | break;
|
| 556 | #endif /* USE_SSL */ |
| 557 | } |
| 558 | } else if (page == SETUP_PAGE_FINISH) { |
| 559 | prev_enable = FALSE; |
| 560 | next_enable = FALSE; |
| 561 | gtk_button_set_label(GTK_BUTTON(setupac.cancel_btn), |
| 562 | GTK_STOCK_CLOSE); |
| 563 | |
| 564 | switch (setupac.type) {
|
| 565 | case SETUP_TYPE_POP3:
|
| 566 | #if USE_SSL
|
| 567 | setupac.serv_ssl = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(setupac.servssl_chkbtn)); |
| 568 | setupac.smtp_ssl = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(setupac.smtpssl_chkbtn)); |
| 569 | setupac.serv_port = setupac.serv_ssl ? POP3S_PORT : POP3_PORT; |
| 570 | setupac.smtp_port = setupac.smtp_ssl ? SMTPS_PORT : SMTP_PORT; |
| 571 | #else /* !USE_SSL */ |
| 572 | setupac.serv_port = POP3_PORT; |
| 573 | setupac.smtp_port = SMTP_PORT; |
| 574 | #endif /* USE_SSL */ |
| 575 | setupac.smtp_auth = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(setupac.smtpauth_chkbtn)); |
| 576 | gtk_label_set_text(GTK_LABEL(setupac.serv_label_name2), _("POP3 server:"));
|
| 577 | break;
|
| 578 | case SETUP_TYPE_IMAP:
|
| 579 | #if USE_SSL
|
| 580 | setupac.serv_ssl = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(setupac.servssl_chkbtn)); |
| 581 | setupac.smtp_ssl = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(setupac.smtpssl_chkbtn)); |
| 582 | setupac.serv_port = setupac.serv_ssl ? IMAPS_PORT : IMAP_PORT; |
| 583 | setupac.smtp_port = setupac.smtp_ssl ? SMTPS_PORT : SMTP_PORT; |
| 584 | #else /* !USE_SSL */ |
| 585 | setupac.serv_port = IMAP_PORT; |
| 586 | setupac.smtp_port = SMTP_PORT; |
| 587 | #endif /* USE_SSL */ |
| 588 | setupac.smtp_auth = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(setupac.smtpauth_chkbtn)); |
| 589 | gtk_label_set_text(GTK_LABEL(setupac.serv_label_name2), _("IMAP4 server:"));
|
| 590 | break;
|
| 591 | #if USE_SSL
|
| 592 | case SETUP_TYPE_POP3G:
|
| 593 | setupac.serv_ssl = TRUE; |
| 594 | setupac.smtp_ssl = TRUE; |
| 595 | setupac.smtp_auth = TRUE; |
| 596 | setupac.serv_port = POP3S_PORT; |
| 597 | setupac.smtp_port = SMTPS_PORT; |
| 598 | gtk_label_set_text(GTK_LABEL(setupac.serv_label_name2), _("POP3 server:"));
|
| 599 | break;
|
| 600 | case SETUP_TYPE_IMAPG:
|
| 601 | setupac.serv_ssl = TRUE; |
| 602 | setupac.smtp_ssl = TRUE; |
| 603 | setupac.smtp_auth = TRUE; |
| 604 | setupac.serv_port = IMAPS_PORT; |
| 605 | setupac.smtp_port = SMTPS_PORT; |
| 606 | gtk_label_set_text(GTK_LABEL(setupac.serv_label_name2), _("IMAP4 server:"));
|
| 607 | break;
|
| 608 | #endif /* USE_SSL */ |
| 609 | } |
| 610 | |
| 611 | GET_STR(name, name_entry); |
| 612 | GET_STR(addr, addr_entry); |
| 613 | GET_STR(userid, id_entry); |
| 614 | GET_STR(serv, serv_entry); |
| 615 | GET_STR(smtpserv, smtp_entry); |
| 616 | gtk_label_set_text(GTK_LABEL(setupac.name_label), setupac.name); |
| 617 | gtk_label_set_text(GTK_LABEL(setupac.addr_label), setupac.addr); |
| 618 | gtk_label_set_text(GTK_LABEL(setupac.id_label), setupac.userid); |
| 619 | #if USE_SSL
|
| 620 | if (setupac.serv_ssl)
|
| 621 | g_snprintf(buf, sizeof(buf), "%s:%u (SSL)", |
| 622 | setupac.serv, setupac.serv_port); |
| 623 | else
|
| 624 | #endif
|
| 625 | g_snprintf(buf, sizeof(buf), "%s:%u", |
| 626 | setupac.serv, setupac.serv_port); |
| 627 | gtk_label_set_text(GTK_LABEL(setupac.serv_label), buf); |
| 628 | #if USE_SSL
|
| 629 | if (setupac.smtp_ssl)
|
| 630 | g_snprintf(buf, sizeof(buf), "%s:%u (SSL)", |
| 631 | setupac.smtpserv, setupac.smtp_port); |
| 632 | else
|
| 633 | #endif
|
| 634 | g_snprintf(buf, sizeof(buf), "%s:%u", |
| 635 | setupac.smtpserv, setupac.smtp_port); |
| 636 | gtk_label_set_text(GTK_LABEL(setupac.smtp_label), buf); |
| 637 | } |
| 638 | |
| 639 | gtk_dialog_set_response_sensitive(GTK_DIALOG(setupac.dialog), |
| 640 | GTK_RESPONSE_REJECT, prev_enable); |
| 641 | gtk_dialog_set_response_sensitive(GTK_DIALOG(setupac.dialog), |
| 642 | GTK_RESPONSE_ACCEPT, next_enable); |
| 643 | |
| 644 | if (page == SETUP_PAGE_ADDRESS || page == SETUP_PAGE_ACCOUNT)
|
| 645 | entry_changed(GTK_EDITABLE(setupac.addr_entry), NULL);
|
| 646 | } |
| 647 | |
| 648 | PrefsAccount *setup_account(void)
|
| 649 | {
|
| 650 | MainWindow *mainwin; |
| 651 | GtkWidget *dialog; |
| 652 | GtkWidget *hbox; |
| 653 | GtkWidget *image; |
| 654 | GtkWidget *vbox; |
| 655 | GtkWidget *vbox2; |
| 656 | GtkWidget *label; |
| 657 | GtkWidget *table; |
| 658 | GtkWidget *chkbtn; |
| 659 | gint result; |
| 660 | PrefsAccount *ac; |
| 661 | |
| 662 | mainwin = main_window_get(); |
| 663 | manage_window_focus_in(mainwin->window, NULL, NULL); |
| 664 | |
| 665 | dialog = gtk_dialog_new_with_buttons(_("New account setup"), NULL, GTK_DIALOG_MODAL, NULL); |
| 666 | setupac.dialog = dialog; |
| 667 | |
| 668 | setupac.prev_btn = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_GO_BACK, GTK_RESPONSE_REJECT); |
| 669 | setupac.next_btn = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_GO_FORWARD, GTK_RESPONSE_ACCEPT); |
| 670 | setupac.cancel_btn = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); |
| 671 | |
| 672 | gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, FALSE, FALSE); |
| 673 | gtk_widget_set_size_request(dialog, 540, -1); |
| 674 | gtk_window_set_position(GTK_WINDOW(dialog), |
| 675 | GTK_WIN_POS_CENTER_ON_PARENT); |
| 676 | //gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
|
| 677 | manage_window_set_transient(GTK_WINDOW(dialog)); |
| 678 | gtk_dialog_set_has_separator(GTK_DIALOG(dialog), TRUE); |
| 679 | gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); |
| 680 | gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), |
| 681 | GTK_RESPONSE_REJECT, FALSE); |
| 682 | MANAGE_WINDOW_SIGNALS_CONNECT(dialog); |
| 683 | gtk_widget_realize(dialog); |
| 684 | |
| 685 | g_signal_connect(dialog, "response",
|
| 686 | G_CALLBACK(setup_account_response_cb), NULL);
|
| 687 | |
| 688 | hbox = gtk_hbox_new(FALSE, 12);
|
| 689 | gtk_container_set_border_width(GTK_CONTAINER(hbox), 12);
|
| 690 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
| 691 | hbox, FALSE, FALSE, 0);
|
| 692 | |
| 693 | image = stock_pixbuf_widget(dialog, STOCK_PIXMAP_SYLPHEED); |
| 694 | |
| 695 | gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.0); |
| 696 | gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
|
| 697 | |
| 698 | vbox = gtk_vbox_new(FALSE, 12);
|
| 699 | gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
|
| 700 | |
| 701 | label = gtk_label_new(_("New account setup"));
|
| 702 | gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
|
| 703 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); |
| 704 | gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
| 705 | |
| 706 | if (!font_desc) {
|
| 707 | gint size; |
| 708 | |
| 709 | size = pango_font_description_get_size |
| 710 | (label->style->font_desc); |
| 711 | font_desc = pango_font_description_new(); |
| 712 | pango_font_description_set_weight |
| 713 | (font_desc, PANGO_WEIGHT_BOLD); |
| 714 | pango_font_description_set_size |
| 715 | (font_desc, size * PANGO_SCALE_LARGE); |
| 716 | } |
| 717 | if (font_desc)
|
| 718 | gtk_widget_modify_font(label, font_desc); |
| 719 | |
| 720 | label = gtk_label_new(_("This dialog will make initial setup of new mail account."));
|
| 721 | gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
|
| 722 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); |
| 723 | gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
| 724 | gtk_label_set_selectable(GTK_LABEL(label), TRUE); |
| 725 | GTK_WIDGET_UNSET_FLAGS(label, GTK_CAN_FOCUS); |
| 726 | MODIFY_LABEL_STYLE(); |
| 727 | |
| 728 | vbox = gtk_vbox_new(FALSE, 8);
|
| 729 | gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
|
| 730 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), vbox, |
| 731 | TRUE, TRUE, 0);
|
| 732 | |
| 733 | setupac.notebook = gtk_notebook_new(); |
| 734 | gtk_notebook_set_show_border(GTK_NOTEBOOK(setupac.notebook), FALSE); |
| 735 | gtk_notebook_set_show_tabs(GTK_NOTEBOOK(setupac.notebook), FALSE); |
| 736 | gtk_box_pack_start(GTK_BOX(vbox), setupac.notebook, TRUE, TRUE, 0);
|
| 737 | |
| 738 | /* Page 1 */
|
| 739 | vbox = gtk_vbox_new(FALSE, 12);
|
| 740 | gtk_notebook_append_page(GTK_NOTEBOOK(setupac.notebook), vbox, NULL);
|
| 741 | gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
|
| 742 | |
| 743 | label = gtk_label_new(_("Select account type:"));
|
| 744 | gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 8);
|
| 745 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); |
| 746 | |
| 747 | setupac.pop3_radio = gtk_radio_button_new_with_label(NULL, "POP3"); |
| 748 | gtk_box_pack_start(GTK_BOX(vbox), setupac.pop3_radio, FALSE, FALSE, 0);
|
| 749 | setupac.imap_radio = gtk_radio_button_new_with_label_from_widget |
| 750 | (GTK_RADIO_BUTTON(setupac.pop3_radio), "IMAP4");
|
| 751 | gtk_box_pack_start(GTK_BOX(vbox), setupac.imap_radio, FALSE, FALSE, 0);
|
| 752 | #if USE_SSL
|
| 753 | setupac.pop3g_radio = gtk_radio_button_new_with_label_from_widget |
| 754 | (GTK_RADIO_BUTTON(setupac.pop3_radio), "POP3 (Gmail)");
|
| 755 | gtk_box_pack_start(GTK_BOX(vbox), setupac.pop3g_radio, FALSE, FALSE, 0);
|
| 756 | setupac.imapg_radio = gtk_radio_button_new_with_label_from_widget |
| 757 | (GTK_RADIO_BUTTON(setupac.pop3_radio), "IMAP4 (Gmail)");
|
| 758 | gtk_box_pack_start(GTK_BOX(vbox), setupac.imapg_radio, FALSE, FALSE, 0);
|
| 759 | #endif
|
| 760 | |
| 761 | /* Page 2 */
|
| 762 | vbox = gtk_vbox_new(FALSE, 12);
|
| 763 | gtk_notebook_append_page(GTK_NOTEBOOK(setupac.notebook), vbox, NULL);
|
| 764 | gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
|
| 765 | |
| 766 | label = gtk_label_new(_("Input your name and mail address:"));
|
| 767 | gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 8);
|
| 768 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); |
| 769 | |
| 770 | table = gtk_table_new(4, 2, FALSE); |
| 771 | gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
|
| 772 | gtk_table_set_row_spacings(GTK_TABLE(table), 8);
|
| 773 | gtk_table_set_col_spacings(GTK_TABLE(table), 8);
|
| 774 | |
| 775 | label = gtk_label_new(_("Display name:"));
|
| 776 | gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, |
| 777 | GTK_FILL, GTK_FILL, 0, 0); |
| 778 | gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
| 779 | label = gtk_label_new(_("E-mail address:"));
|
| 780 | gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, |
| 781 | GTK_FILL, GTK_FILL, 0, 0); |
| 782 | gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
| 783 | |
| 784 | setupac.name_entry = gtk_entry_new(); |
| 785 | gtk_table_attach(GTK_TABLE(table), setupac.name_entry, 1, 2, 0, 1, |
| 786 | GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0); |
| 787 | g_signal_connect(setupac.name_entry, "changed",
|
| 788 | G_CALLBACK(entry_changed), NULL);
|
| 789 | setupac.addr_entry = gtk_entry_new(); |
| 790 | gtk_table_attach(GTK_TABLE(table), setupac.addr_entry, 1, 2, 3, 4, |
| 791 | GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0); |
| 792 | g_signal_connect(setupac.addr_entry, "changed",
|
| 793 | G_CALLBACK(entry_changed), NULL);
|
| 794 | |
| 795 | label = gtk_label_new(_("This name will be seen at the side of recipients (e.g. John Doe)"));
|
| 796 | gtk_table_attach(GTK_TABLE(table), label, 1, 2, 1, 2, |
| 797 | GTK_FILL, GTK_FILL, 0, 0); |
| 798 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| 799 | |
| 800 | /* Page 3 */
|
| 801 | vbox = gtk_vbox_new(FALSE, 12);
|
| 802 | gtk_notebook_append_page(GTK_NOTEBOOK(setupac.notebook), vbox, NULL);
|
| 803 | gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
|
| 804 | gtk_widget_show_all(dialog); |
| 805 | |
| 806 | label = gtk_label_new(_("Input user ID and mail server:"));
|
| 807 | gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 8);
|
| 808 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); |
| 809 | |
| 810 | table = gtk_table_new(6, 2, FALSE); |
| 811 | gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
|
| 812 | gtk_table_set_row_spacings(GTK_TABLE(table), 8);
|
| 813 | gtk_table_set_col_spacings(GTK_TABLE(table), 8);
|
| 814 | |
| 815 | label = gtk_label_new(_("User ID:"));
|
| 816 | gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, |
| 817 | GTK_FILL, GTK_FILL, 0, 0); |
| 818 | gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
| 819 | label = gtk_label_new(_("POP3 server:"));
|
| 820 | gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, |
| 821 | GTK_FILL, GTK_FILL, 0, 0); |
| 822 | gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
| 823 | setupac.serv_label_name1 = label; |
| 824 | label = gtk_label_new(_("SMTP server:"));
|
| 825 | gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, |
| 826 | GTK_FILL, GTK_FILL, 0, 0); |
| 827 | gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
| 828 | |
| 829 | setupac.id_entry = gtk_entry_new(); |
| 830 | gtk_table_attach(GTK_TABLE(table), setupac.id_entry, 1, 2, 0, 1, |
| 831 | GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0); |
| 832 | g_signal_connect(setupac.id_entry, "changed",
|
| 833 | G_CALLBACK(entry_changed), NULL);
|
| 834 | setupac.serv_entry = gtk_entry_new(); |
| 835 | gtk_table_attach(GTK_TABLE(table), setupac.serv_entry, 1, 2, 1, 2, |
| 836 | GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0); |
| 837 | g_signal_connect(setupac.serv_entry, "changed",
|
| 838 | G_CALLBACK(entry_changed), NULL);
|
| 839 | setupac.smtp_entry = gtk_entry_new(); |
| 840 | gtk_table_attach(GTK_TABLE(table), setupac.smtp_entry, 1, 2, 4, 5, |
| 841 | GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0); |
| 842 | g_signal_connect(setupac.smtp_entry, "changed",
|
| 843 | G_CALLBACK(entry_changed), NULL);
|
| 844 | |
| 845 | #if USE_SSL
|
| 846 | hbox = gtk_hbox_new(FALSE, 12);
|
| 847 | gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 2, 3, |
| 848 | GTK_FILL, GTK_FILL, 0, 0); |
| 849 | chkbtn = gtk_check_button_new_with_mnemonic(_("Use SSL"));
|
| 850 | gtk_box_pack_start(GTK_BOX(hbox), chkbtn, FALSE, FALSE, 0);
|
| 851 | setupac.servssl_chkbtn = chkbtn; |
| 852 | #endif
|
| 853 | |
| 854 | hbox = gtk_hbox_new(FALSE, 12);
|
| 855 | gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 5, 6, |
| 856 | GTK_FILL, GTK_FILL, 0, 0); |
| 857 | chkbtn = gtk_check_button_new_with_mnemonic(_("Use SMTP authentication"));
|
| 858 | gtk_box_pack_start(GTK_BOX(hbox), chkbtn, FALSE, FALSE, 0);
|
| 859 | setupac.smtpauth_chkbtn = chkbtn; |
| 860 | #if USE_SSL
|
| 861 | chkbtn = gtk_check_button_new_with_mnemonic(_("Use SSL"));
|
| 862 | gtk_box_pack_start(GTK_BOX(hbox), chkbtn, FALSE, FALSE, 0);
|
| 863 | setupac.smtpssl_chkbtn = chkbtn; |
| 864 | #endif
|
| 865 | |
| 866 | /* Page 4 */
|
| 867 | vbox = gtk_vbox_new(FALSE, 12);
|
| 868 | gtk_notebook_append_page(GTK_NOTEBOOK(setupac.notebook), vbox, NULL);
|
| 869 | gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
|
| 870 | |
| 871 | vbox2 = gtk_vbox_new(FALSE, 8);
|
| 872 | gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, FALSE, 8);
|
| 873 | |
| 874 | label = gtk_label_new(_("Your new mail account has been set up with the following settings."));
|
| 875 | gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
|
| 876 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); |
| 877 | label = gtk_label_new(_("If you want to modify the settings, select\n"
|
| 878 | "'Configuration - Preferences for current account' or\n"
|
| 879 | "'Configuration - Edit accounts' in the main menu."));
|
| 880 | gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
|
| 881 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); |
| 882 | //gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
|
| 883 | |
| 884 | table = gtk_table_new(5, 2, FALSE); |
| 885 | gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
|
| 886 | gtk_table_set_row_spacings(GTK_TABLE(table), 8);
|
| 887 | gtk_table_set_col_spacings(GTK_TABLE(table), 8);
|
| 888 | |
| 889 | label = gtk_label_new(_("Display name:"));
|
| 890 | gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, |
| 891 | GTK_FILL, GTK_FILL, 0, 0); |
| 892 | gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
| 893 | label = gtk_label_new(_("E-mail address:"));
|
| 894 | gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, |
| 895 | GTK_FILL, GTK_FILL, 0, 0); |
| 896 | gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
| 897 | label = gtk_label_new(_("User ID:"));
|
| 898 | gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, |
| 899 | GTK_FILL, GTK_FILL, 0, 0); |
| 900 | gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
| 901 | setupac.serv_label_name2 = gtk_label_new(_("POP3 server:"));
|
| 902 | gtk_table_attach(GTK_TABLE(table), setupac.serv_label_name2, 0, 1, 3, 4, |
| 903 | GTK_FILL, GTK_FILL, 0, 0); |
| 904 | gtk_misc_set_alignment(GTK_MISC(setupac.serv_label_name2), 1, 0.5); |
| 905 | label = gtk_label_new(_("SMTP server:"));
|
| 906 | gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, |
| 907 | GTK_FILL, GTK_FILL, 0, 0); |
| 908 | gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
| 909 | |
| 910 | setupac.name_label = gtk_label_new("");
|
| 911 | gtk_table_attach(GTK_TABLE(table), setupac.name_label, 1, 2, 0, 1, |
| 912 | GTK_FILL, GTK_FILL, 0, 0); |
| 913 | gtk_misc_set_alignment(GTK_MISC(setupac.name_label), 0, 0.5); |
| 914 | setupac.addr_label = gtk_label_new("");
|
| 915 | gtk_table_attach(GTK_TABLE(table), setupac.addr_label, 1, 2, 1, 2, |
| 916 | GTK_FILL, GTK_FILL, 0, 0); |
| 917 | gtk_misc_set_alignment(GTK_MISC(setupac.addr_label), 0, 0.5); |
| 918 | setupac.id_label = gtk_label_new("");
|
| 919 | gtk_table_attach(GTK_TABLE(table), setupac.id_label, 1, 2, 2, 3, |
| 920 | GTK_FILL, GTK_FILL, 0, 0); |
| 921 | gtk_misc_set_alignment(GTK_MISC(setupac.id_label), 0, 0.5); |
| 922 | setupac.serv_label = gtk_label_new("");
|
| 923 | gtk_table_attach(GTK_TABLE(table), setupac.serv_label, 1, 2, 3, 4, |
| 924 | GTK_FILL, GTK_FILL, 0, 0); |
| 925 | gtk_misc_set_alignment(GTK_MISC(setupac.serv_label), 0, 0.5); |
| 926 | setupac.smtp_label = gtk_label_new("");
|
| 927 | gtk_table_attach(GTK_TABLE(table), setupac.smtp_label, 1, 2, 4, 5, |
| 928 | GTK_FILL, GTK_FILL, 0, 0); |
| 929 | gtk_misc_set_alignment(GTK_MISC(setupac.smtp_label), 0, 0.5); |
| 930 | |
| 931 | |
| 932 | gtk_widget_show_all(dialog); |
| 933 | |
| 934 | while (!setupac.finished)
|
| 935 | result = gtk_dialog_run(GTK_DIALOG(dialog)); |
| 936 | |
| 937 | gtk_widget_destroy(dialog); |
| 938 | |
| 939 | if (setupac.cancelled) {
|
| 940 | memset(&setupac, 0, sizeof(setupac)); |
| 941 | return NULL; |
| 942 | } |
| 943 | |
| 944 | /* Create account */
|
| 945 | ac = prefs_account_new(); |
| 946 | |
| 947 | if (!cur_account) {
|
| 948 | account_set_as_default(ac); |
| 949 | cur_account = ac; |
| 950 | } |
| 951 | g_free(ac->account_name); |
| 952 | ac->account_name = g_strdup(setupac.addr); |
| 953 | g_free(ac->name); |
| 954 | ac->name = g_strdup(setupac.name); |
| 955 | g_free(ac->address); |
| 956 | ac->address = g_strdup(setupac.addr); |
| 957 | g_free(ac->recv_server); |
| 958 | ac->recv_server = g_strdup(setupac.serv); |
| 959 | g_free(ac->smtp_server); |
| 960 | ac->smtp_server = g_strdup(setupac.smtpserv); |
| 961 | g_free(ac->userid); |
| 962 | ac->userid = g_strdup(setupac.userid); |
| 963 | #if USE_SSL
|
| 964 | if (setupac.smtp_ssl)
|
| 965 | ac->ssl_smtp = SSL_TUNNEL; |
| 966 | #endif
|
| 967 | ac->smtpport = setupac.smtp_port; |
| 968 | ac->use_smtp_auth = setupac.smtp_auth; |
| 969 | |
| 970 | switch (setupac.type) {
|
| 971 | case SETUP_TYPE_POP3:
|
| 972 | ac->protocol = A_POP3; |
| 973 | #if USE_SSL
|
| 974 | if (setupac.serv_ssl)
|
| 975 | ac->ssl_pop = SSL_TUNNEL; |
| 976 | #endif
|
| 977 | ac->popport = setupac.serv_port; |
| 978 | break;
|
| 979 | case SETUP_TYPE_IMAP:
|
| 980 | ac->protocol = A_IMAP4; |
| 981 | #if USE_SSL
|
| 982 | if (setupac.serv_ssl)
|
| 983 | ac->ssl_imap = SSL_TUNNEL; |
| 984 | #endif
|
| 985 | ac->imapport = setupac.serv_port; |
| 986 | break;
|
| 987 | #if USE_SSL
|
| 988 | case SETUP_TYPE_POP3G:
|
| 989 | ac->protocol = A_POP3; |
| 990 | ac->ssl_pop = SSL_TUNNEL; |
| 991 | ac->popport = setupac.serv_port; |
| 992 | break;
|
| 993 | case SETUP_TYPE_IMAPG:
|
| 994 | ac->protocol = A_IMAP4; |
| 995 | ac->ssl_imap = SSL_TUNNEL; |
| 996 | ac->imapport = setupac.serv_port; |
| 997 | break;
|
| 998 | #endif /* USE_SSL */ |
| 999 | } |
| 1000 | |
| 1001 | g_free(ac->sig_text); |
| 1002 | ac->sig_text = g_strdup_printf("%s <%s>\\n", ac->name, ac->address);
|
| 1003 | |
| 1004 | account_update_lock(); |
| 1005 | account_append(ac); |
| 1006 | account_write_config_all(); |
| 1007 | account_update_unlock(); |
| 1008 | account_updated(); |
| 1009 | |
| 1010 | g_free(setupac.name); |
| 1011 | g_free(setupac.addr); |
| 1012 | g_free(setupac.serv); |
| 1013 | g_free(setupac.smtpserv); |
| 1014 | g_free(setupac.userid); |
| 1015 | memset(&setupac, 0, sizeof(setupac)); |
| 1016 | |
| 1017 | return ac;
|
| 1018 | } |