From 559307912e940d7aec64743ff9cd60f129e97b38 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 2 Mar 2006 11:14:45 +0000 Subject: [PATCH] remove awaiting events associated to a FT when we remove it from FT window. Fixes #1553 --- src/filetransfers_window.py | 14 ++++++++++++++ src/gajim.py | 24 +++++++++++++++++++----- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/filetransfers_window.py b/src/filetransfers_window.py index 68bf35cf2..a3ff1e09b 100644 --- a/src/filetransfers_window.py +++ b/src/filetransfers_window.py @@ -451,6 +451,20 @@ _('Connection with peer cannot be established.')) if gajim.connections.has_key(account): # there is a connection to the account gajim.connections[account].remove_transfer(file_props) + if file_props['type'] == 'r': # we receive a file + other = file_props['sender'] + else: # we send a file + other = file_props['receiver'] + if isinstance(other, unicode): + jid = gajim.get_jid_without_resource(other) + else: # It's a Contact instance + jid = other.jid + if gajim.awaiting_events[account].has_key(jid): + for event in gajim.awaiting_events[account][jid]: + if event[0] in ('file-error', 'file-completed', + 'file-request-error', 'file-send-error', 'file-stopped') and \ + event[1]['sid'] == file_props['sid']: + gajim.interface.remove_event(account, jid, event) del(self.files_props[sid[0]][sid[1:]]) del(file_props) diff --git a/src/gajim.py b/src/gajim.py index 6e394e730..c03d7edbc 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -992,6 +992,7 @@ class Interface: # We add it to the awaiting_events queue # Do we have a queue? jid = gajim.get_jid_without_resource(jid) + print 'add_event', account, jid, typ qs = gajim.awaiting_events[account] no_queue = False if not qs.has_key(jid): @@ -1006,18 +1007,31 @@ class Interface: if self.systray_enabled: self.systray.add_jid(jid, account, typ) + def redraw_roster_systray(self, account, jid, typ = None): + self.roster.nb_unread -= 1 + self.roster.show_title() + self.roster.draw_contact(jid, account) + if self.systray_enabled: + self.systray.remove_jid(jid, account, typ) + def remove_first_event(self, account, jid, typ = None): qs = gajim.awaiting_events[account] event = gajim.get_first_event(account, jid, typ) qs[jid].remove(event) - self.roster.nb_unread -= 1 - self.roster.show_title() # Is it the last event? if not len(qs[jid]): del qs[jid] - self.roster.draw_contact(jid, account) - if self.systray_enabled: - self.systray.remove_jid(jid, account, typ) + self.redraw_roster_systray(account, jid, typ) + + def remove_event(self, account, jid, event): + qs = gajim.awaiting_events[account] + if not event in qs[jid]: + return + qs[jid].remove(event) + # Is it the last event? + if not len(qs[jid]): + del qs[jid] + self.redraw_roster_systray(account, jid, event[0]) def handle_event_file_request_error(self, account, array): jid = array[0]