comparison idavoll/tap.py @ 177:faf1c9bc2612

Add HTTP gateway in a separate plugin. Author: ralphm Fixes #8.
author Ralph Meijer <ralphm@ik.nu>
date Thu, 10 Apr 2008 11:18:29 +0000
parents 17fc5dd77158
children c61034369463
comparison
equal deleted inserted replaced
176:17fc5dd77158 177:faf1c9bc2612
1 # Copyright (c) 2003-2007 Ralph Meijer 1 # Copyright (c) 2003-2008 Ralph Meijer
2 # See LICENSE for details. 2 # See LICENSE for details.
3 3
4 from twisted.application import service 4 from twisted.application import service
5 from twisted.python import usage 5 from twisted.python import usage
6 from twisted.words.protocols.jabber.jid import JID 6 from twisted.words.protocols.jabber.jid import JID
35 35
36 def postOptions(self): 36 def postOptions(self):
37 if self['backend'] not in ['pgsql', 'memory']: 37 if self['backend'] not in ['pgsql', 'memory']:
38 raise usage.UsageError, "Unknown backend!" 38 raise usage.UsageError, "Unknown backend!"
39 39
40 self['jid'] = JID(self['jid'])
41
40 def makeService(config): 42 def makeService(config):
41 s = service.MultiService() 43 s = service.MultiService()
42 44
43 # Create backend service with storage 45 # Create backend service with storage
44 46
52 elif config['backend'] == 'memory': 54 elif config['backend'] == 'memory':
53 from idavoll.memory_storage import Storage 55 from idavoll.memory_storage import Storage
54 st = Storage() 56 st = Storage()
55 57
56 bs = BackendService(st) 58 bs = BackendService(st)
59 bs.setName('backend')
57 bs.setServiceParent(s) 60 bs.setServiceParent(s)
58 61
59 # Set up XMPP server-side component with publish-subscribe capabilities 62 # Set up XMPP server-side component with publish-subscribe capabilities
60 63
61 cs = Component(config["rhost"], int(config["rport"]), 64 cs = Component(config["rhost"], int(config["rport"]),
62 config["jid"], config["secret"]) 65 config["jid"].full(), config["secret"])
66 cs.setName('component')
63 cs.setServiceParent(s) 67 cs.setServiceParent(s)
64 68
65 cs.factory.maxDelay = 900 69 cs.factory.maxDelay = 900
66 70
67 if config["verbose"]: 71 if config["verbose"]:
72 DiscoHandler().setHandlerParent(cs) 76 DiscoHandler().setHandlerParent(cs)
73 77
74 ps = IPubSubService(bs) 78 ps = IPubSubService(bs)
75 ps.setHandlerParent(cs) 79 ps.setHandlerParent(cs)
76 ps.hideNodes = config["hide-nodes"] 80 ps.hideNodes = config["hide-nodes"]
77 ps.serviceJID = JID(config["jid"]) 81 ps.serviceJID = config["jid"]
78 82
79 return s 83 return s