Re: Identity for Reply



On Sun, 21 Oct 2001 16:33:36 +0200, Emmanuel wrote:
> Just a few comments to clean it a bit :
>         use LIBBALSA_XXX instead of direct casts

Already using LIBBALSA_IDENTITY - what else is needed?

>         g_list_next instead of list=list->next
> 
>         nth_address = g_list_nth(addy->address_list, 0); should be replaced
> by
>         nth_address = addy->address_list;

A lot of this code was lifted directly out of libbalsa - did you
make these changes there already?  I can't seem to find the code
I copied anymore...

> if I correctly understand that you just want the first address?

Yes, in fact, there should only be one address, and that assumption
is make elsewhere in the balsa code.

Anyways, here's a new version of it - slightly cleaner, makes use
of libbalsa_address_get_mailbox() to get the e-mail addresses,
looks in the Cc: list if it can't get an address from the To: list,
looks in the From: address it it's a continuation.

-- 
Steve Wall
Index: src/sendmsg-window.c
===================================================================
RCS file: /cvs/gnome/balsa/src/sendmsg-window.c,v
retrieving revision 1.323
diff -u -p -r1.323 sendmsg-window.c
--- src/sendmsg-window.c	2001/10/21 21:33:35	1.323
+++ src/sendmsg-window.c	2001/10/23 20:54:27
@@ -2211,30 +2211,64 @@ sendmsg_window_new(GtkWidget * widget, L
     }
 
     /* Get the identity from the To: field of the previous message */
-    if (message && message->to_list && balsa_app.identities) {
-	gboolean done = FALSE;
-	GList *alist = message->to_list;
+    if (type == SEND_REPLY || type == SEND_REPLY_ALL || type == SEND_REPLY_GROUP ||
+	type == SEND_FORWARD_ATTACH || type == SEND_FORWARD_INLINE) {
+	if (message && message->to_list && balsa_app.identities) {
+	    gboolean done = FALSE;
+	    GList *alist = message->to_list;
+
+	    /*
+	    * Loop through all the addresses in the message's To:
+	    * field, and look for an identity that matches one of them.
+	    */
+	    for (;!done && alist; alist = g_list_next(alist)) {
+		GList *ilist = balsa_app.identities;
+		const gchar *address_string = libbalsa_address_get_mailbox(alist->data, 0);
+
+		for (; !done && ilist; ilist = g_list_next(ilist)) {
+		    LibBalsaIdentity *ident = LIBBALSA_IDENTITY(ilist->data);
+
+		    if (!g_strcasecmp(address_string, (gchar*)
+				      (ident->address->address_list->data))) {
+			msg->ident = ident;
+			done = TRUE;
+		    }
+		}
+	    }
+	    if (!done) {
+		/* No match in the to_list, try the cc_list */
+		alist = message->cc_list;
+		done = FALSE;
+		for (;!done && alist; alist = g_list_next(alist)) {
+		    GList *ilist = balsa_app.identities;
+		    const gchar *address_string = libbalsa_address_get_mailbox(alist->data, 0);
+
+		    for (; !done && ilist; ilist = g_list_next(ilist)) {
+			LibBalsaIdentity *ident = LIBBALSA_IDENTITY(ilist->data);
+
+			if (!g_strcasecmp(address_string, (gchar*)
+				          (ident->address->address_list->data))) {
+			    msg->ident = ident;
+			    done = TRUE;
+			}
+		    }
+		}
+	    }
+	}
+    } else if (type == SEND_CONTINUE) {
+	if (message && message->from && balsa_app.identities) {
+	    gboolean done = FALSE;
+	    GList *ilist = balsa_app.identities;
+	    const gchar *address_string = libbalsa_address_get_mailbox(message->from, 0);
+
+	    /*
+	    * Look for an identity that matches the From: address.
+	    */
+	    for (; !done && ilist; ilist = g_list_next(ilist)) {
+		LibBalsaIdentity *ident = LIBBALSA_IDENTITY(ilist->data);
 
-        /*
-         * Loop through all the addresses in the message's To:
-         * field, and look for an identity that matches one of them.
-         */
-	for (;!done && alist;alist = alist->next) {
-            LibBalsaAddress *addy;
-            GList *nth_address, *ilist;
-            gchar *address_string;
-
-	    addy = alist->data;
-	    nth_address = g_list_nth(addy->address_list, 0);
-	    address_string = (gchar*)nth_address->data;
-	    for (ilist = balsa_app.identities;
-		 !done && ilist;
-		 ilist = g_list_next(ilist)) {
-                LibBalsaIdentity* ident;
-
-		ident = LIBBALSA_IDENTITY(ilist->data);
-		if (!g_strcasecmp(address_string,
-			    (gchar*)(ident->address->address_list->data))) {
+		if (!g_strcasecmp(address_string, (gchar*)
+				  (ident->address->address_list->data))) {
 		    msg->ident = ident;
 		    done = TRUE;
 		}


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