fix bug when merging server logs of MUC conversations

This commit is contained in:
Yann Leboulanger 2009-11-15 15:37:41 +01:00
parent 72420b0e73
commit 623a51d53f
4 changed files with 23 additions and 18 deletions

View File

@ -1243,12 +1243,12 @@ class ConnectionVcard:
pass pass
elif self.awaiting_answers[id_][0] == ARCHIVING_COLLECTION_ARRIVED: elif self.awaiting_answers[id_][0] == ARCHIVING_COLLECTION_ARRIVED:
def save_if_not_exists(with_, direction, tim, payload): def save_if_not_exists(with_, nick, direction, tim, payload):
assert len(payload) == 1, 'got several archiving messages in the' +\ assert len(payload) == 1, 'got several archiving messages in the' +\
' same time %s' % ''.join(payload) ' same time %s' % ''.join(payload)
if payload[0].getName() == 'body': if payload[0].getName() == 'body':
gajim.logger.save_if_not_exists(with_, direction, tim, gajim.logger.save_if_not_exists(with_, direction, tim,
msg=payload[0].getData()) msg=payload[0].getData(), nick=nick)
elif payload[0].getName() == 'message': elif payload[0].getName() == 'message':
print 'Not implemented' print 'Not implemented'
chat = iq_obj.getTag('chat') chat = iq_obj.getTag('chat')
@ -1265,12 +1265,13 @@ class ConnectionVcard:
secs = 0 secs = 0
if secs: if secs:
tim += secs tim += secs
nick = element.getAttr('name')
if element.getName() == 'from': if element.getName() == 'from':
save_if_not_exists(with_, 'from', localtime(tim), save_if_not_exists(with_, nick, 'from', localtime(tim),
element.getPayload()) element.getPayload())
nb += 1 nb += 1
if element.getName() == 'to': if element.getName() == 'to':
save_if_not_exists(with_, 'to', localtime(tim), save_if_not_exists(with_, nick, 'to', localtime(tim),
element.getPayload()) element.getPayload())
nb += 1 nb += 1
set_ = chat.getTag('set') set_ = chat.getTag('set')

View File

@ -981,16 +981,21 @@ class Logger:
(account_jid_id,)) (account_jid_id,))
self.con.commit() self.con.commit()
def save_if_not_exists(self, with_, direction, tim, msg=''): def save_if_not_exists(self, with_, direction, tim, msg='', nick=None):
if tim: if tim:
time_col = int(float(time.mktime(tim))) time_col = int(float(time.mktime(tim)))
else: else:
time_col = int(float(time.time())) time_col = int(float(time.time()))
if msg: if msg:
if self.jid_is_from_pm(with_): if self.jid_is_room_jid(with_) or nick:
# We cannot know if it's a pm or groupchat message because we only # It's a groupchat message
# get body of the message if nick:
type_ = 'gc_msg' # It's a message from a groupchat occupent
type_ = 'gc_msg'
with_ = with_ + '/' + nick
else:
# It's a server message message, we don't log them
return
else: else:
if direction == 'from': if direction == 'from':
type_ = 'chat_msg_recv' type_ = 'chat_msg_recv'

View File

@ -179,12 +179,12 @@ class ConnectionArchive:
self.dispatch('ARCHIVING_CHANGED', ('itemremove', self.dispatch('ARCHIVING_CHANGED', ('itemremove',
item.getAttr('jid'))) item.getAttr('jid')))
def request_collections_list_page(self, with='', start=None, end=None, def request_collections_list_page(self, with_='', start=None, end=None,
after=None, max=30, exact_match=False): after=None, max=30, exact_match=False):
iq_ = common.xmpp.Iq('get') iq_ = common.xmpp.Iq('get')
list_ = iq_.setTag('list', namespace=common.xmpp.NS_ARCHIVE) list_ = iq_.setTag('list', namespace=common.xmpp.NS_ARCHIVE)
if with: if with_:
list_.setAttr('with', with) list_.setAttr('with', with_)
if exact_match: if exact_match:
list_.setAttr('exactmatch', 'true') list_.setAttr('exactmatch', 'true')
if start: if start:
@ -200,11 +200,11 @@ class ConnectionArchive:
self.awaiting_answers[id_] = (ARCHIVING_COLLECTIONS_ARRIVED, ) self.awaiting_answers[id_] = (ARCHIVING_COLLECTIONS_ARRIVED, )
self.connection.send(iq_) self.connection.send(iq_)
def request_collection_page(self, with, start, end=None, after=None, def request_collection_page(self, with_, start, end=None, after=None,
max=30, exact_match=False): max=30, exact_match=False):
iq_ = common.xmpp.Iq('get') iq_ = common.xmpp.Iq('get')
retrieve = iq_.setTag('retrieve', namespace=common.xmpp.NS_ARCHIVE, retrieve = iq_.setTag('retrieve', namespace=common.xmpp.NS_ARCHIVE,
attrs={'with': with, 'start': start}) attrs={'with': with_, 'start': start})
if exact_match: if exact_match:
retrieve.setAttr('exactmatch', 'true') retrieve.setAttr('exactmatch', 'true')
set_ = retrieve.setTag('set', namespace=common.xmpp.NS_RSM) set_ = retrieve.setTag('set', namespace=common.xmpp.NS_RSM)
@ -216,12 +216,12 @@ class ConnectionArchive:
self.awaiting_answers[id_] = (ARCHIVING_COLLECTION_ARRIVED, ) self.awaiting_answers[id_] = (ARCHIVING_COLLECTION_ARRIVED, )
self.connection.send(iq_) self.connection.send(iq_)
def remove_collection(self, with='', start=None, end=None, def remove_collection(self, with_='', start=None, end=None,
exact_match=False, open=False): exact_match=False, open=False):
iq_ = common.xmpp.Iq('set') iq_ = common.xmpp.Iq('set')
remove = iq_.setTag('remove', namespace=common.xmpp.NS_ARCHIVE) remove = iq_.setTag('remove', namespace=common.xmpp.NS_ARCHIVE)
if with: if with_:
remove.setAttr('with', with) remove.setAttr('with', with_)
if exact_match: if exact_match:
remove.setAttr('exactmatch', 'true') remove.setAttr('exactmatch', 'true')
if start: if start:

View File

@ -3405,7 +3405,6 @@ class Interface:
self.last_ftwindow_update = 0 self.last_ftwindow_update = 0
self.music_track_changed_signal = None self.music_track_changed_signal = None
self.create_ipython_window()
class PassphraseRequest: class PassphraseRequest: