filter patch
- From: Tim O'Brien <timob paradise net nz>
- To: balsa list <balsa-list gnome org>
- Subject: filter patch
- Date: Mon, 27 May 2002 05:37:00 +1200
Hi,
Just wrote a liitle function to stop an annoying
problem with filters, when a filter gets a
matche that moves a message to another mailbox
it leaves behind a deleted message that will also
get copied the next time the filter is run (even
if you have delete immediately option on) . So
you end up with a mess of duplicate messages. I
really think that the libbalsa_messages_move
function should not just copy and leave deleted
messages behind, execpt maybe for when moving to
the trash.....
This patch is against version
filter-1.3.6-1.patch that Manu posted
Seeya
diff -u -b -B ./orig/filter.c ./libbalsa/filter.c
--- ./orig/filter.c Mon May 27 04:53:46 2002
+++ ./libbalsa/filter.c Mon May 27 04:49:33 2002
@@ -378,6 +378,10 @@
/* Nothing to do */
break;
}
+
+ /* remove deleted messages from filtered mailbox */
+ libbalsa_mailbox_kill_messages(filt->matching_messages);
+
/* We unref all messages */
for (lst_messages=filt->matching_messages;lst_messages;lst_messages=g_list_next(lst_messages))
gtk_object_unref(GTK_OBJECT(lst_messages->data));
diff -u -b -B ./orig/mailbox.c ./libbalsa/mailbox.c
--- ./orig/mailbox.c Mon May 27 04:53:50 2002
+++ ./libbalsa/mailbox.c Mon May 27 04:49:38 2002
@@ -993,4 +993,49 @@
message);
}
+/* libbalsa_mailbox_kill_messages removes any deleted messages passed in the list parameter
+ * from a mailbox. and syncs front end (like sync_backend). msgs can be from any mailbox
+ * (useful for clearing filtered mail from a mailbox)
+ */
+void
+libbalsa_mailbox_kill_messages(GList* messages) {
+ LibBalsaMessage *msg;
+ GList *list;
+ GList *mbox_list;
+ LibBalsaMailbox *mbox;
+ LibBalsaMailbox *locked = 0;
+ GList *q = NULL;
+
+ /* get mailbox list items into q */
+ for(list=messages;list;list = g_list_next(list)) {
+ msg = LIBBALSA_MESSAGE(list->data);
+ if (!(msg->flags & LIBBALSA_MESSAGE_FLAG_DELETED))
+ continue;
+ mbox = msg->mailbox;
+ for(mbox_list = mbox->message_list; mbox_list; mbox_list = g_list_next(mbox_list))
+ if (list->data == mbox_list->data)
+ q = g_list_prepend(q, mbox_list);
+ }
+
+ for(list = q;list;list = g_list_next(list)) {
+ mbox_list = list->data;
+ msg = LIBBALSA_MESSAGE(mbox_list->data);
+ mbox = msg->mailbox;
+ /* Lock for each (possibly different) mailbox as needed*/
+ if (mbox != locked) {
+ if (locked)
+ UNLOCK_MAILBOX(locked);
+ g_return_val_if_fail(CLIENT_CONTEXT_OPEN(mbox), 0);
+ LOCK_MAILBOX_RETURN_VAL(mbox, 0);
+ locked = mbox;
+ }
+ gtk_signal_emit(GTK_OBJECT(mbox),libbalsa_mailbox_signals[MESSAGE_DELETE],msg);
+ msg->mailbox = NULL;
+ gtk_object_unref(GTK_OBJECT(msg));
+ mbox->message_list = g_list_remove_link(mbox->message_list,mbox_list);
+ g_list_free_1(mbox_list);
+ }
+ g_list_free(q);
+ UNLOCK_MAILBOX(locked);
+}
diff -u -b -B ./orig/mailbox.h ./libbalsa/mailbox.h
--- ./orig/mailbox.h Mon May 27 04:53:52 2002
+++ ./libbalsa/mailbox.h Mon May 27 04:49:40 2002
@@ -184,6 +184,7 @@
*/
GtkType libbalsa_mailbox_type_from_path(const gchar * filename);
gboolean libbalsa_mailbox_commit(LibBalsaMailbox* mailbox);
+void libbalsa_mailbox_kill_messages(GList* messages);
#endif /* __LIBBALSA_MAILBOX_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]