Remote server SMTP port



Patch (against CVS) that allows to specify remote SMTP server TCP port (in Preferences) follows.

Rationale:

- useful for non-standard SMTP server and/or for SSH port forwarding
- bug #26834 (wishlist) can be closed
- also fixes recently introduced bug where 'Local mail usear agent' in 'Mail Servers' tab 
  never gets active            

slon!
--- balsa/src/balsa-app.c	Mon Nov 13 09:21:59 2000
+++ balsa-test/src/balsa-app.c	Thu Nov 23 09:54:52 2000
@@ -103,6 +103,7 @@
     balsa_app.signature_path = NULL;
     balsa_app.sig_separator = TRUE;
     balsa_app.smtp_server = NULL;
+    balsa_app.smtp_port = 25;
 
     balsa_app.inbox = NULL;
     balsa_app.inbox_input = NULL;
--- balsa/src/balsa-app.h	Tue Nov 21 17:20:21 2000
+++ balsa-test/src/balsa-app.h	Thu Nov 23 10:10:14 2000
@@ -144,6 +144,7 @@
 
     gchar *local_mail_directory;
     gchar *smtp_server;
+    gint smtp_port;
 
     /* signature stuff */
     gboolean sig_sending;
--- balsa/src/main-window.c	Tue Nov 21 18:28:35 2000
+++ balsa-test/src/main-window.c	Thu Nov 23 10:12:15 2000
@@ -1111,9 +1111,7 @@
 	if(LIBBALSA_IS_MAILBOX_POP3(mailbox) && 
 	   LIBBALSA_MAILBOX_POP3(mailbox)->check) {
 	    s = LIBBALSA_MAILBOX_REMOTE_SERVER(mailbox);
-	    if (!s->passwd || (strlen(s->passwd)==0)) {
-		if(s->passwd)
-		    g_free(s->passwd);
+	    if (!s->passwd) {
 		s->passwd = libbalsa_server_get_password(s, mailbox);
 	    }
 	}
@@ -1266,7 +1264,7 @@
 send_outbox_messages_cb(GtkWidget * widget, gpointer data)
 {
     libbalsa_process_queue(balsa_app.outbox, balsa_app.encoding_style,
-			   balsa_app.smtp ? balsa_app.smtp_server : NULL);
+			   balsa_app.smtp ? balsa_app.smtp_server : NULL, balsa_app.smtp_port);
 }
 
 /* this one is called only in the threaded code */
--- balsa/src/pref-manager.c	Tue Nov 21 17:20:22 2000
+++ balsa-test/src/pref-manager.c	Thu Nov 23 10:44:56 2000
@@ -47,7 +47,7 @@
 
     GtkWidget *address_books;
 
-    GtkWidget *pop3servers, *smtp_server, *mail_directory;
+    GtkWidget *pop3servers, *smtp_server, *smtp_port, *mail_directory;
     GtkWidget *rb_local_mua, *rb_smtp_server;
     GtkRadioButton *encoding_type[NUM_ENCODING_MODES];
     GtkWidget *check_mail_auto;
@@ -338,6 +338,11 @@
     gtk_signal_connect(GTK_OBJECT(pui->smtp_server), "changed",
 		       GTK_SIGNAL_FUNC(properties_modified_cb),
 		       property_box);
+
+    gtk_signal_connect(GTK_OBJECT(pui->smtp_port), "changed",
+		       GTK_SIGNAL_FUNC(properties_modified_cb),
+		       property_box);
+
     for (i = 0; i < NUM_ENCODING_MODES; i++) {
 	gtk_signal_connect(GTK_OBJECT(pui->encoding_type[i]), "clicked",
 			   properties_modified_cb, property_box);
@@ -465,6 +470,7 @@
 {
     balsa_app.smtp = !balsa_app.smtp;
     gtk_widget_set_sensitive(pui->smtp_server, balsa_app.smtp);
+    gtk_widget_set_sensitive(pui->smtp_port, balsa_app.smtp);
 }
 
 /*
@@ -514,6 +520,9 @@
     balsa_app.smtp_server =
 	g_strdup(gtk_entry_get_text(GTK_ENTRY(pui->smtp_server)));
 
+    balsa_app.smtp_port =
+	atoi(gtk_entry_get_text(GTK_ENTRY(pui->smtp_port)));
+
     g_free(balsa_app.signature_path);
     balsa_app.signature_path =
 	g_strdup(gtk_entry_get_text(GTK_ENTRY(pui->signature)));
@@ -749,6 +758,13 @@
 	gtk_entry_set_text(GTK_ENTRY(pui->smtp_server),
 			   balsa_app.smtp_server);
 
+    if (balsa_app.smtp_port){
+	
+	char tmp[10];
+
+	sprintf(tmp, "%d", balsa_app.smtp_port);
+	gtk_entry_set_text(GTK_ENTRY(pui->smtp_port),tmp);
+    }
 
     gtk_entry_set_text(GTK_ENTRY(pui->mail_directory),
 		       balsa_app.local_mail_directory);
@@ -787,6 +803,10 @@
 			     GTK_TOGGLE_BUTTON(pui->rb_smtp_server)->
 			     active);
 
+    gtk_widget_set_sensitive(pui->smtp_port,
+			     GTK_TOGGLE_BUTTON(pui->rb_smtp_server)->
+			     active);
+
     gtk_widget_set_sensitive(pui->check_mail_minutes,
 			     GTK_TOGGLE_BUTTON(pui->check_mail_auto)->
 			     active);
@@ -1137,6 +1157,7 @@
     GtkWidget *frame3;
     GtkWidget *hbox1;
     GtkWidget *scrolledwindow3;
+    GtkWidget *label1;
     GtkWidget *label14;
     GtkWidget *label15;
     GtkWidget *vbox1;
@@ -1208,7 +1229,7 @@
 		     (GtkAttachOptions) (GTK_FILL), 0, 0);
     gtk_container_set_border_width(GTK_CONTAINER(frame5), 5);
 
-    table4 = gtk_table_new(2, 2, FALSE);
+    table4 = gtk_table_new(2, 4, FALSE);
     gtk_container_add(GTK_CONTAINER(frame5), table4);
     gtk_container_set_border_width(GTK_CONTAINER(table4), 10);
 
@@ -1218,6 +1239,17 @@
 		     (GtkAttachOptions) (0), 0, 0);
     gtk_widget_set_sensitive(pui->smtp_server, FALSE);
 
+    pui->smtp_port = gtk_entry_new();
+    gtk_table_attach(GTK_TABLE(table4), pui->smtp_port, 3, 4, 0, 1,
+		     (GtkAttachOptions) (GTK_FILL),
+		     (GtkAttachOptions) (0), 0, 0);
+    gtk_widget_set_sensitive(pui->smtp_port, FALSE);
+
+    label1 = gtk_label_new(_("Port"));
+    gtk_table_attach(GTK_TABLE(table4), label1, 2, 3, 0, 1,
+		     (GtkAttachOptions) (GTK_FILL),
+		     (GtkAttachOptions) (0), 5, 0);
+
     pui->rb_smtp_server = 
 	gtk_radio_button_new_with_label(table4_group,
 					_("Remote SMTP Server"));
@@ -1235,6 +1267,10 @@
     gtk_table_attach(GTK_TABLE(table4), pui->rb_local_mua, 0, 1, 1, 2,
 		     (GtkAttachOptions) (GTK_FILL),
 		     (GtkAttachOptions) (0), 0, 0);
+
+    /* this must be here otherwise rb_local_mua never gets active */
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->rb_local_mua),
+				 TRUE);
 
     /* fill in data */
     update_pop3_servers();
--- balsa/src/save-restore.c	Tue Nov 21 17:20:22 2000
+++ balsa-test/src/save-restore.c	Thu Nov 23 09:56:26 2000
@@ -445,6 +445,7 @@
 
     /* ... SMTP server */
     balsa_app.smtp_server = gnome_config_get_string("SMTPServer");
+    balsa_app.smtp_port = gnome_config_get_int("SMTPPort=25");
     balsa_app.smtp = gnome_config_get_bool("SMTP=false");
 
     /* ... outgoing mail */
@@ -613,6 +614,7 @@
 
     gnome_config_set_bool("SMTP", balsa_app.smtp);
     gnome_config_set_string("SMTPServer", balsa_app.smtp_server);
+    gnome_config_set_int("SMTPPort", balsa_app.smtp_port);
     gnome_config_set_int("EncodingStyle", balsa_app.encoding_style);
     gnome_config_set_bool("WordWrap", balsa_app.wordwrap);
     gnome_config_set_int("WrapLength", balsa_app.wraplength);
