Don't print twice "ping? pong" when using /ping command in a pm.

This commit is contained in:
Julien Pivotto 2008-08-07 15:27:02 +00:00
parent 949f83d1db
commit d7c60041ea
1 changed files with 18 additions and 4 deletions

View File

@ -1870,7 +1870,12 @@ class Interface:
gajim.connections[account].change_status('offline','') gajim.connections[account].change_status('offline','')
def handle_event_ping_sent(self, account, contact): def handle_event_ping_sent(self, account, contact):
for jid in [contact.jid, contact.get_full_jid()]: if contact.jid == contact.get_full_jid():
# If contact is a groupchat user
jids = [contact.jid]
else:
jids = [contact.jid, contact.get_full_jid()]
for jid in jids:
ctrl = self.msg_win_mgr.get_control(jid, account) ctrl = self.msg_win_mgr.get_control(jid, account)
if ctrl: if ctrl:
ctrl.print_conversation(_('Ping?'), 'status') ctrl.print_conversation(_('Ping?'), 'status')
@ -1878,14 +1883,23 @@ class Interface:
def handle_event_ping_reply(self, account, data): def handle_event_ping_reply(self, account, data):
contact = data[0] contact = data[0]
seconds = data[1] seconds = data[1]
if contact.jid == contact.get_full_jid():
for jid in [contact.jid, contact.get_full_jid()]: # If contact is a groupchat user
jids = [contact.jid]
else:
jids = [contact.jid, contact.get_full_jid()]
for jid in jids:
ctrl = self.msg_win_mgr.get_control(jid, account) ctrl = self.msg_win_mgr.get_control(jid, account)
if ctrl: if ctrl:
ctrl.print_conversation(_('Pong! (%s s.)') % seconds, 'status') ctrl.print_conversation(_('Pong! (%s s.)') % seconds, 'status')
def handle_event_ping_error(self, account, contact): def handle_event_ping_error(self, account, contact):
for jid in [contact.jid, contact.get_full_jid()]: if contact.jid == contact.get_full_jid():
# If contact is a groupchat user
jids = [contact.jid]
else:
jids = [contact.jid, contact.get_full_jid()]
for jid in jids:
ctrl = self.msg_win_mgr.get_control(jid, account) ctrl = self.msg_win_mgr.get_control(jid, account)
if ctrl: if ctrl:
ctrl.print_conversation(_('Error.'), 'status') ctrl.print_conversation(_('Error.'), 'status')