aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
author0 <NotZed@Ximian.com>2001-09-21 03:34:58 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-09-21 03:34:58 +0800
commit55690284e1557f5c85bc8edae36b3cf3817eff9e (patch)
treeffdddd8c001cfc66fd9a8d75ca535b67b13af538 /mail
parent66ec2f9d1ef656f558173d69cc5f917743fb3dfb (diff)
downloadgsoc2013-evolution-55690284e1557f5c85bc8edae36b3cf3817eff9e.tar.gz
gsoc2013-evolution-55690284e1557f5c85bc8edae36b3cf3817eff9e.tar.zst
gsoc2013-evolution-55690284e1557f5c85bc8edae36b3cf3817eff9e.zip
Dont special case file: url's anymore.
2001-09-20 <NotZed@Ximian.com> * mail-tools.c (mail_tool_uri_to_folder): Dont special case file: url's anymore. * mail-local.c: Add real_path to MailLocalFolder. (mail_local_folder_construct): Added path argument, setup full_name == path, and real_path == full_name. (mls_get_folder): First lookup folderinfo to confirm this folder exists, then use that to properly construct the folder paths. (mail_local_folder_reconfigure): Use real_path not full_name to create the store uri. (mlf_set_folder): Use real_path not folder_name to get real uri path. 2001-09-19 <NotZed@Ximian.com> * mail-folder-cache.c (setup_store): Use the wrong spelling of finalised for the event hook. (real_note_folder): Use the wrong spelling of finalised for the event hook. (free_folder_info): Free the full_name parameter. (setup_folder): (real_note_folder): Key the folderinfo table on full_name, not path. svn path=/trunk/; revision=13014
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog27
-rw-r--r--mail/mail-folder-cache.c19
-rw-r--r--mail/mail-local.c79
-rw-r--r--mail/mail-tools.c5
4 files changed, 89 insertions, 41 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 1d9a826bb9..f280c9dcf7 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,30 @@
+2001-09-20 <NotZed@Ximian.com>
+
+ * mail-tools.c (mail_tool_uri_to_folder): Dont special case file:
+ url's anymore.
+
+ * mail-local.c: Add real_path to MailLocalFolder.
+ (mail_local_folder_construct): Added path argument, setup
+ full_name == path, and real_path == full_name.
+ (mls_get_folder): First lookup folderinfo to confirm this folder
+ exists, then use that to properly construct the folder paths.
+ (mail_local_folder_reconfigure): Use real_path not full_name to
+ create the store uri.
+ (mlf_set_folder): Use real_path not folder_name to get real uri
+ path.
+
+2001-09-19 <NotZed@Ximian.com>
+
+ * mail-folder-cache.c (setup_store): Use the wrong spelling of
+ finalised for the event hook.
+ (real_note_folder): Use the wrong spelling of finalised for the
+ event hook.
+ (free_folder_info): Free the full_name parameter.
+ (setup_folder):
+ (real_note_folder): Key the folderinfo table on full_name, not
+ path.
+
+
2001-09-20 Jeffrey Stedfast <fejj@ximian.com>
* mail-ops.c (save_messages_save): Convert all textual parts to
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index 9514724271..32c68b75de 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -40,7 +40,7 @@
#include "mail-folder-cache.h"
#include "mail-ops.h"
-#define d(x)
+#define d(x) x
/* note that many things are effectively serialised by having them run in
the main loop thread which they need to do because of corba/gtk calls */
@@ -52,13 +52,14 @@ static pthread_mutex_t info_lock = PTHREAD_MUTEX_INITIALIZER;
struct _folder_info {
struct _store_info *store_info; /* 'parent' link */
- char *path;
+ char *path; /* shell path */
char *name; /* shell display name? */
+ char *full_name; /* full name of folder/folderinfo */
CamelFolder *folder; /* if known */
};
struct _store_info {
- GHashTable *folders; /* by path */
+ GHashTable *folders; /* by full_name */
/* only 1 should be set */
EvolutionStorage *storage;
@@ -106,7 +107,7 @@ setup_folder(const char *path, CamelFolderInfo *fi, struct _store_info *si)
int unread = fi->unread_message_count;
LOCK(info_lock);
- mfi = g_hash_table_lookup(si->folders, path);
+ mfi = g_hash_table_lookup(si->folders, fi->full_name);
if (mfi) {
UNLOCK(info_lock);
update_1folder(mfi, fi);
@@ -116,8 +117,9 @@ setup_folder(const char *path, CamelFolderInfo *fi, struct _store_info *si)
mfi = g_malloc0(sizeof(*mfi));
mfi->path = g_strdup(path);
mfi->name = g_strdup(fi->name);
+ mfi->full_name = g_strdup(fi->full_name);
mfi->store_info = si;
- g_hash_table_insert(si->folders, mfi->path, mfi);
+ g_hash_table_insert(si->folders, mfi->full_name, mfi);
UNLOCK(info_lock);
if (si->storage != NULL) {
@@ -178,7 +180,7 @@ real_note_folder(CamelFolder *folder, char *path, void *data)
path = g_strdup_printf("/%s", folder->full_name);
LOCK(info_lock);
- mfi = g_hash_table_lookup(si->folders, path);
+ mfi = g_hash_table_lookup(si->folders, folder->full_name);
UNLOCK(info_lock);
if (mfi == NULL) {
@@ -198,7 +200,7 @@ real_note_folder(CamelFolder *folder, char *path, void *data)
camel_object_hook_event((CamelObject *)folder, "folder_changed", folder_changed, mfi);
camel_object_hook_event((CamelObject *)folder, "message_changed", folder_changed, mfi);
- camel_object_hook_event((CamelObject *)folder, "finalised", folder_finalised, mfi);
+ camel_object_hook_event((CamelObject *)folder, "finalized", folder_finalised, mfi);
camel_object_unref((CamelObject *)folder);
}
@@ -271,6 +273,7 @@ free_folder_info(char *path, struct _folder_info *info, void *data)
{
g_free(info->path);
g_free(info->name);
+ g_free(info->full_name);
}
static void
@@ -343,7 +346,7 @@ setup_store(CamelStore *store, EvolutionStorage *storage, GNOME_Evolution_Storag
camel_object_hook_event((CamelObject *)store, "folder_created", store_folder_created, NULL);
camel_object_hook_event((CamelObject *)store, "folder_deleted", store_folder_deleted, NULL);
- camel_object_hook_event((CamelObject *)store, "finalised", store_finalised, NULL);
+ camel_object_hook_event((CamelObject *)store, "finalized", store_finalised, NULL);
}
UNLOCK(info_lock);
diff --git a/mail/mail-local.c b/mail/mail-local.c
index dcc6567638..13d03f75f6 100644
--- a/mail/mail-local.c
+++ b/mail/mail-local.c
@@ -110,6 +110,8 @@ typedef struct {
CamelFolder *real_folder;
CamelStore *real_store;
+ char *real_path;
+
struct _local_meta *meta;
GMutex *real_folder_lock; /* no way to use the CamelFolder's lock, so... */
@@ -415,7 +417,7 @@ mlf_set_folder(MailLocalFolder *mlf, guint32 flags, CamelException *ex)
g_assert(mlf->real_folder == NULL);
- uri = g_strdup_printf("%s:%s%s", mlf->meta->format, ((CamelService *)folder->parent_store)->url->path, folder->full_name);
+ uri = g_strdup_printf("%s:%s%s", mlf->meta->format, ((CamelService *)folder->parent_store)->url->path, mlf->real_path);
d(printf("opening real store: %s\n", uri));
mlf->real_store = camel_session_get_store(session, uri, ex);
g_free(uri);
@@ -508,7 +510,7 @@ mail_local_folder_get_type (void)
}
static MailLocalFolder *
-mail_local_folder_construct(MailLocalFolder *mlf, MailLocalStore *parent_store, const char *full_name, CamelException *ex)
+mail_local_folder_construct(MailLocalFolder *mlf, MailLocalStore *parent_store, const char *full_name, char *path, CamelException *ex)
{
const char *name;
char *metapath;
@@ -522,6 +524,9 @@ mail_local_folder_construct(MailLocalFolder *mlf, MailLocalStore *parent_store,
camel_folder_construct(CAMEL_FOLDER (mlf), CAMEL_STORE(parent_store), full_name, name);
+ mlf->real_path = ((CamelFolder *)mlf)->full_name;
+ ((CamelFolder *)mlf)->full_name = g_strdup(path);
+
metapath = g_strdup_printf("%s/%s/local-metadata.xml", ((CamelService *)parent_store)->url->path, full_name);
mlf->meta = load_metainfo(metapath);
g_free(metapath);
@@ -555,7 +560,7 @@ mail_local_folder_reconfigure (MailLocalFolder *mlf, const char *new_format, Cam
}
store_uri = g_strdup_printf("%s:%s%s", mlf->meta->format,
- ((CamelService *)((CamelFolder *)mlf)->parent_store)->url->path, ((CamelFolder *)mlf)->full_name);
+ ((CamelService *)((CamelFolder *)mlf)->parent_store)->url->path, mlf->real_path);
fromstore = camel_session_get_store(session, store_uri, ex);
g_free(store_uri);
if (fromstore == NULL)
@@ -652,11 +657,28 @@ mls_get_folder(CamelStore *store, const char *folder_name, guint32 flags, CamelE
MailLocalFolder *folder;
char *physical_uri;
CamelFolderInfo *info;
+ char *path = NULL;
- d(printf("--LOCAL-- get_folder: %s", folder_name));
+ d(printf("--LOCAL-- get_folder: %s\n", folder_name));
+
+ physical_uri = g_strdup_printf("file:/%s/%s", ((CamelService *)store)->url->path, folder_name);
+ LOCAL_STORE_LOCK(local_store);
+ info = g_hash_table_lookup(local_store->folder_infos, physical_uri);
+ g_free(physical_uri);
+ if (info) {
+ path = g_strdup(info->full_name);
+ LOCAL_STORE_UNLOCK(local_store);
+ } else {
+ LOCAL_STORE_UNLOCK(local_store);
+ g_warning("LocalStore opening a folder we weren't told existed!: %s", physical_uri);
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Cannot open folder: %s: No such folder"),
+ folder_name);
+ return NULL;
+ }
folder = (MailLocalFolder *)camel_object_new(MAIL_LOCAL_FOLDER_TYPE);
- folder = mail_local_folder_construct(folder, local_store, folder_name, ex);
+ folder = mail_local_folder_construct(folder, local_store, folder_name, path, ex);
if (folder == NULL)
return NULL;
@@ -675,23 +697,6 @@ mls_get_folder(CamelStore *store, const char *folder_name, guint32 flags, CamelE
}
}
- physical_uri = g_strdup_printf("file:/%s/%s", ((CamelService *)store)->url->path, folder_name);
- LOCAL_STORE_LOCK(local_store);
- info = g_hash_table_lookup(local_store->folder_infos, physical_uri);
- if (info) {
- char *path = g_strdup(info->full_name);
-
- d(printf("noting folder: '%s' path = '%s'\n", info->url, info->full_name));
-
- LOCAL_STORE_UNLOCK(local_store);
- mail_note_folder((CamelFolder *)folder, path);
- g_free(path);
- } else {
- LOCAL_STORE_UNLOCK(local_store);
- g_warning("LocalStore opening a folder we weren't told existed!: %s", physical_uri);
- }
- g_free(physical_uri);
-
return (CamelFolder *)folder;
}
@@ -808,7 +813,19 @@ mail_local_store_get_type (void)
static void mail_local_store_add_folder(MailLocalStore *mls, const char *uri, const char *path, const char *name)
{
- CamelFolderInfo *info;
+ CamelFolderInfo *info = NULL;
+ CamelURL *url;
+
+ url = camel_url_new(uri, NULL);
+ if (url == NULL) {
+ g_warning("Shell trying to add invalid folder url: %s", uri);
+ return;
+ }
+ if (url->path == NULL || url->path[0] == 0) {
+ g_warning("Shell trying to add invalid folder url: %s", uri);
+ camel_url_free(url);
+ return;
+ }
LOCAL_STORE_LOCK(mls);
@@ -825,14 +842,18 @@ static void mail_local_store_add_folder(MailLocalStore *mls, const char *uri, co
LOCAL_STORE_UNLOCK(mls);
- d(printf("adding folder: '%s' path = '%s'\n", info->url, path));
+ camel_url_free(url);
+
+ if (info) {
+ d(printf("adding folder: '%s' path = '%s'\n", uri, path));
- /* FIXME: should copy info, so we dont get a removed while we're using it? */
- camel_object_trigger_event((CamelObject *)mls, "folder_created", info);
+ /* FIXME: should copy info, so we dont get a removed while we're using it? */
+ camel_object_trigger_event((CamelObject *)mls, "folder_created", info);
- /* this is just so the folder is opened at least once to setup the folder
- counts etc in the display. Joy eh? The result is discarded. */
- mail_get_folder(uri, NULL, NULL);
+ /* this is just so the folder is opened at least once to setup the folder
+ counts etc in the display. Joy eh? The result is discarded. */
+ mail_get_folder(uri, NULL, NULL);
+ }
}
struct _search_info {
diff --git a/mail/mail-tools.c b/mail/mail-tools.c
index 5e0d3ee9ee..406b5f2c47 100644
--- a/mail/mail-tools.c
+++ b/mail/mail-tools.c
@@ -366,10 +366,7 @@ mail_tool_uri_to_folder (const char *uri, CamelException *ex)
folder = NULL;
}
} else {
- /* we dont want to note file url's, they need to be noted elsewhere (sigh) */
- if (strncmp(uri, "file:", 5) != 0)
- mail_note_folder(folder, NULL);
- /*mail_folder_cache_note_folder (uri, folder);*/
+ mail_note_folder(folder, NULL);
}
camel_url_free (url);