evolution-rss r449 - in trunk: . src



Author: lucilanga
Date: Fri Feb 20 17:22:55 2009
New Revision: 449
URL: http://svn.gnome.org/viewvc/evolution-rss?rev=449&view=rev

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

* src/parser.c: (generic_finish_feed) stop parsing if feed error and
treat the error

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

Modified: trunk/TODO
==============================================================================
--- trunk/TODO	(original)
+++ trunk/TODO	Fri Feb 20 17:22:55 2009
@@ -50,3 +50,7 @@
 	* slow delete operation on large folders
 	* check operation cancel button
 	* add icon to feed setup panel
+	* add handling parser error to setup_feed (check HIG for error msg)
+	* handle slash categories
+	* add feed logo in title
+	* use ico if feed does not provide an icon

Modified: trunk/src/parser.c
==============================================================================
--- trunk/src/parser.c	(original)
+++ trunk/src/parser.c	Fri Feb 20 17:22:55 2009
@@ -21,6 +21,9 @@
 
 /************ RDF Parser *******************/
 
+guint rsserror = FALSE;
+gchar *rssstrerror = NULL;
+
 void
 html_set_base(xmlNode *doc, char *base, char *tag, char *prop, char *basehref)
 {
@@ -95,6 +98,14 @@
 }
 
 static void
+my_xml_perror_handler (void *ctx, const char *msg, ...)
+{
+	rsserror = TRUE;
+//	rssstrerror
+        g_print("!!ERROR:%s!!", msg);
+}
+
+static void
 my_xml_parser_error_handler (void *ctx, const char *msg, ...)
 {
         ;
@@ -106,6 +117,8 @@
         static xmlSAXHandler *sax;
         xmlParserCtxtPtr ctxt;
         xmlDoc *doc;
+	rsserror = FALSE;
+	rssstrerror = NULL;
 
         g_return_val_if_fail (buf != NULL, NULL);
 
@@ -118,7 +131,7 @@
   //              memcpy (sax, &xmlDefaultSAXHandler, sizeof (xmlSAXHandler));
 //#endif
                 sax->warning = my_xml_parser_error_handler;
-                sax->error = my_xml_parser_error_handler;
+                sax->error = my_xml_perror_handler;
         }
 
         if (len == -1)
@@ -458,11 +471,12 @@
 		return fail;
 }
 
-gchar *standard_rss_modules[4][3] = {
+gchar *standard_rss_modules[5][3] = {
 	{"content", "content", (gchar *)content_rss},
 	{"dublin core", "dc", (gchar *)dublin_core_rss},
 	{"syndication", "sy", (gchar *)syndication_rss},
-	{"well formed web", "wfw", (gchar *)wfw_rss}};
+	{"well formed web", "wfw", (gchar *)wfw_rss},
+	{"slashdot entities", "slash", (gchar *)dublin_core_rss}};
 
 //<nsmatch:match>content</nsmatch:match>
 static char*
