2 namespace callnotifier;
10 public function __construct()
17 $this->config = new Config();
19 $result = $this->cliParser->parse();
20 } catch (\Exception $exc) {
21 $this->cliParser->displayError($exc->getMessage());
24 $this->fillConfig($this->config, $result);
27 if ($result->options['debug'] || $result->options['debugEdss1']) {
28 $debugLogger = new Logger_Debug();
29 $log->addLogger($debugLogger, '*');
30 if ($result->options['debugEdss1']) {
31 $debugLogger->edss1MsgOnly = true;
35 new Logger_CallEcho(), array('startingCall', 'finishedCall')
38 $callMonitor = new CallMonitor($this->config, $log);
39 $callMonitor->addDetailler(new CallMonitor_Detailler_LDAP());
40 $callMonitor->addDetailler(new CallMonitor_Detailler_OpenGeoDb());
42 $handler = new MessageHandler($this->config, $log, $callMonitor);
44 if ($this->config->replayFile !== null) {
45 $sourceClass = 'callnotifier\Source_File';
47 $sourceClass = 'callnotifier\Source_Remote';
49 $source = new $sourceClass($this->config, $handler);
53 public function setupCli()
55 $p = new \Console_CommandLine();
56 $p->description = 'Notifies about incoming calls on an Auerswald COMpact 3000';
57 $p->version = '0.0.1';
63 'long_name' => '--host',
64 'description' => 'IP of COMpact 3000',
66 'action' => 'StoreString'
73 'long_name' => '--dump',
74 'description' => 'dump messages into file for later replay',
75 'help_name' => 'FILE',
76 'action' => 'StoreString'
82 'long_name' => '--replay',
83 'description' => "Replay messages from file instead from network",
84 'help_name' => 'FILE',
85 'action' => 'StoreString'
93 'long_name' => '--debug',
94 'description' => "Debug mode: Echo all received messages and events",
95 'action' => 'StoreTrue'
101 'short_name' => '-e',
102 'long_name' => '--debug-edss1',
103 'description' => "Debug mode: Show EDSS1 messages only",
104 'action' => 'StoreTrue'
108 $this->cliParser = $p;
111 protected function fillConfig($config, $result)
113 $config->setIfNotEmpty('host', $result->options['host']);
114 $config->setIfNotEmpty('dumpFile', $result->options['dumpFile']);
115 $config->setIfNotEmpty('replayFile', $result->options['replayFile']);