# Slixmpp: The Slick XMPP Library# Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout# This file is part of Slixmpp.# See the file LICENSE for copying permission.importloggingfromslixmppimportClientXMPPfromslixmpp.stanzaimportStreamFeaturesfromslixmpp.xmlstreamimportregister_stanza_pluginfromslixmpp.plugins.baseimportBasePluginfromslixmpp.plugins.xep_0352importstanza,Active,Inactive,ClientStateIndicationlog=logging.getLogger(__name__)
[docs]classXEP_0352(BasePlugin):""" XEP-0352: Client State Indication """name='xep_0352'description='XEP-0352: Client State Indication'dependencies=set()stanza=stanzadefault_config={"order":12000,}defplugin_init(self):"""Start the XEP-0352 plugin."""self.enabled=Falseregister_stanza_plugin(StreamFeatures,ClientStateIndication)self.xmpp.register_stanza(stanza.Active)self.xmpp.register_stanza(stanza.Inactive)ifisinstance(self.xmpp,ClientXMPP):self.xmpp.register_feature('csi',self._handle_csi_feature,restart=False,order=self.order)defplugin_end(self):ifself.xmpp.is_component:returnifisinstance(self.xmpp,ClientXMPP):self.xmpp.unregister_feature('csi',self.order)self.xmpp.remove_stanza(stanza.Active)self.xmpp.remove_stanza(stanza.Inactive)
[docs]defsend_active(self):"""Send an 'active' state"""ifself.enabled:self.xmpp.send_raw(str(stanza.Active(self.xmpp)))
[docs]defsend_inactive(self):"""Send an 'active' state"""ifself.enabled:self.xmpp.send_raw(str(stanza.Inactive(self.xmpp)))