[grilo] core: Serialize/unserialize GDateTime metadata keys
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo] core: Serialize/unserialize GDateTime metadata keys
- Date: Thu, 1 Nov 2012 22:44:20 +0000 (UTC)
commit f223ef8ed8ba73bedf3e00e38839927bce1236c8
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Thu Nov 1 22:41:15 2012 +0000
core: Serialize/unserialize GDateTime metadata keys
Dates are encoded as iso8601 format.
src/data/grl-media.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/data/grl-media.c b/src/data/grl-media.c
index e1a95fb..76e02d5 100644
--- a/src/data/grl-media.c
+++ b/src/data/grl-media.c
@@ -307,6 +307,7 @@ grl_media_serialize_extended (GrlMedia *media,
const gchar *source;
const gchar *type_name;
gchar *base64_blob;
+ gchar *iso8601_datetime;
gchar *protocol;
gchar *serial_media;
va_list va_serial;
@@ -390,6 +391,14 @@ grl_media_serialize_extended (GrlMedia *media,
NULL,
TRUE);
g_free (base64_blob);
+ } else if (G_VALUE_TYPE (value) == G_TYPE_DATE_TIME) {
+ iso8601_datetime = g_date_time_format (g_value_get_boxed (value),
+ "%FT%T");
+ g_string_append_uri_escaped (serial,
+ iso8601_datetime,
+ NULL,
+ TRUE);
+ g_free (iso8601_datetime);
}
g_string_append_c (serial, '&');
}
@@ -422,6 +431,7 @@ grl_media_serialize_extended (GrlMedia *media,
GrlMedia *
grl_media_unserialize (const gchar *serial)
{
+ GDateTime *datetime;
GMatchInfo *match_info;
GRegex *protocol_regex;
GRegex *query_regex;
@@ -519,6 +529,10 @@ grl_media_unserialize (const gchar *serial)
blob = g_base64_decode (value, &blob_size);
grl_data_set_binary (GRL_DATA (media), grlkey, blob, blob_size);
g_free (blob);
+ } else if (type_grlkey == G_TYPE_DATE_TIME) {
+ datetime = grl_date_time_from_iso8601 (value);
+ grl_data_set_boxed (GRL_DATA (media), grlkey, datetime);
+ g_date_time_unref (datetime);
}
g_free (escaped_value);
g_free (value);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]