From b9ff018a03374a8993cbd3d2557e9ff345aa7cc2 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 14 Jan 2014 22:48:51 +0100 Subject: [PATCH] add a new event that is sent just before changing status. Fixes #7593 --- src/common/connection.py | 8 ++++++++ src/common/connection_handlers_events.py | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/common/connection.py b/src/common/connection.py index 8a9a6e9bb..948b821b9 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -708,12 +708,16 @@ class CommonConnection: if gajim.HAVE_GPG: self.USE_GPG = True self.gpg = gpg.GnuPG(gajim.config.get('use_gpg_agent')) + gajim.nec.push_incoming_event(BeforeChangeShowEvent(None, + conn=self, show=show, message=msg)) self.connect_and_init(show, msg, sign_msg) return if show == 'offline': self.connected = 0 if self.connection: + gajim.nec.push_incoming_event(BeforeChangeShowEvent(None, + conn=self, show=show, message=msg)) p = nbxmpp.Presence(typ = 'unavailable') p = self.add_sha(p, False) if msg: @@ -731,12 +735,16 @@ class CommonConnection: if self.connected == 1: return if show == 'invisible': + gajim.nec.push_incoming_event(BeforeChangeShowEvent(None, + conn=self, show=show, message=msg)) self._change_to_invisible(msg) return if show not in ['offline', 'online', 'chat', 'away', 'xa', 'dnd']: return -1 was_invisible = self.connected == gajim.SHOW_LIST.index('invisible') self.connected = gajim.SHOW_LIST.index(show) + gajim.nec.push_incoming_event(BeforeChangeShowEvent(None, + conn=self, show=show, message=msg)) if was_invisible: self._change_from_invisible() self._update_status(show, msg) diff --git a/src/common/connection_handlers_events.py b/src/common/connection_handlers_events.py index 567c48b80..e5996f188 100644 --- a/src/common/connection_handlers_events.py +++ b/src/common/connection_handlers_events.py @@ -997,6 +997,10 @@ class OurShowEvent(nec.NetworkIncomingEvent): name = 'our-show' base_network_events = [] +class BeforeChangeShowEvent(nec.NetworkIncomingEvent): + name = 'before-change-show' + base_network_events = [] + class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): name = 'message-received' base_network_events = ['raw-message-received']