[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sylpheed
Subject:    [sylpheed:14671] NEW PATCH: Enhanced smart account selection
From:       Sylpheed Patches <sylpheed () thewildbeast ! co ! uk>
Date:       2002-06-29 15:48:40
[Download RAW message or body]

ANNOUNCING THE RELEASE OF A NEW PATCH

Patch Author: Melvin Hadasht <melvin.hadasht@free.fr>
Title:        Enhanced smart account selection
Filename:     sylpheed-0.7.8-smart-account-selection.patch (8.4 kb)
Works with:   0.7.8

Description:
This patch enhances the automatic (smart) account selection feature of sylpheed.
1. Automatic account selection now works when replying, forwarding, redirecting or reediting. When \
replying, forwarding or redirecting, the account is selected depending on the TO: header and then (if it \
fails) on the CC: header. When reediting drafts, it depends only on the FROM: header. 2. Automatic \
account selection works even when there are more than one address in the header. 3. Each automatic \
account selection (reply/forward/reedit/redirect) is independently  enabled/disabled from \
'Configuration->Common Preferences->Compose'.

Notes:
Apply patch with 'patch -p0 <sylpheed-0.7.8-smart-account-selection.patch'

--------------------------
This is an automated message from the Sylpheed Patch homepage.
<http://www.thewildbeast.co.uk/sylpheed>

If you have made a patch that you want included at the
Sylpheed Patch homepage, request details from
<sylpheed@thewildbeast.co.uk>.


["sylpheed-0.7.8-smart-account-selection.patch" (application/octet-stream)]

diff -ur ../sylpheed-0.7.8/src/account.c ../sylpheed-0.7.8.sas/src/account.c
--- ../sylpheed-0.7.8/src/account.c	Sun Jun  9 14:22:54 2002
+++ ../sylpheed-0.7.8.sas/src/account.c	Sat Jun 29 16:15:32 2002
@@ -205,7 +205,7 @@
 	for (cur = account_list; cur != NULL; cur = cur->next) {
 		ac = (PrefsAccount *)cur->data;
 		if (ac->protocol != A_NNTP && ac->address &&
-		    !g_strcasecmp(address, ac->address))
+		    strcasestr(address, ac->address))
 			return ac;
 	}
 
diff -ur ../sylpheed-0.7.8/src/compose.c ../sylpheed-0.7.8.sas/src/compose.c
--- ../sylpheed-0.7.8/src/compose.c	Sun Jun  9 14:22:54 2002
+++ ../sylpheed-0.7.8.sas/src/compose.c	Sat Jun 29 17:02:55 2002
@@ -632,6 +632,14 @@
 		extract_address(to);
 		account = account_find_from_address(to);
 	}
+	if (!account && prefs_common.reply_account_autosel) {
+		gchar cc[BUFFSIZE];
+		if (!get_header_from_msginfo(msginfo, cc, sizeof (cc), "CC:")) {
+			extract_address(cc);
+			account = account_find_from_address(cc);
+		}
+	}
+
 	if (!account) account = cur_account;
 	g_return_if_fail(account != NULL);
 
@@ -700,6 +708,19 @@
 	g_return_if_fail(msginfo->folder != NULL);
 
 	account = msginfo->folder->folder->account;
+	if (!account && msginfo->to && prefs_common.forward_account_autosel) {
+		gchar *to;
+		Xstrdup_a(to, msginfo->to, return);
+		extract_address(to);
+		account = account_find_from_address(to);
+	}
+        if (!account && prefs_common.forward_account_autosel) {
+               	gchar cc[BUFFSIZE];
+		if (!get_header_from_msginfo(msginfo, cc, sizeof (cc), "CC:")){
+		        extract_address(cc);
+		        account = account_find_from_address(cc);
+                }        
+	}
 	if (!account) account = cur_account;
 	g_return_if_fail(account != NULL);
 
@@ -791,6 +812,19 @@
 	g_return_if_fail(msginfo->folder != NULL);
 
 	account = msginfo->folder->folder->account;
+        if (!account && msginfo->to && prefs_common.redirect_account_autosel) {
+		gchar *to;
+		Xstrdup_a(to, msginfo->to, return);
+		extract_address(to);
+		account = account_find_from_address(to);
+	}
+        if(!account&& prefs_common.redirect_account_autosel) {
+               	gchar cc[BUFFSIZE];
+		if (!get_header_from_msginfo(msginfo, cc, sizeof (cc), "CC:")) {
+			extract_address(cc);
+		        account = account_find_from_address(cc);
+                }        
+	}
 	if (!account) account = cur_account;
 	g_return_if_fail(account != NULL);
 
