diff options
Diffstat (limited to 'mail/em-account-editor.c')
-rw-r--r-- | mail/em-account-editor.c | 626 |
1 files changed, 458 insertions, 168 deletions
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c index f2d93a7363..6c674465fe 100644 --- a/mail/em-account-editor.c +++ b/mail/em-account-editor.c @@ -51,21 +51,22 @@ #include <libgnomeui/gnome-druid.h> #include <libgnomeui/gnome-druid-page-standard.h> -#include <libedataserver/e-account-list.h> -#include <e-util/e-signature-list.h> - +#include "shell/e-shell.h" #include "e-util/e-error.h" +#include "e-util/e-account-utils.h" +#include "e-util/e-signature-list.h" +#include "e-util/e-signature-utils.h" #include "e-util/e-util-private.h" +#include "widgets/misc/e-signature-editor.h" +#include "e-mail-local.h" +#include "e-mail-store.h" #include "em-config.h" #include "em-folder-selection-button.h" #include "em-account-editor.h" #include "mail-session.h" #include "mail-send-recv.h" -#include "mail-signature-editor.h" -#include "mail-component.h" #include "em-utils.h" -#include "em-composer-prefs.h" #include "mail-config.h" #include "mail-ops.h" #include "mail-mt.h" @@ -74,6 +75,10 @@ #include "smime/gui/e-cert-selector.h" #endif +#define EM_ACCOUNT_EDITOR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), EM_TYPE_ACCOUNT_EDITOR, EMAccountEditorPrivate)) + #define d(x) /* econfig item for the extra config hings */ @@ -128,6 +133,10 @@ typedef struct _EMAccountEditorService { } EMAccountEditorService; struct _EMAccountEditorPrivate { + + EAccount *modified_account; + EAccount *original_account; + struct _EMConfig *config; GList *providers; @@ -188,53 +197,186 @@ struct _EMAccountEditorPrivate { guint management_set:1; }; +enum { + PROP_0, + PROP_MODIFIED_ACCOUNT, + PROP_ORIGINAL_ACCOUNT, + PROP_SHELL +}; + static void emae_refresh_authtype (EMAccountEditor *emae, EMAccountEditorService *service); -static void em_account_editor_construct (EMAccountEditor *emae, EAccount *account, em_account_editor_t type, const gchar *id); +static void em_account_editor_construct (EMAccountEditor *emae, EMAccountEditorType type, const gchar *id); static void emae_account_folder_changed (EMFolderSelectionButton *folder, EMAccountEditor *emae); -static GtkVBoxClass *emae_parent; + +static gpointer parent_class; static void -emae_init (GObject *o) +emae_set_original_account (EMAccountEditor *emae, + EAccount *original_account) { - EMAccountEditor *emae = (EMAccountEditor *)o; + EAccount *modified_account; - emae->priv = g_malloc0(sizeof (*emae->priv)); + g_return_if_fail (emae->priv->original_account == NULL); - emae->priv->source.emae = emae; - emae->priv->transport.emae = emae; + /* Editing an existing account. */ + if (original_account != NULL) { + gchar *xml; + + xml = e_account_to_xml (original_account); + modified_account = e_account_new_from_xml (xml); + g_free (xml); + + g_object_ref (original_account); + emae->do_signature = TRUE; + + /* Creating a new account. */ + } else { + modified_account = e_account_new (); + modified_account->enabled = TRUE; + + e_account_set_string ( + modified_account, E_ACCOUNT_DRAFTS_FOLDER_URI, + e_mail_local_get_folder_uri (E_MAIL_FOLDER_DRAFTS)); + + e_account_set_string ( + modified_account, E_ACCOUNT_SENT_FOLDER_URI, + e_mail_local_get_folder_uri (E_MAIL_FOLDER_SENT)); + } + + emae->priv->original_account = original_account; + emae->priv->modified_account = modified_account; } static void -emae_finalise (GObject *o) +emae_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) { - EMAccountEditor *emae = (EMAccountEditor *)o; - EMAccountEditorPrivate *p = emae->priv; + switch (property_id) { + case PROP_ORIGINAL_ACCOUNT: + emae_set_original_account ( + EM_ACCOUNT_EDITOR (object), + g_value_get_object (value)); + return; + } - if (p->sig_added_id) { - ESignatureList *signatures = mail_config_get_signatures (); + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} - g_signal_handler_disconnect (signatures, p->sig_added_id); - g_signal_handler_disconnect (signatures, p->sig_removed_id); - g_signal_handler_disconnect (signatures, p->sig_changed_id); +static void +emae_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_MODIFIED_ACCOUNT: + g_value_set_object ( + value, + em_account_editor_get_modified_account ( + EM_ACCOUNT_EDITOR (object))); + return; + + case PROP_ORIGINAL_ACCOUNT: + g_value_set_object ( + value, + em_account_editor_get_original_account ( + EM_ACCOUNT_EDITOR (object))); + return; } - g_list_free (p->source.authtypes); - g_list_free (p->transport.authtypes); + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +emae_dispose (GObject *object) +{ + EMAccountEditorPrivate *priv; - g_list_free (p->providers); - g_free (p); + priv = EM_ACCOUNT_EDITOR_GET_PRIVATE (object); - g_object_unref (emae->account); - if (emae->original) - g_object_unref (emae->original); + if (priv->modified_account != NULL) { + g_object_unref (priv->modified_account); + priv->modified_account = NULL; + } - ((GObjectClass *)emae_parent)->finalize (o); + if (priv->original_account != NULL) { + g_object_unref (priv->original_account); + priv->original_account = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); } static void -emae_class_init (GObjectClass *klass) +emae_finalize (GObject *object) { - klass->finalize = emae_finalise; + EMAccountEditor *emae = EM_ACCOUNT_EDITOR (object); + EMAccountEditorPrivate *priv = emae->priv; + + if (priv->sig_added_id) { + ESignatureList *signatures; + + signatures = e_get_signature_list (); + g_signal_handler_disconnect (signatures, priv->sig_added_id); + g_signal_handler_disconnect (signatures, priv->sig_removed_id); + g_signal_handler_disconnect (signatures, priv->sig_changed_id); + } + + g_list_free (priv->source.authtypes); + g_list_free (priv->transport.authtypes); + + g_list_free (priv->providers); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +emae_class_init (GObjectClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EMAccountEditorPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = emae_set_property; + object_class->get_property = emae_get_property; + object_class->dispose = emae_dispose; + object_class->finalize = emae_finalize; + + g_object_class_install_property ( + object_class, + PROP_MODIFIED_ACCOUNT, + g_param_spec_object ( + "modified-account", + "Modified Account", + NULL, + E_TYPE_ACCOUNT, + G_PARAM_READABLE)); + + g_object_class_install_property ( + object_class, + PROP_ORIGINAL_ACCOUNT, + g_param_spec_object ( + "original-account", + "Original Account", + NULL, + E_TYPE_ACCOUNT, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); +} + +static void +emae_init (EMAccountEditor *emae) +{ + emae->priv = EM_ACCOUNT_EDITOR_GET_PRIVATE (emae); + + emae->priv->source.emae = emae; + emae->priv->transport.emae = emae; } GType @@ -242,17 +384,22 @@ em_account_editor_get_type (void) { static GType type = 0; - if (type == 0) { - static const GTypeInfo info = { + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { sizeof (EMAccountEditorClass), - NULL, NULL, - (GClassInitFunc)emae_class_init, - NULL, NULL, - sizeof (EMAccountEditor), 0, - (GInstanceInitFunc)emae_init + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) emae_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMAccountEditor), + 0, /* n_preallocs */ + (GInstanceInitFunc) emae_init, + NULL /* value_table */ }; - emae_parent = g_type_class_ref (G_TYPE_OBJECT); - type = g_type_register_static (G_TYPE_OBJECT, "EMAccountEditor", &info, 0); + + type = g_type_register_static ( + G_TYPE_OBJECT, "EMAccountEditor", &type_info, 0); } return type; @@ -269,11 +416,18 @@ em_account_editor_get_type (void) * * Return value: **/ -EMAccountEditor *em_account_editor_new (EAccount *account, em_account_editor_t type, const gchar *id) +EMAccountEditor * +em_account_editor_new (EAccount *account, + EMAccountEditorType type, + const gchar *id) { - EMAccountEditor *emae = g_object_new (em_account_editor_get_type (), NULL); + EMAccountEditor *emae; - em_account_editor_construct (emae, account, type, id); + emae = g_object_new ( + EM_TYPE_ACCOUNT_EDITOR, + "original-account", account, NULL); + + em_account_editor_construct (emae, type, id); return emae; } @@ -289,15 +443,40 @@ EMAccountEditor *em_account_editor_new (EAccount *account, em_account_editor_t t * * Return value: **/ -EMAccountEditor *em_account_editor_new_for_pages (EAccount *account, em_account_editor_t type, gchar *id, GtkWidget **pages) +EMAccountEditor * +em_account_editor_new_for_pages (EAccount *account, + EMAccountEditorType type, + const gchar *id, + GtkWidget **pages) { - EMAccountEditor *emae = g_object_new (em_account_editor_get_type (), NULL); + EMAccountEditor *emae; + + emae = g_object_new ( + EM_TYPE_ACCOUNT_EDITOR, + "original-account", account, NULL); + emae->pages = pages; - em_account_editor_construct (emae, account, type, id); + em_account_editor_construct (emae, type, id); return emae; } +EAccount * +em_account_editor_get_modified_account (EMAccountEditor *emae) +{ + g_return_val_if_fail (EM_IS_ACCOUNT_EDITOR (emae), NULL); + + return emae->priv->modified_account; +} + +EAccount * +em_account_editor_get_original_account (EMAccountEditor *emae) +{ + g_return_val_if_fail (EM_IS_ACCOUNT_EDITOR (emae), NULL); + + return emae->priv->original_account; +} + /* ********************************************************************** */ static struct { @@ -337,10 +516,12 @@ is_email (const gchar *address) static CamelURL * emae_account_url (EMAccountEditor *emae, gint urlid) { + EAccount *account; CamelURL *url = NULL; const gchar *uri; - uri = e_account_get_string (emae->account, urlid); + account = em_account_editor_get_modified_account (emae); + uri = e_account_get_string (account, urlid); if (uri && uri[0]) url = camel_url_new (uri, NULL); @@ -469,11 +650,11 @@ default_folders_clicked (GtkButton *button, gpointer user_data) EMAccountEditor *emae = user_data; const gchar *uri; - uri = mail_component_get_folder_uri (NULL, MAIL_COMPONENT_FOLDER_DRAFTS); + uri = e_mail_local_get_folder_uri (E_MAIL_FOLDER_DRAFTS); em_folder_selection_button_set_selection ((EMFolderSelectionButton *)emae->priv->drafts_folder_button, uri); emae_account_folder_changed ((EMFolderSelectionButton *)emae->priv->drafts_folder_button, emae); - uri = mail_component_get_folder_uri (NULL, MAIL_COMPONENT_FOLDER_SENT); + uri = e_mail_local_get_folder_uri (E_MAIL_FOLDER_SENT); em_folder_selection_button_set_selection ((EMFolderSelectionButton *)emae->priv->sent_folder_button, uri); emae_account_folder_changed ((EMFolderSelectionButton *)emae->priv->sent_folder_button, emae); } @@ -484,7 +665,8 @@ GtkWidget *em_account_editor_folder_selector_button_new (gchar *widget_name, gch GtkWidget * em_account_editor_folder_selector_button_new (gchar *widget_name, gchar *string1, gchar *string2, gint int1, gint int2) { - return (GtkWidget *)em_folder_selection_button_new (string1 ? string1 : _("Select Folder"), NULL); + return (GtkWidget *)em_folder_selection_button_new ( + string1 ? string1 : _("Select Folder"), NULL); } GtkWidget *em_account_editor_dropdown_new (gchar *widget_name, gchar *string1, gchar *string2, gint int1, gint int2); @@ -492,7 +674,7 @@ GtkWidget *em_account_editor_dropdown_new (gchar *widget_name, gchar *string1, g GtkWidget * em_account_editor_dropdown_new (gchar *widget_name, gchar *string1, gchar *string2, gint int1, gint int2) { - return (GtkWidget *)gtk_combo_box_new (); + return gtk_combo_box_new (); } GtkWidget *em_account_editor_ssl_selector_new (gchar *widget_name, gchar *string1, gchar *string2, gint int1, gint int2); @@ -659,34 +841,53 @@ emae_signature_changed (ESignatureList *signatures, ESignature *sig, EMAccountEd static void emae_signaturetype_changed (GtkComboBox *dropdown, EMAccountEditor *emae) { + EAccount *account; gint id = gtk_combo_box_get_active (dropdown); GtkTreeModel *model; GtkTreeIter iter; gchar *uid = NULL; + account = em_account_editor_get_modified_account (emae); + if (id != -1) { model = gtk_combo_box_get_model (dropdown); if (gtk_tree_model_iter_nth_child (model, &iter, NULL, id)) gtk_tree_model_get (model, &iter, 1, &uid, -1); } - e_account_set_string (emae->account, E_ACCOUNT_ID_SIGNATURE, uid); + e_account_set_string (account, E_ACCOUNT_ID_SIGNATURE, uid); g_free (uid); } static void -emae_signature_new (GtkWidget *w, EMAccountEditor *emae) +emae_signature_new (GtkWidget *widget, EMAccountEditor *emae) { - /* TODO: why is this in composer prefs? apart from it being somewhere to put it? */ - em_composer_prefs_new_signature ((GtkWindow *)gtk_widget_get_toplevel (w), - gconf_client_get_bool (mail_config_get_gconf_client (), - "/apps/evolution/mail/composer/send_html", NULL)); + EShell *shell; + EShellSettings *shell_settings; + GtkWidget *editor; + gboolean html_mode; + gpointer parent; + + shell = e_shell_get_default (); + shell_settings = e_shell_get_shell_settings (shell); + + parent = gtk_widget_get_toplevel (widget); + parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; + + html_mode = e_shell_settings_get_boolean ( + shell_settings, "composer-format-html"); + + editor = e_signature_editor_new (); + gtkhtml_editor_set_html_mode (GTKHTML_EDITOR (editor), html_mode); + gtk_window_set_transient_for (GTK_WINDOW (editor), parent); + gtk_widget_show (editor); } static GtkWidget * emae_setup_signatures (EMAccountEditor *emae, GladeXML *xml) { EMAccountEditorPrivate *p = emae->priv; + EAccount *account; GtkComboBox *dropdown = (GtkComboBox *)glade_xml_get_widget (xml, "signature_dropdown"); GtkCellRenderer *cell = gtk_cell_renderer_text_new (); GtkListStore *store; @@ -694,9 +895,12 @@ emae_setup_signatures (EMAccountEditor *emae, GladeXML *xml) GtkTreeIter iter; ESignatureList *signatures; EIterator *it; - const gchar *current = e_account_get_string (emae->account, E_ACCOUNT_ID_SIGNATURE); + const gchar *current; GtkWidget *button; + account = em_account_editor_get_modified_account (emae); + current = e_account_get_string (account, E_ACCOUNT_ID_SIGNATURE); + emae->priv->signatures_dropdown = dropdown; gtk_widget_show ((GtkWidget *)dropdown); @@ -705,7 +909,7 @@ emae_setup_signatures (EMAccountEditor *emae, GladeXML *xml) gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, _("None"), 1, NULL, -1); - signatures = mail_config_get_signatures (); + signatures = e_get_signature_list (); if (p->sig_added_id == 0) { p->sig_added_id = g_signal_connect (signatures, "signature-added", G_CALLBACK(emae_signature_added), emae); @@ -737,7 +941,7 @@ emae_setup_signatures (EMAccountEditor *emae, GladeXML *xml) gtk_combo_box_set_active (dropdown, active); g_signal_connect (dropdown, "changed", G_CALLBACK(emae_signaturetype_changed), emae); - gtk_widget_set_sensitive ((GtkWidget *)dropdown, e_account_writable (emae->account, E_ACCOUNT_ID_SIGNATURE)); + gtk_widget_set_sensitive ((GtkWidget *)dropdown, e_account_writable (account, E_ACCOUNT_ID_SIGNATURE)); button = glade_xml_get_widget (xml, "sigAddNew"); g_signal_connect (button, "clicked", G_CALLBACK(emae_signature_new), emae); @@ -751,29 +955,32 @@ emae_setup_signatures (EMAccountEditor *emae, GladeXML *xml) static void emae_receipt_policy_changed (GtkComboBox *dropdown, EMAccountEditor *emae) { + EAccount *account; gint id = gtk_combo_box_get_active (dropdown); GtkTreeModel *model; GtkTreeIter iter; EAccountReceiptPolicy policy; + account = em_account_editor_get_modified_account (emae); + if (id != -1) { model = gtk_combo_box_get_model (dropdown); if (gtk_tree_model_iter_nth_child (model, &iter, NULL, id)) { gtk_tree_model_get (model, &iter, 1, &policy, -1); - e_account_set_int (emae->account, E_ACCOUNT_RECEIPT_POLICY, policy); + e_account_set_int (account, E_ACCOUNT_RECEIPT_POLICY, policy); } } - } static GtkWidget * emae_setup_receipt_policy (EMAccountEditor *emae, GladeXML *xml) { + EAccount *account; GtkComboBox *dropdown = (GtkComboBox *)glade_xml_get_widget (xml, "receipt_policy_dropdown"); GtkListStore *store; gint i = 0, active = 0; GtkTreeIter iter; - EAccountReceiptPolicy current = emae->account->receipt_policy; + EAccountReceiptPolicy current; static struct { EAccountReceiptPolicy policy; const gchar *label; @@ -783,6 +990,9 @@ emae_setup_receipt_policy (EMAccountEditor *emae, GladeXML *xml) { E_ACCOUNT_RECEIPT_ASK, N_("Ask for each message") } }; + account = em_account_editor_get_modified_account (emae); + current = account->receipt_policy; + gtk_widget_show ((GtkWidget *)dropdown); store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); @@ -801,7 +1011,7 @@ emae_setup_receipt_policy (EMAccountEditor *emae, GladeXML *xml) gtk_combo_box_set_active (dropdown, active); g_signal_connect (dropdown, "changed", G_CALLBACK(emae_receipt_policy_changed), emae); - gtk_widget_set_sensitive ((GtkWidget *)dropdown, e_account_writable (emae->account, E_ACCOUNT_RECEIPT_POLICY)); + gtk_widget_set_sensitive ((GtkWidget *)dropdown, e_account_writable (account, E_ACCOUNT_RECEIPT_POLICY)); return (GtkWidget *)dropdown; } @@ -809,24 +1019,32 @@ emae_setup_receipt_policy (EMAccountEditor *emae, GladeXML *xml) static void emae_account_entry_changed (GtkEntry *entry, EMAccountEditor *emae) { - gint item = GPOINTER_TO_INT(g_object_get_data ((GObject *)entry, "account-item")); + EAccount *account; + const gchar *text; + gpointer data; - e_account_set_string (emae->account, item, gtk_entry_get_text (entry)); + account = em_account_editor_get_modified_account (emae); + data = g_object_get_data (G_OBJECT (entry), "account-item"); + text = gtk_entry_get_text (entry); + + e_account_set_string (account, GPOINTER_TO_INT (data), text); } static GtkEntry * emae_account_entry (EMAccountEditor *emae, const gchar *name, gint item, GladeXML *xml) { + EAccount *account; GtkEntry *entry; const gchar *text; + account = em_account_editor_get_modified_account (emae); entry = (GtkEntry *)glade_xml_get_widget (xml, name); - text = e_account_get_string (emae->account, item); + text = e_account_get_string (account, item); if (text) gtk_entry_set_text (entry, text); g_object_set_data ((GObject *)entry, "account-item", GINT_TO_POINTER(item)); g_signal_connect (entry, "changed", G_CALLBACK(emae_account_entry_changed), emae); - gtk_widget_set_sensitive ((GtkWidget *)entry, e_account_writable (emae->account, item)); + gtk_widget_set_sensitive ((GtkWidget *)entry, e_account_writable (account, item)); return entry; } @@ -834,18 +1052,39 @@ emae_account_entry (EMAccountEditor *emae, const gchar *name, gint item, GladeXM static void emae_account_toggle_changed (GtkToggleButton *toggle, EMAccountEditor *emae) { - gint item = GPOINTER_TO_INT(g_object_get_data ((GObject *)toggle, "account-item")); + EAccount *account; + gboolean active; + gpointer data; + + account = em_account_editor_get_modified_account (emae); + data = g_object_get_data (G_OBJECT (toggle), "account-item"); + active = gtk_toggle_button_get_active (toggle); - e_account_set_bool (emae->account, item, gtk_toggle_button_get_active (toggle)); + e_account_set_bool (account, GPOINTER_TO_INT (data), active); } static void emae_account_toggle_widget (EMAccountEditor *emae, GtkToggleButton *toggle, gint item) { - gtk_toggle_button_set_active (toggle, e_account_get_bool (emae->account, item)); - g_object_set_data ((GObject *)toggle, "account-item", GINT_TO_POINTER(item)); - g_signal_connect (toggle, "toggled", G_CALLBACK(emae_account_toggle_changed), emae); - gtk_widget_set_sensitive ((GtkWidget *)toggle, e_account_writable (emae->account, item)); + EAccount *account; + gboolean active; + gboolean writable; + + account = em_account_editor_get_modified_account (emae); + + active = e_account_get_bool (account, item); + gtk_toggle_button_set_active (toggle, active); + + writable = e_account_writable (account, item); + gtk_widget_set_sensitive (GTK_WIDGET (toggle), writable); + + g_object_set_data ( + G_OBJECT (toggle), "account-item", + GINT_TO_POINTER (item)); + + g_signal_connect ( + toggle, "toggled", + G_CALLBACK (emae_account_toggle_changed), emae); } static GtkToggleButton * @@ -862,18 +1101,39 @@ emae_account_toggle (EMAccountEditor *emae, const gchar *name, gint item, GladeX static void emae_account_spinint_changed (GtkSpinButton *spin, EMAccountEditor *emae) { - gint item = GPOINTER_TO_INT(g_object_get_data ((GObject *)spin, "account-item")); + EAccount *account; + gpointer data; + gint value; - e_account_set_int (emae->account, item, gtk_spin_button_get_value (spin)); + account = em_account_editor_get_modified_account (emae); + data = g_object_get_data (G_OBJECT (spin), "account-item"); + value = gtk_spin_button_get_value (spin); + + e_account_set_int (account, GPOINTER_TO_INT (data), value); } static void emae_account_spinint_widget (EMAccountEditor *emae, GtkSpinButton *spin, gint item) { - gtk_spin_button_set_value (spin, e_account_get_int (emae->account, item)); - g_object_set_data ((GObject *)spin, "account-item", GINT_TO_POINTER(item)); - g_signal_connect (spin, "value_changed", G_CALLBACK(emae_account_spinint_changed), emae); - gtk_widget_set_sensitive ((GtkWidget *)spin, e_account_writable (emae->account, item)); + EAccount *account; + gboolean writable; + gint v_int; + + account = em_account_editor_get_modified_account (emae); + + v_int = e_account_get_int (account, item); + gtk_spin_button_set_value (spin, v_int); + + writable = e_account_writable (account, item); + gtk_widget_set_sensitive (GTK_WIDGET (spin), writable); + + g_object_set_data ( + G_OBJECT (spin), "account-item", + GINT_TO_POINTER (item)); + + g_signal_connect ( + spin, "value-changed", + G_CALLBACK(emae_account_spinint_changed), emae); } #if 0 @@ -892,26 +1152,37 @@ emae_account_spinint (EMAccountEditor *emae, const gchar *name, gint item) static void emae_account_folder_changed (EMFolderSelectionButton *folder, EMAccountEditor *emae) { - gint item = GPOINTER_TO_INT(g_object_get_data ((GObject *)folder, "account-item")); + EAccount *account; + gpointer data; + const gchar *selection; + + account = em_account_editor_get_modified_account (emae); + data = g_object_get_data (G_OBJECT (folder), "account-item"); + selection = em_folder_selection_button_get_selection (folder); - e_account_set_string (emae->account, item, em_folder_selection_button_get_selection (folder)); + e_account_set_string (account, GPOINTER_TO_INT (data), selection); } static EMFolderSelectionButton * emae_account_folder (EMAccountEditor *emae, const gchar *name, gint item, gint deffolder, GladeXML *xml) { + EAccount *account; EMFolderSelectionButton *folder; const gchar *uri; + account = em_account_editor_get_modified_account (emae); folder = (EMFolderSelectionButton *)glade_xml_get_widget (xml, name); - uri = e_account_get_string (emae->account, item); + uri = e_account_get_string (account, item); if (uri) { gchar *tmp = em_uri_to_camel (uri); em_folder_selection_button_set_selection (folder, tmp); g_free (tmp); } else { - em_folder_selection_button_set_selection (folder, mail_component_get_folder_uri (NULL, deffolder)); + const gchar *uri; + + uri = e_mail_local_get_folder_uri (deffolder); + em_folder_selection_button_set_selection (folder, uri); } g_object_set_data ((GObject *)folder, "account-item", GINT_TO_POINTER(item)); @@ -919,7 +1190,7 @@ emae_account_folder (EMAccountEditor *emae, const gchar *name, gint item, gint d g_signal_connect (folder, "selected", G_CALLBACK(emae_account_folder_changed), emae); gtk_widget_show ((GtkWidget *)folder); - gtk_widget_set_sensitive ((GtkWidget *)folder, e_account_writable (emae->account, item)); + gtk_widget_set_sensitive ((GtkWidget *)folder, e_account_writable (account, item)); return folder; } @@ -1128,17 +1399,19 @@ static struct _service_info { static void emae_uri_changed (EMAccountEditorService *service, CamelURL *url) { + EAccount *account; gchar *uri; + account = em_account_editor_get_modified_account (service->emae); uri = camel_url_to_string (url, 0); - e_account_set_string (service->emae->account, emae_service_info[service->type].account_uri_key, uri); + e_account_set_string (account, emae_service_info[service->type].account_uri_key, uri); /* small hack for providers which are store and transport - copy settings across */ if (service->type == CAMEL_PROVIDER_STORE && service->provider && CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT(service->provider)) - e_account_set_string (service->emae->account, E_ACCOUNT_TRANSPORT_URL, uri); + e_account_set_string (account, E_ACCOUNT_TRANSPORT_URL, uri); g_free (uri); } @@ -1263,10 +1536,13 @@ emae_ssl_changed (GtkComboBox *dropdown, EMAccountEditorService *service) static void emae_service_provider_changed (EMAccountEditorService *service) { + EAccount *account; gint i, j; void (*show)(GtkWidget *); CamelURL *url = emae_account_url (service->emae, emae_service_info[service->type].account_uri_key); + account = em_account_editor_get_modified_account (service->emae); + if (service->provider) { gint enable; GtkWidget *dwidget = NULL; @@ -1278,14 +1554,14 @@ emae_service_provider_changed (EMAccountEditorService *service) else gtk_widget_show (service->frame); - enable = e_account_writable_option (service->emae->account, service->provider->protocol, "auth"); + enable = e_account_writable_option (account, service->provider->protocol, "auth"); gtk_widget_set_sensitive ((GtkWidget *)service->authtype, enable); gtk_widget_set_sensitive ((GtkWidget *)service->check_supported, enable); - enable = e_account_writable_option (service->emae->account, service->provider->protocol, "use_ssl"); + enable = e_account_writable_option (account, service->provider->protocol, "use_ssl"); gtk_widget_set_sensitive ((GtkWidget *)service->use_ssl, enable); - enable = e_account_writable (service->emae->account, emae_service_info[service->type].save_passwd_key); + enable = e_account_writable (account, emae_service_info[service->type].save_passwd_key); gtk_widget_set_sensitive ((GtkWidget *)service->remember, enable); for (i=0;emae_service_info[service->type].host_info[i].flag;i++) { @@ -1395,7 +1671,7 @@ emae_provider_changed (GtkComboBox *dropdown, EMAccountEditorService *service) static void emae_refresh_providers (EMAccountEditor *emae, EMAccountEditorService *service) { - EAccount *account = emae->account; + EAccount *account; GtkListStore *store; GtkTreeIter iter; GList *l; @@ -1403,11 +1679,14 @@ emae_refresh_providers (EMAccountEditor *emae, EMAccountEditorService *service) GtkComboBox *dropdown; gint active = 0, i; struct _service_info *info = &emae_service_info[service->type]; - const gchar *uri = e_account_get_string (account, info->account_uri_key); - const gchar *tmp; + const gchar *uri; gchar *current = NULL; + const gchar *tmp; CamelURL *url; + account = em_account_editor_get_modified_account (emae); + uri = e_account_get_string (account, info->account_uri_key); + dropdown = service->providers; gtk_widget_show ((GtkWidget *)dropdown); @@ -1422,7 +1701,7 @@ emae_refresh_providers (EMAccountEditor *emae, EMAccountEditorService *service) current[len] = 0; } } else { - current = (gchar *)"imap"; + current = (gchar *) "imap"; } store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); @@ -1496,6 +1775,7 @@ emae_refresh_providers (EMAccountEditor *emae, EMAccountEditorService *service) static void emae_authtype_changed (GtkComboBox *dropdown, EMAccountEditorService *service) { + EAccount *account; gint id = gtk_combo_box_get_active (dropdown); GtkTreeModel *model; GtkTreeIter iter; @@ -1505,6 +1785,8 @@ emae_authtype_changed (GtkComboBox *dropdown, EMAccountEditorService *service) if (id == -1) return; + account = em_account_editor_get_modified_account (service->emae); + url = emae_account_url (service->emae, emae_service_info[service->type].account_uri_key); model = gtk_combo_box_get_model (dropdown); if (gtk_tree_model_iter_nth_child (model, &iter, NULL, id)) { @@ -1519,7 +1801,7 @@ emae_authtype_changed (GtkComboBox *dropdown, EMAccountEditorService *service) gtk_widget_set_sensitive ((GtkWidget *)service->remember, authtype - ?(authtype->need_password && e_account_writable (service->emae->account, emae_service_info[service->type].save_passwd_key)) + ?(authtype->need_password && e_account_writable (account, emae_service_info[service->type].save_passwd_key)) :FALSE); } @@ -1546,17 +1828,20 @@ static void emae_check_authtype (GtkWidget *w, EMAccountEditorService *service); static void emae_refresh_authtype (EMAccountEditor *emae, EMAccountEditorService *service) { - EAccount *account = emae->account; + EAccount *account; GtkListStore *store; GtkTreeIter iter; GtkComboBox *dropdown; gint active = 0; gint i; struct _service_info *info = &emae_service_info[service->type]; - const gchar *uri = e_account_get_string (account, info->account_uri_key); + const gchar *uri; GList *l, *ll; CamelURL *url = NULL; + account = em_account_editor_get_modified_account (emae); + uri = e_account_get_string (account, info->account_uri_key); + dropdown = service->authtype; gtk_widget_show ((GtkWidget *)dropdown); @@ -1640,10 +1925,13 @@ static void emae_check_authtype_response (GtkWidget *d, gint button, EMAccountEd static void emae_check_authtype (GtkWidget *w, EMAccountEditorService *service) { EMAccountEditor *emae = service->emae; + EAccount *account; const gchar *uri; + account = em_account_editor_get_modified_account (emae); + /* TODO: do we need to remove the auth mechanism from the uri? */ - uri = e_account_get_string (emae->account, emae_service_info[service->type].account_uri_key); + uri = e_account_get_string (account, emae_service_info[service->type].account_uri_key); g_object_ref (emae); service->check_dialog = e_error_new (emae->editor ? (GtkWindow *)gtk_widget_get_toplevel (emae->editor) : NULL, @@ -1658,12 +1946,16 @@ static void emae_check_authtype (GtkWidget *w, EMAccountEditorService *service) static void emae_setup_service (EMAccountEditor *emae, EMAccountEditorService *service, GladeXML *xml) { + EAccount *account; struct _service_info *info = &emae_service_info[service->type]; CamelURL *url = emae_account_url (emae, info->account_uri_key); - const gchar *uri = e_account_get_string (emae->account, info->account_uri_key); + const gchar *uri; const gchar *tmp; gint i; + account = em_account_editor_get_modified_account (emae); + uri = e_account_get_string (account, info->account_uri_key); + service->provider = uri?camel_provider_get (uri, NULL):NULL; service->frame = glade_xml_get_widget (xml, info->frame); service->container = glade_xml_get_widget (xml, info->container); @@ -1752,7 +2044,7 @@ emae_setup_service (EMAccountEditor *emae, EMAccountEditorService *service, Glad service->needs_auth = NULL; } - if (!e_account_writable (emae->account, info->account_uri_key)) + if (!e_account_writable (account, info->account_uri_key)) gtk_widget_set_sensitive (service->container, FALSE); else gtk_widget_set_sensitive (service->container, TRUE); @@ -1800,7 +2092,7 @@ emae_identity_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget { EMAccountEditor *emae = data; EMAccountEditorPrivate *gui = emae->priv; - EAccount *account = emae->account; + EAccount *account; gint i; GtkWidget *w; GladeXML *xml; @@ -1809,6 +2101,8 @@ emae_identity_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget /*if (old) return old;*/ + account = em_account_editor_get_modified_account (emae); + gladefile = g_build_filename (EVOLUTION_GLADEDIR, "mail-config.glade", NULL); @@ -1822,9 +2116,9 @@ emae_identity_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget gui->management_frame = glade_xml_get_widget (xml, "management_frame"); gui->default_account = GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "management_default")); - if (!mail_config_get_default_account () - || (account == mail_config_get_default_account ()) - || (GPOINTER_TO_INT(g_object_get_data (G_OBJECT (emae->account), "default_flagged"))) ) + if (!e_get_default_account () + || (account == e_get_default_account ()) + || (GPOINTER_TO_INT(g_object_get_data (G_OBJECT (account), "default_flagged"))) ) gtk_toggle_button_set_active (gui->default_account, TRUE); if (emae->do_signature) { @@ -2394,6 +2688,7 @@ emae_defaults_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget { EMAccountEditor *emae = data; EMAccountEditorPrivate *gui = emae->priv; + EAccount *account; GtkWidget *w; GladeXML *xml; gchar *gladefile; @@ -2401,6 +2696,8 @@ emae_defaults_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget /*if (old) return old;*/ + account = em_account_editor_get_modified_account (emae); + gladefile = g_build_filename (EVOLUTION_GLADEDIR, "mail-config.glade", NULL); @@ -2408,8 +2705,8 @@ emae_defaults_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget g_free (gladefile); /* Special folders */ - gui->drafts_folder_button = (GtkButton *)emae_account_folder (emae, "drafts_button", E_ACCOUNT_DRAFTS_FOLDER_URI, MAIL_COMPONENT_FOLDER_DRAFTS, xml); - gui->sent_folder_button = (GtkButton *)emae_account_folder (emae, "sent_button", E_ACCOUNT_SENT_FOLDER_URI, MAIL_COMPONENT_FOLDER_SENT, xml); + gui->drafts_folder_button = (GtkButton *)emae_account_folder (emae, "drafts_button", E_ACCOUNT_DRAFTS_FOLDER_URI, E_MAIL_FOLDER_DRAFTS, xml); + gui->sent_folder_button = (GtkButton *)emae_account_folder (emae, "sent_button", E_ACCOUNT_SENT_FOLDER_URI, E_MAIL_FOLDER_SENT, xml); /* Special Folders "Reset Defaults" button */ gui->restore_folders_button = (GtkButton *)glade_xml_get_widget (xml, "default_folders_button"); @@ -2421,18 +2718,18 @@ emae_defaults_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget emae_account_toggle (emae, "always_bcc", E_ACCOUNT_BCC_ALWAYS, xml); emae_account_entry (emae, "bcc_addrs", E_ACCOUNT_BCC_ADDRS, xml); - gtk_widget_set_sensitive ((GtkWidget *)gui->drafts_folder_button, e_account_writable (emae->account, E_ACCOUNT_DRAFTS_FOLDER_URI)); + gtk_widget_set_sensitive ((GtkWidget *)gui->drafts_folder_button, e_account_writable (account, E_ACCOUNT_DRAFTS_FOLDER_URI)); gtk_widget_set_sensitive ( (GtkWidget *)gui->sent_folder_button, - e_account_writable (emae->account, E_ACCOUNT_SENT_FOLDER_URI) + e_account_writable (account, E_ACCOUNT_SENT_FOLDER_URI) && (emae->priv->source.provider ? !(emae->priv->source.provider->flags & CAMEL_PROVIDER_DISABLE_SENT_FOLDER): TRUE) ); gtk_widget_set_sensitive ((GtkWidget *)gui->restore_folders_button, - (e_account_writable (emae->account, E_ACCOUNT_SENT_FOLDER_URI) + (e_account_writable (account, E_ACCOUNT_SENT_FOLDER_URI) && ((emae->priv->source.provider && !( emae->priv->source.provider->flags & CAMEL_PROVIDER_DISABLE_SENT_FOLDER)) - || e_account_writable (emae->account, E_ACCOUNT_DRAFTS_FOLDER_URI)))); + || e_account_writable (account, E_ACCOUNT_DRAFTS_FOLDER_URI)))); /* Receipt policy */ emae_setup_receipt_policy (emae, xml); @@ -2680,6 +2977,7 @@ emae_free_auto (EConfig *ec, GSList *items, gpointer data) static gboolean emae_service_complete (EMAccountEditor *emae, EMAccountEditorService *service) { + EAccount *account; CamelURL *url; gint ok = TRUE; const gchar *uri; @@ -2687,7 +2985,9 @@ emae_service_complete (EMAccountEditor *emae, EMAccountEditorService *service) if (service->provider == NULL) return TRUE; - uri = e_account_get_string (emae->account, emae_service_info[service->type].account_uri_key); + account = em_account_editor_get_modified_account (emae); + + uri = e_account_get_string (account, emae_service_info[service->type].account_uri_key); if (uri == NULL || (url = camel_url_new (uri, NULL)) == NULL) return FALSE; @@ -2749,11 +3049,17 @@ static gboolean emae_check_complete (EConfig *ec, const gchar *pageid, gpointer data) { EMAccountEditor *emae = data; + EAccount *account; + EAccount *original_account; gint ok = TRUE; const gchar *tmp; EAccount *ea; gboolean refresh = FALSE; - gboolean edit = emae->original != NULL; + gboolean new_account; + + account = em_account_editor_get_modified_account (emae); + original_account = em_account_editor_get_original_account (emae); + new_account = (original_account == NULL); /* We use the page-check of various pages to 'prepare' or pre-load their values, only in the druid */ @@ -2778,11 +3084,11 @@ emae_check_complete (EConfig *ec, const gchar *pageid, gpointer data) if (!emae->priv->receive_set) { gchar *user, *at; gint index; - gchar *uri = g_strdup (e_account_get_string (emae->account, E_ACCOUNT_SOURCE_URL)); + gchar *uri = g_strdup (e_account_get_string (account, E_ACCOUNT_SOURCE_URL)); CamelURL *url; emae->priv->receive_set = 1; - tmp = (gchar *)e_account_get_string (emae->account, E_ACCOUNT_ID_ADDRESS); + tmp = (gchar *)e_account_get_string (account, E_ACCOUNT_ID_ADDRESS); at = strchr (tmp, '@'); user = g_alloca (at-tmp+1); memcpy (user, tmp, at-tmp); @@ -2792,7 +3098,7 @@ emae_check_complete (EConfig *ec, const gchar *pageid, gpointer data) index = check_servers (at); gtk_entry_set_text (emae->priv->source.username, user); gtk_entry_set_text (emae->priv->transport.username, user); - if (!edit && uri && (url = camel_url_new (uri, NULL)) != NULL) { + if (new_account && uri && (url = camel_url_new (uri, NULL)) != NULL) { refresh = TRUE; camel_url_set_user (url, user); if (index != -1) { @@ -2801,20 +3107,16 @@ emae_check_complete (EConfig *ec, const gchar *pageid, gpointer data) camel_url_set_host (url, mail_servers[index].recv); gtk_entry_set_text (emae->priv->source.hostname, mail_servers[index].recv); gtk_entry_set_text (emae->priv->transport.hostname, mail_servers[index].send); - camel_url_set_host (url, mail_servers[index].recv); - } else { camel_url_set_host (url, ""); } - camel_url_set_user (url, user); g_free (uri); uri = camel_url_to_string (url, 0); - e_account_set_string (emae->account, E_ACCOUNT_SOURCE_URL, uri); - g_free (uri); + e_account_set_string (account, E_ACCOUNT_SOURCE_URL, uri); + camel_url_free (url); - } else { - g_free (uri); } + g_free (uri); } } else if (!strcmp (pageid, "30.send")) { @@ -2822,9 +3124,10 @@ emae_check_complete (EConfig *ec, const gchar *pageid, gpointer data) CamelURL *url; gchar *at, *user; gint index; - gchar *uri = (gchar *)e_account_get_string (emae->account, E_ACCOUNT_TRANSPORT_URL); + gchar *uri = (gchar *)e_account_get_string (account, E_ACCOUNT_TRANSPORT_URL); + emae->priv->send_set = 1; - tmp = e_account_get_string (emae->account, E_ACCOUNT_ID_ADDRESS); + tmp = e_account_get_string (account, E_ACCOUNT_ID_ADDRESS); at = strchr (tmp, '@'); user = g_alloca (at-tmp+1); memcpy (user, tmp, at-tmp); @@ -2832,19 +3135,19 @@ emae_check_complete (EConfig *ec, const gchar *pageid, gpointer data) at++; index = check_servers (at); - if (index != -1 && uri && (url = camel_url_new (uri, NULL)) != NULL) { + if (index != -1 && uri && (url = camel_url_new (uri, NULL)) != NULL) { refresh = TRUE; camel_url_set_protocol (url, "smtp"); camel_url_set_param (url, "use_ssl", mail_servers[index].ssl); camel_url_set_host (url, mail_servers[index].send); camel_url_set_user (url, user); uri = camel_url_to_string (url, 0); - e_account_set_string (emae->account, E_ACCOUNT_TRANSPORT_URL, uri); + e_account_set_string (account, E_ACCOUNT_TRANSPORT_URL, uri); g_free (uri); camel_url_free (url); } - } + } else if (!strcmp (pageid, "20.receive_options")) { if (emae->priv->source.provider && emae->priv->extra_provider != emae->priv->source.provider) { @@ -2857,11 +3160,11 @@ emae_check_complete (EConfig *ec, const gchar *pageid, gpointer data) guint i = 0, len; emae->priv->management_set = 1; - tmp = e_account_get_string (emae->account, E_ACCOUNT_ID_ADDRESS); + tmp = e_account_get_string (account, E_ACCOUNT_ID_ADDRESS); len = strlen (tmp); template = alloca (len + 14); strcpy (template, tmp); - while (mail_config_get_account_by_name (template)) + while (e_get_account_by_name (template)) sprintf (template + len, " (%d)", i++); gtk_entry_set_text (emae->priv->identity_entries[0], template); @@ -2875,15 +3178,15 @@ emae_check_complete (EConfig *ec, const gchar *pageid, gpointer data) editing multiple accounts at a time */ if (gtk_toggle_button_get_active (emae->priv->default_account)) - g_object_set_data (G_OBJECT (emae->account), "default_flagged", GINT_TO_POINTER(1)); + g_object_set_data (G_OBJECT (account), "default_flagged", GINT_TO_POINTER(1)); if (pageid == NULL || !strcmp (pageid, "00.identity")) { /* TODO: check the account name is set, and unique in the account list */ - ok = (tmp = e_account_get_string (emae->account, E_ACCOUNT_ID_NAME)) + ok = (tmp = e_account_get_string (account, E_ACCOUNT_ID_NAME)) && tmp[0] - && (tmp = e_account_get_string (emae->account, E_ACCOUNT_ID_ADDRESS)) + && (tmp = e_account_get_string (account, E_ACCOUNT_ID_ADDRESS)) && is_email (tmp) - && ((tmp = e_account_get_string (emae->account, E_ACCOUNT_ID_REPLY_TO)) == NULL + && ((tmp = e_account_get_string (account, E_ACCOUNT_ID_REPLY_TO)) == NULL || tmp[0] == 0 || is_email (tmp)); if (!ok) { @@ -2912,10 +3215,10 @@ emae_check_complete (EConfig *ec, const gchar *pageid, gpointer data) } if (ok && (pageid == NULL || !strcmp (pageid, "40.management"))) { - ok = (tmp = e_account_get_string (emae->account, E_ACCOUNT_NAME)) + ok = (tmp = e_account_get_string (account, E_ACCOUNT_NAME)) && tmp[0] - && ((ea = mail_config_get_account_by_name (tmp)) == NULL - || ea == emae->original); + && ((ea = e_get_account_by_name (tmp)) == NULL + || ea == original_account); if (!ok) { d (printf ("management page incomplete\n")); } @@ -2934,40 +3237,44 @@ em_account_editor_check (EMAccountEditor *emae, const gchar *page) static void add_new_store (gchar *uri, CamelStore *store, gpointer user_data) { - MailComponent *component = mail_component_peek (); EAccount *account = user_data; if (store == NULL) return; - mail_component_add_store (component, store, account->name); + e_mail_store_add (store, account->name); } static void emae_commit (EConfig *ec, GSList *items, gpointer data) { EMAccountEditor *emae = data; - EAccountList *accounts = mail_config_get_accounts (); + EAccountList *accounts = e_get_account_list (); EAccount *account; + EAccount *modified_account; + EAccount *original_account; /* the mail-config*acconts* api needs a lot of work */ - if (emae->original) { - d (printf ("Committing account '%s'\n", e_account_get_string (emae->account, E_ACCOUNT_NAME))); - e_account_import (emae->original, emae->account); - account = emae->original; + modified_account = em_account_editor_get_modified_account (emae); + original_account = em_account_editor_get_original_account (emae); + + if (original_account != NULL) { + d (printf ("Committing account '%s'\n", e_account_get_string (modified_account, E_ACCOUNT_NAME))); + e_account_import (original_account, modified_account); + account = original_account; e_account_list_change (accounts, account); } else { - d (printf ("Adding new account '%s'\n", e_account_get_string (emae->account, E_ACCOUNT_NAME))); - e_account_list_add (accounts, emae->account); - account = emae->account; + d (printf ("Adding new account '%s'\n", e_account_get_string (account, E_ACCOUNT_NAME))); + e_account_list_add (accounts, modified_account); + account = modified_account; /* HACK: this will add the account to the folder tree. We should just be listening to the account list directly for changed events */ if (account->enabled && emae->priv->source.provider && (emae->priv->source.provider->flags & CAMEL_PROVIDER_IS_STORAGE)) - mail_get_store (e_account_get_string (emae->account, E_ACCOUNT_SOURCE_URL), NULL, add_new_store, account); + mail_get_store (e_account_get_string (modified_account, E_ACCOUNT_SOURCE_URL), NULL, add_new_store, account); } if (gtk_toggle_button_get_active (emae->priv->default_account)) @@ -2990,9 +3297,10 @@ emae_editor_destroyed (GtkWidget *dialog, EMAccountEditor *emae) } static void -em_account_editor_construct (EMAccountEditor *emae, EAccount *account, em_account_editor_t type, const gchar *id) +em_account_editor_construct (EMAccountEditor *emae, EMAccountEditorType type, const gchar *id) { EMAccountEditorPrivate *gui = emae->priv; + EAccount *account; gint i, index; GSList *l; GList *prov; @@ -3002,25 +3310,6 @@ em_account_editor_construct (EMAccountEditor *emae, EAccount *account, em_accoun EConfigItem *items; emae->type = type; - emae->original = account; - if (emae->original) { - gchar *xml; - - g_object_ref (emae->original); - xml = e_account_to_xml (emae->original); - emae->account = e_account_new_from_xml (xml); - g_free (xml); - - emae->do_signature = TRUE; - } else { - /* TODO: have a get_default_account thing?? */ - emae->account = e_account_new (); - emae->account->enabled = TRUE; - e_account_set_string (emae->account, E_ACCOUNT_DRAFTS_FOLDER_URI, - mail_component_get_folder_uri (NULL, MAIL_COMPONENT_FOLDER_DRAFTS)); - e_account_set_string (emae->account, E_ACCOUNT_SENT_FOLDER_URI, - mail_component_get_folder_uri (NULL, MAIL_COMPONENT_FOLDER_SENT)); - } /* sort the providers, remote first */ gui->providers = g_list_sort (camel_provider_list (TRUE), (GCompareFunc)provider_compare); @@ -3099,7 +3388,8 @@ em_account_editor_construct (EMAccountEditor *emae, EAccount *account, em_accoun e_config_add_page_check ((EConfig *)ec, NULL, emae_check_complete, emae); - target = em_config_target_new_account (ec, emae->account); + account = em_account_editor_get_modified_account (emae); + target = em_config_target_new_account (ec, account); e_config_set_target ((EConfig *)ec, (EConfigTarget *)target); if (type != EMAE_PAGES) { |