aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2003-03-24 21:27:32 +0800
committerMichael Zucci <zucchi@src.gnome.org>2003-03-24 21:27:32 +0800
commit33e87f5331e8cbdd3b3b9713bbe7446882e3ca37 (patch)
treeaedcf6d61636003f743d2b37fa905a7f6315b266 /mail
parented0a0ca71623bdfdca4afe145038995c4bf83560 (diff)
downloadgsoc2013-evolution-33e87f5331e8cbdd3b3b9713bbe7446882e3ca37.tar.gz
gsoc2013-evolution-33e87f5331e8cbdd3b3b9713bbe7446882e3ca37.tar.zst
gsoc2013-evolution-33e87f5331e8cbdd3b3b9713bbe7446882e3ca37.zip
Load per-folder setting of show_preview from meta data.
2003-03-25 Not Zed <NotZed@Ximian.com> * folder-browser-ui.c (folder_browser_ui_add_global): Load per-folder setting of show_preview from meta data. (folder_browser_ui_add_list): Same, for thread_list. * mail-tools.c (mail_tool_get_meta_data) (mail_tool_delete_meta_data): helpers to lookup/delete meta data. * mail-config.c (mail_config_uri_deleted): delete the meta-data for the folder. * folder-browser.c (folder_browser_reload): dont reload the uri if we're in the process of loading it still. (folder_browser_new): load the folder meta data before loading the folder. (folder_browser_toggle_preview): (folder_browser_toggle_threads): save change to meta-data. (got_folder): Load the metadata if we have a folder to set, and the meta-data has changed from initislisation. svn path=/trunk/; revision=20478
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog21
-rw-r--r--mail/component-factory.c1
-rw-r--r--mail/folder-browser-ui.c5
-rw-r--r--mail/folder-browser.c55
-rw-r--r--mail/folder-browser.h2
-rw-r--r--mail/mail-config.c2
-rw-r--r--mail/mail-tools.c69
-rw-r--r--mail/mail-tools.h3
8 files changed, 139 insertions, 19 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index bfd2d74449..1982b4b147 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,24 @@
+2003-03-25 Not Zed <NotZed@Ximian.com>
+
+ * folder-browser-ui.c (folder_browser_ui_add_global): Load
+ per-folder setting of show_preview from meta data.
+ (folder_browser_ui_add_list): Same, for thread_list.
+
+ * mail-tools.c (mail_tool_get_meta_data)
+ (mail_tool_delete_meta_data): helpers to lookup/delete meta data.
+
+ * mail-config.c (mail_config_uri_deleted): delete the meta-data
+ for the folder.
+
+ * folder-browser.c (folder_browser_reload): dont reload the uri if
+ we're in the process of loading it still.
+ (folder_browser_new): load the folder meta data before loading the
+ folder.
+ (folder_browser_toggle_preview):
+ (folder_browser_toggle_threads): save change to meta-data.
+ (got_folder): Load the metadata if we have a folder to set, and
+ the meta-data has changed from initislisation.
+
2003-03-23 Chris Toshok <toshok@ximian.com>
* mail-callbacks.c (ask_confirm_for_unwanted_html_mail): pass
diff --git a/mail/component-factory.c b/mail/component-factory.c
index bee831a3a3..3e8ccddf55 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -731,6 +731,7 @@ got_folder (char *uri, CamelFolder *folder, void *data)
*fp = folder;
if (folder) {
+ printf("got folder '%s'\n", uri);
camel_object_ref (CAMEL_OBJECT (folder));
/* emit a changed event, this is a little hack so that the folderinfo cache
diff --git a/mail/folder-browser-ui.c b/mail/folder-browser-ui.c
index c265ad62c3..1bb4cbf3c9 100644
--- a/mail/folder-browser-ui.c
+++ b/mail/folder-browser-ui.c
@@ -577,6 +577,9 @@ folder_browser_ui_add_list (FolderBrowser *fb)
/* Threaded toggle */
state = gconf_client_get_bool (gconf, "/apps/evolution/mail/display/thread_list", NULL);
+ if (fb->meta)
+ state = e_meta_get_bool(fb->meta, "thread_list", state);
+
bonobo_ui_component_set_prop (uic, "/commands/ViewThreaded", "state", state ? "1" : "0", NULL);
bonobo_ui_component_add_listener (uic, "ViewThreaded", folder_browser_toggle_threads, fb);
message_list_set_threaded (fb->message_list, state);
@@ -627,6 +630,8 @@ folder_browser_ui_add_global (FolderBrowser *fb)
/* (Pre)view toggle */
show_preview = gconf_client_get_bool (gconf, "/apps/evolution/mail/display/show_preview", NULL);
+ if (fb->meta)
+ show_preview = e_meta_get_bool(fb->meta, "show_preview", show_preview);
bonobo_ui_component_set_prop (uic, "/commands/ViewPreview", "state", show_preview ? "1" : "0", NULL);
folder_browser_set_message_preview (fb, show_preview);
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index 3f6930cd10..eeb464803a 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -56,6 +56,7 @@
#include "e-util/e-sexp.h"
#include "e-util/e-mktemp.h"
+#include "e-util/e-meta.h"
#include "folder-browser.h"
#include "e-searching-tokenizer.h"
#include "mail.h"
@@ -865,7 +866,8 @@ static void
got_folder (char *uri, CamelFolder *folder, void *user_data)
{
FolderBrowser *fb = user_data;
-
+ EMeta *meta;
+
fb->get_id = -1;
d(printf ("got folder '%s' = %p, previous folder was %p\n", uri, folder, fb->folder));
@@ -878,12 +880,26 @@ got_folder (char *uri, CamelFolder *folder, void *user_data)
camel_object_unhook_event (fb->folder, "message_changed", folder_changed, fb);
camel_object_unref (fb->folder);
}
-
- fb->folder = folder;
- if (folder == NULL)
+
+ if (folder) {
+ fb->folder = folder;
+ camel_object_ref (folder);
+ meta = mail_tool_get_meta_data(fb->uri);
+ if (meta != fb->meta) {
+ g_object_unref(fb->meta);
+ fb->meta = meta;
+ } else {
+ g_object_unref(meta);
+ }
+ } else {
+ fb->folder = NULL;
+ if (fb->meta) {
+ g_object_unref(fb->meta);
+ fb->meta = NULL;
+ }
goto done;
-
- camel_object_ref (folder);
+ }
+
gtk_widget_set_sensitive (GTK_WIDGET (fb->search), camel_folder_has_search_capability (folder));
message_list_set_folder (fb->message_list, folder,
@@ -919,7 +935,7 @@ folder_browser_reload (FolderBrowser *fb)
if (fb->folder) {
mail_refresh_folder (fb->folder, NULL, NULL);
- } else if (fb->uri) {
+ } else if (fb->uri && fb->get_id == -1) {
g_object_ref (fb);
fb->get_id = mail_get_folder (fb->uri, 0, got_folder, fb, mail_thread_new);
}
@@ -1280,14 +1296,15 @@ folder_browser_toggle_preview (BonoboUIComponent *component,
gpointer user_data)
{
FolderBrowser *fb = user_data;
- GConfClient *gconf;
-
+ gboolean bstate;
+
if (type != Bonobo_UIComponent_STATE_CHANGED || fb->message_list == NULL)
return;
- gconf = gconf_client_get_default ();
- gconf_client_set_bool (gconf, "/apps/evolution/mail/display/show_preview", atoi (state), NULL);
- folder_browser_set_message_preview (fb, atoi (state));
+ bstate = atoi(state);
+ e_meta_set_bool(fb->meta, "show_preview", bstate);
+ gconf_client_set_bool (gconf_client_get_default(), "/apps/evolution/mail/display/show_preview", bstate, NULL);
+ folder_browser_set_message_preview (fb, bstate);
}
void
@@ -1298,17 +1315,16 @@ folder_browser_toggle_threads (BonoboUIComponent *component,
gpointer user_data)
{
FolderBrowser *fb = user_data;
- GConfClient *gconf;
int prev_state;
+ gboolean bstate;
if (type != Bonobo_UIComponent_STATE_CHANGED || fb->message_list == NULL)
return;
-
- gconf = gconf_client_get_default ();
- gconf_client_set_bool (gconf, "/apps/evolution/mail/display/thread_list",
- atoi (state), NULL);
-
- message_list_set_threaded (fb->message_list, atoi (state));
+
+ bstate = atoi(state);
+ e_meta_set_bool(fb->meta, "thread_list", bstate);
+ gconf_client_set_bool (gconf_client_get_default (), "/apps/evolution/mail/display/thread_list", bstate, NULL);
+ message_list_set_threaded (fb->message_list, bstate);
prev_state = fb->selection_state;
fb->selection_state = FB_SELSTATE_UNDEFINED;
@@ -2608,6 +2624,7 @@ folder_browser_new (const GNOME_Evolution_Shell shell, const char *uri)
if (uri) {
folder_browser->uri = g_strdup (uri);
+ folder_browser->meta = mail_tool_get_meta_data(uri);
g_object_ref (folder_browser);
folder_browser->get_id = mail_get_folder (folder_browser->uri, 0, got_folder,
folder_browser, mail_thread_new);
diff --git a/mail/folder-browser.h b/mail/folder-browser.h
index d538003301..d4665c91b8 100644
--- a/mail/folder-browser.h
+++ b/mail/folder-browser.h
@@ -71,6 +71,8 @@ struct _FolderBrowser {
EFilterBar *search;
FilterRule *search_full; /* if we have a full search active */
+
+ struct _EMeta *meta; /* various per-folder meta-data */
guint32 preview_shown : 1;
guint32 threaded : 1;
diff --git a/mail/mail-config.c b/mail/mail-config.c
index cfd550e716..71758dc3bc 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -851,6 +851,8 @@ mail_config_uri_deleted (GCompareFunc uri_cmp, const char *uri)
int work = 0;
/* assumes these can't be removed ... */
extern char *default_sent_folder_uri, *default_drafts_folder_uri;
+
+ mail_tool_delete_meta_data(uri);
iter = e_list_get_iterator ((EList *) config->accounts);
while (e_iterator_is_valid (iter)) {
diff --git a/mail/mail-tools.c b/mail/mail-tools.c
index 9528c5a1cb..9892090221 100644
--- a/mail/mail-tools.c
+++ b/mail/mail-tools.c
@@ -43,6 +43,8 @@
#include <filter/filter-option.h>
#include <filter/filter-input.h>
+#include "e-util/e-meta.h"
+
#include "mail-vfolder.h"
#include "mail.h" /*session*/
#include "mail-format.h"
@@ -497,3 +499,70 @@ mail_tools_folder_to_url (CamelFolder *folder)
return url;
}
+
+static char *meta_data_key(const char *uri, char **pathp)
+{
+ CamelURL *url;
+ GString *path;
+ const char *key;
+ char *p, c;
+
+ url = camel_url_new(uri, NULL);
+ path = g_string_new(evolution_dir);
+ g_string_append_printf(path, "/meta/%s/", url->protocol);
+
+ if (url->host && url->host[0]) {
+ if (url->user)
+ g_string_append_printf(path, "%s@", url->user);
+ g_string_append(path, url->host);
+ if (url->port)
+ g_string_append_printf(path, ":%d", url->port);
+ key = url->path;
+ } else if (url->path) {
+ if (url->fragment) {
+ p = url->path;
+ while ((c = *p++)) {
+ if (c == '/')
+ c = '_';
+ g_string_append_c(path, c);
+ }
+ key = url->fragment;
+ } else {
+ key = url->path;
+ }
+ }
+
+ if (key == NULL)
+ key = uri;
+
+ camel_url_free(url);
+ *pathp = path->str;
+ g_string_free(path, FALSE);
+
+ return g_strdup(key);
+}
+
+EMeta *
+mail_tool_get_meta_data(const char *uri)
+{
+ char *path, *key;
+ EMeta *meta;
+
+ key = meta_data_key(uri, &path);
+ meta = e_meta_data_find(path, key);
+ g_free(key);
+ g_free(path);
+
+ return meta;
+}
+
+void
+mail_tool_delete_meta_data(const char *uri)
+{
+ char *path, *key;
+
+ key = meta_data_key(uri, &path);
+ e_meta_data_delete(path, key);
+ g_free(key);
+ g_free(path);
+}
diff --git a/mail/mail-tools.h b/mail/mail-tools.h
index 6c74d291f8..fc01294d4e 100644
--- a/mail/mail-tools.h
+++ b/mail/mail-tools.h
@@ -77,4 +77,7 @@ CamelFolder *mail_tools_x_evolution_message_parse (char *in, unsigned int inlen,
char *mail_tools_folder_to_url (CamelFolder *folder);
+struct _EMeta *mail_tool_get_meta_data(const char *uri);
+void mail_tool_delete_meta_data(const char *uri);
+
#endif