@@ -836,6 +870,14 @@
 	g_return_if_fail(msginfo->folder != NULL);
 
 	account = msginfo->folder->folder->account;
+        if(!account&& prefs_common.reedit_account_autosel) {
+               	gchar from[BUFFSIZE];
+		if(!get_header_from_msginfo(msginfo, from, sizeof (from), 
+					"FROM:")) {
+		        extract_address(from);
+		        account = account_find_from_address(from);
+                }        
+	}
 	if (!account) account = cur_account;
 	g_return_if_fail(account != NULL);
 
diff -ur ../sylpheed-0.7.8/src/prefs_common.c ../sylpheed-0.7.8.sas/src/prefs_common.c
--- ../sylpheed-0.7.8/src/prefs_common.c	Wed May 22 15:54:32 2002
+++ ../sylpheed-0.7.8.sas/src/prefs_common.c	Sat Jun 29 17:26:45 2002
@@ -100,6 +100,9 @@
 	GtkWidget *checkbtn_wrapatsend;
 
 	GtkWidget *checkbtn_reply_account_autosel;
+	GtkWidget *checkbtn_forward_account_autosel;
+	GtkWidget *checkbtn_reedit_account_autosel;
+	GtkWidget *checkbtn_redirect_account_autosel;
 	GtkWidget *checkbtn_quote;
 } compose;
 
@@ -299,6 +302,18 @@
 	 &prefs_common.reply_account_autosel, P_BOOL,
 	 &compose.checkbtn_reply_account_autosel,
 	 prefs_set_data_from_toggle, prefs_set_toggle},
+        {"forward_account_autoselect", "TRUE",
+	 &prefs_common.forward_account_autosel, P_BOOL,
+	 &compose.checkbtn_forward_account_autosel,
+	 prefs_set_data_from_toggle, prefs_set_toggle},
+        {"reedit_account_autoselect", "TRUE",
+	 &prefs_common.reedit_account_autosel, P_BOOL,
+	 &compose.checkbtn_reedit_account_autosel,
+	 prefs_set_data_from_toggle, prefs_set_toggle},
+        {"redirect_account_autoselect", "TRUE",
+	 &prefs_common.redirect_account_autosel, P_BOOL,
+	 &compose.checkbtn_redirect_account_autosel,
+	 prefs_set_data_from_toggle, prefs_set_toggle},
 
 	{"show_ruler", "TRUE", &prefs_common.show_ruler, P_BOOL,
 	 NULL, NULL, NULL},
@@ -1129,6 +1144,7 @@
 	GtkWidget *hbox2;
 
 	GtkWidget *frame_sig;
+	GtkWidget *frame_autosel;
 	GtkWidget *checkbtn_autosig;
 	GtkWidget *label_sigsep;
 	GtkWidget *entry_sigsep;
@@ -1139,6 +1155,7 @@
 	GtkWidget *vbox3;
 	GtkWidget *hbox3;
 	GtkWidget *hbox4;
+	GtkWidget *hbox5;
 	GtkWidget *label_undolevel;
 	GtkObject *spinbtn_undolevel_adj;
 	GtkWidget *spinbtn_undolevel;
@@ -1150,6 +1167,9 @@
 
 	GtkWidget *frame_reply;
 	GtkWidget *checkbtn_reply_account_autosel;
+	GtkWidget *checkbtn_forward_account_autosel;
+	GtkWidget *checkbtn_reedit_account_autosel;
+	GtkWidget *checkbtn_redirect_account_autosel;
 	GtkWidget *checkbtn_quote;
 
 	vbox1 = gtk_vbox_new (FALSE, VSPACING);
@@ -1252,11 +1272,28 @@
 	gtk_container_add (GTK_CONTAINER (frame_reply), vbox2);
 	gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
 
+	/* Commented out by account autoselection patch 
 	PACK_CHECK_BUTTON (vbox2, checkbtn_reply_account_autosel,
-			   _("Automatically select account for replies"));
+			   _("Automatically select account for replies")); 
+	 */
 	PACK_CHECK_BUTTON (vbox2, checkbtn_quote,
 			   _("Quote message when replying"));
 
