adding tests, fixed stanzapath matching to match keys, fixed pubsub#owner stanzas
This commit is contained in:
@@ -286,39 +286,6 @@ stanzaPlugin(Pubsub, Configure)
|
||||
stanzaPlugin(Create, Configure)
|
||||
|
||||
class DefaultConfig(ElementBase):
|
||||
namespace = 'http://jabber.org/protocol/pubsub'
|
||||
name = 'default'
|
||||
plugin_attrib = 'default'
|
||||
interfaces = set(('node', 'type', 'config'))
|
||||
plugin_attrib_map = {}
|
||||
plugin_tag_map = {}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
ElementBase.__init__(self, *args, **kwargs)
|
||||
|
||||
def getConfig(self):
|
||||
config = self.xml.find('{jabber:x:data}x')
|
||||
form = xep_0004.Form()
|
||||
if config is not None:
|
||||
form.fromXML(config)
|
||||
return form
|
||||
|
||||
def setConfig(self, value):
|
||||
self.xml.append(value.getXML())
|
||||
return self
|
||||
|
||||
def delConfig(self):
|
||||
config = self.xml.find('{jabber:x:data}x')
|
||||
self.xml.remove(config)
|
||||
|
||||
def getType(self):
|
||||
t = self._getAttr('type')
|
||||
if not t: t == 'leaf'
|
||||
return t
|
||||
|
||||
stanzaPlugin(Pubsub, DefaultConfig)
|
||||
|
||||
class DefaultConfigOwner(ElementBase):
|
||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||
name = 'default'
|
||||
plugin_attrib = 'default'
|
||||
@@ -440,6 +407,7 @@ class OwnerDelete(ElementBase, OptionalSetting):
|
||||
plugin_attrib = 'delete'
|
||||
plugin_attrib_map = {}
|
||||
plugin_tag_map = {}
|
||||
interfaces = set(('node',))
|
||||
|
||||
stanzaPlugin(PubsubOwner, OwnerDelete)
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ class Iq(RootStanza):
|
||||
interfaces = set(('type', 'to', 'from', 'id','query'))
|
||||
types = set(('get', 'result', 'set', 'error'))
|
||||
name = 'iq'
|
||||
plugin_attrib = name
|
||||
namespace = 'jabber:client'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
@@ -15,6 +15,7 @@ class Message(RootStanza):
|
||||
types = set((None, 'normal', 'chat', 'headline', 'error', 'groupchat'))
|
||||
sub_interfaces = set(('body', 'subject'))
|
||||
name = 'message'
|
||||
plugin_attrib = name
|
||||
namespace = 'jabber:client'
|
||||
|
||||
def getType(self):
|
||||
|
||||
@@ -16,6 +16,7 @@ class Presence(RootStanza):
|
||||
showtypes = set(('dnd', 'chat', 'xa', 'away'))
|
||||
sub_interfaces = set(('status', 'priority'))
|
||||
name = 'presence'
|
||||
plugin_attrib = name
|
||||
namespace = 'jabber:client'
|
||||
|
||||
def getShowElement(self):
|
||||
|
||||
@@ -117,7 +117,7 @@ class ElementBase(tostring.ToString):
|
||||
else:
|
||||
nodes = matchstring
|
||||
tagargs = nodes[0].split('@')
|
||||
if tagargs[0] not in (self.plugins, self.name): return False
|
||||
if tagargs[0] not in (self.plugins, self.plugin_attrib): return False
|
||||
founditerable = False
|
||||
for iterable in self.iterables:
|
||||
founditerable = iterable.match(nodes[1:])
|
||||
@@ -325,8 +325,8 @@ class StanzaBase(ElementBase):
|
||||
def clear(self):
|
||||
for child in self.xml.getchildren():
|
||||
self.xml.remove(child)
|
||||
#for plugin in list(self.plugins.keys()):
|
||||
# del self.plugins[plugin]
|
||||
for plugin in list(self.plugins.keys()):
|
||||
del self.plugins[plugin]
|
||||
|
||||
def reply(self):
|
||||
self['from'], self['to'] = self['to'], self['from']
|
||||
|
||||
Reference in New Issue
Block a user