@@ -476,7 +490,7 @@
 
         while (node!=NULL) {
 		if (node->ns && node->ns->prefix) {
-			for (i=0; i < 4; i++) {
+			for (i=0; i < 5; i++) {
 				if (!strcasecmp (node->ns->prefix, standard_rss_modules[i][1])) {
 					func = (gpointer)standard_rss_modules[i][2];
 					if (strcasecmp (node->ns->prefix, nsmatch) == 0
@@ -952,6 +966,7 @@
 		d(g_print("title:%s\n", p));
 		d(g_print("date:%s\n", d));
 		d(g_print("date:%s\n", d2));
+		d(g_print("body:%s\n", b));
 
 		//not very nice but prevents unnecessary long body processing
 		if (!feed_is_new(feed_name, feed)) {

Modified: trunk/src/rss.c
==============================================================================
--- trunk/src/rss.c	(original)
+++ trunk/src/rss.c	Fri Feb 20 17:22:55 2009
@@ -1763,7 +1763,8 @@
 		camel_stream_printf(fstream, 
 			"<table border=0 width=\"100%%\" cellspacing=2 cellpadding=1>");
      		camel_stream_printf(fstream,
-			"<tr><td bgcolor=\"%06x\"><b><font size=+1><a href=%s>%s</a></font></b></td></tr>", 
+			"<tr><td valign=top bgcolor=\"%06x\"><img src=/usr/share/evolution/2.24/images/rss-16.png>"
+			"<b><font size=+1><a href=%s>%s</a></font></b></td></tr>", 
 			content_colour & 0xEDECEB & 0xffffff,
 			website, subject);
 		if (category)
@@ -1771,15 +1772,10 @@
 				"<tr><td bgcolor=\"%06x\"><b><font size=-1>Posted under: %s</font></b></td></tr>", 
 				content_colour & 0xEDECEB & 0xffffff,
 				category);
-//     		camel_stream_printf (fstream, "<tr><td><table width=\"100%%\" cellpading=2 cellspaing=2><tr><td><font colour=#%06x>%s</font></td></tr></table></td></tr>", text_colour & 0xffffff, buff);
-     		camel_stream_printf (fstream, "<tr><td><font colour=#%06x>%s</font></td></tr>", text_colour & 0xffffff, buff);
+     		camel_stream_printf (fstream, "<tr><td><table width=\"100%%\" cellpading=2 cellspaing=2>"
+					"<tr><td><font colour=#%06x>%s</font></td></tr></table></td></tr>",
+					 text_colour & 0xffffff, buff);
 		if (comments) {
-//			camel_stream_printf (fstream,
-//				"<br><div style=\"border: solid #%06x 1px; background-color: #%06x; color: #%06x;\">\n",
-//				frame_colour & 0xffffff, content_colour & 0xffffff, text_colour & 0xffffff);
-//			camel_stream_printf(fstream, 
-//				"<table border=0 width=\"100%%\" cellspacing=4 cellpadding=4>");
-			//camel_stream_printf (fstream, "<tr><td bgcolor=\"%06x\"><b><font size=+1><a href=%s>Comments</font></b></td></tr>", 
 			camel_stream_printf (fstream, "<tr><td><b><font size=+1><a href=%s>Comments</font></b></td></tr>", 
 				comments);
 			if (commstream) {
@@ -1797,7 +1793,6 @@
       	camel_data_wrapper_construct_from_stream(dw, fstream);
       	camel_medium_set_content_object((CamelMedium *)part, dw);
 	em_format_format_text((EMFormat *)t->format, (CamelStream *)t->stream, (CamelDataWrapper *)part);
-//	gtk_html_select_all(t->format->message);
 	camel_object_unref(dw);
 	camel_object_unref(part);
 	camel_object_unref(fstream);
@@ -2355,7 +2350,13 @@
         r->shown = TRUE;
         xmlSubstituteEntitiesDefaultValue = 1;
         r->cache = xml_parse_sux (response->str, response->len);
-//        r->cache = xmlParseDoc (response->str);
+	if (rsserror) {
+		xmlError *err = xmlGetLastError();
+                gchar *tmsg = g_strdup_printf("\n%s\nInvalid feed: %s", user_data, err->message);
+                rss_error(user_data, NULL, _("Error while parsing feed."), tmsg);
+                g_free(tmsg);
+		goto out;
+	}
 
 	if (msg->status_code == SOUP_STATUS_CANCELLED)
 		goto out;

Modified: trunk/src/rss.h
==============================================================================
--- trunk/src/rss.h	(original)
+++ trunk/src/rss.h	Fri Feb 20 17:22:55 2009
@@ -57,6 +57,8 @@
 	guint		ttl;		//feed specified refresh interval
         /* Soup stuff */
         SoupMessage *message;
+	guint		error;		//invalid feed
+	char		*strerror;	//error msg
 } RDF;
 
 //we keep these values of a feed to be deleted in order



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