aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-01-27 20:35:26 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-01-27 20:35:26 +0800
commitce042b31b62f51282a3e66d1d0725fd5236d9096 (patch)
tree61c6c032f5d7fcdfb2ee7b7dd9cd96bd84e629ad
parent2cf803cfc656c511342b5d80f464fe590b3f5d9d (diff)
downloadgsoc2013-evolution-ce042b31b62f51282a3e66d1d0725fd5236d9096.tar.gz
gsoc2013-evolution-ce042b31b62f51282a3e66d1d0725fd5236d9096.tar.zst
gsoc2013-evolution-ce042b31b62f51282a3e66d1d0725fd5236d9096.zip
** See bug #53084 and others.
2004-01-27 Not Zed <NotZed@Ximian.com> ** See bug #53084 and others. * em-migrate.c (em_migrate): remove the vfolder_revert hack. * em-composer-utils.c (ask_confirm_for_only_bcc): removed unused vars. * mail-tools.c (mail_tool_get_local_inbox): removed, handled by mail_component_get_folder now. * mail-component.c (mail_component_*): Changed the api slightly. Using NULL as the component argument automatically implies you want the default component. (em_uri_from_camel, em_uri_to_camel): moved to em-utils.[ch]. Ok so it isn't namespaced right ... *shrug*. (mail_component_get_local_inbox): removed. (mail_component_get_folder): single entry point for getting standard folders. This is MT-Safe. (mail_component_get_folder_uri): single entry point for getting standard folder uri's. This is MT-Safe. (add_store): removed, moved to mail_component_add_store. (mail_component_load_store_by_uri): call mail_component_add_store directly rather than copying its code. (default_*_folder*): Removed, use accessor methods instead, fixed all callers. (setup_local_store): renamed to mc_setup_local_store, use proper url encoding too. make run-once and thread-safe. (MailComponentPrivate): Added a lock. (mail_control_new): exported properly to kill warnings. (mail_component_init): dont setup_local_store or add accounts here. (impl_createControls): setup local store/accounts here. (mail_component_peek): dont setup vfolder storage here. (mc_startup): internal function to startup stuff needed for gui operation. (setup_search_context): make run-once. (mail_component_peek_search_context): call setup_search_context incase it isn't setup yet. (impl_upgradeFromVersion): remove the local store setup hack. svn path=/trunk/; revision=24462
-rw-r--r--mail/ChangeLog42
-rw-r--r--mail/em-composer-utils.c8
-rw-r--r--mail/em-migrate.c4
-rw-r--r--mail/em-subscribe-editor.c1
-rw-r--r--mail/em-utils.c136
-rw-r--r--mail/em-utils.h3
-rw-r--r--mail/mail-account-gui.c15
-rw-r--r--mail/mail-autofilter.c1
-rw-r--r--mail/mail-component.c423
-rw-r--r--mail/mail-component.h24
-rw-r--r--mail/mail-config.c3
-rw-r--r--mail/mail-folder-cache.c11
-rw-r--r--mail/mail-ops.c17
-rw-r--r--mail/mail-send-recv.c14
-rw-r--r--mail/mail-tools.c10
-rw-r--r--mail/mail-tools.h3
-rw-r--r--mail/mail-vfolder.c7
17 files changed, 413 insertions, 309 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 8fae433051..79b3ace9aa 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,47 @@
2004-01-27 Not Zed <NotZed@Ximian.com>
+ ** See bug #53084 and others.
+
+ * em-migrate.c (em_migrate): remove the vfolder_revert hack.
+
+ * em-composer-utils.c (ask_confirm_for_only_bcc): removed unused
+ vars.
+
+ * mail-tools.c (mail_tool_get_local_inbox): removed, handled by
+ mail_component_get_folder now.
+
+ * mail-component.c (mail_component_*): Changed the api slightly.
+ Using NULL as the component argument automatically implies you
+ want the default component.
+ (em_uri_from_camel, em_uri_to_camel): moved to em-utils.[ch]. Ok
+ so it isn't namespaced right ... *shrug*.
+ (mail_component_get_local_inbox): removed.
+ (mail_component_get_folder): single entry point for getting
+ standard folders. This is MT-Safe.
+ (mail_component_get_folder_uri): single entry point for getting
+ standard folder uri's. This is MT-Safe.
+ (add_store): removed, moved to mail_component_add_store.
+ (mail_component_load_store_by_uri): call mail_component_add_store
+ directly rather than copying its code.
+ (default_*_folder*): Removed, use accessor methods instead, fixed
+ all callers.
+ (setup_local_store): renamed to mc_setup_local_store, use proper
+ url encoding too. make run-once and thread-safe.
+ (MailComponentPrivate): Added a lock.
+ (mail_control_new): exported properly to kill warnings.
+ (mail_component_init): dont setup_local_store or add accounts
+ here.
+ (impl_createControls): setup local store/accounts here.
+ (mail_component_peek): dont setup vfolder storage here.
+ (mc_startup): internal function to startup stuff needed for gui
+ operation.
+ (setup_search_context): make run-once.
+ (mail_component_peek_search_context): call setup_search_context
+ incase it isn't setup yet.
+ (impl_upgradeFromVersion): remove the local store setup hack.
+
+2004-01-27 Not Zed <NotZed@Ximian.com>
+
* em-folder-tree-model.c (folder_renamed): fix the parent-finding
logic.
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 09ca8a8b4f..b31ee4f9ee 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -33,6 +33,7 @@
#include "mail-config.h"
#include "mail-session.h"
#include "mail-send-recv.h"
+#include "mail-component.h"
#include <e-util/e-dialog-utils.h> /* e_notice */
@@ -140,7 +141,6 @@ ask_confirm_for_empty_subject (EMsgComposer *composer)
static gboolean
ask_confirm_for_only_bcc (EMsgComposer *composer, gboolean hidden_list_case)
{
- gboolean show_again, res;
const char *first_text;
/* If the user is mailing a hidden contact list, it is possible for
@@ -390,7 +390,7 @@ got_post_folder (char *uri, CamelFolder *folder, void *data)
void
em_utils_composer_send_cb (EMsgComposer *composer, gpointer user_data)
{
- extern CamelFolder *outbox_folder;
+ CamelFolder *outbox_folder = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_OUTBOX);
CamelMimeMessage *message;
CamelMessageInfo *info;
struct _send_data *send;
@@ -558,8 +558,8 @@ save_draft_folder (char *uri, CamelFolder *folder, gpointer data)
void
em_utils_composer_save_draft_cb (EMsgComposer *composer, int quit, gpointer user_data)
{
- extern char *default_drafts_folder_uri;
- extern CamelFolder *drafts_folder;
+ const char *default_drafts_folder_uri = mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_DRAFTS);
+ CamelFolder *drafts_folder = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_DRAFTS);
struct _save_draft_info *sdi;
CamelFolder *folder = NULL;
CamelMimeMessage *msg;
diff --git a/mail/em-migrate.c b/mail/em-migrate.c
index 7e81d66047..10e2d688da 100644
--- a/mail/em-migrate.c
+++ b/mail/em-migrate.c
@@ -57,9 +57,8 @@
#include "e-util/e-account-list.h"
#include "mail-config.h"
-#include "mail-component.h" /* for em_uri_from_camel() */
+#include "em-utils.h"
#include "em-migrate.h"
-#include "mail-vfolder.h"
#define d(x) x
@@ -2374,7 +2373,6 @@ em_migrate (const char *evolution_dir, int major, int minor, int revision, Camel
if (vfolders) {
emm_save_xml (vfolders, path, "vfolders.xml");
xmlFreeDoc (vfolders);
- vfolder_revert();
}
g_free (path);
diff --git a/mail/em-subscribe-editor.c b/mail/em-subscribe-editor.c
index ae240647bf..3dc772abba 100644
--- a/mail/em-subscribe-editor.c
+++ b/mail/em-subscribe-editor.c
@@ -127,6 +127,7 @@ struct _EMSubscribeNode {
static void sub_editor_busy(EMSubscribeEditor *se, int dir);
static int sub_queue_fill_level(EMSubscribe *sub, EMSubscribeNode *node);
+static void sub_selection_changed(GtkTreeSelection *selection, EMSubscribe *sub);
static void
sub_node_free(char *key, EMSubscribeNode *node, EMSubscribe *sub)
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 016d99380a..dfce2bab15 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -55,6 +55,8 @@
static EAccount *guess_account (CamelMimeMessage *message, CamelFolder *folder);
static void emu_save_part_done (CamelMimePart *part, char *name, int done, void *data);
+#define d(x)
+
/**
* em_utils_prompt_user:
* @parent: parent window
@@ -2113,8 +2115,6 @@ em_utils_temp_save_part(GtkWidget *parent, CamelMimePart *part)
return path;
}
-extern CamelFolder *drafts_folder, *sent_folder, *outbox_folder;
-
/**
* em_utils_folder_is_drafts:
* @folder: folder
@@ -2132,7 +2132,7 @@ em_utils_folder_is_drafts(CamelFolder *folder, const char *uri)
EIterator *iter;
int is = FALSE;
- if (folder == drafts_folder)
+ if (folder == mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_DRAFTS))
return TRUE;
if (uri == NULL)
@@ -2173,7 +2173,7 @@ em_utils_folder_is_sent(CamelFolder *folder, const char *uri)
EIterator *iter;
int is = FALSE;
- if (folder == sent_folder)
+ if (folder == mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_SENT))
return TRUE;
if (uri == NULL)
@@ -2210,7 +2210,7 @@ gboolean
em_utils_folder_is_outbox(CamelFolder *folder, const char *uri)
{
/* <Highlander>There can be only one.</Highlander> */
- return folder == outbox_folder;
+ return folder == mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_OUTBOX);
}
/**
@@ -2487,3 +2487,129 @@ em_utils_folder_name_from_uri (const char *uri)
return folder_name;
}
+
+extern struct _CamelSession *session;
+
+/* email: uri's are based on the account, with special cases for local
+ * stores, vfolder and local mail.
+ * e.g.
+ * imap account imap://user@host/ -> email://accountid@accountid.host/
+ * vfolder vfolder:/storage/path#folder -> email://vfolder@local/folder
+ * local local:/storage/path#folder -> email://local@local/folder
+ */
+
+char *em_uri_from_camel(const char *curi)
+{
+ CamelURL *curl;
+ EAccount *account;
+ const char *uid, *path;
+ char *euri, *tmp;
+ CamelProvider *provider;
+
+ provider = camel_session_get_provider(session, curi, NULL);
+ if (provider == NULL) {
+ d(printf("em uri from camel failed '%s'\n", curi));
+ return g_strdup(curi);
+ }
+
+ curl = camel_url_new(curi, NULL);
+ if (curl == NULL)
+ return g_strdup(curi);
+
+ if (strcmp(curl->protocol, "vfolder") == 0)
+ uid = "vfolder@local";
+ else if ((account = mail_config_get_account_by_source_url(curi)) == NULL)
+ uid = "local@local";
+ else
+ uid = account->uid;
+ path = (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH)?curl->fragment:curl->path;
+ if (path[0] == '/')
+ path++;
+
+ tmp = camel_url_encode(path, ";?");
+ euri = g_strdup_printf("email://%s/%s", uid, tmp);
+ g_free(tmp);
+
+ d(printf("em uri from camel '%s' -> '%s'\n", curi, euri));
+
+ camel_url_free(curl);
+
+ return euri;
+}
+
+char *em_uri_to_camel(const char *euri)
+{
+ EAccountList *accounts;
+ const EAccount *account;
+ EAccountService *service;
+ CamelProvider *provider;
+ CamelURL *eurl, *curl;
+ char *uid, *curi;
+
+ if (strncmp(euri, "email:", 6) != 0) {
+ d(printf("em uri to camel not euri '%s'\n", euri));
+ return g_strdup(euri);
+ }
+
+ eurl = camel_url_new(euri, NULL);
+ if (eurl == NULL)
+ return g_strdup(euri);
+
+ g_assert(eurl->host != NULL);
+
+ if (eurl->user != NULL) {
+ /* Sigh, shoul'dve used mbox@local for mailboxes, not local@local */
+ if (strcmp(eurl->host, "local") == 0
+ && (strcmp(eurl->user, "local") == 0 || strcmp(eurl->user, "vfolder") == 0)) {
+ char *base;
+
+ if (strcmp(eurl->user, "vfolder") == 0)
+ curl = camel_url_new("vfolder:", NULL);
+ else
+ curl = camel_url_new("mbox:", NULL);
+
+ base = g_strdup_printf("%s/.evolution/mail/%s", g_get_home_dir(), eurl->user);
+ camel_url_set_path(curl, base);
+ g_free(base);
+ camel_url_set_fragment(curl, eurl->path[0]=='/'?eurl->path+1:eurl->path);
+ curi = camel_url_to_string(curl, 0);
+ camel_url_free(curl);
+ camel_url_free(eurl);
+
+ d(printf("em uri to camel local '%s' -> '%s'\n", euri, curi));
+ return curi;
+ }
+
+ uid = g_strdup_printf("%s@%s", eurl->user, eurl->host);
+ } else {
+ uid = g_strdup(eurl->host);
+ }
+
+ accounts = mail_config_get_accounts();
+ account = e_account_list_find(accounts, E_ACCOUNT_FIND_UID, uid);
+ g_free(uid);
+
+ if (account == NULL) {
+ camel_url_free(eurl);
+ d(printf("em uri to camel no account '%s' -> '%s'\n", euri, euri));
+ return g_strdup(euri);
+ }
+
+ service = account->source;
+ provider = camel_session_get_provider(session, service->url, NULL);
+
+ curl = camel_url_new(service->url, NULL);
+ if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH)
+ camel_url_set_fragment(curl, eurl->path[0]=='/'?eurl->path+1:eurl->path);
+ else
+ camel_url_set_path(curl, eurl->path);
+
+ curi = camel_url_to_string(curl, 0);
+
+ camel_url_free(eurl);
+ camel_url_free(curl);
+
+ d(printf("em uri to camel '%s' -> '%s'\n", euri, curi));
+
+ return curi;
+}
diff --git a/mail/em-utils.h b/mail/em-utils.h
index 6b54e48de2..e89a68145c 100644
--- a/mail/em-utils.h
+++ b/mail/em-utils.h
@@ -125,6 +125,9 @@ void em_utils_empty_trash (struct _GtkWidget *parent);
/* returns the folder name portion of an URI */
char *em_utils_folder_name_from_uri (const char *uri);
+/* internal/camel uri translation */
+char *em_uri_from_camel (const char *curi);
+char *em_uri_to_camel (const char *euri);
#ifdef __cplusplus
}
diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c
index b2c35b3bfb..2864adba2f 100644
--- a/mail/mail-account-gui.c
+++ b/mail/mail-account-gui.c
@@ -42,6 +42,7 @@
#include "mail-send-recv.h"
#include "mail-signature-editor.h"
#include "mail-component.h"
+#include "em-utils.h"
#include "em-composer-prefs.h"
#include "mail-config.h"
#include "mail-ops.h"
@@ -54,8 +55,6 @@
#define d(x)
-extern char *default_drafts_folder_uri, *default_sent_folder_uri;
-
static void save_service (MailAccountGuiService *gsvc, GHashTable *extra_conf, EAccountService *service);
static void service_changed (GtkEntry *entry, gpointer user_data);
@@ -1080,12 +1079,12 @@ default_folders_clicked (GtkButton *button, gpointer user_data)
/* Drafts folder */
g_free (gui->drafts_folder_uri);
- gui->drafts_folder_uri = g_strdup (default_drafts_folder_uri);
+ gui->drafts_folder_uri = g_strdup(mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_DRAFTS));
em_folder_selection_button_set_selection((EMFolderSelectionButton *)gui->drafts_folder_button, gui->drafts_folder_uri);
/* Sent folder */
g_free (gui->sent_folder_uri);
- gui->sent_folder_uri = g_strdup (default_sent_folder_uri);
+ gui->sent_folder_uri = g_strdup(mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_SENT));
em_folder_selection_button_set_selection((EMFolderSelectionButton *)gui->sent_folder_button, gui->sent_folder_uri);
}
@@ -1587,7 +1586,7 @@ mail_account_gui_new (EAccount *account, EMAccountPrefs *dialog)
if (account->drafts_folder_uri)
gui->drafts_folder_uri = em_uri_to_camel (account->drafts_folder_uri);
else
- gui->drafts_folder_uri = g_strdup (default_drafts_folder_uri);
+ gui->drafts_folder_uri = g_strdup(mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_DRAFTS));
em_folder_selection_button_set_selection((EMFolderSelectionButton *)gui->drafts_folder_button, gui->drafts_folder_uri);
/* Sent folder */
@@ -1596,7 +1595,7 @@ mail_account_gui_new (EAccount *account, EMAccountPrefs *dialog)
if (account->sent_folder_uri)
gui->sent_folder_uri = em_uri_to_camel (account->sent_folder_uri);
else
- gui->sent_folder_uri = g_strdup (default_sent_folder_uri);
+ gui->sent_folder_uri = g_strdup(mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_SENT));
em_folder_selection_button_set_selection((EMFolderSelectionButton *)gui->sent_folder_button, gui->sent_folder_uri);
/* Special Folders "Reset Defaults" button */
@@ -2010,7 +2009,7 @@ mail_account_gui_save (MailAccountGui *gui)
new->drafts_folder_uri = em_uri_from_camel (gui->drafts_folder_uri);
} else {
/* assign defaults - the uri is unknown to us (probably pointed to an old source url) */
- new->drafts_folder_uri = em_uri_from_camel (default_drafts_folder_uri);
+ new->drafts_folder_uri = em_uri_from_camel(mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_DRAFTS));
}
/* Check to make sure that the Sent folder uri is "valid" before assigning it */
@@ -2019,7 +2018,7 @@ mail_account_gui_save (MailAccountGui *gui)
new->sent_folder_uri = em_uri_from_camel (gui->sent_folder_uri);
} else {
/* assign defaults - the uri is unknown to us (probably pointed to an old source url) */
- new->sent_folder_uri = em_uri_from_camel (default_sent_folder_uri);
+ new->sent_folder_uri = em_uri_from_camel(mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_SENT));
}
new->always_cc = gtk_toggle_button_get_active (gui->always_cc);
diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c
index 5d8de5fcad..394cb46dd5 100644
--- a/mail/mail-autofilter.c
+++ b/mail/mail-autofilter.c
@@ -40,6 +40,7 @@
#include "mail-vfolder.h"
#include "mail-autofilter.h"
#include "mail-component.h"
+#include "em-utils.h"
#include "camel/camel.h"
diff --git a/mail/mail-component.c b/mail/mail-component.c
index ff45e0af5a..a9c850ab25 100644
--- a/mail/mail-component.c
+++ b/mail/mail-component.c
@@ -3,6 +3,10 @@
*
* Copyright (C) 2003 Ximian Inc.
*
+ * Authors: Ettore Perazzoli <ettore@ximian.com>
+ * Michael Zucchi <notzed@ximian.com>
+ * Jeffrey Stedfast <fejj@ximian.com>
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
@@ -17,7 +21,6 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * Author: Ettore Perazzoli <ettore@ximian.com>
*/
#ifdef HAVE_CONFIG_H
@@ -70,10 +73,14 @@
#define d(x)
+#define MAIL_COMPONENT_DEFAULT(mc) if (mc == NULL) mc = mail_component_peek();
+
#define PARENT_TYPE bonobo_object_get_type ()
static BonoboObjectClass *parent_class = NULL;
struct _MailComponentPrivate {
+ GMutex *lock;
+
char *base_directory;
EMFolderTreeModel *model;
@@ -91,21 +98,86 @@ struct _MailComponentPrivate {
};
/* Utility functions. */
+static void
+mc_add_store(CamelStore *store, const char *name, MailComponent *mc)
+{
+ mail_component_add_store(mc, store, name);
+
+ camel_object_unref(store);
+ g_object_unref(mc);
+}
+
+/* indexed by _mail_component_folder_t */
+static struct {
+ char *name;
+ char *uri;
+ CamelFolder *folder;
+} mc_default_folders[] = {
+ { "Inbox", },
+ { "Drafts", },
+ { "Outbox", },
+ { "Sent", },
+ { "Inbox", }, /* 'always local' inbox */
+};
static void
-add_store (MailComponent *component, const char *name, CamelStore *store, CamelException *ex)
+mc_setup_local_store(MailComponent *mc)
{
- camel_object_ref (store);
- g_hash_table_insert (component->priv->store_hash, store, g_strdup (name));
- em_folder_tree_model_add_store (component->priv->model, store, name);
- mail_note_store (store, NULL, NULL, NULL);
+ MailComponentPrivate *p = mc->priv;
+ CamelURL *url;
+ char *tmp;
+ CamelException ex;
+ int i;
+
+ g_mutex_lock(p->lock);
+ if (p->local_store != NULL) {
+ g_mutex_unlock(p->lock);
+ return;
+ }
+
+ camel_exception_init(&ex);
+
+ url = camel_url_new("mbox:", NULL);
+ tmp = g_strdup_printf("%s/mail/local", p->base_directory);
+ camel_url_set_path(url, tmp);
+ g_free(tmp);
+ tmp = camel_url_to_string(url, 0);
+ p->local_store = (CamelStore *)camel_session_get_service(session, tmp, CAMEL_PROVIDER_STORE, &ex);
+ g_free(tmp);
+ if (p->local_store == NULL)
+ goto fail;
+
+ for (i=0;i<sizeof(mc_default_folders)/sizeof(mc_default_folders[0]);i++) {
+ /* FIXME: should this uri be account relative? */
+ camel_url_set_fragment(url, mc_default_folders[i].name);
+ mc_default_folders[i].uri = camel_url_to_string(url, 0);
+ mc_default_folders[i].folder = camel_store_get_folder(p->local_store, mc_default_folders[i].name,
+ CAMEL_STORE_FOLDER_CREATE, &ex);
+ camel_exception_clear(&ex);
+ }
+
+ camel_url_free(url);
+ g_mutex_unlock(p->lock);
+
+ g_object_ref(mc);
+ camel_object_ref(p->local_store);
+ mail_async_event_emit(p->async_event, MAIL_ASYNC_GUI, (MailAsyncFunc)mc_add_store, p->local_store, _("On this Computer"), mc);
+
+ return;
+fail:
+ g_mutex_unlock(p->lock);
+
+ g_warning("Could not setup local store/folder: %s", ex.desc);
+
+ camel_url_free(url);
+ camel_exception_clear(&ex);
}
static void
load_accounts (MailComponent *component, EAccountList *accounts)
{
EIterator *iter;
-
+
/* Load each service (don't connect!). Check its provider and
* see if this belongs in the shell's folder list. If so, add
* it.
@@ -134,68 +206,37 @@ static void
setup_search_context (MailComponent *component)
{
MailComponentPrivate *priv = component->priv;
- char *user = g_build_filename(component->priv->base_directory, "mail/searches.xml", NULL);
- char *system = g_strdup (EVOLUTION_PRIVDATADIR "/searchtypes.xml");
-
- priv->search_context = rule_context_new ();
- g_object_set_data_full (G_OBJECT (priv->search_context), "user", user, g_free);
- g_object_set_data_full (G_OBJECT (priv->search_context), "system", system, g_free);
-
- rule_context_add_part_set (priv->search_context, "partset", filter_part_get_type (),
- rule_context_add_part, rule_context_next_part);
+
+ if (priv->search_context == NULL) {
+ char *user = g_build_filename(component->priv->base_directory, "mail/searches.xml", NULL);
+ char *system = g_strdup (EVOLUTION_PRIVDATADIR "/searchtypes.xml");
- rule_context_add_rule_set (priv->search_context, "ruleset", filter_rule_get_type (),
- rule_context_add_rule, rule_context_next_rule);
+ priv->search_context = rule_context_new ();
+ g_object_set_data_full (G_OBJECT (priv->search_context), "user", user, g_free);
+ g_object_set_data_full (G_OBJECT (priv->search_context), "system", system, g_free);
- rule_context_load (priv->search_context, system, user);
+ rule_context_add_part_set (priv->search_context, "partset", filter_part_get_type (),
+ rule_context_add_part, rule_context_next_part);
+
+ rule_context_add_rule_set (priv->search_context, "ruleset", filter_rule_get_type (),
+ rule_context_add_rule, rule_context_next_rule);
+
+ rule_context_load (priv->search_context, system, user);
+ }
}
-/* Local store setup. */
-char *default_drafts_folder_uri;
-CamelFolder *drafts_folder = NULL;
-char *default_sent_folder_uri;
-CamelFolder *sent_folder = NULL;
-char *default_outbox_folder_uri;
-CamelFolder *outbox_folder = NULL;
-char *default_inbox_folder_uri;
-CamelFolder *inbox_folder = NULL;
-
-static struct {
- char *base;
- char **uri;
- CamelFolder **folder;
-} default_folders[] = {
- { "Inbox", &default_inbox_folder_uri, &inbox_folder },
- { "Drafts", &default_drafts_folder_uri, &drafts_folder },
- { "Outbox", &default_outbox_folder_uri, &outbox_folder },
- { "Sent", &default_sent_folder_uri, &sent_folder },
-};
-
static void
-setup_local_store(MailComponent *component)
+mc_startup(MailComponent *mc)
{
- MailComponentPrivate *p = component->priv;
- CamelException ex;
- char *store_uri;
- int i;
-
- g_assert(p->local_store == NULL);
+ static int started = 0;
- /* EPFIXME It should use base_directory once we have moved it. */
- store_uri = g_strconcat("mbox:", g_get_home_dir (), "/.evolution/mail/local", NULL);
- p->local_store = mail_component_load_store_by_uri (component, store_uri, _("On this Computer"));
- camel_object_ref (p->local_store);
-
- camel_exception_init (&ex);
- for (i=0;i<sizeof(default_folders)/sizeof(default_folders[0]);i++) {
- /* FIXME: should this uri be account relative? */
- *default_folders[i].uri = g_strdup_printf("%s#%s", store_uri, default_folders[i].base);
- *default_folders[i].folder = camel_store_get_folder(p->local_store, default_folders[i].base,
- CAMEL_STORE_FOLDER_CREATE, &ex);
- camel_exception_clear(&ex);
- }
+ if (started)
+ return;
+ started = 1;
- g_free(store_uri);
+ mc_setup_local_store(mc);
+ load_accounts(mc, mail_config_get_accounts());
+ vfolder_load_storage();
}
static void
@@ -211,11 +252,7 @@ folder_selected_cb (EMFolderTree *emft, const char *path, const char *uri, EMFol
#define PROPERTY_FOLDER_URI_IDX 1
static void
-set_prop (BonoboPropertyBag *bag,
- const BonoboArg *arg,
- guint arg_id,
- CORBA_Environment *ev,
- gpointer user_data)
+set_prop(BonoboPropertyBag *bag, const BonoboArg *arg, guint arg_id, CORBA_Environment *ev, gpointer user_data)
{
EMFolderView *view = (EMFolderView *)bonobo_control_get_widget (user_data);
const gchar *uri;
@@ -235,11 +272,7 @@ set_prop (BonoboPropertyBag *bag,
}
static void
-get_prop (BonoboPropertyBag *bag,
- BonoboArg *arg,
- guint arg_id,
- CORBA_Environment *ev,
- gpointer user_data)
+get_prop(BonoboPropertyBag *bag, BonoboArg *arg, guint arg_id, CORBA_Environment *ev, gpointer user_data)
{
GtkWidget *widget = bonobo_control_get_widget (user_data);
EMFolderView *view = (EMFolderView *)widget;
@@ -334,6 +367,7 @@ impl_finalize (GObject *object)
}
g_free (priv->context_path);
+ g_mutex_free(priv->lock);
g_free (priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
@@ -364,6 +398,8 @@ impl_createControls (PortableServer_Servant servant,
GtkWidget *tree_widget;
GtkWidget *view_widget;
GtkWidget *statusbar_widget;
+
+ mc_startup(mail_component);
view_widget = em_folder_browser_new ();
tree_widget = (GtkWidget *) em_folder_tree_new_with_model (priv->model);
@@ -463,10 +499,6 @@ impl_upgradeFromVersion (PortableServer_Servant servant, short major, short mino
/* FIXME: report errors? */
camel_exception_clear (&ex);
- /* This is a hack so that after importing new folders, they properly hook into vfolders, etc.
- Perhaps the CamelLocalStore class should emit folder_created events for folders when opened */
- mail_note_store(component->priv->local_store, NULL, NULL, NULL);
-
return ok;
}
@@ -495,12 +527,13 @@ static void
mail_component_init (MailComponent *component)
{
MailComponentPrivate *priv;
- EAccountList *accounts;
MailOfflineHandler *offline;
priv = g_new0 (MailComponentPrivate, 1);
component->priv = priv;
+ priv->lock = g_mutex_new();
+
priv->base_directory = g_build_filename (g_get_home_dir (), ".evolution", NULL);
if (camel_mkdir (priv->base_directory, 0777) == -1 && errno != EEXIST)
abort ();
@@ -514,11 +547,6 @@ mail_component_init (MailComponent *component)
priv->async_event = mail_async_event_new();
priv->store_hash = g_hash_table_new (NULL, NULL);
- setup_local_store (component);
-
- accounts = mail_config_get_accounts ();
- load_accounts(component, accounts);
-
mail_autoreceive_setup();
setup_search_context (component);
@@ -564,13 +592,8 @@ mail_component_peek (void)
{
static MailComponent *component = NULL;
- if (component == NULL) {
- component = g_object_new (mail_component_get_type (), NULL);
-
- /* FIXME: this should all be initialised in a starutp routine, not from the peek function,
- this covers much of the ::init method's content too */
- vfolder_load_storage ();
- }
+ if (component == NULL)
+ component = g_object_new(mail_component_get_type(), NULL);
return component;
}
@@ -578,39 +601,44 @@ mail_component_peek (void)
const char *
mail_component_peek_base_directory (MailComponent *component)
{
+ MAIL_COMPONENT_DEFAULT(component);
+
return component->priv->base_directory;
}
RuleContext *
mail_component_peek_search_context (MailComponent *component)
{
+ MAIL_COMPONENT_DEFAULT(component);
+
+ setup_search_context(component);
+
return component->priv->search_context;
}
EActivityHandler *
mail_component_peek_activity_handler (MailComponent *component)
{
+ MAIL_COMPONENT_DEFAULT(component);
+
return component->priv->activity_handler;
}
void
mail_component_add_store (MailComponent *component, CamelStore *store, const char *name)
{
- CamelException ex;
-
- camel_exception_init (&ex);
-
- if (name == NULL) {
- char *service_name;
-
- service_name = camel_service_get_name ((CamelService *) store, TRUE);
- add_store (component, service_name, store, &ex);
- g_free (service_name);
- } else {
- add_store (component, name, store, &ex);
- }
+ char *service_name = NULL;
+
+ MAIL_COMPONENT_DEFAULT(component);
- camel_exception_clear (&ex);
+ if (name == NULL)
+ name = service_name = camel_service_get_name ((CamelService *) store, TRUE);
+
+ camel_object_ref(store);
+ g_hash_table_insert(component->priv->store_hash, store, g_strdup(name));
+ em_folder_tree_model_add_store(component->priv->model, store, name);
+ mail_note_store(store, NULL, NULL, NULL);
+ g_free(service_name);
}
/**
@@ -628,6 +656,8 @@ mail_component_load_store_by_uri (MailComponent *component, const char *uri, con
CamelException ex;
CamelStore *store;
CamelProvider *prov;
+
+ MAIL_COMPONENT_DEFAULT(component);
camel_exception_init (&ex);
@@ -657,24 +687,8 @@ mail_component_load_store_by_uri (MailComponent *component, const char *uri, con
camel_exception_clear (&ex);
return NULL;
}
-
- if (name != NULL) {
- add_store (component, name, store, &ex);
- } else {
- char *service_name;
-
- service_name = camel_service_get_name ((CamelService *) store, TRUE);
- add_store (component, service_name, store, &ex);
- g_free (service_name);
- }
-
- if (camel_exception_is_set (&ex)) {
- /* EPFIXME: real error dialog */
- g_warning ("Cannot load store: %s",
- camel_exception_get_description (&ex));
- camel_exception_clear (&ex);
- }
-
+
+ mail_component_add_store(component, store, name);
camel_object_unref (store);
return store;
@@ -690,9 +704,13 @@ store_disconnect (CamelStore *store, void *event_data, void *user_data)
void
mail_component_remove_store (MailComponent *component, CamelStore *store)
{
- MailComponentPrivate *priv = component->priv;
+ MailComponentPrivate *priv;
char *name;
-
+
+ MAIL_COMPONENT_DEFAULT(component);
+
+ priv = component->priv;
+
/* Because the store_hash holds a reference to each store
* used as a key in it, none of them will ever be gc'ed, meaning
* any call to camel_session_get_{service,store} with the same
@@ -714,12 +732,13 @@ mail_component_remove_store (MailComponent *component, CamelStore *store)
mail_async_event_emit (priv->async_event, MAIL_ASYNC_THREAD, (MailAsyncFunc) store_disconnect, store, NULL, NULL);
}
-
void
mail_component_remove_store_by_uri (MailComponent *component, const char *uri)
{
CamelProvider *prov;
CamelStore *store;
+
+ MAIL_COMPONENT_DEFAULT(component);
if (!(prov = camel_session_get_provider (session, uri, NULL)))
return;
@@ -738,157 +757,73 @@ mail_component_remove_store_by_uri (MailComponent *component, const char *uri)
int
mail_component_get_store_count (MailComponent *component)
{
+ MAIL_COMPONENT_DEFAULT(component);
+
return g_hash_table_size (component->priv->store_hash);
}
void
mail_component_stores_foreach (MailComponent *component, GHFunc func, void *user_data)
{
+ MAIL_COMPONENT_DEFAULT(component);
+
g_hash_table_foreach (component->priv->store_hash, func, user_data);
}
void
mail_component_remove_folder (MailComponent *component, CamelStore *store, const char *path)
{
+ MAIL_COMPONENT_DEFAULT(component);
+
/* FIXME: implement me. but first, am I really even needed? */
}
EMFolderTreeModel *
mail_component_peek_tree_model (MailComponent *component)
{
+ MAIL_COMPONENT_DEFAULT(component);
+
return component->priv->model;
}
+/**
+ * mail_component_get_folder:
+ * @mc:
+ * @id:
+ *
+ * Get a standard/default folder by id. This call is thread-safe.
+ *
+ * Return value:
+ **/
struct _CamelFolder *
-mail_component_get_local_inbox(MailComponent *mc, struct _CamelException *ex)
-{
- return camel_store_get_folder(mc->priv->local_store, "Inbox", 0, ex);
-}
-
-extern struct _CamelSession *session;
-
-/* email: uri's are based on the account, with special cases for local
- * stores, vfolder and local mail.
- * e.g.
- * imap account imap://user@host/ -> email://accountid@accountid.host/
- * vfolder vfolder:/storage/path#folder -> email://vfolder@local/folder
- * local local:/storage/path#folder -> email://local@local/folder
- */
-
-char *em_uri_from_camel(const char *curi)
+mail_component_get_folder(MailComponent *mc, enum _mail_component_folder_t id)
{
- CamelURL *curl;
- EAccount *account;
- const char *uid, *path;
- char *euri, *tmp;
- CamelProvider *provider;
-
- provider = camel_session_get_provider(session, curi, NULL);
- if (provider == NULL) {
- d(printf("em uri from camel failed '%s'\n", curi));
- return g_strdup(curi);
- }
-
- curl = camel_url_new(curi, NULL);
- if (curl == NULL)
- return g_strdup(curi);
+ g_assert(id <= MAIL_COMPONENT_FOLDER_LOCAL_INBOX);
- if (strcmp(curl->protocol, "vfolder") == 0)
- uid = "vfolder@local";
- else if ((account = mail_config_get_account_by_source_url(curi)) == NULL)
- uid = "local@local";
- else
- uid = account->uid;
- path = (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH)?curl->fragment:curl->path;
- if (path[0] == '/')
- path++;
-
- tmp = camel_url_encode(path, ";?");
- euri = g_strdup_printf("email://%s/%s", uid, tmp);
- g_free(tmp);
-
- d(printf("em uri from camel '%s' -> '%s'\n", curi, euri));
+ MAIL_COMPONENT_DEFAULT(mc);
+ mc_setup_local_store(mc);
- camel_url_free(curl);
-
- return euri;
+ return mc_default_folders[id].folder;
}
-char *em_uri_to_camel(const char *euri)
+/**
+ * mail_component_get_folder_uri:
+ * @mc:
+ * @id:
+ *
+ * Get a standard/default folder's uri. This call is thread-safe.
+ *
+ * Return value:
+ **/
+const char *
+mail_component_get_folder_uri(MailComponent *mc, enum _mail_component_folder_t id)
{
- EAccountList *accounts;
- const EAccount *account;
- EAccountService *service;
- CamelProvider *provider;
- CamelURL *eurl, *curl;
- char *uid, *curi;
-
- if (strncmp(euri, "email:", 6) != 0) {
- d(printf("em uri to camel not euri '%s'\n", euri));
- return g_strdup(euri);
- }
-
- eurl = camel_url_new(euri, NULL);
- if (eurl == NULL)
- return g_strdup(euri);
-
- g_assert(eurl->host != NULL);
-
- if (eurl->user != NULL) {
- /* Sigh, shoul'dve used mbox@local for mailboxes, not local@local */
- if (strcmp(eurl->host, "local") == 0
- && (strcmp(eurl->user, "local") == 0 || strcmp(eurl->user, "vfolder") == 0)) {
- char *base;
-
- if (strcmp(eurl->user, "vfolder") == 0)
- curl = camel_url_new("vfolder:", NULL);
- else
- curl = camel_url_new("mbox:", NULL);
-
- base = g_strdup_printf("%s/.evolution/mail/%s", g_get_home_dir(), eurl->user);
- camel_url_set_path(curl, base);
- g_free(base);
- camel_url_set_fragment(curl, eurl->path[0]=='/'?eurl->path+1:eurl->path);
- curi = camel_url_to_string(curl, 0);
- camel_url_free(curl);
- camel_url_free(eurl);
-
- d(printf("em uri to camel local '%s' -> '%s'\n", euri, curi));
- return curi;
- }
-
- uid = g_strdup_printf("%s@%s", eurl->user, eurl->host);
- } else {
- uid = g_strdup(eurl->host);
- }
-
- accounts = mail_config_get_accounts();
- account = e_account_list_find(accounts, E_ACCOUNT_FIND_UID, uid);
- g_free(uid);
-
- if (account == NULL) {
- camel_url_free(eurl);
- d(printf("em uri to camel no account '%s' -> '%s'\n", euri, euri));
- return g_strdup(euri);
- }
-
- service = account->source;
- provider = camel_session_get_provider(session, service->url, NULL);
-
- curl = camel_url_new(service->url, NULL);
- if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH)
- camel_url_set_fragment(curl, eurl->path[0]=='/'?eurl->path+1:eurl->path);
- else
- camel_url_set_path(curl, eurl->path);
-
- curi = camel_url_to_string(curl, 0);
-
- camel_url_free(eurl);
- camel_url_free(curl);
+ g_assert(id <= MAIL_COMPONENT_FOLDER_LOCAL_INBOX);
- d(printf("em uri to camel '%s' -> '%s'\n", euri, curi));
+ MAIL_COMPONENT_DEFAULT(mc);
+ mc_setup_local_store(mc);
- return curi;
+ return mc_default_folders[id].uri;
}
BONOBO_TYPE_FUNC_FULL (MailComponent, GNOME_Evolution_Component, PARENT_TYPE, mail_component)
diff --git a/mail/mail-component.h b/mail/mail-component.h
index afce0a64d4..5f32dd110b 100644
--- a/mail/mail-component.h
+++ b/mail/mail-component.h
@@ -44,6 +44,14 @@ typedef struct _MailComponent MailComponent;
typedef struct _MailComponentPrivate MailComponentPrivate;
typedef struct _MailComponentClass MailComponentClass;
+enum _mail_component_folder_t {
+ MAIL_COMPONENT_FOLDER_INBOX = 0,
+ MAIL_COMPONENT_FOLDER_DRAFTS,
+ MAIL_COMPONENT_FOLDER_OUTBOX,
+ MAIL_COMPONENT_FOLDER_SENT,
+ MAIL_COMPONENT_FOLDER_LOCAL_INBOX,
+};
+
struct _MailComponent {
BonoboObject parent;
@@ -58,8 +66,11 @@ struct _MailComponentClass {
GType mail_component_get_type (void);
+struct _BonoboControl *mail_control_new(void);
+
MailComponent *mail_component_peek (void);
+/* NOTE: Using NULL as the component implies using the default component */
const char *mail_component_peek_base_directory (MailComponent *component);
RuleContext *mail_component_peek_search_context (MailComponent *component);
EActivityHandler *mail_component_peek_activity_handler (MailComponent *component);
@@ -85,16 +96,7 @@ void mail_component_remove_folder (MailComponent *component, CamelStore *store,
struct _EMFolderTreeModel *mail_component_peek_tree_model (MailComponent *component);
-struct _CamelFolder *mail_component_get_local_inbox(MailComponent *mc, struct _CamelException *ex);
-
-char *em_uri_from_camel (const char *curi);
-char *em_uri_to_camel (const char *euri);
-
-CamelFolder *mail_component_get_folder_from_evomail_uri (MailComponent *component,
- guint32 flags,
- const char *evomail_uri,
- CamelException *ex);
-char *mail_component_evomail_uri_from_folder (MailComponent *component,
- CamelFolder *folder);
+struct _CamelFolder *mail_component_get_folder(MailComponent *mc, enum _mail_component_folder_t id);
+const char *mail_component_get_folder_uri(MailComponent *mc, enum _mail_component_folder_t id);
#endif /* _MAIL_COMPONENT_H_ */
diff --git a/mail/mail-config.c b/mail/mail-config.c
index a14fad42a3..ac3d20a5bb 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -1014,7 +1014,8 @@ mail_config_uri_deleted (GCompareFunc uri_cmp, const char *uri)
EIterator *iter;
int work = 0;
/* assumes these can't be removed ... */
- extern char *default_sent_folder_uri, *default_drafts_folder_uri;
+ const char *default_sent_folder_uri = mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_SENT);
+ const char *default_drafts_folder_uri = mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_DRAFTS);
iter = e_list_get_iterator ((EList *) config->accounts);
while (e_iterator_is_valid (iter)) {
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index 285f1d1230..0887f55bca 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -327,15 +327,14 @@ update_1folder(struct _folder_info *mfi, int new, CamelFolderInfo *info)
struct _folder_update *up;
CamelFolder *folder;
int unread = -1;
- extern CamelFolder *outbox_folder, *sent_folder;
si = mfi->store_info;
folder = mfi->folder;
if (folder) {
if ((count_trash && CAMEL_IS_VTRASH_FOLDER (folder))
- || folder == outbox_folder
- || (count_sent && folder == sent_folder)) {
+ || folder == mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_OUTBOX)
+ || (count_sent && folder == mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_SENT))) {
unread = camel_folder_get_message_count(folder);
} else {
if (info)
@@ -412,7 +411,6 @@ create_folders(CamelFolderInfo *fi, struct _store_info *si)
static void
folder_changed (CamelObject *o, gpointer event_data, gpointer user_data)
{
- extern CamelFolder *outbox_folder, *sent_folder;
CamelFolderChangeInfo *changes = event_data;
CamelFolder *folder = (CamelFolder *) o;
struct _folder_info *mfi = user_data;
@@ -421,7 +419,10 @@ folder_changed (CamelObject *o, gpointer event_data, gpointer user_data)
if (mfi->folder != folder)
return;
- if (!CAMEL_IS_VTRASH_FOLDER (folder) && folder != outbox_folder && folder != sent_folder && changes && changes->uid_added)
+ if (!CAMEL_IS_VTRASH_FOLDER(folder)
+ && folder != mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_OUTBOX)
+ && folder != mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_SENT)
+ && changes && changes->uid_added)
new = changes->uid_added->len;
LOCK(info_lock);
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index c389483cac..6cdfaad631 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -253,7 +253,7 @@ fetch_mail_fetch (struct _mail_msg *mm)
if (m->cancel)
camel_operation_register (m->cancel);
- if ((fm->destination = mail_tool_get_local_inbox (&mm->ex)) == NULL)
+ if ((fm->destination = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_LOCAL_INBOX)) == NULL)
goto fail;
/* FIXME: this should support keep_on_server too, which would then perform a spool
@@ -406,8 +406,6 @@ mail_fetch_mail (const char *source, int keep, const char *type, CamelOperation
/* sending stuff */
/* ** SEND MAIL *********************************************************** */
-extern CamelFolder *sent_folder;
-
static char *normal_recipients[] = {
CAMEL_RECIPIENT_TYPE_TO,
CAMEL_RECIPIENT_TYPE_CC,
@@ -520,8 +518,8 @@ mail_send_message (CamelMimeMessage *message, const char *destination,
}
if (!folder) {
- camel_object_ref (sent_folder);
- folder = sent_folder;
+ folder = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_SENT);
+ camel_object_ref(folder);
}
if (driver) {
@@ -543,9 +541,13 @@ mail_send_message (CamelMimeMessage *message, const char *destination,
camel_exception_clear (ex);
camel_folder_append_message (folder, message, info, NULL, ex);
if (camel_exception_is_set (ex)) {
+ CamelFolder *sent_folder;
+
if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_USER_CANCEL)
goto exit;
-
+
+ sent_folder = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_SENT);
+
if (err == NULL)
err = g_string_new ("");
else
@@ -706,7 +708,8 @@ static void
send_queue_send(struct _mail_msg *mm)
{
struct _send_queue_msg *m = (struct _send_queue_msg *)mm;
- extern CamelFolder *sent_folder; /* FIXME */
+ /* FIXME (what is this fixme for?) */
+ CamelFolder *sent_folder = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_SENT);
GPtrArray *uids;
int i;
diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c
index 49b2c3c574..fc6556f2e8 100644
--- a/mail/mail-send-recv.c
+++ b/mail/mail-send-recv.c
@@ -131,7 +131,7 @@ static struct _send_data *setup_send_data(void)
send_data = data = g_malloc0(sizeof(*data));
data->lock = g_mutex_new();
data->folders = g_hash_table_new(g_str_hash, g_str_equal);
- data->inbox = mail_tool_get_local_inbox(NULL);
+ data->inbox = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_LOCAL_INBOX);
data->active = g_hash_table_new(g_str_hash, g_str_equal);
}
return send_data;
@@ -297,7 +297,6 @@ build_dialog (EAccountList *accounts, CamelFolder *outbox, const char *destinati
EClippedLabel *status_label;
GtkProgressBar *bar;
GtkButton *stop;
- GtkHSeparator *line;
struct _send_info *info;
char *pretty_url;
EAccount *account;
@@ -671,7 +670,7 @@ receive_update_got_store (char *uri, CamelStore *store, void *data)
GtkWidget *mail_send_receive (void)
{
- extern CamelFolder *outbox_folder;
+ CamelFolder *outbox_folder;
struct _send_data *data;
EAccountList *accounts;
EAccount *account;
@@ -693,7 +692,8 @@ GtkWidget *mail_send_receive (void)
return send_recv_dialog;
accounts = mail_config_get_accounts ();
-
+
+ outbox_folder = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_OUTBOX);
data = build_dialog (accounts, outbox_folder, account->transport->url);
scan = data->infos;
while (scan) {
@@ -831,7 +831,7 @@ mail_receive_uri (const char *uri, int keep)
{
struct _send_info *info;
struct _send_data *data;
- extern CamelFolder *outbox_folder;
+ CamelFolder *outbox_folder;
send_info_t type;
data = setup_send_data();
@@ -876,6 +876,7 @@ mail_receive_uri (const char *uri, int keep)
break;
case SEND_SEND:
/* todo, store the folder in info? */
+ outbox_folder = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_OUTBOX);
mail_send_queue (outbox_folder, info->uri,
FILTER_SOURCE_OUTGOING,
info->cancel,
@@ -894,7 +895,7 @@ mail_receive_uri (const char *uri, int keep)
void
mail_send (void)
{
- extern CamelFolder *outbox_folder;
+ CamelFolder *outbox_folder;
EAccountService *transport;
struct _send_info *info;
struct _send_data *data;
@@ -936,6 +937,7 @@ mail_send (void)
g_hash_table_insert (data->active, SEND_URI_KEY, info);
/* todo, store the folder in info? */
+ outbox_folder = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_OUTBOX);
mail_send_queue (outbox_folder, info->uri,
FILTER_SOURCE_OUTGOING,
info->cancel,
diff --git a/mail/mail-tools.c b/mail/mail-tools.c
index 50b2d0ab12..ac04e63c67 100644
--- a/mail/mail-tools.c
+++ b/mail/mail-tools.c
@@ -45,24 +45,18 @@
#include "e-util/e-meta.h"
-#include "mail.h" /*session*/
#include "mail-component.h"
+#include "mail-session.h"
#include "mail-config.h"
#include "mail-vfolder.h"
#include "mail-tools.h"
#include "mail-mt.h"
#include "mail-folder-cache.h"
-
+#include "em-utils.h"
/* **************************************** */
CamelFolder *
-mail_tool_get_local_inbox (CamelException *ex)
-{
- return mail_component_get_local_inbox(mail_component_peek(), ex);
-}
-
-CamelFolder *
mail_tool_get_inbox (const gchar *url, CamelException *ex)
{
CamelStore *store;
diff --git a/mail/mail-tools.h b/mail/mail-tools.h
index 2f4b61123c..1603ae6d34 100644
--- a/mail/mail-tools.h
+++ b/mail/mail-tools.h
@@ -37,9 +37,6 @@ typedef struct _xevolution {
char *postto;
} XEvolution;
-/* Get the CamelFolder for the local inbox */
-CamelFolder *mail_tool_get_local_inbox (CamelException *ex);
-
/* Get the "inbox" for a url (uses global session) */
CamelFolder *mail_tool_get_inbox (const char *url, CamelException *ex);
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index fc0e502c8f..65954efbe4 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -299,7 +299,6 @@ my_list_find(GList *l, const char *uri, GCompareFunc cmp)
static int
uri_is_ignore(const char *uri, GCompareFunc uri_cmp)
{
- extern char *default_outbox_folder_uri, *default_sent_folder_uri, *default_drafts_folder_uri;
EAccountList *accounts;
EAccount *account;
EIterator *iter;
@@ -307,9 +306,9 @@ uri_is_ignore(const char *uri, GCompareFunc uri_cmp)
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));
+ found = uri_cmp(mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_OUTBOX), uri)
+ || uri_cmp(mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_SENT), uri)
+ || uri_cmp(mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_DRAFTS), uri);
if (found)
return found;