--- balsa/src/sendmsg-window.c	Tue Nov 21 17:20:22 2000
+++ balsa-test/src/sendmsg-window.c	Thu Nov 23 09:57:04 2000
@@ -1680,7 +1680,8 @@
 	successful = libbalsa_message_send(message, balsa_app.outbox, fcc,
 					   balsa_app.encoding_style,  
 					   balsa_app.smtp ? 
-					   balsa_app.smtp_server : NULL);
+					   balsa_app.smtp_server : NULL,
+					   balsa_app.smtp_port);
     if (successful) {
 	if (bsmsg->type == SEND_REPLY || bsmsg->type == SEND_REPLY_ALL) {
 	    if (bsmsg->orig_message)
--- balsa/libbalsa/message.h	Sun Nov 19 15:44:31 2000
+++ balsa-test/libbalsa/message.h	Thu Nov 23 09:44:00 2000
@@ -158,7 +158,8 @@
 gboolean libbalsa_message_send(LibBalsaMessage* message,
 			       LibBalsaMailbox* outbox,  
 			       LibBalsaMailbox* fccbox,
-			       gint encoding, const gchar* smtp_server);
+			       gint encoding, const gchar* smtp_server,
+			       const gint smtp_port);
 gboolean libbalsa_message_postpone(LibBalsaMessage * message,
 				   LibBalsaMailbox * draftbox,
 				   LibBalsaMessage * reply_message,
--- balsa/libbalsa/misc.h	Sun Nov 19 15:44:31 2000
+++ balsa-test/libbalsa/misc.h	Thu Nov 23 10:06:21 2000
@@ -73,7 +73,7 @@
 
 void libbalsa_set_charset(const gchar * charset);
 gboolean libbalsa_process_queue(LibBalsaMailbox* outbox, gint encoding,
-				const gchar* smtp_server);
+				const gchar* smtp_server, const gint smtp_port);
 void libbalsa_marshal_POINTER__OBJECT(GtkObject * object,
 				      GtkSignalFunc func,
 				      gpointer func_data, GtkArg * args);
--- balsa/libbalsa/send.c	Tue Nov 21 13:36:56 2000
+++ balsa-test/libbalsa/send.c	Thu Nov 23 10:09:18 2000
@@ -60,6 +60,7 @@
 static MessageQueueItem *message_queue;
 static int total_messages_left;
 static gchar * send_smtp_server;
+static int send_smtp_port;
 /* end of state variables section */
 
 
@@ -93,7 +94,7 @@
 
 static guint balsa_send_message_real(LibBalsaMailbox* outbox);
 static void encode_descriptions(BODY * b);
-static int libbalsa_smtp_send(const char *server);
+static int libbalsa_smtp_send(const char *server, int port);
 static int libbalsa_smtp_protocol(int s, char *tempfile, HEADER * msg);
 static gboolean libbalsa_create_msg(LibBalsaMessage * message,
 				    HEADER * msg, char *tempfile,
@@ -209,12 +210,12 @@
 gboolean
 libbalsa_message_send(LibBalsaMessage* message, LibBalsaMailbox* outbox,
 		      LibBalsaMailbox* fccbox, gint encoding, 
-		      const gchar* smtp_server)
+		      const gchar* smtp_server, const gint smtp_port)
 {
 
     if (message != NULL)
 	libbalsa_message_queue(message, outbox, fccbox, encoding);
-    return libbalsa_process_queue(outbox, encoding, smtp_server);
+    return libbalsa_process_queue(outbox, encoding, smtp_server, smtp_port);
 }
 
 /* libbalsa_process_queue:
@@ -225,7 +226,7 @@
 */
 gboolean 
 libbalsa_process_queue(LibBalsaMailbox* outbox, gint encoding, 
-		       const gchar* smtp_server)
+		       const gchar* smtp_server, const int smtp_port)
 {
     MessageQueueItem *mqi, *new_message;
     GList *lista;
@@ -287,6 +288,7 @@
 
     if (start_thread) {
 	g_free(send_smtp_server); send_smtp_server = g_strdup(smtp_server);
+	send_smtp_port = smtp_port;
 	pthread_create(&send_mail, NULL,
 		       (void *) &balsa_send_message_real, outbox);
 	/* Detach so we don't need to pthread_join
@@ -298,6 +300,7 @@
     pthread_mutex_unlock(&send_messages_lock);
 #else				/*non-threaded code */
     g_free(send_smtp_server); send_smtp_server = g_strdup(smtp_server);
+    send_smtp_port = smtp_port;
     balsa_send_message_real(outbox);
 #endif
     return TRUE;
@@ -366,7 +369,7 @@
 	    total_messages_left--; /* whatever the status is, one less to do*/
 	}
     } else {
-	i = libbalsa_smtp_send(send_smtp_server);
+	i = libbalsa_smtp_send(send_smtp_server, send_smtp_port);
 	
 /* We give a message to the user because an error has ocurred in the protocol
  * A mistyped address? A server not allowing relay? We can pop a window to ask
@@ -737,7 +740,7 @@
  * -2    Error during protocol 
  * 1     Everything when perfect */
 /* Does not expect the GDK lock to be held */
-static int libbalsa_smtp_send(const char *server) {
+static int libbalsa_smtp_send(const char *server, int port) {
 
     struct sockaddr_in sin;
     struct hostent *he;
@@ -747,6 +750,9 @@
 #ifdef BALSA_USE_THREADS
     SendThreadMessage *finish_message;
 #endif
+
+    if (port > 0)
+	SmtpPort=port;
 
     g_return_val_if_fail(server, -1);
     /* Here we make the conecction */


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