added incoming_filter
This commit is contained in:
parent
171bb30e83
commit
7a15d14c93
2 changed files with 12 additions and 8 deletions
|
@ -23,14 +23,6 @@ from __future__ import absolute_import
|
||||||
from . basexmpp import basexmpp
|
from . basexmpp import basexmpp
|
||||||
from xml.etree import cElementTree as ET
|
from xml.etree import cElementTree as ET
|
||||||
|
|
||||||
# some servers use different namespaces for components -- this is a hack, but is there for compatibility
|
|
||||||
from . xmlstream.matcher import xmlmask
|
|
||||||
from . xmlstream.matcher import xpath
|
|
||||||
|
|
||||||
xmlmask.ignore_ns = True
|
|
||||||
xpath.ignore_ns = True
|
|
||||||
# ----------
|
|
||||||
|
|
||||||
from . xmlstream.xmlstream import XMLStream
|
from . xmlstream.xmlstream import XMLStream
|
||||||
from . xmlstream.xmlstream import RestartStream
|
from . xmlstream.xmlstream import RestartStream
|
||||||
from . xmlstream.matcher.xmlmask import MatchXMLMask
|
from . xmlstream.matcher.xmlmask import MatchXMLMask
|
||||||
|
@ -77,6 +69,14 @@ class ComponentXMPP(basexmpp, XMLStream):
|
||||||
MatchXMLMask("<presence xmlns='%s' type='unsubscribe'/>" % self.default_ns), \
|
MatchXMLMask("<presence xmlns='%s' type='unsubscribe'/>" % self.default_ns), \
|
||||||
MatchXMLMask("<presence xmlns='%s' type='unsubscribed'/>" % self.default_ns) \
|
MatchXMLMask("<presence xmlns='%s' type='unsubscribed'/>" % self.default_ns) \
|
||||||
)), self._handlePresenceSubscription))
|
)), self._handlePresenceSubscription))
|
||||||
|
|
||||||
|
def incoming_filter(self, xmlobj):
|
||||||
|
if xmlobj.tag.startswith('{jabber:client}'):
|
||||||
|
xmlobj.tag = xmlobj.tag.replace('jabber:client', 'jabber:component:accept')
|
||||||
|
for child in xmlobj.children():
|
||||||
|
child = self.incoming_filter(child)
|
||||||
|
return xmlobj
|
||||||
|
|
||||||
|
|
||||||
def _handlePresenceProbe(self, stanza):
|
def _handlePresenceProbe(self, stanza):
|
||||||
xml = stanza.xml
|
xml = stanza.xml
|
||||||
|
|
|
@ -289,10 +289,14 @@ class XMLStream(object):
|
||||||
self.state.set('ssl',False)
|
self.state.set('ssl',False)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.connect()
|
self.connect()
|
||||||
|
|
||||||
|
def incoming_filter(self, xmlobj):
|
||||||
|
return xmlobj
|
||||||
|
|
||||||
def __spawnEvent(self, xmlobj):
|
def __spawnEvent(self, xmlobj):
|
||||||
"watching xmlOut and processes handlers"
|
"watching xmlOut and processes handlers"
|
||||||
#convert XML into Stanza
|
#convert XML into Stanza
|
||||||
|
xmlobj = self.incoming_filter(xmlobj)
|
||||||
logging.debug("PROCESSING: %s" % xmlobj.tag)
|
logging.debug("PROCESSING: %s" % xmlobj.tag)
|
||||||
stanza = None
|
stanza = None
|
||||||
for stanza_class in self.__root_stanza:
|
for stanza_class in self.__root_stanza:
|
||||||
|
|
Loading…
Reference in a new issue