diff --git a/src/common/logger.py b/src/common/logger.py index 85932cb95..6a14bbc2b 100644 --- a/src/common/logger.py +++ b/src/common/logger.py @@ -228,6 +228,21 @@ class Logger: except sqlite.OperationalError, e: print >> sys.stderr, str(e) + def get_um_for_contact(self, jid): + ''' get unread messages for jid ''' + if not jid: + return + jid = jid.lower() + jid_id = self.get_jid_id(jid) + self.cur.execute(''' + SELECT message_id, message, time, subject FROM logs , unread_messages + WHERE jid_id = %d AND log_line_id = message_id ORDER BY time ASC + ''' % (jid_id) + ) + + results = self.cur.fetchall() + return results + def write(self, kind, jid, message = None, show = None, tim = None, subject = None): '''write a row (status, gcstatus, message etc) to logs database @@ -320,6 +335,7 @@ class Logger: ) results = self.cur.fetchall() + #FIXME: why do we reverse, instead of selecting by ASC order? results.reverse() return results diff --git a/src/roster_window.py b/src/roster_window.py index bd87a7728..cfaed6074 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -888,7 +888,11 @@ class RosterWindow: def add_account_contacts(self, account): for jid in gajim.contacts.get_jid_list(account): self.add_contact_to_roster(jid, account) - + results = gajim.logger.get_um_for_contact(jid) + for result in results: + tim = time.localtime(float(result[2])) + self.on_message(jid, result[1], tim, account, msg_type= 'chat', msg_id=result[0]) + def fill_contacts_and_groups_dicts(self, array, account): '''fill gajim.contacts and gajim.groups''' if account not in gajim.contacts.get_accounts():