diff options
author | Lance Stout <lancestout@gmail.com> | 2012-07-24 20:01:18 -0700 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2012-07-24 20:01:18 -0700 |
commit | c42f1ad4c79863261977a9c5ea3b33be0b51b946 (patch) | |
tree | 8eee86ddb082f51dea0866f16146bcd1f4f13c1f /sleekxmpp/plugins | |
parent | a3ec1af2053bc0be4864ae290e6e5fc39f3fd5fe (diff) | |
parent | 9d8de7fc15afc39a666d2ac16b62a068dfc55112 (diff) | |
download | slixmpp-c42f1ad4c79863261977a9c5ea3b33be0b51b946.tar.gz slixmpp-c42f1ad4c79863261977a9c5ea3b33be0b51b946.tar.bz2 slixmpp-c42f1ad4c79863261977a9c5ea3b33be0b51b946.tar.xz slixmpp-c42f1ad4c79863261977a9c5ea3b33be0b51b946.zip |
Merge branch 'master' into develop
Diffstat (limited to 'sleekxmpp/plugins')
-rw-r--r-- | sleekxmpp/plugins/__init__.py | 1 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0047/stream.py | 7 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0084/avatar.py | 16 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0084/stanza.py | 2 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0106.py | 26 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0153/vcard_avatar.py | 3 |
6 files changed, 42 insertions, 13 deletions
diff --git a/sleekxmpp/plugins/__init__.py b/sleekxmpp/plugins/__init__.py index dbab2d1c..270626ed 100644 --- a/sleekxmpp/plugins/__init__.py +++ b/sleekxmpp/plugins/__init__.py @@ -37,6 +37,7 @@ __all__ = [ 'xep_0085', # Chat State Notifications 'xep_0086', # Legacy Error Codes 'xep_0092', # Software Version + 'xep_0106', # JID Escaping 'xep_0107', # User Mood 'xep_0108', # User Activity 'xep_0115', # Entity Capabilities diff --git a/sleekxmpp/plugins/xep_0047/stream.py b/sleekxmpp/plugins/xep_0047/stream.py index 49f56f36..b49a077b 100644 --- a/sleekxmpp/plugins/xep_0047/stream.py +++ b/sleekxmpp/plugins/xep_0047/stream.py @@ -1,11 +1,8 @@ import socket import threading import logging -try: - import queue -except ImportError: - import Queue as queue +from sleekxmpp.util import Queue from sleekxmpp.exceptions import XMPPError @@ -33,7 +30,7 @@ class IBBytestream(object): self.stream_in_closed = threading.Event() self.stream_out_closed = threading.Event() - self.recv_queue = queue.Queue() + self.recv_queue = Queue() self.send_window = threading.BoundedSemaphore(value=self.window_size) self.window_ids = set() diff --git a/sleekxmpp/plugins/xep_0084/avatar.py b/sleekxmpp/plugins/xep_0084/avatar.py index bbac330a..03711871 100644 --- a/sleekxmpp/plugins/xep_0084/avatar.py +++ b/sleekxmpp/plugins/xep_0084/avatar.py @@ -41,6 +41,9 @@ class XEP_0084(BasePlugin): def session_bind(self, jid): self.xmpp['xep_0163'].register_pep('avatar_metadata', MetaData) + def generate_id(self, data): + return hashlib.sha1(data).hexdigest() + def retrieve_avatar(self, jid, id, url=None, ifrom=None, block=True, callback=None, timeout=None): return self.xmpp['xep_0060'].get_item(jid, Data.namespace, id, @@ -54,8 +57,7 @@ class XEP_0084(BasePlugin): payload = Data() payload['value'] = data return self.xmpp['xep_0163'].publish(payload, - node=Data.namespace, - id=hashlib.sha1(data).hexdigest(), + id=self.generate_id(data), ifrom=ifrom, block=block, callback=callback, @@ -72,12 +74,12 @@ class XEP_0084(BasePlugin): height=info.get('height', ''), width=info.get('width', ''), url=info.get('url', '')) - for pointer in pointers: - metadata.add_pointer(pointer) - return self.xmpp['xep_0163'].publish(payload, - node=Data.namespace, - id=hashlib.sha1(data).hexdigest(), + if pointers is not None: + for pointer in pointers: + metadata.add_pointer(pointer) + + return self.xmpp['xep_0163'].publish(metadata, ifrom=ifrom, block=block, callback=callback, diff --git a/sleekxmpp/plugins/xep_0084/stanza.py b/sleekxmpp/plugins/xep_0084/stanza.py index 1b204471..e9133998 100644 --- a/sleekxmpp/plugins/xep_0084/stanza.py +++ b/sleekxmpp/plugins/xep_0084/stanza.py @@ -43,7 +43,7 @@ class MetaData(ElementBase): info = Info() info.values = {'id': id, 'type': itype, - 'bytes': ibytes, + 'bytes': '%s' % ibytes, 'height': height, 'width': width, 'url': url} diff --git a/sleekxmpp/plugins/xep_0106.py b/sleekxmpp/plugins/xep_0106.py new file mode 100644 index 00000000..1859a77b --- /dev/null +++ b/sleekxmpp/plugins/xep_0106.py @@ -0,0 +1,26 @@ +""" + SleekXMPP: The Sleek XMPP Library + Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout + This file is part of SleekXMPP. + + See the file LICENSE for copying permission. +""" + + +from sleekxmpp.plugins import BasePlugin, register_plugin + + +class XEP_0106(BasePlugin): + + name = 'xep_0106' + description = 'XEP-0106: JID Escaping' + dependencies = set(['xep_0030']) + + def session_bind(self, jid): + self.xmpp['xep_0030'].add_feature(feature='jid\\20escaping') + + def plugin_end(self): + self.xmpp['xep_0030'].del_feature(feature='jid\\20escaping') + + +register_plugin(XEP_0106) diff --git a/sleekxmpp/plugins/xep_0153/vcard_avatar.py b/sleekxmpp/plugins/xep_0153/vcard_avatar.py index 6b70e33e..bec792cb 100644 --- a/sleekxmpp/plugins/xep_0153/vcard_avatar.py +++ b/sleekxmpp/plugins/xep_0153/vcard_avatar.py @@ -75,6 +75,9 @@ class XEP_0153(BasePlugin): return stanza def _reset_hash(self, jid=None): + if jid is None: + jid = self.xmpp.boundjid + own_jid = (jid.bare == self.xmpp.boundjid.bare) if self.xmpp.is_component: own_jid = (jid.domain == self.xmpp.boundjid.domain) |