diff idavoll/tap.py @ 167:ef22e4150caa

Move protocol implementations (pubsub, disco, forms) to and depend on wokkel. Author: ralphm Fixes: #4
author Ralph Meijer <ralphm@ik.nu>
date Wed, 03 Oct 2007 12:41:43 +0000
parents 1701c0e2c707
children 96afb248df5e
line wrap: on
line diff
--- a/idavoll/tap.py	Thu Jan 18 14:08:32 2007 +0000
+++ b/idavoll/tap.py	Wed Oct 03 12:41:43 2007 +0000
@@ -1,10 +1,18 @@
-# Copyright (c) 2003-2006 Ralph Meijer
+# Copyright (c) 2003-2007 Ralph Meijer
 # See LICENSE for details.
 
-from twisted.application import internet, service
-from twisted.internet import interfaces
+from twisted.application import service
 from twisted.python import usage
-import idavoll
+from twisted.words.protocols.jabber.jid import JID
+
+from wokkel.component import Component
+from wokkel.disco import DiscoHandler
+from wokkel.generic import FallbackHandler, VersionHandler
+from wokkel.iwokkel import IPubSubService
+
+from idavoll.backend import BackendService
+
+__version__ = '0.6.0'
 
 class Options(usage.Options):
     optParameters = [
@@ -22,10 +30,42 @@
         ('verbose', 'v', 'Show traffic'),
         ('hide-nodes', None, 'Hide all nodes for disco')
     ]
-    
+
     def postOptions(self):
         if self['backend'] not in ['pgsql', 'memory']:
             raise usage.UsageError, "Unknown backend!"
 
 def makeService(config):
-    return idavoll.makeService(config)
+    s = service.MultiService()
+
+    cs = Component(config["rhost"], int(config["rport"]),
+                   config["jid"], config["secret"])
+    cs.setServiceParent(s)
+
+    cs.factory.maxDelay = 900
+
+    if config["verbose"]:
+        cs.logTraffic = True
+
+    FallbackHandler().setHanderParent(cs)
+    VersionHandler('Idavoll', __version__).setHanderParent(cs)
+    DiscoHandler().setHanderParent(cs)
+
+    if config['backend'] == 'pgsql':
+        from idavoll.pgsql_storage import Storage
+        st = Storage(user=config['dbuser'],
+                     database=config['dbname'],
+                     password=config['dbpass'])
+    elif config['backend'] == 'memory':
+        from idavoll.memory_storage import Storage
+        st = Storage()
+
+    bs = BackendService(st)
+    bs.setServiceParent(s)
+
+    ps = IPubSubService(bs)
+    ps.setHanderParent(cs)
+    ps.hideNodes = config["hide-nodes"]
+    ps.serviceJID = JID(config["jid"])
+
+    return s