[libgdata] Bug 614253 — GDataMediaGroup:tags should be a string array



commit 270b8bae0c238ea0b8335af8f04e4c20a505ddc1
Author: Philip Withnall <philip tecnocode co uk>
Date:   Tue Mar 30 00:44:47 2010 +0100

    Bug 614253 â?? GDataMediaGroup:tags should be a string array
    
    Convert GDataMediaGroup:tags to be a string array, which automatically
    escapes and unescapes the tags passed to it. Also convert all properties
    which proxy GDataMediaGroup:tags, which means the following API breaks:
     * GDataPicasaWebAlbum:tags and getter/setter
     * GDataPicasaWebFile:tags and getter/setter
     * GDataYouTubeVideo:keywords and getter/setter
    All these properties are now string arrays, and their getters/setters deal
    with them as such. Closes: bgo#614253

 gdata/media/gdata-media-group.c                  |   88 +++++++++++++++++++---
 gdata/media/gdata-media-group.h                  |    4 +-
 gdata/services/picasaweb/gdata-picasaweb-album.c |   20 +++---
 gdata/services/picasaweb/gdata-picasaweb-album.h |    4 +-
 gdata/services/picasaweb/gdata-picasaweb-file.c  |   20 +++---
 gdata/services/picasaweb/gdata-picasaweb-file.h  |    4 +-
 gdata/services/youtube/gdata-youtube-video.c     |   22 +++---
 gdata/services/youtube/gdata-youtube-video.h     |    4 +-
 gdata/tests/picasaweb.c                          |   23 +++++-
 9 files changed, 133 insertions(+), 56 deletions(-)
