Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Leboulanger <asterix@lagaule.org>2012-06-14 20:34:07 +0400
committerYann Leboulanger <asterix@lagaule.org>2012-06-14 20:34:07 +0400
commit1fdf6b7e35f48bbaafef7030e6d611f0d315a53a (patch)
treec9f56ebe6b554fe67363b5575e1abf6b7c8ef369
parent2af1af2011220d38d4ef13e2583134af8df6b12b (diff)
jingle IBB and normal IBB are different
-rw-r--r--src/common/connection_handlers_events.py36
-rw-r--r--src/common/protocol/bytestream.py14
-rw-r--r--src/common/xmpp/protocol.py28
3 files changed, 43 insertions, 35 deletions
diff --git a/src/common/connection_handlers_events.py b/src/common/connection_handlers_events.py
index 4a8fc1bde..a30c9f1f8 100644
--- a/src/common/connection_handlers_events.py
+++ b/src/common/connection_handlers_events.py
@@ -1978,6 +1978,21 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
self.file_props.stream_methods = xmpp.NS_BYTESTREAM
file_tag = self.jingle_content.getTag('description').getTag(
'offer').getTag('file')
+ for child in file_tag.getChildren():
+ name = child.getName()
+ val = child.getData()
+ if val is None:
+ continue
+ if name == 'name':
+ self.file_props.name = val
+ if name == 'size':
+ self.file_props.size = val
+ if name == 'hash':
+ self.file_props.algo = child.getAttr('algo')
+ self.file_props.hash_ = val
+ if name == 'date':
+ self.file_props.date = val
+
else:
profile = si.getAttr('profile')
if profile != xmpp.NS_FILE:
@@ -2002,20 +2017,13 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
typ='stream')
raise xmpp.NodeProcessed
file_tag = si.getTag('file')
- for child in file_tag.getChildren():
- name = child.getName()
- val = child.getData()
- if val is None:
- continue
- if name == 'name':
- self.file_props.name = val
- if name == 'size':
- self.file_props.size = val
- if name == 'hash':
- self.file_props.algo = child.getAttr('algo')
- self.file_props.hash_ = val
- if name == 'date':
- self.file_props.date = val
+ for name, val in file_tag.getAttrs().items():
+ if val is None:
+ continue
+ if name == 'name':
+ self.file_props.name = val
+ if name == 'size':
+ self.file_props.size = val
file_desc_tag = file_tag.getTag('desc')
if file_desc_tag is not None:
self.file_props.desc = file_desc_tag.getData()
diff --git a/src/common/protocol/bytestream.py b/src/common/protocol/bytestream.py
index 644c85454..0dd437d33 100644
--- a/src/common/protocol/bytestream.py
+++ b/src/common/protocol/bytestream.py
@@ -569,7 +569,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
err.setData(msg)
self.connection.send(iq)
if code == 404:
- file_props = FilesProp.getFileProp(self.name, sid)
+ file_props = FilesProp.getFileProp(self.name, sid)
if file_props is not None:
self.disconnect_transfer(file_props)
file_props.error = -3
@@ -584,7 +584,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
"""
if not self.connection or self.connected < 2:
return
- file_props = FilesProp.getFileProp(self.connection, proxy['sid'])
+ file_props = FilesProp.getFileProp(self.connection, proxy['sid'])
iq = xmpp.Iq(to=proxy['initiator'], typ='set')
auth_id = "au_" + proxy['sid']
iq.setID(auth_id)
@@ -617,7 +617,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
id_ = unicode(iq_obj.getAttr('id'))
query = iq_obj.getTag('query')
sid = unicode(query.getAttr('sid'))
- file_props = FilesProp.getFileProp(self.name, sid)
+ file_props = FilesProp.getFileProp(self.name, sid)
streamhosts = []
for item in query.getChildren():
if item.getName() == 'streamhost':
@@ -780,14 +780,14 @@ class ConnectionIBBytestream(ConnectionBytestream):
blocksize = stanza.getTagAttr('open', 'block-size')
log.debug('StreamOpenHandler called sid->%s blocksize->%s' % (sid,
blocksize))
- file_props = FilesProp.getFileProp(self.name, sid)
+ file_props = FilesProp.getFileProp(self.name, sid)
try:
blocksize = int(blocksize)
except:
err = xmpp.ERR_BAD_REQUEST
if not sid or not blocksize:
err = xmpp.ERR_BAD_REQUEST
- elif not file_props:
+ elif not file_props:
err = xmpp.ERR_UNEXPECTED_REQUEST
if err:
rep = xmpp.Error(stanza, err)
@@ -900,8 +900,8 @@ class ConnectionIBBytestream(ConnectionBytestream):
seq = ''
data = ''
err = None
- file_props = FilesProp.getFileProp(self.name, sid)
- if file_props is None:
+ file_props = FilesProp.getFileProp(self.name, sid)
+ if file_props is None:
err = xmpp.ERR_ITEM_NOT_FOUND
else:
if not data:
diff --git a/src/common/xmpp/protocol.py b/src/common/xmpp/protocol.py
index daac07278..d4c5fb254 100644
--- a/src/common/xmpp/protocol.py
+++ b/src/common/xmpp/protocol.py
@@ -167,7 +167,7 @@ NS_HASHES_MD5 = 'urn:xmpp:hash-function-textual-names:md5'
NS_HASHES_SHA1 = 'urn:xmpp:hash-function-textual-names:sha-1'
NS_HASHES_SHA256 = 'urn:xmpp:hash-function-textual-names:sha-256'
NS_HASHES_SHA512 = 'urn:xmpp:hash-function-textual-names:sha-512'
-
+
xmpp_stream_error_conditions = '''
bad-format -- -- -- The entity has sent XML that cannot be processed.
bad-namespace-prefix -- -- -- The entity has sent a namespace prefix that is unsupported, or has sent no namespace prefix on an element that requires such a prefix.
@@ -1037,12 +1037,12 @@ class Iq(Protocol):
attrs={'id': self.getID()})
iq.setQuery(self.getQuery().getName()).setNamespace(self.getQueryNS())
return iq
-
-class Hashes(Node):
+
+class Hashes(Node):
"""
Hash elements for various XEPs as defined in XEP-300
"""
-
+
"""
RECOMENDED HASH USE:
Algorithm Support
@@ -1053,14 +1053,14 @@ class Hashes(Node):
SHA-256 MUST
SHA-512 SHOULD
"""
-
+
supported = ('md5', 'sha-1', 'sha-256', 'sha-512')
-
+
def __init__(self, nsp=NS_HASHES):
Node.__init__(self, None, {}, [], None, None, False, None)
self.setNamespace(nsp)
self.setName('hash')
-
+
def calculateHash(self, algo, file_string):
"""
Calculate the hash and add it. It is preferable doing it here
@@ -1078,12 +1078,12 @@ class Hashes(Node):
hl = hashlib.sha256()
elif algo == 'sha-512':
hl = hashlib.sha512()
-
+
if hl:
hl.update(file_string)
hash_ = hl.hexdigest()
else: # if it is a file
-
+
if algo == 'md5':
hl = hashlib.md5()
elif algo == 'sha-1':
@@ -1092,18 +1092,18 @@ class Hashes(Node):
hl = hashlib.sha256()
elif algo == 'sha-512':
hl = hashlib.sha512()
-
+
if hl:
for line in file_string:
hl.update(line)
hash_ = hl.hexdigest()
-
- return hash_
-
+
+ return hash_
+
def addHash(self, hash_, algo):
self.setAttr('algo', algo)
self.setData(hash_)
-
+
class Acks(Node):
"""
Acknowledgement elements for Stream Management