From d5671c624202d00f737dc3170fc46c6a8c0c29e9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 8 Jan 2014 14:31:53 +0000 Subject: [PATCH] Adapt for merge of Contacts into Connection, and deletion of Requests This also resyncs constants.py, servicetest.py with my current Gabble branch. --- rakia/base-connection.c | 14 -------------- rakia/base-connection.h | 2 -- rakia/connection-aliasing.c | 34 ++++++++++++---------------------- rakia/connection-aliasing.h | 9 +++++++-- src/sip-connection.c | 22 ++++++++++++++++------ tests/twisted/cm/protocol.py | 2 -- tests/twisted/constants.py | 18 ++++++++++++------ tests/twisted/servicetest.py | 38 +++++++++++++++++++++++++++++++++----- 8 files changed, 80 insertions(+), 59 deletions(-) diff --git a/rakia/base-connection.c b/rakia/base-connection.c index 2e7ad8b..58ae394 100644 --- a/rakia/base-connection.c +++ b/rakia/base-connection.c @@ -58,27 +58,16 @@ static void event_target_iface_init (gpointer iface, gpointer data) {} G_DEFINE_TYPE_WITH_CODE (RakiaBaseConnection, rakia_base_connection, TP_TYPE_BASE_CONNECTION, - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACTS, - tp_contacts_mixin_iface_init); G_IMPLEMENT_INTERFACE (RAKIA_TYPE_EVENT_TARGET, event_target_iface_init); ); static void rakia_base_connection_init (RakiaBaseConnection *self) { - GObject *object = G_OBJECT (self); - TpBaseConnection *base = TP_BASE_CONNECTION (self); - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, RAKIA_TYPE_BASE_CONNECTION, RakiaBaseConnectionPrivate); self->priv->uris = g_hash_table_new_full (NULL, NULL, NULL, free); - - tp_contacts_mixin_init (object, - G_STRUCT_OFFSET (RakiaBaseConnection, contacts_mixin)); - - /* Connection attributes */ - tp_base_connection_register_with_contacts_mixin (base); } static void @@ -191,9 +180,6 @@ rakia_base_connection_class_init (RakiaBaseConnectionClass *klass) "Sofia-SIP UA", "The UA object for Sofia-SIP", G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - - tp_contacts_mixin_class_init (object_class, - G_STRUCT_OFFSET(RakiaBaseConnectionClass, contacts_mixin_class)); } nua_handle_t * diff --git a/rakia/base-connection.h b/rakia/base-connection.h index 1bd505d..972e091 100644 --- a/rakia/base-connection.h +++ b/rakia/base-connection.h @@ -36,7 +36,6 @@ typedef struct _RakiaBaseConnectionPrivate RakiaBaseConnectionPrivate; struct _RakiaBaseConnectionClass { TpBaseConnectionClass parent_class; - TpContactsMixinClass contacts_mixin_class; nua_handle_t *(*create_handle) (RakiaBaseConnection *, TpHandle contact); void (*add_auth_handler) (RakiaBaseConnection *, RakiaEventTarget *); @@ -44,7 +43,6 @@ struct _RakiaBaseConnectionClass { struct _RakiaBaseConnection { TpBaseConnection parent; - TpContactsMixin contacts_mixin; RakiaBaseConnectionPrivate *priv; }; diff --git a/rakia/connection-aliasing.c b/rakia/connection-aliasing.c index a802c1f..4e41c8c 100644 --- a/rakia/connection-aliasing.c +++ b/rakia/connection-aliasing.c @@ -280,43 +280,33 @@ rakia_connection_set_aliases (TpSvcConnectionInterfaceAliasing1 *iface, tp_svc_connection_interface_aliasing1_return_from_set_aliases (context); } -static void -rakia_conn_aliasing_fill_contact_attributes (GObject *obj, - const GArray *contacts, GHashTable *attributes_hash) +gboolean +rakia_conn_aliasing_fill_contact_attributes (TpBaseConnection *base, + const gchar *dbus_interface, + TpHandle handle, + TpContactAttributeMap *attributes) { - TpBaseConnection *base = TP_BASE_CONNECTION (obj); - TpHandleRepoIface *contact_handles; - guint i; - - contact_handles = tp_base_connection_get_handles (base, - TP_HANDLE_TYPE_CONTACT); - - for (i = 0; i < contacts->len; i++) + if (!tp_strdiff (dbus_interface, TP_IFACE_CONNECTION_INTERFACE_ALIASING1)) { - TpHandle handle; + TpHandleRepoIface *contact_handles; GValue *val; - handle = g_array_index (contacts, TpHandle, i); + contact_handles = tp_base_connection_get_handles (base, + TP_HANDLE_TYPE_CONTACT); val = tp_g_value_slice_new (G_TYPE_STRING); g_value_take_string (val, conn_get_alias (base, contact_handles, handle)); - tp_contacts_mixin_set_contact_attribute (attributes_hash, handle, + tp_contact_attribute_map_take_sliced_gvalue (attributes, handle, TP_TOKEN_CONNECTION_INTERFACE_ALIASING1_ALIAS, val); + return TRUE; } -} -void -rakia_connection_aliasing_init (gpointer instance) -{ - tp_contacts_mixin_add_contact_attributes_iface (G_OBJECT (instance), - TP_IFACE_CONNECTION_INTERFACE_ALIASING1, - rakia_conn_aliasing_fill_contact_attributes); + return FALSE; } - void rakia_connection_aliasing_svc_iface_init (gpointer g_iface, gpointer iface_data) { diff --git a/rakia/connection-aliasing.h b/rakia/connection-aliasing.h index b2482e4..d933e11 100644 --- a/rakia/connection-aliasing.h +++ b/rakia/connection-aliasing.h @@ -23,6 +23,8 @@ #include +#include + G_BEGIN_DECLS typedef struct _RakiaConnectionAliasing RakiaConnectionAliasing; @@ -48,11 +50,14 @@ struct _RakiaConnectionAliasingInterface { GType rakia_connection_aliasing_get_type (void) G_GNUC_CONST; -void rakia_connection_aliasing_init (gpointer instance); - void rakia_connection_aliasing_svc_iface_init (gpointer g_iface, gpointer iface_data); +gboolean rakia_conn_aliasing_fill_contact_attributes (TpBaseConnection *base, + const gchar *dbus_interface, + TpHandle handle, + TpContactAttributeMap *attributes); + G_END_DECLS #endif /*__RAKIA_CONN_ALIASING_H__*/ diff --git a/src/sip-connection.c b/src/sip-connection.c index 4e3b973..2db7b59 100644 --- a/src/sip-connection.c +++ b/src/sip-connection.c @@ -170,8 +170,6 @@ rakia_connection_init (RakiaConnection *self) RakiaConnectionPrivate *priv = RAKIA_CONNECTION_GET_PRIVATE (self); priv->sofia_home = su_home_new(sizeof (su_home_t)); - - rakia_connection_aliasing_init (self); } static void @@ -421,8 +419,6 @@ static gboolean rakia_connection_start_connecting (TpBaseConnection *base, GError **error); static const gchar *interfaces_always_present[] = { - TP_IFACE_CONNECTION_INTERFACE_REQUESTS, - TP_IFACE_CONNECTION_INTERFACE_CONTACTS, TP_IFACE_CONNECTION_INTERFACE_ALIASING1, NULL }; @@ -454,6 +450,20 @@ static void rakia_connection_add_auth_handler (RakiaBaseConnection *, RakiaEventTarget *); static void +rakia_connection_fill_contact_attributes (TpBaseConnection *base, + const gchar *dbus_interface, + TpHandle handle, + TpContactAttributeMap *attributes) +{ + if (rakia_conn_aliasing_fill_contact_attributes (base, + dbus_interface, handle, attributes)) + return; + + TP_BASE_CONNECTION_CLASS (rakia_connection_parent_class)-> + fill_contact_attributes (base, dbus_interface, handle, attributes); +} + +static void rakia_connection_class_init (RakiaConnectionClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -481,6 +491,8 @@ rakia_connection_class_init (RakiaConnectionClass *klass) base_class->start_connecting = rakia_connection_start_connecting; base_class->shut_down = rakia_connection_shut_down; base_class->get_interfaces_always_present = get_interfaces_always_present; + base_class->fill_contact_attributes = + rakia_connection_fill_contact_attributes; g_type_class_add_private (klass, sizeof (RakiaConnectionPrivate)); @@ -1028,8 +1040,6 @@ rakia_connection_finalize (GObject *obj) g_free (priv->registrar_realm); - tp_contacts_mixin_finalize (obj); - G_OBJECT_CLASS (rakia_connection_parent_class)->finalize (obj); } diff --git a/tests/twisted/cm/protocol.py b/tests/twisted/cm/protocol.py index f2234e0..d92b654 100644 --- a/tests/twisted/cm/protocol.py +++ b/tests/twisted/cm/protocol.py @@ -35,8 +35,6 @@ def test(q, bus, conn, sip): assertEquals('im-sip', proto_props['Icon']) assertContains(cs.CONN_IFACE_ALIASING, proto_props['ConnectionInterfaces']) - assertContains(cs.CONN_IFACE_CONTACTS, proto_props['ConnectionInterfaces']) - assertContains(cs.CONN_IFACE_REQUESTS, proto_props['ConnectionInterfaces']) assertEquals('sip:example@mit.edu', unwrap(proto_iface.NormalizeContact('example@MIT.Edu'))) diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py index ff0f0a1..d710529 100644 --- a/tests/twisted/constants.py +++ b/tests/twisted/constants.py @@ -51,7 +51,6 @@ CHANNEL_IFACE_SUBJECT = CHANNEL + '.Interface.Subject1' CHANNEL_IFACE_FILE_TRANSFER_METADATA = CHANNEL + '.Interface.FileTransfer.Metadata1' CHANNEL_TYPE_CALL = CHANNEL + ".Type.Call1" -CHANNEL_TYPE_CONTACT_LIST = CHANNEL + ".Type.ContactList1" CHANNEL_TYPE_CONTACT_SEARCH = CHANNEL + ".Type.ContactSearch1" CHANNEL_TYPE_TEXT = CHANNEL + ".Type.Text" CHANNEL_TYPE_STREAM_TUBE = CHANNEL + ".Type.StreamTube1" @@ -186,10 +185,11 @@ CONTACT_LIST_STATE_SUCCESS = 3 CONN = PREFIX + ".Connection" CONN_IFACE_AVATARS = CONN + '.Interface.Avatars1' CONN_IFACE_ALIASING = CONN + '.Interface.Aliasing1' -CONN_IFACE_CONTACTS = CONN + '.Interface.Contacts' CONN_IFACE_CONTACT_CAPS = CONN + '.Interface.ContactCapabilities1' CONN_IFACE_CONTACT_INFO = CONN + ".Interface.ContactInfo1" CONN_IFACE_PRESENCE = CONN + '.Interface.Presence1' +CONN_IFACE_RENAMING = CONN + '.Interface.Renaming1' +CONN_IFACE_SIDECARS1 = CONN + '.Interface.Sidecars1' CONN_IFACE_REQUESTS = CONN + '.Interface.Requests' CONN_IFACE_LOCATION = CONN + '.Interface.Location1' CONN_IFACE_GABBLE_DECLOAK = CONN + '.Interface.Gabble.Decloak' @@ -202,12 +202,17 @@ CONN_IFACE_CONTACT_BLOCKING = CONN + '.Interface.ContactBlocking1' CONN_IFACE_ADDRESSING = CONN + '.Interface.Addressing1' CONN_IFACE_SERVICE_POINT = CONN + '.Interface.ServicePoint1' -ATTR_CONTACT_ID = CONN + '/contact-id' +ATTR_ALIAS = CONN_IFACE_ALIASING + '/alias' +ATTR_AVATAR_TOKEN = CONN_IFACE_AVATARS + '/token' +ATTR_CLIENT_TYPES = CONN_IFACE_CLIENT_TYPES + '/client-types' ATTR_CONTACT_CAPABILITIES = CONN_IFACE_CONTACT_CAPS + '/capabilities' +ATTR_CONTACT_ID = CONN + '/contact-id' +ATTR_CONTACT_INFO = CONN_IFACE_CONTACT_INFO + '/info' +ATTR_GROUPS = CONN_IFACE_CONTACT_GROUPS + '/groups' +ATTR_LOCATION = CONN_IFACE_LOCATION + '/location' ATTR_PRESENCE = CONN_IFACE_PRESENCE + '/presence' -ATTR_SUBSCRIBE = CONN_IFACE_CONTACT_LIST + '/subscribe' ATTR_PUBLISH = CONN_IFACE_CONTACT_LIST + '/publish' -ATTR_GROUPS = CONN_IFACE_CONTACT_GROUPS + '/groups' +ATTR_SUBSCRIBE = CONN_IFACE_CONTACT_LIST + '/subscribe' STREAM_HANDLER = PREFIX + '.Media.StreamHandler' @@ -333,7 +338,7 @@ FT_DATE = CHANNEL_TYPE_FILE_TRANSFER + '.Date' FT_AVAILABLE_SOCKET_TYPES = CHANNEL_TYPE_FILE_TRANSFER + '.AvailableSocketTypes' FT_TRANSFERRED_BYTES = CHANNEL_TYPE_FILE_TRANSFER + '.TransferredBytes' FT_INITIAL_OFFSET = CHANNEL_TYPE_FILE_TRANSFER + '.InitialOffset' -FT_FILE_COLLECTION = CHANNEL_TYPE_FILE_TRANSFER + '.FUTURE.FileCollection' +FT_FILE_COLLECTION = CHANNEL_TYPE_FILE_TRANSFER + '.FileCollection' FT_URI = CHANNEL_TYPE_FILE_TRANSFER + '.URI' FT_SERVICE_NAME = CHANNEL_IFACE_FILE_TRANSFER_METADATA + '.ServiceName' FT_METADATA = CHANNEL_IFACE_FILE_TRANSFER_METADATA + '.Metadata' @@ -565,6 +570,7 @@ CR = PREFIX + '.ChannelRequest' CDO = PREFIX + '.ChannelDispatchOperation' CD = PREFIX + '.ChannelDispatcher' +CD_IFACE_MESSAGES1 = PREFIX + '.ChannelDispatcher.Interface.Messages1' CD_IFACE_OP_LIST = PREFIX + '.ChannelDispatcher.Interface.OperationList1' CD_PATH = PATH_PREFIX + '/ChannelDispatcher' diff --git a/tests/twisted/servicetest.py b/tests/twisted/servicetest.py index 1363802..86212f3 100644 --- a/tests/twisted/servicetest.py +++ b/tests/twisted/servicetest.py @@ -197,7 +197,14 @@ class BaseEventQueue: t = time.time() while True: - event = self.wait([pattern.subqueue]) + try: + event = self.wait([pattern.subqueue]) + except TimeoutError: + self.log('timeout') + self.log('still expecting:') + self.log(' - %r' % pattern) + raise + self._check_forbidden(event) if pattern.match(event): @@ -619,26 +626,44 @@ def wrap_connection(conn): return ConnWrapper(conn, tp_name_prefix + '.Connection', dict( [('Peer', 'org.freedesktop.DBus.Peer'), + ('Contacts', cs.CONN), # backwards compat with Telepathy 0 ('Aliasing', cs.CONN_IFACE_ALIASING), ('Avatars', cs.CONN_IFACE_AVATARS), - ('Contacts', cs.CONN_IFACE_CONTACTS), ('ContactCapabilities', cs.CONN_IFACE_CONTACT_CAPS), ('ContactInfo', cs.CONN_IFACE_CONTACT_INFO), ('Location', cs.CONN_IFACE_LOCATION), ('Presence', cs.CONN_IFACE_PRESENCE), ('Requests', cs.CONN_IFACE_REQUESTS), - ('Future', tp_name_prefix + '.Connection.FUTURE'), ('MailNotification', cs.CONN_IFACE_MAIL_NOTIFICATION), ('ContactList', cs.CONN_IFACE_CONTACT_LIST), ('ContactGroups', cs.CONN_IFACE_CONTACT_GROUPS), + ('ContactBlocking', cs.CONN_IFACE_CONTACT_BLOCKING), ('PowerSaving', cs.CONN_IFACE_POWER_SAVING), ('Addressing', cs.CONN_IFACE_ADDRESSING), + ('ClientTypes', cs.CONN_IFACE_CLIENT_TYPES), + ('Renaming', cs.CONN_IFACE_RENAMING), + ('Sidecars1', cs.CONN_IFACE_SIDECARS1), ])) +class ChannelWrapper(ProxyWrapper): + def send_msg_sync(self, txt): + message = [ + { 'message-type': cs.MT_NORMAL, }, + { 'content-type': 'text/plain', + 'content': txt + }] + self.Text.SendMessage(message, 0) + def wrap_channel(chan, type_, extra=None): interfaces = { type_: tp_name_prefix + '.Channel.Type.' + type_, + 'Channel': cs.CHANNEL, 'Group': cs.CHANNEL_IFACE_GROUP, + 'Hold': cs.CHANNEL_IFACE_HOLD, + 'RoomConfig1': cs.CHANNEL_IFACE_ROOM_CONFIG, + 'ChatState': cs.CHANNEL_IFACE_CHAT_STATE, + 'Destroyable': cs.CHANNEL_IFACE_DESTROYABLE, + 'Password': cs.CHANNEL_IFACE_PASSWORD, } if extra: @@ -646,11 +671,14 @@ def wrap_channel(chan, type_, extra=None): (name, tp_name_prefix + '.Channel.Interface.' + name) for name in extra])) - return ProxyWrapper(chan, tp_name_prefix + '.Channel', interfaces) + return ChannelWrapper(chan, tp_name_prefix + '.Channel', interfaces) def wrap_content(chan, extra=None): - interfaces = { } + interfaces = { + 'DTMF': cs.CALL_CONTENT_IFACE_DTMF, + 'Media': cs.CALL_CONTENT_IFACE_MEDIA, + } if extra: interfaces.update(dict([ -- 1.8.5.2