diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 69 | ||||
-rw-r--r-- | mail/component-factory.c | 33 | ||||
-rw-r--r-- | mail/folder-browser.c | 50 | ||||
-rw-r--r-- | mail/mail-account-editor.c | 8 | ||||
-rw-r--r-- | mail/mail-account-editor.h | 2 | ||||
-rw-r--r-- | mail/mail-account-gui.c | 174 | ||||
-rw-r--r-- | mail/mail-account-gui.h | 4 | ||||
-rw-r--r-- | mail/mail-accounts.c | 40 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 89 | ||||
-rw-r--r-- | mail/mail-config-druid.c | 205 | ||||
-rw-r--r-- | mail/mail-config.c | 944 | ||||
-rw-r--r-- | mail/mail-config.h | 112 | ||||
-rw-r--r-- | mail/mail-crypto.c | 2 | ||||
-rw-r--r-- | mail/mail-crypto.h | 2 | ||||
-rw-r--r-- | mail/mail-ops.c | 2 | ||||
-rw-r--r-- | mail/mail-send-recv.c | 83 | ||||
-rw-r--r-- | mail/mail-session.c | 8 | ||||
-rw-r--r-- | mail/mail-vfolder.c | 67 | ||||
-rw-r--r-- | mail/mail.h | 2 | ||||
-rw-r--r-- | mail/subscribe-dialog.c | 62 |
20 files changed, 833 insertions, 1125 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index ab971296ec..79dae4b8b6 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,72 @@ +2003-01-17 Jeffrey Stedfast <fejj@ximian.com> + + * mail-session.c (do_get_pass): Updated. + (request_password): Same. + + * mail-send-recv.c (mail_send): Fixed to use EAccountService. + + * mail-config-druid.c (make_account): Updated to use EAccount and + friends. + + * mail-account-gui.c (service_check_supported): Updated to use + EAccountService. + (mail_account_gui_new): Ref the account passed in and also update + to use EAccount objects. + (save_service): Updated to use an EAccountService. + (add_new_store): Updated to use an EAccount. + (mail_account_gui_save): Updated to use EAccounts. + (setup_signatures): Updated because the new account->id->def_sig + is now an int and not a structure pointer. + + * mail-account-editor.c (construct): Updated. + (mail_account_editor_new): Now takes an EAccount object as an + argument instead of a MailConfigAccount. + + * mail-crypto.c (mail_crypto_get_pgp_cipher_context): Updated to + use EAccounts. + + * subscribe-dialog.c (populate_store_foreach): Removed. + (populate_store_list): Can't use populate_store_foreach here + because of the change to EAccountList so do it manually. + + * mail-vfolder.c (uri_is_ignore): Rewrote to use EAccountList and + EIterator and all that fun. + + * mail-send-recv.c (build_dialogue): Updated to use EAccountList + and EAccount object stuff. *ugh* + (mail_send_receive): Here too. + (mail_autoreceive_setup): Same. + + * mail-callbacks.c (check_send_configuration): Updated. + (composer_get_message): Updated. + (compose_msg): " + (list_add_addresses): " + (guess_me): " + (guess_me_from_accounts): Same. + (forward_get_composer): Here too. + (mail_generate_reply): Same. + (redirect_get_composer): " + (empty_trash): And finally here. + + * mail-accounts.c (account_edit_clicked): Updated. + (account_delete_clicked): Same. + (account_default_clicked): Here too. + (account_able_clicked): " + (account_cursor_change): " + (mail_accounts_load): Again here. + + * folder-browser.c (folder_browser_is_drafts): Updated to use + EAccountList and EAccount stuff. + (folder_browser_is_sent): Same. + + * component-factory.c (mail_load_storages): Updated to use + EAccount and EAccountList stuff. + (owner_set_cb): Same. + (send_receive_cb): Here too. + + * mail-config.c: Rewritten to use EAccount and EAccountList + objects. + 2003-01-16 Jeffrey Stedfast <fejj@ximian.com> * mail-config-druid.c (get_fn): Connect to the toggled event on diff --git a/mail/component-factory.c b/mail/component-factory.c index b78465c6a5..353d0026f2 100644 --- a/mail/component-factory.c +++ b/mail/component-factory.c @@ -762,7 +762,7 @@ owner_set_cb (EvolutionShellComponent *shell_component, gpointer user_data) { GNOME_Evolution_Shell corba_shell; - const GSList *accounts; + EAccountList *accounts; int i; /* FIXME: should we ref this? */ @@ -773,7 +773,7 @@ owner_set_cb (EvolutionShellComponent *shell_component, mail_session_init (); async_event = mail_async_event_new(); - + storages_hash = g_hash_table_new (NULL, NULL); corba_shell = evolution_shell_client_corba_objref (shell_client); @@ -972,7 +972,7 @@ send_receive_cb (EvolutionShellComponent *shell_component, gboolean show_dialog, void *data) { - const MailConfigAccount *account; + EAccount *account; /* FIXME: configure_mail() should be changed to work without a FolderBrowser, and then we will be able to call configure_mail from @@ -981,7 +981,7 @@ send_receive_cb (EvolutionShellComponent *shell_component, return; account = mail_config_get_default_account (); - if (!account || !account->transport) { + if (!account || !account->transport->url) { GtkWidget *dialog; dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, @@ -1473,10 +1473,10 @@ mail_load_storage_by_uri (GNOME_Evolution_Shell shell, const char *uri, const ch } void -mail_load_storages (GNOME_Evolution_Shell shell, const GSList *sources) +mail_load_storages (GNOME_Evolution_Shell shell, EAccountList *accounts) { CamelException ex; - const GSList *iter; + EIterator *iter; camel_exception_init (&ex); @@ -1485,22 +1485,23 @@ mail_load_storages (GNOME_Evolution_Shell shell, const GSList *sources) * it. */ - for (iter = sources; iter; iter = iter->next) { - const MailConfigAccount *account = NULL; - const MailConfigService *service = NULL; - char *name; + iter = e_list_get_iterator ((EList *) accounts); + while (e_iterator_is_valid (iter)) { + EAccountService *service; + EAccount *account; + const char *name; - account = iter->data; + account = (EAccount *) e_iterator_get (iter); service = account->source; name = account->name; - if (service == NULL || service->url == NULL || service->url[0] == '\0') - continue; - - /* don't auto-connect here; the shell will tell us to goOnline */ - if (account->enabled) + if (account->enabled && service->url != NULL) mail_load_storage_by_uri (shell, service->url, name); + + e_iterator_next (iter); } + + g_object_unref (iter); } void diff --git a/mail/folder-browser.c b/mail/folder-browser.c index f611f126f4..dc3aefde87 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -1016,8 +1016,10 @@ extern CamelFolder *drafts_folder, *sent_folder, *outbox_folder; gboolean folder_browser_is_drafts (FolderBrowser *fb) { - const GSList *accounts; - MailConfigAccount *account; + gboolean is_drafts = FALSE; + EAccountList *accounts; + EAccount *account; + EIterator *iter; g_return_val_if_fail (IS_FOLDER_BROWSER (fb), FALSE); @@ -1028,14 +1030,21 @@ folder_browser_is_drafts (FolderBrowser *fb) return TRUE; accounts = mail_config_get_accounts (); - while (accounts) { - account = accounts->data; - if (account->drafts_folder_uri && camel_store_uri_cmp(fb->folder->parent_store, account->drafts_folder_uri, fb->uri)) - return TRUE; - accounts = accounts->next; + iter = e_list_get_iterator ((EList *) accounts); + while (e_iterator_is_valid (iter)) { + account = (EAccount *) e_iterator_get (iter); + if (account->drafts_folder_uri && + camel_store_uri_cmp (fb->folder->parent_store, account->drafts_folder_uri, fb->uri)) { + is_drafts = TRUE; + break; + } + + e_iterator_next (iter); } - return FALSE; + g_object_unref (iter); + + return is_drafts; } /** @@ -1048,8 +1057,10 @@ folder_browser_is_drafts (FolderBrowser *fb) gboolean folder_browser_is_sent (FolderBrowser *fb) { - const GSList *accounts; - MailConfigAccount *account; + gboolean is_sent = FALSE; + EAccountList *accounts; + EAccount *account; + EIterator *iter; g_return_val_if_fail (IS_FOLDER_BROWSER (fb), FALSE); @@ -1060,14 +1071,21 @@ folder_browser_is_sent (FolderBrowser *fb) return TRUE; accounts = mail_config_get_accounts (); - while (accounts) { - account = accounts->data; - if (account->sent_folder_uri && camel_store_uri_cmp(fb->folder->parent_store, account->sent_folder_uri, fb->uri)) - return TRUE; - accounts = accounts->next; + iter = e_list_get_iterator ((EList *) accounts); + while (e_iterator_is_valid (iter)) { + account = (EAccount *) e_iterator_get (iter); + if (account->sent_folder_uri && + camel_store_uri_cmp (fb->folder->parent_store, account->sent_folder_uri, fb->uri)) { + is_sent = TRUE; + break; + } + + e_iterator_next (iter); } - return FALSE; + g_object_unref (iter); + + return is_sent; } /** diff --git a/mail/mail-account-editor.c b/mail/mail-account-editor.c index 848c1a7fd1..49fdba2ff8 100644 --- a/mail/mail-account-editor.c +++ b/mail/mail-account-editor.c @@ -132,9 +132,9 @@ editor_response_cb (GtkWidget *widget, int button, gpointer user_data) } static void -construct (MailAccountEditor *editor, MailConfigAccount *account, MailAccountsTab *dialog) +construct (MailAccountEditor *editor, EAccount *account, MailAccountsTab *dialog) { - MailConfigService *source = account->source; + EAccountService *source = account->source; editor->gui = mail_account_gui_new (account, dialog); @@ -162,11 +162,11 @@ construct (MailAccountEditor *editor, MailConfigAccount *account, MailAccountsTa } MailAccountEditor * -mail_account_editor_new (MailConfigAccount *account, GtkWindow *parent, MailAccountsTab *dialog) +mail_account_editor_new (EAccount *account, GtkWindow *parent, MailAccountsTab *dialog) { MailAccountEditor *new; - new = (MailAccountEditor *) g_object_new(mail_account_editor_get_type (), NULL); + new = (MailAccountEditor *) g_object_new (mail_account_editor_get_type (), NULL); gtk_window_set_transient_for ((GtkWindow *) new, parent); construct (new, account, dialog); diff --git a/mail/mail-account-editor.h b/mail/mail-account-editor.h index afb81513a9..2ee67f67cf 100644 --- a/mail/mail-account-editor.h +++ b/mail/mail-account-editor.h @@ -58,7 +58,7 @@ typedef struct { GtkType mail_account_editor_get_type (void); -MailAccountEditor *mail_account_editor_new (MailConfigAccount *account, GtkWindow *parent, MailAccountsTab *dialog); +MailAccountEditor *mail_account_editor_new (EAccount *account, GtkWindow *parent, MailAccountsTab *dialog); #ifdef __cplusplus } diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c index da8b35074b..11587f886c 100644 --- a/mail/mail-account-gui.c +++ b/mail/mail-account-gui.c @@ -50,7 +50,7 @@ extern char *default_drafts_folder_uri, *default_sent_folder_uri; extern EvolutionShellClient *global_shell_client; -static void save_service (MailAccountGuiService *gsvc, GHashTable *extra_conf, MailConfigService *service); +static void save_service (MailAccountGuiService *gsvc, GHashTable *extra_conf, EAccountService *service); static void service_changed (GtkEntry *entry, gpointer user_data); struct { @@ -668,12 +668,12 @@ static void service_check_supported (GtkButton *button, gpointer user_data) { MailAccountGuiService *gsvc = user_data; - MailConfigService *service; + EAccountService *service; GList *authtypes = NULL; GtkWidget *authitem; GtkWidget *window; - service = g_new0 (MailConfigService, 1); + service = g_new0 (EAccountService, 1); /* This is sort of a hack, when checking for supported AUTH types we don't want to use whatever authtype is selected @@ -696,7 +696,8 @@ service_check_supported (GtkButton *button, gpointer user_data) g_list_free (authtypes); } - service_destroy (service); + g_free (service->url); + g_free (service); } @@ -1069,7 +1070,7 @@ mail_account_gui_folder_selector_button_new (char *widget_name, } static gboolean -setup_service (MailAccountGuiService *gsvc, MailConfigService *service) +setup_service (MailAccountGuiService *gsvc, EAccountService *service) { CamelURL *url = camel_url_new (service->url, NULL); gboolean has_auth = FALSE; @@ -1282,7 +1283,13 @@ sig_add_new_signature (GtkWidget *w, MailAccountGui *gui) static void setup_signatures (MailAccountGui *gui) { - gui->def_signature = gui->account->id->def_signature; + MailConfigSignature *sig; + GSList *signatures; + + signatures = mail_config_get_signature_list (); + sig = g_slist_nth_data (signatures, gui->account->id->def_signature); + + gui->def_signature = sig; gui->auto_signature = gui->account->id->auto_signature; gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_menu), sig_gui_get_index (gui)); } @@ -1366,12 +1373,14 @@ prepare_signatures (MailAccountGui *gui) } MailAccountGui * -mail_account_gui_new (MailConfigAccount *account, MailAccountsTab *dialog) +mail_account_gui_new (EAccount *account, MailAccountsTab *dialog) { const char *allowed_types[] = { "mail/*", NULL }; MailAccountGui *gui; GtkWidget *button; + g_object_ref (account); + gui = g_new0 (MailAccountGui, 1); gui->account = account; gui->dialog = dialog; @@ -1394,18 +1403,16 @@ mail_account_gui_new (MailConfigAccount *account, MailAccountsTab *dialog) prepare_signatures (gui); - if (account->id) { - if (account->id->name) - gtk_entry_set_text (gui->full_name, account->id->name); - if (account->id->address) - gtk_entry_set_text (gui->email_address, account->id->address); - if (account->id->reply_to) - gtk_entry_set_text (gui->reply_to, account->id->reply_to); - if (account->id->organization) - gtk_entry_set_text (gui->organization, account->id->organization); - - setup_signatures (gui); - } + if (account->id->name) + gtk_entry_set_text (gui->full_name, account->id->name); + if (account->id->address) + gtk_entry_set_text (gui->email_address, account->id->address); + if (account->id->reply_to) + gtk_entry_set_text (gui->reply_to, account->id->reply_to); + if (account->id->organization) + gtk_entry_set_text (gui->organization, account->id->organization); + + setup_signatures (gui); /* Source */ gui->source.provider_type = CAMEL_PROVIDER_STORE; @@ -1719,8 +1726,7 @@ mail_account_gui_setup (MailAccountGui *gui, GtkWidget *top) } static void -save_service (MailAccountGuiService *gsvc, GHashTable *extra_config, - MailConfigService *service) +save_service (MailAccountGuiService *gsvc, GHashTable *extra_config, EAccountService *service) { CamelURL *url; const char *str; @@ -1798,7 +1804,7 @@ save_service (MailAccountGuiService *gsvc, GHashTable *extra_config, static void add_new_store (char *uri, CamelStore *store, void *user_data) { - const MailConfigAccount *account = user_data; + EAccount *account = user_data; EvolutionStorage *storage; if (store == NULL) @@ -1817,12 +1823,13 @@ add_new_store (char *uri, CamelStore *store, void *user_data) gboolean mail_account_gui_save (MailAccountGui *gui) { - MailConfigAccount *account = gui->account; - MailConfigAccount *old_account; + EAccount *account, *new; CamelProvider *provider = NULL; CamelURL *source_url = NULL, *url; + gboolean is_new = FALSE; const char *new_name; gboolean is_storage; + GSList *signatures; if (!mail_account_gui_identity_complete (gui, NULL) || !mail_account_gui_source_complete (gui, NULL) || @@ -1830,67 +1837,63 @@ mail_account_gui_save (MailAccountGui *gui) !mail_account_gui_management_complete (gui, NULL)) return FALSE; + new = gui->account; + /* this would happen at an inconvenient time in the druid, * but the druid performs its own check so this can't happen * here. */ new_name = gtk_entry_get_text (gui->account_name); - old_account = (MailConfigAccount *) mail_config_get_account_by_name (new_name); + account = mail_config_get_account_by_name (new_name); - if (old_account && old_account != account) { - e_notice (NULL, GTK_MESSAGE_ERROR, - _("You may not create two accounts with the same name.")); + if (account && account != new) { + e_notice (NULL, GTK_MESSAGE_ERROR, _("You may not create two accounts with the same name.")); return FALSE; } - /* make a copy of the old account for later use... */ - old_account = account_copy (account); + account = new; - g_free (account->name); - account->name = g_strdup (new_name); + new = e_account_new (); + new->name = g_strdup (new_name); + new->enabled = account->enabled; /* construct the identity */ - identity_destroy (account->id); - account->id = g_new0 (MailConfigIdentity, 1); - account->id->name = g_strdup (gtk_entry_get_text (gui->full_name)); - account->id->address = g_strdup (gtk_entry_get_text (gui->email_address)); - account->id->reply_to = g_strdup (gtk_entry_get_text (gui->reply_to)); - account->id->organization = g_strdup (gtk_entry_get_text (gui->organization)); + new->id->name = g_strdup (gtk_entry_get_text (gui->full_name)); + new->id->address = g_strdup (gtk_entry_get_text (gui->email_address)); + new->id->reply_to = g_strdup (gtk_entry_get_text (gui->reply_to)); + new->id->organization = g_strdup (gtk_entry_get_text (gui->organization)); /* signatures */ - account->id->def_signature = gui->def_signature; - account->id->auto_signature = gui->auto_signature; - - service_destroy (account->source); - account->source = g_new0 (MailConfigService, 1); - save_service (&gui->source, gui->extra_config, account->source); - if (account->source->url) { - provider = camel_session_get_provider (session, account->source->url, NULL); - source_url = provider ? camel_url_new (account->source->url, NULL) : NULL; + signatures = mail_config_get_signature_list (); + new->id->def_signature = g_slist_index (signatures, gui->def_signature); + new->id->auto_signature = gui->auto_signature; + + /* source */ + save_service (&gui->source, gui->extra_config, new->source); + if (new->source->url) { + provider = camel_session_get_provider (session, new->source->url, NULL); + source_url = provider ? camel_url_new (new->source->url, NULL) : NULL; } - account->source->auto_check = gtk_toggle_button_get_active (gui->source_auto_check); - if (account->source->auto_check) - account->source->auto_check_time = gtk_spin_button_get_value_as_int (gui->source_auto_check_min); + new->source->auto_check = gtk_toggle_button_get_active (gui->source_auto_check); + if (new->source->auto_check) + new->source->auto_check_time = gtk_spin_button_get_value_as_int (gui->source_auto_check_min); - service_destroy (account->transport); - account->transport = g_new0 (MailConfigService, 1); + /* transport */ if (CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT (gui->transport.provider)) { /* The transport URI is the same as the source URI. */ - save_service (&gui->source, gui->extra_config, account->transport); + save_service (&gui->source, gui->extra_config, new->transport); } else - save_service (&gui->transport, NULL, account->transport); + save_service (&gui->transport, NULL, new->transport); /* Check to make sure that the Drafts folder uri is "valid" before assigning it */ url = source_url && gui->drafts_folder_uri ? camel_url_new (gui->drafts_folder_uri, NULL) : NULL; if (mail_config_get_account_by_source_url (gui->drafts_folder_uri) || (url && provider->url_equal (source_url, url))) { - g_free (account->drafts_folder_uri); - account->drafts_folder_uri = g_strdup (gui->drafts_folder_uri); + new->drafts_folder_uri = g_strdup (gui->drafts_folder_uri); } else { /* assign defaults - the uri is unknown to us (probably pointed to an old source url) */ - g_free (account->drafts_folder_uri); - account->drafts_folder_uri = g_strdup (default_drafts_folder_uri); + new->drafts_folder_uri = g_strdup (default_drafts_folder_uri); } if (url) @@ -1900,12 +1903,10 @@ mail_account_gui_save (MailAccountGui *gui) url = source_url && gui->sent_folder_uri ? camel_url_new (gui->sent_folder_uri, NULL) : NULL; if (mail_config_get_account_by_source_url (gui->sent_folder_uri) || (url && provider->url_equal (source_url, url))) { - g_free (account->sent_folder_uri); - account->sent_folder_uri = g_strdup (gui->sent_folder_uri); + new->sent_folder_uri = g_strdup (gui->sent_folder_uri); } else { /* assign defaults - the uri is unknown to us (probably pointed to an old source url) */ - g_free (account->sent_folder_uri); - account->sent_folder_uri = g_strdup (default_sent_folder_uri); + new->sent_folder_uri = g_strdup (default_sent_folder_uri); } if (url) @@ -1914,44 +1915,46 @@ mail_account_gui_save (MailAccountGui *gui) if (source_url) camel_url_free (source_url); - account->always_cc = gtk_toggle_button_get_active (gui->always_cc); - account->cc_addrs = g_strdup (gtk_entry_get_text (gui->cc_addrs)); - account->always_bcc = gtk_toggle_button_get_active (gui->always_bcc); - account->bcc_addrs = g_strdup (gtk_entry_get_text (gui->bcc_addrs)); + new->always_cc = gtk_toggle_button_get_active (gui->always_cc); + new->cc_addrs = g_strdup (gtk_entry_get_text (gui->cc_addrs)); + new->always_bcc = gtk_toggle_button_get_active (gui->always_bcc); + new->bcc_addrs = g_strdup (gtk_entry_get_text (gui->bcc_addrs)); - g_free (account->pgp_key); - account->pgp_key = g_strdup (gtk_entry_get_text (gui->pgp_key)); - account->pgp_encrypt_to_self = gtk_toggle_button_get_active (gui->pgp_encrypt_to_self); - account->pgp_always_sign = gtk_toggle_button_get_active (gui->pgp_always_sign); - account->pgp_no_imip_sign = gtk_toggle_button_get_active (gui->pgp_no_imip_sign); - account->pgp_always_trust = gtk_toggle_button_get_active (gui->pgp_always_trust); + new->pgp_key = g_strdup (gtk_entry_get_text (gui->pgp_key)); + new->pgp_encrypt_to_self = gtk_toggle_button_get_active (gui->pgp_encrypt_to_self); + new->pgp_always_sign = gtk_toggle_button_get_active (gui->pgp_always_sign); + new->pgp_no_imip_sign = gtk_toggle_button_get_active (gui->pgp_no_imip_sign); + new->pgp_always_trust = gtk_toggle_button_get_active (gui->pgp_always_trust); #if defined (HAVE_NSS) && defined (SMIME_SUPPORTED) - g_free (account->smime_key); - account->smime_key = g_strdup (gtk_entry_get_text (gui->smime_key)); - account->smime_encrypt_to_self = gtk_toggle_button_get_active (gui->smime_encrypt_to_self); - account->smime_always_sign = gtk_toggle_button_get_active (gui->smime_always_sign); + new->smime_key = g_strdup (gtk_entry_get_text (gui->smime_key)); + new->smime_encrypt_to_self = gtk_toggle_button_get_active (gui->smime_encrypt_to_self); + new->smime_always_sign = gtk_toggle_button_get_active (gui->smime_always_sign); #endif /* HAVE_NSS && SMIME_SUPPORTED */ is_storage = provider && (provider->flags & CAMEL_PROVIDER_IS_STORAGE) && !(provider->flags & CAMEL_PROVIDER_IS_EXTERNAL); if (!mail_config_find_account (account)) { - /* this is a new account so it it to our account-list */ - mail_config_add_account (account); - } else if (old_account->source && old_account->source->url) { + /* this is a new account so add it to our account-list */ + is_new = TRUE; + } else if (account->source->url) { /* this means the account was edited - if the old and new source urls are not identical, replace the old storage with the new storage */ #define sources_equal(old,new) (new->url && !strcmp (old->url, new->url)) - if (!sources_equal (old_account->source, account->source)) { + if (!sources_equal (account->source, new->source)) { /* Remove the old storage from the folder-tree */ - mail_remove_storage_by_uri (old_account->source->url); + mail_remove_storage_by_uri (account->source->url); } } - /* destroy the copy of the old account */ - account_destroy (old_account); + /* update the old account with the new settings */ + e_account_import (account, new); + g_object_unref (new); + + if (is_new) + mail_config_add_account (account); /* if the account provider is something we can stick in the folder-tree and not added by some other @@ -1976,10 +1979,13 @@ mail_account_gui_destroy (MailAccountGui *gui) { if (gui->dialog) mail_config_signature_unregister_client ((MailConfigSignatureClient) sig_event_client, gui); - + g_object_unref (gui->xml); + g_object_unref (gui->account); + if (gui->extra_config) g_hash_table_destroy (gui->extra_config); + g_free (gui->drafts_folder_uri); g_free (gui->sent_folder_uri); g_free (gui); diff --git a/mail/mail-account-gui.h b/mail/mail-account-gui.h index 451f16da3e..74c00d5dc0 100644 --- a/mail/mail-account-gui.h +++ b/mail/mail-account-gui.h @@ -59,7 +59,7 @@ typedef struct { typedef struct { GtkWidget *top; - MailConfigAccount *account; + EAccount *account; MailAccountsTab *dialog; GladeXML *xml; @@ -115,7 +115,7 @@ typedef struct { } MailAccountGui; -MailAccountGui *mail_account_gui_new (MailConfigAccount *account, MailAccountsTab *dialog); +MailAccountGui *mail_account_gui_new (EAccount *account, MailAccountsTab *dialog); void mail_account_gui_setup (MailAccountGui *gui, GtkWidget *top); gboolean mail_account_gui_save (MailAccountGui *gui); void mail_account_gui_destroy (MailAccountGui *gui); diff --git a/mail/mail-accounts.c b/mail/mail-accounts.c index 21ce6dd6cc..afcc22f83b 100644 --- a/mail/mail-accounts.c +++ b/mail/mail-accounts.c @@ -168,8 +168,8 @@ account_edit_clicked (GtkButton *button, gpointer user_data) MailAccountsTab *prefs = (MailAccountsTab *) user_data; if (prefs->editor == NULL) { - MailConfigAccount *account = NULL; GtkTreeSelection *selection; + EAccount *account = NULL; GtkTreeModel *model; GtkTreeIter iter; @@ -195,11 +195,11 @@ static void account_delete_clicked (GtkButton *button, gpointer user_data) { MailAccountsTab *prefs = user_data; - const MailConfigAccount *account = NULL; GtkTreeSelection *selection; + EAccount *account = NULL; + EAccountList *accounts; GtkTreeModel *model; GtkWidget *confirm; - const GSList *list; GtkTreeIter iter; int ans; @@ -238,7 +238,8 @@ account_delete_clicked (GtkButton *button, gpointer user_data) mail_remove_storage_by_uri (account->source->url); /* remove it from the config file */ - list = mail_config_remove_account ((MailConfigAccount *) account); + mail_config_remove_account (account); + accounts = mail_config_get_accounts (); mail_config_write (); @@ -246,7 +247,7 @@ account_delete_clicked (GtkButton *button, gpointer user_data) gtk_list_store_remove ((GtkListStore *) model, &iter); - len = list ? g_slist_length ((GSList *) list) : 0; + len = e_list_length ((EList *) accounts); if (len > 0) { gtk_tree_selection_select_iter (selection, &iter); } else { @@ -262,8 +263,8 @@ static void account_default_clicked (GtkButton *button, gpointer user_data) { MailAccountsTab *prefs = user_data; - const MailConfigAccount *account = NULL; GtkTreeSelection *selection; + EAccount *account = NULL; GtkTreeModel *model; GtkTreeIter iter; int row; @@ -285,8 +286,8 @@ static void account_able_clicked (GtkButton *button, gpointer user_data) { MailAccountsTab *prefs = user_data; - MailConfigAccount *account = NULL; GtkTreeSelection *selection; + EAccount *account = NULL; GtkTreeModel *model; GtkTreeIter iter; @@ -295,8 +296,8 @@ account_able_clicked (GtkButton *button, gpointer user_data) gtk_tree_model_get (model, &iter, 3, &account, -1); account->enabled = !account->enabled; gtk_list_store_set ((GtkListStore *) model, &iter, 0, account->enabled, -1); - - gtk_button_set_label (prefs->mail_able, account->enabled?_("Disable"):_("Enable")); + + gtk_button_set_label (prefs->mail_able, account->enabled ? _("Disable") : _("Enable")); } if (account) { @@ -325,7 +326,7 @@ account_double_click (GtkTreeView *treeview, GtkTreePath *path, static void account_cursor_change (GtkTreeSelection *selection, MailAccountsTab *prefs) { - const MailConfigAccount *account; + EAccount *account = NULL; GtkTreeModel *model; GtkTreeIter iter; int state; @@ -350,11 +351,12 @@ account_cursor_change (GtkTreeSelection *selection, MailAccountsTab *prefs) static void mail_accounts_load (MailAccountsTab *prefs) { - const MailConfigAccount *default_account; + EAccount *default_account; + EAccountList *accounts; GtkListStore *model; - const GSList *node; GtkTreeIter iter; char *name, *val; + EIterator *node; int row = 0; model = (GtkListStore *) gtk_tree_view_get_model (prefs->table); @@ -362,12 +364,13 @@ mail_accounts_load (MailAccountsTab *prefs) default_account = mail_config_get_default_account (); - node = mail_config_get_accounts (); - while (node) { - const MailConfigAccount *account; + accounts = mail_config_get_accounts (); + node = e_list_get_iterator ((EList *) accounts); + while (e_iterator_is_valid (node)) { + EAccount *account; CamelURL *url; - account = node->data; + account = (EAccount *) e_iterator_get (node); url = account->source && account->source->url ? camel_url_new (account->source->url, NULL) : NULL; @@ -391,9 +394,12 @@ mail_accounts_load (MailAccountsTab *prefs) if (url) camel_url_free (url); - node = node->next; row++; + + e_iterator_next (node); } + + g_object_unref (node); } diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index 847e5bd39a..07ccf89000 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -205,7 +205,7 @@ configure_mail (FolderBrowser *fb) static gboolean check_send_configuration (FolderBrowser *fb) { - const MailConfigAccount *account; + EAccount *account; GtkWidget *dialog; if (!mail_config_is_configured ()) { @@ -230,7 +230,7 @@ check_send_configuration (FolderBrowser *fb) } /* Check for a transport */ - if (!account->transport || !account->transport->url) { + if (!account->transport->url) { e_notice (FB_WINDOW (fb), GTK_MESSAGE_WARNING, _("You need to configure a mail transport\n" "before you can compose mail.")); @@ -406,13 +406,13 @@ composer_send_queued_cb (CamelFolder *folder, CamelMimeMessage *msg, CamelMessag static CamelMimeMessage * composer_get_message (EMsgComposer *composer, gboolean post, gboolean save_html_object_data) { - const MailConfigAccount *account; CamelMimeMessage *message = NULL; EDestination **recipients, **recipients_bcc; gboolean send_html, confirm_html; int hidden = 0, shown = 0; int num = 0, num_bcc = 0; GConfClient *gconf; + EAccount *account; char *subject; int i; @@ -696,11 +696,11 @@ composer_save_draft_cb (EMsgComposer *composer, int quit, gpointer user_data) { extern char *default_drafts_folder_uri; extern CamelFolder *drafts_folder; - CamelMimeMessage *msg; - CamelMessageInfo *info; - const MailConfigAccount *account; struct _save_draft_info *sdi; CamelFolder *folder = NULL; + CamelMimeMessage *msg; + CamelMessageInfo *info; + EAccount *account; account = e_msg_composer_get_preferred_account (composer); if (account && account->drafts_folder_uri && @@ -744,7 +744,7 @@ composer_save_draft_cb (EMsgComposer *composer, int quit, gpointer user_data) } static GtkWidget * -create_msg_composer (const MailConfigAccount *account, gboolean post, const char *url) +create_msg_composer (EAccount *account, gboolean post, const char *url) { EMsgComposer *composer; GConfClient *gconf; @@ -779,10 +779,10 @@ create_msg_composer (const MailConfigAccount *account, gboolean post, const char void compose_msg (GtkWidget *widget, gpointer user_data) { - const MailConfigAccount *account; FolderBrowser *fb = FOLDER_BROWSER (user_data); struct _composer_callback_data *ccd; GtkWidget *composer; + EAccount *account; if (FOLDER_BROWSER_IS_DESTROYED (fb) || !check_send_configuration (fb)) return; @@ -833,10 +833,10 @@ send_to_url (const char *url) static GList * list_add_addresses (GList *list, const CamelInternetAddress *cia, GHashTable *account_hash, - GHashTable *rcpt_hash, const MailConfigAccount **me) + GHashTable *rcpt_hash, EAccount **me) { - const MailConfigAccount *account; const char *name, *addr; + EAccount *account; int i; for (i = 0; camel_internet_address_get (cia, i, &name, &addr); i++) { @@ -862,10 +862,10 @@ list_add_addresses (GList *list, const CamelInternetAddress *cia, GHashTable *ac return list; } -static const MailConfigAccount * +static EAccount * guess_me (const CamelInternetAddress *to, const CamelInternetAddress *cc, GHashTable *account_hash) { - const MailConfigAccount *account = NULL; + EAccount *account = NULL; const char *addr; int i; @@ -894,12 +894,12 @@ guess_me (const CamelInternetAddress *to, const CamelInternetAddress *cc, GHashT return account; } -static const MailConfigAccount * -guess_me_from_accounts (const CamelInternetAddress *to, const CamelInternetAddress *cc, const GSList *accounts) +static EAccount * +guess_me_from_accounts (const CamelInternetAddress *to, const CamelInternetAddress *cc, EAccountList *accounts) { - const MailConfigAccount *account, *def; + EAccount *account, *def; GHashTable *account_hash; - const GSList *l; + EIterator *iter; account_hash = g_hash_table_new (g_strcase_hash, g_strcase_equal); @@ -909,12 +909,12 @@ guess_me_from_accounts (const CamelInternetAddress *to, const CamelInternetAddre g_hash_table_insert (account_hash, (char *) def->id->address, (void *) def); } - l = accounts; - while (l) { - account = l->data; + iter = e_list_get_iterator ((EList *) accounts); + while (e_iterator_is_valid (iter)) { + account = (EAccount *) e_iterator_get (iter); if (account->id->address) { - const MailConfigAccount *acnt; + EAccount *acnt; /* Accounts with identical email addresses that are enabled * take precedence over the accounts that aren't. If all @@ -932,9 +932,11 @@ guess_me_from_accounts (const CamelInternetAddress *to, const CamelInternetAddre g_hash_table_insert (account_hash, (char *) account->id->address, (void *) account); } - l = l->next; + e_iterator_next (iter); } + g_object_unref (iter); + account = guess_me (to, cc, account_hash); g_hash_table_destroy (account_hash); @@ -970,8 +972,8 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char const char *name = NULL, *address = NULL, *source = NULL; const char *message_id, *references, *mlist = NULL; char *text = NULL, *subject, format[256]; - const MailConfigAccount *def, *account, *me = NULL; - const GSList *l, *accounts = NULL; + EAccount *def, *account, *me = NULL; + EAccountList *accounts = NULL; GHashTable *account_hash = NULL; CamelMessageInfo *info = NULL; GList *to = NULL, *cc = NULL; @@ -979,6 +981,7 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char EMsgComposer *composer; CamelMimePart *part; GConfClient *gconf; + EIterator *iter; time_t date; char *url; @@ -1009,12 +1012,12 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char g_hash_table_insert (account_hash, (char *) def->id->address, (void *) def); } - l = accounts; - while (l) { - account = l->data; + iter = e_list_get_iterator ((EList *) accounts); + while (e_iterator_is_valid (iter)) { + account = (EAccount *) e_iterator_get (iter); if (account->id->address) { - const MailConfigAccount *acnt; + EAccount *acnt; /* Accounts with identical email addresses that are enabled * take precedence over the accounts that aren't. If all @@ -1032,9 +1035,11 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char g_hash_table_insert (account_hash, (char *) account->id->address, (void *) account); } - l = l->next; + e_iterator_next (iter); } + g_object_unref (iter); + to_addrs = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO); cc_addrs = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC); mail_ignore_address (composer, to_addrs); @@ -1337,13 +1342,13 @@ enumerate_msg (MessageList *ml, const char *uid, gpointer data) static EMsgComposer * forward_get_composer (CamelMimeMessage *message, const char *subject) { - const MailConfigAccount *account = NULL; struct _composer_callback_data *ccd; + EAccount *account = NULL; EMsgComposer *composer; if (message) { const CamelInternetAddress *to_addrs, *cc_addrs; - const GSList *accounts = NULL; + EAccountList *accounts; accounts = mail_config_get_accounts (); to_addrs = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO); @@ -1544,10 +1549,10 @@ post_reply (GtkWidget *widget, gpointer user_data) static EMsgComposer * redirect_get_composer (CamelMimeMessage *message) { - const MailConfigAccount *account = NULL; const CamelInternetAddress *to_addrs, *cc_addrs; - const GSList *accounts = NULL; struct _composer_callback_data *ccd; + EAccountList *accounts = NULL; + EAccount *account = NULL; EMsgComposer *composer; g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL); @@ -3151,12 +3156,13 @@ empty_trash_expunged_cb (CamelFolder *folder, void *data) void empty_trash (BonoboUIComponent *uih, void *user_data, const char *path) { - MailConfigAccount *account; CamelProvider *provider; - const GSList *accounts; + EAccountList *accounts; CamelFolder *vtrash; FolderBrowser *fb; CamelException ex; + EAccount *account; + EIterator *iter; fb = user_data ? FOLDER_BROWSER (user_data) : NULL; @@ -3167,11 +3173,12 @@ empty_trash (BonoboUIComponent *uih, void *user_data, const char *path) /* expunge all remote stores */ accounts = mail_config_get_accounts (); - while (accounts) { - account = accounts->data; + iter = e_list_get_iterator ((EList *) accounts); + while (e_iterator_is_valid (iter)) { + account = (EAccount *) e_iterator_get (iter); /* make sure this is a valid source */ - if (account->source && account->enabled && account->source->url) { + if (account->enabled && account->source->url) { provider = camel_session_get_provider (session, account->source->url, &ex); if (provider) { /* make sure this store is a remote store */ @@ -3188,14 +3195,16 @@ empty_trash (BonoboUIComponent *uih, void *user_data, const char *path) /* clear the exception for the next round */ camel_exception_clear (&ex); } - accounts = accounts->next; + + e_iterator_next (iter); } + g_object_unref (iter); + /* Now empty the local trash folder */ vtrash = mail_tool_get_trash ("file:/", TRUE, &ex); - if (vtrash) { + if (vtrash) mail_expunge_folder (vtrash, empty_trash_expunged_cb, NULL); - } camel_exception_clear (&ex); } diff --git a/mail/mail-config-druid.c b/mail/mail-config-druid.c index 639d2e31d0..c7791e3646 100644 --- a/mail/mail-config-druid.c +++ b/mail/mail-config-druid.c @@ -74,7 +74,7 @@ typedef enum { typedef struct { MailAccountGui *gui; - MailConfigAccount *account; + EAccount *account; EvolutionWizard *wizard; gboolean identity_copied; @@ -135,7 +135,7 @@ mail_config_druid_destroy (GtkObject *obj) bonobo_object_unref (BONOBO_OBJECT (druid->listener)); } - ((GtkObjectClass *)(parent_class))->destroy(obj); + ((GtkObjectClass *)(parent_class))->destroy(obj); } @@ -460,26 +460,27 @@ management_changed (GtkWidget *widget, gpointer data) gtk_widget_grab_focus (GTK_WIDGET (gui->gui->account_name)); } -static MailConfigAccount * +static EAccount * make_account (void) { - MailConfigAccount *account; const char *name, *user; + EAccountService *xport; struct utsname uts; + EAccount *account; - account = g_new0 (MailConfigAccount, 1); + account = e_account_new (); account->enabled = TRUE; - account->uid = e_account_gen_uid (); - account->id = g_new0 (MailConfigIdentity, 1); name = g_get_real_name (); account->id->name = g_strdup (name); user = g_get_user_name (); if (user && !uname (&uts) && strchr (uts.nodename, '.')) account->id->address = g_strdup_printf ("%s@%s", user, uts.nodename); - if (mail_config_get_default_transport ()) - account->transport = service_copy (mail_config_get_default_transport ()); + if ((xport = mail_config_get_default_transport ())) { + account->transport->url = g_strdup (xport->url); + account->transport->save_passwd = xport->save_passwd; + } return account; } @@ -763,15 +764,15 @@ management_activate_cb (GtkEntry *ent, gpointer user_data) static BonoboControl * get_fn (EvolutionWizard *wizard, - int page_num, - void *closure) + int page_num, + void *closure) { - MailConfigWizard *gui = closure; - BonoboControl *control; - GtkWidget *vbox, *widget; + MailConfigWizard *gui = closure; + BonoboControl *control; + GtkWidget *vbox, *widget; static gboolean first_time = TRUE; - if (gui->gui == NULL) { + if (gui->gui == NULL) { if (gui->account == NULL) { gui->account = make_account (); g_object_set_data ((GObject *) wizard, "account-data", gui->account); @@ -784,7 +785,7 @@ get_fn (EvolutionWizard *wizard, G_CALLBACK (management_changed), gui); g_signal_connect (gui->gui->full_name, "changed", G_CALLBACK (identity_changed), gui); - g_signal_connect (gui->gui->email_address, "changed", + g_signal_connect (gui->gui->email_address, "changed", G_CALLBACK (identity_changed), gui); g_signal_connect (gui->gui->reply_to,"changed", G_CALLBACK (identity_changed), gui); @@ -806,11 +807,11 @@ get_fn (EvolutionWizard *wizard, g_signal_connect (gui->gui->full_name, "activate", G_CALLBACK (identity_activate_cb), gui); - g_signal_connect (gui->gui->email_address, "activate", + g_signal_connect (gui->gui->email_address, "activate", G_CALLBACK (identity_activate_cb), gui); - g_signal_connect (gui->gui->reply_to,"activate", + g_signal_connect (gui->gui->reply_to,"activate", G_CALLBACK (identity_activate_cb), gui); - g_signal_connect (gui->gui->organization, "activate", + g_signal_connect (gui->gui->organization, "activate", G_CALLBACK (identity_activate_cb), gui); g_signal_connect (gui->gui->source.hostname, "activate", @@ -825,12 +826,12 @@ get_fn (EvolutionWizard *wizard, g_signal_connect (gui->gui->transport.username, "activate", G_CALLBACK (transport_activate_cb), gui); first_time = TRUE; - } + } - /* Fill in the druid pages */ + /* Fill in the druid pages */ vbox = gtk_vbox_new (FALSE, 0); - switch (page_num) { - case 0: + switch (page_num) { + case 0: widget = create_label ("identity_html"); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); widget = glade_xml_get_widget (gui->gui->xml, "identity_required_frame"); @@ -839,89 +840,89 @@ get_fn (EvolutionWizard *wizard, widget = glade_xml_get_widget (gui->gui->xml, "identity_optional_frame"); gtk_widget_reparent (widget, vbox); gtk_box_set_child_packing (GTK_BOX (vbox), widget, FALSE, FALSE, 0, GTK_PACK_START); - break; - case 1: + break; + case 1: widget = create_label ("source_html"); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); widget = glade_xml_get_widget (gui->gui->xml, "source_vbox"); - gtk_widget_reparent (widget, vbox); + gtk_widget_reparent (widget, vbox); gtk_widget_show (widget); - break; - case 2: + break; + case 2: widget = create_label ("extra_html"); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); - widget = glade_xml_get_widget (gui->gui->xml, "extra_vbox"); - gtk_widget_reparent (widget, vbox); - break; - case 3: + widget = glade_xml_get_widget (gui->gui->xml, "extra_vbox"); + gtk_widget_reparent (widget, vbox); + break; + case 3: widget = create_label ("transport_html"); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); - widget = glade_xml_get_widget (gui->gui->xml, "transport_vbox"); - gtk_widget_reparent (widget, vbox); + widget = glade_xml_get_widget (gui->gui->xml, "transport_vbox"); + gtk_widget_reparent (widget, vbox); gtk_widget_show (widget); - break; - case 4: + break; + case 4: widget = glade_xml_get_widget (gui->gui->xml, "management_frame"); gtk_widget_reparent (widget, vbox); break; - default: - return NULL; - } + default: + return NULL; + } - gtk_widget_show (vbox); - control = bonobo_control_new (vbox); + gtk_widget_show (vbox); + control = bonobo_control_new (vbox); if (first_time) { mail_account_gui_setup (gui->gui, NULL); first_time = FALSE; } - return control; + return control; } typedef gboolean (*NextFunc)(EvolutionWizard *wizard, gpointer data); typedef void (*PrepFunc)(EvolutionWizard *wizard, gpointer data); static struct { - NextFunc next_func; - PrepFunc prepare_func; - NextFunc back_func; - GtkSignalFunc finish_func; - GtkSignalFunc help_func; + NextFunc next_func; + PrepFunc prepare_func; + NextFunc back_func; + GtkSignalFunc finish_func; + GtkSignalFunc help_func; } wizard_pages[] = { - { identity_next, - identity_prepare, - NULL, - G_CALLBACK (NULL), - G_CALLBACK (NULL) }, - { source_next, - source_prepare, - NULL, - G_CALLBACK (NULL), - G_CALLBACK (NULL) }, - { NULL, - extra_prepare, - NULL, - G_CALLBACK (NULL), - G_CALLBACK (NULL) }, - { transport_next, - transport_prepare, - transport_back, - G_CALLBACK (NULL), - G_CALLBACK (NULL) }, - { NULL, - management_prepare, - NULL, - G_CALLBACK (NULL), - G_CALLBACK (NULL) } + { identity_next, + identity_prepare, + NULL, + G_CALLBACK (NULL), + G_CALLBACK (NULL) }, + { source_next, + source_prepare, + NULL, + G_CALLBACK (NULL), + G_CALLBACK (NULL) }, + { NULL, + extra_prepare, + NULL, + G_CALLBACK (NULL), + G_CALLBACK (NULL) }, + { transport_next, + transport_prepare, + transport_back, + G_CALLBACK (NULL), + G_CALLBACK (NULL) }, + { NULL, + management_prepare, + NULL, + G_CALLBACK (NULL), + G_CALLBACK (NULL) } }; static void wizard_next_cb (EvolutionWizard *wizard, - int page_num, - MailConfigWizard *gui) + int page_num, + MailConfigWizard *gui) { - if (wizard_pages[page_num].next_func == NULL + if (wizard_pages[page_num].next_func == NULL || !(wizard_pages[page_num].next_func (wizard, gui))) { if (page_num < 5-1) { evolution_wizard_set_page(wizard, page_num+1, NULL); @@ -931,26 +932,26 @@ wizard_next_cb (EvolutionWizard *wizard, static void wizard_prepare_cb (EvolutionWizard *wizard, - int page_num, - MailConfigWizard *gui) + int page_num, + MailConfigWizard *gui) { - if (wizard_pages[page_num].prepare_func != NULL) { - wizard_pages[page_num].prepare_func (wizard, gui); - } + if (wizard_pages[page_num].prepare_func != NULL) { + wizard_pages[page_num].prepare_func (wizard, gui); + } } static void wizard_back_cb (EvolutionWizard *wizard, - int page_num, - MailConfigWizard *gui) + int page_num, + MailConfigWizard *gui) { if (page_num >= 5) evolution_wizard_set_page(wizard, 4, NULL); - else if (wizard_pages[page_num].back_func == NULL + else if (wizard_pages[page_num].back_func == NULL || !(wizard_pages[page_num].back_func (wizard, gui))) { if (page_num > 0) evolution_wizard_set_page(wizard, page_num-1, NULL); - } + } } static void @@ -974,8 +975,8 @@ wizard_finish_cb (EvolutionWizard *wizard, static void wizard_cancel_cb (EvolutionWizard *wizard, - int page_num, - MailConfigWizard *gui) + int page_num, + MailConfigWizard *gui) { mail_account_gui_destroy (gui->gui); gui->gui = NULL; @@ -983,8 +984,8 @@ wizard_cancel_cb (EvolutionWizard *wizard, static void wizard_help_cb (EvolutionWizard *wizard, - int page_num, - MailConfigWizard *gui) + int page_num, + MailConfigWizard *gui) { } @@ -1001,34 +1002,34 @@ wizard_free (MailConfigWizard *wizard) } BonoboObject * -evolution_mail_config_wizard_new(void) +evolution_mail_config_wizard_new (void) { EvolutionWizard *wizard; - MailConfigAccount *account; - MailConfigWizard *gui; + MailConfigWizard *gui; + EAccount *account; - account = make_account (); + account = make_account (); - gui = g_new (MailConfigWizard, 1); + gui = g_new (MailConfigWizard, 1); gui->gui = NULL; - gui->account = account; + gui->account = account; gui->identity_copied = FALSE; gui->last_source = NULL; gui->page = MAIL_CONFIG_WIZARD_PAGE_NONE; - wizard = evolution_wizard_new (get_fn, 5, gui); + wizard = evolution_wizard_new (get_fn, 5, gui); account_wizard = wizard; g_object_set_data_full ((GObject *) account_wizard, "account-data", gui, (GDestroyNotify) wizard_free); gui->wizard = wizard; - g_signal_connect (wizard, "next", G_CALLBACK (wizard_next_cb), gui); - g_signal_connect (wizard, "prepare", G_CALLBACK (wizard_prepare_cb), gui); - g_signal_connect (wizard, "back", G_CALLBACK (wizard_back_cb), gui); - g_signal_connect (wizard, "finish", G_CALLBACK (wizard_finish_cb), gui); - g_signal_connect (wizard, "cancel", G_CALLBACK (wizard_cancel_cb), gui); - g_signal_connect (wizard, "help", G_CALLBACK (wizard_help_cb), gui); + g_signal_connect (wizard, "next", G_CALLBACK (wizard_next_cb), gui); + g_signal_connect (wizard, "prepare", G_CALLBACK (wizard_prepare_cb), gui); + g_signal_connect (wizard, "back", G_CALLBACK (wizard_back_cb), gui); + g_signal_connect (wizard, "finish", G_CALLBACK (wizard_finish_cb), gui); + g_signal_connect (wizard, "cancel", G_CALLBACK (wizard_cancel_cb), gui); + g_signal_connect (wizard, "help", G_CALLBACK (wizard_help_cb), gui); - return BONOBO_OBJECT (wizard); + return BONOBO_OBJECT (wizard); } diff --git a/mail/mail-config.c b/mail/mail-config.c index 54ffbb1d31..b370c96932 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -54,7 +54,6 @@ #include <gal/util/e-util.h> #include <gal/widgets/e-gui-utils.h> -#include <e-util/e-account.h> #include <e-util/e-url.h> #include <e-util/e-passwords.h> #include "mail.h" @@ -78,7 +77,7 @@ typedef struct { gboolean corrupt; - GSList *accounts; + EAccountList *accounts; guint accounts_notify_id; GHashTable *threaded_hash; @@ -99,9 +98,6 @@ static guint config_write_timeout = 0; #define MAIL_CONFIG_IID "OAFIID:GNOME_Evolution_MailConfig_Factory" -/* Prototypes */ -static void config_read (void); - /* signatures */ MailConfigSignature * signature_copy (const MailConfigSignature *sig) @@ -130,145 +126,6 @@ signature_destroy (MailConfigSignature *sig) g_free (sig); } -/* Identity */ -MailConfigIdentity * -identity_copy (const MailConfigIdentity *id) -{ - MailConfigIdentity *new; - - g_return_val_if_fail (id != NULL, NULL); - - new = g_new0 (MailConfigIdentity, 1); - new->name = g_strdup (id->name); - new->address = g_strdup (id->address); - new->reply_to = g_strdup (id->reply_to); - new->organization = g_strdup (id->organization); - new->def_signature = id->def_signature; - new->auto_signature = id->auto_signature; - - return new; -} - -void -identity_destroy (MailConfigIdentity *id) -{ - if (!id) - return; - - g_free (id->name); - g_free (id->address); - g_free (id->reply_to); - g_free (id->organization); - - g_free (id); -} - -/* Service */ -MailConfigService * -service_copy (const MailConfigService *source) -{ - MailConfigService *new; - - g_return_val_if_fail (source != NULL, NULL); - - new = g_new0 (MailConfigService, 1); - new->url = g_strdup (source->url); - new->keep_on_server = source->keep_on_server; - new->auto_check = source->auto_check; - new->auto_check_time = source->auto_check_time; - new->save_passwd = source->save_passwd; - - return new; -} - -void -service_destroy (MailConfigService *source) -{ - if (!source) - return; - - g_free (source->url); - - g_free (source); -} - -void -service_destroy_each (gpointer item, gpointer data) -{ - service_destroy ((MailConfigService *) item); -} - -/* Account */ -MailConfigAccount * -account_copy (const MailConfigAccount *account) -{ - MailConfigAccount *new; - - g_return_val_if_fail (account != NULL, NULL); - - new = g_new0 (MailConfigAccount, 1); - new->name = g_strdup (account->name); - new->uid = e_account_gen_uid (); - - new->enabled = account->enabled; - - new->id = identity_copy (account->id); - new->source = service_copy (account->source); - new->transport = service_copy (account->transport); - - new->drafts_folder_uri = g_strdup (account->drafts_folder_uri); - new->sent_folder_uri = g_strdup (account->sent_folder_uri); - - new->always_cc = account->always_cc; - new->cc_addrs = g_strdup (account->cc_addrs); - new->always_bcc = account->always_bcc; - new->bcc_addrs = g_strdup (account->bcc_addrs); - - new->pgp_key = g_strdup (account->pgp_key); - new->pgp_encrypt_to_self = account->pgp_encrypt_to_self; - new->pgp_always_sign = account->pgp_always_sign; - new->pgp_no_imip_sign = account->pgp_no_imip_sign; - new->pgp_always_trust = account->pgp_always_trust; - - new->smime_key = g_strdup (account->smime_key); - new->smime_encrypt_to_self = account->smime_encrypt_to_self; - new->smime_always_sign = account->smime_always_sign; - - return new; -} - -void -account_destroy (MailConfigAccount *account) -{ - if (!account) - return; - - g_free (account->name); - g_free (account->uid); - - identity_destroy (account->id); - service_destroy (account->source); - service_destroy (account->transport); - - g_free (account->drafts_folder_uri); - g_free (account->sent_folder_uri); - - g_free (account->cc_addrs); - g_free (account->bcc_addrs); - - g_free (account->pgp_key); - g_free (account->smime_key); - - g_free (account); -} - -void -account_destroy_each (gpointer item, gpointer data) -{ - account_destroy ((MailConfigAccount *) item); -} - - static gboolean xml_get_bool (xmlNodePtr node, const char *name) { @@ -342,363 +199,10 @@ lookup_signature (int id) return NULL; } -static MailConfigAccount * -account_new_from_xml (char *in) -{ - MailConfigAccount *account; - xmlNodePtr node, cur; - xmlDocPtr doc; - char *buf; - - if (!(doc = xmlParseDoc (in))) - return NULL; - - node = doc->children; - if (strcmp (node->name, "account") != 0) { - xmlFreeDoc (doc); - return NULL; - } - - account = g_new0 (MailConfigAccount, 1); - account->name = xml_get_prop (node, "name"); - account->uid = xml_get_prop (node, "uid"); - account->enabled = xml_get_bool (node, "enabled"); - - /* temporary pre-1.4 back compat */ - if (!account->uid) - account->uid = e_account_gen_uid (); - - node = node->children; - while (node != NULL) { - if (!strcmp (node->name, "identity")) { - account->id = g_new0 (MailConfigIdentity, 1); - - cur = node->children; - while (cur != NULL) { - if (!strcmp (cur->name, "name")) { - account->id->name = xml_get_content (cur); - } else if (!strcmp (cur->name, "addr-spec")) { - account->id->address = xml_get_content (cur); - } else if (!strcmp (cur->name, "reply-to")) { - account->id->reply_to = xml_get_content (cur); - } else if (!strcmp (cur->name, "organization")) { - account->id->organization = xml_get_content (cur); - } else if (!strcmp (cur->name, "signature")) { - account->id->auto_signature = xml_get_bool (cur, "auto"); - account->id->def_signature = lookup_signature (xml_get_int (cur, "default")); - } - - cur = cur->next; - } - } else if (!strcmp (node->name, "source")) { - int timeout; - - account->source = g_new0 (MailConfigService, 1); - account->source->save_passwd = xml_get_bool (node, "save-passwd"); - account->source->keep_on_server = xml_get_bool (node, "keep-on-server"); - account->source->auto_check = xml_get_bool (node, "auto-check"); - timeout = xml_get_int (node, "auto-check-timeout"); - if (account->source->auto_check && timeout <= 0) { - account->source->auto_check = FALSE; - account->source->auto_check_time = 0; - } else { - account->source->auto_check_time = timeout; - } - - cur = node->children; - while (cur != NULL) { - if (!strcmp (cur->name, "url")) { - account->source->url = xml_get_content (cur); - break; - } - cur = cur->next; - } - } else if (!strcmp (node->name, "transport")) { - account->transport = g_new0 (MailConfigService, 1); - account->transport->save_passwd = xml_get_bool (node, "save-passwd"); - - cur = node->children; - while (cur != NULL) { - if (!strcmp (cur->name, "url")) { - account->transport->url = xml_get_content (cur); - break; - } - cur = cur->next; - } - } else if (!strcmp (node->name, "drafts-folder")) { - account->drafts_folder_uri = xml_get_content (node); - } else if (!strcmp (node->name, "sent-folder")) { - account->sent_folder_uri = xml_get_content (node); - } else if (!strcmp (node->name, "auto-cc")) { - account->always_cc = xml_get_bool (node, "always"); - account->cc_addrs = xml_get_content (node); - } else if (!strcmp (node->name, "auto-bcc")) { - account->always_cc = xml_get_bool (node, "always"); - account->bcc_addrs = xml_get_content (node); - } else if (!strcmp (node->name, "pgp")) { - account->pgp_encrypt_to_self = xml_get_bool (node, "encrypt-to-self"); - account->pgp_always_trust = xml_get_bool (node, "always-trust"); - account->pgp_always_sign = xml_get_bool (node, "always-sign"); - account->pgp_no_imip_sign = xml_get_bool (node, "no-imip-sign"); - - if (node->children) { - cur = node->children; - while (cur != NULL) { - if (!strcmp (cur->name, "key-id")) { - account->pgp_key = xml_get_content (cur); - break; - } - - cur = cur->next; - } - } - } else if (!strcmp (node->name, "smime")) { - account->smime_encrypt_to_self = xml_get_bool (node, "encrypt-to-self"); - account->smime_always_sign = xml_get_bool (node, "always-sign"); - - if (node->children) { - cur = node->children; - while (cur != NULL) { - if (!strcmp (cur->name, "key-id")) { - account->smime_key = xml_get_content (cur); - break; - } - - cur = cur->next; - } - } - } - - node = node->next; - } - - xmlFreeDoc (doc); - - return account; -} - -static char * -account_to_xml (MailConfigAccount *account) -{ - xmlNodePtr root, node, id, src, xport; - char *xmlbuf, *tmp, buf[20]; - xmlDocPtr doc; - int n; - - doc = xmlNewDoc ("1.0"); - - root = xmlNewDocNode (doc, NULL, "account", NULL); - xmlDocSetRootElement (doc, root); - - xmlSetProp (root, "name", account->name); - xmlSetProp (root, "uid", account->uid); - xmlSetProp (root, "enabled", account->enabled ? "true" : "false"); - - id = xmlNewChild (root, NULL, "identity", NULL); - if (account->id->name) - xmlNewTextChild (id, NULL, "name", account->id->name); - if (account->id->address) - xmlNewTextChild (id, NULL, "addr-spec", account->id->address); - if (account->id->reply_to) - xmlNewTextChild (id, NULL, "reply-to", account->id->reply_to); - if (account->id->organization) - xmlNewTextChild (id, NULL, "organization", account->id->organization); - - node = xmlNewChild (id, NULL, "signature", NULL); - xmlSetProp (node, "auto", account->id->auto_signature ? "true" : "false"); - sprintf (buf, "%d", account->id->def_signature); - xmlSetProp (node, "default", buf); - - src = xmlNewChild (root, NULL, "source", NULL); - xmlSetProp (src, "save-passwd", account->source->save_passwd ? "true" : "false"); - xmlSetProp (src, "keep-on-server", account->source->keep_on_server ? "true" : "false"); - xmlSetProp (src, "auto-check", account->source->auto_check ? "true" : "false"); - sprintf (buf, "%d", account->source->auto_check_time); - xmlSetProp (src, "auto-check-timeout", buf); - if (account->source->url) - xmlNewTextChild (src, NULL, "url", account->source->url); - - xport = xmlNewChild (root, NULL, "transport", NULL); - xmlSetProp (xport, "save-passwd", account->transport->save_passwd ? "true" : "false"); - if (account->transport->url) - xmlNewTextChild (xport, NULL, "url", account->transport->url); - - xmlNewTextChild (root, NULL, "drafts-folder", account->drafts_folder_uri); - xmlNewTextChild (root, NULL, "sent-folder", account->sent_folder_uri); - - node = xmlNewChild (root, NULL, "auto-cc", NULL); - xmlSetProp (node, "always", account->always_cc ? "true" : "false"); - if (account->cc_addrs) - xmlNewTextChild (node, NULL, "recipients", account->cc_addrs); - - node = xmlNewChild (root, NULL, "auto-bcc", NULL); - xmlSetProp (node, "always", account->always_bcc ? "true" : "false"); - if (account->bcc_addrs) - xmlNewTextChild (node, NULL, "recipients", account->bcc_addrs); - - node = xmlNewChild (root, NULL, "pgp", NULL); - xmlSetProp (node, "encrypt-to-self", account->pgp_encrypt_to_self ? "true" : "false"); - xmlSetProp (node, "always-trust", account->pgp_always_trust ? "true" : "false"); - xmlSetProp (node, "always-sign", account->pgp_always_sign ? "true" : "false"); - xmlSetProp (node, "no-imip-sign", account->pgp_no_imip_sign ? "true" : "false"); - if (account->pgp_key) - xmlNewTextChild (node, NULL, "key-id", account->pgp_key); - - node = xmlNewChild (root, NULL, "smime", NULL); - xmlSetProp (node, "encrypt-to-self", account->smime_encrypt_to_self ? "true" : "false"); - xmlSetProp (node, "always-sign", account->smime_always_sign ? "true" : "false"); - if (account->smime_key) - xmlNewTextChild (node, NULL, "key-id", account->smime_key); - - xmlDocDumpMemory (doc, (xmlChar **) &xmlbuf, &n); - xmlFreeDoc (doc); - - /* remap to glib memory */ - tmp = g_malloc (n + 1); - memcpy (tmp, xmlbuf, n); - tmp[n] = '\0'; - xmlFree (xmlbuf); - - return tmp; -} - -static void -accounts_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data) -{ - GSList *list, *l, *tail, *n; - - if (config->accounts != NULL) { - l = config->accounts; - while (l != NULL) { - n = l->next; - account_destroy ((MailConfigAccount *) l->data); - g_slist_free_1 (l); - l = n; - } - - config->accounts = NULL; - } - - tail = NULL; - list = gconf_client_get_list (config->gconf, "/apps/evolution/mail/accounts", - GCONF_VALUE_STRING, NULL); - - l = list; - while (l != NULL) { - MailConfigAccount *account; - - if ((account = account_new_from_xml ((char *) l->data))) { - n = g_slist_alloc (); - n->data = account; - n->next = NULL; - - if (tail == NULL) - config->accounts = n; - else - tail->next = n; - tail = n; - } - - n = l->next; - g_slist_free_1 (l); - l = n; - } -} - -static void -accounts_save (void) -{ - GSList *list, *tail, *n, *l; - char *xmlbuf; - - list = NULL; - tail = NULL; - - l = config->accounts; - while (l != NULL) { - if ((xmlbuf = account_to_xml ((MailConfigAccount *) l->data))) { - n = g_slist_alloc (); - n->data = xmlbuf; - n->next = NULL; - - if (tail == NULL) - list = n; - else - tail->next = n; - tail = n; - } - - l = l->next; - } - - gconf_client_set_list (config->gconf, "/apps/evolution/mail/accounts", GCONF_VALUE_STRING, list, NULL); - - l = list; - while (l != NULL) { - n = l->next; - g_free (l->data); - g_slist_free_1 (l); - l = n; - } - - gconf_client_suggest_sync (config->gconf, NULL); -} - void mail_config_save_accounts (void) { - gconf_client_notify_remove (config->gconf, config->accounts_notify_id); - - accounts_save (); - - config->accounts_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/accounts", - accounts_changed, NULL, NULL, NULL); -} - -/* Config struct routines */ -void -mail_config_init (void) -{ - if (config) - return; - - config = g_new0 (MailConfig, 1); - config->gconf = gconf_client_get_default (); - - gconf_client_add_dir (config->gconf, "/apps/evolution/mail/accounts", - GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - - config->accounts_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/accounts", - accounts_changed, NULL, NULL, NULL); - - config_read (); -} - -void -mail_config_clear (void) -{ - GSList *list, *l, *n; - int i; - - if (!config) - return; - - l = config->accounts; - while (l != NULL) { - n = l->next; - account_destroy ((MailConfigAccount *) l->data); - g_slist_free_1 (l); - l = n; - } - - config->accounts = NULL; - - for (i = 0; i < 5; i++) { - g_free (config->labels[i].name); - config->labels[i].name = NULL; - g_free (config->labels[i].string); - config->labels[i].string = NULL; - } + e_account_list_save (config->accounts); } static MailConfigSignature * @@ -857,24 +361,49 @@ config_write_signatures (void) gconf_client_suggest_sync (config->gconf, NULL); } +/* Config struct routines */ void -mail_config_write_account_sig (MailConfigAccount *account, int id) +mail_config_init (void) { - /* FIXME: what is this supposed to do? */ - ; + if (config) + return; + + config = g_new0 (MailConfig, 1); + config->gconf = gconf_client_get_default (); + + mail_config_clear (); + + config_read_signatures (); + + config->accounts = e_account_list_new (config->gconf); } -static void -config_read (void) +void +mail_config_clear (void) { - int len, i, default_num; - char *path, *val, *p; + int i; - mail_config_clear (); + if (!config) + return; - config_read_signatures (); + if (config->accounts) { + g_object_unref (config->accounts); + config->accounts = NULL; + } - accounts_changed (config->gconf, 0, NULL, NULL); + for (i = 0; i < 5; i++) { + g_free (config->labels[i].name); + config->labels[i].name = NULL; + g_free (config->labels[i].string); + config->labels[i].string = NULL; + } +} + +void +mail_config_write_account_sig (EAccount *account, int id) +{ + /* FIXME: what is this supposed to do? */ + ; } void @@ -884,6 +413,7 @@ mail_config_write (void) return; config_write_signatures (); + e_account_list_save (config->accounts); gconf_client_suggest_sync (config->gconf, NULL); } @@ -909,8 +439,8 @@ hash_save_state (gpointer key, gpointer value, gpointer user_data) void mail_config_write_on_exit (void) { - MailConfigAccount *account; - const GSList *accounts; + EAccount *account; + EIterator *iter; char *path, *p; int i; @@ -928,10 +458,12 @@ mail_config_write_on_exit (void) /* then we make sure the ones we want to remember are in the session cache */ - accounts = config->accounts; - for ( ; accounts; accounts = accounts->next) { + iter = e_list_get_iterator ((EList *) config->accounts); + while (e_iterator_is_valid (iter)) { char *passwd; - account = accounts->data; + + account = (EAccount *) e_iterator_get (iter); + if (account->source->save_passwd && account->source->url) { passwd = mail_session_get_password (account->source->url); mail_session_forget_password (account->source->url); @@ -945,20 +477,27 @@ mail_config_write_on_exit (void) mail_session_add_password (account->transport->url, passwd); g_free (passwd); } + + e_iterator_next (iter); } + g_object_unref (iter); + /* then we clear out our component passwords */ e_passwords_clear_component_passwords ("Mail"); /* then we remember them */ - accounts = config->accounts; - for ( ; accounts; accounts = accounts->next) { - account = accounts->data; + iter = e_list_get_iterator ((EList *) config->accounts); + while (e_iterator_is_valid (iter)) { + account = (EAccount *) e_iterator_get (iter); + if (account->source->save_passwd && account->source->url) mail_session_remember_password (account->source->url); if (account->transport->save_passwd && account->transport->url) mail_session_remember_password (account->transport->url); + + e_iterator_next (iter); } /* now do cleanup */ @@ -969,7 +508,7 @@ mail_config_write_on_exit (void) gboolean mail_config_is_configured (void) { - return config->accounts != NULL; + return e_list_length ((EList *) config->accounts) > 0; } gboolean @@ -1117,16 +656,33 @@ mail_config_get_label_color_string (int label) } gboolean -mail_config_find_account (const MailConfigAccount *account) +mail_config_find_account (EAccount *account) { - return g_slist_find (config->accounts, (gpointer) account) != NULL; + EAccount *acnt; + EIterator *iter; + + iter = e_list_get_iterator ((EList *) config->accounts); + while (e_iterator_is_valid (iter)) { + acnt = (EAccount *) e_iterator_get (iter); + if (acnt == account) { + g_object_unref (iter); + return TRUE; + } + + e_iterator_next (iter); + } + + g_object_unref (iter); + + return FALSE; } -const MailConfigAccount * +EAccount * mail_config_get_default_account (void) { - MailConfigAccount *account; - int index; + EAccount *account = NULL; + EIterator *iter; + int index, n; if (config == NULL) mail_config_init (); @@ -1135,44 +691,63 @@ mail_config_get_default_account (void) return NULL; index = gconf_client_get_int (config->gconf, "/apps/evolution/mail/default_account", NULL); - account = g_slist_nth_data (config->accounts, index); - /* Looks like we have no default, so make the first account - the default */ + iter = e_list_get_iterator ((EList *) config->accounts); + n = 0; + + while (e_iterator_is_valid (iter)) { + if (n == index) { + account = (EAccount *) e_iterator_get (iter); + break; + } + + n++; + e_iterator_next (iter); + } + if (account == NULL) { + /* Looks like we have no default, so make the first account + the default */ + e_iterator_reset (iter); + account = (EAccount *) e_iterator_get (iter); + gconf_client_set_int (config->gconf, "/apps/evolution/mail/default_account", 0, NULL); - account = config->accounts->data; } + g_object_unref (iter); + return account; } -const MailConfigAccount * +EAccount * mail_config_get_account_by_name (const char *account_name) { - /* FIXME: this should really use a hash */ - const MailConfigAccount *account; - GSList *l; + EAccount *account; + EIterator *iter; - l = config->accounts; - while (l) { - account = l->data; - if (account && !strcmp (account->name, account_name)) + iter = e_list_get_iterator ((EList *) config->accounts); + while (e_iterator_is_valid (iter)) { + account = (EAccount *) e_iterator_get (iter); + if (!strcmp (account->name, account_name)) { + g_object_unref (iter); return account; + } - l = l->next; + e_iterator_next (iter); } + g_object_unref (iter); + return NULL; } -const MailConfigAccount * +EAccount * mail_config_get_account_by_source_url (const char *source_url) { - const MailConfigAccount *account; CamelProvider *provider; + EAccount *account; CamelURL *source; - GSList *l; + EIterator *iter; g_return_val_if_fail (source_url != NULL, NULL); @@ -1184,17 +759,19 @@ mail_config_get_account_by_source_url (const char *source_url) if (!source) return NULL; - l = config->accounts; - while (l) { - account = l->data; + iter = e_list_get_iterator ((EList *) config->accounts); + while (e_iterator_is_valid (iter)) { + account = (EAccount *) e_iterator_get (iter); - if (account && account->source && account->source->url) { + if (account->source && account->source->url) { CamelURL *url; url = camel_url_new (account->source->url, NULL); if (url && provider->url_equal (url, source)) { camel_url_free (url); camel_url_free (source); + g_object_unref (iter); + return account; } @@ -1202,21 +779,23 @@ mail_config_get_account_by_source_url (const char *source_url) camel_url_free (url); } - l = l->next; + e_iterator_next (iter); } + g_object_unref (iter); + camel_url_free (source); return NULL; } -const MailConfigAccount * +EAccount * mail_config_get_account_by_transport_url (const char *transport_url) { - const MailConfigAccount *account; CamelProvider *provider; CamelURL *transport; - GSList *l; + EAccount *account; + EIterator *iter; g_return_val_if_fail (transport_url != NULL, NULL); @@ -1228,17 +807,19 @@ mail_config_get_account_by_transport_url (const char *transport_url) if (!transport) return NULL; - l = config->accounts; - while (l) { - account = l->data; + iter = e_list_get_iterator ((EList *) config->accounts); + while (e_iterator_is_valid (iter)) { + account = (EAccount *) e_iterator_get (iter); - if (account && account->transport && account->transport->url) { + if (account->transport && account->transport->url) { CamelURL *url; url = camel_url_new (account->transport->url, NULL); if (url && provider->url_equal (url, transport)) { camel_url_free (url); camel_url_free (transport); + g_object_unref (iter); + return account; } @@ -1246,15 +827,17 @@ mail_config_get_account_by_transport_url (const char *transport_url) camel_url_free (url); } - l = l->next; + e_iterator_next (iter); } + g_object_unref (iter); + camel_url_free (transport); return NULL; } -const GSList * +EAccountList * mail_config_get_accounts (void) { g_assert (config != NULL); @@ -1263,16 +846,18 @@ mail_config_get_accounts (void) } void -mail_config_add_account (MailConfigAccount *account) +mail_config_add_account (EAccount *account) { - config->accounts = g_slist_append (config->accounts, account); + e_list_append ((EList *) config->accounts, account); mail_config_save_accounts (); } -const GSList * -mail_config_remove_account (MailConfigAccount *account) +void +mail_config_remove_account (EAccount *account) { + EAccount *acnt = NULL; + EIterator *iter; int index, cur; cur = gconf_client_get_int (config->gconf, "/apps/evolution/mail/default_account", NULL); @@ -1283,35 +868,61 @@ mail_config_remove_account (MailConfigAccount *account) gconf_client_set_int (config->gconf, "/apps/evolution/mail/default_account", 0, NULL); } else { /* adjust the default to make sure it points to the same one */ - index = g_slist_index (config->accounts, account); + index = 0; + iter = e_list_get_iterator ((EList *) config->accounts); + while (e_iterator_is_valid (iter)) { + acnt = (EAccount *) e_iterator_get (iter); + if (acnt == account) + break; + + index++; + e_iterator_next (iter); + } + + g_object_unref (iter); + if (cur > index) gconf_client_set_int (config->gconf, "/apps/evolution/mail/default_account", cur - 1, NULL); } - config->accounts = g_slist_remove (config->accounts, account); - account_destroy (account); + e_list_remove ((EList *) config->accounts, account); + g_object_unref (account); mail_config_save_accounts (); - - return config->accounts; } void -mail_config_set_default_account (const MailConfigAccount *account) +mail_config_set_default_account (EAccount *account) { - int index; + EIterator *iter; + EAccount *acnt; + int index = -1; + int i = 0; + + iter = e_list_get_iterator ((EList *) config->accounts); + while (e_iterator_is_valid (iter)) { + acnt = (EAccount *) e_iterator_get (iter); + if (acnt == account) { + index = i; + break; + } + + i++; + e_iterator_next (iter); + } + + g_object_unref (iter); - index = g_slist_index (config->accounts, (void *) account); if (index == -1) return; gconf_client_set_int (config->gconf, "/apps/evolution/mail/default_account", index, NULL); } -const MailConfigIdentity * +EAccountIdentity * mail_config_get_default_identity (void) { - const MailConfigAccount *account; + EAccount *account; account = mail_config_get_default_account (); if (account) @@ -1320,27 +931,32 @@ mail_config_get_default_identity (void) return NULL; } -const MailConfigService * +EAccountService * mail_config_get_default_transport (void) { - const MailConfigAccount *account; - const GSList *accounts; + EAccount *account; + EIterator *iter; account = mail_config_get_default_account (); if (account && account->transport && account->transport->url) return account->transport; /* return the first account with a transport? */ - accounts = config->accounts; - while (accounts) { - account = accounts->data; + iter = e_list_get_iterator ((EList *) config->accounts); + while (e_iterator_is_valid (iter)) { + account = (EAccount *) e_iterator_get (iter); - if (account->transport && account->transport->url) + if (account->transport && account->transport->url) { + g_object_unref (iter); + return account->transport; + } - accounts = accounts->next; + e_iterator_next (iter); } + g_object_unref (iter); + return NULL; } @@ -1362,11 +978,11 @@ uri_to_evname (const char *uri, const char *prefix) } void -mail_config_uri_renamed(GCompareFunc uri_cmp, const char *old, const char *new) +mail_config_uri_renamed (GCompareFunc uri_cmp, const char *old, const char *new) { - MailConfigAccount *ac; - const GSList *l; - int work = 0; + EAccount *account; + EIterator *iter; + int i, work = 0; gpointer oldkey, newkey, hashkey; gpointer val; char *oldname, *newname; @@ -1376,42 +992,46 @@ mail_config_uri_renamed(GCompareFunc uri_cmp, const char *old, const char *new) "*views/mail/current_view-", "*views/mail/custom_view-", NULL }; - int i; - - l = mail_config_get_accounts(); - while (l) { - ac = l->data; - if (ac->sent_folder_uri && uri_cmp(ac->sent_folder_uri, old)) { - g_free(ac->sent_folder_uri); - ac->sent_folder_uri = g_strdup(new); + + iter = e_list_get_iterator ((EList *) config->accounts); + while (e_iterator_is_valid (iter)) { + account = (EAccount *) e_iterator_get (iter); + + if (account->sent_folder_uri && uri_cmp (account->sent_folder_uri, old)) { + g_free (account->sent_folder_uri); + account->sent_folder_uri = g_strdup (new); work = 1; } - if (ac->drafts_folder_uri && uri_cmp(ac->drafts_folder_uri, old)) { - g_free(ac->drafts_folder_uri); - ac->drafts_folder_uri = g_strdup(new); + + if (account->drafts_folder_uri && uri_cmp (account->drafts_folder_uri, old)) { + g_free (account->drafts_folder_uri); + account->drafts_folder_uri = g_strdup (new); work = 1; } - l = l->next; + + e_iterator_next (iter); } - + + g_object_unref (iter); + oldkey = uri_to_key (old); newkey = uri_to_key (new); - + /* call this to load the hash table and the key */ mail_config_get_thread_list (old); if (g_hash_table_lookup_extended (config->threaded_hash, oldkey, &hashkey, &val)) { /*printf ("changing key in threaded_hash\n");*/ g_hash_table_remove (config->threaded_hash, hashkey); - g_hash_table_insert (config->threaded_hash, g_strdup(newkey), val); + g_hash_table_insert (config->threaded_hash, g_strdup (newkey), val); work = 2; } g_free (oldkey); g_free (newkey); - + /* ignore return values or if the files exist or * not, doesn't matter */ - + for (i = 0; cachenames[i]; i++) { oldname = uri_to_evname (old, cachenames[i]); newname = uri_to_evname (new, cachenames[i]); @@ -1420,44 +1040,47 @@ mail_config_uri_renamed(GCompareFunc uri_cmp, const char *old, const char *new) g_free (oldname); g_free (newname); } - + /* nasty ... */ if (work) - mail_config_write(); + mail_config_write (); } void -mail_config_uri_deleted(GCompareFunc uri_cmp, const char *uri) +mail_config_uri_deleted (GCompareFunc uri_cmp, const char *uri) { - MailConfigAccount *ac; - const GSList *l; + EAccount *account; + EIterator *iter; int work = 0; /* assumes these can't be removed ... */ extern char *default_sent_folder_uri, *default_drafts_folder_uri; - - l = mail_config_get_accounts(); - while (l) { - ac = l->data; - if (ac->sent_folder_uri && uri_cmp(ac->sent_folder_uri, uri)) { - g_free(ac->sent_folder_uri); - ac->sent_folder_uri = g_strdup(default_sent_folder_uri); + + iter = e_list_get_iterator ((EList *) config->accounts); + while (e_iterator_is_valid (iter)) { + account = (EAccount *) e_iterator_get (iter); + + if (account->sent_folder_uri && uri_cmp (account->sent_folder_uri, uri)) { + g_free (account->sent_folder_uri); + account->sent_folder_uri = g_strdup (default_sent_folder_uri); work = 1; } - if (ac->drafts_folder_uri && uri_cmp(ac->drafts_folder_uri, uri)) { - g_free(ac->drafts_folder_uri); - ac->drafts_folder_uri = g_strdup(default_drafts_folder_uri); + + if (account->drafts_folder_uri && uri_cmp (account->drafts_folder_uri, uri)) { + g_free (account->drafts_folder_uri); + account->drafts_folder_uri = g_strdup (default_drafts_folder_uri); work = 1; } - l = l->next; + + e_iterator_next (iter); } - + /* nasty again */ if (work) - mail_config_write(); + mail_config_write (); } void -mail_config_service_set_save_passwd (MailConfigService *service, gboolean save_passwd) +mail_config_service_set_save_passwd (EAccountService *service, gboolean save_passwd) { service->save_passwd = save_passwd; } @@ -1628,62 +1251,44 @@ impl_GNOME_Evolution_MailConfig_addAccount (PortableServer_Servant servant, { GNOME_Evolution_MailConfig_Service source, transport; GNOME_Evolution_MailConfig_Identity id; - MailConfigAccount *mail_account; - MailConfigService *mail_service; - MailConfigIdentity *mail_id; + EAccount *new; if (mail_config_get_account_by_name (account->name)) { /* FIXME: we need an exception. */ return; } - mail_account = g_new0 (MailConfigAccount, 1); - mail_account->name = g_strdup (account->name); - mail_account->enabled = source.enabled; + new = e_account_new (); + new->name = g_strdup (account->name); + new->enabled = source.enabled; /* Copy ID */ id = account->id; - mail_id = g_new0 (MailConfigIdentity, 1); - mail_id->name = g_strdup (id.name); - mail_id->address = g_strdup (id.address); - mail_id->reply_to = g_strdup (id.reply_to); - mail_id->organization = g_strdup (id.organization); - - mail_account->id = mail_id; + new->id->name = g_strdup (id.name); + new->id->address = g_strdup (id.address); + new->id->reply_to = g_strdup (id.reply_to); + new->id->organization = g_strdup (id.organization); /* Copy source */ source = account->source; - mail_service = g_new0 (MailConfigService, 1); - if (source.url == NULL || strcmp (source.url, "none://") == 0) { - mail_service->url = NULL; - } else { - mail_service->url = g_strdup (source.url); - } - mail_service->keep_on_server = source.keep_on_server; - mail_service->auto_check = source.auto_check; - mail_service->auto_check_time = source.auto_check_time; - mail_service->save_passwd = source.save_passwd; + if (!(source.url == NULL || strcmp (source.url, "none://") == 0)) + new->source->url = g_strdup (source.url); - mail_account->source = mail_service; + new->source->keep_on_server = source.keep_on_server; + new->source->auto_check = source.auto_check; + new->source->auto_check_time = source.auto_check_time; + new->source->save_passwd = source.save_passwd; /* Copy transport */ transport = account->transport; - mail_service = g_new0 (MailConfigService, 1); - if (transport.url == NULL) { - mail_service->url = NULL; - } else { - mail_service->url = g_strdup (transport.url); - } - mail_service->url = g_strdup (transport.url); - mail_service->keep_on_server = transport.keep_on_server; - mail_service->auto_check = transport.auto_check; - mail_service->auto_check_time = transport.auto_check_time; - mail_service->save_passwd = transport.save_passwd; + if (transport.url != NULL) + new->transport->url = g_strdup (transport.url); - mail_account->transport = mail_service; + new->transport->url = g_strdup (transport.url); + new->transport->save_passwd = transport.save_passwd; /* Add new account */ - mail_config_add_account (mail_account); + mail_config_add_account (new); /* Don't write out the config right away in case the remote * component is creating or removing multiple accounts. @@ -1697,12 +1302,11 @@ impl_GNOME_Evolution_MailConfig_removeAccount (PortableServer_Servant servant, const CORBA_char *name, CORBA_Environment *ev) { - MailConfigAccount *account; - - account = (MailConfigAccount *)mail_config_get_account_by_name (name); - if (account) + EAccount *account; + + if ((account = mail_config_get_account_by_name (name))) mail_config_remove_account (account); - + /* Don't write out the config right away in case the remote * component is creating or removing multiple accounts. */ @@ -1714,7 +1318,7 @@ static void evolution_mail_config_class_init (EvolutionMailConfigClass *klass) { POA_GNOME_Evolution_MailConfig__epv *epv = &klass->epv; - + parent_class = g_type_class_ref(PARENT_TYPE); epv->addAccount = impl_GNOME_Evolution_MailConfig_addAccount; epv->removeAccount = impl_GNOME_Evolution_MailConfig_removeAccount; @@ -1723,6 +1327,7 @@ evolution_mail_config_class_init (EvolutionMailConfigClass *klass) static void evolution_mail_config_init (EvolutionMailConfig *config) { + ; } BONOBO_TYPE_FUNC_FULL (EvolutionMailConfig, @@ -1736,9 +1341,9 @@ evolution_mail_config_factory_fn (BonoboGenericFactory *factory, void *closure) { EvolutionMailConfig *config; - + config = g_object_new (evolution_mail_config_get_type (), NULL); - + return BONOBO_OBJECT (config); } @@ -1866,19 +1471,28 @@ delete_unused_signature_file (const char *filename) void mail_config_signature_delete (MailConfigSignature *sig) { + EAccount *account; + EIterator *iter; GSList *node, *next; gboolean after = FALSE; + int index; - node = config->accounts; - while (node != NULL) { - MailConfigAccount *account = node->data; + index = g_slist_index (config->signatures, sig); + + iter = e_list_get_iterator ((EList *) config->accounts); + while (e_iterator_is_valid (iter)) { + account = (EAccount *) e_iterator_get (iter); - if (account->id->def_signature == sig) - account->id->def_signature = NULL; + if (account->id->def_signature == index) + account->id->def_signature = -1; + else if (account->id->def_signature > index) + account->id->def_signature--; - node = node->next; + e_iterator_next (iter); } + g_object_unref (iter); + node = config->signatures; while (node != NULL) { next = node->next; diff --git a/mail/mail-config.h b/mail/mail-config.h index 239a6d2feb..6f990b7a6d 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -26,6 +26,9 @@ #include <gtk/gtk.h> #include <camel/camel.h> +#include "e-util/e-account.h" +#include "e-util/e-account-list.h" + #ifdef __cplusplus extern "C" { #pragma } @@ -39,51 +42,6 @@ typedef struct { gboolean html; } MailConfigSignature; -typedef struct { - char *name; - char *address; - char *reply_to; - char *organization; - - MailConfigSignature *def_signature; - gboolean auto_signature; -} MailConfigIdentity; - -typedef struct { - char *url; - gboolean keep_on_server; - gboolean auto_check; - int auto_check_time; - gboolean save_passwd; -} MailConfigService; - -typedef struct { - char *name; - char *uid; - - gboolean enabled; - - MailConfigIdentity *id; - MailConfigService *source; - MailConfigService *transport; - - char *drafts_folder_uri, *sent_folder_uri; - - gboolean always_cc; - char *cc_addrs; - gboolean always_bcc; - char *bcc_addrs; - - char *pgp_key; - gboolean pgp_encrypt_to_self; - gboolean pgp_always_sign; - gboolean pgp_no_imip_sign; - gboolean pgp_always_trust; - - char *smime_key; - gboolean smime_encrypt_to_self; - gboolean smime_always_sign; -} MailConfigAccount; typedef enum { MAIL_CONFIG_HTTP_NEVER, @@ -135,20 +93,6 @@ extern MailConfigLabel label_defaults[5]; MailConfigSignature *signature_copy (const MailConfigSignature *sig); void signature_destroy (MailConfigSignature *sig); -/* Identities */ -MailConfigIdentity *identity_copy (const MailConfigIdentity *id); -void identity_destroy (MailConfigIdentity *id); - -/* Services */ -MailConfigService *service_copy (const MailConfigService *source); -void service_destroy (MailConfigService *source); -void service_destroy_each (gpointer item, gpointer data); - -/* Accounts */ -MailConfigAccount *account_copy (const MailConfigAccount *account); -void account_destroy (MailConfigAccount *account); -void account_destroy_each (gpointer item, gpointer data); - /* Configuration */ void mail_config_init (void); void mail_config_clear (void); @@ -168,30 +112,37 @@ guint32 mail_config_get_label_color (int label); void mail_config_set_label_color (int label, guint32 color); const char *mail_config_get_label_color_string (int label); -void mail_config_service_set_save_passwd (MailConfigService *service, gboolean save_passwd); +void mail_config_service_set_save_passwd (EAccountService *service, gboolean save_passwd); -gboolean mail_config_find_account (const MailConfigAccount *account); -const MailConfigAccount *mail_config_get_default_account (void); -const MailConfigAccount *mail_config_get_account_by_name (const char *account_name); -const MailConfigAccount *mail_config_get_account_by_source_url (const char *url); -const MailConfigAccount *mail_config_get_account_by_transport_url (const char *url); -const GSList *mail_config_get_accounts (void); -void mail_config_add_account (MailConfigAccount *account); -const GSList *mail_config_remove_account (MailConfigAccount *account); +gboolean mail_config_find_account (EAccount *account); +EAccount *mail_config_get_default_account (void); +EAccount *mail_config_get_account_by_name (const char *account_name); +EAccount *mail_config_get_account_by_source_url (const char *url); +EAccount *mail_config_get_account_by_transport_url (const char *url); +EAccountList *mail_config_get_accounts (void); +void mail_config_add_account (EAccount *account); +void mail_config_remove_account (EAccount *account); -void mail_config_set_default_account (const MailConfigAccount *account); +void mail_config_set_default_account (EAccount *account); -const MailConfigIdentity *mail_config_get_default_identity (void); -const MailConfigService *mail_config_get_default_transport (void); +EAccountIdentity *mail_config_get_default_identity (void); +EAccountService *mail_config_get_default_transport (void); void mail_config_save_accounts (void); -/* uri's got changed by the store, etc */ -void mail_config_uri_renamed(GCompareFunc uri_cmp, const char *old, const char *new); -void mail_config_uri_deleted(GCompareFunc uri_cmp, const char *uri); +GSList *mail_config_get_signature_list (void); +MailConfigSignature *mail_config_signature_add (gboolean html, const char *script); +void mail_config_signature_delete (MailConfigSignature *sig); +void mail_config_signature_write (MailConfigSignature *sig); +void mail_config_signature_set_name (MailConfigSignature *sig, const char *name); +void mail_config_signature_set_html (MailConfigSignature *sig, gboolean html); +void mail_config_signature_set_filename (MailConfigSignature *sig, const char *filename); -GtkType evolution_mail_config_get_type (void); +/* uri's got changed by the store, etc */ +void mail_config_uri_renamed (GCompareFunc uri_cmp, const char *old, const char *new); +void mail_config_uri_deleted (GCompareFunc uri_cmp, const char *uri); + /* static utility functions */ char *mail_config_folder_to_cachename (CamelFolder *folder, const char *prefix); @@ -201,15 +152,10 @@ gboolean mail_config_check_service (const char *url, CamelProviderType type, GLi +GtkType evolution_mail_config_get_type (void); + gboolean evolution_mail_config_factory_init (void); -GSList *mail_config_get_signature_list (void); -MailConfigSignature *mail_config_signature_add (gboolean html, const gchar *script); -void mail_config_signature_delete (MailConfigSignature *sig); -void mail_config_signature_write (MailConfigSignature *sig); -void mail_config_signature_set_name (MailConfigSignature *sig, const gchar *name); -void mail_config_signature_set_html (MailConfigSignature *sig, gboolean html); -void mail_config_signature_set_filename (MailConfigSignature *sig, const gchar *filename); typedef enum { MAIL_CONFIG_SIG_EVENT_NAME_CHANGED, @@ -225,7 +171,7 @@ void mail_config_signature_register_client (MailConfigSignatureClient client, gp void mail_config_signature_unregister_client (MailConfigSignatureClient client, gpointer data); void mail_config_signature_emit_event (MailConfigSigEvent event, MailConfigSignature *sig); -void mail_config_write_account_sig (MailConfigAccount *account, int i); +void mail_config_write_account_sig (EAccount *account, int i); char *mail_config_signature_run_script (char *script); #ifdef __cplusplus diff --git a/mail/mail-crypto.c b/mail/mail-crypto.c index 629bc8b845..68f91b35de 100644 --- a/mail/mail-crypto.c +++ b/mail/mail-crypto.c @@ -40,7 +40,7 @@ * options set based on the account provided. **/ CamelCipherContext * -mail_crypto_get_pgp_cipher_context (const MailConfigAccount *account) +mail_crypto_get_pgp_cipher_context (EAccount *account) { CamelCipherContext *cipher; diff --git a/mail/mail-crypto.h b/mail/mail-crypto.h index bc92e2a74b..1aebb286c8 100644 --- a/mail/mail-crypto.h +++ b/mail/mail-crypto.h @@ -36,7 +36,7 @@ extern "C" { /* PGP/MIME convenience wrappers */ -CamelCipherContext *mail_crypto_get_pgp_cipher_context (const MailConfigAccount *account); +CamelCipherContext *mail_crypto_get_pgp_cipher_context (EAccount *account); /* S/MIME v3 convenience wrappers */ diff --git a/mail/mail-ops.c b/mail/mail-ops.c index c9de994aaa..c7f12dd8a3 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -451,7 +451,7 @@ static void mail_send_message (CamelMimeMessage *message, const char *destination, CamelFilterDriver *driver, CamelException *ex) { - const MailConfigAccount *account = NULL; + EAccount *account = NULL; const CamelInternetAddress *iaddr; CamelAddress *from, *recipients; CamelMessageInfo *info; diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c index 532faa9866..64d9118a4a 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -277,7 +277,7 @@ static send_info_t get_receive_type(const char *url) } static struct _send_data * -build_dialogue (const GSList *accounts, CamelFolder *outbox, const char *destination) +build_dialogue (EAccountList *accounts, CamelFolder *outbox, const char *destination) { GtkDialog *gd; GtkTable *table; @@ -290,8 +290,9 @@ build_dialogue (const GSList *accounts, CamelFolder *outbox, const char *destina GtkButton *stop; GtkHSeparator *line; struct _send_info *info; - char *pretty_url; - const GSList *l; + char *pretty_url; + EAccount *account; + EIterator *iter; gd = (GtkDialog *)send_recv_dialogue = gtk_dialog_new_with_buttons(_("Send & Receive Mail"), NULL, 0, NULL); stop = (GtkButton *)gtk_button_new_from_stock(GTK_STOCK_CANCEL); @@ -302,30 +303,35 @@ build_dialogue (const GSList *accounts, CamelFolder *outbox, const char *destina gnome_window_icon_set_from_file (GTK_WINDOW (gd), EVOLUTION_ICONSDIR "/send-receive.xpm"); num_sources = 0; - l = accounts; - while (l != NULL) { - MailConfigAccount *account = l->data; + + iter = e_list_get_iterator ((EList *) accounts); + while (e_iterator_is_valid (iter)) { + account = (EAccount *) e_iterator_get (iter); - if (account->source && account->source->url) + if (account->source->url) num_sources++; - l = l->next; + e_iterator_next (iter); } - table = (GtkTable *)gtk_table_new (num_sources, 4, FALSE); + g_object_unref (iter); + + table = (GtkTable *) gtk_table_new (num_sources, 4, FALSE); gtk_box_pack_start (GTK_BOX (gd->vbox), GTK_WIDGET (table), TRUE, TRUE, 0); /* must bet setup after send_recv_dialogue as it may re-trigger send-recv button */ data = setup_send_data (); row = 0; - while (accounts) { - MailConfigAccount *account = accounts->data; - MailConfigService *source; + iter = e_list_get_iterator ((EList *) accounts); + while (e_iterator_is_valid (iter)) { + EAccountService *source; + + account = (EAccount *) e_iterator_get (iter); source = account->source; - if (!account->enabled || !source || !source->url) { - accounts = accounts->next; + if (!account->enabled || !source->url) { + e_iterator_next (iter); continue; } @@ -336,7 +342,7 @@ build_dialogue (const GSList *accounts, CamelFolder *outbox, const char *destina type = get_receive_type (source->url); if (type == SEND_INVALID) { - accounts = accounts->next; + e_iterator_next (iter); continue; } @@ -355,7 +361,7 @@ build_dialogue (const GSList *accounts, CamelFolder *outbox, const char *destina list = g_list_prepend (list, info); } else if (info->bar != NULL) { /* incase we get the same source pop up again */ - accounts = accounts->next; + e_iterator_next (iter); continue; } else if (info->timeout_id == 0) info->timeout_id = gtk_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info); @@ -387,11 +393,13 @@ build_dialogue (const GSList *accounts, CamelFolder *outbox, const char *destina info->stop = stop; info->data = data; - g_signal_connect(stop, "clicked", G_CALLBACK(receive_cancel), info); - accounts = accounts->next; + g_signal_connect (stop, "clicked", G_CALLBACK(receive_cancel), info); + e_iterator_next (iter); row = row + 2; } + g_object_unref (iter); + line = (GtkHSeparator *)gtk_hseparator_new (); gtk_table_attach (table, GTK_WIDGET (line), 0, 4, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 3, 3); row++; @@ -663,11 +671,11 @@ receive_update_got_store (char *uri, CamelStore *store, void *data) void mail_send_receive (void) { - const GSList *accounts; - GList *scan; - struct _send_data *data; extern CamelFolder *outbox_folder; - const MailConfigAccount *account; + struct _send_data *data; + EAccountList *accounts; + EAccount *account; + GList *scan; if (send_recv_dialogue != NULL) { if (GTK_WIDGET_REALIZED(send_recv_dialogue)) { @@ -680,13 +688,12 @@ void mail_send_receive (void) if (!camel_session_is_online (session)) return; - if (!(accounts = mail_config_get_accounts ())) - return; - account = mail_config_get_default_account (); - if (!account || !account->transport) + if (!account || !account->transport->url) return; + accounts = mail_config_get_accounts (); + data = build_dialogue (accounts, outbox_folder, account->transport->url); scan = data->infos; while (scan) { @@ -760,11 +767,11 @@ static void auto_clean_set(void *key, struct _auto_data *info, GHashTable *set) void mail_autoreceive_setup (void) { + EAccountList *accounts; GHashTable *set_hash; - const GSList *accounts; + EIterator *iter; - if (!(accounts = mail_config_get_accounts ())) - return; + accounts = mail_config_get_accounts (); if (auto_active == NULL) auto_active = g_hash_table_new(g_str_hash, g_str_equal); @@ -772,13 +779,15 @@ mail_autoreceive_setup (void) set_hash = g_hash_table_new(g_str_hash, g_str_equal); g_hash_table_foreach(auto_active, (GHFunc)auto_setup_set, set_hash); - while (accounts) { - MailConfigAccount *account = accounts->data; - MailConfigService *source; + iter = e_list_get_iterator ((EList *) accounts); + while (e_iterator_is_valid (iter)) { + EAccountService *source; + EAccount *account; + account = (EAccount *) e_iterator_get (iter); source = account->source; - if (account->enabled && source && source->url && source->auto_check) { + if (account->enabled && source->url && source->auto_check) { struct _auto_data *info; d(printf("setting up auto-receive mail for : %s\n", source->url)); @@ -805,9 +814,11 @@ mail_autoreceive_setup (void) } } - accounts = accounts->next; + e_iterator_next (iter); } - + + g_object_unref (iter); + g_hash_table_foreach(set_hash, (GHFunc)auto_clean_set, auto_active); g_hash_table_destroy(set_hash); } @@ -884,7 +895,7 @@ void mail_send (void) { extern CamelFolder *outbox_folder; - const MailConfigService *transport; + EAccountService *transport; struct _send_info *info; struct _send_data *data; send_info_t type; diff --git a/mail/mail-session.c b/mail/mail-session.c index 8bc1f89ef3..00402fa5b5 100644 --- a/mail/mail-session.c +++ b/mail/mail-session.c @@ -166,7 +166,7 @@ struct _pass_msg { char *service_url; char *key; - MailConfigService *config_service; + EAccountService *config_service; GtkWidget *check; GtkWidget *entry; char *result; @@ -227,7 +227,7 @@ pass_response (GtkDialog *dialog, int button, void *data) static void request_password (struct _pass_msg *m) { - const MailConfigAccount *mca = NULL; + EAccount *mca = NULL; char *title; /* If we already have a password_dialog up, save this request till later */ @@ -281,8 +281,8 @@ do_get_pass(struct _mail_msg *mm) MailSession *mail_session = MAIL_SESSION (m->session); if (!strcmp (m->item, "popb4smtp_uri")) { - char *url = camel_url_to_string(m->service->url, 0); - const MailConfigAccount *account = mail_config_get_account_by_transport_url(url); + char *url = camel_url_to_string (m->service->url, 0); + EAccount *account = mail_config_get_account_by_transport_url (url); g_free(url); if (account) diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index 43b47032a9..ec1eee12d7 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -1,12 +1,24 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - Copyright 2000, 2001 Ximian Inc. - - Author: Michael Zucchi <notzed@ximian.com> - - code for managing vfolders - - NOTE: dont run this through fucking indent. -*/ + * Authors: Michael Zucchi <notzed@ximian.com> + * + * Copyright 2000-2003 Ximian, Inc. (www.ximian.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ #ifdef HAVE_CONFIG_H #include <config.h> @@ -287,26 +299,37 @@ my_list_find(GList *l, const char *uri, GCompareFunc cmp) static int uri_is_ignore(const char *uri, GCompareFunc uri_cmp) { - int found = FALSE; - const GSList *l; - MailConfigAccount *ac; extern char *default_outbox_folder_uri, *default_sent_folder_uri, *default_drafts_folder_uri; - + EAccountList *accounts; + EAccount *account; + EIterator *iter; + int found = FALSE; + d(printf("checking '%s' against:\n %s\n %s\n %s\n", uri, default_outbox_folder_uri, default_sent_folder_uri, default_drafts_folder_uri)); - + found = (default_outbox_folder_uri && uri_cmp(default_outbox_folder_uri, uri)) || (default_sent_folder_uri && uri_cmp(default_sent_folder_uri, uri)) || (default_drafts_folder_uri && uri_cmp(default_drafts_folder_uri, uri)); - - l = mail_config_get_accounts(); - while (!found && l) { - ac = l->data; - d(printf("checkint sent_folder_uri '%s' == '%s'\n", ac->sent_folder_uri?ac->sent_folder_uri:"empty", uri)); - found = (ac->sent_folder_uri && uri_cmp(ac->sent_folder_uri, uri)) - || (ac->drafts_folder_uri && uri_cmp(ac->drafts_folder_uri, uri)); - l = l->next; + + accounts = mail_config_get_accounts (); + iter = e_list_get_iterator ((EList *) accounts); + while (e_iterator_is_valid (iter)) { + account = (EAccount *) e_iterator_get (iter); + + d(printf("checking sent_folder_uri '%s' == '%s'\n", + account->sent_folder_uri ? account->sent_folder_uri : "empty", uri)); + + found = (account->sent_folder_uri && uri_cmp (account->sent_folder_uri, uri)) + || (account->drafts_folder_uri && uri_cmp (account->drafts_folder_uri, uri)); + + if (found) + break; + + e_iterator_next (iter); } - + + g_object_unref (iter); + return found; } diff --git a/mail/mail.h b/mail/mail.h index 082403d173..1c40b52107 100644 --- a/mail/mail.h +++ b/mail/mail.h @@ -42,7 +42,7 @@ char *mail_identify_mime_part (CamelMimePart *part, MailDisplay *md); void mail_add_storage (CamelStore *store, const char *name, const char *uri); void mail_load_storage_by_uri (GNOME_Evolution_Shell shell, const char *uri, const char *name); /*takes a GSList of MailConfigServices */ -void mail_load_storages (GNOME_Evolution_Shell shell, const GSList *sources); +void mail_load_storages (GNOME_Evolution_Shell shell, EAccountList *sources); void mail_hash_storage (CamelService *store, EvolutionStorage *storage); EvolutionStorage *mail_lookup_storage (CamelStore *store); diff --git a/mail/subscribe-dialog.c b/mail/subscribe-dialog.c index ba53617715..7500b4a7ca 100644 --- a/mail/subscribe-dialog.c +++ b/mail/subscribe-dialog.c @@ -1365,7 +1365,7 @@ static void sc_filter_toggled (GtkWidget *widget, gpointer user_data) { SubscribeDialog *sc = SUBSCRIBE_DIALOG (user_data); - StoreData *store = sc->priv->current_store; + StoreData *store = sc->priv->current_store; if (!store) return; @@ -1377,18 +1377,6 @@ sc_filter_toggled (GtkWidget *widget, gpointer user_data) } static void -populate_store_foreach (MailConfigAccount *account, SubscribeDialog *sc) -{ - StoreData *sd; - - if (!account->enabled || !account->source || !account->source->url) - return; - - sd = store_data_new (account->source->url); - sc->priv->store_list = g_list_prepend (sc->priv->store_list, sd); -} - -static void kill_default_view (SubscribeDialog *sc) { gtk_widget_hide (sc->priv->none_item); @@ -1515,40 +1503,56 @@ got_sd_store (StoreData *sd, CamelStore *store, gpointer data) static void populate_store_list (SubscribeDialog *sc) { - const GSList *accounts; - GList *iter; + EAccountList *accounts; + EAccount *account; + EIterator *iter; GtkWidget *menu; GtkWidget *omenu; + GList *l; accounts = mail_config_get_accounts (); - g_slist_foreach ((GSList *) accounts, (GFunc) populate_store_foreach, sc); + iter = e_list_get_iterator ((EList *) accounts); + while (e_iterator_is_valid (iter)) { + StoreData *sd; + + account = (EAccount *) e_iterator_get (iter); + + if (account->enabled && account->source->url) { + sd = store_data_new (account->source->url); + sc->priv->store_list = g_list_prepend (sc->priv->store_list, sd); + } + + e_iterator_next (iter); + } + + g_object_unref (iter); menu = gtk_menu_new (); - - for (iter = sc->priv->store_list; iter; iter = iter->next) { + + for (l = sc->priv->store_list; l; l = l->next) { GtkWidget *item; CamelURL *url; char *string; - - url = camel_url_new (((StoreData *) iter->data)->uri, NULL); + + url = camel_url_new (((StoreData *) l->data)->uri, NULL); string = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); camel_url_free (url); item = gtk_menu_item_new_with_label (string); - store_data_async_get_store (iter->data, got_sd_store, item); - g_object_set_data (G_OBJECT (item), STORE_DATA_KEY, iter->data); - g_signal_connect(item, "activate", G_CALLBACK(menu_item_selected), sc); + store_data_async_get_store (l->data, got_sd_store, item); + g_object_set_data (G_OBJECT (item), STORE_DATA_KEY, l->data); + g_signal_connect (item, "activate", G_CALLBACK (menu_item_selected), sc); g_free (string); - + gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); } - + sc->priv->none_item = gtk_menu_item_new_with_label (_("No server has been selected")); - g_signal_connect(sc->priv->none_item, "activate", G_CALLBACK(dummy_item_selected), sc); + g_signal_connect (sc->priv->none_item, "activate", G_CALLBACK (dummy_item_selected), sc); gtk_widget_show (sc->priv->none_item); - gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), sc->priv->none_item); - + gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), sc->priv->none_item); + gtk_widget_show (menu); - + omenu = glade_xml_get_widget (sc->priv->xml, "store_menu"); gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); } |