From 5406f8b49c57e1034ff96d15bba08042dbbbcb06 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 2 Oct 2009 16:47:42 +0200 Subject: [PATCH] improve connection time to muc. --- src/common/connection.py | 46 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index 6485cd825..2df4f7a21 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -1754,27 +1754,6 @@ class Connection(ConnectionHandlers): if show == 'invisible': # Never join a room when invisible return - p = common.xmpp.Presence(to = '%s/%s' % (room_jid, nick), - show = show, status = self.status) - if gajim.config.get('send_sha_in_gc_presence'): - p = self.add_sha(p) - self.add_lang(p) - if not change_nick: - t = p.setTag(common.xmpp.NS_MUC + ' x') - last_date = gajim.logger.get_last_date_that_has_logs(room_jid, - self.name, is_room=True) - if last_date is None: - last_date = time.time() - gajim.config.get( - 'muc_restore_timeout') * 60 - else: - last_time = min(last_date, time.time() - gajim.config.get( - 'muc_restore_timeout') * 60) - last_date = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(last_date)) - t.setTag('history', {'maxstanzas': gajim.config.get( - 'muc_restore_lines'), 'since': last_date}) - if password: - t.setTagData('password', password) - self.connection.send(p) # last date/time in history to avoid duplicate if room_jid not in self.last_history_time: @@ -1787,12 +1766,33 @@ class Connection(ConnectionHandlers): if last_log is None: # Not in special table, get it from messages DB last_log = gajim.logger.get_last_date_that_has_logs(room_jid, - is_room = True) + is_room=True) # Create self.last_history_time[room_jid] even if not logging, # could be used in connection_handlers if last_log is None: last_log = 0 - self.last_history_time[room_jid]= last_log + self.last_history_time[room_jid] = last_log + + p = common.xmpp.Presence(to = '%s/%s' % (room_jid, nick), + show = show, status = self.status) + if gajim.config.get('send_sha_in_gc_presence'): + p = self.add_sha(p) + self.add_lang(p) + if not change_nick: + t = p.setTag(common.xmpp.NS_MUC + ' x') + last_date = self.last_history_time[room_jid] + if last_date = 0: + last_date = time.time() - gajim.config.get( + 'muc_restore_timeout') * 60 + else: + last_time = min(last_date, time.time() - gajim.config.get( + 'muc_restore_timeout') * 60) + last_date = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(last_date)) + t.setTag('history', {'maxstanzas': gajim.config.get( + 'muc_restore_lines'), 'since': last_date}) + if password: + t.setTagData('password', password) + self.connection.send(p) def send_gc_message(self, jid, msg, xhtml = None): if not self.connection: