Initial import to Tizen
[profile/ivi/python-twisted.git] / twisted / words / xmpproutertap.py
1 # -*- test-case-name: twisted.words.test.test_xmpproutertap -*-
2 #
3 # Copyright (c) Twisted Matrix Laboratories.
4 # See LICENSE for details.
5
6 from twisted.application import strports
7 from twisted.python import usage
8 from twisted.words.protocols.jabber import component
9
10 class Options(usage.Options):
11     optParameters = [
12             ('port', None, 'tcp:5347:interface=127.0.0.1',
13                            'Port components connect to'),
14             ('secret', None, 'secret', 'Router secret'),
15     ]
16
17     optFlags = [
18             ('verbose', 'v', 'Log traffic'),
19     ]
20
21
22
23 def makeService(config):
24     router = component.Router()
25     factory = component.XMPPComponentServerFactory(router, config['secret'])
26
27     if config['verbose']:
28         factory.logTraffic = True
29
30     return strports.service(config['port'], factory)