aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-tools.c
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/mail-tools.c
parented0a0ca71623bdfdca4afe145038995c4bf83560 (diff)
downloadgsoc2013-evolution-33e87f5331e8cbdd3b3b9713bbe7446882e3ca37.tar
gsoc2013-evolution-33e87f5331e8cbdd3b3b9713bbe7446882e3ca37.tar.gz
gsoc2013-evolution-33e87f5331e8cbdd3b3b9713bbe7446882e3ca37.tar.bz2
gsoc2013-evolution-33e87f5331e8cbdd3b3b9713bbe7446882e3ca37.tar.lz
gsoc2013-evolution-33e87f5331e8cbdd3b3b9713bbe7446882e3ca37.tar.xz
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/mail-tools.c')
-rw-r--r--mail/mail-tools.c69
1 files changed, 69 insertions, 0 deletions
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);
+}