Fixed: PATCH: Allow use of an IMAP mailbox as Sentbox



Here's a version of Manuel McLure's patch for IMAP sentbox.

Thanks to that patch I was able to find the relevant parts of source code.

This version will get the IMAP passwords and open the mailbox, but not read
it, if the box has hot been accessed before, so it will work in all cases.

diff -r -b -B -u ../balsa/libbalsa/mailbox_imap.c ./libbalsa/mailbox_imap.c
--- ../balsa/libbalsa/mailbox_imap.c	Tue Jun 19 22:36:25 2001
+++ ./libbalsa/mailbox_imap.c	Tue Jul 10 13:19:01 2001
@@ -211,7 +211,7 @@
     server_settings_changed(server, mailbox);
 }
 
-static void
+void
 reset_mutt_passwords(LibBalsaServer* server)
 {
     if (ImapUser)
diff -r -b -B -u ../balsa/libbalsa/mailbox_imap.h ./libbalsa/mailbox_imap.h
--- ../balsa/libbalsa/mailbox_imap.h	Sat Mar  3 22:24:26 2001
+++ ./libbalsa/mailbox_imap.h	Tue Jul 10 13:18:49 2001
@@ -61,4 +61,6 @@
 
 void libbalsa_imap_close_all_connections(void);
 
+void reset_mutt_passwords(LibBalsaServer *);
+
 #endif				/* __LIBBALSA_MAILBOX_IMAP_H__ */
diff -r -b -B -u ../balsa/libbalsa/send.c ./libbalsa/send.c
--- ../balsa/libbalsa/send.c	Wed Jun 20 10:45:01 2001
+++ ./libbalsa/send.c	Tue Jul 10 14:34:49 2001
@@ -32,6 +32,8 @@
 #include "libbalsa_private.h"
 
 #include "mailbackend.h"
+#include "mailbox_imap.h"
+#include "information.h"
 
 #ifdef BALSA_USE_THREADS
 #include "threads.h"
@@ -225,6 +227,10 @@
 		       LibBalsaMailbox * fccbox, gint encoding)
 {
     MessageQueueItem *mqi;
+    LibBalsaMailboxImap *imapfccbox;
+	LibBalsaServer *server;
+    char imappath[_POSIX_PATH_MAX];
+
 
     g_return_if_fail(message);
 
@@ -236,10 +242,44 @@
 	mutt_write_fcc(LIBBALSA_MAILBOX_LOCAL(outbox)->path,
 		       mqi->message, NULL, 0, NULL);
 	libbalsa_unlock_mutt();
-	if (fccbox && LIBBALSA_IS_MAILBOX_LOCAL(fccbox)) {
+	if (fccbox && (LIBBALSA_IS_MAILBOX_LOCAL(fccbox)
+		|| LIBBALSA_IS_MAILBOX_IMAP(fccbox))) {
 	    libbalsa_lock_mutt();
+	    if (LIBBALSA_IS_MAILBOX_LOCAL(fccbox)) {
 	    mutt_write_fcc(LIBBALSA_MAILBOX_LOCAL(fccbox)->path,
 			   mqi->message, NULL, 0, NULL);
+	    } else if (LIBBALSA_IS_MAILBOX_IMAP(fccbox)) {
+		imapfccbox = LIBBALSA_MAILBOX_IMAP(fccbox);
+		if(!CLIENT_CONTEXT_OPEN(fccbox)) /* Has not been opened */
+		{
+			/* We cannot use LIBBALSA_REMOTE_MAILBOX_SERVER() here because */
+			/* it will lock up when NO IMAP mailbox has been accessed since */
+			/* balsa was started. This should be safe because we have already */
+			/* established that fccbox is in fact an IMAP mailbox */
+			server=((LibBalsaMailboxRemote *)fccbox)->server;
+			if(server == (LibBalsaServer *)0) {
+				libbalsa_unlock_mutt();
+				libbalsa_information(LIBBALSA_INFORMATION_ERROR, "Unable to open sentbox - could not get server information");
+				return;
+			}
+			if (!(server->passwd && *server->passwd) &&
+			!(server->passwd = libbalsa_server_get_password(server, fccbox))) {
+				libbalsa_unlock_mutt();
+				libbalsa_information(LIBBALSA_INFORMATION_ERROR, "Unable to open sentbox - could not get passwords for server");
+				return;
+			}
+			reset_mutt_passwords(server);
+		}
+
+		/* Passwords are guaranteed to be set now */
+
+		snprintf(imappath, _POSIX_PATH_MAX, "{%s:%d}%s",
+		    imapfccbox->mailbox.server->host,
+		    imapfccbox->mailbox.server->port,
+		    imapfccbox->path);
+		mutt_write_fcc(imappath,
+			   mqi->message, NULL, 0, NULL);
+	    }
 	    libbalsa_unlock_mutt();
 	    libbalsa_mailbox_check(fccbox);
 	}


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