summaryrefslogtreecommitdiff
path: root/sleekxmpp/roster/single.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-06-19 21:50:33 -0700
committerLance Stout <lancestout@gmail.com>2012-06-19 21:50:33 -0700
commit5820d49cd401a1362a8a675c4b91935adb1240fe (patch)
treef40f78839ae3004bfb0b8da1ae93d61759d8ad66 /sleekxmpp/roster/single.py
parent1ab66e576786ecb0cfb9b6b163811735564b951b (diff)
parent36c11ad9de7c1b5a199aa5a4302e33085513c126 (diff)
downloadslixmpp-5820d49cd401a1362a8a675c4b91935adb1240fe.tar.gz
slixmpp-5820d49cd401a1362a8a675c4b91935adb1240fe.tar.bz2
slixmpp-5820d49cd401a1362a8a675c4b91935adb1240fe.tar.xz
slixmpp-5820d49cd401a1362a8a675c4b91935adb1240fe.zip
Merge branch 'master' into develop
Conflicts: sleekxmpp/basexmpp.py
Diffstat (limited to 'sleekxmpp/roster/single.py')
-rw-r--r--sleekxmpp/roster/single.py35
1 files changed, 12 insertions, 23 deletions
diff --git a/sleekxmpp/roster/single.py b/sleekxmpp/roster/single.py
index 048b091e..f8c9c781 100644
--- a/sleekxmpp/roster/single.py
+++ b/sleekxmpp/roster/single.py
@@ -6,6 +6,8 @@
See the file LICENSE for copying permission.
"""
+import threading
+
from sleekxmpp.xmlstream import JID
from sleekxmpp.roster import RosterItem
@@ -59,13 +61,14 @@ class RosterNode(object):
self.last_status = None
self._version = ''
self._jids = {}
+ self._last_status_lock = threading.Lock()
if self.db:
if hasattr(self.db, 'version'):
self._version = self.db.version(self.jid)
for jid in self.db.entries(self.jid):
self.add(jid)
-
+
@property
def version(self):
"""Retrieve the roster's version ID."""
@@ -146,7 +149,7 @@ class RosterNode(object):
self.db = db
existing_entries = set(self._jids)
new_entries = set(self.db.entries(self.jid, {}))
-
+
for jid in existing_entries:
self._jids[jid].set_backend(db, save)
for jid in new_entries - existing_entries:
@@ -291,8 +294,7 @@ class RosterNode(object):
for jid in self:
self[jid].reset()
- def send_presence(self, ptype=None, pshow=None, pstatus=None,
- ppriority=None, pnick=None, pto=None):
+ def send_presence(self, **kwargs):
"""
Create, initialize, and send a Presence stanza.
@@ -305,27 +307,14 @@ class RosterNode(object):
pstatus -- The presence's status message.
ppriority -- This connections' priority.
pto -- The recipient of a directed presence.
+ pfrom -- The sender of a directed presence, which should
+ be the owner JID plus resource.
ptype -- The type of presence, such as 'subscribe'.
+ pnick -- Optional nickname of the presence's sender.
"""
- if pto:
- self[pto].send_presence(ptype, pshow, pstatus,
- ppriority, pnick)
- else:
- p = self.xmpp.make_presence(pshow=pshow,
- pstatus=pstatus,
- ppriority=ppriority,
- ptype=ptype,
- pnick=pnick)
- if self.xmpp.is_component:
- p['from'] = self.jid
- if p['type'] in p.showtypes or \
- p['type'] in ['available', 'unavailable']:
- self.last_status = p
- p.send()
-
- if not self.xmpp.sentpresence:
- self.xmpp.event('sent_presence')
- self.xmpp.sentpresence = True
+ if self.xmpp.is_component and not kwargs.get('pfrom', ''):
+ kwargs['pfrom'] = self.jid
+ self.xmpp.send_presence(**kwargs)
def send_last_presence(self):
if self.last_status is None: