aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author8 <NotZed@Ximian.com>2001-10-28 18:53:02 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-10-28 18:53:02 +0800
commit4229e6849ddbb2ecef6bef8177203c9b90c98686 (patch)
tree47f5b887300c08292f1b17acd03bc6b20c967edb
parent4ee4cf5693acf3ec206b9dda7ddaf772aa441489 (diff)
downloadgsoc2013-evolution-4229e6849ddbb2ecef6bef8177203c9b90c98686.tar.gz
gsoc2013-evolution-4229e6849ddbb2ecef6bef8177203c9b90c98686.tar.zst
gsoc2013-evolution-4229e6849ddbb2ecef6bef8177203c9b90c98686.zip
Remove uic, kill dumb warning.
2001-10-28 <NotZed@Ximian.com> * folder-browser-ui.c (fbui_sensitize_timeout): Remove uic, kill dumb warning. * mail-autofilter.c (mail_filter_rename_uri): Implement function for filters to keep track of uri's being renamed. (mail_filter_delete_uri): Similarly for deleting uri's. Note that these functions are just noops though. (real_flush_updates): Also rename and delete uri's from filters. (mls_delete_folder): Unref the store when done. (mls_rename_folder): Fix implementation, shell already created destination folder, so we can't just rename :( (xfer_folder): Manually call rename code, since the shell will do a remove/add later on, AND there's no way we can determine the new path from the crock of an api we have to work with. svn path=/trunk/; revision=14291
-rw-r--r--mail/ChangeLog17
-rw-r--r--mail/component-factory.c7
-rw-r--r--mail/folder-browser-ui.c1
-rw-r--r--mail/mail-autofilter.c48
-rw-r--r--mail/mail-autofilter.h9
-rw-r--r--mail/mail-folder-cache.c22
-rw-r--r--mail/mail-local.c104
-rw-r--r--mail/mail-vfolder.c10
8 files changed, 174 insertions, 44 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 4a111df44f..8cd958683a 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,13 @@
+2001-10-28 <NotZed@Ximian.com>
+
+ * folder-browser-ui.c (fbui_sensitize_timeout): Remove uic, kill
+ dumb warning.
+
+ * mail-autofilter.c (mail_filter_rename_uri): Implement function
+ for filters to keep track of uri's being renamed.
+ (mail_filter_delete_uri): Similarly for deleting uri's. Note that
+ these functions are just noops though.
+
2001-10-28 Jeffrey Stedfast <fejj@ximian.com>
* folder-browser.c: Deactivate the Print right-click menu option
@@ -13,12 +23,16 @@
* mail-folder-cache.c (real_flush_updates): Pass the rename event
to vfolder rename uri.
+ (real_flush_updates): Also rename and delete uri's from filters.
* mail-local.c (mail_local_folder_reconfigure): Change the store
path to be same as parent + mbox to be full path.
(mls_delete_folder): Change store path to be parent path, and mbox
to be full path.
(mail_local_folder_reconfigure): Fix a leak of tmpname.
+ (mls_delete_folder): Unref the store when done.
+ (mls_rename_folder): Fix implementation, shell already created
+ destination folder, so we can't just rename :(
* component-factory.c (xfer_folder): Only do a rename if we have
remove set, cleaned up logic a bit.
@@ -26,6 +40,9 @@
all.
(storage_create_folder): IF we have a fragment, use that as part
part for parent.
+ (xfer_folder): Manually call rename code, since the shell will do
+ a remove/add later on, AND there's no way we can determine the new
+ path from the crock of an api we have to work with.
2001-10-27 Jeffrey Stedfast <fejj@ximian.com>
diff --git a/mail/component-factory.c b/mail/component-factory.c
index 92dfddb79b..0139cb43e7 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -384,6 +384,13 @@ xfer_folder (EvolutionShellComponent *shell_component,
if (camel_exception_is_set(&ex))
GNOME_Evolution_ShellComponentListener_notifyResult (listener, GNOME_Evolution_ShellComponentListener_INVALID_URI, &ev);
+ else {
+ /* Since the shell doesn't play nice with local folders, we have to do this manually */
+ mail_vfolder_rename_uri(store, source_physical_uri, destination_physical_uri);
+ mail_filter_rename_uri(store, source_physical_uri, destination_physical_uri);
+ GNOME_Evolution_ShellComponentListener_notifyResult (listener, GNOME_Evolution_ShellComponentListener_OK, &ev);
+ }
+ camel_object_unref((CamelObject *)store);
} else {
source = mail_tool_uri_to_folder (source_physical_uri, 0, &ex);
diff --git a/mail/folder-browser-ui.c b/mail/folder-browser-ui.c
index b5b4e853a8..d11b6a473e 100644
--- a/mail/folder-browser-ui.c
+++ b/mail/folder-browser-ui.c
@@ -455,7 +455,6 @@ static gboolean
fbui_sensitize_timeout (gpointer data)
{
FolderBrowser *fb = FOLDER_BROWSER (data);
- BonoboUIComponent *uic = fb->uicomp;
GSList *iter;
struct sensitize_data *sd;
int i;
diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c
index 2eeafccf1d..43bba61c57 100644
--- a/mail/mail-autofilter.c
+++ b/mail/mail-autofilter.c
@@ -48,6 +48,8 @@
#include "filter/filter-editor.h"
#include "filter/filter-option.h"
+extern char *evolution_dir;
+
static void
rule_match_recipients (RuleContext *context, FilterRule *rule, CamelInternetAddress *iaddr)
{
@@ -319,7 +321,6 @@ filter_gui_add_from_message (CamelMimeMessage *msg, int flags)
FilterContext *fc;
char *user, *system;
FilterRule *rule;
- extern char *evolution_dir;
g_return_if_fail (msg != NULL);
@@ -342,7 +343,6 @@ filter_gui_add_from_mlist (const char *mlist)
FilterContext *fc;
char *user, *system;
FilterRule *rule;
- extern char *evolution_dir;
fc = filter_context_new ();
user = g_strdup_printf ("%s/filters.xml", evolution_dir);
@@ -356,3 +356,47 @@ filter_gui_add_from_mlist (const char *mlist)
g_free (user);
gtk_object_unref (GTK_OBJECT (fc));
}
+
+void
+mail_filter_rename_uri(CamelStore *store, const char *olduri, const char *newuri)
+{
+ GCompareFunc uri_cmp = CAMEL_STORE_CLASS(CAMEL_OBJECT_GET_CLASS(store))->compare_folder_name;
+ FilterContext *fc;
+ char *user, *system;
+
+ fc = filter_context_new ();
+ user = g_strdup_printf ("%s/filters.xml", evolution_dir);
+ system = EVOLUTION_DATADIR "/evolution/filtertypes.xml";
+ rule_context_load ((RuleContext *)fc, system, user);
+
+ if (rule_context_rename_uri((RuleContext *)fc, olduri, newuri, uri_cmp) > 0) {
+ printf("Folder rename '%s' -> '%s' changed filters, resaving\n", olduri, newuri);
+ if (rule_context_save((RuleContext *)fc, user) == -1)
+ g_warning("Could not write out changed filter rules\n");
+ }
+
+ g_free(user);
+ gtk_object_unref (GTK_OBJECT (fc));
+}
+
+void
+mail_filter_delete_uri(CamelStore *store, const char *uri)
+{
+ GCompareFunc uri_cmp = CAMEL_STORE_CLASS(CAMEL_OBJECT_GET_CLASS(store))->compare_folder_name;
+ FilterContext *fc;
+ char *user, *system;
+
+ fc = filter_context_new ();
+ user = g_strdup_printf ("%s/filters.xml", evolution_dir);
+ system = EVOLUTION_DATADIR "/evolution/filtertypes.xml";
+ rule_context_load ((RuleContext *)fc, system, user);
+
+ if (rule_context_delete_uri((RuleContext *)fc, uri, uri_cmp) > 0) {
+ printf("Folder deleterename '%s' changed filters, resaving\n", uri);
+ if (rule_context_save((RuleContext *)fc, user) == -1)
+ g_warning("Could not write out changed filter rules\n");
+ }
+
+ g_free(user);
+ gtk_object_unref (GTK_OBJECT (fc));
+}
diff --git a/mail/mail-autofilter.h b/mail/mail-autofilter.h
index 2c3e2c119c..5a2dbe52e5 100644
--- a/mail/mail-autofilter.h
+++ b/mail/mail-autofilter.h
@@ -43,8 +43,11 @@ FilterRule *filter_rule_from_mlist(FilterContext *context, const char *mlist);
/* easiest place to put this */
-void filter_gui_add_from_message (CamelMimeMessage *msg,
- int flags);
-void filter_gui_add_from_mlist (const char *mlist);
+void filter_gui_add_from_message(CamelMimeMessage *msg, int flags);
+void filter_gui_add_from_mlist(const char *mlist);
+
+/* Also easiest place for these, we should really share a global rule context for this stuff ... */
+void mail_filter_rename_uri(CamelStore *store, const char *olduri, const char *newuri);
+void mail_filter_delete_uri(CamelStore *store, const char *uri);
#endif
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index 7e6c3bca26..3ef602eda0 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -42,7 +42,10 @@
#include "mail-mt.h"
#include "mail-folder-cache.h"
#include "mail-ops.h"
+
+/* For notifications of changes */
#include "mail-vfolder.h"
+#include "mail-autofilter.h"
#define d(x)
@@ -150,9 +153,10 @@ real_flush_updates(void *o, void *event_data, void *data)
UNLOCK(info_lock);
if (up->remove) {
- if (up->delete)
+ if (up->delete) {
mail_vfolder_delete_uri(up->store, up->uri);
- else
+ mail_filter_delete_uri(up->store, up->uri);
+ } else
mail_vfolder_add_uri(up->store, up->uri, TRUE);
} else {
/* Its really a rename, but we have no way of telling the shell that, so remove it */
@@ -163,8 +167,10 @@ real_flush_updates(void *o, void *event_data, void *data)
}
/* We can tell the vfolder code though */
- if (up->olduri && up->add)
+ if (up->olduri && up->add) {
mail_vfolder_rename_uri(up->store, up->olduri, up->uri);
+ mail_filter_rename_uri(up->store, up->olduri, up->uri);
+ }
if (up->name == NULL) {
if (storage != NULL) {
@@ -394,7 +400,7 @@ folder_renamed(CamelObject *o, gpointer event_data, gpointer user_data)
CamelFolder *folder = (CamelFolder *)o;
char *old = event_data;
- printf("Folder renamed from '%s' to '%s'\n", old, folder->full_name);
+ d(printf("Folder renamed from '%s' to '%s'\n", old, folder->full_name));
mfi = mfi;
/* Dont do anything, do it from the store rename event? */
}
@@ -450,7 +456,7 @@ store_folder_subscribed(CamelObject *o, void *event_data, void *data)
struct _store_info *si;
CamelFolderInfo *fi = event_data;
- printf("Store folder subscribed '%s' store '%s' \n", fi->full_name, camel_url_to_string(((CamelService *)o)->url, 0));
+ d(printf("Store folder subscribed '%s' store '%s' \n", fi->full_name, camel_url_to_string(((CamelService *)o)->url, 0)));
LOCK(info_lock);
si = g_hash_table_lookup(stores, o);
@@ -462,8 +468,6 @@ store_folder_subscribed(CamelObject *o, void *event_data, void *data)
static void
store_folder_created(CamelObject *o, void *event_data, void *data)
{
- printf("Store folder created\n");
-
/* we only want created events to do more work if we dont support subscriptions */
if (!camel_store_supports_subscriptions(CAMEL_STORE(o)))
store_folder_subscribed(o, event_data, data);
@@ -514,7 +518,7 @@ rename_folders(struct _store_info *si, const char *oldbase, const char *newbase,
old = g_strdup_printf("%s%s", oldbase, fi->full_name + strlen(newbase));
mfi = g_hash_table_lookup(si->folders, old);
if (mfi) {
- printf("Found old folder '%s' renaming to '%s'\n", mfi->full_name, fi->full_name);
+ d(printf("Found old folder '%s' renaming to '%s'\n", mfi->full_name, fi->full_name));
up->oldpath = mfi->path;
up->olduri = mfi->uri;
@@ -529,7 +533,7 @@ rename_folders(struct _store_info *si, const char *oldbase, const char *newbase,
g_hash_table_insert(si->folders, mfi->full_name, mfi);
g_hash_table_insert(si->folders_uri, mfi->uri, mfi);
} else {
- printf("Rename found a new folder? old '%s' new '%s'\n", old, fi->full_name);
+ d(printf("Rename found a new folder? old '%s' new '%s'\n", old, fi->full_name));
/* Its a new op */
mfi = g_malloc0(sizeof(*mfi));
mfi->path = g_strdup(fi->path);
diff --git a/mail/mail-local.c b/mail/mail-local.c
index 8f43497ce4..3b601005b2 100644
--- a/mail/mail-local.c
+++ b/mail/mail-local.c
@@ -473,7 +473,6 @@ 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, mlf->real_path);*/
uri = g_strdup_printf("%s:%s", mlf->meta->format, ((CamelService *)folder->parent_store)->url->path);
d(printf("opening real store: %s\n", uri));
@@ -786,6 +785,7 @@ mls_delete_folder(CamelStore *store, const char *folder_name, CamelException *ex
if (real_store == NULL) {
g_free(metapath);
free_metainfo(meta);
+ camel_object_unref((CamelObject *)real_store);
return;
}
@@ -796,9 +796,12 @@ mls_delete_folder(CamelStore *store, const char *folder_name, CamelException *ex
camel_exception_xfer(ex, &local_ex);
g_free(metapath);
free_metainfo(meta);
+ camel_object_unref((CamelObject *)real_store);
return;
}
+ camel_object_unref((CamelObject *)real_store);
+
free_metainfo(meta);
if (unlink(metapath) == -1) {
@@ -813,46 +816,97 @@ mls_delete_folder(CamelStore *store, const char *folder_name, CamelException *ex
static void
mls_rename_folder(CamelStore *store, const char *old_name, const char *new_name, CamelException *ex)
{
+ CamelStore *real_store;
+ MailLocalStore *mls = (MailLocalStore *)store;
+ char *uri;
+ /*CamelException local_ex;*/
+ struct _local_meta *meta;
char *oldname, *newname;
+ char *oldmeta, *newmeta;
+ struct stat st;
/* folder:rename() updates all our in-memory data to match */
/* FIXME: Need to lock the subfolder that matches this if its open
Then rename it and unlock it when done */
- printf("Renaming folder from '%s' to '%s'\n", old_name, new_name);
+ d(printf("Renaming folder from '%s' to '%s'\n", old_name, new_name));
- oldname = g_strdup_printf("%s%s", ((CamelService *)store)->url->path, old_name);
- newname = g_strdup_printf("%s%s", ((CamelService *)store)->url->path, new_name);
+ oldmeta = g_strdup_printf("%s%s/local-metadata.xml", ((CamelService *)store)->url->path, old_name);
+ newmeta = g_strdup_printf("%s%s/local-metadata.xml", ((CamelService *)store)->url->path, new_name);
- if (rename(oldname, newname) == -1) {
- printf("Rename failed!\n");
- camel_exception_setv(ex, 1, "Rename failed: %s", strerror(errno));
- }
-
- g_free(oldname);
- g_free(newname);
-#if 0
- /* find the real store for this folder, and proxy the call */
- metapath = g_strdup_printf("%s%s/local-metadata.xml", ((CamelService *)store)->url->path, old_name);
- meta = load_metainfo(metapath);
- uri = g_strdup_printf("%s:%s%s", meta->format, ((CamelService *)store)->url->path);
+ meta = load_metainfo(oldmeta);
+ uri = g_strdup_printf("%s:%s", meta->format, ((CamelService *)store)->url->path);
real_store = (CamelStore *)camel_session_get_service(session, uri, CAMEL_PROVIDER_STORE, ex);
g_free(uri);
if (real_store == NULL) {
- g_free(metapath);
+ g_free(newmeta);
+ g_free(oldmeta);
free_metainfo(meta);
return;
}
- oldname = g_strdup_printf("%s/%s", old_name, mlf->meta->name);
- newname = g_strdup_printf("%s/%s", new_name, mlf->meta->name);
- camel_store_rename_folder(real_store, old_name, new_name, &local_ex);
+ oldname = g_strdup_printf("%s%s/%s", ((CamelService *)store)->url->path, old_name, meta->name);
+ newname = g_strdup_printf("%s%s/%s", ((CamelService *)store)->url->path, new_name, meta->name);
+
+ camel_store_rename_folder(real_store, oldname, newname, ex);
+ if (!camel_exception_is_set(ex)) {
+ /* If this fails? Well, doesn't really matter but 'fail' anyway */
+ if (stat(oldmeta, &st) == 0
+ && rename(oldmeta, newmeta) == -1) {
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Could not rename folder %s to %s: %s"),
+ old_name, new_name, strerror(errno));
+ } else {
+ /* So .. .the shell does a remove/add now the rename worked, so we dont
+ have to do this. However totally broken that idea might be */
+#if 0
+ CamelFolderInfo *info;
+ const char *tmp;
+ char *olduri, *newuri;
+
+ olduri = g_strdup_printf("%s:%s%s", ((CamelService *)store)->url->protocol, ((CamelService *)store)->url->path, old_name);
+ newuri = g_strdup_printf("%s:%s%s", ((CamelService *)store)->url->protocol, ((CamelService *)store)->url->path, new_name);
+ info = g_hash_table_lookup(mls->folder_infos, olduri);
+ if (info) {
+ CamelRenameInfo reninfo;
+
+ g_free(info->url);
+ g_free(info->full_name);
+ g_free(info->name);
+ g_free(info->path);
+ info->url = newuri;
+ info->full_name = g_strdup(new_name);
+ info->path = g_strdup_printf("/%s", new_name);
+ tmp = strchr(new_name, '/');
+ if (tmp == NULL)
+ tmp = new_name;
+ info->name = g_strdup(tmp);
+ g_hash_table_insert(mls->folder_infos, info->url, info);
+
+ reninfo.new = info;
+ reninfo.old_base = (char *)old_name;
+
+ camel_object_trigger_event((CamelObject *)store, "folder_renamed", &reninfo);
+ } else {
+ g_free(newuri);
+ g_warning("Cannot find existing folder '%s' in table?\n", olduri);
+ }
+
+ g_free(olduri);
+#endif
+ }
+ }
-
+ g_free(newname);
+ g_free(oldname);
- camel_exception_setv(ex, 1, "Not supported");
-#endif
+ camel_object_unref((CamelObject *)real_store);
+
+ free_metainfo(meta);
+
+ g_free(newmeta);
+ g_free(oldmeta);
}
static char *
@@ -926,7 +980,7 @@ static void mail_local_store_add_folder(MailLocalStore *mls, const char *uri, co
CamelFolderInfo *info = NULL;
CamelURL *url;
- d(printf("Shell adding folder: '%s' path = '%s'\n", uri, path));
+ (printf("Shell adding folder: '%s' path = '%s'\n", uri, path));
url = camel_url_new(uri, NULL);
if (url == NULL) {
@@ -983,6 +1037,8 @@ static void mail_local_store_remove_folder(MailLocalStore *mls, const char *path
{
struct _search_info data = { path, NULL };
+ printf("shell removing folder? '%s'\n", path);
+
/* we're keyed on uri, not path, so have to search for it manually */
LOCAL_STORE_LOCK(mls);
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 5db432a3b6..216337b4b0 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -440,7 +440,7 @@ mail_vfolder_rename_uri(CamelStore *store, const char *from, const char *to)
CamelVeeFolder *vf;
int changed = 0;
- printf("vfolder rename uri: %s to %s\n", from, to);
+ d(printf("vfolder rename uri: %s to %s\n", from, to));
if (context == NULL || !strncmp(from, "vtrash:", 7) || !strncmp(to, "vtrash:", 7))
return;
@@ -457,7 +457,7 @@ mail_vfolder_rename_uri(CamelStore *store, const char *from, const char *to)
/* Remove all sources that match, ignore changed events though
because the adduri call above does the work async */
if (uri_cmp(from, source)) {
- printf("Vfolder '%s' used '%s' ('%s') now uses '%s'\n", rule->name, source, from, to);
+ d(printf("Vfolder '%s' used '%s' ('%s') now uses '%s'\n", rule->name, source, from, to));
vf = g_hash_table_lookup(vfolder_hash, rule->name);
g_assert(vf);
gtk_signal_disconnect_by_func((GtkObject *)rule, rule_changed, vf);
@@ -502,7 +502,7 @@ rule_changed(FilterRule *rule, CamelFolder *folder)
CamelFolder *old;
LOCK();
- printf("Changing folder name in hash table to '%s'\n", rule->name);
+ d(printf("Changing folder name in hash table to '%s'\n", rule->name));
if (g_hash_table_lookup_extended(vfolder_hash, folder->full_name, (void **)&key, (void **)&old)) {
g_hash_table_remove(vfolder_hash, key);
g_free(key);
@@ -666,11 +666,11 @@ store_folder_renamed(CamelObject *o, void *event_data, void *data)
/* This should be more-or-less thread-safe */
- printf("Folder renamed to '%s' from '%s'\n", info->new->full_name, info->old_base);
+ d(printf("Folder renamed to '%s' from '%s'\n", info->new->full_name, info->old_base));
/* Folder is already renamed? */
LOCK();
- printf("Changing folder name in hash table to '%s'\n", info->new->full_name);
+ d(printf("Changing folder name in hash table to '%s'\n", info->new->full_name));
if (g_hash_table_lookup_extended(vfolder_hash, info->old_base, (void **)&key, (void **)&folder)) {
g_hash_table_remove(vfolder_hash, key);
g_free(key);