evolution-rss r447 - in trunk: . src



Author: lucilanga
Date: Thu Feb 19 15:58:29 2009
New Revision: 447
URL: http://svn.gnome.org/viewvc/evolution-rss?rev=447&view=rev

Log:
2009-02-19  Lucian Langa  <lucilanga gnome org>

* src/parser.c: (update_channel) parse category of feeds

Modified:
   trunk/ChangeLog
   trunk/src/parser.c
   trunk/src/rss.c
   trunk/src/rss.h

Modified: trunk/src/parser.c
==============================================================================
--- trunk/src/parser.c	(original)
+++ trunk/src/parser.c	Thu Feb 19 15:58:29 2009
@@ -353,7 +353,6 @@
 
 /* returns node disregarding type
  */
-
 static char *
 layer_find (xmlNodePtr node, 
 	    char *match, 
@@ -376,6 +375,38 @@
 	return fail;
 }
 
+/* returns all matched nodes disregarding type
+ */
+
+static char *
+layer_find_all (xmlNodePtr node, 
+	    char *match, 
+	    char *fail)
+{
+	GList *category = NULL;
+	while (node!=NULL) {
+#ifdef RDF_DEBUG
+		xmlDebugDumpNode (stdout, node, 32);
+		printf("%s.\n", node->name);
+#endif
+		if (strcasecmp (node->name, match)==0) {
+			while (strcasecmp (node->name, match)==0) {
+				if (node->children != NULL && node->children->content != NULL) {
+					category = g_list_append(category, g_strdup(node->children->content));
+				}
+				node = node->next;
+			}
+		}
+		node = node->next;
+	}
+	if (category)
+		return category;
+	else {
+		g_list_free(category);
+		return fail;
+	}
+}
+
 //
 //namespace-based modularization
 //standard modules
@@ -898,6 +929,7 @@
 
                 char *comments = g_strdup(layer_find (top, "comments", NULL));	//RSS,
 		comments = layer_find_ns_tag(top, "wfw", "commentRss", NULL); //add slash:comments
+		GList *category = layer_find_all(top, "category", NULL);
 		char *id = layer_find (top, "id",				//ATOM
 				layer_find (top, "guid", NULL));		//RSS 2.0
 		feed = g_strdup_printf("%s\n", id ? id : link);
@@ -952,6 +984,7 @@
 		CF->comments 	= g_strdup(comments);
 		CF->feed_fname  = g_strdup(feed_name);	//feed file name
 		CF->feed_uri	= g_strdup(feed);	//feed file url
+		CF->category	= category;		//list of category feed is posted under
 		g_free(p);
 		if (q) g_free(q);
 		g_free(b);

Modified: trunk/src/rss.c
==============================================================================
--- trunk/src/rss.c	(original)
+++ trunk/src/rss.c	Thu Feb 19 15:58:29 2009
@@ -3657,6 +3657,18 @@
 	camel_medium_set_header(CAMEL_MEDIUM(new), "X-evolution-rss-feed-ID", g_strstrip(CF->feed_uri));
 	if (CF->comments)
 		camel_medium_set_header(CAMEL_MEDIUM(new), "X-evolution-rss-comments", CF->comments);
+	if (CF->category) {
+		GString *cats = g_string_new(NULL);
+		GList *p;
+		for (p = (GList *)CF->category; p != NULL; p=p->next) {
+			if (p->next)
+				g_string_append_printf(cats, "%s, ", p->data); 
+			else
+				g_string_append_printf(cats, "%s", p->data); 
+		}
+		camel_medium_set_header(CAMEL_MEDIUM(new), "X-evolution-rss-category", cats->str);
+		g_string_free(cats, FALSE);
+	}
 	rtext = camel_data_wrapper_new ();
         type = camel_content_type_new ("x-evolution", "evolution-rss-feed");
         camel_content_type_set_param (type, "format", "flowed");
@@ -3789,6 +3801,8 @@
 	g_free(CF->encl);
 	g_free(CF->feed_fname);
 	g_free(CF->feed_uri);
+	if (CF->category)
+		g_list_free(CF->category);
 	g_free(CF);
 }
 

Modified: trunk/src/rss.h
==============================================================================
--- trunk/src/rss.h	(original)
+++ trunk/src/rss.h	Thu Feb 19 15:58:29 2009
@@ -269,6 +269,7 @@
 	gchar	*feed_uri;
 	gchar *encl;
 	gchar *comments;
+	GList *category;	// list of categories article is posted under
 } create_feed;
 
 guint           upgrade = 0;                // set to 2 when initailization successfull



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