diff src/plugins/plugin_xep_0096.py @ 391:c34fd9d6242e

spelling
author Goffi <goffi@goffi.org>
date Thu, 29 Sep 2011 14:59:14 +0200
parents deeebf697d9a
children 8f3551ceee17
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0096.py	Thu Sep 29 14:43:33 2011 +0200
+++ b/src/plugins/plugin_xep_0096.py	Thu Sep 29 14:59:14 2011 +0200
@@ -46,7 +46,7 @@
 "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 @@
     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 @@
             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 @@
 
     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 @@
                 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 @@
                 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 @@
         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 @@
             #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 @@
         @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 @@
 
     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 })