hide pep-stuffs if a contact goes offline. fix #4206

This commit is contained in:
Julien Pivotto 2008-08-28 11:43:10 +00:00
parent 5f88d06487
commit 269e5a31c7
2 changed files with 53 additions and 0 deletions

View File

@ -490,4 +490,45 @@ def user_retract_tune(account):
def user_retract_nickname(account):
gajim.connections[account].send_pb_retract('', xmpp.NS_NICK, '0')
def delete_pep(jid, name):
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
activities_keys = ('activity', 'subactivity', 'text')
tune_keys = ('artist', 'title', 'source', 'track', 'length')
mood_keys = ('mood', 'text')
if jid == gajim.get_jid_from_account(name):
acc = gajim.connections[name]
for key in activities_keys:
if acc.activity.has_key(key):
del acc.activity[key]
for key in tune_keys:
if acc.tune.has_key(key):
del acc.tune[key]
for key in mood_keys:
if acc.mood.has_key(key):
del acc.mood[key]
for contact in gajim.contacts.get_contacts(name, user):
for key in activities_keys:
if contact.activity.has_key(key):
del contact.activity[key]
for key in tune_keys:
if contact.tune.has_key(key):
del contact.tune[key]
for key in mood_keys:
if contact.mood.has_key(key):
del contact.mood[key]
if jid == gajim.get_jid_from_account(name):
gajim.interface.roster.draw_account(name)
gajim.interface.roster.draw_activity(user, name)
gajim.interface.roster.draw_tune(user, name)
gajim.interface.roster.draw_mood(user, name)
ctrl = gajim.interface.msg_win_mgr.get_control(user, name)
if ctrl:
ctrl.update_activity()
ctrl.update_tune()
ctrl.update_mood()
# vim: se ts=3:

View File

@ -58,6 +58,7 @@ from common import helpers
from common import passwords
from common.exceptions import GajimGeneralException
from common import i18n
from common import pep
from message_window import MessageWindowMgr
@ -1088,6 +1089,14 @@ class RosterWindow:
if strike:
name = '<span strikethrough="true">%s</span>' % name
# Delete pep if needed
delete_pep = True
for c in contact_instances:
if c.show not in ('error', 'offline'):
delete_pep = False
if delete_pep:
pep.delete_pep(jid, account)
# Show resource counter
nb_connected_contact = 0
for c in contact_instances:
@ -1952,6 +1961,9 @@ class RosterWindow:
if to:
gajim.connections[account].send_custom_status(status, txt, to)
else:
if status in ('invisible', 'offline'):
pep.delete_pep(gajim.get_jid_from_account(account), \
account)
was_invisible = gajim.connections[account].connected == \
gajim.SHOW_LIST.index('invisible')
gajim.connections[account].change_status(status, txt, auto)