This commit is contained in:
Goffi 2011-09-29 14:59:14 +02:00
commit c64b06921b
12 changed files with 51 additions and 51 deletions

View file

@ -52,7 +52,7 @@ v 0.0.2 (10/01/2010):
- Wokkel integration
- added some features from Wokkel: disco, software version
- new account creation (in-band registration): not fully implemented
- IP for file transfert is now set by default (see README)
- IP for file transfer is now set by default (see README)
- Gateways management (Wix only for now)
- VCard support (readonly for now) with avatars/nicks support
- Wix: easier jid setup

View file

@ -892,8 +892,8 @@ msgid "Confirmation asked"
msgstr "Confirmation demandée"
#: wix/main_window.py:241
msgid "File transfert confirmation asked"
msgstr "Demande de confirmation pour un transfert de fichier demandée"
msgid "File transfer confirmation asked"
msgstr "Demande de confirmation pour un transfer de fichier demandée"
#: wix/main_window.py:242
#, python-format

View file

@ -827,7 +827,7 @@ msgid "Confirmation asked"
msgstr ""
#: wix/main_window.py:241
msgid "File transfert confirmation asked"
msgid "File transfer confirmation asked"
msgstr ""
#: wix/main_window.py:242

View file

@ -74,7 +74,7 @@ class JP():
print(_(u"Can't connect to SàT backend, are you sure it's launched ?"))
import sys
sys.exit(1)
self.transfert_id = None
self.transfer_id = None
def check_options(self):
"""Check command line options"""
@ -187,18 +187,18 @@ class JP():
bz2.close()
info(_("OK !"))
path = abspath(tmpfile)
self.transfert_id = self.bridge.sendFile(self.dest_jid, path, {}, profile_key=self.profile)
self.transfer_id = self.bridge.sendFile(self.dest_jid, path, {}, profile_key=self.profile)
else:
for file in self.files:
path = abspath(file)
self.transfert_id = self.bridge.sendFile(self.dest_jid, path, {}, profile_key=self.profile) #FIXME: show progress only for last transfert_id
self.transfer_id = self.bridge.sendFile(self.dest_jid, path, {}, profile_key=self.profile) #FIXME: show progress only for last transfer_id
#TODO: manage ProgressBar
def askConfirmation(self, type, id, data):
"""CB used for file transfert, accept files depending on parameters"""
"""CB used for file transfer, accept files depending on parameters"""
answer_data={}
if type == "FILE_TRANSFERT":
if type == "FILE_TRANSFER":
if self.dest_jids and not data['from'] in self.dest_jids:
return #file is not sent by a filtered jid
@ -207,7 +207,7 @@ class JP():
if self.options.force or not os.path.exists(answer_data["dest_path"]):
self.bridge.confirmationAnswer(id, True, answer_data)
info(_("Accepted file [%(filename)s] from %(sender)s") % {'filename':data['filename'], 'sender':data['from']})
self.transfert_id = id
self.transfer_id = id
else:
self.bridge.confirmationAnswer(id, False, answer_data)
warning(_("Refused file [%(filename)s] from %(sender)s: a file with the same name already exist") % {'filename':data['filename'], 'sender':data['from']})
@ -226,8 +226,8 @@ class JP():
self.bridge.register("askConfirmation", self.askConfirmation)
def progressCB(self):
if self.transfert_id:
data = self.bridge.getProgress(self.transfert_id)
if self.transfer_id:
data = self.bridge.getProgress(self.transfer_id)
if data:
if not data['position']:
data['position'] = '0'

View file

