summaryrefslogtreecommitdiff
path: root/sleekxmpp/basexmpp.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-06-16 16:03:31 -0700
committerLance Stout <lancestout@gmail.com>2011-06-16 16:03:31 -0700
commit29d775e6756e7d8028438942ca2d34d1c39c559f (patch)
tree94d8b81a50d5f30eaa0e841ae9fa9b7d8f023626 /sleekxmpp/basexmpp.py
parent251a47db8cd3262589ffdae5167dd5c4dee065a9 (diff)
downloadslixmpp-29d775e6756e7d8028438942ca2d34d1c39c559f.tar.gz
slixmpp-29d775e6756e7d8028438942ca2d34d1c39c559f.tar.bz2
slixmpp-29d775e6756e7d8028438942ca2d34d1c39c559f.tar.xz
slixmpp-29d775e6756e7d8028438942ca2d34d1c39c559f.zip
Integrate roster with BaseXMPP.
Last sent stanzas are saved regardless of if the roster is used directly or self.send_presence
Diffstat (limited to 'sleekxmpp/basexmpp.py')
-rw-r--r--sleekxmpp/basexmpp.py46
1 files changed, 32 insertions, 14 deletions
diff --git a/sleekxmpp/basexmpp.py b/sleekxmpp/basexmpp.py
index 91b419ba..ef6906a6 100644
--- a/sleekxmpp/basexmpp.py
+++ b/sleekxmpp/basexmpp.py
@@ -426,7 +426,7 @@ class BaseXMPP(XMLStream):
msubject -- Optional subject for the message.
mtype -- The message's type, such as 'chat' or 'groupchat'.
mhtml -- Optional HTML body content.
- mfrom -- The sender of the message. If sending from a client,
+ mfrom -- The sender of the message. if sending from a client,
be aware that some servers require that the full JID
of the sender be used.
mnick -- Optional nickname of the sender.
@@ -441,7 +441,7 @@ class BaseXMPP(XMLStream):
return message
def make_presence(self, pshow=None, pstatus=None, ppriority=None,
- pto=None, ptype=None, pfrom=None):
+ pto=None, ptype=None, pfrom=None, pnick=None):
"""
Create and initialize a new Presence stanza.
@@ -452,14 +452,16 @@ class BaseXMPP(XMLStream):
pto -- The recipient of a directed presence.
ptype -- The type of presence, such as 'subscribe'.
pfrom -- The sender of the presence.
+ pnick -- Optional nickname of the presence's sender.
"""
presence = self.Presence(stype=ptype, sfrom=pfrom, sto=pto)
if pshow is not None:
presence['type'] = pshow
- if pfrom is None:
+ if pfrom is None and self.is_component:
presence['from'] = self.boundjid.full
presence['priority'] = ppriority
presence['status'] = pstatus
+ presence['nick'] = pnick
return presence
def send_message(self, mto, mbody, msubject=None, mtype=None,
@@ -467,13 +469,22 @@ class BaseXMPP(XMLStream):
"""
Create, initialize, and send a Message stanza.
-
+ Arguments:
+ mto -- The recipient of the message.
+ mbody -- The main contents of the message.
+ msubject -- Optional subject for the message.
+ mtype -- The message's type, such as 'chat' or 'groupchat'.
+ mhtml -- Optional HTML body content.
+ mfrom -- The sender of the message. if sending from a client,
+ be aware that some servers require that the full JID
+ of the sender be used.
+ mnick -- Optional nickname of the sender.
"""
- self.makeMessage(mto, mbody, msubject, mtype,
- mhtml, mfrom, mnick).send()
+ self.make_message(mto, mbody, msubject, mtype,
+ mhtml, mfrom, mnick).send()
def send_presence(self, pshow=None, pstatus=None, ppriority=None,
- pto=None, pfrom=None, ptype=None):
+ pto=None, pfrom=None, ptype=None, pnick=None):
"""
Create, initialize, and send a Presence stanza.
@@ -484,13 +495,20 @@ class BaseXMPP(XMLStream):
pto -- The recipient of a directed presence.
ptype -- The type of presence, such as 'subscribe'.
pfrom -- The sender of the presence.
- """
- self.makePresence(pshow, pstatus, ppriority, pto,
- ptype=ptype, pfrom=pfrom).send()
- # Unexpected errors may occur if
- if not self.sentpresence:
- self.event('sent_presence')
- self.sentpresence = True
+ pnick -- Optional nickname of the presence's sender.
+ """
+ # Python2.6 chokes on Unicode strings for dict keys.
+ args = {str('pto'): pto,
+ str('ptype'): ptype,
+ str('pshow'): pshow,
+ str('pstatus'): pstatus,
+ str('ppriority'): ppriority,
+ str('pnick'): pnick}
+
+ if self.is_component:
+ self.roster[pfrom].send_presence(**args)
+ else:
+ self.client_roster.send_presence(**args)
def send_presence_subscription(self, pto, pfrom=None,
ptype='subscribe', pnick=None):