Re: Patch: Handle distribution lists on alias expansion



On 2001.09.20 16:40 Brian Stafford wrote:
> On Thu, 20 September 15:36 Toralf Lund wrote:
> 
> > 1. Insert full name according to RFC-822 for each address when a
> > distribution list is found - refer to notes on code.
> 
> RFC 822 is obsolete.  The correct reference is RFC 2822.
I see.

I actually read some of the RFC now ;-) Based on the information there, I
think we can do [see attached patch] in order to display information on the
actual match. As you can see (I hope), I'm now trying to use the group
construct for distribution lists. I'm not sure I want to reveal this
information (i.e. how exactly I group addresses in my setup) to the
receivers, though, at least not in all cases, but perhaps it could
(optionally) be stripped off elsewhere?

Also, I've now introduced an inconsistency in the formatting between
addresses found by alias expansion and the ones selected in the address
book, obviously the address list code ought to be shared between the two
lookup methods (it's not my fault that it isn't, of course...)

- Toralf
Index: src/expand-alias.c
===================================================================
RCS file: /cvs/gnome/balsa/src/expand-alias.c,v
retrieving revision 1.22
diff -d -u -r1.22 expand-alias.c
--- src/expand-alias.c	2001/09/06 08:59:38	1.22
+++ src/expand-alias.c	2001/09/21 08:48:25
@@ -61,6 +61,32 @@
 	new_str = g_strdup_printf("%s <%s>", full_name, address);
     return new_str;
 }
+
+static gboolean is_mailing_list(const LibBalsaAddress *addr)
+{
+    /**** HACK: The following is valid for LDIF address books: */
+
+    return (!addr || !*addr->first_name && !*addr->last_name);
+}
+
+
+
+static LibBalsaAddress *find_address(const gchar *addr_str, 
+				     LibBalsaAddress *match_addr)
+{
+    GList *ab_list;             /* To iterate address books   */
+    LibBalsaAddressBook *ab;
+    
+    if(is_mailing_list(match_addr)) {
+	/* *** TODO: Search all address books or just the one match_addr 
+	             belongs for entries containing addr_str in address list.
+		     Return first one where !is_mailin_list(<entry>) is true */
+	return NULL;
+    }
+    
+    return match_addr;
+}
+
 	
 /*
  * expand_alias_find_match()
@@ -176,8 +202,39 @@
 	    }
 	    addr = LIBBALSA_ADDRESS(search->data);
 	}
-	output = make_rfc822(addr->full_name,
-			     (gchar *) addr->address_list->data);
+	if(is_mailing_list(addr)) {
+	    GList *addr_entry;
+	    gchar *addr_list=NULL;
+	    
+	    for(addr_entry=addr->address_list; addr_entry;
+		addr_entry=g_list_next(addr_entry)) {
+		gchar *addr_str=(gchar *) addr_entry->data;
+		LibBalsaAddress *p_addr=find_address(addr_str, addr);
+		gchar *rfc_addr;
+		
+
+		if(p_addr) 
+		    rfc_addr=make_rfc822((p_addr?p_addr->full_name:addr_str), 
+					 addr_str);
+		else
+		    rfc_addr=g_strdup(addr_str);
+		
+		if(addr_list) {
+		    gchar *old_list =  addr_list;
+		    addr_list = g_strjoin(", ", addr_list, rfc_addr, NULL);
+		    g_free(rfc_addr);
+		    g_free(old_list);
+		} else
+		    addr_list=rfc_addr;
+	    }
+	    output=g_strdup_printf("%s : %s;", addr->full_name, 
+				   (addr_list?addr_list:""));
+	    g_free(addr_list);
+	} else {
+	    output = make_rfc822(addr->full_name,
+				 (gchar *) addr->address_list->data);
+	}
+	
 	g_message("expand_alias_find_match(): Found [%s]", addr->full_name);
 	g_list_foreach(match, (GFunc)gtk_object_unref, NULL);
 	
@@ -191,5 +248,4 @@
     if (addy->match)
 	g_message("expand_alias_find_match(): Setting to [%s]", addy->match);
 }
-
 


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