diff --git a/gajim/common/jingle.py b/gajim/common/jingle.py
index 6903679b9..4ff16e0c8 100644
--- a/gajim/common/jingle.py
+++ b/gajim/common/jingle.py
@@ -163,9 +163,14 @@ class ConnectionJingle(object):
transport = JingleTransportSocks5()
elif contact.supports(nbxmpp.NS_JINGLE_IBB):
transport = JingleTransportIBB()
+
+ senders = 'initiator'
+ if request:
+ senders = 'responder'
c = JingleFileTransfer(jingle, transport=transport,
file_props=file_props,
- use_security=use_security)
+ use_security=use_security,
+ senders=senders)
file_props.algo = self.__hash_support(contact)
jingle.add_content('file' + helpers.get_random_string_16(), c)
jingle.start_session()
diff --git a/gajim/common/jingle_content.py b/gajim/common/jingle_content.py
index 4108f8ebc..2e1ba2680 100644
--- a/gajim/common/jingle_content.py
+++ b/gajim/common/jingle_content.py
@@ -42,7 +42,7 @@ class JingleContent:
An abstraction of content in Jingle sessions
"""
- def __init__(self, session, transport):
+ def __init__(self, session, transport, senders):
self.session = session
self.transport = transport
# will be filled by JingleSession.add_content()
@@ -56,7 +56,10 @@ class JingleContent:
self.media = None
- self.senders = 'both' #FIXME
+ self.senders = senders
+ if self.senders is None:
+ self.senders = 'both'
+
self.allow_sending = True # Used for stream direction, attribute 'senders'
# These were found by the Politie
@@ -138,7 +141,9 @@ class JingleContent:
if payload is None:
payload = []
return nbxmpp.Node('content',
- attrs={'name': self.name, 'creator': self.creator},
+ attrs={'name': self.name,
+ 'creator': self.creator,
+ 'senders': self.senders},
payload=payload)
def send_candidate(self, candidate):
diff --git a/gajim/common/jingle_ft.py b/gajim/common/jingle_ft.py
index 3f7eae168..d16b7430a 100644
--- a/gajim/common/jingle_ft.py
+++ b/gajim/common/jingle_ft.py
@@ -58,8 +58,8 @@ class State(IntEnum):
class JingleFileTransfer(JingleContent):
def __init__(self, session, transport=None, file_props=None,
- use_security=False):
- JingleContent.__init__(self, session, transport)
+ use_security=False, senders=None):
+ JingleContent.__init__(self, session, transport, senders)
log.info("transport value: %s", transport)
# events we might be interested in
self.callbacks['session-initiate'] += [self.__on_session_initiate]
diff --git a/gajim/common/jingle_session.py b/gajim/common/jingle_session.py
index 371baf56c..996f07813 100644
--- a/gajim/common/jingle_session.py
+++ b/gajim/common/jingle_session.py
@@ -526,7 +526,7 @@ class JingleSession:
contents, contents_rejected, reason_txt = self.__parse_contents(jingle)
# If we are not receivin a file
# Check if there's already a session with this user:
- if contents[0][0] != 'file':
+ if contents[0].media != 'file':
for session in self.connection.iter_jingle_sessions(self.peerjid):
if session is not self:
reason = nbxmpp.Node('reason')
@@ -538,8 +538,7 @@ class JingleSession:
else:
# Stop if we don't have the requested file or the peer is not
# allowed to request the file
- request = \
- jingle.getTag('content').getTag('description').getTag('request')
+ request = contents[0].senders == 'responder'
if request:
self.request = True
hash_tag = request.getTag('file').getTag('hash')
@@ -568,7 +567,7 @@ class JingleSession:
gajim.nec.push_incoming_event(JingleRequestReceivedEvent(None,
conn=self.connection,
jingle_session=self,
- contents=contents))
+ contents=contents[0]))
def __broadcast(self, stanza, jingle, error, action):
"""
@@ -624,6 +623,7 @@ class JingleSession:
contents_rejected = []
reasons = set()
for element in jingle.iterTags('content'):
+ senders = element.getAttr('senders')
transport = get_jingle_transport(element.getTag('transport'))
if transport:
transport.ourjid = self.ourjid
@@ -631,10 +631,11 @@ class JingleSession:
if content_type:
try:
if transport:
- content = content_type(self, transport)
+ content = content_type(
+ self, transport=transport, senders=senders)
self.add_content(element['name'],
content, 'peer')
- contents.append((content.media,))
+ contents.append(content)
else:
reasons.add('unsupported-transports')
contents_rejected.append((element['name'], 'peer'))
@@ -711,12 +712,12 @@ class JingleSession:
@staticmethod
def __append_content(jingle, content):
"""
- Append element to element, with (full=True) or
- without (full=False) children
+ Append element to element
"""
jingle.addChild('content',
attrs={'name': content.name,
- 'creator': content.creator})
+ 'creator': content.creator,
+ 'senders': content.senders})
def __append_contents(self, jingle):
"""
diff --git a/gajim/gui_interface.py b/gajim/gui_interface.py
index 2df08b8f2..c1f36c4cd 100644
--- a/gajim/gui_interface.py
+++ b/gajim/gui_interface.py
@@ -1225,7 +1225,7 @@ class Interface:
# TODO: conditional blocking if peer is not in roster
account = obj.conn.name
- content_types = set(c[0] for c in obj.contents)
+ content_types = obj.contents.media
# check type of jingle session
if 'audio' in content_types or 'video' in content_types: