diff options
Diffstat (limited to 'slixmpp')
178 files changed, 1264 insertions, 562 deletions
diff --git a/slixmpp/clientxmpp.py b/slixmpp/clientxmpp.py index a4bb9a60..891a9fb6 100644 --- a/slixmpp/clientxmpp.py +++ b/slixmpp/clientxmpp.py @@ -15,6 +15,7 @@ import asyncio import logging +from slixmpp.jid import JID from slixmpp.stanza import StreamFeatures from slixmpp.basexmpp import BaseXMPP from slixmpp.exceptions import XMPPError @@ -108,10 +109,21 @@ class ClientXMPP(BaseXMPP): CoroutineCallback('Stream Features', MatchXPath('{%s}features' % self.stream_ns), self._handle_stream_features)) + def roster_push_filter(iq): + from_ = iq['from'] + if from_ and from_ != JID('') and from_ != self.boundjid.bare: + reply = iq.reply() + reply['type'] = 'error' + reply['error']['type'] = 'cancel' + reply['error']['code'] = 503 + reply['error']['condition'] = 'service-unavailable' + reply.send() + return + self.event('roster_update', iq) self.register_handler( Callback('Roster Update', StanzaPath('iq@type=set/roster'), - lambda iq: self.event('roster_update', iq))) + roster_push_filter)) # Setup default stream features self.register_plugin('feature_starttls') @@ -243,7 +255,7 @@ class ClientXMPP(BaseXMPP): orig_cb(resp) callback = wrapped - iq.send(callback, timeout, timeout_callback) + return iq.send(callback, timeout, timeout_callback) def _reset_connection_state(self, event=None): #TODO: Use stream state here diff --git a/slixmpp/features/feature_bind/stanza.py b/slixmpp/features/feature_bind/stanza.py index b9ecd97c..96c3e757 100644 --- a/slixmpp/features/feature_bind/stanza.py +++ b/slixmpp/features/feature_bind/stanza.py @@ -16,6 +16,6 @@ class Bind(ElementBase): name = 'bind' namespace = 'urn:ietf:params:xml:ns:xmpp-bind' - interfaces = set(('resource', 'jid')) + interfaces = {'resource', 'jid'} sub_interfaces = interfaces plugin_attrib = 'bind' diff --git a/slixmpp/features/feature_mechanisms/mechanisms.py b/slixmpp/features/feature_mechanisms/mechanisms.py index 8e507afc..33bdaff5 100644 --- a/slixmpp/features/feature_mechanisms/mechanisms.py +++ b/slixmpp/features/feature_mechanisms/mechanisms.py @@ -49,7 +49,7 @@ class FeatureMechanisms(BasePlugin): if self.security_callback is None: self.security_callback = self._default_security - creds = self.sasl_callback(set(['username']), set()) + creds = self.sasl_callback({'username'}, set()) if not self.use_mech and not creds['username']: self.use_mech = 'ANONYMOUS' diff --git a/slixmpp/features/feature_mechanisms/stanza/auth.py b/slixmpp/features/feature_mechanisms/stanza/auth.py index c32069ec..48f0cf81 100644 --- a/slixmpp/features/feature_mechanisms/stanza/auth.py +++ b/slixmpp/features/feature_mechanisms/stanza/auth.py @@ -19,12 +19,12 @@ class Auth(StanzaBase): name = 'auth' namespace = 'urn:ietf:params:xml:ns:xmpp-sasl' - interfaces = set(('mechanism', 'value')) + interfaces = {'mechanism', 'value'} plugin_attrib = name #: Some SASL mechs require sending values as is, #: without converting base64. - plain_mechs = set(['X-MESSENGER-OAUTH2']) + plain_mechs = {'X-MESSENGER-OAUTH2'} def setup(self, xml): StanzaBase.setup(self, xml) diff --git a/slixmpp/features/feature_mechanisms/stanza/challenge.py b/slixmpp/features/feature_mechanisms/stanza/challenge.py index 21a061ee..7fa76e18 100644 --- a/slixmpp/features/feature_mechanisms/stanza/challenge.py +++ b/slixmpp/features/feature_mechanisms/stanza/challenge.py @@ -19,7 +19,7 @@ class Challenge(StanzaBase): name = 'challenge' namespace = 'urn:ietf:params:xml:ns:xmpp-sasl' - interfaces = set(('value',)) + interfaces = {'value'} plugin_attrib = name def setup(self, xml): diff --git a/slixmpp/features/feature_mechanisms/stanza/failure.py b/slixmpp/features/feature_mechanisms/stanza/failure.py index cc0ac877..adc686b7 100644 --- a/slixmpp/features/feature_mechanisms/stanza/failure.py +++ b/slixmpp/features/feature_mechanisms/stanza/failure.py @@ -16,13 +16,14 @@ class Failure(StanzaBase): name = 'failure' namespace = 'urn:ietf:params:xml:ns:xmpp-sasl' - interfaces = set(('condition', 'text')) + interfaces = {'condition', 'text'} plugin_attrib = name - sub_interfaces = set(('text',)) - conditions = set(('aborted', 'account-disabled', 'credentials-expired', - 'encryption-required', 'incorrect-encoding', 'invalid-authzid', - 'invalid-mechanism', 'malformed-request', 'mechansism-too-weak', - 'not-authorized', 'temporary-auth-failure')) + sub_interfaces = {'text'} + conditions = {'aborted', 'account-disabled', 'credentials-expired', + 'encryption-required', 'incorrect-encoding', + 'invalid-authzid', 'invalid-mechanism', 'malformed-request', + 'mechansism-too-weak', 'not-authorized', + 'temporary-auth-failure'} def setup(self, xml=None): """ diff --git a/slixmpp/features/feature_mechanisms/stanza/mechanisms.py b/slixmpp/features/feature_mechanisms/stanza/mechanisms.py index 064b8d1f..4ff15678 100644 --- a/slixmpp/features/feature_mechanisms/stanza/mechanisms.py +++ b/slixmpp/features/feature_mechanisms/stanza/mechanisms.py @@ -16,7 +16,7 @@ class Mechanisms(ElementBase): name = 'mechanisms' namespace = 'urn:ietf:params:xml:ns:xmpp-sasl' - interfaces = set(('mechanisms', 'required')) + interfaces = {'mechanisms', 'required'} plugin_attrib = name is_extension = True diff --git a/slixmpp/features/feature_mechanisms/stanza/response.py b/slixmpp/features/feature_mechanisms/stanza/response.py index 8da236ba..b25a0592 100644 --- a/slixmpp/features/feature_mechanisms/stanza/response.py +++ b/slixmpp/features/feature_mechanisms/stanza/response.py @@ -19,7 +19,7 @@ class Response(StanzaBase): name = 'response' namespace = 'urn:ietf:params:xml:ns:xmpp-sasl' - interfaces = set(('value',)) + interfaces = {'value'} plugin_attrib = name def setup(self, xml): diff --git a/slixmpp/features/feature_mechanisms/stanza/success.py b/slixmpp/features/feature_mechanisms/stanza/success.py index f7cde0f8..70be1780 100644 --- a/slixmpp/features/feature_mechanisms/stanza/success.py +++ b/slixmpp/features/feature_mechanisms/stanza/success.py @@ -18,7 +18,7 @@ class Success(StanzaBase): name = 'success' namespace = 'urn:ietf:params:xml:ns:xmpp-sasl' - interfaces = set(['value']) + interfaces = {'value'} plugin_attrib = name def setup(self, xml): diff --git a/slixmpp/features/feature_starttls/stanza.py b/slixmpp/features/feature_starttls/stanza.py index df50897e..ba58d93e 100644 --- a/slixmpp/features/feature_starttls/stanza.py +++ b/slixmpp/features/feature_starttls/stanza.py @@ -16,7 +16,7 @@ class STARTTLS(ElementBase): name = 'starttls' namespace = 'urn:ietf:params:xml:ns:xmpp-tls' - interfaces = set(('required',)) + interfaces = {'required'} plugin_attrib = name def get_required(self): diff --git a/slixmpp/plugins/gmail_notify.py b/slixmpp/plugins/gmail_notify.py index f4cf188c..a56ca699 100644 --- a/slixmpp/plugins/gmail_notify.py +++ b/slixmpp/plugins/gmail_notify.py @@ -21,7 +21,7 @@ class GmailQuery(ElementBase): namespace = 'google:mail:notify' name = 'query' plugin_attrib = 'gmail' - interfaces = set(('newer-than-time', 'newer-than-tid', 'q', 'search')) + interfaces = {'newer-than-time', 'newer-than-tid', 'q', 'search'} def get_search(self): return self['q'] @@ -37,8 +37,8 @@ class MailBox(ElementBase): namespace = 'google:mail:notify' name = 'mailbox' plugin_attrib = 'mailbox' - interfaces = set(('result-time', 'total-matched', 'total-estimate', - 'url', 'threads', 'matched', 'estimate')) + interfaces = {'result-time', 'total-matched', 'total-estimate', + 'url', 'threads', 'matched', 'estimate'} def get_threads(self): threads = [] @@ -58,9 +58,9 @@ class MailThread(ElementBase): namespace = 'google:mail:notify' name = 'mail-thread-info' plugin_attrib = 'thread' - interfaces = set(('tid', 'participation', 'messages', 'date', - 'senders', 'url', 'labels', 'subject', 'snippet')) - sub_interfaces = set(('labels', 'subject', 'snippet')) + interfaces = {'tid', 'participation', 'messages', 'date', + 'senders', 'url', 'labels', 'subject', 'snippet'} + sub_interfaces = {'labels', 'subject', 'snippet'} def get_senders(self): senders = [] @@ -75,7 +75,7 @@ class MailSender(ElementBase): namespace = 'google:mail:notify' name = 'sender' plugin_attrib = 'sender' - interfaces = set(('address', 'name', 'originator', 'unread')) + interfaces = {'address', 'name', 'originator', 'unread'} def get_originator(self): return self.xml.attrib.get('originator', '0') == '1' diff --git a/slixmpp/plugins/google/__init__.py b/slixmpp/plugins/google/__init__.py new file mode 100644 index 00000000..657f90b0 --- /dev/null +++ b/slixmpp/plugins/google/__init__.py @@ -0,0 +1,47 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2013 Nathanael C. Fritz, Lance J.T. Stout + This file is part of slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.plugins.base import register_plugin, BasePlugin + +from slixmpp.plugins.google.gmail import Gmail +from slixmpp.plugins.google.auth import GoogleAuth +from slixmpp.plugins.google.settings import GoogleSettings +from slixmpp.plugins.google.nosave import GoogleNoSave + + +class Google(BasePlugin): + + """ + Google: Custom GTalk Features + + Also see: <https://developers.google.com/talk/jep_extensions/extensions> + """ + + name = 'google' + description = 'Google: Custom GTalk Features' + dependencies = set([ + 'gmail', + 'google_settings', + 'google_nosave', + 'google_auth' + ]) + + def __getitem__(self, attr): + if attr in ('settings', 'nosave', 'auth'): + return self.xmpp['google_%s' % attr] + elif attr == 'gmail': + return self.xmpp['gmail'] + else: + raise KeyError(attr) + + +register_plugin(Gmail) +register_plugin(GoogleAuth) +register_plugin(GoogleSettings) +register_plugin(GoogleNoSave) +register_plugin(Google) diff --git a/slixmpp/plugins/google/auth/__init__.py b/slixmpp/plugins/google/auth/__init__.py new file mode 100644 index 00000000..624ffc48 --- /dev/null +++ b/slixmpp/plugins/google/auth/__init__.py @@ -0,0 +1,10 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2013 Nathanael C. Fritz, Lance J.T. Stout + This file is part of slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.plugins.google.auth import stanza +from slixmpp.plugins.google.auth.auth import GoogleAuth diff --git a/slixmpp/plugins/google/auth/auth.py b/slixmpp/plugins/google/auth/auth.py new file mode 100644 index 00000000..71a25ae4 --- /dev/null +++ b/slixmpp/plugins/google/auth/auth.py @@ -0,0 +1,47 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2013 Nathanael C. Fritz, Lance J.T. Stout + This file is part of slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.xmlstream import register_stanza_plugin +from slixmpp.plugins import BasePlugin +from slixmpp.plugins.google.auth import stanza + + +class GoogleAuth(BasePlugin): + + """ + Google: Auth Extensions (JID Domain Discovery, OAuth2) + + Also see: + <https://developers.google.com/talk/jep_extensions/jid_domain_change> + <https://developers.google.com/talk/jep_extensions/oauth> + """ + + name = 'google_auth' + description = 'Google: Auth Extensions (JID Domain Discovery, OAuth2)' + dependencies = set(['feature_mechanisms']) + stanza = stanza + + def plugin_init(self): + self.xmpp.namespace_map['http://www.google.com/talk/protocol/auth'] = 'ga' + + register_stanza_plugin(self.xmpp['feature_mechanisms'].stanza.Auth, + stanza.GoogleAuth) + + self.xmpp.add_filter('out', self._auth) + + def plugin_end(self): + self.xmpp.del_filter('out', self._auth) + + def _auth(self, stanza): + if isinstance(stanza, self.xmpp['feature_mechanisms'].stanza.Auth): + stanza.stream = self.xmpp + stanza['google']['client_uses_full_bind_result'] = True + if stanza['mechanism'] == 'X-OAUTH2': + stanza['google']['service'] = 'oauth2' + print(stanza) + return stanza diff --git a/slixmpp/plugins/google/auth/stanza.py b/slixmpp/plugins/google/auth/stanza.py index c5c693ee..5b1b7862 100644 --- a/slixmpp/plugins/google/auth/stanza.py +++ b/slixmpp/plugins/google/auth/stanza.py @@ -13,7 +13,7 @@ class GoogleAuth(ElementBase): name = 'auth' namespace = 'http://www.google.com/talk/protocol/auth' plugin_attrib = 'google' - interfaces = set(['client_uses_full_bind_result', 'service']) + interfaces = {'client_uses_full_bind_result', 'service'} discovery_attr= '{%s}client-uses-full-bind-result' % namespace service_attr= '{%s}service' % namespace diff --git a/slixmpp/plugins/google/gmail/__init__.py b/slixmpp/plugins/google/gmail/__init__.py new file mode 100644 index 00000000..ad575a3c --- /dev/null +++ b/slixmpp/plugins/google/gmail/__init__.py @@ -0,0 +1,10 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2013 Nathanael C. Fritz, Lance J.T. Stout + This file is part of slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.plugins.google.gmail import stanza +from slixmpp.plugins.google.gmail.notifications import Gmail diff --git a/slixmpp/plugins/google/gmail/stanza.py b/slixmpp/plugins/google/gmail/stanza.py new file mode 100644 index 00000000..e4086551 --- /dev/null +++ b/slixmpp/plugins/google/gmail/stanza.py @@ -0,0 +1,101 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2013 Nathanael C. Fritz, Lance J.T. Stout + This file is part of slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.xmlstream import ElementBase, register_stanza_plugin + + +class GmailQuery(ElementBase): + namespace = 'google:mail:notify' + name = 'query' + plugin_attrib = 'gmail' + interfaces = set(['newer_than_time', 'newer_than_tid', 'search']) + + def get_search(self): + return self._get_attr('q', '') + + def set_search(self, search): + self._set_attr('q', search) + + def del_search(self): + self._del_attr('q') + + def get_newer_than_time(self): + return self._get_attr('newer-than-time', '') + + def set_newer_than_time(self, value): + self._set_attr('newer-than-time', value) + + def del_newer_than_time(self): + self._del_attr('newer-than-time') + + def get_newer_than_tid(self): + return self._get_attr('newer-than-tid', '') + + def set_newer_than_tid(self, value): + self._set_attr('newer-than-tid', value) + + def del_newer_than_tid(self): + self._del_attr('newer-than-tid') + + +class MailBox(ElementBase): + namespace = 'google:mail:notify' + name = 'mailbox' + plugin_attrib = 'gmail_messages' + interfaces = set(['result_time', 'url', 'matched', 'estimate']) + + def get_matched(self): + return self._get_attr('total-matched', '') + + def get_estimate(self): + return self._get_attr('total-estimate', '') == '1' + + def get_result_time(self): + return self._get_attr('result-time', '') + + +class MailThread(ElementBase): + namespace = 'google:mail:notify' + name = 'mail-thread-info' + plugin_attrib = 'thread' + plugin_multi_attrib = 'threads' + interfaces = set(['tid', 'participation', 'messages', 'date', + 'senders', 'url', 'labels', 'subject', 'snippet']) + sub_interfaces = set(['labels', 'subject', 'snippet']) + + def get_senders(self): + result = [] + senders = self.xml.findall('{%s}senders/{%s}sender' % ( + self.namespace, self.namespace)) + + for sender in senders: + result.append(MailSender(xml=sender)) + + return result + + +class MailSender(ElementBase): + namespace = 'google:mail:notify' + name = 'sender' + plugin_attrib = name + interfaces = set(['address', 'name', 'originator', 'unread']) + + def get_originator(self): + return self.xml.attrib.get('originator', '0') == '1' + + def get_unread(self): + return self.xml.attrib.get('unread', '0') == '1' + + +class NewMail(ElementBase): + namespace = 'google:mail:notify' + name = 'new-mail' + plugin_attrib = 'gmail_notification' + + +register_stanza_plugin(MailBox, MailThread, iterable=True) diff --git a/slixmpp/plugins/google/nosave/__init__.py b/slixmpp/plugins/google/nosave/__init__.py new file mode 100644 index 00000000..467e980a --- /dev/null +++ b/slixmpp/plugins/google/nosave/__init__.py @@ -0,0 +1,10 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2013 Nathanael C. Fritz, Lance J.T. Stout + This file is part of slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.plugins.google.nosave import stanza +from slixmpp.plugins.google.nosave.nosave import GoogleNoSave diff --git a/slixmpp/plugins/google/nosave/nosave.py b/slixmpp/plugins/google/nosave/nosave.py new file mode 100644 index 00000000..7387f4df --- /dev/null +++ b/slixmpp/plugins/google/nosave/nosave.py @@ -0,0 +1,78 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2013 Nathanael C. Fritz, Lance J.T. Stout + This file is part of slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.stanza import Iq, Message +from slixmpp.xmlstream.handler import Callback +from slixmpp.xmlstream.matcher import StanzaPath +from slixmpp.xmlstream import register_stanza_plugin +from slixmpp.plugins import BasePlugin +from slixmpp.plugins.google.nosave import stanza + + +class GoogleNoSave(BasePlugin): + + """ + Google: Off the Record Chats + + NOTE: This is NOT an encryption method. + + Also see <https://developers.google.com/talk/jep_extensions/otr>. + """ + + name = 'google_nosave' + description = 'Google: Off the Record Chats' + dependencies = set(['google_settings']) + stanza = stanza + + def plugin_init(self): + register_stanza_plugin(Message, stanza.NoSave) + register_stanza_plugin(Iq, stanza.NoSaveQuery) + + self.xmpp.register_handler( + Callback('Google Nosave', + StanzaPath('iq@type=set/google_nosave'), + self._handle_nosave_change)) + + def plugin_end(self): + self.xmpp.remove_handler('Google Nosave') + + def enable(self, jid=None, timeout=None, callback=None): + if jid is None: + self.xmpp['google_settings'].update({'archiving_enabled': False}, + timeout=timeout, callback=callback) + else: + iq = self.xmpp.Iq() + iq['type'] = 'set' + iq['google_nosave']['item']['jid'] = jid + iq['google_nosave']['item']['value'] = True + return iq.send(timeout=timeout, callback=callback) + + def disable(self, jid=None, timeout=None, callback=None): + if jid is None: + self.xmpp['google_settings'].update({'archiving_enabled': True}, + timeout=timeout, callback=callback) + else: + iq = self.xmpp.Iq() + iq['type'] = 'set' + iq['google_nosave']['item']['jid'] = jid + iq['google_nosave']['item']['value'] = False + return iq.send(timeout=timeout, callback=callback) + + def get(self, timeout=None, callback=None): + iq = self.xmpp.Iq() + iq['type'] = 'get' + iq.enable('google_nosave') + return iq.send(timeout=timeout, callback=callback) + + def _handle_nosave_change(self, iq): + reply = self.xmpp.Iq() + reply['type'] = 'result' + reply['id'] = iq['id'] + reply['to'] = iq['from'] + reply.send() + self.xmpp.event('google_nosave_change', iq) diff --git a/slixmpp/plugins/google/nosave/stanza.py b/slixmpp/plugins/google/nosave/stanza.py index b060a486..2281c91e 100644 --- a/slixmpp/plugins/google/nosave/stanza.py +++ b/slixmpp/plugins/google/nosave/stanza.py @@ -14,7 +14,7 @@ class NoSave(ElementBase): name = 'x' namespace = 'google:nosave' plugin_attrib = 'google_nosave' - interfaces = set(['value']) + interfaces = {'value'} def get_value(self): return self._get_attr('value', '') == 'enabled' @@ -35,7 +35,7 @@ class Item(ElementBase): namespace = 'google:nosave' plugin_attrib = 'item' plugin_multi_attrib = 'items' - interfaces = set(['jid', 'source', 'value']) + interfaces = {'jid', 'source', 'value'} def get_value(self): return self._get_attr('value', '') == 'enabled' diff --git a/slixmpp/plugins/google/settings/__init__.py b/slixmpp/plugins/google/settings/__init__.py new file mode 100644 index 00000000..6cefdae9 --- /dev/null +++ b/slixmpp/plugins/google/settings/__init__.py @@ -0,0 +1,10 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2013 Nathanael C. Fritz, Lance J.T. Stout + This file is part of slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.plugins.google.settings import stanza +from slixmpp.plugins.google.settings.settings import GoogleSettings diff --git a/slixmpp/plugins/google/settings/stanza.py b/slixmpp/plugins/google/settings/stanza.py new file mode 100644 index 00000000..de66ade4 --- /dev/null +++ b/slixmpp/plugins/google/settings/stanza.py @@ -0,0 +1,110 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2013 Nathanael C. Fritz, Lance J.T. Stout + This file is part of slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.xmlstream import ET, ElementBase + + +class UserSettings(ElementBase): + name = 'usersetting' + namespace = 'google:setting' + plugin_attrib = 'google_settings' + interfaces = set(['auto_accept_suggestions', + 'mail_notifications', + 'archiving_enabled', + 'gmail', + 'email_verified', + 'domain_privacy_notice', + 'display_name']) + + def _get_setting(self, setting): + xml = self.xml.find('{%s}%s' % (self.namespace, setting)) + if xml is not None: + return xml.attrib.get('value', '') == 'true' + return False + + def _set_setting(self, setting, value): + self._del_setting(setting) + if value in (True, False): + xml = ET.Element('{%s}%s' % (self.namespace, setting)) + xml.attrib['value'] = 'true' if value else 'false' + self.xml.append(xml) + + def _del_setting(self, setting): + xml = self.xml.find('{%s}%s' % (self.namespace, setting)) + if xml is not None: + self.xml.remove(xml) + + def get_display_name(self): + xml = self.xml.find('{%s}%s' % (self.namespace, 'displayname')) + if xml is not None: + return xml.attrib.get('value', '') + return '' + + def set_display_name(self, value): + self._del_setting(setting) + if value: + xml = ET.Element('{%s}%s' % (self.namespace, 'displayname')) + xml.attrib['value'] = value + self.xml.append(xml) + + def del_display_name(self): + self._del_setting('displayname') + + def get_auto_accept_suggestions(self): + return self._get_setting('autoacceptsuggestions') + + def get_mail_notifications(self): + return self._get_setting('mailnotifications') + + def get_archiving_enabled(self): + return self._get_setting('archivingenabled') + + def get_gmail(self): + return self._get_setting('gmail') + + def get_email_verified(self): + return self._get_setting('emailverified') + + def get_domain_privacy_notice(self): + return self._get_setting('domainprivacynotice') + + def set_auto_accept_suggestions(self, value): + self._set_setting('autoacceptsuggestions', value) + + def set_mail_notifications(self, value): + self._set_setting('mailnotifications', value) + + def set_archiving_enabled(self, value): + self._set_setting('archivingenabled', value) + + def set_gmail(self, value): + self._set_setting('gmail', value) + + def set_email_verified(self, value): + self._set_setting('emailverified', value) + + def set_domain_privacy_notice(self, value): + self._set_setting('domainprivacynotice', value) + + def del_auto_accept_suggestions(self): + self._del_setting('autoacceptsuggestions') + + def del_mail_notifications(self): + self._del_setting('mailnotifications') + + def del_archiving_enabled(self): + self._del_setting('archivingenabled') + + def del_gmail(self): + self._del_setting('gmail') + + def del_email_verified(self): + self._del_setting('emailverified') + + def del_domain_privacy_notice(self): + self._del_setting('domainprivacynotice') diff --git a/slixmpp/plugins/xep_0004/dataforms.py b/slixmpp/plugins/xep_0004/dataforms.py index 90a87774..857bbd1c 100644 --- a/slixmpp/plugins/xep_0004/dataforms.py +++ b/slixmpp/plugins/xep_0004/dataforms.py @@ -23,7 +23,7 @@ class XEP_0004(BasePlugin): name = 'xep_0004' description = 'XEP-0004: Data Forms' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0004/stanza/field.py b/slixmpp/plugins/xep_0004/stanza/field.py index 42f1210b..c186157d 100644 --- a/slixmpp/plugins/xep_0004/stanza/field.py +++ b/slixmpp/plugins/xep_0004/stanza/field.py @@ -14,21 +14,21 @@ class FormField(ElementBase): name = 'field' plugin_attrib = 'field' plugin_multi_attrib = 'fields' - interfaces = set(('answer', 'desc', 'required', 'value', - 'label', 'type', 'var')) - sub_interfaces = set(('desc',)) + interfaces = {'answer', 'desc', 'required', 'value', + 'label', 'type', 'var'} + sub_interfaces = {'desc'} plugin_tag_map = {} plugin_attrib_map = {} - field_types = set(('boolean', 'fixed', 'hidden', 'jid-multi', - 'jid-single', 'list-multi', 'list-single', - 'text-multi', 'text-private', 'text-single')) + field_types = {'boolean', 'fixed', 'hidden', 'jid-multi', + 'jid-single', 'list-multi', 'list-single', + 'text-multi', 'text-private', 'text-single'} - true_values = set((True, '1', 'true')) - option_types = set(('list-multi', 'list-single')) - multi_line_types = set(('hidden', 'text-multi')) - multi_value_types = set(('hidden', 'jid-multi', - 'list-multi', 'text-multi')) + true_values = {True, '1', 'true'} + option_types = {'list-multi', 'list-single'} + multi_line_types = {'hidden', 'text-multi'} + multi_value_types = {'hidden', 'jid-multi', + 'list-multi', 'text-multi'} def setup(self, xml=None): if ElementBase.setup(self, xml): @@ -164,8 +164,8 @@ class FieldOption(ElementBase): namespace = 'jabber:x:data' name = 'option' plugin_attrib = 'option' - interfaces = set(('label', 'value')) - sub_interfaces = set(('value',)) + interfaces = {'label', 'value'} + sub_interfaces = {'value'} plugin_multi_attrib = 'options' diff --git a/slixmpp/plugins/xep_0004/stanza/form.py b/slixmpp/plugins/xep_0004/stanza/form.py index 32bfc0e3..0ae22098 100644 --- a/slixmpp/plugins/xep_0004/stanza/form.py +++ b/slixmpp/plugins/xep_0004/stanza/form.py @@ -24,8 +24,8 @@ class Form(ElementBase): name = 'x' plugin_attrib = 'form' interfaces = OrderedSet(('instructions', 'reported', 'title', 'type', 'items', )) - sub_interfaces = set(('title',)) - form_types = set(('cancel', 'form', 'result', 'submit')) + sub_interfaces = {'title'} + form_types = {'cancel', 'form', 'result', 'submit'} def __init__(self, *args, **kwargs): title = None diff --git a/slixmpp/plugins/xep_0009/rpc.py b/slixmpp/plugins/xep_0009/rpc.py index 3ce156cf..f92844ec 100644 --- a/slixmpp/plugins/xep_0009/rpc.py +++ b/slixmpp/plugins/xep_0009/rpc.py @@ -24,7 +24,7 @@ class XEP_0009(BasePlugin): name = 'xep_0009' description = 'XEP-0009: Jabber-RPC' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): @@ -121,7 +121,7 @@ class XEP_0009(BasePlugin): def _recipient_unvailable(self, iq): payload = iq.get_payload() iq = iq.reply() - error().set_payload(payload) + iq.error().set_payload(payload) iq['error']['code'] = '404' iq['error']['type'] = 'wait' iq['error']['condition'] = 'recipient-unavailable' diff --git a/slixmpp/plugins/xep_0009/stanza/RPC.py b/slixmpp/plugins/xep_0009/stanza/RPC.py index 3abab8fc..f8cec481 100644 --- a/slixmpp/plugins/xep_0009/stanza/RPC.py +++ b/slixmpp/plugins/xep_0009/stanza/RPC.py @@ -14,8 +14,8 @@ class RPCQuery(ElementBase): name = 'query' namespace = 'jabber:iq:rpc' plugin_attrib = 'rpc_query' - interfaces = set(()) - subinterfaces = set(()) + interfaces = {} + subinterfaces = {} plugin_attrib_map = {} plugin_tag_map = {} @@ -24,8 +24,8 @@ class MethodCall(ElementBase): name = 'methodCall' namespace = 'jabber:iq:rpc' plugin_attrib = 'method_call' - interfaces = set(('method_name', 'params')) - subinterfaces = set(()) + interfaces = {'method_name', 'params'} + subinterfaces = {} plugin_attrib_map = {} plugin_tag_map = {} @@ -46,8 +46,8 @@ class MethodResponse(ElementBase): name = 'methodResponse' namespace = 'jabber:iq:rpc' plugin_attrib = 'method_response' - interfaces = set(('params', 'fault')) - subinterfaces = set(()) + interfaces = {'params', 'fault'} + subinterfaces = {} plugin_attrib_map = {} plugin_tag_map = {} diff --git a/slixmpp/plugins/xep_0012/last_activity.py b/slixmpp/plugins/xep_0012/last_activity.py index 6367e393..807c0e05 100644 --- a/slixmpp/plugins/xep_0012/last_activity.py +++ b/slixmpp/plugins/xep_0012/last_activity.py @@ -29,7 +29,7 @@ class XEP_0012(BasePlugin): name = 'xep_0012' description = 'XEP-0012: Last Activity' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0012/stanza.py b/slixmpp/plugins/xep_0012/stanza.py index bd539a2d..16ca6fcf 100644 --- a/slixmpp/plugins/xep_0012/stanza.py +++ b/slixmpp/plugins/xep_0012/stanza.py @@ -14,7 +14,7 @@ class LastActivity(ElementBase): name = 'query' namespace = 'jabber:iq:last' plugin_attrib = 'last_activity' - interfaces = set(('seconds', 'status')) + interfaces = {'seconds', 'status'} def get_seconds(self): return int(self._get_attr('seconds')) diff --git a/slixmpp/plugins/xep_0013/offline.py b/slixmpp/plugins/xep_0013/offline.py index 51840e7b..7303b0d3 100644 --- a/slixmpp/plugins/xep_0013/offline.py +++ b/slixmpp/plugins/xep_0013/offline.py @@ -29,7 +29,7 @@ class XEP_0013(BasePlugin): name = 'xep_0013' description = 'XEP-0013: Flexible Offline Message Retrieval' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0013/stanza.py b/slixmpp/plugins/xep_0013/stanza.py index cf9c385b..780d1f74 100644 --- a/slixmpp/plugins/xep_0013/stanza.py +++ b/slixmpp/plugins/xep_0013/stanza.py @@ -14,7 +14,7 @@ class Offline(ElementBase): name = 'offline' namespace = 'http://jabber.org/protocol/offline' plugin_attrib = 'offline' - interfaces = set(['fetch', 'purge', 'results']) + interfaces = {'fetch', 'purge', 'results'} bool_interfaces = interfaces def setup(self, xml=None): @@ -39,9 +39,9 @@ class Item(ElementBase): name = 'item' namespace = 'http://jabber.org/protocol/offline' plugin_attrib = 'item' - interfaces = set(['action', 'node', 'jid']) + interfaces = {'action', 'node', 'jid'} - actions = set(['view', 'remove']) + actions = {'view', 'remove'} def get_jid(self): return JID(self._get_attr('jid')) diff --git a/slixmpp/plugins/xep_0016/privacy.py b/slixmpp/plugins/xep_0016/privacy.py index 38444b2b..2b8d623d 100644 --- a/slixmpp/plugins/xep_0016/privacy.py +++ b/slixmpp/plugins/xep_0016/privacy.py @@ -17,7 +17,7 @@ class XEP_0016(BasePlugin): name = 'xep_0016' description = 'XEP-0016: Privacy Lists' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0016/stanza.py b/slixmpp/plugins/xep_0016/stanza.py index 58c9fdb3..2fb3d03a 100644 --- a/slixmpp/plugins/xep_0016/stanza.py +++ b/slixmpp/plugins/xep_0016/stanza.py @@ -18,14 +18,14 @@ class Active(ElementBase): name = 'active' namespace = 'jabber:iq:privacy' plugin_attrib = name - interfaces = set(['name']) + interfaces = {'name'} class Default(ElementBase): name = 'default' namespace = 'jabber:iq:privacy' plugin_attrib = name - interfaces = set(['name']) + interfaces = {'name'} class List(ElementBase): @@ -33,7 +33,7 @@ class List(ElementBase): namespace = 'jabber:iq:privacy' plugin_attrib = name plugin_multi_attrib = 'lists' - interfaces = set(['name']) + interfaces = {'name'} def add_item(self, value, action, order, itype=None, iq=False, message=False, presence_in=False, presence_out=False): @@ -55,9 +55,9 @@ class Item(ElementBase): namespace = 'jabber:iq:privacy' plugin_attrib = name plugin_multi_attrib = 'items' - interfaces = set(['type', 'value', 'action', 'order', 'iq', - 'message', 'presence_in', 'presence_out']) - bool_interfaces = set(['message', 'iq', 'presence_in', 'presence_out']) + interfaces = {'type', 'value', 'action', 'order', 'iq', + 'message', 'presence_in', 'presence_out'} + bool_interfaces = {'message', 'iq', 'presence_in', 'presence_out'} type_values = ('', 'jid', 'group', 'subscription') action_values = ('allow', 'deny') diff --git a/slixmpp/plugins/xep_0020/feature_negotiation.py b/slixmpp/plugins/xep_0020/feature_negotiation.py index 2f4e8c15..b024bf0d 100644 --- a/slixmpp/plugins/xep_0020/feature_negotiation.py +++ b/slixmpp/plugins/xep_0020/feature_negotiation.py @@ -24,7 +24,7 @@ class XEP_0020(BasePlugin): name = 'xep_0020' description = 'XEP-0020: Feature Negotiation' - dependencies = set(['xep_0004', 'xep_0030']) + dependencies = {'xep_0004', 'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0027/stanza.py b/slixmpp/plugins/xep_0027/stanza.py index fd41cace..b1fb50be 100644 --- a/slixmpp/plugins/xep_0027/stanza.py +++ b/slixmpp/plugins/xep_0027/stanza.py @@ -13,7 +13,7 @@ class Signed(ElementBase): name = 'x' namespace = 'jabber:x:signed' plugin_attrib = 'signed' - interfaces = set(['signed']) + interfaces = {'signed'} is_extension = True def set_signed(self, value): @@ -33,7 +33,7 @@ class Encrypted(ElementBase): name = 'x' namespace = 'jabber:x:encrypted' plugin_attrib = 'encrypted' - interfaces = set(['encrypted']) + interfaces = {'encrypted'} is_extension = True def set_encrypted(self, value): diff --git a/slixmpp/plugins/xep_0030/stanza/info.py b/slixmpp/plugins/xep_0030/stanza/info.py index 614b68de..b23af0cc 100644 --- a/slixmpp/plugins/xep_0030/stanza/info.py +++ b/slixmpp/plugins/xep_0030/stanza/info.py @@ -71,8 +71,8 @@ class DiscoInfo(ElementBase): name = 'query' namespace = 'http://jabber.org/protocol/disco#info' plugin_attrib = 'disco_info' - interfaces = set(('node', 'features', 'identities')) - lang_interfaces = set(('identities',)) + interfaces = {'node', 'features', 'identities'} + lang_interfaces = {'identities'} # Cache identities and features _identities = set() @@ -91,7 +91,7 @@ class DiscoInfo(ElementBase): """ ElementBase.setup(self, xml) - self._identities = set([id[0:3] for id in self['identities']]) + self._identities = {id[0:3] for id in self['identities']} self._features = self['features'] def add_identity(self, category, itype, name=None, lang=None): diff --git a/slixmpp/plugins/xep_0030/stanza/items.py b/slixmpp/plugins/xep_0030/stanza/items.py index 314ab9b3..b0fd0bf1 100644 --- a/slixmpp/plugins/xep_0030/stanza/items.py +++ b/slixmpp/plugins/xep_0030/stanza/items.py @@ -45,7 +45,7 @@ class DiscoItems(ElementBase): name = 'query' namespace = 'http://jabber.org/protocol/disco#items' plugin_attrib = 'disco_items' - interfaces = set(('node', 'items')) + interfaces = {'node', 'items'} # Cache items _items = set() @@ -62,7 +62,7 @@ class DiscoItems(ElementBase): xml -- Use an existing XML object for the stanza's values. """ ElementBase.setup(self, xml) - self._items = set([item[0:2] for item in self['items']]) + self._items = {item[0:2] for item in self['items']} def add_item(self, jid, node=None, name=None): """ @@ -138,7 +138,7 @@ class DiscoItem(ElementBase): name = 'item' namespace = 'http://jabber.org/protocol/disco#items' plugin_attrib = name - interfaces = set(('jid', 'node', 'name')) + interfaces = {'jid', 'node', 'name'} def get_node(self): """Return the item's node name or ``None``.""" diff --git a/slixmpp/plugins/xep_0033/addresses.py b/slixmpp/plugins/xep_0033/addresses.py index 7b3c2d17..5fadd44d 100644 --- a/slixmpp/plugins/xep_0033/addresses.py +++ b/slixmpp/plugins/xep_0033/addresses.py @@ -22,7 +22,7 @@ class XEP_0033(BasePlugin): name = 'xep_0033' description = 'XEP-0033: Extended Stanza Addressing' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0033/stanza.py b/slixmpp/plugins/xep_0033/stanza.py index 50c7b6db..c3a58037 100644 --- a/slixmpp/plugins/xep_0033/stanza.py +++ b/slixmpp/plugins/xep_0033/stanza.py @@ -37,9 +37,9 @@ class Address(ElementBase): name = 'address' namespace = 'http://jabber.org/protocol/address' plugin_attrib = 'address' - interfaces = set(['type', 'jid', 'node', 'uri', 'desc', 'delivered']) + interfaces = {'type', 'jid', 'node', 'uri', 'desc', 'delivered'} - address_types = set(('bcc', 'cc', 'noreply', 'replyroom', 'replyto', 'to')) + address_types = {'bcc', 'cc', 'noreply', 'replyroom', 'replyto', 'to'} def get_jid(self): return JID(self._get_attr('jid')) diff --git a/slixmpp/plugins/xep_0045.py b/slixmpp/plugins/xep_0045.py index 942ba22a..3d910316 100644 --- a/slixmpp/plugins/xep_0045.py +++ b/slixmpp/plugins/xep_0045.py @@ -25,9 +25,9 @@ class MUCPresence(ElementBase): name = 'x' namespace = 'http://jabber.org/protocol/muc#user' plugin_attrib = 'muc' - interfaces = set(('affiliation', 'role', 'jid', 'nick', 'room')) - affiliations = set(('', )) - roles = set(('', )) + interfaces = {'affiliation', 'role', 'jid', 'nick', 'room'} + affiliations = {'', } + roles = {'', } def get_xml_item(self): item = self.xml.find('{http://jabber.org/protocol/muc#user}item') @@ -117,7 +117,7 @@ class XEP_0045(BasePlugin): name = 'xep_0045' description = 'XEP-0045: Multi-User Chat' - dependencies = set(['xep_0030', 'xep_0004']) + dependencies = {'xep_0030', 'xep_0004'} def plugin_init(self): self.rooms = {} diff --git a/slixmpp/plugins/xep_0047/ibb.py b/slixmpp/plugins/xep_0047/ibb.py index 52d7fbe5..bd96eca2 100644 --- a/slixmpp/plugins/xep_0047/ibb.py +++ b/slixmpp/plugins/xep_0047/ibb.py @@ -18,7 +18,7 @@ class XEP_0047(BasePlugin): name = 'xep_0047' description = 'XEP-0047: In-band Bytestreams' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza default_config = { 'block_size': 4096, diff --git a/slixmpp/plugins/xep_0047/stanza.py b/slixmpp/plugins/xep_0047/stanza.py index 7f8ff0ba..5c47508a 100644 --- a/slixmpp/plugins/xep_0047/stanza.py +++ b/slixmpp/plugins/xep_0047/stanza.py @@ -21,7 +21,7 @@ class Open(ElementBase): name = 'open' namespace = 'http://jabber.org/protocol/ibb' plugin_attrib = 'ibb_open' - interfaces = set(('block_size', 'sid', 'stanza')) + interfaces = {'block_size', 'sid', 'stanza'} def get_block_size(self): return int(self._get_attr('block-size', '0')) @@ -37,8 +37,8 @@ class Data(ElementBase): name = 'data' namespace = 'http://jabber.org/protocol/ibb' plugin_attrib = 'ibb_data' - interfaces = set(('seq', 'sid', 'data')) - sub_interfaces = set(['data']) + interfaces = {'seq', 'sid', 'data'} + sub_interfaces = {'data'} def get_seq(self): return int(self._get_attr('seq', '0')) @@ -67,4 +67,4 @@ class Close(ElementBase): name = 'close' namespace = 'http://jabber.org/protocol/ibb' plugin_attrib = 'ibb_close' - interfaces = set(['sid']) + interfaces = {'sid'} diff --git a/slixmpp/plugins/xep_0048/bookmarks.py b/slixmpp/plugins/xep_0048/bookmarks.py index 10c0909e..bde7ef98 100644 --- a/slixmpp/plugins/xep_0048/bookmarks.py +++ b/slixmpp/plugins/xep_0048/bookmarks.py @@ -24,7 +24,7 @@ class XEP_0048(BasePlugin): name = 'xep_0048' description = 'XEP-0048: Bookmarks' - dependencies = set(['xep_0045', 'xep_0049', 'xep_0060', 'xep_0163', 'xep_0223']) + dependencies = {'xep_0045', 'xep_0049', 'xep_0060', 'xep_0163', 'xep_0223'} stanza = stanza default_config = { 'auto_join': False, diff --git a/slixmpp/plugins/xep_0048/stanza.py b/slixmpp/plugins/xep_0048/stanza.py index c158535a..ddcc8841 100644 --- a/slixmpp/plugins/xep_0048/stanza.py +++ b/slixmpp/plugins/xep_0048/stanza.py @@ -40,8 +40,8 @@ class Conference(ElementBase): namespace = 'storage:bookmarks' plugin_attrib = 'conference' plugin_multi_attrib = 'conferences' - interfaces = set(['nick', 'password', 'autojoin', 'jid', 'name']) - sub_interfaces = set(['nick', 'password']) + interfaces = {'nick', 'password', 'autojoin', 'jid', 'name'} + sub_interfaces = {'nick', 'password'} def get_autojoin(self): value = self._get_attr('autojoin') @@ -58,7 +58,7 @@ class URL(ElementBase): namespace = 'storage:bookmarks' plugin_attrib = 'url' plugin_multi_attrib = 'urls' - interfaces = set(['url', 'name']) + interfaces = {'url', 'name'} register_stanza_plugin(Bookmarks, Conference, iterable=True) diff --git a/slixmpp/plugins/xep_0049/private_storage.py b/slixmpp/plugins/xep_0049/private_storage.py index a66c05d1..cb92db51 100644 --- a/slixmpp/plugins/xep_0049/private_storage.py +++ b/slixmpp/plugins/xep_0049/private_storage.py @@ -23,7 +23,7 @@ class XEP_0049(BasePlugin): name = 'xep_0049' description = 'XEP-0049: Private XML Storage' - dependencies = set([]) + dependencies = {} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0050/adhoc.py b/slixmpp/plugins/xep_0050/adhoc.py index fa6017d5..4cff6b46 100644 --- a/slixmpp/plugins/xep_0050/adhoc.py +++ b/slixmpp/plugins/xep_0050/adhoc.py @@ -74,7 +74,7 @@ class XEP_0050(BasePlugin): name = 'xep_0050' description = 'XEP-0050: Ad-Hoc Commands' - dependencies = set(['xep_0030', 'xep_0004']) + dependencies = {'xep_0030', 'xep_0004'} stanza = stanza default_config = { 'session_db': None @@ -225,8 +225,8 @@ class XEP_0050(BasePlugin): if len(payload) == 1: payload = payload[0] - interfaces = set([item.plugin_attrib for item in payload]) - payload_classes = set([item.__class__ for item in payload]) + interfaces = {item.plugin_attrib for item in payload} + payload_classes = {item.__class__ for item in payload} initial_session = {'id': sessionid, 'from': iq['from'], @@ -322,8 +322,8 @@ class XEP_0050(BasePlugin): interfaces = session.get('interfaces', set()) payload_classes = session.get('payload_classes', set()) - interfaces.update(set([item.plugin_attrib for item in payload])) - payload_classes.update(set([item.__class__ for item in payload])) + interfaces.update({item.plugin_attrib for item in payload}) + payload_classes.update({item.__class__ for item in payload}) session['interfaces'] = interfaces session['payload_classes'] = payload_classes diff --git a/slixmpp/plugins/xep_0050/stanza.py b/slixmpp/plugins/xep_0050/stanza.py index 107135f4..ef3eac9f 100644 --- a/slixmpp/plugins/xep_0050/stanza.py +++ b/slixmpp/plugins/xep_0050/stanza.py @@ -72,11 +72,11 @@ class Command(ElementBase): name = 'command' namespace = 'http://jabber.org/protocol/commands' plugin_attrib = 'command' - interfaces = set(('action', 'sessionid', 'node', - 'status', 'actions', 'notes')) - actions = set(('cancel', 'complete', 'execute', 'next', 'prev')) - statuses = set(('canceled', 'completed', 'executing')) - next_actions = set(('prev', 'next', 'complete')) + interfaces = {'action', 'sessionid', 'node', + 'status', 'actions', 'notes'} + actions = {'cancel', 'complete', 'execute', 'next', 'prev'} + statuses = {'canceled', 'completed', 'executing'} + next_actions = {'prev', 'next', 'complete'} def get_action(self): """ diff --git a/slixmpp/plugins/xep_0054/stanza.py b/slixmpp/plugins/xep_0054/stanza.py index e7647184..9bdcb448 100644 --- a/slixmpp/plugins/xep_0054/stanza.py +++ b/slixmpp/plugins/xep_0054/stanza.py @@ -10,15 +10,15 @@ class VCardTemp(ElementBase): name = 'vCard' namespace = 'vcard-temp' plugin_attrib = 'vcard_temp' - interfaces = set(['FN', 'VERSION']) - sub_interfaces = set(['FN', 'VERSION']) + interfaces = {'FN', 'VERSION'} + sub_interfaces = {'FN', 'VERSION'} class Name(ElementBase): name = 'N' namespace = 'vcard-temp' plugin_attrib = name - interfaces = set(['FAMILY', 'GIVEN', 'MIDDLE', 'PREFIX', 'SUFFIX']) + interfaces = {'FAMILY', 'GIVEN', 'MIDDLE', 'PREFIX', 'SUFFIX'} sub_interfaces = interfaces def _set_component(self, name, value): @@ -72,7 +72,7 @@ class Nickname(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'nicknames' - interfaces = set([name]) + interfaces = {name} is_extension = True def set_nickname(self, value): @@ -95,9 +95,9 @@ class Email(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'emails' - interfaces = set(['HOME', 'WORK', 'INTERNET', 'PREF', 'X400', 'USERID']) - sub_interfaces = set(['USERID']) - bool_interfaces = set(['HOME', 'WORK', 'INTERNET', 'PREF', 'X400']) + interfaces = {'HOME', 'WORK', 'INTERNET', 'PREF', 'X400', 'USERID'} + sub_interfaces = {'USERID'} + bool_interfaces = {'HOME', 'WORK', 'INTERNET', 'PREF', 'X400'} class Address(ElementBase): @@ -105,12 +105,12 @@ class Address(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'addresses' - interfaces = set(['HOME', 'WORK', 'POSTAL', 'PARCEL', 'DOM', 'INTL', - 'PREF', 'POBOX', 'EXTADD', 'STREET', 'LOCALITY', - 'REGION', 'PCODE', 'CTRY']) - sub_interfaces = set(['POBOX', 'EXTADD', 'STREET', 'LOCALITY', - 'REGION', 'PCODE', 'CTRY']) - bool_interfaces = set(['HOME', 'WORK', 'DOM', 'INTL', 'PREF']) + interfaces = {'HOME', 'WORK', 'POSTAL', 'PARCEL', 'DOM', 'INTL', + 'PREF', 'POBOX', 'EXTADD', 'STREET', 'LOCALITY', + 'REGION', 'PCODE', 'CTRY'} + sub_interfaces = {'POBOX', 'EXTADD', 'STREET', 'LOCALITY', + 'REGION', 'PCODE', 'CTRY'} + bool_interfaces = {'HOME', 'WORK', 'DOM', 'INTL', 'PREF'} class Telephone(ElementBase): @@ -118,13 +118,13 @@ class Telephone(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'telephone_numbers' - interfaces = set(['HOME', 'WORK', 'VOICE', 'FAX', 'PAGER', 'MSG', - 'CELL', 'VIDEO', 'BBS', 'MODEM', 'ISDN', 'PCS', - 'PREF', 'NUMBER']) - sub_interfaces = set(['NUMBER']) - bool_interfaces = set(['HOME', 'WORK', 'VOICE', 'FAX', 'PAGER', - 'MSG', 'CELL', 'VIDEO', 'BBS', 'MODEM', - 'ISDN', 'PCS', 'PREF']) + interfaces = {'HOME', 'WORK', 'VOICE', 'FAX', 'PAGER', 'MSG', + 'CELL', 'VIDEO', 'BBS', 'MODEM', 'ISDN', 'PCS', + 'PREF', 'NUMBER'} + sub_interfaces = {'NUMBER'} + bool_interfaces = {'HOME', 'WORK', 'VOICE', 'FAX', 'PAGER', + 'MSG', 'CELL', 'VIDEO', 'BBS', 'MODEM', + 'ISDN', 'PCS', 'PREF'} def setup(self, xml=None): super().setup(xml=xml) @@ -143,10 +143,10 @@ class Label(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'labels' - interfaces = set(['HOME', 'WORK', 'POSTAL', 'PARCEL', 'DOM', 'INT', - 'PREF', 'lines']) - bool_interfaces = set(['HOME', 'WORK', 'POSTAL', 'PARCEL', 'DOM', - 'INT', 'PREF']) + interfaces = {'HOME', 'WORK', 'POSTAL', 'PARCEL', 'DOM', 'INT', + 'PREF', 'lines'} + bool_interfaces = {'HOME', 'WORK', 'POSTAL', 'PARCEL', 'DOM', + 'INT', 'PREF'} def add_line(self, value): line = ET.Element('{%s}LINE' % self.namespace) @@ -177,7 +177,7 @@ class Geo(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'geolocations' - interfaces = set(['LAT', 'LON']) + interfaces = {'LAT', 'LON'} sub_interfaces = interfaces @@ -186,8 +186,8 @@ class Org(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'organizations' - interfaces = set(['ORGNAME', 'ORGUNIT', 'orgunits']) - sub_interfaces = set(['ORGNAME', 'ORGUNIT']) + interfaces = {'ORGNAME', 'ORGUNIT', 'orgunits'} + sub_interfaces = {'ORGNAME', 'ORGUNIT'} def add_orgunit(self, value): orgunit = ET.Element('{%s}ORGUNIT' % self.namespace) @@ -218,7 +218,7 @@ class Photo(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'photos' - interfaces = set(['TYPE', 'EXTVAL']) + interfaces = {'TYPE', 'EXTVAL'} sub_interfaces = interfaces @@ -227,7 +227,7 @@ class Logo(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'logos' - interfaces = set(['TYPE', 'EXTVAL']) + interfaces = {'TYPE', 'EXTVAL'} sub_interfaces = interfaces @@ -236,7 +236,7 @@ class Sound(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'sounds' - interfaces = set(['PHONETC', 'EXTVAL']) + interfaces = {'PHONETC', 'EXTVAL'} sub_interfaces = interfaces @@ -244,7 +244,7 @@ class BinVal(ElementBase): name = 'BINVAL' namespace = 'vcard-temp' plugin_attrib = name - interfaces = set(['BINVAL']) + interfaces = {'BINVAL'} is_extension = True def setup(self, xml=None): @@ -275,7 +275,7 @@ class Classification(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'classifications' - interfaces = set(['PUBLIC', 'PRIVATE', 'CONFIDENTIAL']) + interfaces = {'PUBLIC', 'PRIVATE', 'CONFIDENTIAL'} bool_interfaces = interfaces @@ -284,7 +284,7 @@ class Categories(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'categories' - interfaces = set([name]) + interfaces = {name} is_extension = True def set_categories(self, values): @@ -314,7 +314,7 @@ class Birthday(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'birthdays' - interfaces = set([name]) + interfaces = {name} is_extension = True def set_bday(self, value): @@ -336,7 +336,7 @@ class Rev(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'revision_dates' - interfaces = set([name]) + interfaces = {name} is_extension = True def set_rev(self, value): @@ -358,7 +358,7 @@ class Title(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'titles' - interfaces = set([name]) + interfaces = {name} is_extension = True def set_title(self, value): @@ -373,7 +373,7 @@ class Role(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'roles' - interfaces = set([name]) + interfaces = {name} is_extension = True def set_role(self, value): @@ -388,7 +388,7 @@ class Note(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'notes' - interfaces = set([name]) + interfaces = {name} is_extension = True def set_note(self, value): @@ -403,7 +403,7 @@ class Desc(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'descriptions' - interfaces = set([name]) + interfaces = {name} is_extension = True def set_desc(self, value): @@ -418,7 +418,7 @@ class URL(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'urls' - interfaces = set([name]) + interfaces = {name} is_extension = True def set_url(self, value): @@ -433,7 +433,7 @@ class UID(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'uids' - interfaces = set([name]) + interfaces = {name} is_extension = True def set_uid(self, value): @@ -448,7 +448,7 @@ class ProdID(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'product_ids' - interfaces = set([name]) + interfaces = {name} is_extension = True def set_prodid(self, value): @@ -463,7 +463,7 @@ class Mailer(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'mailers' - interfaces = set([name]) + interfaces = {name} is_extension = True def set_mailer(self, value): @@ -478,7 +478,7 @@ class SortString(ElementBase): namespace = 'vcard-temp' plugin_attrib = 'SORT_STRING' plugin_multi_attrib = 'sort_strings' - interfaces = set([name]) + interfaces = {name} is_extension = True def set_sort_string(self, value): @@ -493,7 +493,7 @@ class Agent(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'agents' - interfaces = set(['EXTVAL']) + interfaces = {'EXTVAL'} sub_interfaces = interfaces @@ -502,7 +502,7 @@ class JabberID(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'jids' - interfaces = set([name]) + interfaces = {name} is_extension = True def set_jabberid(self, value): @@ -517,7 +517,7 @@ class TimeZone(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'timezones' - interfaces = set([name]) + interfaces = {name} is_extension = True def set_tz(self, value): diff --git a/slixmpp/plugins/xep_0054/vcard_temp.py b/slixmpp/plugins/xep_0054/vcard_temp.py index f0173386..098b0e34 100644 --- a/slixmpp/plugins/xep_0054/vcard_temp.py +++ b/slixmpp/plugins/xep_0054/vcard_temp.py @@ -29,7 +29,7 @@ class XEP_0054(BasePlugin): name = 'xep_0054' description = 'XEP-0054: vcard-temp' - dependencies = set(['xep_0030', 'xep_0082']) + dependencies = {'xep_0030', 'xep_0082'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0059/rsm.py b/slixmpp/plugins/xep_0059/rsm.py index 5876a9aa..a02d94e0 100644 --- a/slixmpp/plugins/xep_0059/rsm.py +++ b/slixmpp/plugins/xep_0059/rsm.py @@ -111,7 +111,7 @@ class XEP_0059(BasePlugin): name = 'xep_0059' description = 'XEP-0059: Result Set Management' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0059/stanza.py b/slixmpp/plugins/xep_0059/stanza.py index 3843bc85..38ac08b8 100644 --- a/slixmpp/plugins/xep_0059/stanza.py +++ b/slixmpp/plugins/xep_0059/stanza.py @@ -64,10 +64,10 @@ class Set(ElementBase): namespace = 'http://jabber.org/protocol/rsm' name = 'set' plugin_attrib = 'rsm' - sub_interfaces = set(('first', 'after', 'before', 'count', - 'index', 'last', 'max')) - interfaces = set(('first_index', 'first', 'after', 'before', - 'count', 'index', 'last', 'max')) + sub_interfaces = {'first', 'after', 'before', 'count', + 'index', 'last', 'max'} + interfaces = {'first_index', 'first', 'after', 'before', + 'count', 'index', 'last', 'max'} def set_first_index(self, val): fi = self.xml.find("{%s}first" % (self.namespace)) diff --git a/slixmpp/plugins/xep_0060/pubsub.py b/slixmpp/plugins/xep_0060/pubsub.py index 8e12ae92..8d6a2877 100644 --- a/slixmpp/plugins/xep_0060/pubsub.py +++ b/slixmpp/plugins/xep_0060/pubsub.py @@ -26,7 +26,7 @@ class XEP_0060(BasePlugin): name = 'xep_0060' description = 'XEP-0060: Publish-Subscribe' - dependencies = set(['xep_0030', 'xep_0004', 'xep_0082', 'xep_0131']) + dependencies = {'xep_0030', 'xep_0004', 'xep_0082', 'xep_0131'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0060/stanza/base.py b/slixmpp/plugins/xep_0060/stanza/base.py index b8f3d6cc..2f781e98 100644 --- a/slixmpp/plugins/xep_0060/stanza/base.py +++ b/slixmpp/plugins/xep_0060/stanza/base.py @@ -11,7 +11,7 @@ from slixmpp.xmlstream import ET class OptionalSetting(object): - interfaces = set(('required',)) + interfaces = {'required'} def set_required(self, value): if value in (True, 'true', 'True', '1'): diff --git a/slixmpp/plugins/xep_0060/stanza/pubsub.py b/slixmpp/plugins/xep_0060/stanza/pubsub.py index 3f6f2719..210bce08 100644 --- a/slixmpp/plugins/xep_0060/stanza/pubsub.py +++ b/slixmpp/plugins/xep_0060/stanza/pubsub.py @@ -23,14 +23,14 @@ class Affiliations(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'affiliations' plugin_attrib = name - interfaces = set(('node',)) + interfaces = {'node'} class Affiliation(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'affiliation' plugin_attrib = name - interfaces = set(('node', 'affiliation', 'jid')) + interfaces = {'node', 'affiliation', 'jid'} def set_jid(self, value): self._set_attr('jid', str(value)) @@ -43,7 +43,7 @@ class Subscription(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'subscription' plugin_attrib = name - interfaces = set(('jid', 'node', 'subscription', 'subid')) + interfaces = {'jid', 'node', 'subscription', 'subid'} def set_jid(self, value): self._set_attr('jid', str(value)) @@ -56,21 +56,21 @@ class Subscriptions(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'subscriptions' plugin_attrib = name - interfaces = set(('node',)) + interfaces = {'node'} class SubscribeOptions(ElementBase, OptionalSetting): namespace = 'http://jabber.org/protocol/pubsub' name = 'subscribe-options' plugin_attrib = 'suboptions' - interfaces = set(('required',)) + interfaces = {'required'} class Item(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'item' plugin_attrib = name - interfaces = set(('id', 'payload')) + interfaces = {'id', 'payload'} def set_payload(self, value): del self['payload'] @@ -95,7 +95,7 @@ class Items(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'items' plugin_attrib = name - interfaces = set(('node', 'max_items')) + interfaces = {'node', 'max_items'} def set_max_items(self, value): self._set_attr('max_items', str(value)) @@ -105,14 +105,14 @@ class Create(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'create' plugin_attrib = name - interfaces = set(('node',)) + interfaces = {'node'} class Default(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'default' plugin_attrib = name - interfaces = set(('node', 'type')) + interfaces = {'node', 'type'} def get_type(self): t = self._get_attr('type') @@ -125,14 +125,14 @@ class Publish(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'publish' plugin_attrib = name - interfaces = set(('node',)) + interfaces = {'node'} class Retract(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'retract' plugin_attrib = name - interfaces = set(('node', 'notify')) + interfaces = {'node', 'notify'} def get_notify(self): notify = self._get_attr('notify') @@ -156,7 +156,7 @@ class Unsubscribe(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'unsubscribe' plugin_attrib = name - interfaces = set(('node', 'jid', 'subid')) + interfaces = {'node', 'jid', 'subid'} def set_jid(self, value): self._set_attr('jid', str(value)) @@ -169,7 +169,7 @@ class Subscribe(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'subscribe' plugin_attrib = name - interfaces = set(('node', 'jid')) + interfaces = {'node', 'jid'} def set_jid(self, value): self._set_attr('jid', str(value)) @@ -182,7 +182,7 @@ class Configure(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'configure' plugin_attrib = name - interfaces = set(('node', 'type')) + interfaces = {'node', 'type'} def getType(self): t = self._get_attr('type') @@ -195,7 +195,7 @@ class Options(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'options' plugin_attrib = name - interfaces = set(('jid', 'node', 'options')) + interfaces = {'jid', 'node', 'options'} def __init__(self, *args, **kwargs): ElementBase.__init__(self, *args, **kwargs) @@ -227,7 +227,7 @@ class PublishOptions(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'publish-options' plugin_attrib = 'publish_options' - interfaces = set(('publish_options',)) + interfaces = {'publish_options'} is_extension = True def get_publish_options(self): diff --git a/slixmpp/plugins/xep_0060/stanza/pubsub_errors.py b/slixmpp/plugins/xep_0060/stanza/pubsub_errors.py index 3e728009..d0444081 100644 --- a/slixmpp/plugins/xep_0060/stanza/pubsub_errors.py +++ b/slixmpp/plugins/xep_0060/stanza/pubsub_errors.py @@ -13,18 +13,18 @@ from slixmpp.xmlstream import ElementBase, ET, register_stanza_plugin class PubsubErrorCondition(ElementBase): plugin_attrib = 'pubsub' - interfaces = set(('condition', 'unsupported')) + interfaces = {'condition', 'unsupported'} plugin_attrib_map = {} plugin_tag_map = {} - conditions = set(('closed-node', 'configuration-required', 'invalid-jid', - 'invalid-options', 'invalid-payload', 'invalid-subid', - 'item-forbidden', 'item-required', 'jid-required', - 'max-items-exceeded', 'max-nodes-exceeded', - 'nodeid-required', 'not-in-roster-group', - 'not-subscribed', 'payload-too-big', - 'payload-required', 'pending-subscription', - 'presence-subscription-required', 'subid-required', - 'too-many-subscriptions', 'unsupported')) + conditions = {'closed-node', 'configuration-required', 'invalid-jid', + 'invalid-options', 'invalid-payload', 'invalid-subid', + 'item-forbidden', 'item-required', 'jid-required', + 'max-items-exceeded', 'max-nodes-exceeded', + 'nodeid-required', 'not-in-roster-group', + 'not-subscribed', 'payload-too-big', + 'payload-required', 'pending-subscription', + 'presence-subscription-required', 'subid-required', + 'too-many-subscriptions', 'unsupported'} condition_ns = 'http://jabber.org/protocol/pubsub#errors' def setup(self, xml): diff --git a/slixmpp/plugins/xep_0060/stanza/pubsub_event.py b/slixmpp/plugins/xep_0060/stanza/pubsub_event.py index 1ba97c75..e46ad408 100644 --- a/slixmpp/plugins/xep_0060/stanza/pubsub_event.py +++ b/slixmpp/plugins/xep_0060/stanza/pubsub_event.py @@ -25,7 +25,7 @@ class EventItem(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#event' name = 'item' plugin_attrib = name - interfaces = set(('id', 'payload', 'node', 'publisher')) + interfaces = {'id', 'payload', 'node', 'publisher'} def set_payload(self, value): self.xml.append(value) @@ -44,56 +44,56 @@ class EventRetract(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#event' name = 'retract' plugin_attrib = name - interfaces = set(('id',)) + interfaces = {'id'} class EventItems(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#event' name = 'items' plugin_attrib = name - interfaces = set(('node',)) + interfaces = {'node'} class EventCollection(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#event' name = 'collection' plugin_attrib = name - interfaces = set(('node',)) + interfaces = {'node'} class EventAssociate(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#event' name = 'associate' plugin_attrib = name - interfaces = set(('node',)) + interfaces = {'node'} class EventDisassociate(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#event' name = 'disassociate' plugin_attrib = name - interfaces = set(('node',)) + interfaces = {'node'} class EventConfiguration(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#event' name = 'configuration' plugin_attrib = name - interfaces = set(('node',)) + interfaces = {'node'} class EventPurge(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#event' name = 'purge' plugin_attrib = name - interfaces = set(('node',)) + interfaces = {'node'} class EventDelete(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#event' name = 'delete' plugin_attrib = name - interfaces = set(('node', 'redirect')) + interfaces = {'node', 'redirect'} def set_redirect(self, uri): del self['redirect'] @@ -117,7 +117,7 @@ class EventSubscription(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#event' name = 'subscription' plugin_attrib = name - interfaces = set(('node', 'expiry', 'jid', 'subid', 'subscription')) + interfaces = {'node', 'expiry', 'jid', 'subid', 'subscription'} def get_expiry(self): expiry = self._get_attr('expiry') diff --git a/slixmpp/plugins/xep_0060/stanza/pubsub_owner.py b/slixmpp/plugins/xep_0060/stanza/pubsub_owner.py index 402e5e30..850df8cf 100644 --- a/slixmpp/plugins/xep_0060/stanza/pubsub_owner.py +++ b/slixmpp/plugins/xep_0060/stanza/pubsub_owner.py @@ -25,7 +25,7 @@ class DefaultConfig(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#owner' name = 'default' plugin_attrib = name - interfaces = set(('node', 'config')) + interfaces = {'node', 'config'} def __init__(self, *args, **kwargs): ElementBase.__init__(self, *args, **kwargs) @@ -41,7 +41,7 @@ class DefaultConfig(ElementBase): class OwnerAffiliations(Affiliations): namespace = 'http://jabber.org/protocol/pubsub#owner' - interfaces = set(('node',)) + interfaces = {'node'} def append(self, affiliation): if not isinstance(affiliation, OwnerAffiliation): @@ -51,40 +51,40 @@ class OwnerAffiliations(Affiliations): class OwnerAffiliation(Affiliation): namespace = 'http://jabber.org/protocol/pubsub#owner' - interfaces = set(('affiliation', 'jid')) + interfaces = {'affiliation', 'jid'} class OwnerConfigure(Configure): namespace = 'http://jabber.org/protocol/pubsub#owner' name = 'configure' plugin_attrib = name - interfaces = set(('node',)) + interfaces = {'node'} class OwnerDefault(OwnerConfigure): namespace = 'http://jabber.org/protocol/pubsub#owner' - interfaces = set(('node',)) + interfaces = {'node'} class OwnerDelete(ElementBase, OptionalSetting): namespace = 'http://jabber.org/protocol/pubsub#owner' name = 'delete' plugin_attrib = name - interfaces = set(('node',)) + interfaces = {'node'} class OwnerPurge(ElementBase, OptionalSetting): namespace = 'http://jabber.org/protocol/pubsub#owner' name = 'purge' plugin_attrib = name - interfaces = set(('node',)) + interfaces = {'node'} class OwnerRedirect(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#owner' name = 'redirect' plugin_attrib = name - interfaces = set(('node', 'jid')) + interfaces = {'node', 'jid'} def set_jid(self, value): self._set_attr('jid', str(value)) @@ -97,7 +97,7 @@ class OwnerSubscriptions(Subscriptions): name = 'subscriptions' namespace = 'http://jabber.org/protocol/pubsub#owner' plugin_attrib = name - interfaces = set(('node',)) + interfaces = {'node'} def append(self, subscription): if not isinstance(subscription, OwnerSubscription): @@ -109,7 +109,7 @@ class OwnerSubscription(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#owner' name = 'subscription' plugin_attrib = name - interfaces = set(('jid', 'subscription')) + interfaces = {'jid', 'subscription'} def set_jid(self, value): self._set_attr('jid', str(value)) diff --git a/slixmpp/plugins/xep_0065/proxy.py b/slixmpp/plugins/xep_0065/proxy.py index c5d358dd..3fe6d2d1 100644 --- a/slixmpp/plugins/xep_0065/proxy.py +++ b/slixmpp/plugins/xep_0065/proxy.py @@ -22,7 +22,7 @@ class XEP_0065(BasePlugin): name = 'xep_0065' description = "XEP-0065: SOCKS5 Bytestreams" - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} default_config = { 'auto_accept': False } @@ -55,6 +55,7 @@ class XEP_0065(BasePlugin): """Returns the socket associated to the SID.""" return self._sessions.get(sid, None) + @asyncio.coroutine def handshake(self, to, ifrom=None, sid=None, timeout=None): """ Starts the handshake to establish the socks5 bytestreams connection. @@ -104,6 +105,7 @@ class XEP_0065(BasePlugin): iq['socks'].add_streamhost(proxy, host, port) return iq.send(timeout=timeout, callback=callback) + @asyncio.coroutine def discover_proxies(self, jid=None, ifrom=None, timeout=None): """Auto-discover the JIDs of SOCKS5 proxies on an XMPP server.""" if jid is None: diff --git a/slixmpp/plugins/xep_0065/stanza.py b/slixmpp/plugins/xep_0065/stanza.py index 5ba15b32..9701c237 100644 --- a/slixmpp/plugins/xep_0065/stanza.py +++ b/slixmpp/plugins/xep_0065/stanza.py @@ -6,8 +6,8 @@ class Socks5(ElementBase): name = 'query' namespace = 'http://jabber.org/protocol/bytestreams' plugin_attrib = 'socks' - interfaces = set(['sid', 'activate']) - sub_interfaces = set(['activate']) + interfaces = {'sid', 'activate'} + sub_interfaces = {'activate'} def add_streamhost(self, jid, host, port): sh = StreamHost(parent=self) @@ -21,7 +21,7 @@ class StreamHost(ElementBase): namespace = 'http://jabber.org/protocol/bytestreams' plugin_attrib = 'streamhost' plugin_multi_attrib = 'streamhosts' - interfaces = set(['host', 'jid', 'port']) + interfaces = {'host', 'jid', 'port'} def set_jid(self, value): return self._set_attr('jid', str(value)) @@ -34,7 +34,7 @@ class StreamHostUsed(ElementBase): name = 'streamhost-used' namespace = 'http://jabber.org/protocol/bytestreams' plugin_attrib = 'streamhost_used' - interfaces = set(['jid']) + interfaces = {'jid'} def set_jid(self, value): return self._set_attr('jid', str(value)) diff --git a/slixmpp/plugins/xep_0066/oob.py b/slixmpp/plugins/xep_0066/oob.py index c9d4ae5b..233263a2 100644 --- a/slixmpp/plugins/xep_0066/oob.py +++ b/slixmpp/plugins/xep_0066/oob.py @@ -44,7 +44,7 @@ class XEP_0066(BasePlugin): name = 'xep_0066' description = 'XEP-0066: Out of Band Data' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0066/stanza.py b/slixmpp/plugins/xep_0066/stanza.py index e1da5bdd..55707b99 100644 --- a/slixmpp/plugins/xep_0066/stanza.py +++ b/slixmpp/plugins/xep_0066/stanza.py @@ -17,8 +17,8 @@ class OOBTransfer(ElementBase): name = 'query' namespace = 'jabber:iq:oob' plugin_attrib = 'oob_transfer' - interfaces = set(('url', 'desc', 'sid')) - sub_interfaces = set(('url', 'desc')) + interfaces = {'url', 'desc', 'sid'} + sub_interfaces = {'url', 'desc'} class OOB(ElementBase): @@ -29,5 +29,5 @@ class OOB(ElementBase): name = 'x' namespace = 'jabber:x:oob' plugin_attrib = 'oob' - interfaces = set(('url', 'desc')) + interfaces = {'url', 'desc'} sub_interfaces = interfaces diff --git a/slixmpp/plugins/xep_0071/stanza.py b/slixmpp/plugins/xep_0071/stanza.py index 3df686cf..4c3380c4 100644 --- a/slixmpp/plugins/xep_0071/stanza.py +++ b/slixmpp/plugins/xep_0071/stanza.py @@ -19,8 +19,8 @@ class XHTML_IM(ElementBase): namespace = 'http://jabber.org/protocol/xhtml-im' name = 'html' - interfaces = set(['body']) - lang_interfaces = set(['body']) + interfaces = {'body'} + lang_interfaces = {'body'} plugin_attrib = name def set_body(self, content, lang=None): diff --git a/slixmpp/plugins/xep_0071/xhtml_im.py b/slixmpp/plugins/xep_0071/xhtml_im.py index 0b412126..ff4cf591 100644 --- a/slixmpp/plugins/xep_0071/xhtml_im.py +++ b/slixmpp/plugins/xep_0071/xhtml_im.py @@ -17,7 +17,7 @@ class XEP_0071(BasePlugin): name = 'xep_0071' description = 'XEP-0071: XHTML-IM' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0077/register.py b/slixmpp/plugins/xep_0077/register.py index eb2e7443..8c0c6f09 100644 --- a/slixmpp/plugins/xep_0077/register.py +++ b/slixmpp/plugins/xep_0077/register.py @@ -26,7 +26,7 @@ class XEP_0077(BasePlugin): name = 'xep_0077' description = 'XEP-0077: In-Band Registration' - dependencies = set(['xep_0004', 'xep_0066']) + dependencies = {'xep_0004', 'xep_0066'} stanza = stanza default_config = { 'create_account': True, diff --git a/slixmpp/plugins/xep_0077/stanza.py b/slixmpp/plugins/xep_0077/stanza.py index 6ac543c2..d020a005 100644 --- a/slixmpp/plugins/xep_0077/stanza.py +++ b/slixmpp/plugins/xep_0077/stanza.py @@ -16,14 +16,14 @@ class Register(ElementBase): namespace = 'jabber:iq:register' name = 'query' plugin_attrib = 'register' - interfaces = set(('username', 'password', 'email', 'nick', 'name', - 'first', 'last', 'address', 'city', 'state', 'zip', - 'phone', 'url', 'date', 'misc', 'text', 'key', - 'registered', 'remove', 'instructions', 'fields')) + interfaces = {'username', 'password', 'email', 'nick', 'name', + 'first', 'last', 'address', 'city', 'state', 'zip', + 'phone', 'url', 'date', 'misc', 'text', 'key', + 'registered', 'remove', 'instructions', 'fields'} sub_interfaces = interfaces - form_fields = set(('username', 'password', 'email', 'nick', 'name', - 'first', 'last', 'address', 'city', 'state', 'zip', - 'phone', 'url', 'date', 'misc', 'text', 'key')) + form_fields = {'username', 'password', 'email', 'nick', 'name', + 'first', 'last', 'address', 'city', 'state', 'zip', + 'phone', 'url', 'date', 'misc', 'text', 'key'} def get_registered(self): present = self.xml.find('{%s}registered' % self.namespace) diff --git a/slixmpp/plugins/xep_0078/stanza.py b/slixmpp/plugins/xep_0078/stanza.py index 7dc9401d..2a9ba510 100644 --- a/slixmpp/plugins/xep_0078/stanza.py +++ b/slixmpp/plugins/xep_0078/stanza.py @@ -13,8 +13,8 @@ class IqAuth(ElementBase): namespace = 'jabber:iq:auth' name = 'query' plugin_attrib = 'auth' - interfaces = set(('fields', 'username', 'password', 'resource', 'digest')) - sub_interfaces = set(('username', 'password', 'resource', 'digest')) + interfaces = {'fields', 'username', 'password', 'resource', 'digest'} + sub_interfaces = {'username', 'password', 'resource', 'digest'} plugin_tag_map = {} plugin_attrib_map = {} diff --git a/slixmpp/plugins/xep_0079/amp.py b/slixmpp/plugins/xep_0079/amp.py index 6e65d02a..a8fbc258 100644 --- a/slixmpp/plugins/xep_0079/amp.py +++ b/slixmpp/plugins/xep_0079/amp.py @@ -27,7 +27,7 @@ class XEP_0079(BasePlugin): name = 'xep_0079' description = 'XEP-0079: Advanced Message Processing' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0079/stanza.py b/slixmpp/plugins/xep_0079/stanza.py index e3e1553a..f959f21b 100644 --- a/slixmpp/plugins/xep_0079/stanza.py +++ b/slixmpp/plugins/xep_0079/stanza.py @@ -8,6 +8,7 @@ from __future__ import unicode_literals +from slixmpp import JID from slixmpp.xmlstream import ElementBase, register_stanza_plugin @@ -15,7 +16,7 @@ class AMP(ElementBase): namespace = 'http://jabber.org/protocol/amp' name = 'amp' plugin_attrib = 'amp' - interfaces = set(['from', 'to', 'status', 'per_hop']) + interfaces = {'from', 'to', 'status', 'per_hop'} def get_from(self): return JID(self._get_attr('from')) @@ -53,7 +54,7 @@ class Rule(ElementBase): name = 'rule' plugin_attrib = name plugin_multi_attrib = 'rules' - interfaces = set(['action', 'condition', 'value']) + interfaces = {'action', 'condition', 'value'} class InvalidRules(ElementBase): diff --git a/slixmpp/plugins/xep_0080/geoloc.py b/slixmpp/plugins/xep_0080/geoloc.py index c9d97edb..459d8a91 100644 --- a/slixmpp/plugins/xep_0080/geoloc.py +++ b/slixmpp/plugins/xep_0080/geoloc.py @@ -25,7 +25,7 @@ class XEP_0080(BasePlugin): name = 'xep_0080' description = 'XEP-0080: User Location' - dependencies = set(['xep_0163']) + dependencies = {'xep_0163'} stanza = stanza def plugin_end(self): diff --git a/slixmpp/plugins/xep_0080/stanza.py b/slixmpp/plugins/xep_0080/stanza.py index e25fea4f..adad6321 100644 --- a/slixmpp/plugins/xep_0080/stanza.py +++ b/slixmpp/plugins/xep_0080/stanza.py @@ -65,11 +65,11 @@ class Geoloc(ElementBase): namespace = 'http://jabber.org/protocol/geoloc' name = 'geoloc' - interfaces = set(('accuracy', 'alt', 'area', 'bearing', 'building', - 'country', 'countrycode', 'datum', 'dscription', - 'error', 'floor', 'lat', 'locality', 'lon', - 'postalcode', 'region', 'room', 'speed', 'street', - 'text', 'timestamp', 'uri')) + interfaces = {'accuracy', 'alt', 'area', 'bearing', 'building', + 'country', 'countrycode', 'datum', 'dscription', + 'error', 'floor', 'lat', 'locality', 'lon', + 'postalcode', 'region', 'room', 'speed', 'street', + 'text', 'timestamp', 'uri'} sub_interfaces = interfaces plugin_attrib = name diff --git a/slixmpp/plugins/xep_0084/avatar.py b/slixmpp/plugins/xep_0084/avatar.py index e5f9dfaa..6ab4d24b 100644 --- a/slixmpp/plugins/xep_0084/avatar.py +++ b/slixmpp/plugins/xep_0084/avatar.py @@ -24,7 +24,7 @@ class XEP_0084(BasePlugin): name = 'xep_0084' description = 'XEP-0084: User Avatar' - dependencies = set(['xep_0163', 'xep_0060']) + dependencies = {'xep_0163', 'xep_0060'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0084/stanza.py b/slixmpp/plugins/xep_0084/stanza.py index ebcd73e3..4b6370ce 100644 --- a/slixmpp/plugins/xep_0084/stanza.py +++ b/slixmpp/plugins/xep_0084/stanza.py @@ -16,7 +16,7 @@ class Data(ElementBase): name = 'data' namespace = 'urn:xmpp:avatar:data' plugin_attrib = 'avatar_data' - interfaces = set(['value']) + interfaces = {'value'} def get_value(self): if self.xml.text: @@ -63,7 +63,7 @@ class Info(ElementBase): namespace = 'urn:xmpp:avatar:metadata' plugin_attrib = 'info' plugin_multi_attrib = 'items' - interfaces = set(['bytes', 'height', 'id', 'type', 'url', 'width']) + interfaces = {'bytes', 'height', 'id', 'type', 'url', 'width'} class Pointer(ElementBase): diff --git a/slixmpp/plugins/xep_0085/chat_states.py b/slixmpp/plugins/xep_0085/chat_states.py index 1aab9eaa..ade6eda9 100644 --- a/slixmpp/plugins/xep_0085/chat_states.py +++ b/slixmpp/plugins/xep_0085/chat_states.py @@ -28,7 +28,7 @@ class XEP_0085(BasePlugin): name = 'xep_0085' description = 'XEP-0085: Chat State Notifications' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0085/stanza.py b/slixmpp/plugins/xep_0085/stanza.py index de1bc645..d0987308 100644 --- a/slixmpp/plugins/xep_0085/stanza.py +++ b/slixmpp/plugins/xep_0085/stanza.py @@ -37,11 +37,11 @@ class ChatState(ElementBase): name = '' namespace = 'http://jabber.org/protocol/chatstates' plugin_attrib = 'chat_state' - interfaces = set(('chat_state',)) + interfaces = {'chat_state'} sub_interfaces = interfaces is_extension = True - states = set(('active', 'composing', 'gone', 'inactive', 'paused')) + states = {'active', 'composing', 'gone', 'inactive', 'paused'} def setup(self, xml=None): self.xml = ET.Element('') diff --git a/slixmpp/plugins/xep_0086/stanza.py b/slixmpp/plugins/xep_0086/stanza.py index cbc9429d..a28abafa 100644 --- a/slixmpp/plugins/xep_0086/stanza.py +++ b/slixmpp/plugins/xep_0086/stanza.py @@ -44,7 +44,7 @@ class LegacyError(ElementBase): name = 'legacy' namespace = Error.namespace plugin_attrib = name - interfaces = set(('condition',)) + interfaces = {'condition'} overrides = ['set_condition'] error_map = {'bad-request': ('modify', '400'), diff --git a/slixmpp/plugins/xep_0091/stanza.py b/slixmpp/plugins/xep_0091/stanza.py index ac6457e6..0ce2acda 100644 --- a/slixmpp/plugins/xep_0091/stanza.py +++ b/slixmpp/plugins/xep_0091/stanza.py @@ -18,7 +18,7 @@ class LegacyDelay(ElementBase): name = 'x' namespace = 'jabber:x:delay' plugin_attrib = 'legacy_delay' - interfaces = set(('from', 'stamp', 'text')) + interfaces = {'from', 'stamp', 'text'} def get_from(self): from_ = self._get_attr('from') diff --git a/slixmpp/plugins/xep_0092/stanza.py b/slixmpp/plugins/xep_0092/stanza.py index 04097a8b..e76a041e 100644 --- a/slixmpp/plugins/xep_0092/stanza.py +++ b/slixmpp/plugins/xep_0092/stanza.py @@ -38,5 +38,5 @@ class Version(ElementBase): name = 'query' namespace = 'jabber:iq:version' plugin_attrib = 'software_version' - interfaces = set(('name', 'version', 'os')) + interfaces = {'name', 'version', 'os'} sub_interfaces = interfaces diff --git a/slixmpp/plugins/xep_0092/version.py b/slixmpp/plugins/xep_0092/version.py index ff0317da..839f740d 100644 --- a/slixmpp/plugins/xep_0092/version.py +++ b/slixmpp/plugins/xep_0092/version.py @@ -28,7 +28,7 @@ class XEP_0092(BasePlugin): name = 'xep_0092' description = 'XEP-0092: Software Version' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza default_config = { 'software_name': 'Slixmpp', diff --git a/slixmpp/plugins/xep_0095/stanza.py b/slixmpp/plugins/xep_0095/stanza.py index 62b5f6f8..0a99ddf6 100644 --- a/slixmpp/plugins/xep_0095/stanza.py +++ b/slixmpp/plugins/xep_0095/stanza.py @@ -13,7 +13,7 @@ class SI(ElementBase): name = 'si' namespace = 'http://jabber.org/protocol/si' plugin_attrib = 'si' - interfaces = set(['id', 'mime_type', 'profile']) + interfaces = {'id', 'mime_type', 'profile'} def get_mime_type(self): return self._get_attr('mime-type', 'application/octet-stream') diff --git a/slixmpp/plugins/xep_0095/stream_initiation.py b/slixmpp/plugins/xep_0095/stream_initiation.py index 3f909d93..d135ecba 100644 --- a/slixmpp/plugins/xep_0095/stream_initiation.py +++ b/slixmpp/plugins/xep_0095/stream_initiation.py @@ -31,7 +31,7 @@ class XEP_0095(BasePlugin): name = 'xep_0095' description = 'XEP-0095: Stream Initiation' - dependencies = set(['xep_0020', 'xep_0030', 'xep_0047', 'xep_0065']) + dependencies = {'xep_0020', 'xep_0030', 'xep_0047', 'xep_0065'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0096/file_transfer.py b/slixmpp/plugins/xep_0096/file_transfer.py index 3c09a5b5..f136772d 100644 --- a/slixmpp/plugins/xep_0096/file_transfer.py +++ b/slixmpp/plugins/xep_0096/file_transfer.py @@ -23,7 +23,7 @@ class XEP_0096(BasePlugin): name = 'xep_0096' description = 'XEP-0096: SI File Transfer' - dependencies = set(['xep_0095']) + dependencies = {'xep_0095'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0096/stanza.py b/slixmpp/plugins/xep_0096/stanza.py index d3781c8d..2a1a9060 100644 --- a/slixmpp/plugins/xep_0096/stanza.py +++ b/slixmpp/plugins/xep_0096/stanza.py @@ -16,8 +16,8 @@ class File(ElementBase): name = 'file' namespace = 'http://jabber.org/protocol/si/profile/file-transfer' plugin_attrib = 'file' - interfaces = set(['name', 'size', 'date', 'hash', 'desc']) - sub_interfaces = set(['desc']) + interfaces = {'name', 'size', 'date', 'hash', 'desc'} + sub_interfaces = {'desc'} def set_size(self, value): self._set_attr('size', str(value)) @@ -36,7 +36,7 @@ class Range(ElementBase): name = 'range' namespace = 'http://jabber.org/protocol/si/profile/file-transfer' plugin_attrib = 'range' - interfaces = set(['length', 'offset']) + interfaces = {'length', 'offset'} def set_length(self, value): self._set_attr('length', str(value)) diff --git a/slixmpp/plugins/xep_0106.py b/slixmpp/plugins/xep_0106.py index a4717956..bcf4c555 100644 --- a/slixmpp/plugins/xep_0106.py +++ b/slixmpp/plugins/xep_0106.py @@ -14,7 +14,7 @@ class XEP_0106(BasePlugin): name = 'xep_0106' description = 'XEP-0106: JID Escaping' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} def session_bind(self, jid): self.xmpp['xep_0030'].add_feature(feature='jid\\20escaping') diff --git a/slixmpp/plugins/xep_0107/stanza.py b/slixmpp/plugins/xep_0107/stanza.py index 05967de9..8384793a 100644 --- a/slixmpp/plugins/xep_0107/stanza.py +++ b/slixmpp/plugins/xep_0107/stanza.py @@ -14,25 +14,25 @@ class UserMood(ElementBase): name = 'mood' namespace = 'http://jabber.org/protocol/mood' plugin_attrib = 'mood' - interfaces = set(['value', 'text']) - sub_interfaces = set(['text']) - moods = set(['afraid', 'amazed', 'amorous', 'angry', 'annoyed', 'anxious', - 'aroused', 'ashamed', 'bored', 'brave', 'calm', 'cautious', - 'cold', 'confident', 'confused', 'contemplative', 'contented', - 'cranky', 'crazy', 'creative', 'curious', 'dejected', - 'depressed', 'disappointed', 'disgusted', 'dismayed', - 'distracted', 'embarrassed', 'envious', 'excited', - 'flirtatious', 'frustrated', 'grateful', 'grieving', 'grumpy', - 'guilty', 'happy', 'hopeful', 'hot', 'humbled', 'humiliated', - 'hungry', 'hurt', 'impressed', 'in_awe', 'in_love', - 'indignant', 'interested', 'intoxicated', 'invincible', - 'jealous', 'lonely', 'lost', 'lucky', 'mean', 'moody', - 'nervous', 'neutral', 'offended', 'outraged', 'playful', - 'proud', 'relaxed', 'relieved', 'remorseful', 'restless', - 'sad', 'sarcastic', 'satisfied', 'serious', 'shocked', - 'shy', 'sick', 'sleepy', 'spontaneous', 'stressed', 'strong', - 'surprised', 'thankful', 'thirsty', 'tired', 'undefined', - 'weak', 'worried']) + interfaces = {'value', 'text'} + sub_interfaces = {'text'} + moods = {'afraid', 'amazed', 'amorous', 'angry', 'annoyed', 'anxious', + 'aroused', 'ashamed', 'bored', 'brave', 'calm', 'cautious', + 'cold', 'confident', 'confused', 'contemplative', 'contented', + 'cranky', 'crazy', 'creative', 'curious', 'dejected', + 'depressed', 'disappointed', 'disgusted', 'dismayed', + 'distracted', 'embarrassed', 'envious', 'excited', + 'flirtatious', 'frustrated', 'grateful', 'grieving', 'grumpy', + 'guilty', 'happy', 'hopeful', 'hot', 'humbled', 'humiliated', + 'hungry', 'hurt', 'impressed', 'in_awe', 'in_love', + 'indignant', 'interested', 'intoxicated', 'invincible', + 'jealous', 'lonely', 'lost', 'lucky', 'mean', 'moody', + 'nervous', 'neutral', 'offended', 'outraged', 'playful', + 'proud', 'relaxed', 'relieved', 'remorseful', 'restless', + 'sad', 'sarcastic', 'satisfied', 'serious', 'shocked', + 'shy', 'sick', 'sleepy', 'spontaneous', 'stressed', 'strong', + 'surprised', 'thankful', 'thirsty', 'tired', 'undefined', + 'weak', 'worried'} def set_value(self, value): self.del_value() diff --git a/slixmpp/plugins/xep_0107/user_mood.py b/slixmpp/plugins/xep_0107/user_mood.py index c56d15fa..c745671f 100644 --- a/slixmpp/plugins/xep_0107/user_mood.py +++ b/slixmpp/plugins/xep_0107/user_mood.py @@ -27,7 +27,7 @@ class XEP_0107(BasePlugin): name = 'xep_0107' description = 'XEP-0107: User Mood' - dependencies = set(['xep_0163']) + dependencies = {'xep_0163'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0108/stanza.py b/slixmpp/plugins/xep_0108/stanza.py index d65dfdf9..c9a3c362 100644 --- a/slixmpp/plugins/xep_0108/stanza.py +++ b/slixmpp/plugins/xep_0108/stanza.py @@ -14,30 +14,30 @@ class UserActivity(ElementBase): name = 'activity' namespace = 'http://jabber.org/protocol/activity' plugin_attrib = 'activity' - interfaces = set(['value', 'text']) - sub_interfaces = set(['text']) - general = set(['doing_chores', 'drinking', 'eating', 'exercising', - 'grooming', 'having_appointment', 'inactive', 'relaxing', - 'talking', 'traveling', 'undefined', 'working']) - specific = set(['at_the_spa', 'brushing_teeth', 'buying_groceries', - 'cleaning', 'coding', 'commuting', 'cooking', 'cycling', - 'dancing', 'day_off', 'doing_maintenance', - 'doing_the_dishes', 'doing_the_laundry', 'driving', - 'fishing', 'gaming', 'gardening', 'getting_a_haircut', - 'going_out', 'hanging_out', 'having_a_beer', - 'having_a_snack', 'having_breakfast', 'having_coffee', - 'having_dinner', 'having_lunch', 'having_tea', 'hiding', - 'hiking', 'in_a_car', 'in_a_meeting', 'in_real_life', - 'jogging', 'on_a_bus', 'on_a_plane', 'on_a_train', - 'on_a_trip', 'on_the_phone', 'on_vacation', - 'on_video_phone', 'other', 'partying', 'playing_sports', - 'praying', 'reading', 'rehearsing', 'running', - 'running_an_errand', 'scheduled_holiday', 'shaving', - 'shopping', 'skiing', 'sleeping', 'smoking', - 'socializing', 'studying', 'sunbathing', 'swimming', - 'taking_a_bath', 'taking_a_shower', 'thinking', - 'walking', 'walking_the_dog', 'watching_a_movie', - 'watching_tv', 'working_out', 'writing']) + interfaces = {'value', 'text'} + sub_interfaces = {'text'} + general = {'doing_chores', 'drinking', 'eating', 'exercising', + 'grooming', 'having_appointment', 'inactive', 'relaxing', + 'talking', 'traveling', 'undefined', 'working'} + specific = {'at_the_spa', 'brushing_teeth', 'buying_groceries', + 'cleaning', 'coding', 'commuting', 'cooking', 'cycling', + 'dancing', 'day_off', 'doing_maintenance', + 'doing_the_dishes', 'doing_the_laundry', 'driving', + 'fishing', 'gaming', 'gardening', 'getting_a_haircut', + 'going_out', 'hanging_out', 'having_a_beer', + 'having_a_snack', 'having_breakfast', 'having_coffee', + 'having_dinner', 'having_lunch', 'having_tea', 'hiding', + 'hiking', 'in_a_car', 'in_a_meeting', 'in_real_life', + 'jogging', 'on_a_bus', 'on_a_plane', 'on_a_train', + 'on_a_trip', 'on_the_phone', 'on_vacation', + 'on_video_phone', 'other', 'partying', 'playing_sports', + 'praying', 'reading', 'rehearsing', 'running', + 'running_an_errand', 'scheduled_holiday', 'shaving', + 'shopping', 'skiing', 'sleeping', 'smoking', + 'socializing', 'studying', 'sunbathing', 'swimming', + 'taking_a_bath', 'taking_a_shower', 'thinking', + 'walking', 'walking_the_dog', 'watching_a_movie', + 'watching_tv', 'working_out', 'writing'} def set_value(self, value): self.del_value() diff --git a/slixmpp/plugins/xep_0108/user_activity.py b/slixmpp/plugins/xep_0108/user_activity.py index 502dfae0..d66ed9c4 100644 --- a/slixmpp/plugins/xep_0108/user_activity.py +++ b/slixmpp/plugins/xep_0108/user_activity.py @@ -23,7 +23,7 @@ class XEP_0108(BasePlugin): name = 'xep_0108' description = 'XEP-0108: User Activity' - dependencies = set(['xep_0163']) + dependencies = {'xep_0163'} stanza = stanza def plugin_end(self): diff --git a/slixmpp/plugins/xep_0115/caps.py b/slixmpp/plugins/xep_0115/caps.py index c6f9ea10..131d269b 100644 --- a/slixmpp/plugins/xep_0115/caps.py +++ b/slixmpp/plugins/xep_0115/caps.py @@ -32,7 +32,7 @@ class XEP_0115(BasePlugin): name = 'xep_0115' description = 'XEP-0115: Entity Capabilities' - dependencies = set(['xep_0030', 'xep_0128', 'xep_0004']) + dependencies = {'xep_0030', 'xep_0128', 'xep_0004'} stanza = stanza default_config = { 'hash': 'sha-1', diff --git a/slixmpp/plugins/xep_0115/stanza.py b/slixmpp/plugins/xep_0115/stanza.py index 36fb173c..1811307f 100644 --- a/slixmpp/plugins/xep_0115/stanza.py +++ b/slixmpp/plugins/xep_0115/stanza.py @@ -16,4 +16,4 @@ class Capabilities(ElementBase): namespace = 'http://jabber.org/protocol/caps' name = 'c' plugin_attrib = 'caps' - interfaces = set(('hash', 'node', 'ver', 'ext')) + interfaces = {'hash', 'node', 'ver', 'ext'} diff --git a/slixmpp/plugins/xep_0118/stanza.py b/slixmpp/plugins/xep_0118/stanza.py index 4f5a1795..579fcbf0 100644 --- a/slixmpp/plugins/xep_0118/stanza.py +++ b/slixmpp/plugins/xep_0118/stanza.py @@ -14,8 +14,8 @@ class UserTune(ElementBase): name = 'tune' namespace = 'http://jabber.org/protocol/tune' plugin_attrib = 'tune' - interfaces = set(['artist', 'length', 'rating', 'source', - 'title', 'track', 'uri']) + interfaces = {'artist', 'length', 'rating', 'source', + 'title', 'track', 'uri'} sub_interfaces = interfaces def set_length(self, value): diff --git a/slixmpp/plugins/xep_0118/user_tune.py b/slixmpp/plugins/xep_0118/user_tune.py index 0882a5ba..8b64eaf7 100644 --- a/slixmpp/plugins/xep_0118/user_tune.py +++ b/slixmpp/plugins/xep_0118/user_tune.py @@ -23,7 +23,7 @@ class XEP_0118(BasePlugin): name = 'xep_0118' description = 'XEP-0118: User Tune' - dependencies = set(['xep_0163']) + dependencies = {'xep_0163'} stanza = stanza def plugin_end(self): diff --git a/slixmpp/plugins/xep_0122/data_validation.py b/slixmpp/plugins/xep_0122/data_validation.py index 6129db51..65e7b3e3 100644 --- a/slixmpp/plugins/xep_0122/data_validation.py +++ b/slixmpp/plugins/xep_0122/data_validation.py @@ -12,7 +12,7 @@ class XEP_0122(BasePlugin): name = 'xep_0122' description = 'XEP-0122: Data Forms Validation' - dependencies = set(['xep_0004']) + dependencies = {'xep_0004'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0128/extended_disco.py b/slixmpp/plugins/xep_0128/extended_disco.py index 5cc1d35a..bf3971e3 100644 --- a/slixmpp/plugins/xep_0128/extended_disco.py +++ b/slixmpp/plugins/xep_0128/extended_disco.py @@ -41,7 +41,7 @@ class XEP_0128(BasePlugin): name = 'xep_0128' description = 'XEP-0128: Service Discovery Extensions' - dependencies = set(['xep_0030', 'xep_0004']) + dependencies = {'xep_0030', 'xep_0004'} def plugin_init(self): """Start the XEP-0128 plugin.""" diff --git a/slixmpp/plugins/xep_0131/headers.py b/slixmpp/plugins/xep_0131/headers.py index 81fc9188..978c490d 100644 --- a/slixmpp/plugins/xep_0131/headers.py +++ b/slixmpp/plugins/xep_0131/headers.py @@ -17,7 +17,7 @@ class XEP_0131(BasePlugin): name = 'xep_0131' description = 'XEP-0131: Stanza Headers and Internet Metadata' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza default_config = { 'supported_headers': set() diff --git a/slixmpp/plugins/xep_0131/stanza.py b/slixmpp/plugins/xep_0131/stanza.py index cbbe61a7..d075c15e 100644 --- a/slixmpp/plugins/xep_0131/stanza.py +++ b/slixmpp/plugins/xep_0131/stanza.py @@ -14,7 +14,7 @@ class Headers(ElementBase): name = 'headers' namespace = 'http://jabber.org/protocol/shim' plugin_attrib = 'headers' - interfaces = set(['headers']) + interfaces = {'headers'} is_extension = True def get_headers(self): diff --git a/slixmpp/plugins/xep_0133.py b/slixmpp/plugins/xep_0133.py index a1eb9e02..aec1ee36 100644 --- a/slixmpp/plugins/xep_0133.py +++ b/slixmpp/plugins/xep_0133.py @@ -14,19 +14,19 @@ class XEP_0133(BasePlugin): name = 'xep_0133' description = 'XEP-0133: Service Administration' - dependencies = set(['xep_0030', 'xep_0004', 'xep_0050']) - commands = set(['add-user', 'delete-user', 'disable-user', - 'reenable-user', 'end-user-session', 'get-user-password', - 'change-user-password', 'get-user-roster', - 'get-user-lastlogin', 'user-stats', 'edit-blacklist', - 'edit-whitelist', 'get-registered-users-num', - 'get-disabled-users-num', 'get-online-users-num', - 'get-active-users-num', 'get-idle-users-num', - 'get-registered-users-list', 'get-disabled-users-list', - 'get-online-users-list', 'get-online-users', - 'get-active-users', 'get-idle-userslist', 'announce', - 'set-motd', 'edit-motd', 'delete-motd', 'set-welcome', - 'delete-welcome', 'edit-admin', 'restart', 'shutdown']) + dependencies = {'xep_0030', 'xep_0004', 'xep_0050'} + commands = {'add-user', 'delete-user', 'disable-user', + 'reenable-user', 'end-user-session', 'get-user-password', + 'change-user-password', 'get-user-roster', + 'get-user-lastlogin', 'user-stats', 'edit-blacklist', + 'edit-whitelist', 'get-registered-users-num', + 'get-disabled-users-num', 'get-online-users-num', + 'get-active-users-num', 'get-idle-users-num', + 'get-registered-users-list', 'get-disabled-users-list', + 'get-online-users-list', 'get-online-users', + 'get-active-users', 'get-idle-userslist', 'announce', + 'set-motd', 'edit-motd', 'delete-motd', 'set-welcome', + 'delete-welcome', 'edit-admin', 'restart', 'shutdown'} def get_commands(self, jid=None, **kwargs): if jid is None: diff --git a/slixmpp/plugins/xep_0138.py b/slixmpp/plugins/xep_0138.py index 049060cf..4780f8ee 100644 --- a/slixmpp/plugins/xep_0138.py +++ b/slixmpp/plugins/xep_0138.py @@ -22,7 +22,7 @@ log = logging.getLogger(__name__) class Compression(ElementBase): name = 'compression' namespace = 'http://jabber.org/features/compress' - interfaces = set(('methods',)) + interfaces = {'methods'} plugin_attrib = 'compression' plugin_tag_map = {} plugin_attrib_map = {} @@ -37,7 +37,7 @@ class Compression(ElementBase): class Compress(StanzaBase): name = 'compress' namespace = 'http://jabber.org/protocol/compress' - interfaces = set(('method',)) + interfaces = {'method'} sub_interfaces = interfaces plugin_attrib = 'compress' plugin_tag_map = {} @@ -95,7 +95,7 @@ class XEP_0138(BasePlugin): """ name = "xep_0138" description = "XEP-0138: Compression" - dependencies = set(["xep_0030"]) + dependencies = {"xep_0030"} def plugin_init(self): self.xep = '0138' diff --git a/slixmpp/plugins/xep_0152/reachability.py b/slixmpp/plugins/xep_0152/reachability.py index e6d94b65..3ff5e118 100644 --- a/slixmpp/plugins/xep_0152/reachability.py +++ b/slixmpp/plugins/xep_0152/reachability.py @@ -23,7 +23,7 @@ class XEP_0152(BasePlugin): name = 'xep_0152' description = 'XEP-0152: Reachability Addresses' - dependencies = set(['xep_0163']) + dependencies = {'xep_0163'} stanza = stanza def plugin_end(self): diff --git a/slixmpp/plugins/xep_0152/stanza.py b/slixmpp/plugins/xep_0152/stanza.py index 661544e3..cbf725fa 100644 --- a/slixmpp/plugins/xep_0152/stanza.py +++ b/slixmpp/plugins/xep_0152/stanza.py @@ -21,9 +21,9 @@ class Address(ElementBase): namespace = 'urn:xmpp:reach:0' plugin_attrib = 'address' plugin_multi_attrib = 'addresses' - interfaces = set(['uri', 'desc']) - lang_interfaces = set(['desc']) - sub_interfaces = set(['desc']) + interfaces = {'uri', 'desc'} + lang_interfaces = {'desc'} + sub_interfaces = {'desc'} register_stanza_plugin(Reachability, Address, iterable=True) diff --git a/slixmpp/plugins/xep_0153/stanza.py b/slixmpp/plugins/xep_0153/stanza.py index fe8d5e98..9d0c51da 100644 --- a/slixmpp/plugins/xep_0153/stanza.py +++ b/slixmpp/plugins/xep_0153/stanza.py @@ -13,7 +13,7 @@ class VCardTempUpdate(ElementBase): name = 'x' namespace = 'vcard-temp:x:update' plugin_attrib = 'vcard_temp_update' - interfaces = set(['photo']) + interfaces = {'photo'} sub_interfaces = interfaces def set_photo(self, value): diff --git a/slixmpp/plugins/xep_0153/vcard_avatar.py b/slixmpp/plugins/xep_0153/vcard_avatar.py index b2c4caf5..f1591e27 100644 --- a/slixmpp/plugins/xep_0153/vcard_avatar.py +++ b/slixmpp/plugins/xep_0153/vcard_avatar.py @@ -24,7 +24,7 @@ class XEP_0153(BasePlugin): name = 'xep_0153' description = 'XEP-0153: vCard-Based Avatars' - dependencies = set(['xep_0054']) + dependencies = {'xep_0054'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0163.py b/slixmpp/plugins/xep_0163.py index b85c662c..5832b4ee 100644 --- a/slixmpp/plugins/xep_0163.py +++ b/slixmpp/plugins/xep_0163.py @@ -24,7 +24,7 @@ class XEP_0163(BasePlugin): name = 'xep_0163' description = 'XEP-0163: Personal Eventing Protocol (PEP)' - dependencies = set(['xep_0030', 'xep_0060', 'xep_0115']) + dependencies = {'xep_0030', 'xep_0060', 'xep_0115'} def register_pep(self, name, stanza): """ diff --git a/slixmpp/plugins/xep_0172/stanza.py b/slixmpp/plugins/xep_0172/stanza.py index 305f3a00..c85137ab 100644 --- a/slixmpp/plugins/xep_0172/stanza.py +++ b/slixmpp/plugins/xep_0172/stanza.py @@ -46,7 +46,7 @@ class UserNick(ElementBase): namespace = 'http://jabber.org/protocol/nick' name = 'nick' plugin_attrib = name - interfaces = set(('nick',)) + interfaces = {'nick'} def set_nick(self, nick): """ diff --git a/slixmpp/plugins/xep_0172/user_nick.py b/slixmpp/plugins/xep_0172/user_nick.py index b9f20b27..0bba8611 100644 --- a/slixmpp/plugins/xep_0172/user_nick.py +++ b/slixmpp/plugins/xep_0172/user_nick.py @@ -28,7 +28,7 @@ class XEP_0172(BasePlugin): name = 'xep_0172' description = 'XEP-0172: User Nickname' - dependencies = set(['xep_0163']) + dependencies = {'xep_0163'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0184/receipt.py b/slixmpp/plugins/xep_0184/receipt.py index 2c3555dc..f89a5d9b 100644 --- a/slixmpp/plugins/xep_0184/receipt.py +++ b/slixmpp/plugins/xep_0184/receipt.py @@ -24,7 +24,7 @@ class XEP_0184(BasePlugin): name = 'xep_0184' description = 'XEP-0184: Message Delivery Receipts' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza default_config = { 'auto_ack': True, diff --git a/slixmpp/plugins/xep_0184/stanza.py b/slixmpp/plugins/xep_0184/stanza.py index 03a0ff9c..26e289a3 100644 --- a/slixmpp/plugins/xep_0184/stanza.py +++ b/slixmpp/plugins/xep_0184/stanza.py @@ -13,7 +13,7 @@ class Request(ElementBase): namespace = 'urn:xmpp:receipts' name = 'request' plugin_attrib = 'request_receipt' - interfaces = set(('request_receipt',)) + interfaces = {'request_receipt'} sub_interfaces = interfaces is_extension = True @@ -45,7 +45,7 @@ class Received(ElementBase): namespace = 'urn:xmpp:receipts' name = 'received' plugin_attrib = 'receipt' - interfaces = set(['receipt']) + interfaces = {'receipt'} sub_interfaces = interfaces is_extension = True diff --git a/slixmpp/plugins/xep_0186/invisible_command.py b/slixmpp/plugins/xep_0186/invisible_command.py index 88266f6e..a6df59a2 100644 --- a/slixmpp/plugins/xep_0186/invisible_command.py +++ b/slixmpp/plugins/xep_0186/invisible_command.py @@ -21,7 +21,7 @@ class XEP_0186(BasePlugin): name = 'xep_0186' description = 'XEP-0186: Invisible Command' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} def plugin_init(self): register_stanza_plugin(Iq, Visible) diff --git a/slixmpp/plugins/xep_0191/blocking.py b/slixmpp/plugins/xep_0191/blocking.py index fa2a013e..5425544d 100644 --- a/slixmpp/plugins/xep_0191/blocking.py +++ b/slixmpp/plugins/xep_0191/blocking.py @@ -23,7 +23,7 @@ class XEP_0191(BasePlugin): name = 'xep_0191' description = 'XEP-0191: Blocking Command' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0191/stanza.py b/slixmpp/plugins/xep_0191/stanza.py index 4dac7bfc..0cf5c71a 100644 --- a/slixmpp/plugins/xep_0191/stanza.py +++ b/slixmpp/plugins/xep_0191/stanza.py @@ -13,7 +13,7 @@ class BlockList(ElementBase): name = 'blocklist' namespace = 'urn:xmpp:blocking' plugin_attrib = 'blocklist' - interfaces = set(['items']) + interfaces = {'items'} def get_items(self): result = set() diff --git a/slixmpp/plugins/xep_0196/stanza.py b/slixmpp/plugins/xep_0196/stanza.py index 9c3cd0ed..79f5621e 100644 --- a/slixmpp/plugins/xep_0196/stanza.py +++ b/slixmpp/plugins/xep_0196/stanza.py @@ -14,7 +14,7 @@ class UserGaming(ElementBase): name = 'gaming' namespace = 'urn:xmpp:gaming:0' plugin_attrib = 'gaming' - interfaces = set(['character_name', 'character_profile', 'name', - 'level', 'server_address', 'server_name', 'uri']) + interfaces = {'character_name', 'character_profile', 'name', + 'level', 'server_address', 'server_name', 'uri'} sub_interfaces = interfaces diff --git a/slixmpp/plugins/xep_0196/user_gaming.py b/slixmpp/plugins/xep_0196/user_gaming.py index f0dee99f..5a573ea9 100644 --- a/slixmpp/plugins/xep_0196/user_gaming.py +++ b/slixmpp/plugins/xep_0196/user_gaming.py @@ -23,7 +23,7 @@ class XEP_0196(BasePlugin): name = 'xep_0196' description = 'XEP-0196: User Gaming' - dependencies = set(['xep_0163']) + dependencies = {'xep_0163'} stanza = stanza def plugin_end(self): diff --git a/slixmpp/plugins/xep_0198/stanza.py b/slixmpp/plugins/xep_0198/stanza.py index 5b13293b..37560227 100644 --- a/slixmpp/plugins/xep_0198/stanza.py +++ b/slixmpp/plugins/xep_0198/stanza.py @@ -13,7 +13,7 @@ from slixmpp.xmlstream import ElementBase, StanzaBase class Enable(StanzaBase): name = 'enable' namespace = 'urn:xmpp:sm:3' - interfaces = set(['max', 'resume']) + interfaces = {'max', 'resume'} def setup(self, xml): StanzaBase.setup(self, xml) @@ -30,7 +30,7 @@ class Enable(StanzaBase): class Enabled(StanzaBase): name = 'enabled' namespace = 'urn:xmpp:sm:3' - interfaces = set(['id', 'location', 'max', 'resume']) + interfaces = {'id', 'location', 'max', 'resume'} def setup(self, xml): StanzaBase.setup(self, xml) @@ -47,7 +47,7 @@ class Enabled(StanzaBase): class Resume(StanzaBase): name = 'resume' namespace = 'urn:xmpp:sm:3' - interfaces = set(['h', 'previd']) + interfaces = {'h', 'previd'} def setup(self, xml): StanzaBase.setup(self, xml) @@ -66,7 +66,7 @@ class Resume(StanzaBase): class Resumed(StanzaBase): name = 'resumed' namespace = 'urn:xmpp:sm:3' - interfaces = set(['h', 'previd']) + interfaces = {'h', 'previd'} def setup(self, xml): StanzaBase.setup(self, xml) @@ -96,7 +96,7 @@ class StreamManagement(ElementBase): name = 'sm' namespace = 'urn:xmpp:sm:3' plugin_attrib = name - interfaces = set(['required', 'optional']) + interfaces = {'required', 'optional'} def get_required(self): return self.xml.find('{%s}required' % self.namespace) is not None @@ -134,7 +134,7 @@ class RequestAck(StanzaBase): class Ack(StanzaBase): name = 'a' namespace = 'urn:xmpp:sm:3' - interfaces = set(['h']) + interfaces = {'h'} def setup(self, xml): StanzaBase.setup(self, xml) diff --git a/slixmpp/plugins/xep_0199/ping.py b/slixmpp/plugins/xep_0199/ping.py index 8594ac01..9bd595a4 100644 --- a/slixmpp/plugins/xep_0199/ping.py +++ b/slixmpp/plugins/xep_0199/ping.py @@ -50,7 +50,7 @@ class XEP_0199(BasePlugin): name = 'xep_0199' description = 'XEP-0199: XMPP Ping' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza default_config = { 'keepalive': False, diff --git a/slixmpp/plugins/xep_0202/stanza.py b/slixmpp/plugins/xep_0202/stanza.py index c855663b..d97b2fb2 100644 --- a/slixmpp/plugins/xep_0202/stanza.py +++ b/slixmpp/plugins/xep_0202/stanza.py @@ -48,7 +48,7 @@ class EntityTime(ElementBase): name = 'time' namespace = 'urn:xmpp:time' plugin_attrib = 'entity_time' - interfaces = set(('tzo', 'utc', 'time')) + interfaces = {'tzo', 'utc', 'time'} sub_interfaces = interfaces def set_time(self, value): diff --git a/slixmpp/plugins/xep_0202/time.py b/slixmpp/plugins/xep_0202/time.py index 185200fc..05df6374 100644 --- a/slixmpp/plugins/xep_0202/time.py +++ b/slixmpp/plugins/xep_0202/time.py @@ -28,7 +28,7 @@ class XEP_0202(BasePlugin): name = 'xep_0202' description = 'XEP-0202: Entity Time' - dependencies = set(['xep_0030', 'xep_0082']) + dependencies = {'xep_0030', 'xep_0082'} stanza = stanza default_config = { #: As a default, respond to time requests with the diff --git a/slixmpp/plugins/xep_0203/stanza.py b/slixmpp/plugins/xep_0203/stanza.py index de907c69..5daed864 100644 --- a/slixmpp/plugins/xep_0203/stanza.py +++ b/slixmpp/plugins/xep_0203/stanza.py @@ -18,7 +18,7 @@ class Delay(ElementBase): name = 'delay' namespace = 'urn:xmpp:delay' plugin_attrib = 'delay' - interfaces = set(('from', 'stamp', 'text')) + interfaces = {'from', 'stamp', 'text'} def get_from(self): from_ = self._get_attr('from') diff --git a/slixmpp/plugins/xep_0221/media.py b/slixmpp/plugins/xep_0221/media.py index 4c34fbd2..628a3b05 100644 --- a/slixmpp/plugins/xep_0221/media.py +++ b/slixmpp/plugins/xep_0221/media.py @@ -21,7 +21,7 @@ class XEP_0221(BasePlugin): name = 'xep_0221' description = 'XEP-0221: Data Forms Media Element' - dependencies = set(['xep_0004']) + dependencies = {'xep_0004'} def plugin_init(self): register_stanza_plugin(FormField, Media) diff --git a/slixmpp/plugins/xep_0221/stanza.py b/slixmpp/plugins/xep_0221/stanza.py index 2a2bbabd..097f03c4 100644 --- a/slixmpp/plugins/xep_0221/stanza.py +++ b/slixmpp/plugins/xep_0221/stanza.py @@ -13,7 +13,7 @@ class Media(ElementBase): name = 'media' namespace = 'urn:xmpp:media-element' plugin_attrib = 'media' - interfaces = set(['height', 'width', 'alt']) + interfaces = {'height', 'width', 'alt'} def add_uri(self, value, itype): uri = URI() @@ -27,7 +27,7 @@ class URI(ElementBase): namespace = 'urn:xmpp:media-element' plugin_attrib = 'uri' plugin_multi_attrib = 'uris' - interfaces = set(['type', 'value']) + interfaces = {'type', 'value'} def get_value(self): return self.xml.text @@ -36,7 +36,7 @@ class URI(ElementBase): self.xml.text = value def del_value(self): - sel.xml.text = '' + self.xml.text = '' register_stanza_plugin(Media, URI, iterable=True) diff --git a/slixmpp/plugins/xep_0222.py b/slixmpp/plugins/xep_0222.py index 059f4c85..81daed38 100644 --- a/slixmpp/plugins/xep_0222.py +++ b/slixmpp/plugins/xep_0222.py @@ -23,12 +23,12 @@ class XEP_0222(BasePlugin): name = 'xep_0222' description = 'XEP-0222: Persistent Storage of Public Data via PubSub' - dependencies = set(['xep_0163', 'xep_0060', 'xep_0004']) + dependencies = {'xep_0163', 'xep_0060', 'xep_0004'} profile = {'pubsub#persist_items': True, 'pubsub#send_last_published_item': 'never'} - def configure(self, node): + def configure(self, node, ifrom=None, callback=None, timeout=None): """ Update a node's configuration to match the public storage profile. """ diff --git a/slixmpp/plugins/xep_0223.py b/slixmpp/plugins/xep_0223.py index 2461bb20..566e430b 100644 --- a/slixmpp/plugins/xep_0223.py +++ b/slixmpp/plugins/xep_0223.py @@ -23,12 +23,12 @@ class XEP_0223(BasePlugin): name = 'xep_0223' description = 'XEP-0223: Persistent Storage of Private Data via PubSub' - dependencies = set(['xep_0163', 'xep_0060', 'xep_0004']) + dependencies = {'xep_0163', 'xep_0060', 'xep_0004'} profile = {'pubsub#persist_items': True, 'pubsub#send_last_published_item': 'never'} - def configure(self, node): + def configure(self, node, ifrom=None, callback=None, timeout=None): """ Update a node's configuration to match the public storage profile. """ diff --git a/slixmpp/plugins/xep_0224/attention.py b/slixmpp/plugins/xep_0224/attention.py index 2777e1b0..196d3ed6 100644 --- a/slixmpp/plugins/xep_0224/attention.py +++ b/slixmpp/plugins/xep_0224/attention.py @@ -27,7 +27,7 @@ class XEP_0224(BasePlugin): name = 'xep_0224' description = 'XEP-0224: Attention' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0224/stanza.py b/slixmpp/plugins/xep_0224/stanza.py index 2b77dadd..d50d74b4 100644 --- a/slixmpp/plugins/xep_0224/stanza.py +++ b/slixmpp/plugins/xep_0224/stanza.py @@ -17,7 +17,7 @@ class Attention(ElementBase): name = 'attention' namespace = 'urn:xmpp:attention:0' plugin_attrib = 'attention' - interfaces = set(('attention',)) + interfaces = {'attention'} is_extension = True def setup(self, xml): diff --git a/slixmpp/plugins/xep_0231/bob.py b/slixmpp/plugins/xep_0231/bob.py index a3b5edd4..690d34d4 100644 --- a/slixmpp/plugins/xep_0231/bob.py +++ b/slixmpp/plugins/xep_0231/bob.py @@ -31,7 +31,7 @@ class XEP_0231(BasePlugin): name = 'xep_0231' description = 'XEP-0231: Bits of Binary' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} def plugin_init(self): self._cids = {} diff --git a/slixmpp/plugins/xep_0231/stanza.py b/slixmpp/plugins/xep_0231/stanza.py index b3b96eff..3de99aac 100644 --- a/slixmpp/plugins/xep_0231/stanza.py +++ b/slixmpp/plugins/xep_0231/stanza.py @@ -18,7 +18,7 @@ class BitsOfBinary(ElementBase): name = 'data' namespace = 'urn:xmpp:bob' plugin_attrib = 'bob' - interfaces = set(('cid', 'max_age', 'type', 'data')) + interfaces = {'cid', 'max_age', 'type', 'data'} def get_max_age(self): return int(self._get_attr('max-age')) diff --git a/slixmpp/plugins/xep_0235/oauth.py b/slixmpp/plugins/xep_0235/oauth.py index bcd220b0..4d685cd2 100644 --- a/slixmpp/plugins/xep_0235/oauth.py +++ b/slixmpp/plugins/xep_0235/oauth.py @@ -19,7 +19,7 @@ class XEP_0235(BasePlugin): name = 'xep_0235' description = 'XEP-0235: OAuth Over XMPP' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0235/stanza.py b/slixmpp/plugins/xep_0235/stanza.py index abb4a38d..5205b07c 100644 --- a/slixmpp/plugins/xep_0235/stanza.py +++ b/slixmpp/plugins/xep_0235/stanza.py @@ -19,9 +19,9 @@ class OAuth(ElementBase): name = 'oauth' namespace = 'urn:xmpp:oauth:0' plugin_attrib = 'oauth' - interfaces = set(['oauth_consumer_key', 'oauth_nonce', 'oauth_signature', - 'oauth_signature_method', 'oauth_timestamp', - 'oauth_token', 'oauth_version']) + interfaces = {'oauth_consumer_key', 'oauth_nonce', 'oauth_signature', + 'oauth_signature_method', 'oauth_timestamp', 'oauth_token', + 'oauth_version'} sub_interfaces = interfaces def generate_signature(self, stanza, sfrom, sto, consumer_secret, diff --git a/slixmpp/plugins/xep_0242.py b/slixmpp/plugins/xep_0242.py index ea077a70..27e4e7c8 100644 --- a/slixmpp/plugins/xep_0242.py +++ b/slixmpp/plugins/xep_0242.py @@ -13,9 +13,9 @@ class XEP_0242(BasePlugin): name = 'xep_0242' description = 'XEP-0242: XMPP Client Compliance 2009' - dependencies = set(['xep_0030', 'xep_0115', 'xep_0054', - 'xep_0045', 'xep_0085', 'xep_0016', - 'xep_0191']) + dependencies = {'xep_0030', 'xep_0115', 'xep_0054', + 'xep_0045', 'xep_0085', 'xep_0016', + 'xep_0191'} register_plugin(XEP_0242) diff --git a/slixmpp/plugins/xep_0249/invite.py b/slixmpp/plugins/xep_0249/invite.py index fe5f5884..9f08eae3 100644 --- a/slixmpp/plugins/xep_0249/invite.py +++ b/slixmpp/plugins/xep_0249/invite.py @@ -28,7 +28,7 @@ class XEP_0249(BasePlugin): name = 'xep_0249' description = 'XEP-0249: Direct MUC Invitations' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0256.py b/slixmpp/plugins/xep_0256.py index 4ad4f0ea..4efa3518 100644 --- a/slixmpp/plugins/xep_0256.py +++ b/slixmpp/plugins/xep_0256.py @@ -23,7 +23,7 @@ class XEP_0256(BasePlugin): name = 'xep_0256' description = 'XEP-0256: Last Activity in Presence' - dependencies = set(['xep_0012']) + dependencies = {'xep_0012'} stanza = stanza default_config = { 'auto_last_activity': False diff --git a/slixmpp/plugins/xep_0256/last_activity_presence.py b/slixmpp/plugins/xep_0256/last_activity_presence.py index 3766c61e..eb153808 100644 --- a/slixmpp/plugins/xep_0256/last_activity_presence.py +++ b/slixmpp/plugins/xep_0256/last_activity_presence.py @@ -20,7 +20,7 @@ class XEP_0256(BasePlugin): name = 'xep_0256' description = 'XEP-0256: Last Activity in Presence' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0257/client_cert_management.py b/slixmpp/plugins/xep_0257/client_cert_management.py index a6d07506..e5a06cf3 100644 --- a/slixmpp/plugins/xep_0257/client_cert_management.py +++ b/slixmpp/plugins/xep_0257/client_cert_management.py @@ -22,7 +22,7 @@ class XEP_0257(BasePlugin): name = 'xep_0257' description = 'XEP-0257: Client Certificate Management for SASL EXTERNAL' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0257/stanza.py b/slixmpp/plugins/xep_0257/stanza.py index 86b63451..18d26775 100644 --- a/slixmpp/plugins/xep_0257/stanza.py +++ b/slixmpp/plugins/xep_0257/stanza.py @@ -21,13 +21,13 @@ class CertItem(ElementBase): namespace = 'urn:xmpp:saslcert:1' plugin_attrib = 'item' plugin_multi_attrib = 'items' - interfaces = set(['name', 'x509cert', 'users']) - sub_interfaces = set(['name', 'x509cert']) + interfaces = {'name', 'x509cert', 'users'} + sub_interfaces = {'name', 'x509cert'} def get_users(self): resources = self.xml.findall('{%s}users/{%s}resource' % ( self.namespace, self.namespace)) - return set([res.text for res in resources]) + return {res.text for res in resources} def set_users(self, values): users = self.xml.find('{%s}users' % self.namespace) @@ -49,8 +49,8 @@ class AppendCert(ElementBase): name = 'append' namespace = 'urn:xmpp:saslcert:1' plugin_attrib = 'sasl_cert_append' - interfaces = set(['name', 'x509cert', 'cert_management']) - sub_interfaces = set(['name', 'x509cert']) + interfaces = {'name', 'x509cert', 'cert_management'} + sub_interfaces = {'name', 'x509cert'} def get_cert_management(self): manage = self.xml.find('{%s}no-cert-management' % self.namespace) @@ -72,7 +72,7 @@ class DisableCert(ElementBase): name = 'disable' namespace = 'urn:xmpp:saslcert:1' plugin_attrib = 'sasl_cert_disable' - interfaces = set(['name']) + interfaces = {'name'} sub_interfaces = interfaces @@ -80,7 +80,7 @@ class RevokeCert(ElementBase): name = 'revoke' namespace = 'urn:xmpp:saslcert:1' plugin_attrib = 'sasl_cert_revoke' - interfaces = set(['name']) + interfaces = {'name'} sub_interfaces = interfaces diff --git a/slixmpp/plugins/xep_0258/security_labels.py b/slixmpp/plugins/xep_0258/security_labels.py index 2fb048c7..b4c3a75a 100644 --- a/slixmpp/plugins/xep_0258/security_labels.py +++ b/slixmpp/plugins/xep_0258/security_labels.py @@ -21,7 +21,7 @@ class XEP_0258(BasePlugin): name = 'xep_0258' description = 'XEP-0258: Security Labels in XMPP' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0258/stanza.py b/slixmpp/plugins/xep_0258/stanza.py index e47bd34f..c0c7080c 100644 --- a/slixmpp/plugins/xep_0258/stanza.py +++ b/slixmpp/plugins/xep_0258/stanza.py @@ -8,6 +8,7 @@ from base64 import b64encode, b64decode +from slixmpp import JID from slixmpp.util import bytes from slixmpp.xmlstream import ElementBase, ET, register_stanza_plugin @@ -33,7 +34,7 @@ class DisplayMarking(ElementBase): name = 'displaymarking' namespace = 'urn:xmpp:sec-label:0' plugin_attrib = 'display_marking' - interfaces = set(['fgcolor', 'bgcolor', 'value']) + interfaces = {'fgcolor', 'bgcolor', 'value'} def get_fgcolor(self): return self._get_attr('fgcolor', 'black') @@ -62,7 +63,7 @@ class Catalog(ElementBase): name = 'catalog' namespace = 'urn:xmpp:sec-label:catalog:2' plugin_attrib = 'security_label_catalog' - interfaces = set(['to', 'from', 'name', 'desc', 'id', 'size', 'restrict']) + interfaces = {'to', 'from', 'name', 'desc', 'id', 'size', 'restrict'} def get_to(self): return JID(self._get_attr('to')) @@ -96,7 +97,7 @@ class CatalogItem(ElementBase): namespace = 'urn:xmpp:sec-label:catalog:2' plugin_attrib = 'item' plugin_multi_attrib = 'items' - interfaces = set(['selector', 'default']) + interfaces = {'selector', 'default'} def get_default(self): value = self._get_attr('default', '') @@ -116,7 +117,7 @@ class ESSLabel(ElementBase): name = 'esssecuritylabel' namespace = 'urn:xmpp:sec-label:ess:0' plugin_attrib = 'ess' - interfaces = set(['value']) + interfaces = {'value'} def get_value(self): if self.xml.text: diff --git a/slixmpp/plugins/xep_0270.py b/slixmpp/plugins/xep_0270.py index 4d02a0a1..e5316ae5 100644 --- a/slixmpp/plugins/xep_0270.py +++ b/slixmpp/plugins/xep_0270.py @@ -13,8 +13,8 @@ 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']) + dependencies = {'xep_0030', 'xep_0115', 'xep_0054', + 'xep_0163', 'xep_0045', 'xep_0085'} register_plugin(XEP_0270) diff --git a/slixmpp/plugins/xep_0279/ipcheck.py b/slixmpp/plugins/xep_0279/ipcheck.py index e8cea46f..56d9afd4 100644 --- a/slixmpp/plugins/xep_0279/ipcheck.py +++ b/slixmpp/plugins/xep_0279/ipcheck.py @@ -19,7 +19,7 @@ class XEP_0279(BasePlugin): name = 'xep_0279' description = 'XEP-0279: Server IP Check' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0279/stanza.py b/slixmpp/plugins/xep_0279/stanza.py index f80623cd..d8f5f674 100644 --- a/slixmpp/plugins/xep_0279/stanza.py +++ b/slixmpp/plugins/xep_0279/stanza.py @@ -14,7 +14,7 @@ class IPCheck(ElementBase): name = 'ip' namespace = 'urn:xmpp:sic:0' plugin_attrib = 'ip_check' - interfaces = set(['ip_check']) + interfaces = {'ip_check'} is_extension = True def get_ip_check(self): diff --git a/slixmpp/plugins/xep_0280/carbons.py b/slixmpp/plugins/xep_0280/carbons.py index a64ccbfd..aa71f7f1 100644 --- a/slixmpp/plugins/xep_0280/carbons.py +++ b/slixmpp/plugins/xep_0280/carbons.py @@ -28,7 +28,7 @@ class XEP_0280(BasePlugin): name = 'xep_0280' description = 'XEP-0280: Message Carbons' - dependencies = set(['xep_0030', 'xep_0297']) + dependencies = {'xep_0030', 'xep_0297'} stanza = stanza def plugin_init(self): @@ -61,10 +61,12 @@ class XEP_0280(BasePlugin): self.xmpp.plugin['xep_0030'].add_feature('urn:xmpp:carbons:2') def _handle_carbon_received(self, msg): - self.xmpp.event('carbon_received', msg) + if msg['from'].bare == self.xmpp.boundjid.bare: + self.xmpp.event('carbon_received', msg) def _handle_carbon_sent(self, msg): - self.xmpp.event('carbon_sent', msg) + if msg['from'].bare == self.xmpp.boundjid.bare: + self.xmpp.event('carbon_sent', msg) def enable(self, ifrom=None, timeout=None, callback=None, timeout_callback=None): diff --git a/slixmpp/plugins/xep_0280/stanza.py b/slixmpp/plugins/xep_0280/stanza.py index 46276189..343df12f 100644 --- a/slixmpp/plugins/xep_0280/stanza.py +++ b/slixmpp/plugins/xep_0280/stanza.py @@ -13,7 +13,7 @@ class ReceivedCarbon(ElementBase): name = 'received' namespace = 'urn:xmpp:carbons:2' plugin_attrib = 'carbon_received' - interfaces = set(['carbon_received']) + interfaces = {'carbon_received'} is_extension = True def get_carbon_received(self): @@ -30,7 +30,7 @@ class SentCarbon(ElementBase): name = 'sent' namespace = 'urn:xmpp:carbons:2' plugin_attrib = 'carbon_sent' - interfaces = set(['carbon_sent']) + interfaces = {'carbon_sent'} is_extension = True def get_carbon_sent(self): diff --git a/slixmpp/plugins/xep_0297/forwarded.py b/slixmpp/plugins/xep_0297/forwarded.py index 7c40bf30..a0c36d0c 100644 --- a/slixmpp/plugins/xep_0297/forwarded.py +++ b/slixmpp/plugins/xep_0297/forwarded.py @@ -21,7 +21,7 @@ class XEP_0297(BasePlugin): name = 'xep_0297' description = 'XEP-0297: Stanza Forwarding' - dependencies = set(['xep_0030', 'xep_0203']) + dependencies = {'xep_0030', 'xep_0203'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0297/stanza.py b/slixmpp/plugins/xep_0297/stanza.py index 233ad4f6..d211f83c 100644 --- a/slixmpp/plugins/xep_0297/stanza.py +++ b/slixmpp/plugins/xep_0297/stanza.py @@ -14,7 +14,7 @@ class Forwarded(ElementBase): name = 'forwarded' namespace = 'urn:xmpp:forward:0' plugin_attrib = 'forwarded' - interfaces = set(['stanza']) + interfaces = {'stanza'} def get_stanza(self): for stanza in self: diff --git a/slixmpp/plugins/xep_0300/__init__.py b/slixmpp/plugins/xep_0300/__init__.py new file mode 100644 index 00000000..522d40e3 --- /dev/null +++ b/slixmpp/plugins/xep_0300/__init__.py @@ -0,0 +1,16 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2017 Emmanuel Gil Peyrot + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.plugins.base import register_plugin + +from slixmpp.plugins.xep_0300 import stanza +from slixmpp.plugins.xep_0300.stanza import Hash +from slixmpp.plugins.xep_0300.hash import XEP_0300 + + +register_plugin(XEP_0300) diff --git a/slixmpp/plugins/xep_0300/hash.py b/slixmpp/plugins/xep_0300/hash.py new file mode 100644 index 00000000..43dcb5bd --- /dev/null +++ b/slixmpp/plugins/xep_0300/hash.py @@ -0,0 +1,87 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2017 Emmanuel Gil Peyrot + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +from base64 import b64encode +import hashlib +import logging + +from slixmpp.plugins import BasePlugin +from slixmpp.plugins.xep_0300 import stanza, Hash + + +log = logging.getLogger(__name__) + + +class XEP_0300(BasePlugin): + + name = 'xep_0300' + description = 'XEP-0300: Use of Cryptographic Hash Functions in XMPP' + dependencies = {'xep_0030'} + stanza = stanza + default_config = { + 'block_size': 1024 * 1024, # One MiB + 'prefered': 'sha-256', + 'enable_sha-1': False, + 'enable_sha-256': True, + 'enable_sha-512': True, + 'enable_sha3-256': True, + 'enable_sha3-512': True, + 'enable_BLAKE2b256': True, + 'enable_BLAKE2b512': True, + } + + _hashlib_function = { + 'sha-1': hashlib.sha1, + 'sha-256': hashlib.sha256, + 'sha-512': hashlib.sha512, + 'sha3-256': lambda: hashlib.sha3_256(), + 'sha3-512': lambda: hashlib.sha3_512(), + 'BLAKE2b256': lambda: hashlib.blake2b(digest_size=32), + 'BLAKE2b512': lambda: hashlib.blake2b(digest_size=64), + } + + def plugin_init(self): + namespace = 'urn:xmpp:hash-function-text-names:%s' + self.enabled_hashes = [] + for algo in self._hashlib_function: + if getattr(self, 'enable_' + algo, False): + # XXX: this is a hack for Python 3.5 or below, which + # don’t support sha3 or blake2b… + try: + self._hashlib_function[algo]() + except AttributeError: + log.warn('Algorithm %s unavailable, disabling.', algo) + else: + self.enabled_hashes.append(namespace % algo) + + def session_bind(self, jid): + self.xmpp['xep_0030'].add_feature(Hash.namespace) + + for namespace in self.enabled_hashes: + self.xmpp['xep_0030'].add_feature(namespace) + + def plugin_end(self): + for namespace in self.enabled_hashes: + self.xmpp['xep_0030'].del_feature(namespace) + + self.xmpp['xep_0030'].del_feature(feature=Hash.namespace) + + def compute_hash(self, filename, function=None): + if function is None: + function = self.prefered + h = self._hashlib_function[function]() + with open(filename, 'rb') as f: + while True: + block = f.read(self.block_size) + if not block: + break + h.update(block) + hash_elem = Hash() + hash_elem['algo'] = function + hash_elem['value'] = b64encode(h.digest()) + return hash_elem diff --git a/slixmpp/plugins/xep_0300/stanza.py b/slixmpp/plugins/xep_0300/stanza.py new file mode 100644 index 00000000..f5ab483c --- /dev/null +++ b/slixmpp/plugins/xep_0300/stanza.py @@ -0,0 +1,35 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2017 Emmanuel Gil Peyrot + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.xmlstream import ElementBase + + +class Hash(ElementBase): + name = 'hash' + namespace = 'urn:xmpp:hashes:2' + plugin_attrib = 'hash' + interfaces = {'algo', 'value'} + + allowed_algos = ['sha-1', 'sha-256', 'sha-512', 'sha3-256', 'sha3-512', 'BLAKE2b256', 'BLAKE2b512'] + + def set_algo(self, value): + if value in self.allowed_algos: + self._set_attr('algo', value) + elif value in [None, '']: + self._del_attr('algo') + else: + raise ValueError('Invalid algo: %s' % value) + + def get_value(self): + return self.xml.text + + def set_value(self, value): + self.xml.text = value + + def del_value(self): + self.xml.text = '' diff --git a/slixmpp/plugins/xep_0302.py b/slixmpp/plugins/xep_0302.py index 6092b3e3..ff56e63e 100644 --- a/slixmpp/plugins/xep_0302.py +++ b/slixmpp/plugins/xep_0302.py @@ -13,9 +13,9 @@ 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']) + dependencies = {'xep_0030', 'xep_0115', 'xep_0054', + 'xep_0163', 'xep_0045', 'xep_0085', + 'xep_0184', 'xep_0198'} register_plugin(XEP_0302) diff --git a/slixmpp/plugins/xep_0308/correction.py b/slixmpp/plugins/xep_0308/correction.py index 3802b799..d94f62a4 100644 --- a/slixmpp/plugins/xep_0308/correction.py +++ b/slixmpp/plugins/xep_0308/correction.py @@ -28,7 +28,7 @@ class XEP_0308(BasePlugin): name = 'xep_0308' description = 'XEP-0308: Last Message Correction' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0308/stanza.py b/slixmpp/plugins/xep_0308/stanza.py index eb04d1ad..11e0d52b 100644 --- a/slixmpp/plugins/xep_0308/stanza.py +++ b/slixmpp/plugins/xep_0308/stanza.py @@ -13,4 +13,4 @@ class Replace(ElementBase): name = 'replace' namespace = 'urn:xmpp:message-correct:0' plugin_attrib = 'replace' - interfaces = set(['id']) + interfaces = {'id'} diff --git a/slixmpp/plugins/xep_0313/mam.py b/slixmpp/plugins/xep_0313/mam.py index d1c6b983..37aa49b4 100644 --- a/slixmpp/plugins/xep_0313/mam.py +++ b/slixmpp/plugins/xep_0313/mam.py @@ -29,7 +29,7 @@ class XEP_0313(BasePlugin): name = 'xep_0313' description = 'XEP-0313: Message Archive Management' - dependencies = set(['xep_0030', 'xep_0050', 'xep_0059', 'xep_0297']) + dependencies = {'xep_0030', 'xep_0050', 'xep_0059', 'xep_0297'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0313/stanza.py b/slixmpp/plugins/xep_0313/stanza.py index d7cfa222..3075c48e 100644 --- a/slixmpp/plugins/xep_0313/stanza.py +++ b/slixmpp/plugins/xep_0313/stanza.py @@ -17,8 +17,8 @@ class MAM(ElementBase): name = 'query' namespace = 'urn:xmpp:mam:tmp' plugin_attrib = 'mam' - interfaces = set(['queryid', 'start', 'end', 'with', 'results']) - sub_interfaces = set(['start', 'end', 'with']) + interfaces = {'queryid', 'start', 'end', 'with', 'results'} + sub_interfaces = {'start', 'end', 'with'} def setup(self, xml=None): ElementBase.setup(self, xml) @@ -66,8 +66,8 @@ class Preferences(ElementBase): name = 'prefs' namespace = 'urn:xmpp:mam:tmp' plugin_attrib = 'mam_prefs' - interfaces = set(['default', 'always', 'never']) - sub_interfaces = set(['always', 'never']) + interfaces = {'default', 'always', 'never'} + sub_interfaces = {'always', 'never'} def get_always(self): results = set() @@ -122,7 +122,7 @@ class Result(ElementBase): name = 'result' namespace = 'urn:xmpp:mam:tmp' plugin_attrib = 'mam_result' - interfaces = set(['queryid', 'id']) + interfaces = {'queryid', 'id'} class Archived(ElementBase): @@ -130,10 +130,10 @@ class Archived(ElementBase): namespace = 'urn:xmpp:mam:tmp' plugin_attrib = 'mam_archived' plugin_multi_attrib = 'mam_archives' - interfaces = set(['by', 'id']) + interfaces = {'by', 'id'} def get_by(self): return JID(self._get_attr('by')) - def set_by(self): + def set_by(self, value): return self._set_attr('by', str(value)) diff --git a/slixmpp/plugins/xep_0319/idle.py b/slixmpp/plugins/xep_0319/idle.py index 1fd980a5..65500706 100644 --- a/slixmpp/plugins/xep_0319/idle.py +++ b/slixmpp/plugins/xep_0319/idle.py @@ -19,7 +19,7 @@ from slixmpp.plugins.xep_0319 import stanza class XEP_0319(BasePlugin): name = 'xep_0319' description = 'XEP-0319: Last User Interaction in Presence' - dependencies = set(['xep_0012']) + dependencies = {'xep_0012'} stanza = stanza def plugin_init(self): diff --git a/slixmpp/plugins/xep_0319/stanza.py b/slixmpp/plugins/xep_0319/stanza.py index ea70087b..3fdcd502 100644 --- a/slixmpp/plugins/xep_0319/stanza.py +++ b/slixmpp/plugins/xep_0319/stanza.py @@ -16,7 +16,7 @@ class Idle(ElementBase): name = 'idle' namespace = 'urn:xmpp:idle:1' plugin_attrib = 'idle' - interfaces = set(['since']) + interfaces = {'since'} def get_since(self): timestamp = self._get_attr('since') diff --git a/slixmpp/plugins/xep_0323/sensordata.py b/slixmpp/plugins/xep_0323/sensordata.py index c88deee9..fa340aae 100644 --- a/slixmpp/plugins/xep_0323/sensordata.py +++ b/slixmpp/plugins/xep_0323/sensordata.py @@ -101,7 +101,7 @@ class XEP_0323(BasePlugin): name = 'xep_0323' description = 'XEP-0323 Internet of Things - Sensor Data' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza diff --git a/slixmpp/plugins/xep_0323/stanza/sensordata.py b/slixmpp/plugins/xep_0323/stanza/sensordata.py index aa223a62..c0906cac 100644 --- a/slixmpp/plugins/xep_0323/stanza/sensordata.py +++ b/slixmpp/plugins/xep_0323/stanza/sensordata.py @@ -10,36 +10,40 @@ from slixmpp import Iq, Message from slixmpp.xmlstream import register_stanza_plugin, ElementBase, ET, JID -from re import match +import re class Sensordata(ElementBase): """ Placeholder for the namespace, not used as a stanza """ namespace = 'urn:xmpp:iot:sensordata' name = 'sensordata' plugin_attrib = name - interfaces = set(tuple()) + interfaces = set() class FieldTypes(): """ All field types are optional booleans that default to False """ - field_types = set([ 'momentary','peak','status','computed','identity','historicalSecond','historicalMinute','historicalHour', \ - 'historicalDay','historicalWeek','historicalMonth','historicalQuarter','historicalYear','historicalOther']) + field_types = {'momentary', 'peak', 'status', 'computed', 'identity', + 'historicalSecond', 'historicalMinute', 'historicalHour', + 'historicalDay', 'historicalWeek', 'historicalMonth', + 'historicalQuarter', 'historicalYear', 'historicalOther'} class FieldStatus(): """ All field statuses are optional booleans that default to False """ - field_status = set([ 'missing','automaticEstimate','manualEstimate','manualReadout','automaticReadout','timeOffset','warning','error', \ - 'signed','invoiced','endOfSeries','powerFailure','invoiceConfirmed']) + field_status = {'missing', 'automaticEstimate', 'manualEstimate', + 'manualReadout', 'automaticReadout', 'timeOffset', + 'warning', 'error', 'signed', 'invoiced', 'endOfSeries', + 'powerFailure', 'invoiceConfirmed'} class Request(ElementBase): namespace = 'urn:xmpp:iot:sensordata' name = 'req' plugin_attrib = name - interfaces = set(['seqnr','nodes','fields','serviceToken','deviceToken','userToken','from','to','when','historical','all']) + interfaces = {'seqnr','nodes','fields','serviceToken','deviceToken','userToken','from','to','when','historical','all'} interfaces.update(FieldTypes.field_types) - _flags = set(['serviceToken','deviceToken','userToken','from','to','when','historical','all']) + _flags = {'serviceToken','deviceToken','userToken','from','to','when','historical','all'} _flags.update(FieldTypes.field_types) def __init__(self, xml=None, parent=None): @@ -59,8 +63,8 @@ class Request(ElementBase): xml -- Use an existing XML object for the stanza's values. """ ElementBase.setup(self, xml) - self._nodes = set([node['nodeId'] for node in self['nodes']]) - self._fields = set([field['name'] for field in self['fields']]) + self._nodes = {node['nodeId'] for node in self['nodes']} + self._fields = {field['name'] for field in self['fields']} def _get_flags(self): """ @@ -225,39 +229,39 @@ class RequestNode(ElementBase): namespace = 'urn:xmpp:iot:sensordata' name = 'node' plugin_attrib = name - interfaces = set(['nodeId','sourceId','cacheType']) + interfaces = {'nodeId','sourceId','cacheType'} class RequestField(ElementBase): """ Field element in a request """ namespace = 'urn:xmpp:iot:sensordata' name = 'field' plugin_attrib = name - interfaces = set(['name']) + interfaces = {'name'} class Accepted(ElementBase): namespace = 'urn:xmpp:iot:sensordata' name = 'accepted' plugin_attrib = name - interfaces = set(['seqnr','queued']) + interfaces = {'seqnr','queued'} class Started(ElementBase): namespace = 'urn:xmpp:iot:sensordata' name = 'started' plugin_attrib = name - interfaces = set(['seqnr']) + interfaces = {'seqnr'} class Failure(ElementBase): namespace = 'urn:xmpp:iot:sensordata' name = 'failure' plugin_attrib = name - interfaces = set(['seqnr','done']) + interfaces = {'seqnr','done'} class Error(ElementBase): """ Error element in a request failure """ namespace = 'urn:xmpp:iot:sensordata' name = 'error' plugin_attrib = name - interfaces = set(['nodeId','timestamp','sourceId','cacheType','text']) + interfaces = {'nodeId','timestamp','sourceId','cacheType','text'} def get_text(self): """Return then contents inside the XML tag.""" @@ -281,15 +285,15 @@ class Rejected(ElementBase): namespace = 'urn:xmpp:iot:sensordata' name = 'rejected' plugin_attrib = name - interfaces = set(['seqnr','error']) - sub_interfaces = set(['error']) + interfaces = {'seqnr','error'} + sub_interfaces = {'error'} class Fields(ElementBase): """ Fields element, top level in a response message with data """ namespace = 'urn:xmpp:iot:sensordata' name = 'fields' plugin_attrib = name - interfaces = set(['seqnr','done','nodes']) + interfaces = {'seqnr','done','nodes'} def __init__(self, xml=None, parent=None): ElementBase.__init__(self, xml, parent) @@ -307,7 +311,7 @@ class Fields(ElementBase): xml -- Use an existing XML object for the stanza's values. """ ElementBase.setup(self, xml) - self._nodes = set([node['nodeId'] for node in self['nodes']]) + self._nodes = {node['nodeId'] for node in self['nodes']} def add_node(self, nodeId, sourceId=None, cacheType=None, substanzas=None): @@ -389,7 +393,7 @@ class FieldsNode(ElementBase): namespace = 'urn:xmpp:iot:sensordata' name = 'node' plugin_attrib = name - interfaces = set(['nodeId','sourceId','cacheType','timestamps']) + interfaces = {'nodeId','sourceId','cacheType','timestamps'} def __init__(self, xml=None, parent=None): ElementBase.__init__(self, xml, parent) @@ -407,7 +411,7 @@ class FieldsNode(ElementBase): xml -- Use an existing XML object for the stanza's values. """ ElementBase.setup(self, xml) - self._timestamps = set([ts['value'] for ts in self['timestamps']]) + self._timestamps = {ts['value'] for ts in self['timestamps']} def add_timestamp(self, timestamp, substanzas=None): """ @@ -498,7 +502,7 @@ class Field(ElementBase): namespace = 'urn:xmpp:iot:sensordata' name = 'field' plugin_attrib = name - interfaces = set(['name','module','stringIds']) + interfaces = {'name','module','stringIds'} interfaces.update(FieldTypes.field_types) interfaces.update(FieldStatus.field_status) @@ -554,7 +558,7 @@ class Timestamp(ElementBase): namespace = 'urn:xmpp:iot:sensordata' name = 'timestamp' plugin_attrib = name - interfaces = set(['value','datas']) + interfaces = {'value','datas'} def __init__(self, xml=None, parent=None): ElementBase.__init__(self, xml, parent) @@ -572,7 +576,7 @@ class Timestamp(ElementBase): xml -- Use an existing XML object for the stanza's values. """ ElementBase.setup(self, xml) - self._datas = set([data['name'] for data in self['datas']]) + self._datas = {data['name'] for data in self['datas']} def add_data(self, typename, name, value, module=None, stringIds=None, unit=None, dataType=None, flags=None): """ @@ -668,7 +672,7 @@ class DataNumeric(Field): namespace = 'urn:xmpp:iot:sensordata' name = 'numeric' plugin_attrib = name - interfaces = set(['value', 'unit']) + interfaces = {'value', 'unit'} interfaces.update(Field.interfaces) def _get_typename(self): @@ -681,7 +685,7 @@ class DataString(Field): namespace = 'urn:xmpp:iot:sensordata' name = 'string' plugin_attrib = name - interfaces = set(['value']) + interfaces = {'value'} interfaces.update(Field.interfaces) def _get_typename(self): @@ -695,7 +699,7 @@ class DataBoolean(Field): namespace = 'urn:xmpp:iot:sensordata' name = 'boolean' plugin_attrib = name - interfaces = set(['value']) + interfaces = {'value'} interfaces.update(Field.interfaces) def _get_typename(self): @@ -709,7 +713,7 @@ class DataDateTime(Field): namespace = 'urn:xmpp:iot:sensordata' name = 'dateTime' plugin_attrib = name - interfaces = set(['value']) + interfaces = {'value'} interfaces.update(Field.interfaces) def _get_typename(self): @@ -723,7 +727,7 @@ class DataTimeSpan(Field): namespace = 'urn:xmpp:iot:sensordata' name = 'timeSpan' plugin_attrib = name - interfaces = set(['value']) + interfaces = {'value'} interfaces.update(Field.interfaces) def _get_typename(self): @@ -737,7 +741,7 @@ class DataEnum(Field): namespace = 'urn:xmpp:iot:sensordata' name = 'enum' plugin_attrib = name - interfaces = set(['value', 'dataType']) + interfaces = {'value', 'dataType'} interfaces.update(Field.interfaces) def _get_typename(self): @@ -748,21 +752,21 @@ class Done(ElementBase): namespace = 'urn:xmpp:iot:sensordata' name = 'done' plugin_attrib = name - interfaces = set(['seqnr']) + interfaces = {'seqnr'} class Cancel(ElementBase): """ Cancel element used to signal that a request shall be cancelled """ namespace = 'urn:xmpp:iot:sensordata' name = 'cancel' plugin_attrib = name - interfaces = set(['seqnr']) + interfaces = {'seqnr'} class Cancelled(ElementBase): """ Cancelled element used to signal that cancellation is confirmed """ namespace = 'urn:xmpp:iot:sensordata' name = 'cancelled' plugin_attrib = name - interfaces = set(['seqnr']) + interfaces = {'seqnr'} register_stanza_plugin(Iq, Request) diff --git a/slixmpp/plugins/xep_0325/control.py b/slixmpp/plugins/xep_0325/control.py index 5c1b3003..5960291c 100644 --- a/slixmpp/plugins/xep_0325/control.py +++ b/slixmpp/plugins/xep_0325/control.py @@ -97,7 +97,7 @@ class XEP_0325(BasePlugin): name = 'xep_0325' description = 'XEP-0325 Internet of Things - Control' - dependencies = set(['xep_0030']) + dependencies = {'xep_0030'} stanza = stanza diff --git a/slixmpp/plugins/xep_0325/stanza/control.py b/slixmpp/plugins/xep_0325/stanza/control.py index c47f3a4e..3662ff0c 100644 --- a/slixmpp/plugins/xep_0325/stanza/control.py +++ b/slixmpp/plugins/xep_0325/stanza/control.py @@ -23,7 +23,7 @@ class ControlSet(ElementBase): namespace = 'urn:xmpp:iot:control' name = 'set' plugin_attrib = name - interfaces = set(['nodes','datas']) + interfaces = {'nodes','datas'} def __init__(self, xml=None, parent=None): ElementBase.__init__(self, xml, parent) @@ -42,8 +42,8 @@ class ControlSet(ElementBase): xml -- Use an existing XML object for the stanza's values. """ ElementBase.setup(self, xml) - self._nodes = set([node['nodeId'] for node in self['nodes']]) - self._datas = set([data['name'] for data in self['datas']]) + self._nodes = {node['nodeId'] for node in self['nodes']} + self._datas = {data['name'] for data in self['datas']} def add_node(self, nodeId, sourceId=None, cacheType=None): """ @@ -207,14 +207,14 @@ class RequestNode(ElementBase): namespace = 'urn:xmpp:iot:control' name = 'node' plugin_attrib = name - interfaces = set(['nodeId','sourceId','cacheType']) + interfaces = {'nodeId','sourceId','cacheType'} class ControlSetResponse(ElementBase): namespace = 'urn:xmpp:iot:control' name = 'setResponse' plugin_attrib = name - interfaces = set(['responseCode']) + interfaces = {'responseCode'} def __init__(self, xml=None, parent=None): ElementBase.__init__(self, xml, parent) @@ -233,8 +233,8 @@ class ControlSetResponse(ElementBase): xml -- Use an existing XML object for the stanza's values. """ ElementBase.setup(self, xml) - self._nodes = set([node['nodeId'] for node in self['nodes']]) - self._datas = set([data['name'] for data in self['datas']]) + self._nodes = {node['nodeId'] for node in self['nodes']} + self._datas = {data['name'] for data in self['datas']} def add_node(self, nodeId, sourceId=None, cacheType=None): """ @@ -370,7 +370,7 @@ class Error(ElementBase): namespace = 'urn:xmpp:iot:control' name = 'error' plugin_attrib = name - interfaces = set(['var','text']) + interfaces = {'var','text'} def get_text(self): """Return then contents inside the XML tag.""" @@ -398,7 +398,7 @@ class ResponseParameter(ElementBase): namespace = 'urn:xmpp:iot:control' name = 'parameter' plugin_attrib = name - interfaces = set(['name']) + interfaces = {'name'} class BaseParameter(ElementBase): @@ -419,7 +419,7 @@ class BaseParameter(ElementBase): namespace = 'urn:xmpp:iot:control' name = 'baseParameter' plugin_attrib = name - interfaces = set(['name','value']) + interfaces = {'name','value'} def _get_typename(self): return self.name diff --git a/slixmpp/plugins/xep_0332/http.py b/slixmpp/plugins/xep_0332/http.py index 7ad14dc8..bebb0e69 100644 --- a/slixmpp/plugins/xep_0332/http.py +++ b/slixmpp/plugins/xep_0332/http.py @@ -36,11 +36,11 @@ class XEP_0332(BasePlugin): #: xep_0047 not included. #: xep_0001, 0137 and 0166 are missing - dependencies = set(['xep_0030', 'xep_0131']) + dependencies = {'xep_0030', 'xep_0131'} #: TODO: Do we really need to mention the supported_headers?! default_config = { - 'supported_headers': set([ + 'supported_headers': { 'Content-Length', 'Transfer-Encoding', 'DateTime', 'Accept-Charset', 'Location', 'Content-ID', 'Description', 'Content-Language', 'Content-Transfer-Encoding', 'Timestamp', @@ -48,7 +48,7 @@ class XEP_0332(BasePlugin): 'WWW-Authenticate', 'Accept-Encoding', 'Server', 'Error-Info', 'Identifier', 'Content-Location', 'Content-Encoding', 'Distribute', 'Accept', 'Proxy-Authenticate', 'ETag', 'Expect', 'Content-Type' - ]) + } } def plugin_init(self): diff --git a/slixmpp/plugins/xep_0332/stanza/data.py b/slixmpp/plugins/xep_0332/stanza/data.py index a19c94f5..92e3d3af 100644 --- a/slixmpp/plugins/xep_0332/stanza/data.py +++ b/slixmpp/plugins/xep_0332/stanza/data.py @@ -17,7 +17,7 @@ class HTTPData(ElementBase): """ name = 'data' namespace = 'urn:xmpp:http' - interfaces = set(['data']) + interfaces = {'data'} plugin_attrib = 'data' is_extension = True diff --git a/slixmpp/plugins/xep_0332/stanza/request.py b/slixmpp/plugins/xep_0332/stanza/request.py index e3e46361..1d4aa5b1 100644 --- a/slixmpp/plugins/xep_0332/stanza/request.py +++ b/slixmpp/plugins/xep_0332/stanza/request.py @@ -49,7 +49,7 @@ class HTTPRequest(ElementBase): name = 'request' namespace = 'urn:xmpp:http' - interfaces = set(['method', 'resource', 'version']) + interfaces = {'method', 'resource', 'version'} plugin_attrib = 'http-req' def get_method(self): diff --git a/slixmpp/plugins/xep_0332/stanza/response.py b/slixmpp/plugins/xep_0332/stanza/response.py index a0b8fe34..8f58f0c2 100644 --- a/slixmpp/plugins/xep_0332/stanza/response.py +++ b/slixmpp/plugins/xep_0332/stanza/response.py @@ -46,7 +46,7 @@ class HTTPResponse(ElementBase): name = 'response' namespace = 'urn:xmpp:http' - interfaces = set(['code', 'message', 'version']) + interfaces = {'code', 'message', 'version'} plugin_attrib = 'http-resp' def get_code(self): diff --git a/slixmpp/plugins/xep_0333/hints.py b/slixmpp/plugins/xep_0333/hints.py index 932bf6d5..5a3d3f9a 100644 --- a/slixmpp/plugins/xep_0333/hints.py +++ b/slixmpp/plugins/xep_0333/hints.py @@ -11,6 +11,8 @@ import logging from slixmpp import Message from slixmpp.plugins import BasePlugin from slixmpp.xmlstream import register_stanza_plugin +from slixmpp.xmlstream.handler import Callback +from slixmpp.xmlstream.matcher import StanzaPath from slixmpp.plugins.xep_0333 import stanza, Markable, Received, Displayed, Acknowledged log = logging.getLogger(__name__) diff --git a/slixmpp/plugins/xep_0380/__init__.py b/slixmpp/plugins/xep_0380/__init__.py new file mode 100644 index 00000000..fec9f60f --- /dev/null +++ b/slixmpp/plugins/xep_0380/__init__.py @@ -0,0 +1,15 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2016 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.plugins.base import register_plugin + +from slixmpp.plugins.xep_0380.stanza import Encryption +from slixmpp.plugins.xep_0380.eme import XEP_0380 + + +register_plugin(XEP_0380) diff --git a/slixmpp/plugins/xep_0380/eme.py b/slixmpp/plugins/xep_0380/eme.py new file mode 100644 index 00000000..abdd3e88 --- /dev/null +++ b/slixmpp/plugins/xep_0380/eme.py @@ -0,0 +1,69 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2016 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +import logging + +import slixmpp +from slixmpp.stanza import Message +from slixmpp.xmlstream.handler import Callback +from slixmpp.xmlstream.matcher import StanzaPath +from slixmpp.xmlstream import register_stanza_plugin, ElementBase, ET +from slixmpp.plugins import BasePlugin +from slixmpp.plugins.xep_0380 import stanza, Encryption + + +log = logging.getLogger(__name__) + + +class XEP_0380(BasePlugin): + + """ + XEP-0380: Explicit Message Encryption + """ + + name = 'xep_0380' + description = 'XEP-0380: Explicit Message Encryption' + dependencies = {'xep_0030'} + default_config = { + 'template': 'This message is encrypted with {name} ({namespace})', + } + + mechanisms = { + 'jabber:x:encrypted': 'Legacy OpenPGP', + 'urn:xmpp:ox:0': 'OpenPGP for XMPP', + 'urn:xmpp:otr:0': 'OTR', + 'eu.siacs.conversations.axolotl': 'Legacy OMEMO', + 'urn:xmpp:omemo:0': 'OMEMO', + } + + def plugin_init(self): + self.xmpp.register_handler( + Callback('Explicit Message Encryption', + StanzaPath('message/eme'), + self._handle_eme)) + + register_stanza_plugin(Message, Encryption) + + def plugin_end(self): + self.xmpp.remove_handler('Chat State') + + def session_bind(self, jid): + self.xmpp.plugin['xep_0030'].add_feature(Encryption.namespace) + + def has_eme(self, msg): + return msg.xml.find('{%s}encryption' % Encryption.namespace) is not None + + def replace_body_with_eme(self, msg): + eme = msg['eme'] + namespace = eme['namespace'] + name = self.mechanisms[namespace] if namespace in self.mechanisms else eme['name'] + body = self.config['template'].format(name=name, namespace=namespace) + msg['body'] = body + + def _handle_eme(self, msg): + self.xmpp.event('message_encryption', msg) diff --git a/slixmpp/plugins/xep_0380/stanza.py b/slixmpp/plugins/xep_0380/stanza.py new file mode 100644 index 00000000..7dd678b1 --- /dev/null +++ b/slixmpp/plugins/xep_0380/stanza.py @@ -0,0 +1,16 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2016 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.xmlstream import ElementBase + + +class Encryption(ElementBase): + name = 'encryption' + namespace = 'urn:xmpp:eme:0' + plugin_attrib = 'eme' + interfaces = {'namespace', 'name'} diff --git a/slixmpp/stanza/atom.py b/slixmpp/stanza/atom.py index ccded724..8dde00de 100644 --- a/slixmpp/stanza/atom.py +++ b/slixmpp/stanza/atom.py @@ -21,9 +21,8 @@ class AtomEntry(ElementBase): namespace = 'http://www.w3.org/2005/Atom' name = 'entry' plugin_attrib = 'entry' - interfaces = set(('title', 'summary', 'id', 'published', 'updated')) - sub_interfaces = set(('title', 'summary', 'id', 'published', - 'updated')) + interfaces = {'title', 'summary', 'id', 'published', 'updated'} + sub_interfaces = {'title', 'summary', 'id', 'published', 'updated'} class AtomAuthor(ElementBase): @@ -37,7 +36,7 @@ class AtomAuthor(ElementBase): name = 'author' plugin_attrib = 'author' - interfaces = set(('name', 'uri')) - sub_interfaces = set(('name', 'uri')) + interfaces = {'name', 'uri'} + sub_interfaces = {'name', 'uri'} register_stanza_plugin(AtomEntry, AtomAuthor) diff --git a/slixmpp/stanza/error.py b/slixmpp/stanza/error.py index 67f736c0..132ffc4d 100644 --- a/slixmpp/stanza/error.py +++ b/slixmpp/stanza/error.py @@ -51,22 +51,22 @@ class Error(ElementBase): namespace = 'jabber:client' name = 'error' plugin_attrib = 'error' - interfaces = set(('code', 'condition', 'text', 'type', - 'gone', 'redirect', 'by')) - sub_interfaces = set(('text',)) + interfaces = {'code', 'condition', 'text', 'type', + 'gone', 'redirect', 'by'} + sub_interfaces = {'text'} plugin_attrib_map = {} plugin_tag_map = {} - conditions = set(('bad-request', 'conflict', 'feature-not-implemented', - 'forbidden', 'gone', 'internal-server-error', - 'item-not-found', 'jid-malformed', 'not-acceptable', - 'not-allowed', 'not-authorized', 'payment-required', - 'recipient-unavailable', 'redirect', - 'registration-required', 'remote-server-not-found', - 'remote-server-timeout', 'resource-constraint', - 'service-unavailable', 'subscription-required', - 'undefined-condition', 'unexpected-request')) + conditions = {'bad-request', 'conflict', 'feature-not-implemented', + 'forbidden', 'gone', 'internal-server-error', + 'item-not-found', 'jid-malformed', 'not-acceptable', + 'not-allowed', 'not-authorized', 'payment-required', + 'recipient-unavailable', 'redirect', + 'registration-required', 'remote-server-not-found', + 'remote-server-timeout', 'resource-constraint', + 'service-unavailable', 'subscription-required', + 'undefined-condition', 'unexpected-request'} condition_ns = 'urn:ietf:params:xml:ns:xmpp-stanzas' - types = set(('cancel', 'continue', 'modify', 'auth', 'wait')) + types = {'cancel', 'continue', 'modify', 'auth', 'wait'} def setup(self, xml=None): """ diff --git a/slixmpp/stanza/iq.py b/slixmpp/stanza/iq.py index a64dfa7f..af7e3109 100644 --- a/slixmpp/stanza/iq.py +++ b/slixmpp/stanza/iq.py @@ -57,8 +57,8 @@ class Iq(RootStanza): namespace = 'jabber:client' name = 'iq' - interfaces = set(('type', 'to', 'from', 'id', 'query')) - types = set(('get', 'result', 'set', 'error')) + interfaces = {'type', 'to', 'from', 'id', 'query'} + types = {'get', 'result', 'set', 'error'} plugin_attrib = name def __init__(self, *args, **kwargs): diff --git a/slixmpp/stanza/message.py b/slixmpp/stanza/message.py index cbb170fa..f5813eaf 100644 --- a/slixmpp/stanza/message.py +++ b/slixmpp/stanza/message.py @@ -47,11 +47,11 @@ class Message(RootStanza): name = 'message' namespace = 'jabber:client' plugin_attrib = name - interfaces = set(['type', 'to', 'from', 'id', 'body', 'subject', - 'thread', 'parent_thread', 'mucroom', 'mucnick']) - sub_interfaces = set(['body', 'subject', 'thread']) + interfaces = {'type', 'to', 'from', 'id', 'body', 'subject', 'thread', + 'parent_thread', 'mucroom', 'mucnick'} + sub_interfaces = {'body', 'subject', 'thread'} lang_interfaces = sub_interfaces - types = set(['normal', 'chat', 'headline', 'error', 'groupchat']) + types = {'normal', 'chat', 'headline', 'error', 'groupchat'} def __init__(self, *args, **kwargs): """ diff --git a/slixmpp/stanza/presence.py b/slixmpp/stanza/presence.py index 517e73c1..614cd331 100644 --- a/slixmpp/stanza/presence.py +++ b/slixmpp/stanza/presence.py @@ -56,14 +56,13 @@ class Presence(RootStanza): name = 'presence' namespace = 'jabber:client' plugin_attrib = name - interfaces = set(['type', 'to', 'from', 'id', 'show', - 'status', 'priority']) - sub_interfaces = set(['show', 'status', 'priority']) - lang_interfaces = set(['status']) - - types = set(['available', 'unavailable', 'error', 'probe', 'subscribe', - 'subscribed', 'unsubscribe', 'unsubscribed']) - showtypes = set(['dnd', 'chat', 'xa', 'away']) + interfaces = {'type', 'to', 'from', 'id', 'show', 'status', 'priority'} + sub_interfaces = {'show', 'status', 'priority'} + lang_interfaces = {'status'} + + types = {'available', 'unavailable', 'error', 'probe', 'subscribe', + 'subscribed', 'unsubscribe', 'unsubscribed'} + showtypes = {'dnd', 'chat', 'xa', 'away'} def __init__(self, *args, **kwargs): """ diff --git a/slixmpp/stanza/roster.py b/slixmpp/stanza/roster.py index c017c33f..11d38cc2 100644 --- a/slixmpp/stanza/roster.py +++ b/slixmpp/stanza/roster.py @@ -36,7 +36,7 @@ class Roster(ElementBase): namespace = 'jabber:iq:roster' name = 'query' plugin_attrib = 'roster' - interfaces = set(('items', 'ver')) + interfaces = {'items', 'ver'} def get_ver(self): """ @@ -118,8 +118,7 @@ class RosterItem(ElementBase): namespace = 'jabber:iq:roster' name = 'item' plugin_attrib = 'item' - interfaces = set(('jid', 'name', 'subscription', 'ask', - 'approved', 'groups')) + interfaces = {'jid', 'name', 'subscription', 'ask', 'approved', 'groups'} def get_jid(self): return JID(self._get_attr('jid', '')) diff --git a/slixmpp/stanza/stream_error.py b/slixmpp/stanza/stream_error.py index d8b8bb5a..2aa70173 100644 --- a/slixmpp/stanza/stream_error.py +++ b/slixmpp/stanza/stream_error.py @@ -54,8 +54,8 @@ class StreamError(Error, StanzaBase): """ namespace = 'http://etherx.jabber.org/streams' - interfaces = set(('condition', 'text', 'see_other_host')) - conditions = set(( + interfaces = {'condition', 'text', 'see_other_host'} + conditions = { 'bad-format', 'bad-namespace-prefix', 'conflict', 'connection-timeout', 'host-gone', 'host-unknown', 'improper-addressing', 'internal-server-error', 'invalid-from', @@ -64,7 +64,7 @@ class StreamError(Error, StanzaBase): 'reset', 'resource-constraint', 'restricted-xml', 'see-other-host', 'system-shutdown', 'undefined-condition', 'unsupported-encoding', 'unsupported-feature', 'unsupported-stanza-type', - 'unsupported-version')) + 'unsupported-version'} condition_ns = 'urn:ietf:params:xml:ns:xmpp-streams' def get_see_other_host(self): diff --git a/slixmpp/stanza/stream_features.py b/slixmpp/stanza/stream_features.py index 05788771..70d0ccca 100644 --- a/slixmpp/stanza/stream_features.py +++ b/slixmpp/stanza/stream_features.py @@ -17,7 +17,7 @@ class StreamFeatures(StanzaBase): name = 'features' namespace = 'http://etherx.jabber.org/streams' - interfaces = set(('features', 'required', 'optional')) + interfaces = {'features', 'required', 'optional'} sub_interfaces = interfaces plugin_tag_map = {} plugin_attrib_map = {} diff --git a/slixmpp/util/sasl/client.py b/slixmpp/util/sasl/client.py index d5daf4be..745eca20 100644 --- a/slixmpp/util/sasl/client.py +++ b/slixmpp/util/sasl/client.py @@ -75,7 +75,7 @@ def sasl_mech(score): MECH_SEC_SCORES[mech.name] = mech.score if mech.channel_binding: MECHANISMS[mech.name + '-PLUS'] = mech - MECH_SEC_SCORES[name] = mech.score + 10 + MECH_SEC_SCORES[mech.name] = mech.score + 10 return mech return register diff --git a/slixmpp/util/sasl/mechanisms.py b/slixmpp/util/sasl/mechanisms.py index de0203c0..36b2795c 100644 --- a/slixmpp/util/sasl/mechanisms.py +++ b/slixmpp/util/sasl/mechanisms.py @@ -39,7 +39,7 @@ class ANONYMOUS(Mech): class LOGIN(Mech): name = 'LOGIN' - required_credentials = set(['username', 'password']) + required_credentials = {'username', 'password'} def setup(self, name): self.step = 0 @@ -59,9 +59,9 @@ class LOGIN(Mech): class PLAIN(Mech): name = 'PLAIN' - required_credentials = set(['username', 'password']) - optional_credentials = set(['authzid']) - security = set(['encrypted', 'encrypted_plain', 'unencrypted_plain']) + required_credentials = {'username', 'password'} + optional_credentials = {'authzid'} + security = {'encrypted', 'encrypted_plain', 'unencrypted_plain'} def setup(self, name): if not self.security_settings['encrypted']: @@ -82,7 +82,7 @@ class PLAIN(Mech): class EXTERNAL(Mech): name = 'EXTERNAL' - optional_credentials = set(['authzid']) + optional_credentials = {'authzid'} def process(self, challenge=b''): return self.credentials['authzid'] @@ -92,7 +92,7 @@ class EXTERNAL(Mech): class X_FACEBOOK_PLATFORM(Mech): name = 'X-FACEBOOK-PLATFORM' - required_credentials = set(['api_key', 'access_token']) + required_credentials = {'api_key', 'access_token'} def process(self, challenge=b''): if challenge: @@ -119,7 +119,7 @@ class X_FACEBOOK_PLATFORM(Mech): class X_MESSENGER_OAUTH2(Mech): name = 'X-MESSENGER-OAUTH2' - required_credentials = set(['access_token']) + required_credentials = {'access_token'} def process(self, challenge=b''): return self.credentials['access_token'] @@ -129,7 +129,7 @@ class X_MESSENGER_OAUTH2(Mech): class X_OAUTH2(Mech): name = 'X-OAUTH2' - required_credentials = set(['username', 'access_token']) + required_credentials = {'username', 'access_token'} def process(self, challenge=b''): return b'\x00' + self.credentials['username'] + \ @@ -140,7 +140,7 @@ class X_OAUTH2(Mech): class X_GOOGLE_TOKEN(Mech): name = 'X-GOOGLE-TOKEN' - required_credentials = set(['email', 'access_token']) + required_credentials = {'email', 'access_token'} def process(self, challenge=b''): email = self.credentials['email'] @@ -153,8 +153,8 @@ class CRAM(Mech): name = 'CRAM' use_hashes = True - required_credentials = set(['username', 'password']) - security = set(['encrypted', 'unencrypted_cram']) + required_credentials = {'username', 'password'} + security = {'encrypted', 'unencrypted_cram'} def setup(self, name): self.hash_name = name[5:] @@ -184,9 +184,9 @@ class SCRAM(Mech): name = 'SCRAM' use_hashes = True channel_binding = True - required_credentials = set(['username', 'password']) - optional_credentials = set(['authzid', 'channel_binding']) - security = set(['encrypted', 'unencrypted_scram']) + required_credentials = {'username', 'password'} + optional_credentials = {'authzid', 'channel_binding'} + security = {'encrypted', 'unencrypted_scram'} def setup(self, name): self.use_channel_binding = False @@ -291,8 +291,7 @@ class SCRAM(Mech): cbind_input = self.gs2_header + cbind_data channel_binding = b'c=' + b64encode(cbind_input).replace(b'\n', b'') - client_final_message_without_proof = channel_binding + b',' + \ - b'r=' + nonce + client_final_message_without_proof = channel_binding + b',r=' + nonce salted_password = self.Hi(self.credentials['password'], salt, @@ -334,9 +333,9 @@ class DIGEST(Mech): name = 'DIGEST' use_hashes = True - required_credentials = set(['username', 'password', 'realm', 'service', 'host']) - optional_credentials = set(['authzid', 'service-name']) - security = set(['encrypted', 'unencrypted_digest']) + required_credentials = {'username', 'password', 'realm', 'service', 'host'} + optional_credentials = {'authzid', 'service-name'} + security = {'encrypted', 'unencrypted_digest'} def setup(self, name): self.hash_name = name[7:] @@ -511,8 +510,8 @@ else: class GSSAPI(Mech): name = 'GSSAPI' - required_credentials = set(['username', 'service-name']) - optional_credentials = set(['authzid']) + required_credentials = {'username', 'service-name'} + optional_credentials = {'authzid'} def setup(self, name): authzid = self.credentials['authzid'] diff --git a/slixmpp/util/stringprep_profiles.py b/slixmpp/util/stringprep_profiles.py index 5fb0b4b7..8ba3842f 100644 --- a/slixmpp/util/stringprep_profiles.py +++ b/slixmpp/util/stringprep_profiles.py @@ -146,6 +146,7 @@ def create(nfkc=True, bidi=True, mappings=None, if bidi: check_bidi(data) if query and unassigned: - check_unassigned(data, unassigned) + #check_unassigned(data, unassigned) + raise StringPrepError('Query profile with unassigned data is unimplemented.') return data return profile diff --git a/slixmpp/version.py b/slixmpp/version.py index 2dd4fcff..ef9cc605 100644 --- a/slixmpp/version.py +++ b/slixmpp/version.py @@ -9,5 +9,5 @@ # We don't want to have to import the entire library # just to get the version info for setup.py -__version__ = '1.2.1' -__version_info__ = (1, 2, 1) +__version__ = '1.2.4' +__version_info__ = (1, 2, 4) diff --git a/slixmpp/xmlstream/cert.py b/slixmpp/xmlstream/cert.py index d357b326..28ef585a 100644 --- a/slixmpp/xmlstream/cert.py +++ b/slixmpp/xmlstream/cert.py @@ -76,7 +76,7 @@ def extract_names(raw_cert): name_type = name.getName() if name_type == 'dNSName': results['DNS'].add(decode_str(name.getComponent())) - if name_type == 'uniformResourceIdentifier': + elif name_type == 'uniformResourceIdentifier': value = decode_str(name.getComponent()) if value.startswith('xmpp:'): results['URI'].add(value[5:]) diff --git a/slixmpp/xmlstream/stanzabase.py b/slixmpp/xmlstream/stanzabase.py index e7ffddc8..605dbb61 100644 --- a/slixmpp/xmlstream/stanzabase.py +++ b/slixmpp/xmlstream/stanzabase.py @@ -147,8 +147,8 @@ def multifactory(stanza, plugin_attrib): Multi.is_extension = True Multi.plugin_attrib = plugin_attrib Multi._multistanza = stanza - Multi.interfaces = set([plugin_attrib]) - Multi.lang_interfaces = set([plugin_attrib]) + Multi.interfaces = {plugin_attrib} + Multi.lang_interfaces = {plugin_attrib} setattr(Multi, "get_%s" % plugin_attrib, get_multi) setattr(Multi, "set_%s" % plugin_attrib, set_multi) setattr(Multi, "del_%s" % plugin_attrib, del_multi) @@ -212,8 +212,8 @@ class ElementBase(object): >>> class Message(ElementBase): ... name = "message" ... namespace = "jabber:client" - ... interfaces = set(('to', 'from', 'type', 'body')) - ... sub_interfaces = set(('body',)) + ... interfaces = {'to', 'from', 'type', 'body'} + ... sub_interfaces = {'body'} The resulting Message stanza's contents may be accessed as so:: @@ -239,7 +239,7 @@ class ElementBase(object): >>> class MessagePlugin(ElementBase): ... name = "custom_plugin" ... namespace = "custom" - ... interfaces = set(('useful_thing', 'custom')) + ... interfaces = {'useful_thing', 'custom'} ... plugin_attrib = "custom" The plugin stanza class must be associated with its intended @@ -311,7 +311,7 @@ class ElementBase(object): #: manipulating the underlying XML object. This set may be augmented #: with the :attr:`plugin_attrib` value of any registered #: stanza plugins. - interfaces = set(('type', 'to', 'from', 'id', 'payload')) + interfaces = {'type', 'to', 'from', 'id', 'payload'} #: A subset of :attr:`interfaces` which maps interfaces to direct #: subelements of the underlying XML object. Using this set, the text @@ -1385,10 +1385,10 @@ class StanzaBase(ElementBase): #: There is a small set of attributes which apply to all XMPP stanzas: #: the stanza type, the to and from JIDs, the stanza ID, and, especially #: in the case of an Iq stanza, a payload. - interfaces = set(('type', 'to', 'from', 'id', 'payload')) + interfaces = {'type', 'to', 'from', 'id', 'payload'} #: A basic set of allowed values for the ``'type'`` interface. - types = set(('get', 'set', 'error', None, 'unavailable', 'normal', 'chat')) + types = {'get', 'set', 'error', None, 'unavailable', 'normal', 'chat'} def __init__(self, stream=None, xml=None, stype=None, sto=None, sfrom=None, sid=None, parent=None): diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index 72d2651c..704a34f1 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -19,7 +19,7 @@ import ssl import weakref import uuid -import xml.etree.ElementTree +import xml.etree.ElementTree as ET from slixmpp.xmlstream.asyncio import asyncio from slixmpp.xmlstream import tostring, highlight @@ -289,7 +289,8 @@ class XMLStream(asyncio.BaseProtocol): record = yield from self.pick_dns_answer(self.default_domain) if record is not None: - host, address, port = record + host, address, dns_port = record + port = dns_port if dns_port else self.address[1] self.address = (address, port) self._service_name = host else: @@ -339,7 +340,7 @@ class XMLStream(asyncio.BaseProtocol): """ self.xml_depth = 0 self.xml_root = None - self.parser = xml.etree.ElementTree.XMLPullParser(("start", "end")) + self.parser = ET.XMLPullParser(("start", "end")) def connection_made(self, transport): """Called when the TCP connection has been established with the server @@ -358,33 +359,51 @@ class XMLStream(asyncio.BaseProtocol): event. This could trigger one or more event (a stanza is received, the stream is opened, etc). """ + if self.parser is None: + log.warning('Received data before the connection is established: %r', + data) + return self.parser.feed(data) - for event, xml in self.parser.read_events(): - if event == 'start': - if self.xml_depth == 0: - # We have received the start of the root element. - self.xml_root = xml - log.debug('[33;1mRECV[0m: %s', highlight(tostring(self.xml_root, xmlns=self.default_ns, - stream=self, - top_level=True, - open_only=True))) - self.start_stream_handler(self.xml_root) - self.xml_depth += 1 - if event == 'end': - self.xml_depth -= 1 - if self.xml_depth == 0: - # The stream's root element has closed, - # terminating the stream. - log.debug("End of stream received") - self.abort() - elif self.xml_depth == 1: - # A stanza is an XML element that is a direct child of - # the root element, hence the check of depth == 1 - self._spawn_event(xml) - if self.xml_root is not None: - # Keep the root element empty of children to - # save on memory use. - self.xml_root.clear() + try: + for event, xml in self.parser.read_events(): + if event == 'start': + if self.xml_depth == 0: + # We have received the start of the root element. + self.xml_root = xml + log.debug('[33;1mRECV[0m: %s', + highlight(tostring(self.xml_root, + xmlns=self.default_ns, + stream=self, + top_level=True, + open_only=True))) + self.start_stream_handler(self.xml_root) + self.xml_depth += 1 + if event == 'end': + self.xml_depth -= 1 + if self.xml_depth == 0: + # The stream's root element has closed, + # terminating the stream. + log.debug("End of stream received") + self.abort() + elif self.xml_depth == 1: + # A stanza is an XML element that is a direct child of + # the root element, hence the check of depth == 1 + self._spawn_event(xml) + if self.xml_root is not None: + # Keep the root element empty of children to + # save on memory use. + self.xml_root.clear() + except ET.ParseError: + log.error('Parse error: %r', data) + + # Due to cyclic dependencies, this can’t be imported at the module + # level. + from slixmpp.stanza.stream_error import StreamError + error = StreamError() + error['condition'] = 'not-well-formed' + error['text'] = 'Server sent: %r' % data + self.send(error) + self.disconnect() def is_connected(self): return self.transport is not None |