summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2012-08-08 11:25:31 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2012-08-08 11:25:31 +0100
commit35e2eb731dfb7cb36a391eb45634453b30a96a46 (patch)
treeccb3421b1f598ea12758eb6f4c3de937c684da08
parentbc29307a40767211930af2e248e5f9cb598a64d1 (diff)
downloadtelepathy-logger-35e2eb731dfb7cb36a391eb45634453b30a96a46.tar.gz
tests library: update snapshots of helper objects from tp-glib
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--tests/lib/Makefile.am4
-rw-r--r--tests/lib/contacts-conn.c540
-rw-r--r--tests/lib/contacts-conn.h74
-rw-r--r--tests/lib/simple-account-manager.c143
-rw-r--r--tests/lib/simple-account-manager.h16
-rw-r--r--tests/lib/simple-account.c275
-rw-r--r--tests/lib/simple-account.h14
-rw-r--r--tests/lib/simple-conn.c167
-rw-r--r--tests/lib/simple-conn.h11
-rw-r--r--tests/lib/textchan-null.c572
-rw-r--r--tests/lib/textchan-null.h137
11 files changed, 597 insertions, 1356 deletions
diff --git a/tests/lib/Makefile.am b/tests/lib/Makefile.am
index e0b7940..0106386 100644
--- a/tests/lib/Makefile.am
+++ b/tests/lib/Makefile.am
@@ -9,8 +9,6 @@ libtp_logger_tests_la_SOURCES = \
simple-account-manager.h \
simple-conn.c \
simple-conn.h \
- textchan-null.c \
- textchan-null.h \
util.c \
util.h
@@ -23,4 +21,4 @@ AM_CFLAGS = \
$(TPL_CFLAGS)\
$(NULL)
-libtp_logger_tests_la_LIBADD = $(TPL_LIBS) \ No newline at end of file
+libtp_logger_tests_la_LIBADD = $(TPL_LIBS)
diff --git a/tests/lib/contacts-conn.c b/tests/lib/contacts-conn.c
index 76ce98e..ce64aaa 100644
--- a/tests/lib/contacts-conn.c
+++ b/tests/lib/contacts-conn.c
@@ -8,6 +8,7 @@
* are permitted in any medium without royalty provided the copyright
* notice and this notice are preserved.
*/
+
#include "config.h"
#include "contacts-conn.h"
@@ -19,8 +20,6 @@
static void init_aliasing (gpointer, gpointer);
static void init_avatars (gpointer, gpointer);
-static void init_location (gpointer, gpointer);
-static void init_contact_caps (gpointer, gpointer);
static void init_contact_info (gpointer, gpointer);
static void conn_avatars_properties_getter (GObject *object, GQuark interface,
GQuark name, GValue *value, gpointer getter_data);
@@ -32,19 +31,21 @@ G_DEFINE_TYPE_WITH_CODE (TpTestsContactsConnection,
init_aliasing);
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_AVATARS,
init_avatars);
- G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACTS,
- tp_contacts_mixin_iface_init);
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_PRESENCE,
tp_presence_mixin_iface_init);
- G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_SIMPLE_PRESENCE,
- tp_presence_mixin_simple_presence_iface_init)
- G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_LOCATION,
- init_location)
+ G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_LOCATION, NULL)
G_IMPLEMENT_INTERFACE (
- TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_CAPABILITIES,
- init_contact_caps)
+ TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_CAPABILITIES, NULL)
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_INFO,
init_contact_info)
+ G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACTS,
+ tp_contacts_mixin_iface_init);
+ G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_LIST,
+ tp_base_contact_list_mixin_list_iface_init);
+ G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_GROUPS,
+ tp_base_contact_list_mixin_groups_iface_init);
+ G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CLIENT_TYPES,
+ NULL);
);
/* type definition stuff */
@@ -315,11 +316,40 @@ conn_contact_info_properties_getter (GObject *object,
if (supported_fields == NULL)
{
supported_fields = g_ptr_array_new ();
+
+ g_ptr_array_add (supported_fields, tp_value_array_build (4,
+ G_TYPE_STRING, "bday",
+ G_TYPE_STRV, NULL,
+ G_TYPE_UINT, 0,
+ G_TYPE_UINT, 1,
+ G_TYPE_INVALID));
+
+ g_ptr_array_add (supported_fields, tp_value_array_build (4,
+ G_TYPE_STRING, "email",
+ G_TYPE_STRV, NULL,
+ G_TYPE_UINT, 0,
+ G_TYPE_UINT, G_MAXUINT32,
+ G_TYPE_INVALID));
+
+ g_ptr_array_add (supported_fields, tp_value_array_build (4,
+ G_TYPE_STRING, "fn",
+ G_TYPE_STRV, NULL,
+ G_TYPE_UINT, 0,
+ G_TYPE_UINT, 1,
+ G_TYPE_INVALID));
+
g_ptr_array_add (supported_fields, tp_value_array_build (4,
- G_TYPE_STRING, "n",
+ G_TYPE_STRING, "tel",
G_TYPE_STRV, NULL,
G_TYPE_UINT, 0,
+ G_TYPE_UINT, G_MAXUINT32,
+ G_TYPE_INVALID));
+
+ g_ptr_array_add (supported_fields, tp_value_array_build (4,
+ G_TYPE_STRING, "url",
+ G_TYPE_STRV, NULL,
G_TYPE_UINT, 0,
+ G_TYPE_UINT, G_MAXUINT32,
G_TYPE_INVALID));
}
g_value_set_boxed (value, supported_fields);
@@ -331,6 +361,23 @@ conn_contact_info_properties_getter (GObject *object,
}
static void
+client_types_fill_contact_attributes (
+ GObject *object,
+ const GArray *contacts,
+ GHashTable *attributes)
+{
+ TpTestsContactsConnectionClass *klass =
+ TP_TESTS_CONTACTS_CONNECTION_GET_CLASS (object);
+
+ if (klass->fill_client_types != NULL)
+ klass->fill_client_types (object, contacts, attributes);
+ /* …else do nothing: a no-op implementation is valid, relatively speaking.
+ * The spec sez the /client-types attribute should be “omitted from the
+ * result if the contact's client types are not known.”
+ */
+}
+
+static void
constructed (GObject *object)
{
TpBaseConnection *base = TP_BASE_CONNECTION (object);
@@ -358,10 +405,13 @@ constructed (GObject *object)
tp_contacts_mixin_add_contact_attributes_iface (object,
TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO,
contact_info_fill_contact_attributes);
+ tp_contacts_mixin_add_contact_attributes_iface (object,
+ TP_IFACE_CONNECTION_INTERFACE_CLIENT_TYPES,
+ client_types_fill_contact_attributes);
tp_presence_mixin_init (object,
G_STRUCT_OFFSET (TpTestsContactsConnection, presence_mixin));
- tp_presence_mixin_simple_presence_register_with_contacts_mixin (object);
+ tp_presence_mixin_register_with_contacts_mixin (object);
}
static const TpPresenceStatusOptionalArgumentSpec can_have_message[] = {
@@ -387,10 +437,7 @@ my_status_available (GObject *object,
{
TpBaseConnection *base = TP_BASE_CONNECTION (object);
- if (base->status != TP_CONNECTION_STATUS_CONNECTED)
- return FALSE;
-
- return TRUE;
+ return tp_base_connection_check_connected (base, NULL);
}
static GHashTable *
@@ -420,7 +467,7 @@ my_get_contact_statuses (GObject *object,
g_str_equal, NULL, (GDestroyNotify) tp_g_value_slice_free);
if (presence_message != NULL)
- g_hash_table_insert (parameters, "message",
+ g_hash_table_insert (parameters, (gpointer) "message",
tp_g_value_slice_new_string (presence_message));
g_hash_table_insert (result, key,
@@ -439,6 +486,7 @@ my_set_own_status (GObject *object,
TpBaseConnection *base_conn = TP_BASE_CONNECTION (object);
TpTestsContactsConnectionPresenceStatusIndex index = status->index;
const gchar *message = "";
+ TpHandle self_handle;
if (status->optional_arguments != NULL)
{
@@ -448,29 +496,59 @@ my_set_own_status (GObject *object,
message = "";
}
+ self_handle = tp_base_connection_get_self_handle (base_conn);
tp_tests_contacts_connection_change_presences (TP_TESTS_CONTACTS_CONNECTION (object),
- 1, &(base_conn->self_handle), &index, &message);
+ 1, &self_handle, &index, &message);
return TRUE;
}
-static void
-tp_tests_contacts_connection_class_init (TpTestsContactsConnectionClass *klass)
+static guint
+my_get_maximum_status_message_length_cb (GObject *obj)
{
- TpBaseConnectionClass *base_class =
- (TpBaseConnectionClass *) klass;
- GObjectClass *object_class = (GObjectClass *) klass;
+ return 512;
+}
+
+static GPtrArray *
+create_channel_managers (TpBaseConnection *conn)
+{
+ return g_ptr_array_new ();
+}
+
+static GPtrArray *
+tp_tests_contacts_get_interfaces_always_present (TpBaseConnection *base)
+{
+ GPtrArray *interfaces;
static const gchar *interfaces_always_present[] = {
TP_IFACE_CONNECTION_INTERFACE_ALIASING,
TP_IFACE_CONNECTION_INTERFACE_AVATARS,
TP_IFACE_CONNECTION_INTERFACE_CONTACTS,
+ TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST,
+ TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS,
TP_IFACE_CONNECTION_INTERFACE_PRESENCE,
- TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE,
TP_IFACE_CONNECTION_INTERFACE_LOCATION,
+ TP_IFACE_CONNECTION_INTERFACE_CLIENT_TYPES,
TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES,
TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO,
- TP_IFACE_CONNECTION_INTERFACE_REQUESTS,
NULL };
+ guint i;
+
+ interfaces = TP_BASE_CONNECTION_CLASS (
+ tp_tests_contacts_connection_parent_class)->get_interfaces_always_present (base);
+
+ for (i = 0; interfaces_always_present[i] != NULL; i++)
+ g_ptr_array_add (interfaces, (gchar *) interfaces_always_present[i]);
+
+ return interfaces;
+}
+
+static void
+tp_tests_contacts_connection_class_init (TpTestsContactsConnectionClass *klass)
+{
+ TpBaseConnectionClass *base_class =
+ (TpBaseConnectionClass *) klass;
+ GObjectClass *object_class = (GObjectClass *) klass;
+ TpPresenceMixinClass *mixin_class;
static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = {
{ TP_IFACE_CONNECTION_INTERFACE_AVATARS,
conn_avatars_properties_getter,
@@ -489,7 +567,8 @@ tp_tests_contacts_connection_class_init (TpTestsContactsConnectionClass *klass)
object_class->finalize = finalize;
g_type_class_add_private (klass, sizeof (TpTestsContactsConnectionPrivate));
- base_class->interfaces_always_present = interfaces_always_present;
+ base_class->get_interfaces_always_present = tp_tests_contacts_get_interfaces_always_present;
+ base_class->create_channel_managers = create_channel_managers;
tp_contacts_mixin_class_init (object_class,
G_STRUCT_OFFSET (TpTestsContactsConnectionClass, contacts_mixin));
@@ -498,14 +577,27 @@ tp_tests_contacts_connection_class_init (TpTestsContactsConnectionClass *klass)
G_STRUCT_OFFSET (TpTestsContactsConnectionClass, presence_mixin),
my_status_available, my_get_contact_statuses,
my_set_own_status, my_statuses);
+ mixin_class = TP_PRESENCE_MIXIN_CLASS(klass);
+ mixin_class->get_maximum_status_message_length =
+ my_get_maximum_status_message_length_cb;
- tp_presence_mixin_simple_presence_init_dbus_properties (object_class);
+ tp_presence_mixin_init_dbus_properties (object_class);
klass->properties_class.interfaces = prop_interfaces;
tp_dbus_properties_mixin_class_init (object_class,
G_STRUCT_OFFSET (TpTestsContactsConnectionClass, properties_class));
+
+ tp_base_contact_list_mixin_class_init (base_class);
}
+/**
+ * tp_tests_contacts_connection_change_aliases:
+ * @self: a #TpTestsContactsConnection
+ * @n: the number of handles
+ * @handles: (array length=n): the handles
+ * @aliases: (array length=n): aliases
+ *
+ */
void
tp_tests_contacts_connection_change_aliases (TpTestsContactsConnection *self,
guint n,
@@ -519,6 +611,8 @@ tp_tests_contacts_connection_change_aliases (TpTestsContactsConnection *self,
{
GValueArray *pair = g_value_array_new (2);
+ g_debug ("contact#%u -> %s", handles[i], aliases[i]);
+
g_hash_table_insert (self->priv->aliases,
GUINT_TO_POINTER (handles[i]), g_strdup (aliases[i]));
@@ -557,6 +651,9 @@ tp_tests_contacts_connection_change_presences (
GHashTable *parameters;
gpointer key = GUINT_TO_POINTER (handles[i]);
+ g_debug ("contact#%u -> %s \"%s\"", handles[i],
+ my_statuses[indexes[i]].name, messages[i]);
+
g_hash_table_insert (self->priv->presence_statuses, key,
GUINT_TO_POINTER (indexes[i]));
g_hash_table_insert (self->priv->presence_messages, key,
@@ -566,7 +663,7 @@ tp_tests_contacts_connection_change_presences (
g_str_equal, NULL, (GDestroyNotify) tp_g_value_slice_free);
if (messages[i] != NULL && messages[i][0] != '\0')
- g_hash_table_insert (parameters, "message",
+ g_hash_table_insert (parameters, (gpointer) "message",
tp_g_value_slice_new_string (messages[i]));
g_hash_table_insert (presences, key, tp_presence_status_new (indexes[i],
@@ -589,6 +686,7 @@ tp_tests_contacts_connection_change_avatar_tokens (TpTestsContactsConnection *se
for (i = 0; i < n; i++)
{
+ g_debug ("contact#%u -> %s", handles[i], tokens[i]);
g_hash_table_insert (self->priv->avatars,
GUINT_TO_POINTER (handles[i]), avatar_data_new (NULL, NULL, tokens[i]));
tp_svc_connection_interface_avatars_emit_avatar_updated (self,
@@ -621,6 +719,7 @@ tp_tests_contacts_connection_change_locations (TpTestsContactsConnection *self,
for (i = 0; i < n; i++)
{
+ g_debug ("contact#%u ->", handles[i]);
tp_asv_dump (locations[i]);
g_hash_table_insert (self->priv->locations,
GUINT_TO_POINTER (handles[i]), g_hash_table_ref (locations[i]));
@@ -682,50 +781,7 @@ my_get_alias_flags (TpSvcConnectionInterfaceAliasing *aliasing,
TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context);
tp_svc_connection_interface_aliasing_return_from_get_alias_flags (context,
- 0);
-}
-
-static void
-my_get_aliases (TpSvcConnectionInterfaceAliasing *aliasing,
- const GArray *contacts,
- DBusGMethodInvocation *context)
-{
- TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (aliasing);
- TpBaseConnection *base = TP_BASE_CONNECTION (aliasing);
- TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (base,
- TP_HANDLE_TYPE_CONTACT);
- GHashTable *result;
- GError *error = NULL;
- guint i;
-
- TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context);
-
- if (!tp_handles_are_valid (contact_repo, contacts, FALSE, &error))
- {
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- return;
- }
-
- result = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
-
- for (i = 0; i < contacts->len; i++)
- {
- TpHandle handle = g_array_index (contacts, TpHandle, i);
- const gchar *alias = g_hash_table_lookup (self->priv->aliases,
- GUINT_TO_POINTER (handle));
-
- if (alias == NULL)
- g_hash_table_insert (result, GUINT_TO_POINTER (handle),
- (gchar *) tp_handle_inspect (contact_repo, handle));
- else
- g_hash_table_insert (result, GUINT_TO_POINTER (handle),
- (gchar *) alias);
- }
-
- tp_svc_connection_interface_aliasing_return_from_get_aliases (context,
- result);
- g_hash_table_unref (result);
+ TP_CONNECTION_ALIAS_FLAG_USER_SET);
}
static void
@@ -774,109 +830,68 @@ my_request_aliases (TpSvcConnectionInterfaceAliasing *aliasing,
}
static void
-init_aliasing (gpointer g_iface,
- gpointer iface_data)
-{
- TpSvcConnectionInterfaceAliasingClass *klass = g_iface;
-
-#define IMPLEMENT(x) tp_svc_connection_interface_aliasing_implement_##x (\
- klass, my_##x)
- IMPLEMENT(get_alias_flags);
- IMPLEMENT(request_aliases);
- IMPLEMENT(get_aliases);
- /* IMPLEMENT(set_aliases); */
-#undef IMPLEMENT
-}
-
-static void
-my_get_avatar_tokens (TpSvcConnectionInterfaceAvatars *avatars,
- const GArray *contacts,
- DBusGMethodInvocation *context)
+my_set_aliases (TpSvcConnectionInterfaceAliasing *aliasing,
+ GHashTable *table,
+ DBusGMethodInvocation *context)
{
- TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (avatars);
- TpBaseConnection *base = TP_BASE_CONNECTION (avatars);
+ TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (aliasing);
+ TpBaseConnection *base = TP_BASE_CONNECTION (aliasing);
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (base,
TP_HANDLE_TYPE_CONTACT);
+ guint n;
+ GArray *handles;
+ GPtrArray *aliases;
+ GHashTableIter iter;
+ gpointer key, value;
GError *error = NULL;
- GHashTable *result;
- guint i;
-
- TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context);
- if (!tp_handles_are_valid (contact_repo, contacts, FALSE, &error))
+ /* Convert the hash table to arrays of handles and aliases */
+ n = g_hash_table_size (table);
+ handles = g_array_sized_new (FALSE, FALSE, sizeof (TpHandle), n);
+ aliases = g_ptr_array_sized_new (n);
+ g_hash_table_iter_init (&iter, table);
+ while (g_hash_table_iter_next (&iter, &key, &value))
{
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- return;
- }
+ TpHandle handle = GPOINTER_TO_UINT (key);
- result = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
+ g_array_append_val (handles, handle);
+ g_ptr_array_add (aliases, value);
+ }
+ g_assert_cmpuint (handles->len, ==, n);
+ g_assert_cmpuint (aliases->len, ==, n);
- for (i = 0; i < contacts->len; i++)
+ /* Verify all handles are valid */
+ if (!tp_handles_are_valid (contact_repo, handles, FALSE, &error))
{
- TpHandle handle = g_array_index (contacts, TpHandle, i);
- AvatarData *a = g_hash_table_lookup (self->priv->avatars,
- GUINT_TO_POINTER (handle));
+ dbus_g_method_return_error (context, error);
+ g_clear_error (&error);
+ goto out;
+ }
- if (a == NULL || a->token == NULL)
- {
- /* we're expected to do a round-trip to the server to find out
- * their token, so we have to give some sort of result. Assume
- * no avatar, here */
- a = avatar_data_new (NULL, NULL, "");
- g_hash_table_insert (self->priv->avatars,
- GUINT_TO_POINTER (handle), a);
- tp_svc_connection_interface_avatars_emit_avatar_updated (self,
- handle, a->token);
- }
+ /* Change aliases */
+ tp_tests_contacts_connection_change_aliases (self, n,
+ (const TpHandle *) handles->data,
+ (const gchar * const *) aliases->pdata);
- g_hash_table_insert (result, GUINT_TO_POINTER (handle),
- a->token);
- }
+ tp_svc_connection_interface_aliasing_return_from_set_aliases (context);
- tp_svc_connection_interface_avatars_return_from_get_known_avatar_tokens (
- context, result);
- g_hash_table_unref (result);
+out:
+ g_array_unref (handles);
+ g_ptr_array_unref (aliases);
}
static void
-my_get_known_avatar_tokens (TpSvcConnectionInterfaceAvatars *avatars,
- const GArray *contacts,
- DBusGMethodInvocation *context)
+init_aliasing (gpointer g_iface,
+ gpointer iface_data)
{
- TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (avatars);
- TpBaseConnection *base = TP_BASE_CONNECTION (avatars);
- TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (base,
- TP_HANDLE_TYPE_CONTACT);
- GError *error = NULL;
- GHashTable *result;
- guint i;
-
- TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context);
-
- if (!tp_handles_are_valid (contact_repo, contacts, FALSE, &error))
- {
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- return;
- }
-
- result = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
-
- for (i = 0; i < contacts->len; i++)
- {
- TpHandle handle = g_array_index (contacts, TpHandle, i);
- AvatarData *a = g_hash_table_lookup (self->priv->avatars,
- GUINT_TO_POINTER (handle));
- const gchar *token = a ? a->token : NULL;
-
- g_hash_table_insert (result, GUINT_TO_POINTER (handle),
- (gchar *) (token != NULL ? token : ""));
- }
+ TpSvcConnectionInterfaceAliasingClass *klass = g_iface;
- tp_svc_connection_interface_avatars_return_from_get_known_avatar_tokens (
- context, result);
- g_hash_table_unref (result);
+#define IMPLEMENT(x) tp_svc_connection_interface_aliasing_implement_##x (\
+ klass, my_##x)
+ IMPLEMENT(get_alias_flags);
+ IMPLEMENT(request_aliases);
+ IMPLEMENT(set_aliases);
+#undef IMPLEMENT
}
static void
@@ -943,8 +958,6 @@ init_avatars (gpointer g_iface,
#define IMPLEMENT(x) tp_svc_connection_interface_avatars_implement_##x (\
klass, my_##x)
/* IMPLEMENT(get_avatar_requirements); */
- IMPLEMENT(get_avatar_tokens);
- IMPLEMENT(get_known_avatar_tokens);
/* IMPLEMENT(request_avatar); */
IMPLEMENT(request_avatars);
/* IMPLEMENT(set_avatar); */
@@ -952,113 +965,6 @@ init_avatars (gpointer g_iface,
#undef IMPLEMENT
}
-static void
-my_get_locations (TpSvcConnectionInterfaceLocation *avatars,
- const GArray *contacts,
- DBusGMethodInvocation *context)
-{
- TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (avatars);
- TpBaseConnection *base = TP_BASE_CONNECTION (avatars);
- TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (base,
- TP_HANDLE_TYPE_CONTACT);
- GError *error = NULL;
- GHashTable *result;
- guint i;
-
- TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context);
-
- if (!tp_handles_are_valid (contact_repo, contacts, FALSE, &error))
- {
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- return;
- }
-
- result = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
-
- for (i = 0; i < contacts->len; i++)
- {
- TpHandle handle = g_array_index (contacts, TpHandle, i);
- GHashTable *location = g_hash_table_lookup (self->priv->locations,
- GUINT_TO_POINTER (handle));
-
- if (location != NULL)
- {
- g_hash_table_insert (result, GUINT_TO_POINTER (handle), location);
- }
- }
-
- tp_svc_connection_interface_location_return_from_get_locations (
- context, result);
- g_hash_table_unref (result);
-}
-
-static void
-init_location (gpointer g_iface,
- gpointer iface_data)
-{
- TpSvcConnectionInterfaceLocationClass *klass = g_iface;
-
-#define IMPLEMENT(x) tp_svc_connection_interface_location_implement_##x (\
- klass, my_##x)
- IMPLEMENT(get_locations);
-#undef IMPLEMENT
-}
-
-static void
-my_get_contact_capabilities (TpSvcConnectionInterfaceContactCapabilities *obj,
- const GArray *contacts,
- DBusGMethodInvocation *context)
-{
- TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (obj);
- TpBaseConnection *base = TP_BASE_CONNECTION (obj);
- TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (base,
- TP_HANDLE_TYPE_CONTACT);
- GError *error = NULL;
- GHashTable *result;
- guint i;
-
- TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context);
-
- if (!tp_handles_are_valid (contact_repo, contacts, FALSE, &error))
- {
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- return;
- }
-
- result = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
-
- for (i = 0; i < contacts->len; i++)
- {
- TpHandle handle = g_array_index (contacts, TpHandle, i);
- GPtrArray *arr = g_hash_table_lookup (self->priv->capabilities,
- GUINT_TO_POINTER (handle));
-
- if (arr != NULL)
- {
- g_hash_table_insert (result, GUINT_TO_POINTER (handle), arr);
- }
- }
-
- tp_svc_connection_interface_contact_capabilities_return_from_get_contact_capabilities (
- context, result);
-
- g_hash_table_unref (result);
-}
-
-static void
-init_contact_caps (gpointer g_iface,
- gpointer iface_data)
-{
- TpSvcConnectionInterfaceContactCapabilitiesClass *klass = g_iface;
-
-#define IMPLEMENT(x) tp_svc_connection_interface_contact_capabilities_implement_##x (\
- klass, my_##x)
- IMPLEMENT(get_contact_capabilities);
-#undef IMPLEMENT
-}
-
static GPtrArray *
lookup_contact_info (TpTestsContactsConnection *self,
TpHandle handle)
@@ -1073,7 +979,10 @@ lookup_contact_info (TpTestsContactsConnection *self,
g_ptr_array_ref (ret));
}
- return ret;
+ if (ret == NULL)
+ return g_ptr_array_new ();
+
+ return g_ptr_array_ref (ret);
}
static void
@@ -1104,6 +1013,7 @@ my_refresh_contact_info (TpSvcConnectionInterfaceContactInfo *obj,
tp_svc_connection_interface_contact_info_emit_contact_info_changed (self,
handle, arr);
+ g_ptr_array_unref (arr);
}
tp_svc_connection_interface_contact_info_return_from_refresh_contact_info (
@@ -1135,6 +1045,8 @@ my_request_contact_info (TpSvcConnectionInterfaceContactInfo *obj,
tp_svc_connection_interface_contact_info_return_from_request_contact_info (
context, ret);
+
+ g_ptr_array_unref (ret);
}
static void
@@ -1156,8 +1068,8 @@ my_set_contact_info (TpSvcConnectionInterfaceContactInfo *obj,
g_ptr_array_add (copy, g_value_array_copy (g_ptr_array_index (info, i)));
self_handle = tp_base_connection_get_self_handle (base);
- g_hash_table_insert (self->priv->contact_info, GUINT_TO_POINTER (self_handle),
- copy);
+ tp_tests_contacts_connection_change_contact_info (self, self_handle, copy);
+ g_ptr_array_unref (copy);
tp_svc_connection_interface_contact_info_return_from_set_contact_info (
context);
@@ -1176,91 +1088,3 @@ init_contact_info (gpointer g_iface,
IMPLEMENT (set_contact_info);
#undef IMPLEMENT
}
-
-/* =============== Legacy version (no Contacts interface) ================= */
-
-G_DEFINE_TYPE (TpTestsLegacyContactsConnection,
- tp_tests_legacy_contacts_connection, TP_TESTS_TYPE_CONTACTS_CONNECTION);
-
-enum
-{
- LEGACY_PROP_HAS_IMMORTAL_HANDLES = 1
-};
-
-static void
-legacy_contacts_connection_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id)
- {
- case LEGACY_PROP_HAS_IMMORTAL_HANDLES:
- /* Pretend we don't. */
- g_value_set_boolean (value, FALSE);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-tp_tests_legacy_contacts_connection_init (TpTestsLegacyContactsConnection *self)
-{
-}
-
-static void
-tp_tests_legacy_contacts_connection_class_init (
- TpTestsLegacyContactsConnectionClass *klass)
-{
- /* Leave Contacts out of the interfaces we say are present, so clients
- * won't use it */
- static const gchar *interfaces_always_present[] = {
- TP_IFACE_CONNECTION_INTERFACE_ALIASING,
- TP_IFACE_CONNECTION_INTERFACE_AVATARS,
- TP_IFACE_CONNECTION_INTERFACE_PRESENCE,
- TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE,
- TP_IFACE_CONNECTION_INTERFACE_LOCATION,
- TP_IFACE_CONNECTION_INTERFACE_REQUESTS,
- NULL };
- TpBaseConnectionClass *base_class =
- (TpBaseConnectionClass *) klass;
- GObjectClass *object_class = (GObjectClass *) klass;
-
- object_class->get_property = legacy_contacts_connection_get_property;
-
- base_class->interfaces_always_present = interfaces_always_present;
-
- g_object_class_override_property (object_class,
- LEGACY_PROP_HAS_IMMORTAL_HANDLES, "has-immortal-handles");
-}
-
-/* =============== No Requests and no ContactCapabilities ================= */
-
-G_DEFINE_TYPE (TpTestsNoRequestsConnection, tp_tests_no_requests_connection,
- TP_TESTS_TYPE_CONTACTS_CONNECTION);
-
-static void
-tp_tests_no_requests_connection_init (TpTestsNoRequestsConnection *self)
-{
-}
-
-static void
-tp_tests_no_requests_connection_class_init (
- TpTestsNoRequestsConnectionClass *klass)
-{
- static const gchar *interfaces_always_present[] = {
- TP_IFACE_CONNECTION_INTERFACE_ALIASING,
- TP_IFACE_CONNECTION_INTERFACE_AVATARS,
- TP_IFACE_CONNECTION_INTERFACE_CONTACTS,
- TP_IFACE_CONNECTION_INTERFACE_PRESENCE,
- TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE,
- TP_IFACE_CONNECTION_INTERFACE_LOCATION,
- NULL };
- TpBaseConnectionClass *base_class =
- (TpBaseConnectionClass *) klass;
-
- base_class->interfaces_always_present = interfaces_always_present;
-}
diff --git a/tests/lib/contacts-conn.h b/tests/lib/contacts-conn.h
index 461cfb6..eb4a24f 100644
--- a/tests/lib/contacts-conn.h
+++ b/tests/lib/contacts-conn.h
@@ -29,6 +29,8 @@ struct _TpTestsContactsConnectionClass {
TpPresenceMixinClass presence_mixin;
TpContactsMixinClass contacts_mixin;
TpDBusPropertiesMixinClass properties_class;
+
+ TpContactsMixinFillContactAttributesFunc fill_client_types;
};
struct _TpTestsContactsConnection {
@@ -105,78 +107,6 @@ void tp_tests_contacts_connection_set_default_contact_info (
TpTestsContactsConnection *self,
GPtrArray *info);
-/* Legacy version (no Contacts interface, and no immortal handles) */
-
-typedef struct _TpTestsLegacyContactsConnection TpTestsLegacyContactsConnection;
-typedef struct _TpTestsLegacyContactsConnectionClass TpTestsLegacyContactsConnectionClass;
-typedef struct _TpTestsLegacyContactsConnectionPrivate
- TpTestsLegacyContactsConnectionPrivate;
-
-struct _TpTestsLegacyContactsConnectionClass {
- TpTestsContactsConnectionClass parent_class;
-};
-
-struct _TpTestsLegacyContactsConnection {
- TpTestsContactsConnection parent;
-
- TpTestsLegacyContactsConnectionPrivate *priv;
-};
-
-GType tp_tests_legacy_contacts_connection_get_type (void);
-
-/* TYPE MACROS */
-#define TP_TESTS_TYPE_LEGACY_CONTACTS_CONNECTION \
- (tp_tests_legacy_contacts_connection_get_type ())
-#define LEGACY_TP_TESTS_CONTACTS_CONNECTION(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), TP_TESTS_TYPE_LEGACY_CONTACTS_CONNECTION, \
- TpTestsLegacyContactsConnection))
-#define LEGACY_TP_TESTS_CONTACTS_CONNECTION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), TP_TESTS_TYPE_LEGACY_CONTACTS_CONNECTION, \
- TpTestsLegacyContactsConnectionClass))
-#define TP_TESTS_LEGACY_CONTACTS_IS_CONNECTION(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), TP_TESTS_TYPE_LEGACY_CONTACTS_CONNECTION))
-#define TP_TESTS_LEGACY_CONTACTS_IS_CONNECTION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), TP_TESTS_TYPE_LEGACY_CONTACTS_CONNECTION))
-#define LEGACY_TP_TESTS_CONTACTS_CONNECTION_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TESTS_TYPE_LEGACY_CONTACTS_CONNECTION, \
- TpTestsLegacyContactsConnectionClass))
-
-/* No Requests version */
-
-typedef struct _TpTestsNoRequestsConnection TpTestsNoRequestsConnection;
-typedef struct _TpTestsNoRequestsConnectionClass TpTestsNoRequestsConnectionClass;
-typedef struct _TpTestsNoRequestsConnectionPrivate
- TpTestsNoRequestsConnectionPrivate;
-
-struct _TpTestsNoRequestsConnectionClass {
- TpTestsContactsConnectionClass parent_class;
-};
-
-struct _TpTestsNoRequestsConnection {
- TpTestsContactsConnection parent;
-
- TpTestsNoRequestsConnectionPrivate *priv;
-};
-
-GType tp_tests_no_requests_connection_get_type (void);
-
-/* TYPE MACROS */
-#define TP_TESTS_TYPE_NO_REQUESTS_CONNECTION \
- (tp_tests_no_requests_connection_get_type ())
-#define TP_TESTS_NO_REQUESTS_CONNECTION(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), TP_TESTS_TYPE_NO_REQUESTS_CONNECTION, \
- TpTestsNoRequestsConnection))
-#define TP_TESTS_NO_REQUESTS_CONNECTION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), TP_TESTS_TYPE_NO_REQUESTS_CONNECTION, \
- TpTestsNoRequestsConnectionClass))
-#define TP_TESTS_NO_REQUESTS_IS_CONNECTION(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), TP_TESTS_TYPE_NO_REQUESTS_CONNECTION))
-#define TP_TESTS_NO_REQUESTS_IS_CONNECTION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), TP_TESTS_TYPE_NO_REQUESTS_CONNECTION))
-#define TP_TESTS_NO_REQUESTS_CONNECTION_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TESTS_TYPE_NO_REQUESTS_CONNECTION, \
- TpTestsNoRequestsConnectionClass))
-
G_END_DECLS
#endif /* ifndef __TP_TESTS_CONTACTS_CONN_H__ */
diff --git a/tests/lib/simple-account-manager.c b/tests/lib/simple-account-manager.c
index a56c96e..e5bddbc 100644
--- a/tests/lib/simple-account-manager.c
+++ b/tests/lib/simple-account-manager.c
@@ -1,7 +1,7 @@
/*
* simple-account-manager.c - a simple account manager service.
*
- * Copyright (C) 2007-2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2007-2012 Collabora Ltd. <http://www.collabora.co.uk/>
* Copyright (C) 2007-2008 Nokia Corporation
*
* Copying and distribution of this file, with or without modification,
@@ -9,6 +9,8 @@
* notice and this notice are preserved.
*/
+#include "config.h"
+
#include "simple-account-manager.h"
#include <telepathy-glib/telepathy-glib.h>
@@ -29,29 +31,22 @@ G_DEFINE_TYPE_WITH_CODE (TpTestsSimpleAccountManager,
/* TP_IFACE_ACCOUNT_MANAGER is implied */
static const char *ACCOUNT_MANAGER_INTERFACES[] = { NULL };
-static gchar *VALID_ACCOUNTS[] = {
- "/org/freedesktop/Telepathy/Account/fakecm/fakeproto/validaccount",
- NULL };
-
-static gchar *INVALID_ACCOUNTS[] = {
- "/org/freedesktop/Telepathy/Account/fakecm/fakeproto/invalidaccount",
- NULL };
-
enum
{
PROP_0,
PROP_INTERFACES,
- PROP_VALID_ACCOUNTS,
- PROP_INVALID_ACCOUNTS,
+ PROP_USABLE_ACCOUNTS,
+ PROP_UNUSABLE_ACCOUNTS,
};
struct _TpTestsSimpleAccountManagerPrivate
{
- int dummy;
+ GPtrArray *usable_accounts;
+ GPtrArray *unusable_accounts;
};
static void
-tp_tests_simple_account_manager_create_account (TpSvcAccountManager *self,
+tp_tests_simple_account_manager_create_account (TpSvcAccountManager *svc,
const gchar *in_Connection_Manager,
const gchar *in_Protocol,
const gchar *in_Display_Name,
@@ -59,9 +54,24 @@ tp_tests_simple_account_manager_create_account (TpSvcAccountManager *self,
GHashTable *in_Properties,
DBusGMethodInvocation *context)
{
- const gchar *out_Account = "/some/fake/account/i/think";
-
- tp_svc_account_manager_return_from_create_account (context, out_Account);
+ TpTestsSimpleAccountManager *self = (TpTestsSimpleAccountManager *) svc;
+ const gchar *out = TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/lospolloshermanos";
+
+ /* if we have fail=yes as a parameter, make the call fail */
+ if (!tp_strdiff (tp_asv_get_string (in_Parameters, "fail"), "yes"))
+ {
+ GError e = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "loldongs" };
+ dbus_g_method_return_error (context, &e);
+ return;
+ }
+
+ self->create_cm = g_strdup (in_Connection_Manager);
+ self->create_protocol = g_strdup (in_Protocol);
+ self->create_display_name = g_strdup (in_Display_Name);
+ self->create_parameters = g_hash_table_ref (in_Parameters);
+ self->create_properties = g_hash_table_ref (in_Properties);
+
+ tp_svc_account_manager_return_from_create_account (context, out);
}
static void
@@ -80,6 +90,9 @@ tp_tests_simple_account_manager_init (TpTestsSimpleAccountManager *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
TP_TESTS_TYPE_SIMPLE_ACCOUNT_MANAGER, TpTestsSimpleAccountManagerPrivate);
+
+ self->priv->usable_accounts = g_ptr_array_new_with_free_func (g_free);
+ self->priv->unusable_accounts = g_ptr_array_new_with_free_func (g_free);
}
static void
@@ -88,30 +101,19 @@ tp_tests_simple_account_manager_get_property (GObject *object,
GValue *value,
GParamSpec *spec)
{
- GPtrArray *accounts;
- guint i = 0;
+ TpTestsSimpleAccountManager *self = SIMPLE_ACCOUNT_MANAGER (object);
switch (property_id) {
case PROP_INTERFACES:
g_value_set_boxed (value, ACCOUNT_MANAGER_INTERFACES);
break;
- case PROP_VALID_ACCOUNTS:
- accounts = g_ptr_array_new ();
-
- for (i=0; VALID_ACCOUNTS[i] != NULL; i++)
- g_ptr_array_add (accounts, g_strdup (VALID_ACCOUNTS[i]));
-
- g_value_take_boxed (value, accounts);
+ case PROP_USABLE_ACCOUNTS:
+ g_value_set_boxed (value, self->priv->usable_accounts);
break;
- case PROP_INVALID_ACCOUNTS:
- accounts = g_ptr_array_new ();
-
- for (i=0; INVALID_ACCOUNTS[i] != NULL; i++)
- g_ptr_array_add (accounts, g_strdup (VALID_ACCOUNTS[i]));
-
- g_value_take_boxed (value, accounts);
+ case PROP_UNUSABLE_ACCOUNTS:
+ g_value_set_boxed (value, self->priv->unusable_accounts);
break;
default:
@@ -120,6 +122,24 @@ tp_tests_simple_account_manager_get_property (GObject *object,
}
}
+static void
+tp_tests_simple_account_manager_finalize (GObject *object)
+{
+ TpTestsSimpleAccountManager *self = SIMPLE_ACCOUNT_MANAGER (object);
+
+ g_ptr_array_unref (self->priv->usable_accounts);
+ g_ptr_array_unref (self->priv->unusable_accounts);
+
+ tp_clear_pointer (&self->create_cm, g_free);
+ tp_clear_pointer (&self->create_protocol, g_free);
+ tp_clear_pointer (&self->create_display_name, g_free);
+ tp_clear_pointer (&self->create_parameters, g_hash_table_unref);
+ tp_clear_pointer (&self->create_properties, g_hash_table_unref);
+
+ G_OBJECT_CLASS (tp_tests_simple_account_manager_parent_class)->finalize (
+ object);
+}
+
/**
* This class currently only provides the minimum for
* tp_account_manager_prepare to succeed. This turns out to be only a working
@@ -136,8 +156,8 @@ tp_tests_simple_account_manager_class_init (
static TpDBusPropertiesMixinPropImpl am_props[] = {
{ "Interfaces", "interfaces", NULL },
- { "ValidAccounts", "valid-accounts", NULL },
- { "InvalidAccounts", "invalid-accounts", NULL },
+ { "UsableAccounts", "usable-accounts", NULL },
+ { "UnusableAccounts", "unusable-accounts", NULL },
/*
{ "SupportedAccountProperties", "supported-account-properties", NULL },
*/
@@ -154,6 +174,7 @@ tp_tests_simple_account_manager_class_init (
};
g_type_class_add_private (klass, sizeof (TpTestsSimpleAccountManagerPrivate));
+ object_class->finalize = tp_tests_simple_account_manager_finalize;
object_class->get_property = tp_tests_simple_account_manager_get_property;
param_spec = g_param_spec_boxed ("interfaces", "Extra D-Bus interfaces",
@@ -161,18 +182,60 @@ tp_tests_simple_account_manager_class_init (
G_TYPE_STRV,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_INTERFACES, param_spec);
- param_spec = g_param_spec_boxed ("valid-accounts", "Valid accounts",
- "The accounts which are valid on this account. This may be a lie.",
+ param_spec = g_param_spec_boxed ("usable-accounts", "Usable accounts",
+ "The accounts which are usable on this account manager. This may be a lie.",
TP_ARRAY_TYPE_OBJECT_PATH_LIST,
G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_VALID_ACCOUNTS, param_spec);
- param_spec = g_param_spec_boxed ("invalid-accounts", "Invalid accounts",
- "The accounts which are invalid on this account. This may be a lie.",
+ g_object_class_install_property (object_class, PROP_USABLE_ACCOUNTS, param_spec);
+ param_spec = g_param_spec_boxed ("unusable-accounts", "Unusable accounts",
+ "The accounts which are unusable on this account manager. This may be a lie.",
TP_ARRAY_TYPE_OBJECT_PATH_LIST,
G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_INVALID_ACCOUNTS, param_spec);
+ g_object_class_install_property (object_class, PROP_UNUSABLE_ACCOUNTS, param_spec);
klass->dbus_props_class.interfaces = prop_interfaces;
tp_dbus_properties_mixin_class_init (object_class,
G_STRUCT_OFFSET (TpTestsSimpleAccountManagerClass, dbus_props_class));
}
+
+static void
+remove_from_array (GPtrArray *array, const gchar *str)
+{
+ guint i;
+
+ for (i = 0; i < array->len; i++)
+ if (!tp_strdiff (str, g_ptr_array_index (array, i)))
+ {
+ g_ptr_array_remove_index_fast (array, i);
+ return;
+ }
+}
+
+void
+tp_tests_simple_account_manager_add_account (
+ TpTestsSimpleAccountManager *self,
+ const gchar *object_path,
+ gboolean usable)
+{
+ remove_from_array (self->priv->usable_accounts, object_path);
+ remove_from_array (self->priv->unusable_accounts, object_path);
+
+ if (usable)
+ g_ptr_array_add (self->priv->usable_accounts, g_strdup (object_path));
+ else
+ g_ptr_array_add (self->priv->unusable_accounts, g_strdup (object_path));
+
+ tp_svc_account_manager_emit_account_usability_changed (self, object_path,
+ usable);
+}
+
+void
+tp_tests_simple_account_manager_remove_account (
+ TpTestsSimpleAccountManager *self,
+ const gchar *object_path)
+{
+ remove_from_array (self->priv->usable_accounts, object_path);
+ remove_from_array (self->priv->unusable_accounts, object_path);
+
+ tp_svc_account_manager_emit_account_removed (self, object_path);
+}
diff --git a/tests/lib/simple-account-manager.h b/tests/lib/simple-account-manager.h
index 5b9d2a4..cc65f09 100644
--- a/tests/lib/simple-account-manager.h
+++ b/tests/lib/simple-account-manager.h
@@ -1,7 +1,7 @@
/*
* simple-account-manager.h - header for a simple account manager service.
*
- * Copyright (C) 2007-2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2007-2012 Collabora Ltd. <http://www.collabora.co.uk/>
* Copyright (C) 2007-2008 Nokia Corporation
*
* Copying and distribution of this file, with or without modification,
@@ -30,6 +30,12 @@ struct _TpTestsSimpleAccountManagerClass {
struct _TpTestsSimpleAccountManager {
GObject parent;
+ gchar *create_cm;
+ gchar *create_protocol;
+ gchar *create_display_name;
+ GHashTable *create_parameters;
+ GHashTable *create_properties;
+
TpTestsSimpleAccountManagerPrivate *priv;
};
@@ -52,6 +58,14 @@ GType tp_tests_simple_account_manager_get_type (void);
(G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TESTS_TYPE_SIMPLE_ACCOUNT_MANAGER, \
TpTestsSimpleAccountManagerClass))
+void tp_tests_simple_account_manager_add_account (
+ TpTestsSimpleAccountManager *self,
+ const gchar *object_path,
+ gboolean usable);
+
+void tp_tests_simple_account_manager_remove_account (
+ TpTestsSimpleAccountManager *self,
+ const gchar *object_path);
G_END_DECLS
diff --git a/tests/lib/simple-account.c b/tests/lib/simple-account.c
index 9a298ad..67ed0f4 100644
--- a/tests/lib/simple-account.c
+++ b/tests/lib/simple-account.c
@@ -1,13 +1,15 @@
/*
* simple-account.c - a simple account service.
*
- * Copyright (C) 2010 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2010-2012 Collabora Ltd. <http://www.collabora.co.uk/>
*
* Copying and distribution of this file, with or without modification,
* are permitted in any medium without royalty provided the copyright
* notice and this notice are preserved.
*/
+#include "config.h"
+
#include "simple-account.h"
#include <telepathy-glib/telepathy-glib.h>
@@ -20,6 +22,10 @@ G_DEFINE_TYPE_WITH_CODE (TpTestsSimpleAccount,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_ACCOUNT,
account_iface_init);
+ G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_ACCOUNT_INTERFACE_AVATAR,
+ NULL);
+ G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_ACCOUNT_INTERFACE_ADDRESSING,
+ NULL);
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_ACCOUNT_INTERFACE_STORAGE,
NULL);
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_DBUS_PROPERTIES,
@@ -28,6 +34,7 @@ G_DEFINE_TYPE_WITH_CODE (TpTestsSimpleAccount,
/* TP_IFACE_ACCOUNT is implied */
static const char *ACCOUNT_INTERFACES[] = {
+ TP_IFACE_ACCOUNT_INTERFACE_ADDRESSING,
TP_IFACE_ACCOUNT_INTERFACE_STORAGE,
NULL };
@@ -37,7 +44,7 @@ enum
PROP_INTERFACES,
PROP_DISPLAY_NAME,
PROP_ICON,
- PROP_VALID,
+ PROP_USABLE,
PROP_ENABLED,
PROP_NICKNAME,
PROP_PARAMETERS,
@@ -50,25 +57,63 @@ enum
PROP_REQUESTED_PRESENCE,
PROP_NORMALIZED_NAME,
PROP_HAS_BEEN_ONLINE,
+ PROP_URI_SCHEMES,
PROP_STORAGE_PROVIDER,
PROP_STORAGE_IDENTIFIER,
PROP_STORAGE_SPECIFIC_INFORMATION,
- PROP_STORAGE_RESTRICTIONS
+ PROP_STORAGE_RESTRICTIONS,
+ PROP_AVATAR,
+ PROP_SUPERSEDES,
+ N_PROPS
};
struct _TpTestsSimpleAccountPrivate
{
- gpointer unused;
+ TpConnectionPresenceType presence;
+ gchar *presence_status;
+ gchar *presence_msg;
+ gchar *connection_path;
+ gboolean enabled;
GHashTable *parameters;
};
static void
+tp_tests_simple_account_update_parameters (TpSvcAccount *svc,
+ GHashTable *parameters,
+ const gchar **unset_parameters,
+ DBusGMethodInvocation *context)
+{
+ GPtrArray *reconnect_required = g_ptr_array_new ();
+ GHashTableIter iter;
+ gpointer k;
+ guint i;
+
+ /* We don't actually store any parameters, but for the purposes
+ * of this method we pretend that every parameter provided is
+ * valid and requires reconnection. */
+
+ g_hash_table_iter_init (&iter, parameters);
+
+ while (g_hash_table_iter_next (&iter, &k, NULL))
+ g_ptr_array_add (reconnect_required, k);
+
+ for (i = 0; unset_parameters != NULL && unset_parameters[i] != NULL; i++)
+ g_ptr_array_add (reconnect_required, (gchar *) unset_parameters[i]);
+
+ g_ptr_array_add (reconnect_required, NULL);
+
+ tp_svc_account_return_from_update_parameters (context,
+ (const gchar **) reconnect_required->pdata);
+ g_ptr_array_unref (reconnect_required);
+}
+
+static void
account_iface_init (gpointer klass,
gpointer unused G_GNUC_UNUSED)
{
#define IMPLEMENT(x) tp_svc_account_implement_##x (\
klass, tp_tests_simple_account_##x)
- /* TODO */
+ IMPLEMENT (update_parameters);
#undef IMPLEMENT
}
@@ -78,10 +123,19 @@ tp_tests_simple_account_init (TpTestsSimpleAccount *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TP_TESTS_TYPE_SIMPLE_ACCOUNT,
TpTestsSimpleAccountPrivate);
+
+ self->priv->presence = TP_CONNECTION_PRESENCE_TYPE_AWAY;
+ self->priv->presence_status = g_strdup ("currently-away");
+ self->priv->presence_msg = g_strdup ("this is my CurrentPresence");
+ self->priv->connection_path = g_strdup ("/");
+ self->priv->enabled = TRUE;
self->priv->parameters = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free, (GDestroyNotify) tp_g_value_slice_free);
}
+/* you may have noticed this is not entirely realistic */
+static const gchar * const uri_schemes[] = { "about", "telnet", NULL };
+
static gpointer
_parameters_hash_copy_key (gpointer boxed)
{
@@ -97,7 +151,6 @@ _parameters_hash_copy_value (gpointer boxed)
return ret;
}
-
static void
tp_tests_simple_account_set_property (GObject *object,
guint param_id,
@@ -118,23 +171,15 @@ tp_tests_simple_account_set_property (GObject *object,
}
}
-
static void
tp_tests_simple_account_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *spec)
+ guint property_id,
+ GValue *value,
+ GParamSpec *spec)
{
TpTestsSimpleAccount *self = TP_TESTS_SIMPLE_ACCOUNT (object);
- GValueArray *presence;
GValue identifier = { 0, };
- presence = tp_value_array_build (3,
- G_TYPE_UINT, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE,
- G_TYPE_STRING, "available",
- G_TYPE_STRING, "",
- G_TYPE_INVALID);
-
g_value_init (&identifier, G_TYPE_STRING);
g_value_set_string (&identifier, "unique-identifier");
@@ -148,11 +193,11 @@ tp_tests_simple_account_get_property (GObject *object,
case PROP_ICON:
g_value_set_string (value, "");
break;
- case PROP_VALID:
+ case PROP_USABLE:
g_value_set_boolean (value, TRUE);
break;
case PROP_ENABLED:
- g_value_set_boolean (value, TRUE);
+ g_value_set_boolean (value, self->priv->enabled);
break;
case PROP_NICKNAME:
g_value_set_string (value, "badger");
@@ -161,13 +206,17 @@ tp_tests_simple_account_get_property (GObject *object,
g_value_set_boxed (value, self->priv->parameters);
break;
case PROP_AUTOMATIC_PRESENCE:
- g_value_set_boxed (value, presence);
+ g_value_take_boxed (value, tp_value_array_build (3,
+ G_TYPE_UINT, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE,
+ G_TYPE_STRING, "automatically-available",
+ G_TYPE_STRING, "this is my AutomaticPresence",
+ G_TYPE_INVALID));
break;
case PROP_CONNECT_AUTO:
g_value_set_boolean (value, FALSE);
break;
case PROP_CONNECTION:
- g_value_set_boxed (value, "/");
+ g_value_set_boxed (value, self->priv->connection_path);
break;
case PROP_CONNECTION_STATUS:
g_value_set_uint (value, TP_CONNECTION_STATUS_CONNECTED);
@@ -176,19 +225,27 @@ tp_tests_simple_account_get_property (GObject *object,
g_value_set_uint (value, TP_CONNECTION_STATUS_REASON_REQUESTED);
break;
case PROP_CURRENT_PRESENCE:
- g_value_set_boxed (value, presence);
+ g_value_take_boxed (value, tp_value_array_build (3,
+ G_TYPE_UINT, self->priv->presence,
+ G_TYPE_STRING, self->priv->presence_status,
+ G_TYPE_STRING, self->priv->presence_msg,
+ G_TYPE_INVALID));
break;
case PROP_REQUESTED_PRESENCE:
- g_value_set_boxed (value, presence);
+ g_value_take_boxed (value, tp_value_array_build (3,
+ G_TYPE_UINT, TP_CONNECTION_PRESENCE_TYPE_BUSY,
+ G_TYPE_STRING, "requesting",
+ G_TYPE_STRING, "this is my RequestedPresence",
+ G_TYPE_INVALID));
break;
case PROP_NORMALIZED_NAME:
- g_value_set_string (value, "");
+ g_value_set_string (value, "bob.mcbadgers@example.com");
break;
case PROP_HAS_BEEN_ONLINE:
g_value_set_boolean (value, TRUE);
break;
case PROP_STORAGE_PROVIDER:
- g_value_set_string (value, "org.freedesktop.Telepathy.glib.test");
+ g_value_set_string (value, "im.telepathy1.glib.test");
break;
case PROP_STORAGE_IDENTIFIER:
g_value_set_boxed (value, &identifier);
@@ -205,15 +262,53 @@ tp_tests_simple_account_get_property (GObject *object,
TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_ENABLED |
TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_PARAMETERS);
break;
+ case PROP_URI_SCHEMES:
+ g_value_set_boxed (value, uri_schemes);
+ break;
+ case PROP_AVATAR:
+ {
+ GArray *arr = g_array_new (FALSE, FALSE, sizeof (char));
+
+ /* includes NUL for simplicity */
+ g_array_append_vals (arr, ":-)", 4);
+
+ g_value_take_boxed (value,
+ tp_value_array_build (2,
+ TP_TYPE_UCHAR_ARRAY, arr,
+ G_TYPE_STRING, "text/plain",
+ G_TYPE_INVALID));
+ g_array_unref (arr);
+ }
+ break;
+ case PROP_SUPERSEDES:
+ {
+ GPtrArray *arr = g_ptr_array_new ();
+
+ g_ptr_array_add (arr,
+ g_strdup (TP_ACCOUNT_OBJECT_PATH_BASE "super/seded/whatever"));
+ g_value_take_boxed (value, arr);
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, spec);
break;
}
- g_boxed_free (TP_STRUCT_TYPE_SIMPLE_PRESENCE, presence);
g_value_unset (&identifier);
}
+static void
+tp_tests_simple_account_finalize (GObject *object)
+{
+ TpTestsSimpleAccount *self = TP_TESTS_SIMPLE_ACCOUNT (object);
+
+ g_free (self->priv->presence_status);
+ g_free (self->priv->presence_msg);
+ g_free (self->priv->connection_path);
+
+ G_OBJECT_CLASS (tp_tests_simple_account_parent_class)->finalize (object);
+}
+
/**
* This class currently only provides the minimum for
* tp_account_prepare to succeed. This turns out to be only a working
@@ -229,7 +324,7 @@ tp_tests_simple_account_class_init (TpTestsSimpleAccountClass *klass)
{ "Interfaces", "interfaces", NULL },
{ "DisplayName", "display-name", NULL },
{ "Icon", "icon", NULL },
- { "Valid", "valid", NULL },
+ { "Usable", "usable", NULL },
{ "Enabled", "enabled", NULL },
{ "Nickname", "nickname", NULL },
{ "Parameters", "parameters", NULL },
@@ -242,6 +337,7 @@ tp_tests_simple_account_class_init (TpTestsSimpleAccountClass *klass)
{ "RequestedPresence", "requested-presence", NULL },
{ "NormalizedName", "normalized-name", NULL },
{ "HasBeenOnline", "has-been-online", NULL },
+ { "Supersedes", "supersedes", NULL },
{ NULL }
};
@@ -253,6 +349,16 @@ tp_tests_simple_account_class_init (TpTestsSimpleAccountClass *klass)
{ NULL },
};
+ static TpDBusPropertiesMixinPropImpl aia_props[] = {
+ { "URISchemes", "uri-schemes", NULL },
+ { NULL },
+ };
+
+ static TpDBusPropertiesMixinPropImpl avatar_props[] = {
+ { "Avatar", "avatar", NULL },
+ { NULL },
+ };
+
static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = {
{ TP_IFACE_ACCOUNT,
tp_dbus_properties_mixin_getter_gobject_properties,
@@ -265,12 +371,24 @@ tp_tests_simple_account_class_init (TpTestsSimpleAccountClass *klass)
NULL,
ais_props
},
+ {
+ TP_IFACE_ACCOUNT_INTERFACE_ADDRESSING,
+ tp_dbus_properties_mixin_getter_gobject_properties,
+ NULL,
+ aia_props
+ },
+ { TP_IFACE_ACCOUNT_INTERFACE_AVATAR,
+ tp_dbus_properties_mixin_getter_gobject_properties,
+ NULL,
+ avatar_props
+ },
{ NULL },
};
g_type_class_add_private (klass, sizeof (TpTestsSimpleAccountPrivate));
object_class->get_property = tp_tests_simple_account_get_property;
object_class->set_property = tp_tests_simple_account_set_property;
+ object_class->finalize = tp_tests_simple_account_finalize;
param_spec = g_param_spec_boxed ("interfaces", "Extra D-Bus interfaces",
"In this case we only implement Account, so none.",
@@ -290,11 +408,11 @@ tp_tests_simple_account_class_init (TpTestsSimpleAccountClass *klass)
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_ICON, param_spec);
- param_spec = g_param_spec_boolean ("valid", "valid",
- "Valid property",
+ param_spec = g_param_spec_boolean ("usable", "usable",
+ "Usable property",
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_VALID, param_spec);
+ g_object_class_install_property (object_class, PROP_USABLE, param_spec);
param_spec = g_param_spec_boolean ("enabled", "enabled",
"Enabled property",
@@ -311,12 +429,12 @@ tp_tests_simple_account_class_init (TpTestsSimpleAccountClass *klass)
param_spec = g_param_spec_boxed ("parameters", "parameters",
"Parameters property",
TP_HASH_TYPE_STRING_VARIANT_MAP,
- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_PARAMETERS, param_spec);
param_spec = g_param_spec_boxed ("automatic-presence", "automatic presence",
"AutomaticPresence property",
- TP_STRUCT_TYPE_SIMPLE_PRESENCE,
+ TP_STRUCT_TYPE_PRESENCE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_AUTOMATIC_PRESENCE,
param_spec);
@@ -335,14 +453,14 @@ tp_tests_simple_account_class_init (TpTestsSimpleAccountClass *klass)
param_spec = g_param_spec_uint ("connection-status", "connection status",
"ConnectionStatus property",
- 0, NUM_TP_CONNECTION_STATUSES, TP_CONNECTION_STATUS_DISCONNECTED,
+ 0, TP_NUM_CONNECTION_STATUSES, TP_CONNECTION_STATUS_DISCONNECTED,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_CONNECTION_STATUS,
param_spec);
param_spec = g_param_spec_uint ("connection-status-reason",
"connection status reason", "ConnectionStatusReason property",
- 0, NUM_TP_CONNECTION_STATUS_REASONS,
+ 0, TP_NUM_CONNECTION_STATUS_REASONS,
TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_CONNECTION_STATUS_REASON,
@@ -350,14 +468,14 @@ tp_tests_simple_account_class_init (TpTestsSimpleAccountClass *klass)
param_spec = g_param_spec_boxed ("current-presence", "current presence",
"CurrentPresence property",
- TP_STRUCT_TYPE_SIMPLE_PRESENCE,
+ TP_STRUCT_TYPE_PRESENCE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_CURRENT_PRESENCE,
param_spec);
param_spec = g_param_spec_boxed ("requested-presence", "requested presence",
"RequestedPresence property",
- TP_STRUCT_TYPE_SIMPLE_PRESENCE,
+ TP_STRUCT_TYPE_PRESENCE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_REQUESTED_PRESENCE,
param_spec);
@@ -404,7 +522,92 @@ tp_tests_simple_account_class_init (TpTestsSimpleAccountClass *klass)
g_object_class_install_property (object_class, PROP_STORAGE_RESTRICTIONS,
param_spec);
+ param_spec = g_param_spec_boxed ("uri-schemes", "URI schemes",
+ "Some URI schemes",
+ G_TYPE_STRV,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_URI_SCHEMES, param_spec);
+
+ param_spec = g_param_spec_boxed ("avatar",
+ "Avatar", "Avatar",
+ TP_STRUCT_TYPE_AVATAR,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class,
+ PROP_AVATAR, param_spec);
+
+ param_spec = g_param_spec_boxed ("supersedes",
+ "Supersedes", "List of superseded accounts",
+ TP_ARRAY_TYPE_OBJECT_PATH_LIST,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class,
+ PROP_SUPERSEDES, param_spec);
+
klass->dbus_props_class.interfaces = prop_interfaces;
tp_dbus_properties_mixin_class_init (object_class,
G_STRUCT_OFFSET (TpTestsSimpleAccountClass, dbus_props_class));
}
+
+void
+tp_tests_simple_account_set_presence (TpTestsSimpleAccount *self,
+ TpConnectionPresenceType presence,
+ const gchar *status,
+ const gchar *message)
+{
+ GHashTable *props;
+ GValueArray *v;
+
+ g_free (self->priv->presence_status);
+ g_free (self->priv->presence_msg);
+
+ self->priv->presence = presence;
+ self->priv->presence_status = g_strdup (status);
+ self->priv->presence_msg = g_strdup (message);
+
+ g_object_get (self, "current-presence", &v, NULL);
+
+ props = tp_asv_new (
+ "CurrentPresence", TP_STRUCT_TYPE_PRESENCE, v,
+ NULL);
+
+ tp_svc_account_emit_account_property_changed (self, props);
+
+ g_boxed_free (TP_STRUCT_TYPE_PRESENCE, v);
+}
+
+void
+tp_tests_simple_account_set_connection (TpTestsSimpleAccount *self,
+ const gchar *object_path)
+{
+ GHashTable *change;
+
+ if (object_path == NULL)
+ object_path = "/";
+
+ g_free (self->priv->connection_path);
+ self->priv->connection_path = g_strdup (object_path);
+
+ change = tp_asv_new (NULL, NULL);
+ tp_asv_set_string (change, "Connection", object_path);
+ tp_svc_account_emit_account_property_changed (self, change);
+ g_hash_table_unref (change);
+}
+
+void
+tp_tests_simple_account_removed (TpTestsSimpleAccount *self)
+{
+ tp_svc_account_emit_removed (self);
+}
+
+void
+tp_tests_simple_account_set_enabled (TpTestsSimpleAccount *self,
+ gboolean enabled)
+{
+ GHashTable *change;
+
+ self->priv->enabled = enabled;
+
+ change = tp_asv_new (NULL, NULL);
+ tp_asv_set_boolean (change, "Enabled", enabled);
+ tp_svc_account_emit_account_property_changed (self, change);
+ g_hash_table_unref (change);
+}
diff --git a/tests/lib/simple-account.h b/tests/lib/simple-account.h
index 04dfcb2..2364bf7 100644
--- a/tests/lib/simple-account.h
+++ b/tests/lib/simple-account.h
@@ -1,7 +1,7 @@
/*
* simple-account.h - header for a simple account service.
*
- * Copyright (C) 2010 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2010-2012 Collabora Ltd. <http://www.collabora.co.uk/>
*
* Copying and distribution of this file, with or without modification,
* are permitted in any medium without royalty provided the copyright
@@ -51,6 +51,18 @@ GType tp_tests_simple_account_get_type (void);
(G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TESTS_TYPE_SIMPLE_ACCOUNT, \
TpTestsSimpleAccountClass))
+void tp_tests_simple_account_set_presence (TpTestsSimpleAccount *self,
+ TpConnectionPresenceType presence,
+ const gchar *status,
+ const gchar *message);
+
+void tp_tests_simple_account_set_connection (TpTestsSimpleAccount *self,
+ const gchar *object_path);
+
+void tp_tests_simple_account_removed (TpTestsSimpleAccount *self);
+void tp_tests_simple_account_set_enabled (TpTestsSimpleAccount *self,
+ gboolean enabled);
+
G_END_DECLS
#endif /* #ifndef __TP_TESTS_SIMPLE_ACCOUNT_H__ */
diff --git a/tests/lib/simple-conn.c b/tests/lib/simple-conn.c
index a3e9757..a306cf8 100644
--- a/tests/lib/simple-conn.c
+++ b/tests/lib/simple-conn.c
@@ -20,28 +20,21 @@
#include <telepathy-glib/telepathy-glib.h>
#include <telepathy-glib/telepathy-glib-dbus.h>
-static void conn_iface_init (TpSvcConnectionClass *);
+#include "util.h"
G_DEFINE_TYPE_WITH_CODE (TpTestsSimpleConnection, tp_tests_simple_connection,
TP_TYPE_BASE_CONNECTION,
- G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION, conn_iface_init))
+ G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION, NULL))
/* type definition stuff */
enum
{
PROP_ACCOUNT = 1,
+ PROP_DBUS_STATUS,
N_PROPS
};
-enum
-{
- SIGNAL_GOT_SELF_HANDLE,
- N_SIGNALS
-};
-
-static guint signals[N_SIGNALS] = {0};
-
struct _TpTestsSimpleConnectionPrivate
{
gchar *account;
@@ -49,9 +42,7 @@ struct _TpTestsSimpleConnectionPrivate
guint disconnect_source;
/* TpHandle => reffed TpTestsTextChannelNull */
- GHashTable *channels;
-
- GError *get_self_handle_error /* initially NULL */ ;
+ GHashTable *text_channels;
};
static void
@@ -60,7 +51,7 @@ tp_tests_simple_connection_init (TpTestsSimpleConnection *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
TP_TESTS_TYPE_SIMPLE_CONNECTION, TpTestsSimpleConnectionPrivate);
- self->priv->channels = g_hash_table_new_full (NULL, NULL, NULL,
+ self->priv->text_channels = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) g_object_unref);
}
@@ -76,6 +67,12 @@ get_property (GObject *object,
case PROP_ACCOUNT:
g_value_set_string (value, self->priv->account);
break;
+ case PROP_DBUS_STATUS:
+ {
+ g_value_set_uint (value,
+ tp_base_connection_get_status (TP_BASE_CONNECTION (self)));
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, spec);
}
@@ -104,7 +101,7 @@ dispose (GObject *object)
{
TpTestsSimpleConnection *self = TP_TESTS_SIMPLE_CONNECTION (object);
- g_hash_table_unref (self->priv->channels);
+ g_hash_table_unref (self->priv->text_channels);
G_OBJECT_CLASS (tp_tests_simple_connection_parent_class)->dispose (object);
}
@@ -124,7 +121,6 @@ finalize (GObject *object)
g_source_remove (self->priv->disconnect_source);
}
- g_clear_error (&self->priv->get_self_handle_error);
g_free (self->priv->account);
G_OBJECT_CLASS (tp_tests_simple_connection_parent_class)->finalize (object);
@@ -163,7 +159,7 @@ tp_tests_simple_normalize_contact (TpHandleRepoIface *repo,
static void
create_handle_repos (TpBaseConnection *conn,
- TpHandleRepoIface *repos[NUM_TP_HANDLE_TYPES])
+ TpHandleRepoIface *repos[TP_NUM_HANDLE_TYPES])
{
repos[TP_HANDLE_TYPE_CONTACT] = tp_dynamic_handle_repo_new
(TP_HANDLE_TYPE_CONTACT, tp_tests_simple_normalize_contact, NULL);
@@ -172,7 +168,7 @@ create_handle_repos (TpBaseConnection *conn,
}
static GPtrArray *
-create_channel_factories (TpBaseConnection *conn)
+create_channel_managers (TpBaseConnection *conn)
{
return g_ptr_array_sized_new (0);
}
@@ -192,11 +188,13 @@ pretend_connected (gpointer data)
TpBaseConnection *conn = (TpBaseConnection *) self;
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (conn,
TP_HANDLE_TYPE_CONTACT);
+ TpHandle self_handle;
- conn->self_handle = tp_handle_ensure (contact_repo, self->priv->account,
+ self_handle = tp_handle_ensure (contact_repo, self->priv->account,
NULL, NULL);
+ tp_base_connection_set_self_handle (conn, self_handle);
- if (conn->status == TP_CONNECTION_STATUS_CONNECTING)
+ if (tp_base_connection_get_status (conn) == TP_CONNECTION_STATUS_CONNECTING)
{
tp_base_connection_change_status (conn, TP_CONNECTION_STATUS_CONNECTED,
TP_CONNECTION_STATUS_REASON_REQUESTED);
@@ -230,7 +228,7 @@ pretend_disconnected (gpointer data)
TpTestsSimpleConnection *self = TP_TESTS_SIMPLE_CONNECTION (data);
/* We are disconnected, all our channels are invalidated */
- g_hash_table_remove_all (self->priv->channels);
+ g_hash_table_remove_all (self->priv->text_channels);
tp_base_connection_finish_shutdown (TP_BASE_CONNECTION (data));
self->priv->disconnect_source = 0;
@@ -250,6 +248,19 @@ shut_down (TpBaseConnection *conn)
conn);
}
+static GPtrArray *
+get_interfaces_always_present (TpBaseConnection *base)
+{
+ GPtrArray *interfaces;
+
+ interfaces = TP_BASE_CONNECTION_CLASS (
+ tp_tests_simple_connection_parent_class)->get_interfaces_always_present (base);
+
+ g_ptr_array_add (interfaces, TP_IFACE_CONNECTION_INTERFACE_REQUESTS);
+
+ return interfaces;
+}
+
static void
tp_tests_simple_connection_class_init (TpTestsSimpleConnectionClass *klass)
{
@@ -257,8 +268,6 @@ tp_tests_simple_connection_class_init (TpTestsSimpleConnectionClass *klass)
(TpBaseConnectionClass *) klass;
GObjectClass *object_class = (GObjectClass *) klass;
GParamSpec *param_spec;
- static const gchar *interfaces_always_present[] = {
- TP_IFACE_CONNECTION_INTERFACE_REQUESTS, NULL };
object_class->get_property = get_property;
object_class->set_property = set_property;
@@ -268,25 +277,24 @@ tp_tests_simple_connection_class_init (TpTestsSimpleConnectionClass *klass)
base_class->create_handle_repos = create_handle_repos;
base_class->get_unique_connection_name = get_unique_connection_name;
- base_class->create_channel_factories = create_channel_factories;
+ base_class->create_channel_managers = create_channel_managers;
base_class->start_connecting = start_connecting;
base_class->shut_down = shut_down;
- base_class->interfaces_always_present = interfaces_always_present;
+ base_class->get_interfaces_always_present = get_interfaces_always_present;
param_spec = g_param_spec_string ("account", "Account name",
"The username of this user", NULL,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB);
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_ACCOUNT, param_spec);
- signals[SIGNAL_GOT_SELF_HANDLE] = g_signal_new ("got-self-handle",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ param_spec = g_param_spec_uint ("dbus-status",
+ "Connection.Status",
+ "The connection status as visible on D-Bus (overridden so can break it)",
+ TP_CONNECTION_STATUS_CONNECTED, G_MAXUINT,
+ TP_CONNECTION_STATUS_DISCONNECTED,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_DBUS_STATUS, param_spec);
}
void
@@ -302,7 +310,6 @@ tp_tests_simple_connection_set_identifier (TpTestsSimpleConnection *self,
g_return_if_fail (handle != 0);
tp_base_connection_set_self_handle (conn, handle);
- tp_handle_unref (contact_repo, handle);
}
TpTestsSimpleConnection *
@@ -316,93 +323,3 @@ tp_tests_simple_connection_new (const gchar *account,
NULL));
}
-gchar *
-tp_tests_simple_connection_ensure_text_chan (TpTestsSimpleConnection *self,
- const gchar *target_id,
- GHashTable **props)
-{
- TpTestsTextChannelNull *chan;
- gchar *chan_path;
- TpHandleRepoIface *contact_repo;
- TpHandle handle;
- static guint count = 0;
- TpBaseConnection *base_conn = (TpBaseConnection *) self;
-
- /* Get contact handle */
- contact_repo = tp_base_connection_get_handles (base_conn,
- TP_HANDLE_TYPE_CONTACT);
- g_assert (contact_repo != NULL);
-
- handle = tp_handle_ensure (contact_repo, target_id, NULL, NULL);
-
- chan = g_hash_table_lookup (self->priv->channels, GUINT_TO_POINTER (handle));
- if (chan != NULL)
- {
- /* Channel already exist, reuse it */
- g_object_get (chan, "object-path", &chan_path, NULL);
- }
- else
- {
- chan_path = g_strdup_printf ("%s/Channel%u", base_conn->object_path,
- count++);
-
- chan = TP_TESTS_TEXT_CHANNEL_NULL (
- tp_tests_object_new_static_class (
- TP_TESTS_TYPE_TEXT_CHANNEL_NULL,
- "connection", self,
- "object-path", chan_path,
- "handle", handle,
- NULL));
-
- g_hash_table_insert (self->priv->channels, GUINT_TO_POINTER (handle),
- chan);
- }
-
- tp_handle_unref (contact_repo, handle);
-
- if (props != NULL)
- *props = tp_tests_text_channel_get_props (chan);
-
- return chan_path;
-}
-
-void
-tp_tests_simple_connection_set_get_self_handle_error (
- TpTestsSimpleConnection *self,
- GQuark domain,
- gint code,
- const gchar *message)
-{
- self->priv->get_self_handle_error = g_error_new_literal (domain, code,
- message);
-}
-
-static void
-get_self_handle (TpSvcConnection *iface,
- DBusGMethodInvocation *context)
-{
- TpTestsSimpleConnection *self = TP_TESTS_SIMPLE_CONNECTION (iface);
- TpBaseConnection *base = TP_BASE_CONNECTION (iface);
-
- g_assert (TP_IS_BASE_CONNECTION (base));
-
- TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context);
-
- if (self->priv->get_self_handle_error != NULL)
- {
- dbus_g_method_return_error (context, self->priv->get_self_handle_error);
- return;
- }
-
- tp_svc_connection_return_from_get_self_handle (context, base->self_handle);
- g_signal_emit (self, signals[SIGNAL_GOT_SELF_HANDLE], 0);
-}
-
-static void
-conn_iface_init (TpSvcConnectionClass *iface)
-{
-#define IMPLEMENT(prefix,x) \
- tp_svc_connection_implement_##x (iface, prefix##x)
- IMPLEMENT(,get_self_handle);
-#undef IMPLEMENT
-}
diff --git a/tests/lib/simple-conn.h b/tests/lib/simple-conn.h
index 14a095b..f34f3be 100644
--- a/tests/lib/simple-conn.h
+++ b/tests/lib/simple-conn.h
@@ -61,17 +61,6 @@ void tp_tests_simple_connection_inject_disconnect (
void tp_tests_simple_connection_set_identifier (TpTestsSimpleConnection *self,
const gchar *identifier);
-gchar * tp_tests_simple_connection_ensure_text_chan (
- TpTestsSimpleConnection *self,
- const gchar *target_id,
- GHashTable **props);
-
-void tp_tests_simple_connection_set_get_self_handle_error (
- TpTestsSimpleConnection *self,
- GQuark domain,
- gint code,
- const gchar *message);
-
G_END_DECLS
#endif /* #ifndef __TP_TESTS_SIMPLE_CONN_H__ */
diff --git a/tests/lib/textchan-null.c b/tests/lib/textchan-null.c
deleted file mode 100644
index 01efb4f..0000000
--- a/tests/lib/textchan-null.c
+++ /dev/null
@@ -1,572 +0,0 @@
-/*
- * /dev/null as a text channel
- *
- * Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
- * Copyright (C) 2008 Nokia Corporation
- *
- * Copying and distribution of this file, with or without modification,
- * are permitted in any medium without royalty provided the copyright
- * notice and this notice are preserved.
- */
-
-#include "config.h"
-
-#include "textchan-null.h"
-
-#include <telepathy-glib/base-connection.h>
-#include <telepathy-glib/channel-iface.h>
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/dbus-properties-mixin.h>
-#include <telepathy-glib/interfaces.h>
-#include <telepathy-glib/svc-channel.h>
-#include <telepathy-glib/svc-generic.h>
-
-static void text_iface_init (gpointer iface, gpointer data);
-static void channel_iface_init (gpointer iface, gpointer data);
-
-G_DEFINE_TYPE_WITH_CODE (TpTestsTextChannelNull,
- tp_tests_text_channel_null,
- G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL, channel_iface_init);
- G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_TYPE_TEXT, text_iface_init);
- G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_IFACE, NULL))
-
-G_DEFINE_TYPE_WITH_CODE (TpTestsPropsTextChannel,
- tp_tests_props_text_channel,
- TP_TESTS_TYPE_TEXT_CHANNEL_NULL,
- G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_DBUS_PROPERTIES,
- tp_dbus_properties_mixin_iface_init))
-
-G_DEFINE_TYPE_WITH_CODE (TpTestsPropsGroupTextChannel,
- tp_tests_props_group_text_channel,
- TP_TESTS_TYPE_PROPS_TEXT_CHANNEL,
- G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_GROUP,
- tp_group_mixin_iface_init))
-
-static const char *tp_tests_text_channel_null_interfaces[] = { NULL };
-
-/* type definition stuff */
-
-enum
-{
- PROP_OBJECT_PATH = 1,
- PROP_CHANNEL_TYPE,
- PROP_HANDLE_TYPE,
- PROP_HANDLE,
- PROP_TARGET_ID,
- PROP_CONNECTION,
- PROP_INTERFACES,
- PROP_REQUESTED,
- PROP_INITIATOR_HANDLE,
- PROP_INITIATOR_ID,
- N_PROPS
-};
-
-struct _TpTestsTextChannelNullPrivate
-{
- TpBaseConnection *conn;
- gchar *object_path;
- TpHandle handle;
-
- unsigned closed:1;
- unsigned disposed:1;
-};
-
-static void
-tp_tests_text_channel_null_init (TpTestsTextChannelNull *self)
-{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- TP_TESTS_TYPE_TEXT_CHANNEL_NULL, TpTestsTextChannelNullPrivate);
-}
-
-static void
-tp_tests_props_text_channel_init (TpTestsPropsTextChannel *self)
-{
- self->dbus_property_interfaces_retrieved = g_hash_table_new (NULL, NULL);
-}
-
-static GObject *
-constructor (GType type,
- guint n_props,
- GObjectConstructParam *props)
-{
- GObject *object =
- G_OBJECT_CLASS (tp_tests_text_channel_null_parent_class)->constructor (type,
- n_props, props);
- TpTestsTextChannelNull *self = TP_TESTS_TEXT_CHANNEL_NULL (object);
- TpHandleRepoIface *contact_repo = tp_base_connection_get_handles
- (self->priv->conn, TP_HANDLE_TYPE_CONTACT);
-
- tp_handle_ref (contact_repo, self->priv->handle);
-
- tp_dbus_daemon_register_object (
- tp_base_connection_get_dbus_daemon (self->priv->conn),
- self->priv->object_path, self);
-
- tp_text_mixin_init (object, G_STRUCT_OFFSET (TpTestsTextChannelNull, text),
- contact_repo);
-
- tp_text_mixin_set_message_types (object,
- TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
- TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION,
- TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE,
- G_MAXUINT);
-
- return object;
-}
-
-static void
-get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- TpTestsTextChannelNull *self = TP_TESTS_TEXT_CHANNEL_NULL (object);
-
- switch (property_id)
- {
- case PROP_OBJECT_PATH:
- g_value_set_string (value, self->priv->object_path);
- break;
- case PROP_CHANNEL_TYPE:
- g_value_set_static_string (value, TP_IFACE_CHANNEL_TYPE_TEXT);
- break;
- case PROP_HANDLE_TYPE:
- g_value_set_uint (value, TP_HANDLE_TYPE_CONTACT);
- break;
- case PROP_HANDLE:
- g_value_set_uint (value, self->priv->handle);
- break;
- case PROP_TARGET_ID:
- {
- TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
- self->priv->conn, TP_HANDLE_TYPE_CONTACT);
-
- g_value_set_string (value,
- tp_handle_inspect (contact_repo, self->priv->handle));
- }
- break;
- case PROP_REQUESTED:
- g_value_set_boolean (value, TRUE);
- break;
- case PROP_INITIATOR_HANDLE:
- g_value_set_uint (value, self->priv->conn->self_handle);
- break;
- case PROP_INITIATOR_ID:
- {
- TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
- self->priv->conn, TP_HANDLE_TYPE_CONTACT);
-
- g_value_set_string (value,
- tp_handle_inspect (contact_repo, self->priv->conn->self_handle));
- }
- break;
- case PROP_INTERFACES:
- g_value_set_boxed (value, tp_tests_text_channel_null_interfaces);
- break;
- case PROP_CONNECTION:
- g_value_set_object (value, self->priv->conn);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- TpTestsTextChannelNull *self = TP_TESTS_TEXT_CHANNEL_NULL (object);
-
- switch (property_id)
- {
- case PROP_OBJECT_PATH:
- g_free (self->priv->object_path);
- self->priv->object_path = g_value_dup_string (value);
- break;
- case PROP_HANDLE:
- /* we don't ref it here because we don't necessarily have access to the
- * contact repo yet - instead we ref it in the constructor.
- */
- self->priv->handle = g_value_get_uint (value);
- break;
- case PROP_HANDLE_TYPE:
- case PROP_CHANNEL_TYPE:
- /* these properties are writable in the interface, but not actually
- * meaningfully changable on this channel, so we do nothing */
- break;
- case PROP_CONNECTION:
- self->priv->conn = g_value_get_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-void
-tp_tests_text_channel_null_close (TpTestsTextChannelNull *self)
-{
- if (!self->priv->closed)
- {
- self->priv->closed = TRUE;
- tp_svc_channel_emit_closed (self);
- tp_dbus_daemon_unregister_object (
- tp_base_connection_get_dbus_daemon (self->priv->conn), self);
- }
-}
-
-static void
-dispose (GObject *object)
-{
- TpTestsTextChannelNull *self = TP_TESTS_TEXT_CHANNEL_NULL (object);
-
- if (self->priv->disposed)
- return;
-
- self->priv->disposed = TRUE;
- tp_tests_text_channel_null_close (self);
-
- ((GObjectClass *) tp_tests_text_channel_null_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- TpTestsTextChannelNull *self = TP_TESTS_TEXT_CHANNEL_NULL (object);
- TpHandleRepoIface *contact_handles = tp_base_connection_get_handles
- (self->priv->conn, TP_HANDLE_TYPE_CONTACT);
-
- tp_handle_unref (contact_handles, self->priv->handle);
- g_free (self->priv->object_path);
-
- tp_text_mixin_finalize (object);
-
- ((GObjectClass *) tp_tests_text_channel_null_parent_class)->finalize (object);
-}
-
-static void
-tp_tests_text_channel_null_class_init (TpTestsTextChannelNullClass *klass)
-{
- GObjectClass *object_class = (GObjectClass *) klass;
- GParamSpec *param_spec;
-
- g_type_class_add_private (klass, sizeof (TpTestsTextChannelNullPrivate));
-
- object_class->constructor = constructor;
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
-
- g_object_class_override_property (object_class, PROP_OBJECT_PATH,
- "object-path");
- g_object_class_override_property (object_class, PROP_CHANNEL_TYPE,
- "channel-type");
- g_object_class_override_property (object_class, PROP_HANDLE_TYPE,
- "handle-type");
- g_object_class_override_property (object_class, PROP_HANDLE, "handle");
-
- param_spec = g_param_spec_object ("connection", "TpBaseConnection object",
- "Connection object that owns this channel",
- TP_TYPE_BASE_CONNECTION,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
- G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB);
- g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
-
- param_spec = g_param_spec_boxed ("interfaces", "Extra D-Bus interfaces",
- "Additional Channel.Interface.* interfaces",
- G_TYPE_STRV,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_INTERFACES, param_spec);
-
- param_spec = g_param_spec_string ("target-id", "Peer's ID",
- "The string obtained by inspecting the target handle",
- NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_TARGET_ID, param_spec);
-
- param_spec = g_param_spec_uint ("initiator-handle", "Initiator's handle",
- "The contact who initiated the channel",
- 0, G_MAXUINT32, 0,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_INITIATOR_HANDLE,
- param_spec);
-
- param_spec = g_param_spec_string ("initiator-id", "Initiator's ID",
- "The string obtained by inspecting the initiator-handle",
- NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_INITIATOR_ID,
- param_spec);
-
- param_spec = g_param_spec_boolean ("requested", "Requested?",
- "True if this channel was requested by the local user",
- FALSE,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_REQUESTED, param_spec);
-
- tp_text_mixin_class_init (object_class,
- G_STRUCT_OFFSET (TpTestsTextChannelNullClass, text_class));
-}
-
-static void
-tp_tests_props_text_channel_getter_gobject_properties (GObject *object,
- GQuark interface,
- GQuark name,
- GValue *value,
- gpointer getter_data)
-{
- TpTestsPropsTextChannel *self = TP_TESTS_PROPS_TEXT_CHANNEL (object);
-
- g_hash_table_insert (self->dbus_property_interfaces_retrieved,
- GUINT_TO_POINTER (interface), GUINT_TO_POINTER (interface));
-
- tp_dbus_properties_mixin_getter_gobject_properties (object, interface, name,
- value, getter_data);
-}
-
-static void
-props_finalize (GObject *object)
-{
- TpTestsPropsTextChannel *self = TP_TESTS_PROPS_TEXT_CHANNEL (object);
-
- g_hash_table_unref (self->dbus_property_interfaces_retrieved);
-
- ((GObjectClass *) tp_tests_props_text_channel_parent_class)->finalize (object);
-}
-
-static void
-tp_tests_props_text_channel_class_init (TpTestsPropsTextChannelClass *klass)
-{
- GObjectClass *object_class = (GObjectClass *) klass;
- static TpDBusPropertiesMixinPropImpl channel_props[] = {
- { "TargetHandleType", "handle-type", NULL },
- { "TargetHandle", "handle", NULL },
- { "ChannelType", "channel-type", NULL },
- { "Interfaces", "interfaces", NULL },
- { "TargetID", "target-id", NULL },
- { "Requested", "requested", NULL },
- { "InitiatorHandle", "initiator-handle", NULL },
- { "InitiatorID", "initiator-id", NULL },
- { NULL }
- };
- static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = {
- { TP_IFACE_CHANNEL,
- tp_tests_props_text_channel_getter_gobject_properties,
- NULL,
- channel_props,
- },
- { NULL }
- };
-
- object_class->finalize = props_finalize;
-
- klass->dbus_properties_class.interfaces = prop_interfaces;
- tp_dbus_properties_mixin_class_init (object_class,
- G_STRUCT_OFFSET (TpTestsPropsTextChannelClass, dbus_properties_class));
-}
-
-static void
-tp_tests_props_group_text_channel_init (TpTestsPropsGroupTextChannel *self)
-{
-}
-
-static void
-group_constructed (GObject *self)
-{
- TpBaseConnection *conn = TP_TESTS_TEXT_CHANNEL_NULL (self)->priv->conn;
- void (*chain_up) (GObject *) =
- ((GObjectClass *) tp_tests_props_group_text_channel_parent_class)->constructed;
-
- if (chain_up != NULL)
- chain_up (self);
-
- tp_group_mixin_init (self,
- G_STRUCT_OFFSET (TpTestsPropsGroupTextChannel, group),
- tp_base_connection_get_handles (conn, TP_HANDLE_TYPE_CONTACT),
- tp_base_connection_get_self_handle (conn));
- tp_group_mixin_change_flags (self, TP_CHANNEL_GROUP_FLAG_PROPERTIES, 0);
-}
-
-static void
-group_finalize (GObject *self)
-{
- tp_group_mixin_finalize (self);
-
- ((GObjectClass *) tp_tests_props_group_text_channel_parent_class)->finalize (self);
-}
-
-static gboolean
-dummy_add_remove_member (GObject *obj,
- TpHandle handle,
- const gchar *message,
- GError **error)
-{
- return TRUE;
-}
-
-static void
-group_iface_props_getter (GObject *object,
- GQuark interface,
- GQuark name,
- GValue *value,
- gpointer getter_data)
-{
- TpTestsPropsTextChannel *self = TP_TESTS_PROPS_TEXT_CHANNEL (object);
-
- g_hash_table_insert (self->dbus_property_interfaces_retrieved,
- GUINT_TO_POINTER (interface), GUINT_TO_POINTER (interface));
-
- tp_group_mixin_get_dbus_property (object, interface, name, value, getter_data);
-}
-
-static void
-tp_tests_props_group_text_channel_class_init (TpTestsPropsGroupTextChannelClass *klass)
-{
- GObjectClass *object_class = (GObjectClass *) klass;
- static TpDBusPropertiesMixinPropImpl group_props[] = {
- { "GroupFlags", NULL, NULL },
- { "HandleOwners", NULL, NULL },
- { "LocalPendingMembers", NULL, NULL },
- { "Members", NULL, NULL },
- { "RemotePendingMembers", NULL, NULL },
- { "SelfHandle", NULL, NULL },
- { NULL }
- };
-
- object_class->constructed = group_constructed;
- object_class->finalize = group_finalize;
-
- tp_group_mixin_class_init (object_class,
- G_STRUCT_OFFSET (TpTestsPropsGroupTextChannelClass, group_class),
- dummy_add_remove_member,
- dummy_add_remove_member);
- tp_dbus_properties_mixin_implement_interface (object_class,
- TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP, group_iface_props_getter, NULL,
- group_props);
-}
-
-static void
-channel_close (TpSvcChannel *iface,
- DBusGMethodInvocation *context)
-{
- TpTestsTextChannelNull *self = TP_TESTS_TEXT_CHANNEL_NULL (iface);
-
- tp_tests_text_channel_null_close (self);
- tp_svc_channel_return_from_close (context);
-}
-
-static void
-channel_get_channel_type (TpSvcChannel *iface,
- DBusGMethodInvocation *context)
-{
- TpTestsTextChannelNull *self = TP_TESTS_TEXT_CHANNEL_NULL (iface);
-
- self->get_channel_type_called++;
-
- tp_svc_channel_return_from_get_channel_type (context,
- TP_IFACE_CHANNEL_TYPE_TEXT);
-}
-
-static void
-channel_get_handle (TpSvcChannel *iface,
- DBusGMethodInvocation *context)
-{
- TpTestsTextChannelNull *self = TP_TESTS_TEXT_CHANNEL_NULL (iface);
-
- self->get_handle_called++;
-
- tp_svc_channel_return_from_get_handle (context, TP_HANDLE_TYPE_CONTACT,
- self->priv->handle);
-}
-
-static void
-channel_get_interfaces (TpSvcChannel *iface,
- DBusGMethodInvocation *context)
-{
- TpTestsTextChannelNull *self = TP_TESTS_TEXT_CHANNEL_NULL (iface);
-
- self->get_interfaces_called++;
-
- tp_svc_channel_return_from_get_interfaces (context,
- tp_tests_text_channel_null_interfaces);
-}
-
-static void
-channel_iface_init (gpointer iface,
- gpointer data)
-{
- TpSvcChannelClass *klass = iface;
-
-#define IMPLEMENT(x) tp_svc_channel_implement_##x (klass, channel_##x)
- IMPLEMENT (close);
- IMPLEMENT (get_channel_type);
- IMPLEMENT (get_handle);
- IMPLEMENT (get_interfaces);
-#undef IMPLEMENT
-}
-
-static void
-text_send (TpSvcChannelTypeText *iface,
- guint type,
- const gchar *text,
- DBusGMethodInvocation *context)
-{
- /* silently swallow the message */
- tp_svc_channel_type_text_return_from_send (context);
-}
-
-static void
-text_iface_init (gpointer iface,
- gpointer data)
-{
- TpSvcChannelTypeTextClass *klass = iface;
-
- tp_text_mixin_iface_init (iface, data);
-#define IMPLEMENT(x) tp_svc_channel_type_text_implement_##x (klass, text_##x)
- IMPLEMENT (send);
-#undef IMPLEMENT
-}
-
-GHashTable *
-tp_tests_text_channel_get_props (TpTestsTextChannelNull *self)
-{
- GHashTable *props;
- TpHandleType handle_type;
- TpHandle handle;
- gchar *target_id;
- gboolean requested;
- TpHandle initiator_handle;
- gchar *initiator_id;
- GStrv interfaces;
-
- g_object_get (self,
- "handle-type", &handle_type,
- "handle", &handle,
- "target-id", &target_id,
- "requested", &requested,
- "initiator-handle", &initiator_handle,
- "initiator-id", &initiator_id,
- "interfaces", &interfaces,
- NULL);
-
- props = tp_asv_new (
- TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT,
- TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, handle_type,
- TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT, handle,
- TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, target_id,
- TP_PROP_CHANNEL_REQUESTED, G_TYPE_BOOLEAN, requested,
- TP_PROP_CHANNEL_INITIATOR_HANDLE, G_TYPE_UINT, initiator_handle,
- TP_PROP_CHANNEL_INITIATOR_ID, G_TYPE_STRING, initiator_id,
- TP_PROP_CHANNEL_INTERFACES, G_TYPE_STRV, interfaces,
- NULL);
-
- g_free (target_id);
- g_free (initiator_id);
- g_strfreev (interfaces);
- return props;
-}
diff --git a/tests/lib/textchan-null.h b/tests/lib/textchan-null.h
deleted file mode 100644
index 583bec5..0000000
--- a/tests/lib/textchan-null.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * /dev/null as a text channel
- *
- * Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
- * Copyright (C) 2008 Nokia Corporation
- *
- * Copying and distribution of this file, with or without modification,
- * are permitted in any medium without royalty provided the copyright
- * notice and this notice are preserved.
- */
-
-#ifndef __TP_TESTS_TEXT_CHANNEL_NULL_H__
-#define __TP_TESTS_TEXT_CHANNEL_NULL_H__
-
-#include <glib-object.h>
-#include <telepathy-glib/base-connection.h>
-#include <telepathy-glib/text-mixin.h>
-#include <telepathy-glib/group-mixin.h>
-
-G_BEGIN_DECLS
-
-typedef struct _TpTestsTextChannelNull TpTestsTextChannelNull;
-typedef struct _TpTestsTextChannelNullClass TpTestsTextChannelNullClass;
-typedef struct _TpTestsTextChannelNullPrivate TpTestsTextChannelNullPrivate;
-
-GType tp_tests_text_channel_null_get_type (void);
-
-#define TP_TESTS_TYPE_TEXT_CHANNEL_NULL \
- (tp_tests_text_channel_null_get_type ())
-#define TP_TESTS_TEXT_CHANNEL_NULL(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), TP_TESTS_TYPE_TEXT_CHANNEL_NULL, \
- TpTestsTextChannelNull))
-#define TP_TESTS_TEXT_CHANNEL_NULL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), TP_TESTS_TYPE_TEXT_CHANNEL_NULL, \
- TpTestsTextChannelNullClass))
-#define TP_TESTS_IS_TEXT_CHANNEL_NULL(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TP_TESTS_TYPE_TEXT_CHANNEL_NULL))
-#define TP_TESTS_IS_TEXT_CHANNEL_NULL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), TP_TESTS_TYPE_TEXT_CHANNEL_NULL))
-#define TP_TESTS_TEXT_CHANNEL_NULL_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TESTS_TYPE_TEXT_CHANNEL_NULL, \
- TpTestsTextChannelNullClass))
-
-struct _TpTestsTextChannelNullClass {
- GObjectClass parent_class;
-
- TpTextMixinClass text_class;
-};
-
-struct _TpTestsTextChannelNull {
- GObject parent;
- TpTextMixin text;
-
- guint get_handle_called;
- guint get_interfaces_called;
- guint get_channel_type_called;
-
- TpTestsTextChannelNullPrivate *priv;
-};
-
-/* Subclass with D-Bus properties */
-
-typedef struct _TestPropsTextChannel TpTestsPropsTextChannel;
-typedef struct _TestPropsTextChannelClass TpTestsPropsTextChannelClass;
-
-struct _TestPropsTextChannel {
- TpTestsTextChannelNull parent;
-
- GHashTable *dbus_property_interfaces_retrieved;
-};
-
-struct _TestPropsTextChannelClass {
- TpTestsTextChannelNullClass parent;
-
- TpDBusPropertiesMixinClass dbus_properties_class;
-};
-
-GType tp_tests_props_text_channel_get_type (void);
-
-#define TP_TESTS_TYPE_PROPS_TEXT_CHANNEL \
- (tp_tests_props_text_channel_get_type ())
-#define TP_TESTS_PROPS_TEXT_CHANNEL(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), TP_TESTS_TYPE_PROPS_TEXT_CHANNEL, \
- TpTestsPropsTextChannel))
-#define TP_TESTS_PROPS_TEXT_CHANNEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), TP_TESTS_TYPE_PROPS_TEXT_CHANNEL, \
- TpTestsPropsTextChannelClass))
-#define TP_TESTS_IS_PROPS_TEXT_CHANNEL(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TP_TESTS_TYPE_PROPS_TEXT_CHANNEL))
-#define TP_TESTS_IS_PROPS_TEXT_CHANNEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), TP_TESTS_TYPE_PROPS_TEXT_CHANNEL))
-#define TP_TESTS_PROPS_TEXT_CHANNEL_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TESTS_TYPE_PROPS_TEXT_CHANNEL, \
- TpTestsPropsTextChannelClass))
-
-/* Subclass with D-Bus properties and Group */
-
-typedef struct _TestPropsGroupTextChannel TpTestsPropsGroupTextChannel;
-typedef struct _TestPropsGroupTextChannelClass TpTestsPropsGroupTextChannelClass;
-
-struct _TestPropsGroupTextChannel {
- TpTestsPropsTextChannel parent;
-
- TpGroupMixin group;
-};
-
-struct _TestPropsGroupTextChannelClass {
- TpTestsPropsTextChannelClass parent;
-
- TpGroupMixinClass group_class;
-};
-
-GType tp_tests_props_group_text_channel_get_type (void);
-
-#define TP_TESTS_TYPE_PROPS_GROUP_TEXT_CHANNEL \
- (tp_tests_props_group_text_channel_get_type ())
-#define TP_TESTS_PROPS_GROUP_TEXT_CHANNEL(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), TP_TESTS_TYPE_PROPS_GROUP_TEXT_CHANNEL, \
- TpTestsPropsGroupTextChannel))
-#define TP_TESTS_PROPS_GROUP_TEXT_CHANNEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), TP_TESTS_TYPE_PROPS_GROUP_TEXT_CHANNEL, \
- TpTestsPropsGroupTextChannelClass))
-#define TP_TESTS_IS_PROPS_GROUP_TEXT_CHANNEL(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TP_TESTS_TYPE_PROPS_GROUP_TEXT_CHANNEL))
-#define TP_TESTS_IS_PROPS_GROUP_TEXT_CHANNEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), TP_TESTS_TYPE_PROPS_GROUP_TEXT_CHANNEL))
-#define TP_TESTS_PROPS_GROUP_TEXT_CHANNEL_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TESTS_TYPE_PROPS_GROUP_TEXT_CHANNEL, \
- TpTestsPropsGroupTextChannelClass))
-
-void tp_tests_text_channel_null_close (TpTestsTextChannelNull *self);
-
-GHashTable * tp_tests_text_channel_get_props (TpTestsTextChannelNull *self);
-
-G_END_DECLS
-
-#endif /* #ifndef __TP_TESTS_TEXT_CHANNEL_NULL_H__ */