+	/* Automatic (Smart) Account Selection */
+	PACK_FRAME(vbox1, frame_autosel, _("Automatic Account Selection"));
+	hbox5 = gtk_hbox_new(FALSE, 32);
+	gtk_widget_show (hbox5);
+	gtk_container_add (GTK_CONTAINER (frame_autosel), hbox5);
+	gtk_container_set_border_width (GTK_CONTAINER (hbox5), 8);
+        PACK_CHECK_BUTTON (hbox5, checkbtn_reply_account_autosel,
+			   _("when replying"));
+	PACK_CHECK_BUTTON (hbox5, checkbtn_forward_account_autosel,
+			   _("when forwarding"));
+	PACK_CHECK_BUTTON (hbox5, checkbtn_reedit_account_autosel,
+			   _("when re-editing"));
+	PACK_CHECK_BUTTON (hbox5, checkbtn_redirect_account_autosel,
+			   _("when redirecting"));
+
 	compose.checkbtn_autosig = checkbtn_autosig;
 	compose.entry_sigsep     = entry_sigsep;
 
@@ -1273,6 +1310,12 @@
 	compose.checkbtn_quote = checkbtn_quote;
 	compose.checkbtn_reply_account_autosel =
 		checkbtn_reply_account_autosel;
+	compose.checkbtn_forward_account_autosel = 
+		checkbtn_forward_account_autosel;
+	compose.checkbtn_reedit_account_autosel = 
+		checkbtn_reedit_account_autosel;
+	compose.checkbtn_redirect_account_autosel = 
+		checkbtn_redirect_account_autosel;
 }
 
 static void prefs_quote_create(void)
diff -ur ../sylpheed-0.7.8/src/prefs_common.h ../sylpheed-0.7.8.sas/src/prefs_common.h
--- ../sylpheed-0.7.8/src/prefs_common.h	Fri May 10 17:40:35 2002
+++ ../sylpheed-0.7.8.sas/src/prefs_common.h	Sat Jun 29 17:00:33 2002
@@ -69,6 +69,9 @@
 	gboolean linewrap_at_send;
 	gboolean auto_exteditor;
 	gboolean reply_account_autosel;
+	gboolean forward_account_autosel;
+	gboolean reedit_account_autosel;
+	gboolean redirect_account_autosel;
 	gboolean show_ruler;
 
 	/* Quote */
diff -ur ../sylpheed-0.7.8/src/procheader.c ../sylpheed-0.7.8.sas/src/procheader.c
--- ../sylpheed-0.7.8/src/procheader.c	Fri May 10 17:40:35 2002
+++ ../sylpheed-0.7.8.sas/src/procheader.c	Sat Jun 29 16:04:45 2002
@@ -633,3 +633,38 @@
 	else
 		strftime(dest, len, default_format, lt);
 }
+
+gint get_header_from_msginfo(MsgInfo *msginfo, 
+			     gchar *buf, 
+			     gint len,
+			     gchar *header)
+{
+        gchar *file;
+        FILE *fp;
+        HeaderEntry hentry[] = {
+		{header,NULL,TRUE},
+		{NULL,NULL,FALSE}
+	};
+        gint val;
+
+        g_return_if_fail(msginfo != NULL);
+
+        file = procmsg_get_message_file_path(msginfo);
+
+        if ((fp = fopen(file, "r")) == NULL) {
+                FILE_OP_ERROR(file, "fopen");
+                g_free(file);
+                return;
+	}
+
+        val = procheader_get_one_field(buf, len, fp, hentry);
+
+      	if (fclose(fp) == EOF) {
+		FILE_OP_ERROR(file, "fclose");
+		unlink(file);
+		return -1;
+	}
+        if (val == -1) 
+           return -1;
+        return 0;
+}
diff -ur ../sylpheed-0.7.8/src/procheader.h ../sylpheed-0.7.8.sas/src/procheader.h
--- ../sylpheed-0.7.8/src/procheader.h	Sat May  5 07:55:58 2001
+++ ../sylpheed-0.7.8.sas/src/procheader.h	Sat Jun 29 16:06:09 2002
@@ -72,5 +72,9 @@
 void procheader_date_get_localtime	(gchar		*dest,
 					 gint		 len,
 					 const time_t	 timer);
+gint get_header_from_msginfo		(MsgInfo *msginfo,
+					 gchar *buf,
+					 gint len,
+					 gchar *header);
 
 #endif /* __PROCHEADER_H__ */


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic