[libgdata] [core] Add support for <rights> to GDataFeed



commit 58da2602ea3616a6d397384d0b1bfae8eef0437a
Author: Philip Withnall <philip tecnocode co uk>
Date:   Tue Apr 6 09:35:08 2010 +0100

    [core] Add support for <rights> to GDataFeed

 docs/reference/gdata-sections.txt |    1 +
 gdata/gdata-entry.c               |    1 +
 gdata/gdata-feed.c                |   45 +++++++++++++++++++++++++++++++++++-
 gdata/gdata-feed.h                |    1 +
 gdata/gdata.symbols               |    1 +
 gdata/tests/general.c             |    7 +++++-
 6 files changed, 53 insertions(+), 3 deletions(-)
---
diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index b237d66..daedd01 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -113,6 +113,7 @@ gdata_feed_look_up_link
 gdata_feed_get_logo
 gdata_feed_get_icon
 gdata_feed_get_updated
+gdata_feed_get_rights
 gdata_feed_get_start_index
 gdata_feed_get_total_results
 gdata_feed_get_items_per_page
diff --git a/gdata/gdata-entry.c b/gdata/gdata-entry.c
index 8184df1..ddc81ee 100644
--- a/gdata/gdata-entry.c
+++ b/gdata/gdata-entry.c
@@ -219,6 +219,7 @@ gdata_entry_class_init (GDataEntryClass *klass)
 					"Inserted?", "Whether the entry has been inserted on the server.",
 					FALSE,
 					G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
 	/**
 	 * GDataEntry:rights:
 	 *
diff --git a/gdata/gdata-feed.c b/gdata/gdata-feed.c
index 7c69b46..9a6eff3 100644
--- a/gdata/gdata-feed.c
+++ b/gdata/gdata-feed.c
@@ -71,6 +71,7 @@ struct _GDataFeedPrivate {
 	guint items_per_page;
 	guint start_index;
 	guint total_results;
+	gchar *rights;
 };
 
 enum {
@@ -84,7 +85,8 @@ enum {
 	PROP_GENERATOR,
 	PROP_ITEMS_PER_PAGE,
 	PROP_START_INDEX,
-	PROP_TOTAL_RESULTS
+	PROP_TOTAL_RESULTS,
+	PROP_RIGHTS
 };
 
 G_DEFINE_TYPE (GDataFeed, gdata_feed, GDATA_TYPE_PARSABLE)
@@ -217,6 +219,22 @@ gdata_feed_class_init (GDataFeedClass *klass)
 					G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
 	/**
+	 * GDataFeed:rights:
+	 *
+	 * The ownership rights pertaining to the entire feed.
+	 *
+	 * For more information, see the <ulink type="http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.rights";>
+	 * Atom specification</ulink>.
+	 *
+	 * Since: 0.7.0
+	 **/
+	g_object_class_install_property (gobject_class, PROP_RIGHTS,
+					 g_param_spec_string ("rights",
+							      "Rights", "The ownership rights pertaining to the entire feed.",
+							      NULL,
+							      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+	/**
 	 * GDataFeed:items-per-page:
 	 *
 	 * The number of items per results page feed.
@@ -319,6 +337,7 @@ gdata_feed_finalize (GObject *object)
 	g_free (priv->etag);
 	g_free (priv->logo);
 	g_free (priv->icon);
+	g_free (priv->rights);
 
 	/* Chain up to the parent class */
 	G_OBJECT_CLASS (gdata_feed_parent_class)->finalize (object);
@@ -354,6 +373,9 @@ gdata_feed_get_property (GObject *object, guint property_id, GValue *value, GPar
 		case PROP_GENERATOR:
 			g_value_set_object (value, priv->generator);
 			break;
+		case PROP_RIGHTS:
+			g_value_set_string (value, priv->rights);
+			break;
 		case PROP_ITEMS_PER_PAGE:
 			g_value_set_uint (value, priv->items_per_page);
 			break;
@@ -431,7 +453,9 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 			                                            _gdata_feed_add_author, self, &success, error) == TRUE ||
 			   gdata_parser_object_from_element (node, "generator", P_REQUIRED | P_NO_DUPES, GDATA_TYPE_GENERATOR,
 			                                     &(self->priv->generator), &success, error) == TRUE ||
-			   gdata_parser_time_val_from_element (node, "updated", P_REQUIRED | P_NO_DUPES, &(self->priv->updated), &success, error) == TRUE) {
+			   gdata_parser_time_val_from_element (node, "updated", P_REQUIRED | P_NO_DUPES,
+			                                       &(self->priv->updated), &success, error) == TRUE ||
+			   gdata_parser_string_from_element (node, "rights", P_NONE, &(self->priv->rights), &success, error) == TRUE) {
 			return success;
 		} else {
 			return GDATA_PARSABLE_CLASS (gdata_feed_parent_class)->parse_xml (parsable, doc, node, user_data, error);
@@ -798,6 +822,23 @@ gdata_feed_get_generator (GDataFeed *self)
 }
 
 /**
+ * gdata_feed_get_rights:
+ * @self: a #GDataFeed
+ *
+ * Returns the rights pertaining to the entire feed, or %NULL if not set.
+ *
+ * Return value: the feed's rights information
+ *
+ * Since: 0.7.0
+ **/
+const gchar *
+gdata_feed_get_rights (GDataFeed *self)
+{
+	g_return_val_if_fail (GDATA_IS_FEED (self), NULL);
+	return self->priv->rights;
+}
+
+/**
  * gdata_feed_get_items_per_page:
  * @self: a #GDataFeed
  *
diff --git a/gdata/gdata-feed.h b/gdata/gdata-feed.h
index 444c635..05c8692 100644
--- a/gdata/gdata-feed.h
+++ b/gdata/gdata-feed.h
@@ -76,6 +76,7 @@ const gchar *gdata_feed_get_etag (GDataFeed *self);
 void gdata_feed_get_updated (GDataFeed *self, GTimeVal *updated);
 const gchar *gdata_feed_get_logo (GDataFeed *self);
 GDataGenerator *gdata_feed_get_generator (GDataFeed *self);
+const gchar *gdata_feed_get_rights (GDataFeed *self);
 guint gdata_feed_get_items_per_page (GDataFeed *self);
 guint gdata_feed_get_start_index (GDataFeed *self);
 guint gdata_feed_get_total_results (GDataFeed *self);
diff --git a/gdata/gdata.symbols b/gdata/gdata.symbols
index 3dd378b..0ecc4ef 100644
--- a/gdata/gdata.symbols
+++ b/gdata/gdata.symbols
@@ -37,6 +37,7 @@ gdata_feed_get_updated
 gdata_feed_get_logo
 gdata_feed_get_icon
 gdata_feed_get_generator
+gdata_feed_get_rights
 gdata_feed_get_items_per_page
 gdata_feed_get_start_index
 gdata_feed_get_total_results
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index b16ffa3..6ac91f6 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -306,7 +306,7 @@ test_feed_parse_xml (void)
 	GDataEntry *entry;
 	GDataLink *link;
 	GList *list;
-	gchar *title, *subtitle, *id, *etag, *logo, *icon;
+	gchar *title, *subtitle, *id, *etag, *logo, *icon, *rights;
 	GTimeVal *updated, updated2;
 	GDataGenerator *generator;
 	guint items_per_page, start_index, total_results;
@@ -328,6 +328,7 @@ test_feed_parse_xml (void)
 			"<link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='http://example.com/post'/>"
 			"<link rel='self' type='application/atom+xml' href='http://example.com/id'/>"
 			"<category scheme='http://example.com/categories' term='feed'/>"
+			"<rights>public</rights>"
 			"<author>"
 				"<name>Joe Smith</name>"
 				"<email>j smith example com</email>"
@@ -366,6 +367,7 @@ test_feed_parse_xml (void)
 	              "logo", &logo,
 	              "icon", &icon,
 	              "generator", &generator,
+	              "rights", &rights,
 	              "items-per-page", &items_per_page,
 	              "start-index", &start_index,
 	              "total-results", &total_results,
@@ -381,6 +383,7 @@ test_feed_parse_xml (void)
 
 	g_assert_cmpstr (logo, ==, "http://example.com/logo.png";);
 	g_assert_cmpstr (icon, ==, "http://example.com/icon.png";);
+	g_assert_cmpstr (rights, ==, "public");
 
 	g_assert (GDATA_IS_GENERATOR (generator));
 	g_assert_cmpstr (gdata_generator_get_name (generator), ==, "Example Generator");
@@ -398,6 +401,7 @@ test_feed_parse_xml (void)
 	g_free (updated);
 	g_free (logo);
 	g_free (icon);
+	g_free (rights);
 	g_object_unref (generator);
 
 	/* Check the entries */
@@ -458,6 +462,7 @@ test_feed_parse_xml (void)
 
 	g_assert_cmpstr (gdata_feed_get_logo (feed), ==, "http://example.com/logo.png";);
 	g_assert_cmpstr (gdata_feed_get_icon (feed), ==, "http://example.com/icon.png";);
+	g_assert_cmpstr (gdata_feed_get_rights (feed), ==, "public");
 
 	generator = gdata_feed_get_generator (feed);
 	g_assert (GDATA_IS_GENERATOR (generator));



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