/*
* Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 Colin Leroy <colin@colino.net>
+ * Copyright (C) 1999-2013 Colin Leroy <colin@colino.net>
* and the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
#ifdef HAVE_CONFIG_H
# include "config.h"
+#include "claws-features.h"
#endif
#include "defs.h"
#include <string.h>
#include <ctype.h>
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "utils.h"
#include "gtk/menu.h"
#include "plugin.h"
#include "prefs_common.h"
#include "combobox.h"
-#ifdef MAEMO
-#include <libgnomevfs/gnome-vfs-volume.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#endif
-
typedef enum
{
GO_BACK,
GtkWidget *smtp_cert_table;
GtkWidget *recv_cert_table;
#endif
-
-#ifdef MAEMO
- GtkWidget *data_root_nokia_radiobtn;
- GtkWidget *data_root_mmc1_radiobtn;
- GtkWidget *data_root_mmc2_radiobtn;
- GnomeVFSVolumeMonitor *volmon;
- gulong volmon_mount_sigid;
- gulong volmon_unmount_sigid;
- GnomeVFSVolume *vol_mmc1;
- GnomeVFSVolume *vol_mmc2;
-#endif
+#if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
+ GtkWidget *auto_configure_lbl;
+ GtkWidget *auto_configure_btn;
+ GtkWidget *auto_configure_cancel_btn;
+#endif
gboolean create_mailbox;
gboolean finished;
gboolean result;
get_rfc822_date(buf_date, sizeof(buf_date));
conv_encode_header_full(enc_subject, sizeof(enc_subject),
- Q_("Welcome Mail Subject|Welcome to Claws Mail"),
+ C_("Welcome Mail Subject", "Welcome to Claws Mail"),
strlen("Subject: "), FALSE, CS_INTERNAL);
conv_encode_header_full(enc_to_name, sizeof(enc_to_name),
gtk_entry_get_text(GTK_ENTRY(wizard->full_name)),
return FALSE;
}
-#ifdef MAEMO
- if (wizard->create_mailbox) {
- g_free(prefs_common.data_root);
- if (gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn)))
- prefs_common.data_root = NULL;
- else if (gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn)))
- prefs_common.data_root = g_strdup(MMC1_PATH);
- else if (gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn)))
- prefs_common.data_root = g_strdup(MMC2_PATH);
- }
-#endif
-
if (!mailbox_ok) {
if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
mailbox_ok = setup_write_mailbox_path(wizard->mainwin,
if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
write_welcome_email(wizard);
-#ifdef MAEMO
- if (wizard->volmon_mount_sigid)
- g_signal_handler_disconnect(
- G_OBJECT(wizard->volmon),
- wizard->volmon_mount_sigid);
- if (wizard->volmon_unmount_sigid)
- g_signal_handler_disconnect(
- G_OBJECT(wizard->volmon),
- wizard->volmon_unmount_sigid);
-#endif
-
#ifndef G_OS_WIN32
plugin_load_standard_plugins();
#endif
return table;
}
-#ifdef MAEMO
-static void wizard_vol_mount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
-{
- gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
- gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
- g_free (uri);
- if (mount_path) {
- if(!strcmp(mount_path, MMC1_PATH)) {
- gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, TRUE);
- }
- if(!strcmp(mount_path, MMC2_PATH)) {
- gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, TRUE);
- }
- }
- g_free(mount_path);
-}
-static void wizard_vol_unmount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
-{
- gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
- gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
- g_free (uri);
- if (mount_path) {
- if(!strcmp(mount_path, MMC1_PATH)) {
- gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, FALSE);
- if (gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn))) {
- gtk_toggle_button_set_active(
- GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn), TRUE);
- }
- }
- if(!strcmp(mount_path, MMC2_PATH)) {
- gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, FALSE);
- if (gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn))) {
- gtk_toggle_button_set_active(
- GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn), TRUE);
- }
- }
- }
- g_free(mount_path);
-}
-
-void data_root_changed (GtkToggleButton *toggle_btn,
- WizardWindow *wizard)
-{
- gchar *name = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
- gchar *path = NULL;
- if (gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn)))
- gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), name);
- else if (gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn))) {
- path = g_strconcat(MMC1_PATH, G_DIR_SEPARATOR_S,
- "Claws", G_DIR_SEPARATOR_S,
- g_get_user_name(), G_DIR_SEPARATOR_S,
- name, NULL);
- gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
- g_free(path);
- } else if (gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn))) {
- path = g_strconcat(MMC2_PATH, G_DIR_SEPARATOR_S,
- "Claws", G_DIR_SEPARATOR_S,
- g_get_user_name(), G_DIR_SEPARATOR_S,
- name, NULL);
- gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
- g_free(path);
- }
- g_free(name);
-}
-#endif
-
static GtkWidget* mailbox_page (WizardWindow * wizard)
{
GtkWidget *table = gtk_table_new(1,1, FALSE);
GtkWidget *vbox;
-#ifdef MAEMO
- GtkWidget *vbox2;
- gchar *uri, *mount_path;
-#endif
GtkWidget *hbox;
gtk_table_set_row_spacings(GTK_TABLE(table), 4);
gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_name, TRUE, TRUE, 0);
-#ifdef MAEMO
- wizard->data_root_nokia_radiobtn = gtk_radio_button_new_with_label(NULL,
- _("on internal memory"));
- wizard->data_root_mmc1_radiobtn = gtk_radio_button_new_with_label_from_widget(
- GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
- _("on external memory card"));
- wizard->data_root_mmc2_radiobtn = gtk_radio_button_new_with_label_from_widget(
- GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
- _("on internal memory card"));
-
- g_signal_connect(G_OBJECT(wizard->data_root_nokia_radiobtn), "toggled",
- G_CALLBACK(data_root_changed), wizard);
- g_signal_connect(G_OBJECT(wizard->data_root_mmc1_radiobtn), "toggled",
- G_CALLBACK(data_root_changed), wizard);
- g_signal_connect(G_OBJECT(wizard->data_root_mmc2_radiobtn), "toggled",
- G_CALLBACK(data_root_changed), wizard);
-
- wizard->volmon = gnome_vfs_get_volume_monitor();
- wizard->vol_mmc1 = gnome_vfs_volume_monitor_get_volume_for_path(wizard->volmon, MMC1_PATH);
- wizard->vol_mmc2 = gnome_vfs_volume_monitor_get_volume_for_path(wizard->volmon, MMC2_PATH);
-
- uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc1);
- mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
- g_free(uri);
- if (wizard->vol_mmc1 == NULL || !gnome_vfs_volume_is_mounted(wizard->vol_mmc1)
- || strcmp(mount_path, MMC1_PATH)) {
- gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, FALSE);
- }
- g_free(mount_path);
-
- uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc2);
- mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
- g_free(uri);
- if (wizard->vol_mmc2 == NULL || !gnome_vfs_volume_is_mounted(wizard->vol_mmc2)
- || strcmp(mount_path, MMC2_PATH)) {
- gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, FALSE);
- } else {
- gtk_toggle_button_set_active(wizard->data_root_mmc2_radiobtn, TRUE);
- }
- g_free(mount_path);
-
- gnome_vfs_volume_unref(wizard->vol_mmc1);
- gnome_vfs_volume_unref(wizard->vol_mmc2);
- wizard->vol_mmc1 = NULL;
- wizard->vol_mmc2 = NULL;
-
- wizard->volmon_mount_sigid = g_signal_connect(G_OBJECT(wizard->volmon),
- "volume-mounted", G_CALLBACK(wizard_vol_mount_cb), wizard);
- wizard->volmon_unmount_sigid = g_signal_connect(G_OBJECT(wizard->volmon),
- "volume-unmounted", G_CALLBACK(wizard_vol_unmount_cb), wizard);
-
- vbox2 = gtk_vbox_new(FALSE, VSPACING_NARROW);
- gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_nokia_radiobtn, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_mmc1_radiobtn, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_mmc2_radiobtn, FALSE, FALSE, 0);
-
- hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
- gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
- PACK_BOX(hbox, _("<span weight=\"bold\">Store data</span>"), vbox2);
-#endif
-
return table;
}
wizard->smtp_password = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(wizard->smtp_password), tmpl.smtppass?tmpl.smtppass:"");
gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_password), FALSE);
-#ifdef MAEMO
- hildon_gtk_entry_set_input_mode(GTK_ENTRY(wizard->smtp_password),
- HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
-#endif
gtk_table_attach(GTK_TABLE(smtp_auth_table), wizard->smtp_password, 1,2,1,2,
GTK_EXPAND|GTK_FILL, 0, 0, 0);
#ifdef USE_GNUTLS
gtk_widget_show(wizard->recv_use_ssl);
gtk_widget_show(wizard->recv_use_tls);
gtk_widget_show(wizard->recv_cert_table);
+#endif
+#if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
+ gtk_widget_show(wizard->auto_configure_btn);
+ gtk_widget_hide(wizard->auto_configure_cancel_btn);
+ gtk_widget_show(wizard->auto_configure_lbl);
#endif
gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
gtk_widget_show(wizard->recv_use_ssl);
gtk_widget_show(wizard->recv_use_tls);
gtk_widget_show(wizard->recv_cert_table);
+#endif
+#if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
+ gtk_widget_show(wizard->auto_configure_btn);
+ gtk_widget_hide(wizard->auto_configure_cancel_btn);
+ gtk_widget_show(wizard->auto_configure_lbl);
#endif
gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
gtk_widget_hide(wizard->recv_password);
gtk_widget_hide(wizard->recv_username_label);
gtk_widget_hide(wizard->recv_password_label);
+#if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
+ gtk_widget_hide(wizard->auto_configure_btn);
+ gtk_widget_hide(wizard->auto_configure_cancel_btn);
+ gtk_widget_hide(wizard->auto_configure_lbl);
+#endif
#ifdef USE_GNUTLS
gtk_widget_hide(wizard->recv_use_ssl);
gtk_widget_hide(wizard->recv_use_tls);
wizard_protocol_change(wizard, protocol);
}
+#if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
+static void auto_configure_cb (GtkWidget *widget, gpointer data)
+{
+ gchar *address = NULL;
+ const gchar *domain = NULL;
+ AutoConfigureData *recv_data;
+ AutoConfigureData *send_data;
+ static GCancellable *recv_cancel = NULL;
+ static GCancellable *send_cancel = NULL;
+ WizardWindow *wizard = (WizardWindow *)data;
+ RecvProtocol protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
+
+ if (!recv_cancel) {
+ recv_cancel = g_cancellable_new();
+ send_cancel = g_cancellable_new();
+ }
+
+ if (widget == wizard->auto_configure_cancel_btn) {
+ g_cancellable_cancel(recv_cancel);
+ g_cancellable_cancel(send_cancel);
+ g_object_unref(recv_cancel);
+ g_object_unref(send_cancel);
+ recv_cancel = NULL;
+ send_cancel = NULL;
+ return;
+ }
+
+ address = gtk_editable_get_chars(GTK_EDITABLE(wizard->email), 0, -1);
+
+ if (strchr(address, '@') < 0) {
+ g_free(address);
+ gtk_label_set_text(GTK_LABEL(wizard->auto_configure_lbl),
+ _("Failed (wrong address)"));
+ }
+ domain = strchr(address, '@') + 1;
+
+ if (protocol == A_POP3 || protocol == A_IMAP4) {
+ recv_data = g_new0(AutoConfigureData, 1);
+ recv_data->configure_button = GTK_BUTTON(wizard->auto_configure_btn);
+ recv_data->cancel_button = GTK_BUTTON(wizard->auto_configure_cancel_btn);
+ recv_data->info_label = GTK_LABEL(wizard->auto_configure_lbl);
+ recv_data->cancel = recv_cancel;
+ switch(protocol) {
+ case A_POP3:
+ recv_data->ssl_service = "pop3s";
+ recv_data->tls_service = "pop3";
+ recv_data->domain = g_strdup(domain);
+ recv_data->hostname_entry = GTK_ENTRY(wizard->recv_server);
+ recv_data->set_port = NULL;
+ recv_data->port = NULL;
+ recv_data->tls_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_tls);
+ recv_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_ssl);
+ recv_data->default_port = 110;
+ recv_data->default_ssl_port = 995;
+ break;
+ case A_IMAP4:
+ recv_data->ssl_service = "imaps";
+ recv_data->tls_service = "imap";
+ recv_data->domain = g_strdup(domain);
+ recv_data->hostname_entry = GTK_ENTRY(wizard->recv_server);
+ recv_data->set_port = NULL;
+ recv_data->port = NULL;
+ recv_data->tls_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_tls);
+ recv_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_ssl);
+ recv_data->default_port = 143;
+ recv_data->default_ssl_port = 993;
+ break;
+ default:
+ cm_return_if_fail(FALSE);
+ }
+ auto_configure_service(recv_data);
+ }
+
+ send_data = g_new0(AutoConfigureData, 1);
+ send_data->configure_button = GTK_BUTTON(wizard->auto_configure_btn);
+ send_data->cancel_button = GTK_BUTTON(wizard->auto_configure_cancel_btn);
+ send_data->info_label = GTK_LABEL(wizard->auto_configure_lbl);
+ send_data->cancel = send_cancel;
+
+ send_data->ssl_service = NULL;
+ send_data->tls_service = "submission";
+ send_data->domain = g_strdup(domain);
+ send_data->hostname_entry = GTK_ENTRY(wizard->smtp_server);
+ send_data->set_port = NULL;
+ send_data->port = NULL;
+ send_data->tls_checkbtn = GTK_TOGGLE_BUTTON(wizard->smtp_use_tls);
+ send_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl);
+ send_data->default_port = 25;
+ send_data->default_ssl_port = -1;
+ send_data->auth_checkbtn = wizard->smtp_auth;
+
+ auto_configure_service(send_data);
+
+ g_free(address);
+}
+#endif
+
static GtkWidget* recv_page (WizardWindow * wizard)
{
GtkWidget *table = gtk_table_new(1,1, FALSE);
#ifdef USE_GNUTLS
GtkWidget *button;
GtkWidget *recv_cert_table;
+#endif
+#if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
+ GtkWidget *auto_configure_btn;
+ GtkWidget *auto_configure_cancel_btn;
+ GtkWidget *auto_configure_lbl;
#endif
GtkListStore *store;
GtkTreeIter iter;
GTK_EXPAND|GTK_FILL, 0, 0, 0);
recv_table = gtk_table_new(4, 2, FALSE);
+
+#if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
+ hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+ auto_configure_btn = gtk_button_new_with_label(_("Auto-configure"));
+ gtk_box_pack_start(GTK_BOX (hbox), auto_configure_btn, FALSE, FALSE, 0);
+ auto_configure_cancel_btn = gtk_button_new_with_label(_("Cancel"));
+ gtk_box_pack_start(GTK_BOX (hbox), auto_configure_cancel_btn, FALSE, FALSE, 0);
+ auto_configure_lbl = gtk_label_new("");
+ gtk_label_set_justify(GTK_LABEL(auto_configure_lbl), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start(GTK_BOX (hbox), auto_configure_lbl, FALSE, FALSE, 0);
+ gtk_widget_show(auto_configure_btn);
+ gtk_widget_show(auto_configure_lbl);
+ gtk_widget_show(hbox);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+ wizard->auto_configure_lbl = auto_configure_lbl;
+ wizard->auto_configure_btn = auto_configure_btn;
+ wizard->auto_configure_cancel_btn = auto_configure_cancel_btn;
+ g_signal_connect (G_OBJECT (auto_configure_btn), "clicked",
+ G_CALLBACK (auto_configure_cb), wizard);
+ g_signal_connect (G_OBJECT (auto_configure_cancel_btn), "clicked",
+ G_CALLBACK (auto_configure_cb), wizard);
+#endif
gtk_box_pack_start(GTK_BOX(vbox), recv_table, FALSE, FALSE, 0);
+
label = gtk_label_new(_("<span weight=\"bold\">Server type:</span>"));
gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
gtk_entry_set_text(GTK_ENTRY(wizard->recv_password), tmpl.recvpass?tmpl.recvpass:"");
gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_password), FALSE);
gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_password, 1,2,3,4,
- GTK_EXPAND|GTK_FILL, 0, 0, 0);
-#ifdef MAEMO
- hildon_gtk_entry_set_input_mode(GTK_ENTRY(wizard->recv_password),
- HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
-#endif
-
+ GTK_EXPAND|GTK_FILL, 0, 0, 0);
#ifdef USE_GNUTLS
hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
WizardWindow * wizard = (WizardWindow *)data;
int current_page, num_pages;
gboolean skip_mailbox_page = FALSE;
-#ifndef MAEMO
gint protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
if (protocol == A_IMAP4) {
skip_mailbox_page = TRUE;
}
-#endif
num_pages = g_slist_length(wizard->pages);
"Claws Mail in less than five minutes."));
widget = gtk_label_new(text);
gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
-#ifndef MAEMO
gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
-#else
- scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start(GTK_BOX(page), scrolled_window, TRUE, TRUE, 0);
-
- gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
- widget);
-#endif
g_free(text);
/* user page: 1 */
gtk_widget_hide(wizard->recv_imap_label);
gtk_widget_hide(wizard->recv_imap_subdir);
gtk_widget_hide(wizard->subsonly_checkbtn);
-
+#if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
+ gtk_widget_hide(wizard->auto_configure_cancel_btn);
+#endif
wizard_protocol_change(wizard, tmpl.recvtype);
while (!wizard->finished)