CVS: sylpheed-claws/src mainwindow.c,1.274.2.109,1.274.2.110 mainwindow.h,1.39.2.16,1.39.2.17 messageview.c,1.94.2.82,1.94.2.83 procheader.c,1.47.2.28,1.47.2.29 procmsg.c,1.150.2.61,1.150.2.62 procmsg.h,1.60.2.27,1.60.2.28 summaryview.c,1.395.2.194,1.395.2.195

Paul Mangan <[email protected]>
Newsgroups gmane.mail.sylpheed.claws.cvs
Message-ID <[email protected]>
Update of /cvsroot/sylpheed-claws/sylpheed-claws/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23355/src

Modified Files:
      Tag: gtk2
	mainwindow.c mainwindow.h messageview.c procheader.c procmsg.c 
	procmsg.h summaryview.c 
Log Message:
2006-05-08 [paul]	2.2.0cvs2

	* src/mainwindow.c
	* src/mainwindow.h
	* src/messageview.c
	* src/procheader.c
	* src/procmsg.c
	* src/procmsg.h
	* src/summaryview.c
		add Mailing List support
		based on the old 0.6.5claws25 patch by 
		Melvin Hadasht, with finishing touches
		by Colin 

Index: mainwindow.c
===================================================================
RCS file: /cvsroot/sylpheed-claws/sylpheed-claws/src/mainwindow.c,v
retrieving revision 1.274.2.109
retrieving revision 1.274.2.110
diff -u -r1.274.2.109 -r1.274.2.110
--- mainwindow.c	8 May 2006 11:57:07 -0000	1.274.2.109
+++ mainwindow.c	8 May 2006 17:13:46 -0000	1.274.2.110
@@ -445,6 +445,17 @@
 						 GtkWidget 	*widget);
 gboolean mainwindow_progressindicator_hook	(gpointer 	 source,
 						 gpointer 	 userdata);
