diff options
author | Lance Stout <lancestout@gmail.com> | 2012-10-15 22:27:30 -0700 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2012-10-15 22:27:30 -0700 |
commit | 77f2a339e1626501a1df388050f09342d7bbcd1d (patch) | |
tree | 7ea3d3889628bd2509797a7069de0560a2c6252c /sleekxmpp/plugins | |
parent | 7c485c6a8b25b97c7faa4abda6e82200bd09bcae (diff) | |
parent | 4190027a787f878b4ea07ddd24883bb9d1a94d6e (diff) | |
download | slixmpp-77f2a339e1626501a1df388050f09342d7bbcd1d.tar.gz slixmpp-77f2a339e1626501a1df388050f09342d7bbcd1d.tar.bz2 slixmpp-77f2a339e1626501a1df388050f09342d7bbcd1d.tar.xz slixmpp-77f2a339e1626501a1df388050f09342d7bbcd1d.zip |
Merge branch 'master' into develop
Diffstat (limited to 'sleekxmpp/plugins')
-rw-r--r-- | sleekxmpp/plugins/xep_0054/stanza.py | 1 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0078/legacyauth.py | 29 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0084/avatar.py | 2 |
3 files changed, 23 insertions, 9 deletions
diff --git a/sleekxmpp/plugins/xep_0054/stanza.py b/sleekxmpp/plugins/xep_0054/stanza.py index 512e1dd8..72da0b51 100644 --- a/sleekxmpp/plugins/xep_0054/stanza.py +++ b/sleekxmpp/plugins/xep_0054/stanza.py @@ -541,6 +541,7 @@ register_stanza_plugin(VCardTemp, Logo, iterable=True) register_stanza_plugin(VCardTemp, Mailer, iterable=True) register_stanza_plugin(VCardTemp, Note, iterable=True) register_stanza_plugin(VCardTemp, Nickname, iterable=True) +register_stanza_plugin(VCardTemp, Org, iterable=True) register_stanza_plugin(VCardTemp, Photo, iterable=True) register_stanza_plugin(VCardTemp, ProdID, iterable=True) register_stanza_plugin(VCardTemp, Rev, iterable=True) diff --git a/sleekxmpp/plugins/xep_0078/legacyauth.py b/sleekxmpp/plugins/xep_0078/legacyauth.py index 5c4045d8..be9fe3c5 100644 --- a/sleekxmpp/plugins/xep_0078/legacyauth.py +++ b/sleekxmpp/plugins/xep_0078/legacyauth.py @@ -44,16 +44,27 @@ class XEP_0078(BasePlugin): restart=False, order=self.order) + self.xmpp.add_event_handler('legacy_protocol', + self._handle_legacy_protocol) + register_stanza_plugin(Iq, stanza.IqAuth) register_stanza_plugin(StreamFeatures, stanza.AuthFeature) def plugin_end(self): + self.xmpp.del_event_handler('legacy_protocol', + self._handle_legacy_protocol) self.xmpp.unregister_feature('auth', self.order) def _handle_auth(self, features): # If we can or have already authenticated with SASL, do nothing. if 'mechanisms' in features['features']: return False + return self.authenticate() + + def _handle_legacy_protocol(self, event): + self.authenticate() + + def authenticate(self): if self.xmpp.authenticated: return False @@ -62,13 +73,13 @@ class XEP_0078(BasePlugin): # Step 1: Request the auth form iq = self.xmpp.Iq() iq['type'] = 'get' - iq['to'] = self.xmpp.boundjid.host - iq['auth']['username'] = self.xmpp.boundjid.user + iq['to'] = self.xmpp.requested_jid.host + iq['auth']['username'] = self.xmpp.requested_jid.user try: resp = iq.send(now=True) - except IqError: - log.info("Authentication failed: %s", resp['error']['condition']) + except IqError as err: + log.info("Authentication failed: %s", err.iq['error']['condition']) self.xmpp.event('failed_auth', direct=True) self.xmpp.disconnect() return True @@ -81,11 +92,11 @@ class XEP_0078(BasePlugin): # Step 2: Fill out auth form for either password or digest auth iq = self.xmpp.Iq() iq['type'] = 'set' - iq['auth']['username'] = self.xmpp.boundjid.user + iq['auth']['username'] = self.xmpp.requested_jid.user # A resource is required, so create a random one if necessary - if self.xmpp.boundjid.resource: - iq['auth']['resource'] = self.xmpp.boundjid.resource + if self.xmpp.requested_jid.resource: + iq['auth']['resource'] = self.xmpp.requested_jid.resource else: iq['auth']['resource'] = '%s' % random.random() @@ -109,12 +120,12 @@ class XEP_0078(BasePlugin): result = iq.send(now=True) except IqError as err: log.info("Authentication failed") - self.xmpp.disconnect() self.xmpp.event("failed_auth", direct=True) + self.xmpp.disconnect() except IqTimeout: log.info("Authentication failed") - self.xmpp.disconnect() self.xmpp.event("failed_auth", direct=True) + self.xmpp.disconnect() self.xmpp.features.add('auth') diff --git a/sleekxmpp/plugins/xep_0084/avatar.py b/sleekxmpp/plugins/xep_0084/avatar.py index 03711871..2454afc7 100644 --- a/sleekxmpp/plugins/xep_0084/avatar.py +++ b/sleekxmpp/plugins/xep_0084/avatar.py @@ -69,6 +69,8 @@ class XEP_0084(BasePlugin): metadata = MetaData() if items is None: items = [] + if not isinstance(items, (list, set)): + items = [items] for info in items: metadata.add_info(info['id'], info['type'], info['bytes'], height=info.get('height', ''), |