plugin XEP-0065: refactored and misc stuff fixed. Still not finished

plugins XEP-0096: XEP-0065 (Socks5 stream method) managed
This commit is contained in:
Goffi 2011-10-03 18:05:15 +02:00
commit 1225131aec

View file

@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from logging import debug, info, warning, error
from twisted.internet import protocol
from twisted.words.protocols.jabber import client, jid
from twisted.words.protocols.jabber import error as jab_error
from twisted.words.xish import domish
@ -85,7 +84,8 @@ class XEP_0047():
if self.current_stream[sid].has_key("observer_cb"):
xmlstream = self.current_stream[sid]["xmlstream"]
xmlstream.removeObserver(self.current_stream[sid]["event_data"], self.current_stream[sid]["observer_cb"])
self.current_stream[sid]['timer'].cancel()
if self.current_stream[sid]['timer'].active():
self.current_stream[sid]['timer'].cancel()
if self.current_stream[sid].has_key("size"):
self.host.removeProgressCB(sid)
@ -112,8 +112,11 @@ class XEP_0047():
def prepareToReceive(self, from_jid, sid, file_obj, size, success_cb, failure_cb):
"""Called when a bytestream is imminent
@param from_jid: jid of the sender
@param id: Stream id
@param file_obj: File Object where the data will be written"""
@param sid: Stream id
@param file_obj: File object where data will be written
@param size: full size of the data, or None if unknown
@param success_cb: method to call when successfuly finished
@param failure_cb: method to call when something goes wrong"""
data = self.current_stream[sid] = {}
data["from"] = from_jid
data["file_obj"] = file_obj
@ -288,7 +291,7 @@ class XEP_0047():
def iqResult(self, sid, seq, length, iq_elt):
"""Called when the result of open iq is received"""
data = self.current_stream[sid]
if iq_elt.type == "error":
if iq_elt["type"] == "error":
warning(_("Transfer failed"))
self.terminateStream(sid, "IQ_ERROR")
return