[evolution] Kill em_utils_get_data/config_dir(), push down to MailSession
- From: Jonathon Jongsma <jjongsma src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution] Kill em_utils_get_data/config_dir(), push down to MailSession
- Date: Wed, 16 Dec 2009 17:10:48 +0000 (UTC)
commit 968ea42023e5e0daf860a7246533311a67f77e05
Author: Jonathon Jongsma <jonathon quotidian org>
Date: Wed Dec 16 10:27:12 2009 -0600
Kill em_utils_get_data/config_dir(), push down to MailSession
This pushes the get_data_dir() API down to the right level. At present, it is
still implemented by querying the shell backend for the data dir / config dir.
But this should eventually be reversed (when mail is split off to EDS) so that
the mail daemon is the one responsible for the storage locations and the shell
backend queries the daemon for these values.
mail/em-utils.c | 37 +++----------------------------------
mail/em-utils.h | 3 ---
mail/importers/mail-importer.c | 4 ++--
mail/mail-autofilter.c | 7 ++++---
mail/mail-config.c | 5 ++---
mail/mail-folder-cache.c | 2 +-
mail/mail-ops.c | 4 ++--
mail/mail-session.c | 17 +++++++++++++++++
mail/mail-session.h | 3 +++
mail/mail-tools.c | 2 +-
mail/mail-vfolder.c | 19 +++++++++----------
11 files changed, 44 insertions(+), 59 deletions(-)
---
diff --git a/mail/em-utils.c b/mail/em-utils.c
index bf4357a..fd60db3 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -78,6 +78,7 @@
#include "em-composer-utils.h"
#include "em-format-quote.h"
#include "e-mail-local.h"
+#include "mail-session.h"
/* XXX This is a dirty hack on a dirty hack. We really need
* to rework or get rid of the functions that use this. */
@@ -91,38 +92,6 @@ static void emu_save_part_done (CamelMimePart *part, gchar *name, gint done, gpo
#define d(x)
-const gchar *
-em_utils_get_data_dir (void)
-{
- EShell *shell;
- EShellBackend *shell_backend;
-
- /* XXX This is a temporary solution until I can figure out a
- * better way. Ideally, nothing below the module layer
- * should need to know about the user data directory. */
- shell = e_shell_get_default ();
- shell_backend = e_shell_get_backend_by_name (
- shell, shell_builtin_backend);
-
- return e_shell_backend_get_data_dir (shell_backend);
-}
-
-const gchar *
-em_utils_get_config_dir (void)
-{
- EShell *shell;
- EShellBackend *shell_backend;
-
- /* XXX This is a temporary solution until I can figure out a
- * better way. Ideally, nothing below the module layer
- * should need to know about the user config directory. */
- shell = e_shell_get_default ();
- shell_backend = e_shell_get_backend_by_name (
- shell, shell_builtin_backend);
-
- return e_shell_backend_get_config_dir (shell_backend);
-}
-
gboolean
em_utils_ask_open_many (GtkWindow *parent,
gint how_many)
@@ -274,7 +243,7 @@ em_filter_editor_response (GtkWidget *dialog, gint button, gpointer user_data)
const gchar *data_dir;
gchar *user;
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
fc = g_object_get_data ((GObject *) dialog, "context");
user = g_strdup_printf ("%s/filters.xml", data_dir);
e_rule_context_save ((ERuleContext *) fc, user);
@@ -312,7 +281,7 @@ em_utils_edit_filters (GtkWidget *parent)
return;
}
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
fc = em_filter_context_new ();
user = g_build_filename (data_dir, "filters.xml", NULL);
diff --git a/mail/em-utils.h b/mail/em-utils.h
index db2a7c6..ae8e2f5 100644
--- a/mail/em-utils.h
+++ b/mail/em-utils.h
@@ -38,9 +38,6 @@ G_BEGIN_DECLS
struct _EMFormat;
-const gchar * em_utils_get_data_dir (void);
-const gchar * em_utils_get_config_dir (void);
-
gboolean em_utils_ask_open_many (GtkWindow *parent, gint how_many);
gboolean em_utils_prompt_user(GtkWindow *parent, const gchar *promptkey, const gchar *tag, const gchar *arg0, ...);
diff --git a/mail/importers/mail-importer.c b/mail/importers/mail-importer.c
index 6e45734..ee1c958 100644
--- a/mail/importers/mail-importer.c
+++ b/mail/importers/mail-importer.c
@@ -50,7 +50,7 @@
#include "mail-mt.h"
#include "mail-tools.h"
#include "e-mail-local.h"
-#include "em-utils.h"
+#include "mail-session.h"
#include "mail-importer.h"
@@ -292,7 +292,7 @@ import_folders_rec(struct _import_folders_data *m, const gchar *filepath, const
if (dir == NULL)
return;
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
utf8_filename = g_filename_to_utf8 (filepath, -1, NULL, NULL, NULL);
camel_operation_start(NULL, _("Scanning %s"), utf8_filename);
diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c
index bbb3694..8117bfc 100644
--- a/mail/mail-autofilter.c
+++ b/mail/mail-autofilter.c
@@ -32,6 +32,7 @@
#include "mail-vfolder.h"
#include "mail-autofilter.h"
+#include "mail-session.h"
#include "em-utils.h"
#include "e-util/e-alert-dialog.h"
#include "e-util/e-util-private.h"
@@ -352,7 +353,7 @@ filter_gui_add_from_message (CamelMimeMessage *msg, const gchar *source, gint fl
g_return_if_fail (msg != NULL);
fc = em_filter_context_new ();
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
user = g_build_filename (data_dir, "filters.xml", NULL);
system = g_build_filename (EVOLUTION_PRIVDATADIR, "filtertypes.xml", NULL);
e_rule_context_load ((ERuleContext *)fc, system, user);
@@ -380,7 +381,7 @@ mail_filter_rename_uri(CamelStore *store, const gchar *olduri, const gchar *newu
enewuri = em_uri_from_camel(newuri);
fc = em_filter_context_new ();
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
user = g_build_filename (data_dir, "filters.xml", NULL);
system = g_build_filename (EVOLUTION_PRIVDATADIR, "filtertypes.xml", NULL);
e_rule_context_load ((ERuleContext *)fc, system, user);
@@ -413,7 +414,7 @@ mail_filter_delete_uri(CamelStore *store, const gchar *uri)
euri = em_uri_from_camel(uri);
fc = em_filter_context_new ();
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
user = g_build_filename (data_dir, "filters.xml", NULL);
system = g_build_filename (EVOLUTION_PRIVDATADIR, "filtertypes.xml", NULL);
e_rule_context_load ((ERuleContext *)fc, system, user);
diff --git a/mail/mail-config.c b/mail/mail-config.c
index 41ac85a..be2125b 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -59,7 +59,6 @@
#include <libedataserverui/e-passwords.h>
#include "e-mail-local.h"
-#include "em-utils.h"
#include "mail-config.h"
#include "mail-folder-cache.h"
#include "mail-mt.h"
@@ -441,7 +440,7 @@ uri_to_evname (const gchar *uri, const gchar *prefix)
gchar *safe;
gchar *tmp;
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
safe = g_strdup (uri);
e_filename_make_safe (safe);
@@ -573,7 +572,7 @@ mail_config_folder_to_cachename (CamelFolder *folder, const gchar *prefix)
gchar *url, *basename, *filename;
const gchar *config_dir;
- config_dir = em_utils_get_config_dir ();
+ config_dir = mail_session_get_config_dir ();
url = mail_config_folder_to_safe_url (folder);
basename = g_strdup_printf ("%s%s", prefix, url);
filename = g_build_filename (config_dir, basename, NULL);
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index f43e16e..5bf5be4 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -701,7 +701,7 @@ rename_folders(MailFolderCache *self, struct _store_info *si, const gchar *oldba
#endif
/* rename the meta-data we maintain ourselves */
- config_dir = em_utils_get_config_dir ();
+ config_dir = mail_session_get_config_dir ();
olduri = folder_to_url(si->store, old);
e_filename_make_safe(olduri);
newuri = folder_to_url(si->store, fi->full_name);
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 8110ab4..e07fe19 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -256,7 +256,7 @@ uid_cachename_hack (CamelStore *store)
url->host);
e_filename_make_safe (encoded_url);
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
filename = g_build_filename (data_dir, "pop", encoded_url, "uid-cache", NULL);
g_free (encoded_url);
@@ -1796,7 +1796,7 @@ empty_trash_exec (struct _empty_trash_msg *m)
if (m->account) {
trash = mail_tool_get_trash (m->account->source->url, FALSE, &m->base.ex);
} else {
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
uri = g_strdup_printf ("mbox:%s/local", data_dir);
trash = mail_tool_get_trash (uri, TRUE, &m->base.ex);
g_free (uri);
diff --git a/mail/mail-session.c b/mail/mail-session.c
index b7b26bf..e9ad274 100644
--- a/mail/mail-session.c
+++ b/mail/mail-session.c
@@ -834,3 +834,20 @@ mail_session_set_junk_headers (const gchar **name, const gchar **value, gint len
camel_session_set_junk_headers (session, name, value, len);
}
+
+const gchar *
+mail_session_get_data_dir (void)
+{
+ g_return_val_if_fail (session_shell_backend, NULL);
+
+ return e_shell_backend_get_data_dir (session_shell_backend);
+}
+
+const gchar *
+mail_session_get_config_dir (void)
+{
+ g_return_val_if_fail (session_shell_backend, NULL);
+
+ return e_shell_backend_get_config_dir (session_shell_backend);
+}
+
diff --git a/mail/mail-session.h b/mail/mail-session.h
index b127440..ccca89d 100644
--- a/mail/mail-session.h
+++ b/mail/mail-session.h
@@ -50,6 +50,9 @@ void mail_session_add_junk_plugin (const gchar *plugin_name, CamelJunkPlugin *ju
const GList * mail_session_get_junk_plugins (void);
void mail_session_set_junk_headers (const gchar **name, const gchar **value, gint len);
+const gchar * mail_session_get_data_dir (void);
+const gchar * mail_session_get_config_dir (void);
+
extern CamelSession *session;
G_END_DECLS
diff --git a/mail/mail-tools.c b/mail/mail-tools.c
index 45f502e..53bf2be 100644
--- a/mail/mail-tools.c
+++ b/mail/mail-tools.c
@@ -129,7 +129,7 @@ mail_tool_get_local_movemail_path (const guchar *uri, CamelException *ex)
if (strchr("/:;=|%&#!*^()\\, ", *c) || !isprint((gint) *c))
*c = '_';
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
path = g_build_filename (data_dir, "spool", NULL);
if (g_stat(path, &st) == -1 && g_mkdir_with_parents(path, 0777) == -1) {
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index b4a8330..6301e5f 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -46,6 +46,7 @@
#include "mail-folder-cache.h"
#include "mail-mt.h"
#include "mail-ops.h"
+#include "mail-session.h"
#include "mail-tools.h"
#include "mail-vfolder.h"
@@ -66,8 +67,6 @@ static GHashTable *vfolder_hash;
/* This is a slightly hacky solution to shutting down, we poll this variable in various
loops, and just quit processing if it is set. */
static volatile gint shutdown; /* are we shutting down? */
-/* more globals ... */
-extern CamelSession *session;
static void rule_changed(EFilterRule *rule, CamelFolder *folder);
@@ -667,7 +666,7 @@ done:
dialog = e_alert_dialog_new_for_args (e_shell_get_active_window (NULL), "mail:vfolder-updated", changed->str, uri, NULL);
em_utils_show_info_silent (dialog);
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
user = g_build_filename (data_dir, "vfolders.xml", NULL);
e_rule_context_save ((ERuleContext *) context, user);
g_free (user);
@@ -735,7 +734,7 @@ mail_vfolder_rename_uri(CamelStore *store, const gchar *cfrom, const gchar *cto)
gchar *user;
d(printf("Vfolders updated from renamed folder\n"));
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
user = g_build_filename (data_dir, "vfolders.xml", NULL);
e_rule_context_save((ERuleContext *)context, user);
g_free(user);
@@ -914,7 +913,7 @@ store_folder_deleted(CamelObject *o, gpointer event_data, gpointer data)
g_object_unref(rule);
g_signal_connect(context, "rule_removed", G_CALLBACK(context_rule_removed), context);
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
user = g_build_filename (data_dir, "vfolders.xml", NULL);
e_rule_context_save((ERuleContext *)context, user);
g_free(user);
@@ -960,7 +959,7 @@ store_folder_renamed(CamelObject *o, gpointer event_data, gpointer data)
e_filter_rule_set_name(rule, info->new->full_name);
g_signal_connect(rule, "changed", G_CALLBACK(rule_changed), folder);
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
user = g_build_filename (data_dir, "vfolders.xml", NULL);
e_rule_context_save((ERuleContext *)context, user);
g_free(user);
@@ -1021,7 +1020,7 @@ vfolder_load_storage(void)
G_UNLOCK (vfolder_hash);
/* first, create the vfolder store, and set it up */
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
storeuri = g_strdup_printf("vfolder:%s/vfolder", data_dir);
vfolder_store = camel_session_get_store(session, storeuri, NULL);
if (vfolder_store == NULL) {
@@ -1091,7 +1090,7 @@ vfolder_revert(void)
gchar *user;
d(printf("vfolder_revert\n"));
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
user = g_build_filename (data_dir, "vfolders.xml", NULL);
e_rule_context_revert((ERuleContext *)context, user);
g_free(user);
@@ -1145,7 +1144,7 @@ edit_rule_response(GtkWidget *w, gint button, gpointer data)
EFilterRule *orig = g_object_get_data (G_OBJECT (w), "orig");
e_filter_rule_copy(orig, rule);
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
user = g_build_filename (data_dir, "vfolders.xml", NULL);
e_rule_context_save((ERuleContext *)context, user);
g_free(user);
@@ -1222,7 +1221,7 @@ new_rule_clicked(GtkWidget *w, gint button, gpointer data)
g_object_ref(rule);
e_rule_context_add_rule((ERuleContext *)context, rule);
- data_dir = em_utils_get_data_dir ();
+ data_dir = mail_session_get_data_dir ();
user = g_build_filename (data_dir, "vfolders.xml", NULL);
e_rule_context_save((ERuleContext *)context, user);
g_free(user);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]