From 320157ec8275f7a76e231a9b4c04e56f79e8001d Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sun, 14 Mar 2010 22:12:10 +0100 Subject: [PATCH] ability to do jingle with zeroconf --- src/common/jingle_session.py | 5 +++-- src/common/zeroconf/client_zeroconf.py | 5 ++++- src/common/zeroconf/connection_handlers_zeroconf.py | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/common/jingle_session.py b/src/common/jingle_session.py index d19b407e5..9ce290c9d 100644 --- a/src/common/jingle_session.py +++ b/src/common/jingle_session.py @@ -68,8 +68,9 @@ class JingleSession(object): self.connection = con # connection to use # our full jid #FIXME: Get rid of gajim here? - self.ourjid = gajim.get_jid_from_account(self.connection.name) + '/' + \ - con.server_resource + self.ourjid = gajim.get_jid_from_account(self.connection.name) + if con.server_resource: + self.ourjid = self.ourjid + '/' + con.server_resource self.peerjid = jid # jid we connect to # jid we use as the initiator self.initiator = weinitiate and self.ourjid or self.peerjid diff --git a/src/common/zeroconf/client_zeroconf.py b/src/common/zeroconf/client_zeroconf.py index 2d6eb97b7..ffad257c3 100644 --- a/src/common/zeroconf/client_zeroconf.py +++ b/src/common/zeroconf/client_zeroconf.py @@ -319,6 +319,9 @@ class P2PClient(IdleObject): common.xmpp.NS_BYTESTREAM) self.RegisterHandler('iq', self._caller._DiscoverItemsGetCB, 'get', common.xmpp.NS_DISCO_ITEMS) + self.RegisterHandler('iq', self._caller._JingleCB, 'result') + self.RegisterHandler('iq', self._caller._JingleCB, 'error') + self.RegisterHandler('iq', self._caller._JingleCB, 'set', common.xmpp.NS_JINGLE) class P2PConnection(IdleObject, PlugIn): def __init__(self, sock_hash, _sock, host=None, port=None, caller=None, @@ -765,7 +768,7 @@ class ClientZeroconf: """ Generate a random id """ - ''.join(Random().sample(string.letters + string.digits, 6)) + return ''.join(Random().sample(string.letters + string.digits, 6)) def RegisterDisconnectHandler(self, handler): """ diff --git a/src/common/zeroconf/connection_handlers_zeroconf.py b/src/common/zeroconf/connection_handlers_zeroconf.py index 876d1a350..ace1b771e 100644 --- a/src/common/zeroconf/connection_handlers_zeroconf.py +++ b/src/common/zeroconf/connection_handlers_zeroconf.py @@ -72,11 +72,12 @@ class ConnectionVcard(connection_handlers.ConnectionVcard): class ConnectionHandlersZeroconf(ConnectionVcard, ConnectionSocks5BytestreamZeroconf, ConnectionCommands, ConnectionPEP, -connection_handlers.ConnectionHandlersBase): +connection_handlers.ConnectionHandlersBase, connection_handlers.ConnectionJingle): def __init__(self): ConnectionVcard.__init__(self) ConnectionSocks5BytestreamZeroconf.__init__(self) ConnectionCommands.__init__(self) + connection_handlers.ConnectionJingle.__init__(self) connection_handlers.ConnectionHandlersBase.__init__(self) try: