Reformatted code base using black.
This commit is contained in:
parent
56319cbad3
commit
53fdaa9d09
1 changed files with 12604 additions and 8966 deletions
|
|
@ -32,8 +32,10 @@ PLUGIN_INFO = {
|
|||
C.PI_DEPENDENCIES: [],
|
||||
C.PI_MAIN: "XEP_0352",
|
||||
C.PI_HANDLER: "no",
|
||||
C.PI_DESCRIPTION: D_("Notify server when frontend is not actively used, to limit "
|
||||
"traffic and save bandwidth and battery life"),
|
||||
C.PI_DESCRIPTION: D_(
|
||||
"Notify server when frontend is not actively used, to limit "
|
||||
"traffic and save bandwidth and battery life"
|
||||
),
|
||||
}
|
||||
|
||||
NS_CSI = "urn:xmpp:csi:0"
|
||||
|
|
@ -54,30 +56,35 @@ class XEP_0352(object):
|
|||
except AttributeError:
|
||||
# _xep_0352_active can not be set if is_active is called before
|
||||
# profile_connected has been called
|
||||
log.debug("is_active called when XEP-0352 plugin has not yet set the "
|
||||
"attributes")
|
||||
log.debug(
|
||||
"is_active called when XEP-0352 plugin has not yet set the " "attributes"
|
||||
)
|
||||
return True
|
||||
|
||||
def profile_connected(self, client):
|
||||
if (NS_CSI, 'csi') in client.xmlstream.features:
|
||||
if (NS_CSI, "csi") in client.xmlstream.features:
|
||||
log.info(_("Client State Indication is available on this server"))
|
||||
client._xep_0352_enabled = True
|
||||
client._xep_0352_active = True
|
||||
else:
|
||||
log.warning(_("Client State Indication is not available on this server, some"
|
||||
" bandwidth optimisations can't be used."))
|
||||
log.warning(
|
||||
_(
|
||||
"Client State Indication is not available on this server, some"
|
||||
" bandwidth optimisations can't be used."
|
||||
)
|
||||
)
|
||||
client._xep_0352_enabled = False
|
||||
|
||||
def set_inactive(self, client):
|
||||
if self.is_active(client):
|
||||
inactive_elt = domish.Element((NS_CSI, 'inactive'))
|
||||
inactive_elt = domish.Element((NS_CSI, "inactive"))
|
||||
client.send(inactive_elt)
|
||||
client._xep_0352_active = False
|
||||
log.info("inactive state set")
|
||||
|
||||
def set_active(self, client):
|
||||
if not self.is_active(client):
|
||||
active_elt = domish.Element((NS_CSI, 'active'))
|
||||
active_elt = domish.Element((NS_CSI, "active"))
|
||||
client.send(active_elt)
|
||||
client._xep_0352_active = True
|
||||
log.info("active state set")
|
||||
|
|
|
|||
Loading…
Reference in a new issue