Re: Handling of delete with IMAP



On 2001.12.14 14:44 Bobby D . Bryant wrote:
> On 2001.12.14 09:47:39 -0600 M. Thielker wrote:
> 
>> On 2001.12.14 16:40 Bobby D . Bryant wrote:
> 
>>>  o select a message on my IMAP server without downloading anything
>>> to show in the viewer, and
>>> 
>> Hmmm - turn off the preview will help as a workaround
>> 
>>>  o delete selected messages on my IMAP server without downloading
>>> them to my local trashbox.
>>> 
>> There are two options: Move to trash or 'd' and Delete (ctrl-d, I
>> think). The latter will _not_ download anything since no copy is
>> saved in the trash.
> 
> Ah, thanks.  Those two together do exactly what I need.
> 
> Bobby Bryant
> Austin, Texas

   One problem arises: `Delete' immediately removes the message from 
the index, so you don't get a chance to change your mind, as you would 
if you moved the message to Trash.
   Balsa seems to have been designed with something else in mind, since 
the Message menu has an Undelete item, which currently isn't much use. 
The attached patch gives the Undelete item something to do, by leaving 
deleted messages in the index with the trashcan icon to show that 
they've been deleted.
   With this change, deleted messages stay around until the next time 
the backend is synchronized. That occurs when:
   - the mailbox is closed;
   - changes to the mailbox are Committed;
   - any message is moved out of the mailbox, to the Trash or elsewhere.
The last of these probably isn't what you'd expect, and arguably needs 
some more work. Moved messages could be left in the index, also with 
the trashcan flag, but any other change would be quite complex.
   Related minor changes:
   - to get the icon to show up correctly, some signal callbacks need to
     be called in a specific order;
   - the message selection code needs one change to avoid a ``Can't
     access message body'' error;
   - Commit Mailbox has to make sure the frontend and backend are in
     sync.

Comments or suggestions?
diff -u -r1.184 mailbox.c
--- libbalsa/mailbox.c	2001/11/25 22:42:09	1.184
+++ libbalsa/mailbox.c	2001/12/15 11:22:29
@@ -624,19 +624,19 @@
 	message = translate_message(cur);
 	message->mailbox = mailbox;
 
-	gtk_signal_connect(GTK_OBJECT(message), "clear-flags",
+	gtk_signal_connect_after(GTK_OBJECT(message), "clear-flags",
 			   GTK_SIGNAL_FUNC(message_status_changed_cb),
 			   mailbox);
-	gtk_signal_connect(GTK_OBJECT(message), "set-answered",
+	gtk_signal_connect_after(GTK_OBJECT(message), "set-answered",
 			   GTK_SIGNAL_FUNC(message_status_changed_cb),
 			   mailbox);
-	gtk_signal_connect(GTK_OBJECT(message), "set-read",
+	gtk_signal_connect_after(GTK_OBJECT(message), "set-read",
 			   GTK_SIGNAL_FUNC(message_status_changed_cb),
 			   mailbox);
-	gtk_signal_connect(GTK_OBJECT(message), "set-deleted",
+	gtk_signal_connect_after(GTK_OBJECT(message), "set-deleted",
 			   GTK_SIGNAL_FUNC(message_status_changed_cb),
 			   mailbox);
-	gtk_signal_connect(GTK_OBJECT(message), "set-flagged",
+	gtk_signal_connect_after(GTK_OBJECT(message), "set-flagged",
 			   GTK_SIGNAL_FUNC(message_status_changed_cb),
 			   mailbox);
 
@@ -742,6 +742,8 @@
 	return FALSE;
 
     LOCK_MAILBOX_RETURN_VAL(mailbox, FALSE);
+    /* remove deleted messages from frontend before committing: */
+    libbalsa_mailbox_sync_backend_real(mailbox);
     libbalsa_lock_mutt();
     index_hint = CLIENT_CONTEXT(mailbox)->vcount;
     rc = mx_sync_mailbox(CLIENT_CONTEXT(mailbox), &index_hint);
Index: src/balsa-index.c
===================================================================
RCS file: /cvs/gnome/balsa/src/balsa-index.c,v
retrieving revision 1.218
diff -u -r1.218 balsa-index.c
--- src/balsa-index.c	2001/11/25 22:42:13	1.218
+++ src/balsa-index.c	2001/12/15 11:22:31
@@ -1113,6 +1113,7 @@
                            struct BalsaIndexScanInfo *b)
 {
     GList *list;
+    LibBalsaMessage *message;
 
     for (list = b->selection; list; list = g_list_next(list)) {
         if (list->data == node) {
@@ -1128,6 +1129,9 @@
     }
 
     /* this node isn't selected */
+    message = LIBBALSA_MESSAGE(gtk_ctree_node_get_row_data(ctree, node));
+    if (message->flags & LIBBALSA_MESSAGE_FLAG_DELETED)
+        return;
 
     if (b->next == NULL)
         /* save it whether or not it's viewable */
@@ -1799,7 +1803,8 @@
 
         /* sync with backend AFTER adjacent message is selected.
          * Update the style and message counts in the mailbox list */
-        libbalsa_mailbox_sync_backend(index->mailbox_node->mailbox);
+        if (move_to_trash)
+            libbalsa_mailbox_sync_backend(index->mailbox_node->mailbox);
         balsa_mblist_update_mailbox(balsa_app.mblist,
                                     index->mailbox_node->mailbox);
         // balsa_index_redraw_current(index);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]