@ -237,8 +237,8 @@ class MainWindow(wx.Frame, QuickApp):
#TODO: refactor this in QuickApp
debug (_("Confirmation asked"))
answer_data={}
if type == "FILE_TRANSFERT":
debug (_("File transfert confirmation asked"))
if type == "FILE_TRANSFER":
debug (_("File transfer confirmation asked"))
dlg = wx.MessageDialog(self, _("The contact %(jid)s wants to send you the file %(filename)s\nDo you accept ?") % {'jid':data["from"], 'filename':data["filename"]},
_('File Request'),
wx.YES_NO | wx.ICON_QUESTION

View file

@ -980,7 +980,7 @@ msgid "Asking registration for [%s]"
msgstr "Demande d'enregistrement pour [%s]"
#: plugins/plugin_xep_0096.py:52
msgid "Implementation of SI File Transfert"
msgid "Implementation of SI File Transfer"
msgstr ""
"Implémentation de l'initialisation de flux pour le transfert de fichier "
@ -999,12 +999,12 @@ msgstr "Fichier proposé: nom=[%(name)s] taille=%(size)s"
#: plugins/plugin_xep_0096.py:91
#, python-format
msgid "Transfert [%s] refused"
msgid "Transfer [%s] refused"
msgstr "Transfert [%s] refusé"
#: plugins/plugin_xep_0096.py:96
#, python-format
msgid "Transfert [%s] accepted"
msgid "Transfer [%s] accepted"
msgstr "Transfert [%s] accepté"
#: plugins/plugin_xep_0096.py:99

View file

@ -923,7 +923,7 @@ msgid "Asking registration for [%s]"
msgstr ""
#: plugins/plugin_xep_0096.py:52
msgid "Implementation of SI File Transfert"
msgid "Implementation of SI File Transfer"
msgstr ""
#: plugins/plugin_xep_0096.py:58
@ -941,12 +941,12 @@ msgstr ""
#: plugins/plugin_xep_0096.py:91
#, python-format
msgid "Transfert [%s] refused"
msgid "Transfer [%s] refused"
msgstr ""
#: plugins/plugin_xep_0096.py:96
#, python-format
msgid "Transfert [%s] accepted"
msgid "Transfer [%s] accepted"
msgstr ""
#: plugins/plugin_xep_0096.py:99

View file

@ -109,7 +109,7 @@ sig_in=ssa{ss}
doc=A confirmation is needed for an action
doc_param_0=conf_type: Type of the confirmation, can be:
- YES/NO: A question which need a yes or no answer
- FILE_TRANSFERT: A confirmation is needed before transfering a file
- FILE_TRANSFER: A confirmation is needed before transfering a file
doc_param_1=id: Id of the confirmation query
doc_param_2=data: conf_type dependent data

View file

@ -540,7 +540,7 @@ class SAT(service.Service):
def askConfirmation(self, id, type, data, cb):
"""Add a confirmation callback
@param id: id used to get answer
@param type: confirmation type ("YES/NO", "FILE_TRANSFERT")
@param type: confirmation type ("YES/NO", "FILE_TRANSFER")
@param data: data (depend of confirmation type)
@param cb: callback called with the answer
"""

View file

@ -101,7 +101,7 @@ class XEP_0047():
failure_cb(sid, file_obj, NS_IBB, failure_reason)
def getProgress(self, sid, data):
"""Fill data with position of current transfert"""
"""Fill data with position of current transfer"""
try:
file_obj = self.current_stream[sid]["file_obj"]
data["position"] = str(file_obj.tell())
@ -134,11 +134,11 @@ class XEP_0047():
sid = open_elt.getAttribute('sid')
stanza = open_elt.getAttribute('stanza', 'iq')
if not sid or not block_size or int(block_size)>65535:
warning(_("malformed IBB transfert: %s" % IQ['id']))
warning(_("malformed IBB transfer: %s" % IQ['id']))
self.sendNotAcceptableError(IQ['id'], IQ['from'], xmlstream)
return
if not sid in self.current_stream:
warning(_("Ignoring unexpected IBB transfert: %s" % sid))
warning(_("Ignoring unexpected IBB transfer: %s" % sid))
self.sendNotAcceptableError(IQ['id'], IQ['from'], xmlstream)
return
if self.current_stream[sid]["from"] != jid.JID(IQ['from']):

View file

@ -109,11 +109,11 @@ class XEP_0095():
self.sendError(id, to_jid, 400, 'cancel', profile=profile)
def sendFailedError(self, id, to_jid, profile):
"""Helper method to send when we transfert failed
"""Helper method to send when we transfer failed
@param id: IQ id
@param to_jid: recipient
@param profile: %(doc_profile)s"""
self.sendError(id, to_jid, 500, 'cancel', {'custom':'failed'}, profile=profile) #as there is no error code for failed transfert, we use 500 (undefined-condition)
self.sendError(id, to_jid, 500, 'cancel', {'custom':'failed'}, profile=profile) #as there is no error code for failed transfer, we use 500 (undefined-condition)
def sendError(self, id, to_jid, err_code, err_type='cancel', data={}, profile='@NONE@'):
"""Send IQ error as a result

View file

@ -46,7 +46,7 @@ PLUGIN_INFO = {
"dependencies": ["XEP-0020", "XEP-0095", "XEP-0065", "XEP-0047"],
"main": "XEP_0096",
"handler": "no",
"description": _("""Implementation of SI File Transfert""")
"description": _("""Implementation of SI File Transfer""")
}
class XEP_0096():
@ -54,30 +54,30 @@ class XEP_0096():
def __init__(self, host):
info(_("Plugin XEP_0096 initialization"))
self.host = host
self._waiting_for_approval = {} #key = id, value = [transfert data, IdelayedCall Reactor timeout,
self._waiting_for_approval = {} #key = id, value = [transfer data, IdelayedCall Reactor timeout,
# current stream method, [failed stream methods], profile]
self.managed_stream_m = [#self.host.plugins["XEP-0065"].NS_BS,
self.host.plugins["XEP-0047"].NAMESPACE] #Stream methods managed
self.host.plugins["XEP-0095"].registerSIProfile(PROFILE_NAME, self.transfertRequest)
self.host.plugins["XEP-0095"].registerSIProfile(PROFILE_NAME, self.transferRequest)
host.bridge.addMethod("sendFile", ".plugin", in_sign='ssa{ss}s', out_sign='s', method=self.sendFile)
def _kill_id(self, approval_id):
"""Delete a waiting_for_approval id, called after timeout
@param approval_id: id of _waiting_for_approval"""
info(_("SI File Transfert: TimeOut reached for id %s") % approval_id);
info(_("SI File Transfer: TimeOut reached for id %s") % approval_id);
try:
del self._waiting_for_approval[approval_id]
except KeyError:
warning(_("kill id called on a non existant approval id"))
def transfertRequest(self, from_jid, si_id, si_mime_type, si_el, profile):
"""Called when a file transfert is requested
def transferRequest(self, from_jid, si_id, si_mime_type, si_el, profile):
"""Called when a file transfer is requested
@param from_jid: jid of the sender
@param si_id: Stream Initiation session id
@param si_mime_type: Mime type of the file (or default "application/octet-stream" if unknown)
@param si_el: domish.Element of the request
@param profile: %(doc_profile)s"""
info (_("XEP-0096 file transfert requested"))
info (_("XEP-0096 file transfer requested"))
debug(si_el.toXml())
filename = ""
file_size = ""
@ -123,11 +123,11 @@ class XEP_0096():
self.host.plugins["XEP-0095"].sendBadRequestError(si_id, from_jid, profile)
return
#if we are here, the transfert can start, we just need user's agreement
#if we are here, the transfer can start, we just need user's agreement
data={ "filename":filename, "from":from_jid, "size":file_size, "date":file_date, "hash":file_hash, "desc":file_desc, "can_range": str(can_range) }
self._waiting_for_approval[si_id] = [data, reactor.callLater(300, self._kill_id, si_id), stream_method, [], profile]
self.host.askConfirmation(si_id, "FILE_TRANSFERT", data, self.confirmationCB)
self.host.askConfirmation(si_id, "FILE_TRANSFER", data, self.confirmationCB)
def _getFileObject(self, dest_path, can_range = False):
@ -139,8 +139,8 @@ class XEP_0096():
def confirmationCB(self, id, accepted, frontend_data):
"""Called on confirmation answer
@param id: file transfert session id
@param accepted: True if file transfert is accepted
@param id: file transfer session id
@param accepted: True if file transfer is accepted
@param frontend_data: data sent by frontend"""
data, timeout, stream_method, failed_methods, profile = self._waiting_for_approval[id]
can_range = data['can_range'] == "True"
@ -161,7 +161,7 @@ class XEP_0096():
range_offset = file_obj.tell()
self.host.plugins["XEP-0047"].prepareToReceive(jid.JID(data['from']), id, file_obj, int(data["size"]), self._transferSucceeded, self._transferFailed)
else:
error(_("Unknown stream method, this should not happen at this stage, cancelling transfert"))
error(_("Unknown stream method, this should not happen at this stage, cancelling transfer"))
del(self._waiting_for_approval[id])
return
@ -176,29 +176,29 @@ class XEP_0096():
misc_elts.append(range_elt)
self.host.plugins["XEP-0095"].acceptStream(id, data['from'], feature_elt, misc_elts, profile)
else:
debug (_("Transfert [%s] refused"), id)
debug (_("Transfer [%s] refused"), id)
self.host.plugins["XEP-0095"].sendRejectedError (id, data['from'], profile=profile)
del(self._waiting_for_approval[id])
def _transferSucceeded(self, sid, file_obj, stream_method):
"""Called by the stream method when transfert successfuly finished
"""Called by the stream method when transfer successfuly finished
@param id: stream id"""
file_obj.close()
info(_('Transfert %s successfuly finished') % sid)
info(_('Transfer %s successfuly finished') % sid)
del(self._waiting_for_approval[sid])
def _transferFailed(self, sid, file_obj, stream_method, reason):
"""Called when something went wrong with the transfert
"""Called when something went wrong with the transfer
@param id: stream id
@param reason: can be TIMEOUT, IO_ERROR, PROTOCOL_ERROR"""
data, timeout, stream_method, failed_methods, profile = self._waiting_for_approval[sid]
warning(_('Transfert %(id)s failed with stream method %(s_method)s') % { 'id': sid,
warning(_('Transfer %(id)s failed with stream method %(s_method)s') % { 'id': sid,
's_method': stream_method })
filepath = file_obj.name
file_obj.close()
os.remove(filepath)
#TODO: session remenber (within a time limit) when a stream method fail, and avoid that stream method with full jid for the rest of the session
warning(_("All stream methods failed, can't transfert the file"))
warning(_("All stream methods failed, can't transfer the file"))
self.host.plugins["XEP-0095"].sendFailedError(id, data['from'], profile)
del(self._waiting_for_approval[id])
@ -206,10 +206,10 @@ class XEP_0096():
if IQ['type'] == "error":
stanza_err = jab_error.exceptionFromStanza(IQ)
if stanza_err.code == '403' and stanza_err.condition == 'forbidden':
debug(_("File transfert refused by %s") % IQ['from'])
debug(_("File transfer refused by %s") % IQ['from'])
self.host.bridge.newAlert(_("The contact %s refused your file") % IQ['from'], _("File refused"), "INFO", profile)
else:
warning(_("Error during file transfert with %s") % IQ['from'])
warning(_("Error during file transfer with %s") % IQ['from'])
self.host.bridge.newAlert(_("Something went wrong during the file transfer session intialisation with %s") % IQ['from'], _("File transfer error"), "ERROR", profile)
return
@ -248,8 +248,8 @@ class XEP_0096():
#query=offer.addElement('query', 'http://jabber.org/protocol/bytestreams')
query['mode']='tcp'
streamhost=query.addElement('streamhost')
streamhost['host']=self.host.memory.getParamA("IP", "File Transfert")
streamhost['port']=self.host.memory.getParamA("Port", "File Transfert")
streamhost['host']=self.host.memory.getParamA("IP", "File Transfer")
streamhost['port']=self.host.memory.getParamA("Port", "File Transfer")
streamhost['jid']=current_jid.full()
offer.send()"""
elif stream_method == self.host.plugins["XEP-0047"].NAMESPACE:
@ -267,7 +267,7 @@ class XEP_0096():
@data: dictionnary with the optional following keys:
- "description": description of the file
@param profile_key: %(doc_profile_key)s
@return: an unique id to identify the transfert
@return: an unique id to identify the transfer
"""
profile = self.host.memory.getProfileName(profile_key)
if not profile:
@ -298,4 +298,4 @@ class XEP_0096():
def sendFailureCb(self, sid, file_obj, stream_method, reason):
file_obj.close()
warning(_('Transfert %(id)s failed with stream method %(s_method)s') % { 'id': sid, s_method: stream_method })
warning(_('Transfer %(id)s failed with stream method %(s_method)s') % { 'id': sid, s_method: stream_method })