Add options to auto add ID values to message and presence stanzas.
This commit is contained in:
parent
e449dce65c
commit
b5c669bdff
3 changed files with 33 additions and 0 deletions
|
@ -114,6 +114,17 @@ class BaseXMPP(XMLStream):
|
||||||
#: ``'to'`` and ``'from'`` JIDs of stanzas.
|
#: ``'to'`` and ``'from'`` JIDs of stanzas.
|
||||||
self.is_component = False
|
self.is_component = False
|
||||||
|
|
||||||
|
#: Messages may optionally be tagged with ID values. Setting
|
||||||
|
#: :attr:`use_message_ids` to `True` will assign all outgoing
|
||||||
|
#: messages an ID. Some plugin features require enabling
|
||||||
|
#: this option.
|
||||||
|
self.use_message_ids = False
|
||||||
|
|
||||||
|
#: Presence updates may optionally be tagged with ID values.
|
||||||
|
#: Setting :attr:`use_message_ids` to `True` will assign all
|
||||||
|
#: outgoing messages an ID.
|
||||||
|
self.use_presence_ids = False
|
||||||
|
|
||||||
#: The API registry is a way to process callbacks based on
|
#: The API registry is a way to process callbacks based on
|
||||||
#: JID+node combinations. Each callback in the registry is
|
#: JID+node combinations. Each callback in the registry is
|
||||||
#: marked with:
|
#: marked with:
|
||||||
|
|
|
@ -63,6 +63,17 @@ class Message(RootStanza):
|
||||||
lang_interfaces = sub_interfaces
|
lang_interfaces = sub_interfaces
|
||||||
types = set(['normal', 'chat', 'headline', 'error', 'groupchat'])
|
types = set(['normal', 'chat', 'headline', 'error', 'groupchat'])
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
Initialize a new <message /> stanza with an optional 'id' value.
|
||||||
|
|
||||||
|
Overrides StanzaBase.__init__.
|
||||||
|
"""
|
||||||
|
StanzaBase.__init__(self, *args, **kwargs)
|
||||||
|
if self['id'] == '':
|
||||||
|
if self.stream is not None and self.stream.use_message_ids:
|
||||||
|
self['id'] = self.stream.new_id()
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
"""
|
"""
|
||||||
Return the message type.
|
Return the message type.
|
||||||
|
|
|
@ -72,6 +72,17 @@ class Presence(RootStanza):
|
||||||
'subscribed', 'unsubscribe', 'unsubscribed'])
|
'subscribed', 'unsubscribe', 'unsubscribed'])
|
||||||
showtypes = set(['dnd', 'chat', 'xa', 'away'])
|
showtypes = set(['dnd', 'chat', 'xa', 'away'])
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
Initialize a new <presence /> stanza with an optional 'id' value.
|
||||||
|
|
||||||
|
Overrides StanzaBase.__init__.
|
||||||
|
"""
|
||||||
|
StanzaBase.__init__(self, *args, **kwargs)
|
||||||
|
if self['id'] == '':
|
||||||
|
if self.stream is not None and self.stream.use_presence_ids:
|
||||||
|
self['id'] = self.stream.new_id()
|
||||||
|
|
||||||
def exception(self, e):
|
def exception(self, e):
|
||||||
"""
|
"""
|
||||||
Override exception passback for presence.
|
Override exception passback for presence.
|
||||||
|
|
Loading…
Reference in a new issue