---
diff --git a/gdata/media/gdata-media-group.c b/gdata/media/gdata-media-group.c
index 0f741ae..0a07247 100644
--- a/gdata/media/gdata-media-group.c
+++ b/gdata/media/gdata-media-group.c
@@ -52,7 +52,7 @@ static void get_xml (GDataParsable *parsable, GString *xml_string);
 static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
 
 struct _GDataMediaGroupPrivate {
-	gchar *keywords;
+	gchar **keywords;
 	gchar *player_uri;
 	GHashTable *restricted_countries;
 	GList *thumbnails; /* GDataMediaThumbnail */
@@ -124,7 +124,7 @@ gdata_media_group_finalize (GObject *object)
 {
 	GDataMediaGroupPrivate *priv = GDATA_MEDIA_GROUP (object)->priv;
 
-	g_free (priv->keywords);
+	g_strfreev (priv->keywords);
 	g_free (priv->player_uri);
 	g_hash_table_destroy (priv->restricted_countries);
 	g_free (priv->title);
@@ -143,7 +143,6 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 	if (gdata_parser_is_namespace (node, "http://search.yahoo.com/mrss/";) == TRUE) {
 		if (gdata_parser_string_from_element (node, "title", P_NONE, &(self->priv->title), &success, error) == TRUE ||
 		    gdata_parser_string_from_element (node, "description", P_NONE, &(self->priv->description), &success, error) == TRUE ||
-		    gdata_parser_string_from_element (node, "keywords", P_NONE, &(self->priv->keywords), &success, error) == TRUE ||
 		    gdata_parser_object_from_element_setter (node, "category", P_REQUIRED, GDATA_TYPE_MEDIA_CATEGORY,
 			                                     gdata_media_group_set_category, self, &success, error) == TRUE ||
 		    gdata_parser_object_from_element_setter (node, "content", P_REQUIRED, GDATA_TYPE_MEDIA_CONTENT,
@@ -153,6 +152,40 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 		    gdata_parser_object_from_element (node, "credit", P_REQUIRED | P_NO_DUPES, GDATA_TYPE_MEDIA_CREDIT,
 			                              &(self->priv->credit), &success, error) == TRUE) {
 			return success;
+		} else if (xmlStrcmp (node->name, (xmlChar*) "keywords") == 0) {
+			/* media:keywords */
+			guint i;
+			xmlChar *text = xmlNodeListGetString (node->doc, node->children, TRUE);
+
+			g_strfreev (self->priv->keywords);
+			if (text == NULL) {
+				self->priv->keywords = NULL;
+				return TRUE;
+			}
+
+			self->priv->keywords = g_strsplit ((gchar*) text, ",", -1);
+
+			for (i = 0; self->priv->keywords[i] != NULL; i++) {
+				gchar *comma, *start = self->priv->keywords[i];
+				gchar *end = start + strlen (start);
+
+				/* Strip any whitespace from the ends of the keyword */
+				g_strstrip (start);
+
+				/* Unescape any %2Cs in the keyword to commas in-place */
+				while ((comma = g_strstr_len (start, -1, "%2C")) != NULL) {
+					/* Unescape the comma */
+					*comma = ',';
+
+					/* Move forwards, skipping the comma */
+					comma++;
+					end -= 2;
+
+					/* Shift the remainder of the string downwards */
+					g_memmove (comma, comma + 2, end - comma);
+					*end = '\0';
+				}
+			}
 		} else if (xmlStrcmp (node->name, (xmlChar*) "player") == 0) {
 			/* media:player */
 			xmlChar *player_uri = xmlGetProp (node, (xmlChar*) "url");
@@ -234,8 +267,39 @@ get_xml (GDataParsable *parsable, GString *xml_string)
 	if (priv->description != NULL)
 		gdata_parser_string_append_escaped (xml_string, "<media:description type='plain'>", priv->description, "</media:description>");
 
-	if (priv->keywords != NULL)
-		gdata_parser_string_append_escaped (xml_string, "<media:keywords>", priv->keywords, "</media:keywords>");
+	if (priv->keywords != NULL) {
+		guint i;
+
+		g_string_append (xml_string, "<media:keywords>");
+
+		/* Add each keyword to the text content, comma-separated from the previous one */
+		for (i = 0; priv->keywords[i] != NULL; i++) {
+			const gchar *comma, *start = priv->keywords[i];
+
+			/* Delimit the previous keyword */
+			if (i != 0)
+				g_string_append_c (xml_string, ',');
+
+			/* Escape any commas in the keyword to %2C */
+			while ((comma = g_utf8_strchr (start, -1, ',')) != NULL) {
+				/* Copy the span */
+				gchar *span = g_strndup (start, comma - start);
+				g_string_append (xml_string, span);
+				g_free (span);
+
+				/* Add an escaped comma */
+				g_string_append (xml_string, "%2C");
+
+				/* Move forwards, skipping the comma */
+				start = comma + 1;
+			}
+
+			/* Append the rest of the string (the entire string if there were no commas) */
+			g_string_append (xml_string, start);
+		}
+
+		g_string_append (xml_string, "</media:keywords>");
+	}
 }
 
 static void
@@ -322,21 +386,21 @@ gdata_media_group_set_description (GDataMediaGroup *self, const gchar *descripti
  *
  * Gets the #GDataMediaGroup:keywords property.
  *
- * Return value: the group's keywords, or %NULL
+ * Return value: a %NULL-terminated array of the group's keywords, or %NULL
  *
  * Since: 0.4.0
  **/
-const gchar *
+const gchar * const *
 gdata_media_group_get_keywords (GDataMediaGroup *self)
 {
 	g_return_val_if_fail (GDATA_IS_MEDIA_GROUP (self), NULL);
-	return self->priv->keywords;
+	return (const gchar * const *) self->priv->keywords;
 }
 
 /**
  * gdata_media_group_set_keywords:
  * @self: a #GDataMediaGroup
- * @keywords: the group's new keywords, or %NULL
+ * @keywords: a %NULL-terminated array of the group's new keywords, or %NULL
  *
  * Sets the #GDataMediaGroup:keywords property to @keywords.
  *
@@ -345,11 +409,11 @@ gdata_media_group_get_keywords (GDataMediaGroup *self)
  * Since: 0.4.0
  **/
 void
-gdata_media_group_set_keywords (GDataMediaGroup *self, const gchar *keywords)
+gdata_media_group_set_keywords (GDataMediaGroup *self, const gchar * const *keywords)
 {
 	g_return_if_fail (GDATA_IS_MEDIA_GROUP (self));
-	g_free (self->priv->keywords);
-	self->priv->keywords = g_strdup (keywords);
+	g_strfreev (self->priv->keywords);
+	self->priv->keywords = g_strdupv ((gchar**) keywords);
 }
 
 /**
diff --git a/gdata/media/gdata-media-group.h b/gdata/media/gdata-media-group.h
index c6e69bc..a656213 100644
--- a/gdata/media/gdata-media-group.h
+++ b/gdata/media/gdata-media-group.h
@@ -68,8 +68,8 @@ const gchar *gdata_media_group_get_title (GDataMediaGroup *self);
 void gdata_media_group_set_title (GDataMediaGroup *self, const gchar *title);
 const gchar *gdata_media_group_get_description (GDataMediaGroup *self);
 void gdata_media_group_set_description (GDataMediaGroup *self, const gchar *description);
-const gchar *gdata_media_group_get_keywords (GDataMediaGroup *self);
-void gdata_media_group_set_keywords (GDataMediaGroup *self, const gchar *keywords);
+const gchar * const *gdata_media_group_get_keywords (GDataMediaGroup *self);
+void gdata_media_group_set_keywords (GDataMediaGroup *self, const gchar * const *keywords);
 GDataMediaCategory *gdata_media_group_get_category (GDataMediaGroup *self);
 void gdata_media_group_set_category (GDataMediaGroup *self, GDataMediaCategory *category);
 GDataMediaContent *gdata_media_group_look_up_content (GDataMediaGroup *self, const gchar *type);
diff --git a/gdata/services/picasaweb/gdata-picasaweb-album.c b/gdata/services/picasaweb/gdata-picasaweb-album.c
index fcef179..0e808a5 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-album.c
+++ b/gdata/services/picasaweb/gdata-picasaweb-album.c
@@ -314,7 +314,7 @@ gdata_picasaweb_album_class_init (GDataPicasaWebAlbumClass *klass)
 	/**
 	 * GDataPicasaWebAlbum:tags:
 	 *
-	 * A comma-separated list of tags associated with the album; all the tags associated with the individual photos in the album.
+	 * A %NULL-terminated array of tags associated with the album; all the tags associated with the individual photos in the album.
 	 *
 	 * For more information, see the <ulink type="http" url="http://code.google.com/apis/picasaweb/reference.html#media_keywords";>
 	 * Media RSS specification</ulink>.
@@ -322,9 +322,9 @@ gdata_picasaweb_album_class_init (GDataPicasaWebAlbumClass *klass)
 	 * Since: 0.4.0
 	 **/
 	g_object_class_install_property (gobject_class, PROP_TAGS,
-					 g_param_spec_string ("tags",
-							      "Tags", "A comma-separated list of tags associated with the album",
-							      NULL,
+					 g_param_spec_boxed ("tags",
+							      "Tags", "A NULL-terminated array of tags associated with the album",
+							      G_TYPE_STRV,
 							      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
 	/**
@@ -514,7 +514,7 @@ gdata_picasaweb_album_get_property (GObject *object, guint property_id, GValue *
 			g_value_set_uint (value, priv->comment_count);
 			break;
 		case PROP_TAGS:
-			g_value_set_string (value, gdata_media_group_get_keywords (priv->media_group));
+			g_value_set_boxed (value, gdata_media_group_get_keywords (priv->media_group));
 			break;
 		case PROP_LATITUDE:
 			g_value_set_double (value, gdata_georss_where_get_latitude (priv->georss_where));
@@ -553,7 +553,7 @@ gdata_picasaweb_album_set_property (GObject *object, guint property_id, const GV
 			gdata_picasaweb_album_set_is_commenting_enabled (self, g_value_get_boolean (value));
 			break;
 		case PROP_TAGS:
-			gdata_picasaweb_album_set_tags (self, g_value_get_string (value));
+			gdata_picasaweb_album_set_tags (self, g_value_get_boxed (value));
 			break;
 		case PROP_LATITUDE:
 			gdata_picasaweb_album_set_coordinates (self, g_value_get_double (value),
@@ -1087,11 +1087,11 @@ gdata_picasaweb_album_get_comment_count (GDataPicasaWebAlbum *self)
  *
  * Gets the #GDataPicasaWebAlbum:tags property.
  *
- * Return value: a comma-separated list of tags associated with all the photos in the album, or %NULL
+ * Return value: a %NULL-terminated array of tags associated with all the photos in the album, or %NULL
  *
  * Since: 0.4.0
  **/
-const gchar *
+const gchar * const *
 gdata_picasaweb_album_get_tags (GDataPicasaWebAlbum *self)
 {
 	g_return_val_if_fail (GDATA_IS_PICASAWEB_ALBUM (self), NULL);
@@ -1101,7 +1101,7 @@ gdata_picasaweb_album_get_tags (GDataPicasaWebAlbum *self)
 /**
  * gdata_picasaweb_album_set_tags:
  * @self: a #GDataPicasaWebAlbum
- * @tags: the new comma-separated list of tags, or %NULL
+ * @tags: the new %NULL-terminated array of tags, or %NULL
  *
  * Sets the #GDataPicasaWebAlbum:tags property to @tags.
  *
@@ -1110,7 +1110,7 @@ gdata_picasaweb_album_get_tags (GDataPicasaWebAlbum *self)
  * Since: 0.4.0
  **/
 void
-gdata_picasaweb_album_set_tags (GDataPicasaWebAlbum *self, const gchar *tags)
+gdata_picasaweb_album_set_tags (GDataPicasaWebAlbum *self, const gchar * const *tags)
 {
 	g_return_if_fail (GDATA_IS_PICASAWEB_ALBUM (self));
 
diff --git a/gdata/services/picasaweb/gdata-picasaweb-album.h b/gdata/services/picasaweb/gdata-picasaweb-album.h
index 8c4bcd5..276f6f5 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-album.h
+++ b/gdata/services/picasaweb/gdata-picasaweb-album.h
@@ -96,8 +96,8 @@ glong gdata_picasaweb_album_get_bytes_used (GDataPicasaWebAlbum *self);
 gboolean gdata_picasaweb_album_is_commenting_enabled (GDataPicasaWebAlbum *self);
 void gdata_picasaweb_album_set_is_commenting_enabled (GDataPicasaWebAlbum *self, gboolean is_commenting_enabled);
 guint gdata_picasaweb_album_get_comment_count (GDataPicasaWebAlbum *self);
-const gchar *gdata_picasaweb_album_get_tags (GDataPicasaWebAlbum *self);
-void gdata_picasaweb_album_set_tags (GDataPicasaWebAlbum *self, const gchar *tags);
+const gchar * const *gdata_picasaweb_album_get_tags (GDataPicasaWebAlbum *self);
+void gdata_picasaweb_album_set_tags (GDataPicasaWebAlbum *self, const gchar * const *tags);
 GList *gdata_picasaweb_album_get_contents (GDataPicasaWebAlbum *self);
 GList *gdata_picasaweb_album_get_thumbnails (GDataPicasaWebAlbum *self);
 void gdata_picasaweb_album_get_coordinates (GDataPicasaWebAlbum *self, gdouble *latitude, gdouble *longitude);
diff --git a/gdata/services/picasaweb/gdata-picasaweb-file.c b/gdata/services/picasaweb/gdata-picasaweb-file.c
index fad748b..a7db304 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-file.c
+++ b/gdata/services/picasaweb/gdata-picasaweb-file.c
@@ -395,7 +395,7 @@ gdata_picasaweb_file_class_init (GDataPicasaWebFileClass *klass)
 	/**
 	 * GDataPicasaWebFile:tags:
 	 *
-	 * A comma-separated list of tags associated with the file.
+	 * A %NULL-terminated array of tags associated with the file.
 	 *
 	 * For more information, see the <ulink type="http" url="http://code.google.com/apis/picasaweb/reference.html#media_keywords";>
 	 * Media RSS specification</ulink>.
@@ -403,9 +403,9 @@ gdata_picasaweb_file_class_init (GDataPicasaWebFileClass *klass)
 	 * Since: 0.4.0
 	 **/
 	g_object_class_install_property (gobject_class, PROP_TAGS,
-					 g_param_spec_string ("tags",
-							      "Tags", "A comma-separated list of tags associated with the file.",
-							      NULL,
+					 g_param_spec_boxed ("tags",
+							      "Tags", "A NULL-terminated array of tags associated with the file.",
+							      G_TYPE_STRV,
 							      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
 	/**
@@ -714,7 +714,7 @@ gdata_picasaweb_file_get_property (GObject *object, guint property_id, GValue *v
 			g_value_set_string (value, gdata_entry_get_summary (GDATA_ENTRY (object)));
 			break;
 		case PROP_TAGS:
-			g_value_set_string (value, gdata_media_group_get_keywords (priv->media_group));
+			g_value_set_boxed (value, gdata_media_group_get_keywords (priv->media_group));
 			break;
 		case PROP_DISTANCE:
 			g_value_set_double (value, gdata_exif_tags_get_distance (priv->exif_tags));
@@ -798,7 +798,7 @@ gdata_picasaweb_file_set_property (GObject *object, guint property_id, const GVa
 			gdata_picasaweb_file_set_caption (self, g_value_get_string (value));
 			break;
 		case PROP_TAGS:
-			gdata_picasaweb_file_set_tags (self, g_value_get_string (value));
+			gdata_picasaweb_file_set_tags (self, g_value_get_boxed (value));
 			break;
 		case PROP_LATITUDE:
 			gdata_picasaweb_file_set_coordinates (self, g_value_get_double (value),
@@ -1435,11 +1435,11 @@ gdata_picasaweb_file_get_video_status (GDataPicasaWebFile *self)
  *
  * Gets the #GDataPicasaWebFile:tags property.
  *
- * Return value: a comma-separated list of tags associated with the file, or %NULL
+ * Return value: a %NULL-terminated array of tags associated with the file, or %NULL
  *
  * Since: 0.4.0
  **/
-const gchar *
+const gchar * const *
 gdata_picasaweb_file_get_tags (GDataPicasaWebFile *self)
 {
 	g_return_val_if_fail (GDATA_IS_PICASAWEB_FILE (self), NULL);
@@ -1449,7 +1449,7 @@ gdata_picasaweb_file_get_tags (GDataPicasaWebFile *self)
 /**
  * gdata_picasaweb_file_set_tags:
  * @self: a #GDataPicasaWebFile
- * @tags: a new comma-separated list of tags, or %NULL
+ * @tags: a new %NULL-terminated array of tags, or %NULL
  *
  * Sets the #GDataPicasaWebFile:tags property to @tags.
  *
@@ -1458,7 +1458,7 @@ gdata_picasaweb_file_get_tags (GDataPicasaWebFile *self)
  * Since: 0.4.0
  **/
 void
-gdata_picasaweb_file_set_tags (GDataPicasaWebFile *self, const gchar *tags)
+gdata_picasaweb_file_set_tags (GDataPicasaWebFile *self, const gchar * const *tags)
 {
 	g_return_if_fail (GDATA_IS_PICASAWEB_FILE (self));
 
diff --git a/gdata/services/picasaweb/gdata-picasaweb-file.h b/gdata/services/picasaweb/gdata-picasaweb-file.h
index 9fb9f82..1942f36 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-file.h
+++ b/gdata/services/picasaweb/gdata-picasaweb-file.h
@@ -124,8 +124,8 @@ guint gdata_picasaweb_file_get_comment_count (GDataPicasaWebFile *self);
 guint gdata_picasaweb_file_get_rotation (GDataPicasaWebFile *self);
 void gdata_picasaweb_file_set_rotation (GDataPicasaWebFile *self, guint rotation);
 const gchar *gdata_picasaweb_file_get_video_status (GDataPicasaWebFile *self);
-const gchar *gdata_picasaweb_file_get_tags (GDataPicasaWebFile *self);
-void gdata_picasaweb_file_set_tags (GDataPicasaWebFile *self, const gchar *tags);
+const gchar * const *gdata_picasaweb_file_get_tags (GDataPicasaWebFile *self);
+void gdata_picasaweb_file_set_tags (GDataPicasaWebFile *self, const gchar * const *tags);
 const gchar *gdata_picasaweb_file_get_credit (GDataPicasaWebFile *self);
 const gchar *gdata_picasaweb_file_get_caption (GDataPicasaWebFile *self);
 void gdata_picasaweb_file_set_caption (GDataPicasaWebFile *self, const gchar *caption);
diff --git a/gdata/services/youtube/gdata-youtube-video.c b/gdata/services/youtube/gdata-youtube-video.c
index df6f930..e436e49 100644
--- a/gdata/services/youtube/gdata-youtube-video.c
+++ b/gdata/services/youtube/gdata-youtube-video.c
@@ -254,15 +254,15 @@ gdata_youtube_video_class_init (GDataYouTubeVideoClass *klass)
 	/**
 	 * GDataYouTubeVideo:keywords:
 	 *
-	 * A comma-separated list of words associated with the video.
+	 * A %NULL-terminated array of words associated with the video.
 	 *
 	 * For more information, see the <ulink type="http"
 	 * url="http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_media:keywords";>online documentation</ulink>.
 	 **/
 	g_object_class_install_property (gobject_class, PROP_KEYWORDS,
-				g_param_spec_string ("keywords",
-					"Keywords", "A comma-separated list of words associated with the video.",
-					NULL,
+				g_param_spec_boxed ("keywords",
+					"Keywords", "A NULL-terminated array of words associated with the video.",
+					G_TYPE_STRV,
 					G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
 	/**
@@ -518,7 +518,7 @@ gdata_youtube_video_get_property (GObject *object, guint property_id, GValue *va
 			g_value_set_double (value, priv->rating.average);
 			break;
 		case PROP_KEYWORDS:
-			g_value_set_string (value, gdata_media_group_get_keywords (priv->media_group));
+			g_value_set_boxed (value, gdata_media_group_get_keywords (priv->media_group));
 			break;
 		case PROP_PLAYER_URI:
 			g_value_set_string (value, gdata_media_group_get_player_uri (priv->media_group));
@@ -575,7 +575,7 @@ gdata_youtube_video_set_property (GObject *object, guint property_id, const GVal
 			gdata_youtube_video_set_location (self, g_value_get_string (value));
 			break;
 		case PROP_KEYWORDS:
-			gdata_youtube_video_set_keywords (self, g_value_get_string (value));
+			gdata_youtube_video_set_keywords (self, g_value_get_boxed (value));
 			break;
 		case PROP_CATEGORY:
 			gdata_youtube_video_set_category (self, g_value_get_object (value));
@@ -1004,9 +1004,9 @@ gdata_youtube_video_get_rating (GDataYouTubeVideo *self, guint *min, guint *max,
  *
  * Gets the #GDataYouTubeVideo:keywords property.
  *
- * Return value: a comma-separated list of words associated with the video
+ * Return value: a %NULL-terminated array of words associated with the video
  **/
-const gchar *
+const gchar * const *
 gdata_youtube_video_get_keywords (GDataYouTubeVideo *self)
 {
 	g_return_val_if_fail (GDATA_IS_YOUTUBE_VIDEO (self), NULL);
@@ -1016,7 +1016,7 @@ gdata_youtube_video_get_keywords (GDataYouTubeVideo *self)
 /**
  * gdata_youtube_video_set_keywords:
  * @self: a #GDataYouTubeVideo
- * @keywords: a new comma-separated list of keywords
+ * @keywords: a new %NULL-terminated array of keywords
  *
  * Sets the #GDataYouTubeVideo:keywords property to the new keyword list, @keywords.
  *
@@ -1024,7 +1024,7 @@ gdata_youtube_video_get_keywords (GDataYouTubeVideo *self)
  * url="http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_media:keywords";>online documentation</ulink>.
  **/
 void
-gdata_youtube_video_set_keywords (GDataYouTubeVideo *self, const gchar *keywords)
+gdata_youtube_video_set_keywords (GDataYouTubeVideo *self, const gchar * const *keywords)
 {
 	g_return_if_fail (keywords != NULL);
 	g_return_if_fail (GDATA_IS_YOUTUBE_VIDEO (self));
@@ -1149,7 +1149,7 @@ gdata_youtube_video_set_description (GDataYouTubeVideo *self, const gchar *descr
 	g_return_if_fail (GDATA_IS_YOUTUBE_VIDEO (self));
 
 	gdata_media_group_set_description (self->priv->media_group, description);
-	g_object_notify (G_OBJECT (self), "keywords");
+	g_object_notify (G_OBJECT (self), "description");
 }
 
 /**
diff --git a/gdata/services/youtube/gdata-youtube-video.h b/gdata/services/youtube/gdata-youtube-video.h
index 82b8cd1..a0847ff 100644
--- a/gdata/services/youtube/gdata-youtube-video.h
+++ b/gdata/services/youtube/gdata-youtube-video.h
@@ -155,8 +155,8 @@ void gdata_youtube_video_set_location (GDataYouTubeVideo *self, const gchar *loc
 GDataYouTubePermission gdata_youtube_video_get_access_control (GDataYouTubeVideo *self, const gchar *action);
 void gdata_youtube_video_set_access_control (GDataYouTubeVideo *self, const gchar *action, GDataYouTubePermission permission);
 void gdata_youtube_video_get_rating (GDataYouTubeVideo *self, guint *min, guint *max, guint *count, gdouble *average);
-const gchar *gdata_youtube_video_get_keywords (GDataYouTubeVideo *self);
-void gdata_youtube_video_set_keywords (GDataYouTubeVideo *self, const gchar *keywords);
+const gchar * const *gdata_youtube_video_get_keywords (GDataYouTubeVideo *self);
+void gdata_youtube_video_set_keywords (GDataYouTubeVideo *self, const gchar * const *keywords);
 const gchar *gdata_youtube_video_get_player_uri (GDataYouTubeVideo *self);
 gboolean gdata_youtube_video_is_restricted_in_country (GDataYouTubeVideo *self, const gchar *country);
 GDataMediaCategory *gdata_youtube_video_get_category (GDataYouTubeVideo *self);
diff --git a/gdata/tests/picasaweb.c b/gdata/tests/picasaweb.c
index d33e2d2..ee0cbfb 100644
--- a/gdata/tests/picasaweb.c
+++ b/gdata/tests/picasaweb.c
@@ -164,9 +164,9 @@ test_upload_async (gconstpointer service)
 	GRegex *regex;
 	GMatchInfo *match_info;
 	guint64 delta;
+	const gchar * const tags[] = { "foo", "bar", ",,baz,baz", NULL };
 	GMainLoop *main_loop = g_main_loop_new (NULL, TRUE);
 
-
 	g_get_current_time (&timeval);
 	time_str = g_time_val_to_iso8601 (&timeval);
 	summary = g_strdup_printf ("Async Photo Summary (%s)", time_str);
@@ -188,6 +188,7 @@ test_upload_async (gconstpointer service)
 						"<media:group>"
 							"<media:title type='plain'>Async Photo Entry Title</media:title>"
 							"<media:description type='plain'>Async Photo Summary \\(%s\\)</media:description>"
+							"<media:keywords>foo,bar,%%2C%%2Cbaz%%2Cbaz</media:keywords>"
 						"</media:group>"
 					"</entry>", time_str, time_str);
 	g_free (time_str);
@@ -200,6 +201,7 @@ test_upload_async (gconstpointer service)
 	photo = gdata_picasaweb_file_new (NULL);
 	gdata_entry_set_title (GDATA_ENTRY (photo), "Async Photo Entry Title");
 	gdata_picasaweb_file_set_caption (photo, summary);
+	gdata_picasaweb_file_set_tags (photo, tags);
 
 	/* Check the XML: match it against the regex built above, then check that the timestamp is within 100ms of the current time at the start of
 	 * the test function. We can't check it exactly, as a few milliseconds may have passed inbetween building the expected_xml and building the XML
@@ -534,6 +536,8 @@ test_upload_simple (gconstpointer service)
 	GRegex *regex;
 	GMatchInfo *match_info;
 	guint64 delta;
+	const gchar * const tags[] = { "foo", "bar", ",,baz,baz", NULL };
+	const gchar * const *tags2;
 
 	g_get_current_time (&timeval);
 	time_str = g_time_val_to_iso8601 (&timeval);
@@ -556,6 +560,7 @@ test_upload_simple (gconstpointer service)
 						"<media:group>"
 							"<media:title type='plain'>Photo Entry Title</media:title>"
 							"<media:description type='plain'>Photo Summary \\(%s\\)</media:description>"
+							"<media:keywords>foo,bar,%%2C%%2Cbaz%%2Cbaz</media:keywords>"
 						"</media:group>"
 					"</entry>", time_str, time_str);
 	g_free (time_str);
@@ -568,6 +573,7 @@ test_upload_simple (gconstpointer service)
 	photo = gdata_picasaweb_file_new (NULL);
 	gdata_entry_set_title (GDATA_ENTRY (photo), "Photo Entry Title");
 	gdata_picasaweb_file_set_caption (photo, summary);
+	gdata_picasaweb_file_set_tags (photo, tags);
 
 	/* Check the XML: match it against the regex built above, then check that the timestamp is within 100ms of the current time at the start of
 	 * the test function. We can't check it exactly, as a few milliseconds may have passed inbetween building the expected_xml and building the XML
@@ -596,6 +602,11 @@ test_upload_simple (gconstpointer service)
 	g_clear_error (&error);
 
 	/* TODO: check entries and feed properties */
+	tags2 = gdata_picasaweb_file_get_tags (photo_new);
+	g_assert_cmpuint (g_strv_length ((gchar**) tags2), ==, 3);
+	g_assert_cmpstr (tags2[0], ==, tags[0]);
+	g_assert_cmpstr (tags2[1], ==, tags[1]);
+	g_assert_cmpstr (tags2[2], ==, tags[2]);
 
 	g_free (summary);
 	g_object_unref (photo);
@@ -621,6 +632,7 @@ test_photo (gconstpointer service)
 	GTimeVal _time;
 	gchar *str;
 	gchar *timestamp;
+	const gchar * const *tags;
 	gdouble latitude;
 	gdouble longitude;
 	gdouble original_latitude;
@@ -673,7 +685,10 @@ test_photo (gconstpointer service)
 	g_assert_cmpuint (gdata_picasaweb_file_get_rotation (photo), ==, 0);
 
 	g_assert_cmpstr (gdata_picasaweb_file_get_caption (photo), ==, "Ginger cookie caption");
-	g_assert_cmpstr (gdata_picasaweb_file_get_tags (photo), ==, "cookies");
+	tags = gdata_picasaweb_file_get_tags (photo);
+	g_assert (tags != NULL);
+	g_assert_cmpstr (tags[0], ==, "cookies");
+	g_assert (tags[1] == NULL);
 	g_assert_cmpstr (gdata_entry_get_title (GDATA_ENTRY (photo)), ==, "100_0269.jpg");
 
 	g_assert_cmpstr (gdata_picasaweb_file_get_credit (photo), ==, "libgdata.picasaweb");
@@ -842,7 +857,6 @@ test_album (gconstpointer service)
 	GTimeVal _time;
 	gchar *str, *original_rights;
 	gdouble latitude, longitude, original_latitude, original_longitude;
-	const gchar *tags;
 	GDataMediaContent *content;
 	GDataMediaThumbnail *thumbnail;
 	GError *error = NULL;
@@ -925,8 +939,7 @@ test_album (gconstpointer service)
 	g_free (original_rights);
 
 	/* Check Media */
-	tags = gdata_picasaweb_album_get_tags (album);
-	g_assert_cmpstr (gdata_picasaweb_album_get_tags (album), ==, NULL);
+	g_assert (gdata_picasaweb_album_get_tags (album) == NULL);
 	/* TODO: they return a <media:keywords></...> but it's empty and the web interface can't set it;
 	   try setting it programmatically; if we can't do that either, consider removing API */
 



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