[libgdata] core: Override GDataEntry::etag in GDataAccessRule
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] core: Override GDataEntry::etag in GDataAccessRule
- Date: Fri, 8 Oct 2010 23:10:18 +0000 (UTC)
commit e5e811acdbe50c93de17575afd6683a88be180be
Author: Philip Withnall <philip tecnocode co uk>
Date: Tue Oct 5 13:51:49 2010 +0100
core: Override GDataEntry::etag in GDataAccessRule
Access rules don't seem to support ETags (at least in Google Calendar), so
we override GDataEntry::etag so that it's always NULL for access rules.
gdata/gdata-access-rule.c | 14 +++++++++++++-
gdata/gdata-entry.c | 15 +++++++++++++--
2 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/gdata/gdata-access-rule.c b/gdata/gdata-access-rule.c
index 326ff86..cd40164 100644
--- a/gdata/gdata-access-rule.c
+++ b/gdata/gdata-access-rule.c
@@ -60,7 +60,8 @@ enum {
PROP_ROLE = 1,
PROP_SCOPE_TYPE,
PROP_SCOPE_VALUE,
- PROP_EDITED
+ PROP_EDITED,
+ PROP_ETAG
};
G_DEFINE_TYPE (GDataAccessRule, gdata_access_rule, GDATA_TYPE_ENTRY)
@@ -141,6 +142,10 @@ gdata_access_rule_class_init (GDataAccessRuleClass *klass)
"Edited", "The last time the access rule was edited.",
-1, G_MAXINT64, -1,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+ /* Override the ETag property since ETags don't seem to be supported for ACL entries. TODO: Investigate this further (might only be
+ * unsupported for Google Calendar). */
+ g_object_class_override_property (gobject_class, PROP_ETAG, "etag");
}
static void notify_role_cb (GDataAccessRule *self, GParamSpec *pspec, gpointer user_data);
@@ -231,6 +236,10 @@ gdata_access_rule_get_property (GObject *object, guint property_id, GValue *valu
case PROP_EDITED:
g_value_set_int64 (value, priv->edited);
break;
+ case PROP_ETAG:
+ /* Never return an ETag */
+ g_value_set_string (value, NULL);
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -257,6 +266,9 @@ gdata_access_rule_set_property (GObject *object, guint property_id, const GValue
self->priv->scope_value = g_value_dup_string (value);
g_object_notify (object, "scope-value");
break;
+ case PROP_ETAG:
+ /* Never set an ETag (note that this doesn't stop it being set in GDataEntry due to XML parsing) */
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
diff --git a/gdata/gdata-entry.c b/gdata/gdata-entry.c
index 1a18ade..e4f9069 100644
--- a/gdata/gdata-entry.c
+++ b/gdata/gdata-entry.c
@@ -492,7 +492,7 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
GDataEntryPrivate *priv = GDATA_ENTRY (parsable)->priv;
/* Add the entry's ETag, if available */
- if (priv->etag != NULL)
+ if (gdata_entry_get_etag (GDATA_ENTRY (parsable)) != NULL)
g_string_append_printf (xml_string, " gd:etag='%s'", priv->etag);
}
@@ -695,8 +695,19 @@ gdata_entry_get_id (GDataEntry *self)
const gchar *
gdata_entry_get_etag (GDataEntry *self)
{
+ gchar *etag;
+
g_return_val_if_fail (GDATA_IS_ENTRY (self), NULL);
- return self->priv->etag;
+
+ /* We have to check if the property's set since GDataAccessRule overrides it and sets it to always be NULL (since ACL entries don't support
+ * ETags, for some reason). */
+ g_object_get (G_OBJECT (self), "etag", &etag, NULL);
+ if (etag != NULL) {
+ g_free (etag);
+ return self->priv->etag;
+ }
+
+ return NULL;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]