Merge branch 'master' into develop
This commit is contained in:
@@ -57,5 +57,8 @@ __all__ = [
|
||||
'xep_0224', # Attention
|
||||
'xep_0231', # Bits of Binary
|
||||
'xep_0249', # Direct MUC Invitations
|
||||
'xep_0256', # Last Activity in Presence
|
||||
'xep_0258', # Security Labels in XMPP
|
||||
'xep_0270', # XMPP Compliance Suites 2010
|
||||
'xep_0302', # XMPP Compliance Suites 2012
|
||||
]
|
||||
|
||||
67
sleekxmpp/plugins/xep_0256.py
Normal file
67
sleekxmpp/plugins/xep_0256.py
Normal file
@@ -0,0 +1,67 @@
|
||||
"""
|
||||
SleekXMPP: The Sleek XMPP Library
|
||||
Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout
|
||||
This file is part of SleekXMPP.
|
||||
|
||||
See the file LICENSE for copying permission.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from sleekxmpp import Presence
|
||||
from sleekxmpp.plugins import BasePlugin, register_plugin
|
||||
from sleekxmpp.xmlstream import register_stanza_plugin
|
||||
|
||||
from sleekxmpp.plugins.xep_0012 import stanza, LastActivity
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class XEP_0256(BasePlugin):
|
||||
|
||||
name = 'xep_0256'
|
||||
description = 'XEP-0256: Last Activity in Presence'
|
||||
dependencies = set(['xep_0012'])
|
||||
stanza = stanza
|
||||
|
||||
def plugin_init(self):
|
||||
self.auto_last_activity = self.config.get('auto_last_activity', False)
|
||||
|
||||
register_stanza_plugin(Presence, LastActivity)
|
||||
|
||||
self.xmpp.add_filter('out', self._initial_presence_activity)
|
||||
self.xmpp.add_event_handler('connected', self._reset_presence_activity)
|
||||
|
||||
self._initial_presence = set()
|
||||
|
||||
def _reset_presence_activity(self, e):
|
||||
self._initial_presence = set()
|
||||
|
||||
def _initial_presence_activity(self, stanza):
|
||||
if isinstance(stanza, Presence):
|
||||
use_last_activity = False
|
||||
|
||||
if self.auto_last_activity and stanza['show'] in ('xa', 'away'):
|
||||
use_last_activity = True
|
||||
|
||||
if stanza['from'] not in self._initial_presence:
|
||||
self._initial_presence.add(stanza['from'])
|
||||
use_last_activity = True
|
||||
|
||||
if use_last_activity:
|
||||
plugin = self.xmpp['xep_0012']
|
||||
try:
|
||||
result = plugin.api['get_last_activity'](stanza['from'],
|
||||
None,
|
||||
stanza['to'])
|
||||
seconds = result['last_activity']['seconds']
|
||||
except XMPPError:
|
||||
seconds = None
|
||||
|
||||
if seconds is not None:
|
||||
stanza['last_activity']['seconds'] = seconds
|
||||
return stanza
|
||||
|
||||
|
||||
register_plugin(XEP_0256)
|
||||
20
sleekxmpp/plugins/xep_0270.py
Normal file
20
sleekxmpp/plugins/xep_0270.py
Normal file
@@ -0,0 +1,20 @@
|
||||
"""
|
||||
SleekXMPP: The Sleek XMPP Library
|
||||
Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout
|
||||
This file is part of SleekXMPP.
|
||||
|
||||
See the file LICENSE for copying permission.
|
||||
"""
|
||||
|
||||
from sleekxmpp.plugins import BasePlugin, register_plugin
|
||||
|
||||
|
||||
class XEP_0270(BasePlugin):
|
||||
|
||||
name = 'xep_0270'
|
||||
description = 'XEP-0270: XMPP Compliance Suites 2010'
|
||||
dependencies = set(['xep_0030', 'xep_0115', 'xep_0054',
|
||||
'xep_0163', 'xep_0045', 'xep_0085'])
|
||||
|
||||
|
||||
register_plugin(XEP_0270)
|
||||
21
sleekxmpp/plugins/xep_0302.py
Normal file
21
sleekxmpp/plugins/xep_0302.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""
|
||||
SleekXMPP: The Sleek XMPP Library
|
||||
Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout
|
||||
This file is part of SleekXMPP.
|
||||
|
||||
See the file LICENSE for copying permission.
|
||||
"""
|
||||
|
||||
from sleekxmpp.plugins import BasePlugin, register_plugin
|
||||
|
||||
|
||||
class XEP_0302(BasePlugin):
|
||||
|
||||
name = 'xep_0302'
|
||||
description = 'XEP-0302: XMPP Compliance Suites 2012'
|
||||
dependencies = set(['xep_0030', 'xep_0115', 'xep_0054',
|
||||
'xep_0163', 'xep_0045', 'xep_0085',
|
||||
'xep_0184', 'xep_0198'])
|
||||
|
||||
|
||||
register_plugin(XEP_0302)
|
||||
Reference in New Issue
Block a user