+
+static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
+				       MsgInfo *msginfo);
+
+static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
+	
+static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
+
+static void mailing_list_compose(GtkWidget *w, gpointer *data);
+ 
+static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
 #define  SEPARATE_ACTION 500 
 static void mainwindow_quicksearch		(MainWindow 	*mainwin, 
 						 guint 		 action, 
@@ -710,6 +721,15 @@
 	{N_("/_Message/_Forward"),		"<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
 	{N_("/_Message/For_ward as attachment"),	NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
 	{N_("/_Message/Redirect"),		NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
+
+	{N_("/_Message/Mailing-_List"),			NULL, NULL, 0, "<Branch>"},
+	{N_("/_Message/Mailing-_List/Post"),		NULL, NULL, 0, "<Branch>"},
+	{N_("/_Message/Mailing-_List/Help"),		NULL, NULL, 0, "<Branch>"},
+ 	{N_("/_Message/Mailing-_List/Subscribe"),	NULL, NULL, 0, "<Branch>"},
+ 	{N_("/_Message/Mailing-_List/Unsubscribe"),	NULL, NULL, 0, "<Branch>"},
+	{N_("/_Message/Mailing-_List/View archive"),	NULL, NULL, 0, "<Branch>"},
+ 	{N_("/_Message/Mailing-_List/Contact owner"),	NULL, NULL, 0, "<Branch>"},
+ 	
 	{N_("/_Message/---"),			NULL, NULL, 0, "<Separator>"},
 	{N_("/_Message/M_ove..."),		"<control>O", move_to_cb, 0, NULL},
 	{N_("/_Message/_Copy..."),		"<shift><control>O", copy_to_cb, 0, NULL},
@@ -1054,6 +1074,9 @@
 	gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
 	ifactory = gtk_item_factory_from_widget(menubar);
 
+/*	gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
+	main_create_mailing_list_menu (mainwin, NULL); */
+
 	menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
 
 	if (prefs_common.toolbar_detachable) {
@@ -1262,6 +1285,8 @@
 	/* create actions menu */
 	main_window_update_actions_menu(mainwin);
 
+	main_create_mailing_list_menu (mainwin, NULL);
+
 	/* attach accel groups to main window */
 #define	ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win)			\
 	gtk_window_add_accel_group					\
@@ -2227,6 +2252,178 @@
 	main_window_menu_callback_unblock(mainwin);
 }
 
+void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
+{
+	GtkItemFactory *ifactory;
+	gint is_menu = 0;
+	ifactory = gtk_item_factory_from_widget(mainwin->menubar);
+	
+	if (msginfo) 
+		is_menu = mailing_list_create_submenu (ifactory, msginfo);
+	if (is_menu)
+		gtk_widget_set_sensitive (gtk_item_factory_get_item
+				(ifactory,"/Message/Mailing-List"), TRUE);
+	else
+		gtk_widget_set_sensitive (gtk_item_factory_get_item
+				(ifactory,"/Message/Mailing-List"), FALSE);
+}
+
+static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
+{
+	gint menu_nb = 0;
+	GtkWidget *menuitem;
+
+	/* Mailing list post */
+	if (msginfo && !strcmp2 (msginfo->list_post, "NO")) {
+		msginfo->list_post = g_strdup (_("No posting allowed"));
+ 	}
+ 	menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
+ 		
+ 	menu_nb += mailing_list_populate_submenu (menuitem, msginfo->list_post);
+ 
+ 	/* Mailing list help */
+	menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
+	
+	menu_nb += mailing_list_populate_submenu (menuitem, msginfo->list_help);
+
+	/* Mailing list subscribe */
+	menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
+	
+	menu_nb += mailing_list_populate_submenu (menuitem, msginfo->list_subscribe);
+		
+	/* Mailing list unsubscribe */
+	menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
+	
+	menu_nb += mailing_list_populate_submenu (menuitem, msginfo->list_unsubscribe);
+	
+	/* Mailing list view archive */
+	menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
+	
+	menu_nb += mailing_list_populate_submenu (menuitem, msginfo->list_archive);
+	
+	/* Mailing list contact owner */
+	menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
+	
+	menu_nb += mailing_list_populate_submenu (menuitem, msginfo->list_owner);
+	
+	return menu_nb;
+}
+
+static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
+{
+	GtkWidget *item, *menu;
+	const gchar *url_pt ;
+	gchar url_decoded[BUFFSIZE];
+	GList *amenu, *alist;
+	gint menu_nb = 0;
+	
+	menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
+	
+	/* First delete old submenu */
+	/* FIXME: we can optimize this, and only change/add/delete necessary items */
+	for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
+		alist = amenu->next;
+		item = GTK_WIDGET (amenu->data);
+		gtk_widget_destroy (item);
+		amenu = alist;
+	}
+	if (list_header) {
+		for (url_pt = list_header; url_pt && *url_pt;) {
+			get_url_part (&url_pt, url_decoded, BUFFSIZE);
+			item = NULL;
+			if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
+ 				item = gtk_menu_item_new_with_label ((url_decoded));
+				gtk_signal_connect (GTK_OBJECT(item), "activate",
+						GTK_SIGNAL_FUNC(mailing_list_compose), NULL);
+			}
+ 			else if (!g_strncasecmp (url_decoded, "http:", 5) ||
+				 !g_strncasecmp (url_decoded, "https:",6)) {
+
+				item = gtk_menu_item_new_with_label ((url_decoded));
+				gtk_signal_connect (GTK_OBJECT(item), "activate",
+						GTK_SIGNAL_FUNC(mailing_list_open_uri), NULL);
+			} 
+			if (item) {
+				gtk_menu_append (GTK_MENU(menu), item);
+				gtk_widget_show (item);
+				menu_nb++;
+			}
+		}
+	}
+	if (menu_nb)
+		gtk_widget_set_sensitive (menuitem, TRUE);
+	else
+		gtk_widget_set_sensitive (menuitem, FALSE);
+		
+
+	return menu_nb;
+}
+
+static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
+{
+	gchar tmp[BUFFSIZE];
+	const gchar *buf;
+	gint i = 0;
+	buf = *buffer;
+	
+	if (buf == 0x00) {
+		url_decoded = 0x00;
+		return;
+	}
+	/* Ignore spaces, comments  and tabs () */
+	for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
+		if (*buf == '(')
+			for (;*buf != ')' && *buf != 0x00; buf++);
+	
+	/* First non space and non comment must be a < */
+	if (*buf =='<' ) {
+		buf++;
+		for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
+		buf++;
+	}
+	else 
+		/* else, we finish parsing and ignore everything */
+		for (;buf != 0x00; buf++);
+	
+	tmp[i]       = 0x00;
+	*url_decoded = 0x00;
+	
+	if (i == maxlen) {
+		for (;*buf != 0x00; buf++);
+		return;
+	}
+	decode_uri (url_decoded, (const gchar *)tmp);
+
+	/* Prepare the work for the next url in the list */
+	/* after the closing bracket >, ignore space, comments and tabs */
+	for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
+		if (*buf == '(')
+			for (;*buf != ')' && *buf != 0x00; buf++);
+	/* now first non space, non comment must be a comma */
+	if (*buf != ',')
+		for (;*buf != 0x00; buf++);
+	else
+		buf++;
+	*buffer = buf;
+}
+	
+static void mailing_list_compose (GtkWidget *w, gpointer *data)
+{
+	gchar *mailto;
+
+	gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
+	compose_new(NULL, mailto+7, NULL);
+}
+ 
+ static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
+{
+ 
+ 	gchar *mailto;
+ 
+ 	gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
+ 	open_uri (mailto, prefs_common.uri_cmd);
+} 
+	
 void main_window_popup(MainWindow *mainwin)
 {
 	gtkut_window_popup(mainwin->window);

Index: mainwindow.h
===================================================================
RCS file: /cvsroot/sylpheed-claws/sylpheed-claws/src/mainwindow.h,v
retrieving revision 1.39.2.16
retrieving revision 1.39.2.17
diff -u -r1.39.2.16 -r1.39.2.17
--- mainwindow.h	10 Apr 2006 16:51:13 -0000	1.39.2.16
+++ mainwindow.h	8 May 2006 17:13:46 -0000	1.39.2.17
@@ -162,6 +162,10 @@
 GtkWidget *main_window_get_folder_window	(MainWindow	*mainwin);
 GtkWidget *main_window_get_message_window	(MainWindow	*mainwin);
 
+/* Mailing list support */
+void main_create_mailing_list_menu 	(MainWindow *mainwin, MsgInfo *msginfo);
+gint mailing_list_get_list_post_mailto 	(gchar **url, gchar *mailto, gint maxlen);
+
 void main_window_separation_change	(MainWindow	*mainwin,
 					 SeparateType	 type);
 

Index: messageview.c
===================================================================
RCS file: /cvsroot/sylpheed-claws/sylpheed-claws/src/messageview.c,v
retrieving revision 1.94.2.82
retrieving revision 1.94.2.83
diff -u -r1.94.2.82 -r1.94.2.83
--- messageview.c	16 Mar 2006 19:16:58 -0000	1.94.2.82
+++ messageview.c	8 May 2006 17:13:46 -0000	1.94.2.83
@@ -46,6 +46,7 @@
 #include "addressbook.h"
 #include "alertpanel.h"
 #include "inputdialog.h"
+#include "mainwindow.h"
 #include "manage_window.h"
 #include "procmsg.h"
 #include "procheader.h"
@@ -839,6 +840,8 @@
 
 	messageview_set_position(messageview, 0);
 
+	main_create_mailing_list_menu(messageview->mainwin, messageview->msginfo);
+
 	if (messageview->msginfo->partial_recv)
 		partial_recv_show(messageview->noticeview, 
 				  messageview->msginfo);

Index: procheader.c
===================================================================
RCS file: /cvsroot/sylpheed-claws/sylpheed-claws/src/procheader.c,v
retrieving revision 1.47.2.28
retrieving revision 1.47.2.29
diff -u -r1.47.2.28 -r1.47.2.29
--- procheader.c	26 Mar 2006 16:52:33 -0000	1.47.2.28
+++ procheader.c	8 May 2006 17:13:46 -0000	1.47.2.29
@@ -358,6 +358,12 @@
 	H_SC_PARTIALLY_RETRIEVED = 20,
 	H_SC_ACCOUNT_SERVER = 21,
 	H_SC_ACCOUNT_LOGIN = 22,
+ 	H_LIST_POST	   = 23,
+	H_LIST_SUBSCRIBE   = 24,
+ 	H_LIST_UNSUBSCRIBE = 25,
+ 	H_LIST_HELP        = 26,
+ 	H_LIST_ARCHIVE     = 27,
+ 	H_LIST_OWNER       = 28,
 };
 
 static HeaderEntry hentry_full[] = {{"Date:",		NULL, FALSE},
@@ -383,6 +389,12 @@
 				   {"SC-Partially-Retrieved:", NULL, FALSE},
 				   {"SC-Account-Server:", NULL, FALSE},
 				   {"SC-Account-Login:",NULL, FALSE},
+				   {"List-Post:",	NULL, TRUE},
+				   {"List-Subscribe:",	NULL, TRUE},
+				   {"List-Unsubscribe:",NULL, TRUE},
+				   {"List-Help:",	NULL, TRUE},
+ 				   {"List-Archive:",	NULL, TRUE},
+ 				   {"List-Owner:",	NULL, TRUE},
 				   {NULL,		NULL, FALSE}};
 
 static HeaderEntry hentry_short[] = {{"Date:",		NULL, FALSE},
@@ -609,6 +621,23 @@
 			if (msginfo->fromspace) break;
 			msginfo->fromspace = g_strdup(hp);
 			break;
+ 		case H_LIST_POST:
+			msginfo->list_post = g_strdup(hp);
+			break;
+		case H_LIST_SUBSCRIBE:
+			msginfo->list_subscribe = g_strdup(hp);
+			break;
+		case H_LIST_UNSUBSCRIBE:
+			msginfo->list_unsubscribe = g_strdup(hp);
+			break;
+		case H_LIST_HELP:
+			msginfo->list_help = g_strdup(hp);
+			break;
+		case H_LIST_ARCHIVE:
+			msginfo->list_archive = g_strdup(hp);
+			break;
+		case H_LIST_OWNER:
+			msginfo->list_owner = g_strdup(hp);
 		default:
 			break;
 		}

Index: procmsg.c
===================================================================
RCS file: /cvsroot/sylpheed-claws/sylpheed-claws/src/procmsg.c,v
retrieving revision 1.150.2.61
retrieving revision 1.150.2.62
diff -u -r1.150.2.61 -r1.150.2.62
--- procmsg.c	18 Apr 2006 16:21:10 -0000	1.150.2.61
+++ procmsg.c	8 May 2006 17:13:46 -0000	1.150.2.62
@@ -1209,6 +1209,18 @@
 
 	/* CLAWS: make sure we add the missing members; see: 
 	 * procheader.c::procheader_get_headernames() */
+	if (!msginfo->list_post)
+		msginfo->list_post = g_strdup(full_msginfo->list_post);
+	if (!msginfo->list_subscribe)
+		msginfo->list_subscribe = g_strdup(full_msginfo->list_subscribe);
+	if (!msginfo->list_unsubscribe)
+		msginfo->list_unsubscribe = g_strdup(full_msginfo->list_unsubscribe);
+	if (!msginfo->list_help)
+		msginfo->list_help = g_strdup(full_msginfo->list_help);
+	if (!msginfo->list_archive)
+		msginfo->list_archive= g_strdup(full_msginfo->list_archive);
+	if (!msginfo->list_owner)
+		msginfo->list_owner = g_strdup(full_msginfo->list_owner);
 	if (!msginfo->xface)
 		msginfo->xface = g_strdup(full_msginfo->xface);
 	if (!msginfo->face)
@@ -1266,6 +1278,13 @@
 	g_free(msginfo->inreplyto);
 	g_free(msginfo->xref);
 
+	g_free(msginfo->list_post);
+	g_free(msginfo->list_subscribe);
+	g_free(msginfo->list_unsubscribe);
+	g_free(msginfo->list_help);
+	g_free(msginfo->list_archive);
+	g_free(msginfo->list_owner);
+
 	g_free(msginfo->partial_recv);
 	g_free(msginfo->account_server);
 	g_free(msginfo->account_login);

Index: procmsg.h
===================================================================
RCS file: /cvsroot/sylpheed-claws/sylpheed-claws/src/procmsg.h,v
retrieving revision 1.60.2.27
retrieving revision 1.60.2.28
diff -u -r1.60.2.27 -r1.60.2.28
--- procmsg.h	16 Mar 2006 18:13:22 -0000	1.60.2.27
+++ procmsg.h	8 May 2006 17:13:46 -0000	1.60.2.28
@@ -218,6 +218,14 @@
 	gchar *account_server;
 	gchar *account_login;
 	gint planned_download;
+
+ 	/* Mailing list support */
+ 	gchar *list_post;
+ 	gchar *list_subscribe;
+ 	gchar *list_unsubscribe;
+ 	gchar *list_help;
+ 	gchar *list_archive;
+ 	gchar *list_owner;
 };
 
 struct _MsgFileInfo

Index: summaryview.c
===================================================================
RCS file: /cvsroot/sylpheed-claws/sylpheed-claws/src/summaryview.c,v
retrieving revision 1.395.2.194
retrieving revision 1.395.2.195
diff -u -r1.395.2.194 -r1.395.2.195
--- summaryview.c	25 Apr 2006 06:33:14 -0000	1.395.2.194
+++ summaryview.c	8 May 2006 17:13:46 -0000	1.395.2.195
@@ -751,6 +751,7 @@
 	summary_clear_list(summaryview);
 	summary_set_column_titles(summaryview);
 	summary_colorlabel_menu_create(summaryview, FALSE);
+	main_create_mailing_list_menu (summaryview->mainwin, NULL);	
 	summary_set_menu_sensitive(summaryview);
 
 }



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.