changeset e472bdfe92b4 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=e472bdfe92b4
description: create a new session for every new file transfer; enable OpenSSL
diffstat:
src/common/jingle.py | 22 +++++++---------------
src/common/jingle_ft.py | 3 ---
src/common/jingle_session.py | 29 ++++++++++++++++++-----------
src/common/socks5.py | 12 ++++++------
4 files changed, 31 insertions(+), 35 deletions(-)
diffs (141 lines):
diff -r 4dbe49e6e8a9 -r e472bdfe92b4 src/common/jingle.py
--- a/src/common/jingle.py Mon Dec 26 21:18:45 2011 -0500
+++ b/src/common/jingle.py Tue Dec 27 23:47:00 2011 -0500
@@ -140,26 +140,18 @@
def start_file_transfer(self, jid, file_props):
logger.info("start file transfer with file: %s" % file_props)
- jingle = self.get_jingle_session(jid, media='file')
contact = gajim.contacts.get_contact_with_highest_priority(self.name,
gajim.get_jid_without_resource(jid))
if contact is None:
return
use_security = contact.supports(xmpp.NS_JINGLE_XTLS)
- if jingle:
- file_props['sid'] = jingle.sid
- c = JingleFileTransfer(jingle, file_props=file_props,
- use_security=use_security)
- jingle.add_content('file' + helpers.get_random_string_16(), c)
- jingle.on_session_state_changed(c)
- else:
- jingle = JingleSession(self, weinitiate=True, jid=jid)
- self._sessions[jingle.sid] = jingle
- file_props['sid'] = jingle.sid
- c = JingleFileTransfer(jingle, file_props=file_props,
- use_security=use_security)
- jingle.add_content('file' + helpers.get_random_string_16(), c)
- jingle.start_session()
+ jingle = JingleSession(self, weinitiate=True, jid=jid)
+ self._sessions[jingle.sid] = jingle
+ file_props['sid'] = jingle.sid
+ c = JingleFileTransfer(jingle, file_props=file_props,
+ use_security=use_security)
+ jingle.add_content('file' + helpers.get_random_string_16(), c)
+ jingle.start_session()
return c.transport.sid
diff -r 4dbe49e6e8a9 -r e472bdfe92b4 src/common/jingle_ft.py
--- a/src/common/jingle_ft.py Mon Dec 26 21:18:45 2011 -0500
+++ b/src/common/jingle_ft.py Tue Dec 27 23:47:00 2011 -0500
@@ -373,9 +373,6 @@
def start_transfer(self):
- # We start the transfer, session negociation is over.
- self.session.state = 0 # STATE 0 SESSION_ENDED
-
self.state = STATE_TRANSFERING
# It tells wether we start the transfer as client or server
diff -r 4dbe49e6e8a9 -r e472bdfe92b4 src/common/jingle_session.py
--- a/src/common/jingle_session.py Mon Dec 26 21:18:45 2011 -0500
+++ b/src/common/jingle_session.py Tue Dec 27 23:47:00 2011 -0500
@@ -488,19 +488,25 @@
# subscription) and the receiver has a policy of not communicating via
# Jingle with unknown entities, it SHOULD return a
<service-unavailable/>
# error.
-
- # Check if there's already a session with this user:
- for session in self.connection.iter_jingle_sessions(self.peerjid):
- if not session is self:
- reason = xmpp.Node('reason')
- alternative_session = reason.setTag('alternative-session')
- alternative_session.setTagData('sid', session.sid)
- self.__ack(stanza, jingle, error, action)
- self._session_terminate(reason)
- raise xmpp.NodeProcessed
-
+
+
# Lets check what kind of jingle session does the peer want
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':
+ for session in self.connection.iter_jingle_sessions(self.peerjid):
+ if not session is self:
+ reason = xmpp.Node('reason')
+ alternative_session = reason.setTag('alternative-session')
+ alternative_session.setTagData('sid', session.sid)
+ self.__ack(stanza, jingle, error, action)
+ self._session_terminate(reason)
+ raise xmpp.NodeProcessed
+
+
# If there's no content we understand...
if not contents:
@@ -699,6 +705,7 @@
self.connection.connection.send(stanza)
def _session_terminate(self, reason=None):
+ assert self.state != JingleStates.ended
stanza, jingle = self.__make_jingle('session-terminate', reason=reason)
self.__broadcast_all(stanza, jingle, None, 'session-terminate-sent')
if self.connection.connection and self.connection.connected >= 2:
diff -r 4dbe49e6e8a9 -r e472bdfe92b4 src/common/socks5.py
--- a/src/common/socks5.py Mon Dec 26 21:18:45 2011 -0500
+++ b/src/common/socks5.py Tue Dec 27 23:47:00 2011 -0500
@@ -517,10 +517,10 @@
for ai in self.ais:
try:
self._sock = socket.socket(*ai[:3])
- '''
+
if not self.fingerprint is None:
self._sock = OpenSSL.SSL.Connection(
- jingle_xtls.get_context('client'), self._sock)'''
+ jingle_xtls.get_context('client'), self._sock)
# this will not block the GUI
self._sock.setblocking(False)
self._server = ai[4]
@@ -956,12 +956,12 @@
if _sock is not None:
- '''if self.fingerprint is not None:
+ if self.fingerprint is not None:
self._sock = OpenSSL.SSL.Connection(
jingle_xtls.get_context('server'), _sock)
else:
self._sock.setblocking(False)
- '''
+
self.fd = _sock.fileno()
self._recv = _sock.recv
self._send = _sock.send
@@ -1445,9 +1445,9 @@
# try the different possibilities (ipv6, ipv4, etc.)
try:
self._serv = socket.socket(*ai[:3])
- '''if self.fingerprint is not None:
+ if self.fingerprint is not None:
self._serv = OpenSSL.SSL.Connection(
- jingle_xtls.get_context('server'), self._serv)'''
+ jingle_xtls.get_context('server'), self._serv)
except socket.error, e:
if e.args[0] == EAFNOSUPPORT:
self.ai = None
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits