show unread messages on roster load
This commit is contained in:
parent
97dc7215df
commit
94b194966f
2 changed files with 21 additions and 1 deletions
|
@ -228,6 +228,21 @@ class Logger:
|
||||||
except sqlite.OperationalError, e:
|
except sqlite.OperationalError, e:
|
||||||
print >> sys.stderr, str(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,
|
def write(self, kind, jid, message = None, show = None, tim = None,
|
||||||
subject = None):
|
subject = None):
|
||||||
'''write a row (status, gcstatus, message etc) to logs database
|
'''write a row (status, gcstatus, message etc) to logs database
|
||||||
|
@ -320,6 +335,7 @@ class Logger:
|
||||||
)
|
)
|
||||||
|
|
||||||
results = self.cur.fetchall()
|
results = self.cur.fetchall()
|
||||||
|
#FIXME: why do we reverse, instead of selecting by ASC order?
|
||||||
results.reverse()
|
results.reverse()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
|
@ -888,7 +888,11 @@ class RosterWindow:
|
||||||
def add_account_contacts(self, account):
|
def add_account_contacts(self, account):
|
||||||
for jid in gajim.contacts.get_jid_list(account):
|
for jid in gajim.contacts.get_jid_list(account):
|
||||||
self.add_contact_to_roster(jid, 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):
|
def fill_contacts_and_groups_dicts(self, array, account):
|
||||||
'''fill gajim.contacts and gajim.groups'''
|
'''fill gajim.contacts and gajim.groups'''
|
||||||
if account not in gajim.contacts.get_accounts():
|
if account not in gajim.contacts.get_accounts():
|
||||||
|
|
Loading…
Add table
Reference in a new issue