aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2010-11-15 02:00:56 +0100
committerThibaut Horel <thibaut.horel@gmail.com>2010-11-15 02:00:56 +0100
commit59f44cc48166589846401d609c0cac3f454b8e5f (patch)
treecd6b7ed71d9ee7a887c0cf0f405900c2edf6fdf2
parentf0552f8d39407c4fdcb14f8cc0c30c31f94a510e (diff)
downloadalias-59f44cc48166589846401d609c0cac3f454b8e5f.tar.gz
Basic alias plugin
-rw-r--r--plugin.py32
-rw-r--r--server.py1
2 files changed, 33 insertions, 0 deletions
diff --git a/plugin.py b/plugin.py
new file mode 100644
index 0000000..a88d244
--- /dev/null
+++ b/plugin.py
@@ -0,0 +1,32 @@
+from sleekxmpp.xmlstream.stanzabase import ElementBase, registerStanzaPlugin
+from sleekxmpp.plugins import base
+from sleekxmpp.xmlstream.handler.callback import Callback
+from sleekxmpp.xmlstream.matcher.xpath import MatchXPath
+from sleekxmpp.stanza.iq import Iq
+import logging
+
+class AliasQuery(ElementBase) :
+ namespace = 'alias:query'
+ name = 'query'
+ plugin_attrib = 'query'
+ interfaces = set(('node', 'type', 'items','object'))
+ sub_interfaces = set(('items'))
+
+
+class AliasPlugin(base.base_plugin) :
+
+ def plugin_init(self) :
+ self.description = 'Plugin to handle alias queries'
+ registerStanzaPlugin(Iq, AliasQuery)
+
+ self.xmpp.registerHandler(
+ Callback('Alias queries',
+ MatchXPath('{%s}iq/{%s}query' % (self.xmpp.default_ns,
+ AliasQuery.namespace)),
+ self.handle_alias_query))
+
+ def handle_alias_query(self, iq) :
+ iq.reply().send()
+
+
+
diff --git a/server.py b/server.py
index 90b4cb1..1ecf779 100644
--- a/server.py
+++ b/server.py
@@ -8,6 +8,7 @@ class ObjectComponent(ComponentXMPP):
def __init__(self, jid, secret, server, port, root):
ComponentXMPP.__init__(self, jid, secret, server, port)
+ self.register_plugin("AliasPlugin", module = "plugin" )
self.add_event_handler("session_start", self.start)
self.add_event_handler("presence_probe", self.presenceProbe)
self.add_event_handler("message", self.message)