show unread messages on roster load
This commit is contained in:
parent
97dc7215df
commit
94b194966f
|
@ -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
|
||||
|
||||
|
|
|
@ -888,6 +888,10 @@ 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'''
|
||||
|
|
Loading…
Reference in New Issue