Patch: Balsa druid updates



Some updates for the init druid, now. The attached patch will:

1. Change default sender address from <name>@<hostname> to 
<name>@<domain>. What you want here is a matter of taste (and local 
configuration), but the original version was quite definitely wrong for 
me, as the host name was unqualified (i.e. it contained no domain info.)
2. Introduce full URL parsing in for for mailbox check, so that e.g. IMAP 
mailboxes may be specified directly.
3. Incomplete attempt to use IMAP mailbox as default when possible. The 
idea was to use IMAP if the server was responding and the appropriate 
user/mailbox found, but the lookup functions were never implemented 
properly.

Notes:
* Some of my other patches may be necessary to build this.
* Makefile.am was updated to get around compilation problems. Please 
revise.
* Instead of 3.) we may want a "use IMAP" toggle button that would cause 
default IMAP URL to be filled in for inbox, and possibly the other special 
mailboxes as well, or a complete folder set to be added. Or possibly a 
"server type" menu, with values "IMAP", "POP", "local spool" etc.


-- 
Toralf Lund <toralf@kscanners.com>  +47 66 85 51 22
Kongsberg Scanners AS               +47 66 85 51 00 (switchboard)
http://www.kscanners.no/~toralf     +47 66 85 51 01 (fax)
? libinit_balsa/balsa-druid-page-directory.gob.imap
? libinit_balsa/balsa-initdruid.gob.ks
Index: libinit_balsa/Makefile.am
===================================================================
RCS file: /cvs/gnome/balsa/libinit_balsa/Makefile.am,v
retrieving revision 1.23
diff -u -b -r1.23 Makefile.am
--- libinit_balsa/Makefile.am	2001/11/06 07:41:06	1.23
+++ libinit_balsa/Makefile.am	2001/11/13 09:42:34
@@ -1,4 +1,5 @@
 noinst_LIBRARIES = libinit_balsa.a
+GOB=/usr/bin/gob
 
 libinit_balsa_a_SOURCES = 		\
 	$(BUILT_SOURCES)		\
@@ -38,7 +39,8 @@
 INCLUDES=-I. -I$(top_srcdir) \
 	-I$(top_srcdir)/libmutt \
 	-I$(top_srcdir)/libbalsa \
-	-I$(top_srcdir)/src
+	-I$(top_srcdir)/src\
+	$(PCRE_CFLAGS)
 
 %.c %.h %-private.h: %.gob
-	@GOB@ $<
+	$(GOB) $<
Index: libinit_balsa/balsa-druid-page-directory.gob
===================================================================
RCS file: /cvs/gnome/balsa/libinit_balsa/balsa-druid-page-directory.gob,v
retrieving revision 1.16
diff -u -b -r1.16 balsa-druid-page-directory.gob
--- libinit_balsa/balsa-druid-page-directory.gob	2001/06/17 12:59:54	1.16
+++ libinit_balsa/balsa-druid-page-directory.gob	2001/11/13 09:42:34
@@ -45,6 +45,8 @@
 #include "save-restore.h"
 #include "balsa-druid-page-error.h"
 #include "misc.h"
+#include "mutt.h"
+#include "url.h"
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -67,6 +69,8 @@
 {
 	gchar *dup;
 	gchar *index;
+	ciss_url_t url;
+	gboolean ssl=FALSE;
 
 	if( (*error) != NULL )
 		return;
@@ -90,13 +94,44 @@
 	}
 
 	index[-1] = '/';
-	g_free ( dup );
 
-	/* The mailbox currently may not be IMAP or POP3 */
-	/* Due to the above test for a / at the start of the filename */
+	url_parse_ciss (&url, dup);
 
+	switch(url.scheme) {
+	case U_IMAPS:
+	  ssl=TRUE;
+	case U_IMAP:
+	  *box = (LibBalsaMailbox*)libbalsa_mailbox_imap_new();
+	  libbalsa_mailbox_imap_set_path((LibBalsaMailboxImap *)*box, url.path);
+	  break;
+	case U_POPS:
+	  ssl=TRUE;
+	case U_POP:
+	  *box = (LibBalsaMailbox*)libbalsa_mailbox_pop3_new();
+	  break;
+	case U_FILE:
+	  *box = (LibBalsaMailbox*)libbalsa_mailbox_local_new(url.path, TRUE);
+	  break;
+	default:
 	*box = (LibBalsaMailbox*)libbalsa_mailbox_local_new(path, TRUE);
+	}
 
