[next] telepathy-glib: contact: use the vardict version of the 'location' property
Guillaume Desmottes
gdesmott at kemper.freedesktop.org
Thu Feb 27 06:07:35 PST 2014
Module: telepathy-glib
Branch: next
Commit: 26d98298c377b27911b0b6744bcd3b98122eb942
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=26d98298c377b27911b0b6744bcd3b98122eb942
Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date: Wed Feb 19 14:24:12 2014 +0100
contact: use the vardict version of the 'location' property
---
telepathy-glib/contact.c | 77 +++++++---------------------------------------
tests/dbus/contacts.c | 13 +++-----
2 files changed, 15 insertions(+), 75 deletions(-)
diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c
index f182826..b828f1e 100644
--- a/telepathy-glib/contact.c
+++ b/telepathy-glib/contact.c
@@ -154,8 +154,8 @@ tp_contact_get_feature_quark_presence (void)
* "location" feature.
*
* When this feature is prepared, the contact's location has been
- * retrieved. In particular, the #TpContact:location and
- * #TpContact:location-vardict properties have been set.
+ * retrieved. In particular, the #TpContact:location
+ * property has been set.
*
* Since: 0.99.1
*/
@@ -326,7 +326,6 @@ enum {
PROP_PRESENCE_STATUS,
PROP_PRESENCE_MESSAGE,
PROP_LOCATION,
- PROP_LOCATION_VARDICT,
PROP_CAPABILITIES,
PROP_CONTACT_INFO,
PROP_CLIENT_TYPES,
@@ -386,7 +385,7 @@ struct _TpContactPrivate {
gchar *presence_message;
/* location */
- GHashTable *location;
+ GVariant *location;
/* client types */
gchar **client_types;
@@ -713,29 +712,6 @@ tp_contact_get_presence_message (TpContact *self)
}
/**
- * tp_contact_get_location:
- * @self: a contact
- *
- * Return the contact's user-defined location or %NULL if the location is
- * unspecified.
- * This remains valid until the main loop is re-entered; if the caller
- * requires a hash table that will persist for longer than that, it must be
- * reffed with g_hash_table_ref().
- *
- * Returns: (element-type utf8 GObject.Value) (transfer none): the same
- * #GHashTable (or %NULL) as the #TpContact:location property
- *
- * Since: 0.11.1
- */
-static GHashTable *
-tp_contact_get_location (TpContact *self)
-{
- g_return_val_if_fail (self != NULL, NULL);
-
- return self->priv->location;
-}
-
-/**
* tp_contact_dup_location:
* @self: a contact
*
@@ -746,7 +722,7 @@ tp_contact_get_location (TpContact *self)
* but in a different format.
*
* Returns: a variant of type %G_VARIANT_TYPE_VARDICT, the same as
- * the #TpContact:location-vardict property
+ * the #TpContact:location property
*
* Since: 0.19.10
*/
@@ -758,7 +734,7 @@ tp_contact_dup_location (TpContact *self)
if (self->priv->location == NULL)
return NULL;
- return _tp_asv_to_vardict (self->priv->location);
+ return g_variant_ref (self->priv->location);
}
/**
@@ -1041,7 +1017,7 @@ tp_contact_dispose (GObject *object)
self->priv->connection = NULL;
}
- tp_clear_pointer (&self->priv->location, g_hash_table_unref);
+ tp_clear_pointer (&self->priv->location, g_variant_unref);
tp_clear_object (&self->priv->capabilities);
tp_clear_object (&self->priv->avatar_file);
tp_clear_pointer (&self->priv->contact_groups, g_ptr_array_unref);
@@ -1123,10 +1099,6 @@ tp_contact_get_property (GObject *object,
break;
case PROP_LOCATION:
- g_value_set_boxed (value, tp_contact_get_location (self));
- break;
-
- case PROP_LOCATION_VARDICT:
g_value_take_variant (value, tp_contact_dup_location (self));
break;
@@ -1415,28 +1387,6 @@ tp_contact_class_init (TpContactClass *klass)
* TpContact:location:
*
* If this contact has set a user-defined location, a string to
- * #GValue * hash table containing his location. If not, %NULL.
- * tp_asv_get_string() and similar functions can be used to access
- * the contents.
- *
- * This may be %NULL even if the contact has set a location,
- * if this #TpContact object has not been set up to track
- * %TP_CONTACT_FEATURE_LOCATION.
- *
- * Since: 0.11.1
- */
- param_spec = g_param_spec_boxed ("location",
- "Location",
- "User-defined location, or NULL",
- TP_HASH_TYPE_STRING_VARIANT_MAP,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_LOCATION,
- param_spec);
-
- /**
- * TpContact:location-vardict:
- *
- * If this contact has set a user-defined location, a string to
* variant map containing his location. If not, %NULL.
* tp_vardict_get_string() and similar functions can be used to access
* the contents.
@@ -1444,18 +1394,13 @@ tp_contact_class_init (TpContactClass *klass)
* This may be %NULL even if the contact has set a location,
* if this #TpContact object has not been set up to track
* %TP_CONTACT_FEATURE_LOCATION.
- *
- * This property contains the same information as #TpContact:location,
- * in a different format.
- *
- * Since: 0.19.10
*/
- param_spec = g_param_spec_variant ("location-vardict",
+ param_spec = g_param_spec_variant ("location",
"Location",
"User-defined location, or NULL",
G_VARIANT_TYPE_VARDICT, NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_LOCATION_VARDICT,
+ g_object_class_install_property (object_class, PROP_LOCATION,
param_spec);
/**
@@ -1855,7 +1800,7 @@ contact_maybe_set_location (TpContact *self,
return;
if (self->priv->location != NULL)
- g_hash_table_unref (self->priv->location);
+ g_variant_unref (self->priv->location);
/* We guarantee that, if we've fetched a location for a contact, the
* :location property is non-NULL. This is mainly because Empathy assumed
@@ -1867,9 +1812,9 @@ contact_maybe_set_location (TpContact *self,
g_hash_table_ref (location);
self->priv->has_features |= CONTACT_FEATURE_FLAG_LOCATION;
- self->priv->location = location;
+ self->priv->location = _tp_asv_to_vardict (location);
g_object_notify ((GObject *) self, "location");
- g_object_notify ((GObject *) self, "location-vardict");
+ g_hash_table_unref (location);
}
static void
diff --git a/tests/dbus/contacts.c b/tests/dbus/contacts.c
index 716ce37..b394fe4 100644
--- a/tests/dbus/contacts.c
+++ b/tests/dbus/contacts.c
@@ -973,7 +973,7 @@ test_upgrade (Fixture *f,
g_variant_unref (vardict);
g_object_get (contacts[i],
- "location-vardict", &vardict,
+ "location", &vardict,
NULL);
ASSERT_SAME_LOCATION (vardict, locations[i]);
g_variant_unref (vardict);
@@ -1052,7 +1052,6 @@ typedef struct
gboolean presence_status_changed;
gboolean presence_msg_changed;
gboolean location_changed;
- gboolean location_vardict_changed;
gboolean capabilities_changed;
} notify_ctx;
@@ -1065,7 +1064,6 @@ notify_ctx_init (notify_ctx *ctx)
ctx->presence_status_changed = FALSE;
ctx->presence_msg_changed = FALSE;
ctx->location_changed = FALSE;
- ctx->location_vardict_changed = FALSE;
ctx->capabilities_changed = FALSE;
}
@@ -1075,7 +1073,7 @@ notify_ctx_is_fully_changed (notify_ctx *ctx)
return ctx->alias_changed && ctx->avatar_token_changed &&
ctx->presence_type_changed && ctx->presence_status_changed &&
ctx->presence_msg_changed && ctx->location_changed &&
- ctx->location_vardict_changed && ctx->capabilities_changed;
+ ctx->capabilities_changed;
}
static gboolean
@@ -1084,7 +1082,7 @@ notify_ctx_is_changed (notify_ctx *ctx)
return ctx->alias_changed || ctx->avatar_token_changed ||
ctx->presence_type_changed || ctx->presence_status_changed ||
ctx->presence_msg_changed || ctx->location_changed ||
- ctx->location_vardict_changed || ctx->capabilities_changed;
+ ctx->capabilities_changed;
}
static void
@@ -1104,8 +1102,6 @@ contact_notify_cb (TpContact *contact,
ctx->presence_msg_changed = TRUE;
else if (!tp_strdiff (param->name, "location"))
ctx->location_changed = TRUE;
- else if (!tp_strdiff (param->name, "location-vardict"))
- ctx->location_vardict_changed = TRUE;
else if (!tp_strdiff (param->name, "capabilities"))
ctx->capabilities_changed = TRUE;
}
@@ -1295,7 +1291,7 @@ test_features (Fixture *f,
"presence-type", &from_gobject.presence_type,
"presence-status", &from_gobject.presence_status,
"presence-message", &from_gobject.presence_message,
- "location-vardict", &from_gobject.location_vardict,
+ "location", &from_gobject.location_vardict,
"capabilities", &from_gobject.capabilities,
NULL);
MYASSERT (from_gobject.connection == client_conn, "");
@@ -1780,7 +1776,6 @@ test_no_location (Fixture *f,
1, &handle, &norway);
tp_tests_proxy_run_until_dbus_queue_processed (f->client_conn);
g_assert (notify_ctx_alice.location_changed);
- g_assert (notify_ctx_alice.location_vardict_changed);
vardict = tp_contact_dup_location (contact);
ASSERT_SAME_LOCATION (vardict, norway);
g_variant_unref (vardict);
More information about the telepathy-commits
mailing list