summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/client/contact-list.c2
-rw-r--r--examples/client/extended-client.c2
-rw-r--r--examples/client/inspect-contact.c9
-rw-r--r--telepathy-glib/channel-contacts.c6
-rw-r--r--telepathy-glib/connection-contact-list.c10
-rw-r--r--telepathy-glib/connection.c2
-rw-r--r--telepathy-glib/contact-internal.h6
-rw-r--r--telepathy-glib/contact.c381
-rw-r--r--telepathy-glib/contact.h66
-rw-r--r--telepathy-glib/simple-client-factory.c49
-rw-r--r--telepathy-glib/simple-client-factory.h5
-rw-r--r--telepathy-glib/stream-tube-channel.c4
-rw-r--r--tests/dbus/channel.c2
-rw-r--r--tests/dbus/contact-list-client.c4
-rw-r--r--tests/dbus/contacts-bug-19101.c2
-rw-r--r--tests/dbus/contacts.c134
-rw-r--r--tests/dbus/text-channel.c2
-rw-r--r--tests/enums.c19
18 files changed, 452 insertions, 253 deletions
diff --git a/examples/client/contact-list.c b/examples/client/contact-list.c
index 6e5d66adc..75bd86ef9 100644
--- a/examples/client/contact-list.c
+++ b/examples/client/contact-list.c
@@ -90,7 +90,7 @@ main (int argc,
tp_simple_client_factory_add_contact_features_varargs (factory,
TP_CONTACT_FEATURE_ALIAS,
TP_CONTACT_FEATURE_CONTACT_GROUPS,
- TP_CONTACT_FEATURE_INVALID);
+ 0);
tp_proxy_prepare_async (manager, NULL, account_manager_prepared_cb, loop);
diff --git a/examples/client/extended-client.c b/examples/client/extended-client.c
index 3afc424b5..548ab04fc 100644
--- a/examples/client/extended-client.c
+++ b/examples/client/extended-client.c
@@ -195,7 +195,7 @@ conn_ready (GObject *source,
}
/* Get contact objects for myself and someone else */
- tp_connection_get_contacts_by_id (conn, 2, names, 0, NULL,
+ tp_connection_get_contacts_by_id (conn, 2, names, NULL,
contacts_ready_cb, NULL, NULL, NULL);
}
diff --git a/examples/client/inspect-contact.c b/examples/client/inspect-contact.c
index c1b6bb37d..98433106a 100644
--- a/examples/client/inspect-contact.c
+++ b/examples/client/inspect-contact.c
@@ -131,10 +131,11 @@ connection_ready_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
- static TpContactFeature features[] = {
+ GQuark features[] = {
TP_CONTACT_FEATURE_ALIAS,
TP_CONTACT_FEATURE_AVATAR_TOKEN,
- TP_CONTACT_FEATURE_PRESENCE
+ TP_CONTACT_FEATURE_PRESENCE,
+ 0
};
InspectContactData *data = user_data;
TpConnection *connection = TP_CONNECTION (source);
@@ -155,7 +156,7 @@ connection_ready_cb (GObject *source,
tp_connection_get_contacts_by_handle (connection,
1, &self_handle,
- G_N_ELEMENTS (features), features,
+ features,
got_contacts_by_handle,
data, NULL, NULL);
}
@@ -165,7 +166,7 @@ connection_ready_cb (GObject *source,
tp_connection_get_contacts_by_id (connection,
1, contacts,
- G_N_ELEMENTS (features), features,
+ features,
got_contacts_by_id,
data, NULL, NULL);
}
diff --git a/telepathy-glib/channel-contacts.c b/telepathy-glib/channel-contacts.c
index ea4ee95d6..f7f5b781b 100644
--- a/telepathy-glib/channel-contacts.c
+++ b/telepathy-glib/channel-contacts.c
@@ -374,7 +374,7 @@ process_contacts_queue (TpChannel *self)
tp_connection_upgrade_contacts (self->priv->connection,
item->contacts->len, (TpContact **) item->contacts->pdata,
- features->len, (TpContactFeature *) features->data,
+ (const GQuark *) features->data,
contacts_queue_item_upgraded_cb,
item, NULL,
(GObject *) self);
@@ -386,7 +386,7 @@ process_contacts_queue (TpChannel *self)
tp_connection_get_contacts_by_id (self->priv->connection,
item->ids->len, (const gchar * const*) item->ids->pdata,
- features->len, (TpContactFeature *) features->data,
+ (const GQuark *) features->data,
contacts_queue_item_by_id_cb,
item, NULL,
(GObject *) self);
@@ -398,7 +398,7 @@ process_contacts_queue (TpChannel *self)
tp_connection_get_contacts_by_handle (self->priv->connection,
item->handles->len, (TpHandle *) item->handles->data,
- features->len, (TpContactFeature *) features->data,
+ (const GQuark *) features->data,
contacts_queue_item_by_handle_cb,
item, NULL,
(GObject *) self);
diff --git a/telepathy-glib/connection-contact-list.c b/telepathy-glib/connection-contact-list.c
index c39fb0471..c0aa162c7 100644
--- a/telepathy-glib/connection-contact-list.c
+++ b/telepathy-glib/connection-contact-list.c
@@ -193,7 +193,7 @@ process_queued_contacts_changed (TpConnection *self)
tp_connection_upgrade_contacts (self,
item->new_contacts->len, (TpContact **) item->new_contacts->pdata,
- features->len, (TpContactFeature *) features->data,
+ (const GQuark *) features->data,
new_contacts_upgraded_cb, NULL, NULL, NULL);
g_array_unref (features);
@@ -262,7 +262,7 @@ got_contact_list_attributes_cb (TpConnection *self,
contact = tp_simple_client_factory_ensure_contact (
tp_proxy_get_factory (self), self, handle, id);
if (!_tp_contact_set_attributes (contact, value,
- features->len, (TpContactFeature *) features->data, &e))
+ (const GQuark *) features->data, &e))
{
DEBUG ("Error setting contact attributes: %s", e->message);
g_clear_error (&e);
@@ -312,8 +312,8 @@ prepare_roster (TpConnection *self,
features = tp_simple_client_factory_dup_contact_features (
tp_proxy_get_factory (self), self);
- supported_interfaces = _tp_contacts_bind_to_signals (self, features->len,
- (TpContactFeature *) features->data);
+ supported_interfaces = _tp_contacts_bind_to_signals (self,
+ (const GQuark *) features->data);
tp_connection_get_contact_list_attributes (self, -1,
supported_interfaces,
@@ -1786,7 +1786,7 @@ process_queued_blocked_changed (TpConnection *self)
tp_connection_upgrade_contacts (self,
contacts->len, (TpContact **) contacts->pdata,
- features->len, (TpContactFeature *) features->data,
+ (const GQuark *) features->data,
blocked_contacts_upgraded_cb, NULL, NULL, NULL);
g_array_unref (features);
diff --git a/telepathy-glib/connection.c b/telepathy-glib/connection.c
index 5e890d2d4..748121cd3 100644
--- a/telepathy-glib/connection.c
+++ b/telepathy-glib/connection.c
@@ -862,7 +862,7 @@ get_self_contact (TpConnection *self)
* which makes it start working slightly early. */
tp_connection_get_contacts_by_handle (self,
1, &self->priv->last_known_self_handle,
- features->len, (TpContactFeature *) features->data,
+ (GQuark *) features->data,
tp_connection_got_self_contact_cb, NULL, NULL, NULL);
g_array_unref (features);
diff --git a/telepathy-glib/contact-internal.h b/telepathy-glib/contact-internal.h
index fde16cd19..ace2fb55a 100644
--- a/telepathy-glib/contact-internal.h
+++ b/telepathy-glib/contact-internal.h
@@ -30,13 +30,11 @@ TpContact *_tp_contact_new (TpConnection *connection,
gboolean _tp_contact_set_attributes (TpContact *contact,
GHashTable *asv,
- guint n_features,
- const TpContactFeature *features,
+ const GQuark *features,
GError **error);
const gchar **_tp_contacts_bind_to_signals (TpConnection *connection,
- guint n_features,
- const TpContactFeature *features);
+ const GQuark *features);
void _tp_contact_set_subscription_states (TpContact *self,
GValueArray *value_array);
diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c
index 233abf4c4..8076077d9 100644
--- a/telepathy-glib/contact.c
+++ b/telepathy-glib/contact.c
@@ -57,7 +57,7 @@
* An object representing a contact on a #TpConnection.
*
* Contact objects support tracking a number of attributes of contacts, as
- * described by the #TpContactFeature flags. Features can be specified when
+ * described by the contact feature #GQuark<!-- -->s. Features can be specified when
* instantiating contact objects (with tp_connection_get_contacts_by_id() or
* tp_connection_get_contacts_by_handle()), or added to an existing contact
* object with tp_connection_upgrade_contacts(). For example, a client wishing
@@ -89,68 +89,226 @@ struct _TpContact {
};
/**
- * TpContactFeature:
- * @TP_CONTACT_FEATURE_ALIAS: #TpContact:alias
- * @TP_CONTACT_FEATURE_AVATAR_TOKEN: #TpContact:avatar-token
- * @TP_CONTACT_FEATURE_PRESENCE: #TpContact:presence-type,
- * #TpContact:presence-status and #TpContact:presence-message
- * @TP_CONTACT_FEATURE_LOCATION: #TpContact:location (available since 0.11.1)
- * @TP_CONTACT_FEATURE_CAPABILITIES: #TpContact:capabilities
- * (available since 0.11.3)
- * @TP_CONTACT_FEATURE_AVATAR_DATA: #TpContact:avatar-file and
- * #TpContact:avatar-mime-type. Implies %TP_CONTACT_FEATURE_AVATAR_TOKEN
- * (available since 0.11.6)
- * @TP_CONTACT_FEATURE_CONTACT_INFO: #TpContact:contact-info
- * (available since 0.11.7)
- * @TP_CONTACT_FEATURE_CLIENT_TYPES: #TpContact:client-types
- * (available since 0.13.1)
- * @TP_CONTACT_FEATURE_SUBSCRIPTION_STATES: #TpContact:subscribe-state,
- * #TpContact:publish-state and #TpContact:publish-request. Require a
- * Connection implementing the %TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST
- * interface. (available since 0.13.12)
- * @TP_CONTACT_FEATURE_CONTACT_GROUPS: #TpContact:contact-groups
- * (available since 0.13.14)
- * @TP_CONTACT_FEATURE_CONTACT_BLOCKING: #TpContact:is-blocked. Require
- * Connection implementing the %TP_IFACE_CONNECTION_INTERFACE_CONTACT_BLOCKING
- * interface. (available since 0.17.0)
- *
- * Enumeration representing the features a #TpContact can optionally support.
- * When requesting a #TpContact, library users specify the desired features;
- * the #TpContact code will only initialize state for those features, to
- * avoid unwanted D-Bus round-trips and signal connections.
- *
- * Since 0.11.5, there is a corresponding #GEnumClass type,
- * %TP_TYPE_CONTACT_FEATURE.
+ * TP_CONTACT_FEATURE_ALIAS:
*
- * Since: 0.7.18
+ * Expands to a call to a function that returns a #GQuark representing the
+ * "alias" feature.
+ *
+ * When this feature is prepared, the contact's alias has been retrieved.
+ * In particular, the #TpContact:alias property has been set.
+ *
+ * Since: 0.UNRELEASED
+ */
+
+GQuark
+tp_contact_get_feature_quark_alias (void)
+{
+ return g_quark_from_static_string ("tp-contact-feature-alias");
+}
+
+/**
+ * TP_CONTACT_FEATURE_AVATAR_TOKEN:
+ *
+ * Expands to a call to a function that returns a #GQuark representing the
+ * "avatar token" feature.
+ *
+ * When this feature is prepared, the contact's avatar token has been
+ * retrieved. In particular, the #TpContact:avatar-token property has
+ * been set.
+ *
+ * Since: 0.UNRELEASED
+ */
+
+GQuark
+tp_contact_get_feature_quark_avatar_token (void)
+{
+ return g_quark_from_static_string ("tp-contact-feature-avatar-token");
+}
+
+/**
+ * TP_CONTACT_FEATURE_PRESENCE:
+ *
+ * Expands to a call to a function that returns a #GQuark representing the
+ * "presence" feature.
+ *
+ * When this feature is prepared, the contact's presence has been
+ * retrieved. In particular, the #TpContact:presence-type,
+ * #TpContact:presence-status, and #TpContact:presence-message
+ * properties have been set.
+ *
+ * Since: 0.UNRELEASED
+ */
+
+GQuark
+tp_contact_get_feature_quark_presence (void)
+{
+ return g_quark_from_static_string ("tp-contact-feature-presence");
+}
+
+/**
+ * TP_CONTACT_FEATURE_LOCATION:
+ *
+ * Expands to a call to a function that returns a #GQuark representing the
+ * "location" feature.
+ *
+ * When this feature is prepared, the contact's location has been
+ * retrieved. In particular, the #TpContact:location property has
+ * been set.
+ *
+ * Since: 0.UNRELEASED
+ */
+
+GQuark
+tp_contact_get_feature_quark_location (void)
+{
+ return g_quark_from_static_string ("tp-contact-feature-location");
+}
+
+/**
+ * TP_CONTACT_FEATURE_CAPABILITIES:
+ *
+ * Expands to a call to a function that returns a #GQuark representing the
+ * "capabilities" feature.
+ *
+ * When this feature is prepared, the contact's capabilities have been
+ * retrieved. In particular, the #TpContact:capabilities property has
+ * been set.
+ *
+ * Since: 0.UNRELEASED
+ */
+
+GQuark
+tp_contact_get_feature_quark_capabilities (void)
+{
+ return g_quark_from_static_string ("tp-contact-feature-capabilities");
+}
+
+/**
+ * TP_CONTACT_FEATURE_AVATAR_DATA:
+ *
+ * Expands to a call to a function that returns a #GQuark representing
+ * the "avatar data" feature.
+ *
+ * When this feature is prepared, the contact's avatar has been
+ * retrieved. In particular, the #TpContact:avatar-file property has
+ * been set.
+ *
+ * This feature also implies the %TP_CONTACT_FEATURE_AVATAR_TOKEN.
+ *
+ * Since: 0.UNRELEASED
*/
+GQuark
+tp_contact_get_feature_quark_avatar_data (void)
+{
+ return g_quark_from_static_string ("tp-contact-feature-avatar-data");
+}
+
/**
- * TP_NUM_CONTACT_FEATURES:
+ * TP_CONTACT_FEATURE_CONTACT_INFO:
*
- * 1 higher than the highest #TpContactFeature supported by this version of
- * telepathy-glib.
+ * Expands to a call to a function that returns a #GQuark representing
+ * the "contact info" feature.
+ *
+ * When this feature is prepared, the contact's contact info has been
+ * retrieved. In particular, the #TpContact:contact-info property has
+ * been set.
*
* Since: 0.UNRELEASED
*/
+GQuark
+tp_contact_get_feature_quark_contact_info (void)
+{
+ return g_quark_from_static_string ("tp-contact-feature-contact-info");
+}
+
+/**
+ * TP_CONTACT_FEATURE_CLIENT_TYPES:
+ *
+ * Expands to a call to a function that returns a #GQuark representing
+ * the "client types" feature.
+ *
+ * When this feature is prepared, the contact's client types have been
+ * retrieved. In particular, the #TpContact:client-types property has
+ * been set.
+ *
+ * Since: 0.UNRELEASED
+ */
+
+GQuark
+tp_contact_get_feature_quark_client_types (void)
+{
+ return g_quark_from_static_string ("tp-contact-feature-client-types");
+}
+
+/**
+ * TP_CONTACT_FEATURE_SUBSCRIPTION_STATES:
+ *
+ * Expands to a call to a function that returns a #GQuark representing
+ * the "subscription states" feature.
+ *
+ * When this feature is prepared, the contact's subscription states
+ * have been retrieved. In particular, the #TpContact:subscribe-state,
+ * #TpContact:publish-request, and #TpContact:publish-state properties
+ * have been set.
+ *
+ * This feature requires a Connection implementing the
+ * %TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST interface.
+ *
+ * Since: 0.UNRELEASED
+ */
+
+GQuark
+tp_contact_get_feature_quark_subscription_states (void)
+{
+ return g_quark_from_static_string ("tp-contact-feature-subscription-states");
+}
+
/**
- * TP_CONTACT_FEATURE_INVALID: (skip)
+ * TP_CONTACT_FEATURE_CONTACT_GROUPS:
+ *
+ * Expands to a call to a function that returns a #GQuark representing the
+ * "contact groups" feature.
+ *
+ * When this feature is prepared, the contact's contact groups have
+ * been retrieved. In particular, the #TpContact:contact-groups
+ * property has been set.
*
- * An invalid TpContactFeature. Used as list termination. See for example
- * tp_simple_client_factory_add_contact_features_varargs().
+ * This feature requires a Connection implementing the
+ * %TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS interface.
*
- * Since: 0.15.5
+ * Since: 0.UNRELEASED
*/
+GQuark
+tp_contact_get_feature_quark_contact_groups (void)
+{
+ return g_quark_from_static_string ("tp-contact-feature-contact-groups");
+}
+
/**
- * TP_TYPE_CONTACT_FEATURE:
+ * TP_CONTACT_FEATURE_CONTACT_BLOCKING:
+ *
+ * Expands to a call to a function that returns a #GQuark representing
+ * the "contact blocking" feature.
*
- * The #GEnumClass type of a #TpContactFeature.
+ * When this feature is prepared, the contact's blocking state have
+ * been retrieved. In particular, the #TpContact:is-blocked property
+ * has been set.
*
- * Since: 0.11.5
+ * This feature requires a Connection implementing the
+ * %TP_IFACE_CONNECTION_INTERFACE_CONTACT_BLOCKING interface.
+ *
+ * Since: 0.UNRELEASED
*/
+GQuark
+tp_contact_get_feature_quark_contact_blocking (void)
+{
+ return g_quark_from_static_string ("tp-contact-feature-contact-blocking");
+}
+
G_DEFINE_TYPE (TpContact, tp_contact, G_TYPE_OBJECT)
@@ -186,20 +344,22 @@ enum {
static guint signals[N_SIGNALS] = {0};
+static GQuark const no_quarks[] = { 0 };
+
/* The API allows for more than 32 features, but this implementation does
* not. We can easily expand this later. */
typedef enum {
- CONTACT_FEATURE_FLAG_ALIAS = 1 << TP_CONTACT_FEATURE_ALIAS,
- CONTACT_FEATURE_FLAG_AVATAR_TOKEN = 1 << TP_CONTACT_FEATURE_AVATAR_TOKEN,
- CONTACT_FEATURE_FLAG_PRESENCE = 1 << TP_CONTACT_FEATURE_PRESENCE,
- CONTACT_FEATURE_FLAG_LOCATION = 1 << TP_CONTACT_FEATURE_LOCATION,
- CONTACT_FEATURE_FLAG_CAPABILITIES = 1 << TP_CONTACT_FEATURE_CAPABILITIES,
- CONTACT_FEATURE_FLAG_AVATAR_DATA = 1 << TP_CONTACT_FEATURE_AVATAR_DATA,
- CONTACT_FEATURE_FLAG_CONTACT_INFO = 1 << TP_CONTACT_FEATURE_CONTACT_INFO,
- CONTACT_FEATURE_FLAG_CLIENT_TYPES = 1 << TP_CONTACT_FEATURE_CLIENT_TYPES,
- CONTACT_FEATURE_FLAG_STATES = 1 << TP_CONTACT_FEATURE_SUBSCRIPTION_STATES,
- CONTACT_FEATURE_FLAG_CONTACT_GROUPS = 1 << TP_CONTACT_FEATURE_CONTACT_GROUPS,
- CONTACT_FEATURE_FLAG_CONTACT_BLOCKING = 1 << TP_CONTACT_FEATURE_CONTACT_BLOCKING,
+ CONTACT_FEATURE_FLAG_ALIAS = 1 << 1,
+ CONTACT_FEATURE_FLAG_AVATAR_TOKEN = 1 << 2,
+ CONTACT_FEATURE_FLAG_PRESENCE = 1 << 3,
+ CONTACT_FEATURE_FLAG_LOCATION = 1 << 4,
+ CONTACT_FEATURE_FLAG_CAPABILITIES = 1 << 5,
+ CONTACT_FEATURE_FLAG_AVATAR_DATA = 1 << 6,
+ CONTACT_FEATURE_FLAG_CONTACT_INFO = 1 << 7,
+ CONTACT_FEATURE_FLAG_CLIENT_TYPES = 1 << 8,
+ CONTACT_FEATURE_FLAG_STATES = 1 << 9,
+ CONTACT_FEATURE_FLAG_CONTACT_GROUPS = 1 << 10,
+ CONTACT_FEATURE_FLAG_CONTACT_BLOCKING = 1 << 11,
} ContactFeatureFlags;
struct _TpContactPrivate {
@@ -318,6 +478,35 @@ tp_contact_get_identifier (TpContact *self)
return self->priv->identifier;
}
+static guint
+get_feature (GQuark feature)
+{
+ if (feature == TP_CONTACT_FEATURE_ALIAS)
+ return CONTACT_FEATURE_FLAG_ALIAS;
+ else if (feature == TP_CONTACT_FEATURE_AVATAR_TOKEN)
+ return CONTACT_FEATURE_FLAG_AVATAR_TOKEN;
+ else if (feature == TP_CONTACT_FEATURE_PRESENCE)
+ return CONTACT_FEATURE_FLAG_PRESENCE;
+ else if (feature == TP_CONTACT_FEATURE_LOCATION)
+ return CONTACT_FEATURE_FLAG_LOCATION;
+ else if (feature == TP_CONTACT_FEATURE_CAPABILITIES)
+ return CONTACT_FEATURE_FLAG_CAPABILITIES;
+ else if (feature == TP_CONTACT_FEATURE_AVATAR_DATA)
+ return CONTACT_FEATURE_FLAG_AVATAR_DATA;
+ else if (feature == TP_CONTACT_FEATURE_CONTACT_INFO)
+ return CONTACT_FEATURE_FLAG_CONTACT_INFO;
+ else if (feature == TP_CONTACT_FEATURE_CLIENT_TYPES)
+ return CONTACT_FEATURE_FLAG_CLIENT_TYPES;
+ else if (feature == TP_CONTACT_FEATURE_SUBSCRIPTION_STATES)
+ return CONTACT_FEATURE_FLAG_STATES;
+ else if (feature == TP_CONTACT_FEATURE_CONTACT_GROUPS)
+ return CONTACT_FEATURE_FLAG_CONTACT_GROUPS;
+ else if (feature == TP_CONTACT_FEATURE_CONTACT_BLOCKING)
+ return CONTACT_FEATURE_FLAG_CONTACT_BLOCKING;
+
+ return 0;
+}
+
/**
* tp_contact_has_feature:
* @self: a contact
@@ -331,12 +520,18 @@ tp_contact_get_identifier (TpContact *self)
*/
gboolean
tp_contact_has_feature (TpContact *self,
- TpContactFeature feature)
+ GQuark feature)
{
+ guint mask;
+
g_return_val_if_fail (self != NULL, FALSE);
- g_return_val_if_fail (feature < TP_NUM_CONTACT_FEATURES, FALSE);
- return ((self->priv->has_features & (1 << feature)) != 0);
+ mask = get_feature (feature);
+
+ if (mask == 0)
+ return FALSE;
+
+ return ((self->priv->has_features & mask) != 0);
}
@@ -2991,19 +3186,18 @@ tp_contact_set_attributes (TpContact *contact,
return TRUE;
}
-static gboolean get_feature_flags (guint n_features,
- const TpContactFeature *features, ContactFeatureFlags *flags);
+static gboolean get_feature_flags (const GQuark *features,
+ ContactFeatureFlags *flags);
gboolean
_tp_contact_set_attributes (TpContact *contact,
GHashTable *asv,
- guint n_features,
- const TpContactFeature *features,
+ const GQuark *features,
GError **error)
{
ContactFeatureFlags feature_flags = 0;
- if (!get_feature_flags (n_features, features, &feature_flags))
+ if (!get_feature_flags (features, &feature_flags))
return FALSE;
return tp_contact_set_attributes (contact, asv, feature_flags, error);
@@ -3219,12 +3413,11 @@ contacts_bind_to_signals (TpConnection *connection,
const gchar **
_tp_contacts_bind_to_signals (TpConnection *connection,
- guint n_features,
- const TpContactFeature *features)
+ const GQuark *features)
{
ContactFeatureFlags feature_flags = 0;
- if (!get_feature_flags (n_features, features, &feature_flags))
+ if (!get_feature_flags (features, &feature_flags))
return NULL;
return contacts_bind_to_signals (connection, feature_flags);
@@ -3313,18 +3506,16 @@ lookup_all_contacts (ContactsContext *context)
}
static gboolean
-get_feature_flags (guint n_features,
- const TpContactFeature *features,
+get_feature_flags (const GQuark *features,
ContactFeatureFlags *flags)
{
ContactFeatureFlags feature_flags = 0;
guint i;
- for (i = 0; i < n_features; i++)
- {
- g_return_val_if_fail (features[i] < TP_NUM_CONTACT_FEATURES, FALSE);
- feature_flags |= (1 << features[i]);
- }
+ g_return_val_if_fail (features != NULL, FALSE);
+
+ for (i = 0; features[i] != 0; i++)
+ feature_flags |= get_feature (features[i]);
/* Force AVATAR_TOKEN if we have AVATAR_DATA */
if ((feature_flags & CONTACT_FEATURE_FLAG_AVATAR_DATA) != 0)
@@ -3364,10 +3555,10 @@ contacts_context_remove_common_features (ContactsContext *context)
* @n_handles: The number of handles in @handles (must be at least 1)
* @handles: (array length=n_handles) (element-type uint): An array of handles
* of type %TP_HANDLE_TYPE_CONTACT representing the desired contacts
- * @n_features: The number of features in @features (may be 0)
- * @features: (array length=n_features) (allow-none) (element-type uint): An array of features that
+ * @features: (transfer-none) (array zero-terminated=1) (allow-none)
+ * (element-type GLib.Quark): A zero-terminated array of features that
* must be ready for use (if supported) before the callback is called (may
- * be %NULL if @n_features is 0)
+ * be %NULL)
* @callback: A user callback to call when the contacts are ready
* @user_data: Data to pass to the callback
* @destroy: Called to destroy @user_data either after @callback has been
@@ -3391,8 +3582,7 @@ void
tp_connection_get_contacts_by_handle (TpConnection *self,
guint n_handles,
const TpHandle *handles,
- guint n_features,
- const TpContactFeature *features,
+ const GQuark *features,
TpConnectionContactsByHandleCb callback,
gpointer user_data,
GDestroyNotify destroy,
@@ -3410,10 +3600,12 @@ tp_connection_get_contacts_by_handle (TpConnection *self,
g_return_if_fail (tp_proxy_get_invalidated (self) == NULL);
g_return_if_fail (n_handles >= 1);
g_return_if_fail (handles != NULL);
- g_return_if_fail (n_features == 0 || features != NULL);
g_return_if_fail (callback != NULL);
- if (!get_feature_flags (n_features, features, &feature_flags))
+ if (features == NULL)
+ features = no_quarks;
+
+ if (!get_feature_flags (features, &feature_flags))
return;
context = contacts_context_new (self, n_handles, feature_flags,
@@ -3444,8 +3636,8 @@ tp_connection_get_contacts_by_handle (TpConnection *self,
* @n_contacts: The number of contacts in @contacts (must be at least 1)
* @contacts: (array length=n_contacts): An array of #TpContact objects
* associated with @self
- * @n_features: The number of features in @features (must be at least 1)
- * @features: (array length=n_features): An array of features that must be
+ * @features: (transfer-none) (array zero-terminated=1)
+ * (element-type GLib.Quark): An array of features that must be
* ready for use (if supported) before the callback is called
* @callback: A user callback to call when the contacts are ready
* @user_data: Data to pass to the callback
@@ -3470,8 +3662,7 @@ void
tp_connection_upgrade_contacts (TpConnection *self,
guint n_contacts,
TpContact * const *contacts,
- guint n_features,
- const TpContactFeature *features,
+ const GQuark *features,
TpConnectionUpgradeContactsCb callback,
gpointer user_data,
GDestroyNotify destroy,
@@ -3485,16 +3676,18 @@ tp_connection_upgrade_contacts (TpConnection *self,
TP_CONNECTION_FEATURE_CONNECTED));
g_return_if_fail (n_contacts >= 1);
g_return_if_fail (contacts != NULL);
- g_return_if_fail (n_features == 0 || features != NULL);
g_return_if_fail (callback != NULL);
+ if (features == NULL)
+ features = no_quarks;
+
for (i = 0; i < n_contacts; i++)
{
g_return_if_fail (contacts[i]->priv->connection == self);
g_return_if_fail (contacts[i]->priv->identifier != NULL);
}
- if (!get_feature_flags (n_features, features, &feature_flags))
+ if (!get_feature_flags (features, &feature_flags))
return;
context = contacts_context_new (self, n_contacts, feature_flags,
@@ -3646,10 +3839,9 @@ contacts_requested_handles (TpConnection *connection,
* the desired contacts by their
* identifiers in the IM protocol (XMPP JIDs, SIP URIs, MSN Passports,
* AOL screen-names etc.)
- * @n_features: The number of features in @features (may be 0)
- * @features: (array length=n_features) (allow-none): An array of features
- * that must be ready for use (if supported)
- * before the callback is called (may be %NULL if @n_features is 0)
+ * @features: (transfer-none) (array zero-terminated=1) (allow-none)
+ * (element-type GLib.Quark): An array of features that must be ready for
+ * use (if supported) before the callback is called (may be %NULL)
* @callback: A user callback to call when the contacts are ready
* @user_data: Data to pass to the callback
* @destroy: Called to destroy @user_data either after @callback has been
@@ -3673,8 +3865,7 @@ void
tp_connection_get_contacts_by_id (TpConnection *self,
guint n_ids,
const gchar * const *ids,
- guint n_features,
- const TpContactFeature *features,
+ const GQuark *features,
TpConnectionContactsByIdCb callback,
gpointer user_data,
GDestroyNotify destroy,
@@ -3689,10 +3880,12 @@ tp_connection_get_contacts_by_id (TpConnection *self,
g_return_if_fail (n_ids >= 1);
g_return_if_fail (ids != NULL);
g_return_if_fail (ids[0] != NULL);
- g_return_if_fail (n_features == 0 || features != NULL);
g_return_if_fail (callback != NULL);
- if (!get_feature_flags (n_features, features, &feature_flags))
+ if (features == NULL)
+ features = no_quarks;
+
+ if (!get_feature_flags (features, &feature_flags))
return;
context = contacts_context_new (self, n_ids, feature_flags,
diff --git a/telepathy-glib/contact.h b/telepathy-glib/contact.h
index 35f8636cc..d609aeb60 100644
--- a/telepathy-glib/contact.h
+++ b/telepathy-glib/contact.h
@@ -54,27 +54,55 @@ GType tp_contact_get_type (void) G_GNUC_CONST;
(G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TYPE_CONTACT, \
TpContactClass))
-typedef enum {
- TP_CONTACT_FEATURE_ALIAS,
- TP_CONTACT_FEATURE_AVATAR_TOKEN,
- TP_CONTACT_FEATURE_PRESENCE,
- TP_CONTACT_FEATURE_LOCATION,
- TP_CONTACT_FEATURE_CAPABILITIES,
- TP_CONTACT_FEATURE_AVATAR_DATA,
- TP_CONTACT_FEATURE_CONTACT_INFO,
- TP_CONTACT_FEATURE_CLIENT_TYPES,
- TP_CONTACT_FEATURE_SUBSCRIPTION_STATES,
- TP_CONTACT_FEATURE_CONTACT_GROUPS,
- TP_CONTACT_FEATURE_CONTACT_BLOCKING,
-} TpContactFeature;
-#define TP_NUM_CONTACT_FEATURES (TP_CONTACT_FEATURE_CONTACT_BLOCKING + 1)
-#define TP_CONTACT_FEATURE_INVALID ((TpContactFeature) -1)
+#define TP_CONTACT_FEATURE_ALIAS \
+ (tp_contact_get_feature_quark_alias ())
+GQuark tp_contact_get_feature_quark_alias (void) G_GNUC_CONST;
+
+#define TP_CONTACT_FEATURE_AVATAR_TOKEN \
+ (tp_contact_get_feature_quark_avatar_token ())
+GQuark tp_contact_get_feature_quark_avatar_token (void) G_GNUC_CONST;
+
+#define TP_CONTACT_FEATURE_PRESENCE \
+ (tp_contact_get_feature_quark_presence ())
+GQuark tp_contact_get_feature_quark_presence (void) G_GNUC_CONST;
+
+#define TP_CONTACT_FEATURE_LOCATION \
+ (tp_contact_get_feature_quark_location ())
+GQuark tp_contact_get_feature_quark_location (void) G_GNUC_CONST;
+
+#define TP_CONTACT_FEATURE_CAPABILITIES \
+ (tp_contact_get_feature_quark_capabilities ())
+GQuark tp_contact_get_feature_quark_capabilities (void) G_GNUC_CONST;
+
+#define TP_CONTACT_FEATURE_AVATAR_DATA \
+ (tp_contact_get_feature_quark_avatar_data ())
+GQuark tp_contact_get_feature_quark_avatar_data (void) G_GNUC_CONST;
+
+#define TP_CONTACT_FEATURE_CONTACT_INFO \
+ (tp_contact_get_feature_quark_contact_info ())
+GQuark tp_contact_get_feature_quark_contact_info (void) G_GNUC_CONST;
+
+#define TP_CONTACT_FEATURE_CLIENT_TYPES \
+ (tp_contact_get_feature_quark_client_types ())
+GQuark tp_contact_get_feature_quark_client_types (void) G_GNUC_CONST;
+
+#define TP_CONTACT_FEATURE_SUBSCRIPTION_STATES \
+ (tp_contact_get_feature_quark_subscription_states ())
+GQuark tp_contact_get_feature_quark_subscription_states (void) G_GNUC_CONST;
+
+#define TP_CONTACT_FEATURE_CONTACT_GROUPS \
+ (tp_contact_get_feature_quark_contact_groups ())
+GQuark tp_contact_get_feature_quark_contact_groups (void) G_GNUC_CONST;
+
+#define TP_CONTACT_FEATURE_CONTACT_BLOCKING \
+ (tp_contact_get_feature_quark_contact_blocking ())
+GQuark tp_contact_get_feature_quark_contact_blocking (void) G_GNUC_CONST;
/* Basic functionality, always available */
TpConnection *tp_contact_get_connection (TpContact *self);
TpHandle tp_contact_get_handle (TpContact *self);
const gchar *tp_contact_get_identifier (TpContact *self);
-gboolean tp_contact_has_feature (TpContact *self, TpContactFeature feature);
+gboolean tp_contact_has_feature (TpContact *self, GQuark feature);
/* TP_CONTACT_FEATURE_ALIAS */
const gchar *tp_contact_get_alias (TpContact *self);
@@ -137,7 +165,7 @@ typedef void (*TpConnectionContactsByHandleCb) (TpConnection *connection,
void tp_connection_get_contacts_by_handle (TpConnection *self,
guint n_handles, const TpHandle *handles,
- guint n_features, const TpContactFeature *features,
+ const GQuark *features,
TpConnectionContactsByHandleCb callback,
gpointer user_data, GDestroyNotify destroy, GObject *weak_object);
@@ -147,7 +175,7 @@ typedef void (*TpConnectionUpgradeContactsCb) (TpConnection *connection,
void tp_connection_upgrade_contacts (TpConnection *self,
guint n_contacts, TpContact * const *contacts,
- guint n_features, const TpContactFeature *features,
+ const GQuark *features,
TpConnectionUpgradeContactsCb callback,
gpointer user_data, GDestroyNotify destroy, GObject *weak_object);
@@ -158,7 +186,7 @@ typedef void (*TpConnectionContactsByIdCb) (TpConnection *connection,
void tp_connection_get_contacts_by_id (TpConnection *self,
guint n_ids, const gchar * const *ids,
- guint n_features, const TpContactFeature *features,
+ const GQuark *features,
TpConnectionContactsByIdCb callback,
gpointer user_data, GDestroyNotify destroy, GObject *weak_object);
diff --git a/telepathy-glib/simple-client-factory.c b/telepathy-glib/simple-client-factory.c
index 852e9a337..813c56a44 100644
--- a/telepathy-glib/simple-client-factory.c
+++ b/telepathy-glib/simple-client-factory.c
@@ -258,14 +258,8 @@ static GArray *
dup_contact_features_impl (TpSimpleClientFactory *self,
TpConnection *connection)
{
- GArray *array;
-
- array = g_array_sized_new (FALSE, FALSE, sizeof (TpContactFeature),
- self->priv->desired_contact_features->len);
- g_array_append_vals (array, self->priv->desired_contact_features->data,
- self->priv->desired_contact_features->len);
-
- return array;
+ return _tp_quark_array_copy (
+ (GQuark *) self->priv->desired_contact_features->data);
}
static void
@@ -357,8 +351,8 @@ tp_simple_client_factory_init (TpSimpleClientFactory *self)
feature = TP_CHANNEL_FEATURE_CORE;
g_array_append_val (self->priv->desired_channel_features, feature);
- self->priv->desired_contact_features = g_array_new (FALSE, FALSE,
- sizeof (TpContactFeature));
+ self->priv->desired_contact_features = g_array_new (TRUE, FALSE,
+ sizeof (GQuark));
}
static void
@@ -861,10 +855,10 @@ tp_simple_client_factory_ensure_contact (TpSimpleClientFactory *self,
* @self: a #TpSimpleClientFactory object
* @connection: a #TpConnection
*
- * Return a #GArray containing the #TpContactFeature that should be prepared on
- * all contacts of @connection.
+ * Return a #GArray containing the contact feature #GQuark<!-- -->s
+ * that should be prepared on all contacts of @connection.
*
- * Returns: (transfer full) (element-type TelepathyGLib.ContactFeature): a newly
+ * Returns: (transfer full) (element-type GLib.Quark): a newly
* allocated #GArray
*
* Since: 0.15.5
@@ -884,9 +878,8 @@ tp_simple_client_factory_dup_contact_features (TpSimpleClientFactory *self,
/**
* tp_simple_client_factory_add_contact_features:
* @self: a #TpSimpleClientFactory object
- * @n_features: The number of features in @features (may be 0)
- * @features: (array length=n_features) (allow-none): an array of desired
- * features (may be %NULL if @n_features is 0)
+ * @features: (transfer none) (array zero-terminated=1) (allow-none):
+ * an array of desired features
*
* Add @features to the desired features to be prepared on #TpContact
* objects. Those features will be added to the features already returned be
@@ -899,14 +892,15 @@ tp_simple_client_factory_dup_contact_features (TpSimpleClientFactory *self,
*/
void
tp_simple_client_factory_add_contact_features (TpSimpleClientFactory *self,
- guint n_features, const TpContactFeature *features)
+ const GQuark *features)
{
guint i;
g_return_if_fail (TP_IS_SIMPLE_CLIENT_FACTORY (self));
+ g_return_if_fail (features != NULL);
/* Add features into desired_contact_features avoiding dups */
- for (i = 0; i < n_features; i++)
+ for (i = 0; features[i] != 0; i++)
{
guint j;
gboolean found = FALSE;
@@ -914,7 +908,7 @@ tp_simple_client_factory_add_contact_features (TpSimpleClientFactory *self,
for (j = 0; j < self->priv->desired_contact_features->len; j++)
{
if (features[i] == g_array_index (
- self->priv->desired_contact_features, TpContactFeature, j))
+ self->priv->desired_contact_features, GQuark, j))
{
found = TRUE;
break;
@@ -930,8 +924,7 @@ tp_simple_client_factory_add_contact_features (TpSimpleClientFactory *self,
* tp_simple_client_factory_add_contact_features_varargs: (skip)
* @self: a #TpSimpleClientFactory
* @feature: the first feature
- * @...: the second and subsequent features, if any, ending with
- * %TP_CONTACT_FEATURE_INVALID
+ * @...: the second and subsequent features, if any, ending with 0
*
* The same as tp_simple_client_factory_add_contact_features(), but with a
* more convenient calling convention from C.
@@ -941,24 +934,24 @@ tp_simple_client_factory_add_contact_features (TpSimpleClientFactory *self,
void
tp_simple_client_factory_add_contact_features_varargs (
TpSimpleClientFactory *self,
- TpContactFeature feature,
+ GQuark feature,
...)
{
va_list var_args;
GArray *features;
- TpContactFeature f;
+ GQuark f;
g_return_if_fail (TP_IS_SIMPLE_CLIENT_FACTORY (self));
va_start (var_args, feature);
- features = g_array_new (FALSE, FALSE, sizeof (TpContactFeature));
+ features = g_array_new (TRUE, FALSE, sizeof (GQuark));
- for (f = feature; f != TP_CONTACT_FEATURE_INVALID;
- f = va_arg (var_args, TpContactFeature))
+ for (f = feature; f != 0;
+ f = va_arg (var_args, GQuark))
g_array_append_val (features, f);
- tp_simple_client_factory_add_contact_features (self, features->len,
- (TpContactFeature *) features->data);
+ tp_simple_client_factory_add_contact_features (self,
+ (const GQuark *) features->data);
g_array_unref (features);
va_end (var_args);
diff --git a/telepathy-glib/simple-client-factory.h b/telepathy-glib/simple-client-factory.h
index 3b9a8d0b5..375fb05b8 100644
--- a/telepathy-glib/simple-client-factory.h
+++ b/telepathy-glib/simple-client-factory.h
@@ -162,11 +162,10 @@ GArray *tp_simple_client_factory_dup_contact_features (
TpSimpleClientFactory *self,
TpConnection *connection);
void tp_simple_client_factory_add_contact_features (TpSimpleClientFactory *self,
- guint n_features,
- const TpContactFeature *features);
+ const GQuark *features);
void tp_simple_client_factory_add_contact_features_varargs (
TpSimpleClientFactory *self,
- TpContactFeature feature,
+ GQuark feature,
...);
G_END_DECLS
diff --git a/telepathy-glib/stream-tube-channel.c b/telepathy-glib/stream-tube-channel.c
index a766bd119..1dfa50e15 100644
--- a/telepathy-glib/stream-tube-channel.c
+++ b/telepathy-glib/stream-tube-channel.c
@@ -610,7 +610,7 @@ new_local_connection_identified (TpStreamTubeChannel *self,
/* Pass ownership of tube_conn to the function */
tp_connection_get_contacts_by_handle (connection,
1, &initiator_handle,
- features->len, (TpContactFeature *) features->data,
+ (const GQuark *) features->data,
new_local_connection_with_contact,
tube_conn, g_object_unref, G_OBJECT (self));
@@ -1081,7 +1081,7 @@ connection_identified (TpStreamTubeChannel *self,
/* Pass the ref on tube_conn to the function */
tp_connection_get_contacts_by_handle (connection,
1, &handle,
- features->len, (TpContactFeature *) features->data,
+ (const GQuark *) features->data,
_new_remote_connection_with_contact,
tube_conn, g_object_unref, G_OBJECT (self));
diff --git a/tests/dbus/channel.c b/tests/dbus/channel.c
index 0ad56dbee..3f2aa29ec 100644
--- a/tests/dbus/channel.c
+++ b/tests/dbus/channel.c
@@ -609,7 +609,7 @@ test_contacts (Test *test,
factory = tp_proxy_get_factory (test->connection);
tp_simple_client_factory_add_contact_features_varargs (factory,
TP_CONTACT_FEATURE_ALIAS,
- TP_CONTACT_FEATURE_INVALID);
+ 0);
/* Set an alias for channel's target contact */
handle = tp_channel_get_handle (test->channel_contact, NULL);
diff --git a/tests/dbus/contact-list-client.c b/tests/dbus/contact-list-client.c
index e6efd460f..7e8910b08 100644
--- a/tests/dbus/contact-list-client.c
+++ b/tests/dbus/contact-list-client.c
@@ -455,7 +455,7 @@ test_is_blocked (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
const gchar *id = "bill@example.com";
- TpContactFeature features[] = { TP_CONTACT_FEATURE_CONTACT_BLOCKING };
+ GQuark features[] = { TP_CONTACT_FEATURE_CONTACT_BLOCKING };
GQuark conn_features[] = { TP_CONNECTION_FEATURE_CONTACT_LIST, 0 };
tp_proxy_prepare_async (test->connection, conn_features,
@@ -478,7 +478,7 @@ test_is_blocked (Test *test,
/* Bill is already blocked in the CM */
tp_connection_get_contacts_by_id (test->connection, 1, &id,
- G_N_ELEMENTS (features), features, get_contacts_by_id_cb, test,
+ features, get_contacts_by_id_cb, test,
NULL, NULL);
test->wait = 1;
diff --git a/tests/dbus/contacts-bug-19101.c b/tests/dbus/contacts-bug-19101.c
index 1cc0d8ce0..e13a04cce 100644
--- a/tests/dbus/contacts-bug-19101.c
+++ b/tests/dbus/contacts-bug-19101.c
@@ -111,7 +111,7 @@ test_by_id (TpConnection *client_conn)
tp_connection_get_contacts_by_id (client_conn,
2, ids,
- 0, NULL,
+ NULL,
by_id_cb,
&result, finish, NULL);
diff --git a/tests/dbus/contacts.c b/tests/dbus/contacts.c
index 115b7abb2..5a013d6be 100644
--- a/tests/dbus/contacts.c
+++ b/tests/dbus/contacts.c
@@ -59,30 +59,12 @@ typedef struct {
TpTestsContactsConnection *service_conn;
TpHandleRepoIface *service_repo;
TpConnection *client_conn;
+ GArray *all_contact_features;
} Fixture;
/* We only really actively test TP_CONTACT_FEATURE_ALIAS, but preparing any
* of these once should be enough, assuming that the CM is not broken.
*/
-static TpContactFeature all_contact_features[] = {
- TP_CONTACT_FEATURE_ALIAS,
- TP_CONTACT_FEATURE_AVATAR_TOKEN,
- TP_CONTACT_FEATURE_PRESENCE,
- TP_CONTACT_FEATURE_LOCATION,
- TP_CONTACT_FEATURE_CAPABILITIES,
- TP_CONTACT_FEATURE_AVATAR_DATA,
- TP_CONTACT_FEATURE_CONTACT_INFO,
- TP_CONTACT_FEATURE_CLIENT_TYPES,
- TP_CONTACT_FEATURE_SUBSCRIPTION_STATES,
- TP_CONTACT_FEATURE_CONTACT_GROUPS,
- TP_CONTACT_FEATURE_CONTACT_BLOCKING
-};
-
-/* If people add new features, they should add them to this test. We could
- * generate the list dynamically but this seems less brittle.
- */
-G_STATIC_ASSERT (G_N_ELEMENTS (all_contact_features) == TP_NUM_CONTACT_FEATURES);
-
static void
by_handle_cb (TpConnection *connection,
@@ -315,7 +297,7 @@ test_contact_info (Fixture *f,
Result result = { g_main_loop_new (NULL, FALSE), NULL, NULL, NULL };
TpHandleRepoIface *service_repo = tp_base_connection_get_handles (
(TpBaseConnection *) service_conn, TP_HANDLE_TYPE_CONTACT);
- TpContactFeature features[] = { TP_CONTACT_FEATURE_CONTACT_INFO };
+ GQuark features[] = { TP_CONTACT_FEATURE_CONTACT_INFO, 0 };
TpContact *contact;
TpHandle handle;
const gchar *field_value[] = { "Foo", NULL };
@@ -353,7 +335,7 @@ test_contact_info (Fixture *f,
handle = tp_connection_get_self_handle (client_conn);
tp_connection_get_contacts_by_handle (client_conn,
1, &handle,
- 0, NULL,
+ NULL,
by_handle_cb,
&result, finish, NULL);
g_main_loop_run (result.loop);
@@ -369,7 +351,7 @@ test_contact_info (Fixture *f,
handle = tp_connection_get_self_handle (client_conn);
tp_connection_get_contacts_by_handle (client_conn,
1, &handle,
- G_N_ELEMENTS (features), features,
+ features,
by_handle_cb,
&result, finish, NULL);
g_main_loop_run (result.loop);
@@ -385,7 +367,7 @@ test_contact_info (Fixture *f,
handle = tp_handle_ensure (service_repo, "info-test-3", NULL, NULL);
tp_connection_get_contacts_by_handle (client_conn,
1, &handle,
- G_N_ELEMENTS (features), features,
+ features,
by_handle_cb,
&result, finish, NULL);
g_main_loop_run (result.loop);
@@ -411,7 +393,7 @@ test_contact_info (Fixture *f,
tp_connection_get_contacts_by_handle (client_conn,
1, &handle,
- 0, NULL,
+ NULL,
by_handle_cb,
&result, finish, NULL);
g_main_loop_run (result.loop);
@@ -434,7 +416,7 @@ test_contact_info (Fixture *f,
handle = tp_handle_ensure (service_repo, "info-test-5", NULL, NULL);
tp_connection_get_contacts_by_handle (client_conn,
1, &handle,
- 0, NULL,
+ NULL,
by_handle_cb,
&result, finish, NULL);
g_main_loop_run (result.loop);
@@ -456,7 +438,7 @@ test_contact_info (Fixture *f,
handle = tp_handle_ensure (service_repo, "info-test-6", NULL, NULL);
tp_connection_get_contacts_by_handle (client_conn,
1, &handle,
- 0, NULL,
+ NULL,
by_handle_cb,
&result, finish, NULL);
g_main_loop_run (result.loop);
@@ -539,7 +521,7 @@ create_contact_with_fake_avatar (TpTestsContactsConnection *service_conn,
Result result = { g_main_loop_new (NULL, FALSE), NULL, NULL, NULL };
TpHandleRepoIface *service_repo = tp_base_connection_get_handles (
(TpBaseConnection *) service_conn, TP_HANDLE_TYPE_CONTACT);
- TpContactFeature features[] = { TP_CONTACT_FEATURE_AVATAR_DATA };
+ GQuark features[] = { TP_CONTACT_FEATURE_AVATAR_DATA, 0 };
const gchar avatar_data[] = "fake-avatar-data";
const gchar avatar_token[] = "fake-avatar-token";
const gchar avatar_mime_type[] = "fake-avatar-mime-type";
@@ -558,7 +540,7 @@ create_contact_with_fake_avatar (TpTestsContactsConnection *service_conn,
tp_connection_get_contacts_by_handle (client_conn,
1, &handle,
- G_N_ELEMENTS (features), features,
+ features,
by_handle_cb,
&result, finish, NULL);
g_main_loop_run (result.loop);
@@ -743,7 +725,7 @@ test_by_handle (Fixture *f,
*/
tp_connection_get_contacts_by_handle (client_conn,
5, handles,
- 0, NULL,
+ NULL,
by_handle_cb,
&result, finish, NULL);
@@ -782,7 +764,7 @@ test_by_handle (Fixture *f,
*/
tp_connection_get_contacts_by_handle (client_conn,
4, handles,
- 0, NULL,
+ NULL,
by_handle_cb,
&result, finish, NULL);
@@ -919,7 +901,7 @@ test_by_handle_again (Fixture *f,
tp_connection_get_contacts_by_handle (f->client_conn,
1, &handle,
- G_N_ELEMENTS (all_contact_features), all_contact_features,
+ (const GQuark *) f->all_contact_features->data,
by_handle_cb,
&result, finish, NULL);
g_main_loop_run (result.loop);
@@ -941,7 +923,7 @@ test_by_handle_again (Fixture *f,
tp_connection_get_contacts_by_handle (f->client_conn,
1, &handle,
- G_N_ELEMENTS (all_contact_features), all_contact_features,
+ (const GQuark *) f->all_contact_features->data,
by_handle_cb,
&result, finish, NULL);
g_main_loop_run (result.loop);
@@ -977,7 +959,7 @@ test_by_handle_upgrade (Fixture *f,
TpContact *contact;
gpointer weak_pointer;
const gchar *alias = "Alice in Wonderland";
- TpContactFeature feature = TP_CONTACT_FEATURE_ALIAS;
+ GQuark features[] = { TP_CONTACT_FEATURE_ALIAS, 0 };
g_test_bug ("32191");
@@ -988,7 +970,7 @@ test_by_handle_upgrade (Fixture *f,
tp_connection_get_contacts_by_handle (f->client_conn,
1, &handle,
- 0, NULL,
+ NULL,
by_handle_cb,
&result, finish, NULL);
g_main_loop_run (result.loop);
@@ -1011,7 +993,7 @@ test_by_handle_upgrade (Fixture *f,
* round trips */
tp_connection_get_contacts_by_handle (f->client_conn,
1, &handle,
- 1, &feature,
+ features,
by_handle_cb,
&result, finish, NULL);
g_main_loop_run (result.loop);
@@ -1055,7 +1037,7 @@ test_no_features (Fixture *f,
tp_connection_get_contacts_by_handle (client_conn,
3, handles,
- 0, NULL,
+ NULL,
by_handle_cb,
&result, finish, NULL);
@@ -1259,9 +1241,9 @@ test_upgrade (Fixture *f,
TpHandleRepoIface *service_repo = tp_base_connection_get_handles (
(TpBaseConnection *) service_conn, TP_HANDLE_TYPE_CONTACT);
TpContact *contacts[3];
- TpContactFeature features[] = { TP_CONTACT_FEATURE_ALIAS,
+ GQuark features[] = { TP_CONTACT_FEATURE_ALIAS,
TP_CONTACT_FEATURE_AVATAR_TOKEN, TP_CONTACT_FEATURE_PRESENCE,
- TP_CONTACT_FEATURE_LOCATION, TP_CONTACT_FEATURE_CAPABILITIES };
+ TP_CONTACT_FEATURE_LOCATION, TP_CONTACT_FEATURE_CAPABILITIES, 0 };
guint i;
g_message (G_STRFUNC);
@@ -1284,7 +1266,7 @@ test_upgrade (Fixture *f,
tp_connection_get_contacts_by_handle (client_conn,
3, handles,
- 0, NULL,
+ NULL,
by_handle_cb,
&result, finish, NULL);
@@ -1335,7 +1317,7 @@ test_upgrade (Fixture *f,
tp_connection_upgrade_contacts (client_conn,
3, contacts,
- G_N_ELEMENTS (features), features,
+ features,
upgrade_cb,
&result, finish, NULL);
@@ -1427,7 +1409,7 @@ test_upgrade_noop (Fixture *f,
handle = get_handle_with_no_caps (f, "test-upgrade-noop");
tp_connection_get_contacts_by_handle (f->client_conn,
1, &handle,
- G_N_ELEMENTS (all_contact_features), all_contact_features,
+ (const GQuark *) f->all_contact_features->data,
by_handle_cb,
&result, finish, NULL);
g_main_loop_run (result.loop);
@@ -1440,7 +1422,7 @@ test_upgrade_noop (Fixture *f,
make_the_connection_disappear (f);
tp_connection_upgrade_contacts (f->client_conn,
1, &contact,
- G_N_ELEMENTS (all_contact_features), all_contact_features,
+ (const GQuark *) f->all_contact_features->data,
upgrade_cb,
&result, finish, NULL);
g_main_loop_run (result.loop);
@@ -1582,9 +1564,9 @@ test_features (Fixture *f,
TpHandleRepoIface *service_repo = tp_base_connection_get_handles (
(TpBaseConnection *) service_conn, TP_HANDLE_TYPE_CONTACT);
TpContact *contacts[3];
- TpContactFeature features[] = { TP_CONTACT_FEATURE_ALIAS,
+ GQuark features[] = { TP_CONTACT_FEATURE_ALIAS,
TP_CONTACT_FEATURE_AVATAR_TOKEN, TP_CONTACT_FEATURE_PRESENCE,
- TP_CONTACT_FEATURE_LOCATION, TP_CONTACT_FEATURE_CAPABILITIES };
+ TP_CONTACT_FEATURE_LOCATION, TP_CONTACT_FEATURE_CAPABILITIES, 0 };
guint i;
struct {
TpConnection *connection;
@@ -1622,7 +1604,7 @@ test_features (Fixture *f,
tp_connection_get_contacts_by_handle (client_conn,
3, handles,
- G_N_ELEMENTS (features), features,
+ features,
by_handle_cb,
&result, finish, NULL);
@@ -1915,7 +1897,7 @@ test_by_id (Fixture *f,
tp_connection_get_contacts_by_id (client_conn,
1, ids + 2,
- 0, NULL,
+ NULL,
by_id_cb,
&result, finish, NULL);
@@ -1935,7 +1917,7 @@ test_by_id (Fixture *f,
tp_connection_get_contacts_by_id (client_conn,
2, ids,
- 0, NULL,
+ NULL,
by_id_cb,
&result, finish, NULL);
@@ -1961,7 +1943,7 @@ test_by_id (Fixture *f,
tp_connection_get_contacts_by_id (client_conn,
5, ids,
- 0, NULL,
+ NULL,
by_id_cb,
&result, finish, NULL);
@@ -2015,7 +1997,7 @@ test_dup_if_possible (Fixture *f,
tp_connection_get_contacts_by_handle (f->client_conn,
1, &alice_handle,
- 0, NULL,
+ NULL,
by_handle_cb,
&f->result, finish, NULL);
g_main_loop_run (f->result.loop);
@@ -2093,7 +2075,7 @@ test_subscription_states (Fixture *f,
TpHandle alice_handle;
TpContact *alice;
TpTestsContactListManager *manager;
- TpContactFeature features[] = { TP_CONTACT_FEATURE_SUBSCRIPTION_STATES };
+ GQuark features[] = { TP_CONTACT_FEATURE_SUBSCRIPTION_STATES, 0 };
SubscriptionStates states = { TP_SUBSCRIPTION_STATE_NO,
TP_SUBSCRIPTION_STATE_NO, "", f->result.loop };
@@ -2105,7 +2087,7 @@ test_subscription_states (Fixture *f,
tp_connection_get_contacts_by_handle (f->client_conn,
1, &alice_handle,
- G_N_ELEMENTS (features), features,
+ features,
by_handle_cb,
&f->result, finish, NULL);
g_main_loop_run (f->result.loop);
@@ -2185,7 +2167,7 @@ test_contact_groups (Fixture *f,
TpHandle alice_handle;
TpContact *alice;
TpTestsContactListManager *manager;
- TpContactFeature features[] = { TP_CONTACT_FEATURE_CONTACT_GROUPS };
+ GQuark features[] = { TP_CONTACT_FEATURE_CONTACT_GROUPS, 0 };
ContactGroups data;
data.groups = g_ptr_array_new ();
@@ -2199,7 +2181,7 @@ test_contact_groups (Fixture *f,
tp_connection_get_contacts_by_handle (f->client_conn,
1, &alice_handle,
- G_N_ELEMENTS (features), features,
+ features,
by_handle_cb,
&f->result, finish, NULL);
g_main_loop_run (f->result.loop);
@@ -2267,7 +2249,7 @@ test_no_location (Fixture *f,
TpHandle handle;
TpContact *contact;
gpointer weak_pointer;
- TpContactFeature feature = TP_CONTACT_FEATURE_LOCATION;
+ GQuark features[] = { TP_CONTACT_FEATURE_LOCATION, 0 };
GHashTable *norway = tp_asv_new ("country", G_TYPE_STRING, "Norway", NULL);
notify_ctx notify_ctx_alice;
@@ -2278,7 +2260,7 @@ test_no_location (Fixture *f,
tp_connection_get_contacts_by_handle (f->client_conn,
1, &handle,
- 1, &feature,
+ features,
by_handle_cb,
&f->result, finish, NULL);
g_main_loop_run (f->result.loop);
@@ -2298,7 +2280,7 @@ test_no_location (Fixture *f,
make_the_connection_disappear (f);
tp_connection_get_contacts_by_handle (f->client_conn,
1, &handle,
- 1, &feature,
+ features,
by_handle_cb,
&f->result, finish, NULL);
g_main_loop_run (f->result.loop);
@@ -2342,7 +2324,7 @@ test_no_location (Fixture *f,
tp_connection_get_contacts_by_handle (f->client_conn,
1, &handle,
- 0, NULL,
+ NULL,
by_handle_cb,
&f->result, finish, NULL);
g_main_loop_run (f->result.loop);
@@ -2360,7 +2342,7 @@ test_no_location (Fixture *f,
tp_connection_upgrade_contacts (f->client_conn,
1, &contact,
- 1, &feature,
+ features,
upgrade_cb,
&f->result, finish, NULL);
g_main_loop_run (f->result.loop);
@@ -2402,8 +2384,8 @@ test_superfluous_attributes (Fixture *f,
TpHandle handle;
TpContact *contact;
const gchar * const *client_types;
- TpContactFeature client_types_feature = TP_CONTACT_FEATURE_CLIENT_TYPES;
- TpContactFeature presence_feature = TP_CONTACT_FEATURE_PRESENCE;
+ GQuark client_types_features[] = { TP_CONTACT_FEATURE_CLIENT_TYPES, 0 };
+ GQuark presence_features[] = { TP_CONTACT_FEATURE_PRESENCE, 0 };
g_assert (TP_TESTS_IS_BROKEN_CLIENT_TYPES_CONNECTION (f->service_conn));
@@ -2420,7 +2402,7 @@ test_superfluous_attributes (Fixture *f,
*/
tp_connection_get_contacts_by_handle (f->client_conn,
1, &handle,
- 1, &client_types_feature,
+ client_types_features,
by_handle_cb,
&f->result, finish, NULL);
g_main_loop_run (f->result.loop);
@@ -2466,7 +2448,7 @@ test_superfluous_attributes (Fixture *f,
make_the_connection_disappear (f);
tp_connection_get_contacts_by_handle (f->client_conn,
1, &handle,
- 1, &presence_feature,
+ presence_features,
by_handle_cb,
&f->result, finish, NULL);
g_main_loop_run (f->result.loop);
@@ -2529,7 +2511,7 @@ test_contact_list (Fixture *f,
factory = tp_proxy_get_factory (f->client_conn);
tp_simple_client_factory_add_contact_features_varargs (factory,
TP_CONTACT_FEATURE_ALIAS,
- TP_CONTACT_FEATURE_INVALID);
+ 0);
/* Now put it online and wait for contact list state move to success */
g_signal_connect (f->client_conn, "contact-list-changed",
@@ -2570,7 +2552,7 @@ test_self_contact (Fixture *f,
factory = tp_proxy_get_factory (f->client_conn);
tp_simple_client_factory_add_contact_features_varargs (factory,
TP_CONTACT_FEATURE_ALIAS,
- TP_CONTACT_FEATURE_INVALID);
+ 0);
tp_cli_connection_call_connect (f->client_conn, -1, NULL, NULL, NULL, NULL);
tp_tests_proxy_run_until_prepared (f->client_conn, conn_features);
@@ -2585,6 +2567,27 @@ setup_internal (Fixture *f,
gboolean connect,
gconstpointer user_data)
{
+/* TODO: we should assert that when people add new TpContact features
+ * they're added to this list and tested; this was easier with
+ * TpContactFeature... */
+ const GQuark features[] = {
+ TP_CONTACT_FEATURE_ALIAS,
+ TP_CONTACT_FEATURE_AVATAR_TOKEN,
+ TP_CONTACT_FEATURE_PRESENCE,
+ TP_CONTACT_FEATURE_LOCATION,
+ TP_CONTACT_FEATURE_CAPABILITIES,
+ TP_CONTACT_FEATURE_AVATAR_DATA,
+ TP_CONTACT_FEATURE_CONTACT_INFO,
+ TP_CONTACT_FEATURE_CLIENT_TYPES,
+ TP_CONTACT_FEATURE_SUBSCRIPTION_STATES,
+ TP_CONTACT_FEATURE_CONTACT_GROUPS,
+ TP_CONTACT_FEATURE_CONTACT_BLOCKING,
+ };
+
+ f->all_contact_features = g_array_new (TRUE, FALSE, sizeof (GQuark));
+ g_array_append_vals (f->all_contact_features,
+ features, G_N_ELEMENTS (features));
+
tp_tests_create_conn (TP_TESTS_TYPE_CONTACTS_CONNECTION,
"me@test.com", connect, &f->base_connection, &f->client_conn);
@@ -2617,6 +2620,9 @@ teardown (Fixture *f,
if (f->client_conn != NULL)
tp_tests_connection_assert_disconnect_succeeds (f->client_conn);
+ if (f->all_contact_features != NULL)
+ g_array_unref (f->all_contact_features);
+
tp_clear_object (&f->client_conn);
f->service_repo = NULL;
tp_clear_object (&f->service_conn);
diff --git a/tests/dbus/text-channel.c b/tests/dbus/text-channel.c
index fbc13005c..92603e521 100644
--- a/tests/dbus/text-channel.c
+++ b/tests/dbus/text-channel.c
@@ -865,7 +865,7 @@ test_sender_prepared (Test *test,
factory = tp_proxy_get_factory (test->connection);
tp_simple_client_factory_add_contact_features_varargs (factory,
TP_CONTACT_FEATURE_ALIAS,
- TP_CONTACT_FEATURE_INVALID);
+ 0);
msg = tp_cm_message_new_text (test->base_connection, admin,
TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
diff --git a/tests/enums.c b/tests/enums.c
index 17ec4b46c..6c147dfb8 100644
--- a/tests/enums.c
+++ b/tests/enums.c
@@ -18,24 +18,6 @@
#include "tests/lib/util.h"
static void
-test_tp_contact_feature (void)
-{
- GEnumClass *klass;
-
- g_type_init ();
-
- klass = g_type_class_ref (TP_TYPE_CONTACT_FEATURE);
-
- g_assert (klass != NULL);
- g_assert (G_IS_ENUM_CLASS (klass));
-
- g_assert_cmpint (klass->n_values, ==, TP_NUM_CONTACT_FEATURES);
-
- g_type_class_unref (klass);
-}
-
-
-static void
test_tp_dbus_error (void)
{
GEnumClass *klass;
@@ -57,7 +39,6 @@ main (int argc,
{
g_test_init (&argc, &argv, NULL);
- g_test_add_func ("/enums/tp-contact-feature", test_tp_contact_feature);
g_test_add_func ("/enums/tp-dbus-error", test_tp_dbus_error);
return g_test_run ();