[libgrss] Added grss_feed_channel_set_format() and grss_feed_channel_get_format()
- From: Roberto Guido <rguido src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgrss] Added grss_feed_channel_set_format() and grss_feed_channel_get_format()
- Date: Mon, 13 Feb 2012 00:23:02 +0000 (UTC)
commit aa070ee21e2225699c0cc2aa656cebd131b90897
Author: Roberto Guido <bob4mail gmail com>
Date: Wed Dec 28 18:42:02 2011 -0800
Added grss_feed_channel_set_format() and grss_feed_channel_get_format()
doc/reference/libgrss-sections.txt | 2 ++
src/feed-atom-handler.c | 2 ++
src/feed-channel.c | 29 +++++++++++++++++++++++++++++
src/feed-channel.h | 2 ++
src/feed-pie-handler.c | 9 ++++++++-
src/feed-rss-handler.c | 2 ++
src/feeds-xoxo-group-handler.c | 1 +
7 files changed, 46 insertions(+), 1 deletions(-)
---
diff --git a/doc/reference/libgrss-sections.txt b/doc/reference/libgrss-sections.txt
index 0fc98db..44f085d 100644
--- a/doc/reference/libgrss-sections.txt
+++ b/doc/reference/libgrss-sections.txt
@@ -110,6 +110,8 @@ GrssFeedChannel
grss_feed_channel_new
grss_feed_channel_new_from_source
grss_feed_channel_new_from_file
+grss_feed_channel_set_format
+grss_feed_channel_get_format
grss_feed_channel_set_source
grss_feed_channel_get_source
grss_feed_channel_set_title
diff --git a/src/feed-atom-handler.c b/src/feed-atom-handler.c
index fdfaf04..3af51c6 100644
--- a/src/feed-atom-handler.c
+++ b/src/feed-atom-handler.c
@@ -839,6 +839,8 @@ feed_atom_handler_parse (FeedHandler *self, GrssFeedChannel *feed, xmlDocPtr doc
break;
}
+ grss_feed_channel_set_format (feed, "application/atom+xml");
+
if (items != NULL)
items = g_list_reverse (items);
return items;
diff --git a/src/feed-channel.c b/src/feed-channel.c
index 530d344..ba67807 100644
--- a/src/feed-channel.c
+++ b/src/feed-channel.c
@@ -43,6 +43,7 @@ typedef struct {
} RSSCloud;
struct _GrssFeedChannelPrivate {
+ gchar *format;
gchar *source;
gchar *title;
@@ -205,6 +206,34 @@ grss_feed_channel_new_from_file (const gchar *path)
}
/**
+ * grss_feed_channel_set_format:
+ * @channel: a #GrssFeedChannel
+ * @format: format of the file, such as "application/atom+xml" or "application/rss+xml"
+ *
+ * To assign a file format to the feed
+ */
+void
+grss_feed_channel_set_format (GrssFeedChannel *channel, gchar *format)
+{
+ FREE_STRING (channel->priv->format);
+ channel->priv->format = g_strdup (format);
+}
+
+/**
+ * grss_feed_channel_get_format:
+ * @channel: a #GrssFeedChannel
+ *
+ * Retrieves the file format of @channel
+ *
+ * Return value: file format of channel
+ */
+const gchar*
+grss_feed_channel_get_format (GrssFeedChannel *channel)
+{
+ return (const gchar*) channel->priv->format;
+}
+
+/**
* grss_feed_channel_set_source:
* @channel: a #GrssFeedChannel
* @source: URL of the feed
diff --git a/src/feed-channel.h b/src/feed-channel.h
index 4582d6b..1737e96 100644
--- a/src/feed-channel.h
+++ b/src/feed-channel.h
@@ -48,6 +48,8 @@ GrssFeedChannel* grss_feed_channel_new ();
GrssFeedChannel* grss_feed_channel_new_from_source (gchar *source);
GrssFeedChannel* grss_feed_channel_new_from_file (const gchar *path);
+void grss_feed_channel_set_format (GrssFeedChannel *channel, gchar *format);
+const gchar* grss_feed_channel_get_format (GrssFeedChannel *channel);
void grss_feed_channel_set_source (GrssFeedChannel *channel, gchar *source);
const gchar* grss_feed_channel_get_source (GrssFeedChannel *channel);
void grss_feed_channel_set_title (GrssFeedChannel *channel, gchar *title);
diff --git a/src/feed-pie-handler.c b/src/feed-pie-handler.c
index 1e32f09..a719654 100644
--- a/src/feed-pie-handler.c
+++ b/src/feed-pie-handler.c
@@ -455,7 +455,14 @@ feed_pie_handler_parse (FeedHandler *self, GrssFeedChannel *feed, xmlDocPtr doc,
break;
}
- return g_list_reverse (items);
+ /*
+ I've not found a more appropriate mimetype for PIE...
+ */
+ grss_feed_channel_set_format (feed, "application/atom+xml");
+
+ if (items != NULL)
+ items = g_list_reverse (items);
+ return items;
}
static void
diff --git a/src/feed-rss-handler.c b/src/feed-rss-handler.c
index 339db79..3e9f07f 100644
--- a/src/feed-rss-handler.c
+++ b/src/feed-rss-handler.c
@@ -528,6 +528,8 @@ feed_rss_handler_parse (FeedHandler *self, GrssFeedChannel *feed, xmlDocPtr doc,
cur = cur->next;
}
+ grss_feed_channel_set_format (feed, "application/rss+xml");
+
if (items != NULL)
items = g_list_reverse (items);
return items;
diff --git a/src/feeds-xoxo-group-handler.c b/src/feeds-xoxo-group-handler.c
index 2e43b0a..9a4f252 100644
--- a/src/feeds-xoxo-group-handler.c
+++ b/src/feeds-xoxo-group-handler.c
@@ -152,6 +152,7 @@ feeds_xoxo_group_handler_dump (GrssFeedsGroupHandler *self, GList *channels, GEr
childNode = xmlNewChild (funkyNode, NULL, BAD_CAST"li", NULL);
linkNode = xmlNewTextChild (childNode, NULL, BAD_CAST"a", BAD_CAST grss_feed_channel_get_title (channel));
xmlNewProp (linkNode, BAD_CAST"href", BAD_CAST grss_feed_channel_get_source (channel));
+ xmlNewProp (linkNode, BAD_CAST"type", BAD_CAST grss_feed_channel_get_format (channel));
}
xmlDocSetRootElement (doc, xoxoNode);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]