summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream
diff options
context:
space:
mode:
authorNathan Fritz <fritzy@netflint.net>2010-01-15 21:07:28 -0800
committerNathan Fritz <fritzy@netflint.net>2010-01-15 21:07:28 -0800
commite39a2395d7d5b1490e66316cd46b3f31b787cb37 (patch)
tree64579f2b44aa6fcf37c18f0029aa4021ade940c2 /sleekxmpp/xmlstream
parent5345e9a46ba6b862944bcddacd73fba448758109 (diff)
downloadslixmpp-e39a2395d7d5b1490e66316cd46b3f31b787cb37.tar.gz
slixmpp-e39a2395d7d5b1490e66316cd46b3f31b787cb37.tar.bz2
slixmpp-e39a2395d7d5b1490e66316cd46b3f31b787cb37.tar.xz
slixmpp-e39a2395d7d5b1490e66316cd46b3f31b787cb37.zip
xep 30 and 50 always reply from jid iq sent to
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r--sleekxmpp/xmlstream/matcher/id.py2
-rw-r--r--sleekxmpp/xmlstream/matcher/stanzapath.py7
-rw-r--r--sleekxmpp/xmlstream/matcher/xmlmask.py1
-rw-r--r--sleekxmpp/xmlstream/matcher/xpath.py1
-rw-r--r--sleekxmpp/xmlstream/stanzabase.py26
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py2
6 files changed, 32 insertions, 7 deletions
diff --git a/sleekxmpp/xmlstream/matcher/id.py b/sleekxmpp/xmlstream/matcher/id.py
index ec7597d4..44fad15c 100644
--- a/sleekxmpp/xmlstream/matcher/id.py
+++ b/sleekxmpp/xmlstream/matcher/id.py
@@ -3,4 +3,4 @@ from . import base
class MatcherId(base.MatcherBase):
def match(self, xml):
- return xml.get('id') == self._criteria
+ return xml['id'] == self._criteria
diff --git a/sleekxmpp/xmlstream/matcher/stanzapath.py b/sleekxmpp/xmlstream/matcher/stanzapath.py
new file mode 100644
index 00000000..d036d0b8
--- /dev/null
+++ b/sleekxmpp/xmlstream/matcher/stanzapath.py
@@ -0,0 +1,7 @@
+from . import base
+from xml.etree import cElementTree
+
+class StanzaPath(base.MatcherBase):
+
+ def match(self, stanza):
+ return stanza.match(self._criteria)
diff --git a/sleekxmpp/xmlstream/matcher/xmlmask.py b/sleekxmpp/xmlstream/matcher/xmlmask.py
index e8e4df02..1cd19644 100644
--- a/sleekxmpp/xmlstream/matcher/xmlmask.py
+++ b/sleekxmpp/xmlstream/matcher/xmlmask.py
@@ -16,6 +16,7 @@ class MatchXMLMask(base.MatcherBase):
self.default_ns = ns
def match(self, xml):
+ xml = xml.xml
return self.maskcmp(xml, self._criteria, True)
def maskcmp(self, source, maskobj, use_ns=False, default_ns='__no_ns__'):
diff --git a/sleekxmpp/xmlstream/matcher/xpath.py b/sleekxmpp/xmlstream/matcher/xpath.py
index 060d5df3..5e0411ef 100644
--- a/sleekxmpp/xmlstream/matcher/xpath.py
+++ b/sleekxmpp/xmlstream/matcher/xpath.py
@@ -6,6 +6,7 @@ ignore_ns = False
class MatchXPath(base.MatcherBase):
def match(self, xml):
+ xml = xml.xml
x = cElementTree.Element('x')
x.append(xml)
if not ignore_ns:
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py
index 00a1439a..feb9b268 100644
--- a/sleekxmpp/xmlstream/stanzabase.py
+++ b/sleekxmpp/xmlstream/stanzabase.py
@@ -91,11 +91,27 @@ class ElementBase(object):
out.append('substanzas')
return tuple(out)
- def find(self, item):
- return self.iterables.find(item)
-
- def match(self, xml):
- return xml.tag == self.tag
+ def match(self, matchstring):
+ if isinstance(matchstring, str):
+ nodes = matchstring.split('/')
+ else:
+ nodes = matchstring
+ tagargs = nodes[0].split('@')
+ if tagargs[0] not in (self.plugins, self.name): return False
+ founditerable = False
+ for iterable in self.iterables:
+ founditerable = iterable.match(nodes[1:])
+ if founditerable: break;
+ for evals in tagargs[1:]:
+ x,y = evals.split('=')
+ if self[x] != y: return False
+ if not founditerable and len(nodes) > 1:
+ next = nodes[1].split('@')[0]
+ if next in self.plugins:
+ return self.plugins[next].match(nodes[1:])
+ else:
+ return False
+ return True
def find(self, xpath): # for backwards compatiblity, expose elementtree interface
return self.xml.find(xpath)
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index 51786935..06011aa4 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -277,7 +277,7 @@ class XMLStream(object):
stanza = StanzaBase(self, xmlobj)
unhandled = True
for handler in self.__handlers:
- if handler.match(xmlobj):
+ if handler.match(stanza):
handler.prerun(stanza)
self.eventqueue.put(('stanza', handler, stanza))
if handler.checkDelete(): self.__handlers.pop(self.__handlers.index(handler))