IBB supports file request

This commit is contained in:
Jefry Lagrange 2012-09-15 10:39:35 -04:00
parent a3c486f2b1
commit c22f5db122
2 changed files with 16 additions and 7 deletions

View File

@ -69,13 +69,15 @@ class JingleFileTransfer(JingleContent):
self.callbacks['iq-result'] += [self.__on_iq_result]
self.use_security = use_security
self.file_props = file_props
if file_props is None:
self.weinitiate = False
else:
self.weinitiate = True
self.weinitiate = self.session.weinitiate
self.werequest = self.session.werequest
if self.file_props is not None:
self.file_props.sender = session.ourjid
self.file_props.receiver = session.peerjid
if self.session.werequest:
self.file_props.sender = self.session.peerjid
self.file_props.receiver = self.session.ourjid
else:
self.file_props.sender = self.session.ourjid
self.file_props.receiver = self.session.peerjid
self.file_props.session_type = 'jingle'
self.file_props.sid = session.sid
self.file_props.transfered_size = []
@ -172,6 +174,9 @@ class JingleFileTransfer(JingleContent):
response = stanza.buildReply('result')
response.delChild(response.getQuery())
con.connection.send(response)
# If we are requesting we don't have the file
if self.session.werequest:
raise xmpp.NodeProcessed
# We send the file
self.__state_changed(STATE_TRANSFERING)
raise xmpp.NodeProcessed
@ -359,6 +364,10 @@ class JingleFileTransfer(JingleContent):
else:
return self.weinitiate
def start_IBB_transfer(self):
if self.file_props.type_ == 's':
self.__state_changed(STATE_TRANSFERING)
def get_content(desc):
return JingleFileTransfer

View File

@ -366,7 +366,6 @@ class JingleSession(object):
error_name = child.getName()
self.__dispatch_error(error_name, text, error.getAttr('type'))
# FIXME: Not sure when we would want to do that...
def transport_replace(self):
transport = JingleTransportIBB()
# For debug only, delete this and replace for a function
@ -399,6 +398,7 @@ class JingleSession(object):
self.contents[(creator,name)].state = STATE_TRANSPORT_REPLACE
self.__ack(stanza, jingle, error, action)
self.__session_accept()
self.contents[(creator,name)].start_IBB_transfer()
else:
stanza, jingle = self.__make_jingle('transport-reject')
content = jingle.setTag('content', attrs={'creator': creator,