summaryrefslogtreecommitdiff
path: root/sleekxmpp/stanza
diff options
context:
space:
mode:
Diffstat (limited to 'sleekxmpp/stanza')
-rw-r--r--sleekxmpp/stanza/message.py44
-rw-r--r--sleekxmpp/stanza/presence.py17
2 files changed, 47 insertions, 14 deletions
diff --git a/sleekxmpp/stanza/message.py b/sleekxmpp/stanza/message.py
index 407802bd..02133682 100644
--- a/sleekxmpp/stanza/message.py
+++ b/sleekxmpp/stanza/message.py
@@ -7,7 +7,7 @@
"""
from sleekxmpp.stanza.rootstanza import RootStanza
-from sleekxmpp.xmlstream import StanzaBase
+from sleekxmpp.xmlstream import StanzaBase, ET
class Message(RootStanza):
@@ -54,13 +54,14 @@ class Message(RootStanza):
del_mucnick -- Dummy method to prevent deletion.
"""
- namespace = 'jabber:client'
name = 'message'
- interfaces = set(('type', 'to', 'from', 'id', 'body', 'subject',
- 'mucroom', 'mucnick'))
- sub_interfaces = set(('body', 'subject'))
+ namespace = 'jabber:client'
plugin_attrib = name
- types = set((None, 'normal', 'chat', 'headline', 'error', 'groupchat'))
+ interfaces = set(['type', 'to', 'from', 'id', 'body', 'subject',
+ 'thread', 'parent_thread', 'mucroom', 'mucnick'])
+ sub_interfaces = set(['body', 'subject', 'thread'])
+ lang_interfaces = sub_interfaces
+ types = set(['normal', 'chat', 'headline', 'error', 'groupchat'])
def get_type(self):
"""
@@ -72,6 +73,31 @@ class Message(RootStanza):
"""
return self._get_attr('type', 'normal')
+ def get_parent_thread(self):
+ """Return the message thread's parent thread."""
+ thread = self.xml.find('{%s}thread' % self.namespace)
+ if thread is not None:
+ return thread.attrib.get('parent', '')
+ return ''
+
+ def set_parent_thread(self, value):
+ """Add or change the message thread's parent thread."""
+ thread = self.xml.find('{%s}thread' % self.namespace)
+ if value:
+ if thread is None:
+ thread = ET.Element('{%s}thread' % self.namespace)
+ self.xml.append(thread)
+ thread.attrib['parent'] = value
+ else:
+ if thread is not None and 'parent' in thread.attrib:
+ del thread.attrib['parent']
+
+ def del_parent_thread(self):
+ """Delete the message thread's parent reference."""
+ thread = self.xml.find('{%s}thread' % self.namespace)
+ if thread is not None and 'parent' in thread.attrib:
+ del thread.attrib['parent']
+
def chat(self):
"""Set the message type to 'chat'."""
self['type'] = 'chat'
@@ -96,10 +122,16 @@ class Message(RootStanza):
clear -- Indicates if existing content should be removed
before replying. Defaults to True.
"""
+ thread = self['thread']
+ parent = self['parent_thread']
+
StanzaBase.reply(self, clear)
if self['type'] == 'groupchat':
self['to'] = self['to'].bare
+ self['thread'] = thread
+ self['parent_thread'] = parent
+
del self['id']
if body is not None:
diff --git a/sleekxmpp/stanza/presence.py b/sleekxmpp/stanza/presence.py
index f2dd0968..7951f861 100644
--- a/sleekxmpp/stanza/presence.py
+++ b/sleekxmpp/stanza/presence.py
@@ -60,16 +60,17 @@ class Presence(RootStanza):
set_priority -- Set the value of the <priority> element.
"""
- namespace = 'jabber:client'
name = 'presence'
- interfaces = set(('type', 'to', 'from', 'id', 'show',
- 'status', 'priority'))
- sub_interfaces = set(('show', 'status', 'priority'))
+ namespace = 'jabber:client'
plugin_attrib = name
-
- types = set(('available', 'unavailable', 'error', 'probe', 'subscribe',
- 'subscribed', 'unsubscribe', 'unsubscribed'))
- showtypes = set(('dnd', 'chat', 'xa', 'away'))
+ 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'])
def exception(self, e):
"""