+	if( url.host && LIBBALSA_IS_MAILBOX_REMOTE(*box) ) {
+	  if( !url.port )
+	    url.port = LIBBALSA_MAILBOX_REMOTE_SERVER(*box)->port;
+
+	  libbalsa_server_set_host(LIBBALSA_MAILBOX_REMOTE_SERVER(*box),
+				   url.host, url.port
+#ifdef USE_SSL
+				   , ssl
+#endif
+				   );
+	  libbalsa_server_set_username(LIBBALSA_MAILBOX_REMOTE_SERVER(*box),
+				       getenv("USER"));
+	}
+	g_free ( dup );
+	
+
 	if( *box == NULL ) {
 	  if(strcmp( "/var/spool/mail/", path )) {
 	    (*error) = g_strdup_printf( _("The mailbox \"%s\" does not appear to be valid.\n"
@@ -146,6 +181,7 @@
 		GtkLabel *label;
 		int i;
 		GtkWidget **init_widgets[NUM_EDs];
+		gchar *imap_inbox = libbalsa_guess_imap_inbox();
 		gchar *init_presets[NUM_EDs] = { NULL, NULL, NULL, NULL, NULL };
 
 		self->_priv->paths_locked = FALSE;
@@ -166,7 +202,12 @@
 			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
 			8, 4 );
 
+		if( 0 /* FIXME: libbalsa_mailbox_exists(imap_inbox) */ )
+		  init_presets[INBOX] = imap_inbox;
+		else {
+		  g_free(imap_inbox);
 		init_presets[INBOX] = libbalsa_guess_mail_spool();
+		}
 
 		init_widgets[INBOX] = &( self->_priv->inbox );
 		init_widgets[OUTBOX] = &( self->_priv->outbox );
Index: libinit_balsa/balsa-druid-page-user.gob
===================================================================
RCS file: /cvs/gnome/balsa/libinit_balsa/balsa-druid-page-user.gob,v
retrieving revision 1.13
diff -u -b -r1.13 balsa-druid-page-user.gob
--- libinit_balsa/balsa-druid-page-user.gob	2001/07/11 20:48:20	1.13
+++ libinit_balsa/balsa-druid-page-user.gob	2001/11/13 09:42:34
@@ -59,7 +59,7 @@
 	init( self ) {
 		GtkTable *table;
 		GtkLabel *label;
-		gchar *preset;
+		gchar *preset, *domain;
 		char hostbuf[512];
 
 		self->_priv->emaster.setbits = 0;
@@ -87,7 +87,13 @@
 		preset = g_get_real_name();
 		balsa_init_add_table_entry( table, 0, _("Name:"), preset, &( self->_priv->ed0 ), GTK_WIDGET( self ), &( self->_priv->name ) );
 		
+			
 		gethostname( hostbuf, 511 );
+		domain = libbalsa_get_domainname();
+		if( domain ) {
+		   preset = g_strconcat( g_get_user_name(), "@", domain, NULL );	
+		   g_free(domain);
+		} else 
 		preset = g_strconcat( g_get_user_name(), "@", hostbuf, NULL );
 		balsa_init_add_table_entry( table, 1, _("Email address:"), preset, &( self->_priv->ed1 ), GTK_WIDGET( self ), &( self->_priv->email ) );
 		g_free( preset );
Index: libinit_balsa/helper.c
===================================================================
RCS file: /cvs/gnome/balsa/libinit_balsa/helper.c,v
retrieving revision 1.4
diff -u -b -r1.4 helper.c
--- libinit_balsa/helper.c	2000/03/29 03:14:46	1.4
+++ libinit_balsa/helper.c	2001/11/13 09:42:35
@@ -31,6 +31,8 @@
 #include "helper.h"
 #include "balsa-druid-page.h"
 #include "libbalsa.h"
+#include "mutt.h"
+#include "url.h"
 
 /*
  * #ifdef BALSA_LOCAL_INSTALL
@@ -137,6 +139,10 @@
     struct stat sb;
     gchar *sofar;
     guint32 i;
+    url_scheme_t scheme=url_check_scheme(dir);
+
+    if( scheme == U_IMAP || scheme == U_POP) 
+      return FALSE;		/* *** For now */
 
     if( dir[0] != '/' ) {
 	(*complaint) = g_strdup_printf( _("The path %s must be relative to the filesystem root (start with /)."), dir );


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