moved session.remove_events. fixes #3942

This commit is contained in:
Brendan Taylor 2008-05-14 00:34:02 +00:00
parent f8b12e3b6b
commit ade56853fe
3 changed files with 21 additions and 16 deletions

View File

@ -924,7 +924,7 @@ class ChatControlBase(MessageControl):
self.parent_win.get_active_control() == self and \
self.parent_win.window.is_active():
# we are at the end
if not self.session.remove_events(types_list):
if self.session.remove_events(types_list):
# There were events to remove
self.redraw_after_event_removed(jid)

View File

@ -49,6 +49,26 @@ class StanzaSession(object):
return self.loggable and account not in no_log_for and self.jid not in no_log_for
# remove events associated with this session from the queue
# returns True if any events were removed (unlike gajim.events.remove_events)
def remove_events(self, types):
any_removed = False
for event in gajim.events.get_events(self.conn.name, self.jid, types=types):
# the event wasn't in this session
if (event.type_ == 'chat' and event.parameters[8] != self) or \
(event.type_ == 'printed_chat' and event.parameters[0] != self):
continue
# events.remove_events returns True when there were no events
# for some reason
r = gajim.events.remove_events(self.conn.name, self.jid, event)
if not r:
any_removed = True
return any_removed
def generate_thread_id(self):
return "".join([random.choice(string.ascii_letters) for x in xrange(0,32)])

View File

@ -26,21 +26,6 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
if self.control:
self.control.session = None
# remove events associated with this session from the queue
def remove_events(self, types):
any_removed = False
for event in gajim.events.get_events(self.conn, self.jid, types=types):
if event.parameters[8] != self:
continue
r = gajim.events.remove_events(self.conn, self.jid, event)
if not_any_removed:
any_removed = r
return any_removed
# extracts chatstate from a <message/> stanza
def get_chatstate(self, msg, msgtxt):
composing_xep = None