show disconnected, when recipient rejects

transfer
This commit is contained in:
Dimitur Kirov 2005-08-03 16:21:23 +00:00
parent 148db88343
commit e7536c0679
3 changed files with 32 additions and 14 deletions

View File

@ -351,7 +351,7 @@ class Connection:
prs.getReason(), prs.getActor(), prs.getStatusCode(),
prs.getNewNick()))
else:
self.dispatch('ERROR_ANSWER', (prs.getFrom().getStripped(), errmsg,
self.dispatch('ERROR_ANSWER', ('', prs.getFrom().getStripped(), errmsg,
errcode))
if not ptype or ptype == 'unavailable':
jid = prs.getFrom()
@ -861,7 +861,8 @@ class Connection:
errmsg = iq_obj.getError()
errcode = iq_obj.getErrorCode()
jid_from = str(iq_obj.getFrom())
self.dispatch('ERROR_ANSWER', (jid_from, errmsg, errcode))
id = str(iq_obj.getID())
self.dispatch('ERROR_ANSWER', (id, jid_from, errmsg, errcode))
def _StanzaArrivedCB(self, con, obj):
self.last_incoming = time.time()

View File

@ -47,6 +47,8 @@ class SocksQueue:
if self.listener == None:
self.listener = Socks5Listener(host, port)
self.listener.bind()
if self.listener.started is False:
return None
self.connected += 1
return self.listener
@ -84,8 +86,7 @@ class SocksQueue:
if not self.files_props.has_key(account):
self.files_props[account] = {}
self.files_props[account][id] = file_props
def get_file_props(self, account, id):
def get_file_props(self, account, sid):
if self.files_props.has_key(account):
fl_props = self.files_props[account]
if fl_props.has_key(id):
@ -276,7 +277,6 @@ class Socks5:
def _get_request_buff(self, msg, command = 0x01):
''' Connect request by domain name,
sid sha, instead of domain name (jep 0096) '''
#~ msg = self._get_sha1_auth()
buff = struct.pack('!BBBBB%dsBB' % len(msg), \
0x05, command, 0x00, 0x03, len(msg), msg, 0, 0)
return buff
@ -337,11 +337,13 @@ class Socks5Sender(Socks5):
self.state = 4
self.fd.close()
self.disconnect()
self.file_props['error'] = -1
return -1
self.size += lenn
self.file_props['received-len'] = self.size
if self.size == int(self.file_props['size']):
self.state = 4
self.file_props['error'] = 0
self.fd.close()
self.disconnect()
return -1
@ -370,6 +372,7 @@ class Socks5Sender(Socks5):
file_props['started'] = True
file_props['completed'] = False
file_props['paused'] = False
file_props['received-len'] = 0
self.pauses = 0
self.file_props = file_props
self.size = 0
@ -428,12 +431,15 @@ class Socks5Listener:
self._sock = None
def bind(self):
self._serv=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
self._serv.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
self._serv.bind((self.host, self.port))
self._serv.listen(socket.SOMAXCONN)
try:
self._serv=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
self._serv.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
self._serv.bind((self.host, self.port))
self._serv.listen(socket.SOMAXCONN)
except Exception, (errno, errstr):
return None
self._serv.setblocking(False)
self.started = True
@ -460,7 +466,8 @@ class Socks5Receiver(Socks5):
self.queue_idx = -1
self.queue = None
self.file_props = file_props
self.file_props['started'] = True
self.file_props['started'] = True
self.connected = False
if file_props:
file_props['disconnect_cb'] = self.disconnect
file_props['error'] = 0

View File

@ -198,8 +198,18 @@ class Interface:
dialogs.InformationDialog(data[0], data[1]).get_response()
def handle_event_error_answer(self, account, array):
#('ERROR_ANSWER', account, (jid_from. errmsg, errcode))
jid_from = array[0]
id, jid_from, errmsg, errcode = array
if str(errcode) == '403' and id:
ft = self.windows['file_transfers']
if ft.files_props['s'].has_key(id):
file_props = ft.files_props['s'][id]
file_props['error'] = -1
if file_props.has_key('disconnect_cb') and \
file_props['disconnect_cb'] is not None:
file_props['disconnect_cb']()
self.handle_event_file_rcv_completed(account, file_props)
return
#('ERROR_ANSWER', account, (id, jid_from. errmsg, errcode))
if jid_from in self.windows[account]['gc']:
self.windows[account]['gc'][jid_from].print_conversation(
'Error %s: %s' % (array[2], array[1]), jid_from)