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




On 2001.07.10 07:30 M . Thielker wrote:
> 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.

Great! I was supposing that if you had Sentbox on IMAP, you would have
INBOX as IMAP, but your solution is much better. I did take the liberty of
cleaning up the patch a bit (using the type conversion macros instead of
direct casting and changing some nasty structure member access in my
original code) - here's the new patch.



-- 
Manuel A. McLure KE6TAW | ...for in Ulthar, according to an ancient
<manuel@mclure.org>     | and significant law, no man may kill a cat.
<http://www.mclure.org> |             -- H.P. Lovecraft
*** balsa-1.1.6/libbalsa/mailbox_imap.c	Sat Jun 23 10:47:26 2001
--- balsa-1.1.6-test/libbalsa/mailbox_imap.c	Tue Jul 10 12:37:47 2001
***************
*** 211,217 ****
      server_settings_changed(server, mailbox);
  }
  
! static void
  reset_mutt_passwords(LibBalsaServer* server)
  {
      if (ImapUser)
--- 211,217 ----
      server_settings_changed(server, mailbox);
  }
  
! void
  reset_mutt_passwords(LibBalsaServer* server)
  {
      if (ImapUser)
*** balsa-1.1.6/libbalsa/mailbox_imap.h	Sun Mar  4 11:31:33 2001
--- balsa-1.1.6-test/libbalsa/mailbox_imap.h	Tue Jul 10 12:37:47 2001
***************
*** 61,64 ****
--- 61,66 ----
  
  void libbalsa_imap_close_all_connections(void);
  
+ void reset_mutt_passwords(LibBalsaServer *);
+ 
  #endif				/* __LIBBALSA_MAILBOX_IMAP_H__ */
*** balsa-1.1.6/libbalsa/send.c	Mon Jul  9 00:35:31 2001
--- balsa-1.1.6-test/libbalsa/send.c	Tue Jul 10 12:40:11 2001
***************
*** 32,37 ****
--- 32,39 ----
  #include "libbalsa_private.h"
  
  #include "mailbackend.h"
+ #include "mailbox_imap.h"
+ #include "information.h"
  
  #ifdef BALSA_USE_THREADS
  #include "threads.h"
***************
*** 225,230 ****
--- 227,237 ----
  		       LibBalsaMailbox * fccbox, gint encoding)
  {
      MessageQueueItem *mqi;
+     LibBalsaMailboxImap *imapfccbox;
+     LibBalsaMailboxRemote *remotefccbox;
+     LibBalsaServer *server;
+     char imappath[_POSIX_PATH_MAX];
+ 
  
      g_return_if_fail(message);
  
***************
*** 236,245 ****
  	mutt_write_fcc(LIBBALSA_MAILBOX_LOCAL(outbox)->path,
  		       mqi->message, NULL, 0, NULL);
  	libbalsa_unlock_mutt();
! 	if (fccbox && LIBBALSA_IS_MAILBOX_LOCAL(fccbox)) {
  	    libbalsa_lock_mutt();
  	    mutt_write_fcc(LIBBALSA_MAILBOX_LOCAL(fccbox)->path,
  			   mqi->message, NULL, 0, NULL);
  	    libbalsa_unlock_mutt();
  	    libbalsa_mailbox_check(fccbox);
  	}
--- 243,287 ----
  	mutt_write_fcc(LIBBALSA_MAILBOX_LOCAL(outbox)->path,
  		       mqi->message, NULL, 0, NULL);
  	libbalsa_unlock_mutt();
! 	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);
+ 		remotefccbox = LIBBALSA_MAILBOX_REMOTE(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=remotefccbox->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",
+ 		    remotefccbox->server->host,
+ 		    remotefccbox->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]