changeset ac09400aded7 in /home/hg/repos/gajim
author: Yann Leboulanger asterix@lagaule.org branches: gajim_0.16 details:http://hg.gajim.org/gajim?cmd=changeset;node=ac09400aded7 description: add /ping command in groupchat to ping occupants
diffstat:
src/chat_control.py | 14 +++++++++----- src/command_system/implementation/standard.py | 9 +++++++++ src/common/connection.py | 5 +++-- src/groupchat_control.py | 9 +++++++++ 4 files changed, 30 insertions(+), 7 deletions(-)
diffs (91 lines):
diff -r cd2b18340d4d -r ac09400aded7 src/chat_control.py --- a/src/chat_control.py Fri Aug 22 14:23:05 2014 +0200 +++ b/src/chat_control.py Fri Aug 22 15:44:07 2014 +0200 @@ -208,11 +208,6 @@ return self.print_conversation(_('Ping?'), 'status')
- def _nec_ping_reply(self, obj): - if self.contact != obj.contact: - return - self.print_conversation(_('Pong! (%s s.)') % obj.seconds, 'status') - def _nec_ping_error(self, obj): if self.contact != obj.contact: return @@ -2850,6 +2845,15 @@ return self.update_ui()
+ def _nec_ping_reply(self, obj): + if obj.control: + if obj.control != self: + return + else: + if self.contact != obj.contact: + return + self.print_conversation(_('Pong! (%s s.)') % obj.seconds, 'status') + def set_control_active(self, state): ChatControlBase.set_control_active(self, state) # send chatstate inactive to the one we're leaving diff -r cd2b18340d4d -r ac09400aded7 src/command_system/implementation/standard.py --- a/src/command_system/implementation/standard.py Fri Aug 22 14:23:05 2014 +0200 +++ b/src/command_system/implementation/standard.py Fri Aug 22 15:44:07 2014 +0200 @@ -410,3 +410,12 @@ @doc(_("Allow an occupant to send you public or private messages")) def unblock(self, who): self.on_unblock(None, who) + + @command + @doc(_("Send a ping to the contact")) + def ping(self, nick): + if self.account == gajim.ZEROCONF_ACC_NAME: + raise CommandError(_('Command is not supported for zeroconf accounts')) + gc_c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick) + gajim.connections[self.account].sendPing(gc_c, self) + diff -r cd2b18340d4d -r ac09400aded7 src/common/connection.py --- a/src/common/connection.py Fri Aug 22 14:23:05 2014 +0200 +++ b/src/common/connection.py Fri Aug 22 15:44:07 2014 +0200 @@ -1551,10 +1551,11 @@ assert id_ == self.awaiting_xmpp_ping_id self.awaiting_xmpp_ping_id = None
- def sendPing(self, pingTo=None): + def sendPing(self, pingTo=None, control=None): """ Send XMPP Ping (XEP-0199) request. If pingTo is not set, ping is sent to server to detect connection failure at application level + If control is set, display result there """ if not gajim.account_is_connected(self.name): return @@ -1577,7 +1578,7 @@ return timeDiff = round(timePong - timePing, 2) gajim.nec.push_incoming_event(PingReplyEvent(None, conn=self, - contact=pingTo, seconds=timeDiff)) + contact=pingTo, seconds=timeDiff, control=control)) if pingTo: timePing = time_time() self.connection.SendAndCallForResponse(iq, _on_response) diff -r cd2b18340d4d -r ac09400aded7 src/groupchat_control.py --- a/src/groupchat_control.py Fri Aug 22 14:23:05 2014 +0200 +++ b/src/groupchat_control.py Fri Aug 22 15:44:07 2014 +0200 @@ -1375,6 +1375,15 @@ obj.xhtml, self.session, msg_id=obj.msg_id, encrypted=obj.encrypted, displaymarking=obj.displaymarking)
+ def _nec_ping_reply(self, obj): + if obj.control: + if obj.control != self: + return + else: + if self.contact != obj.contact: + return + self.print_conversation(_('Pong! (%s s.)') % obj.seconds) + def got_connected(self): # Make autorejoin stop. if self.autorejoin: