X-Git-Url: https://git.cweiske.de/auerswald-callnotifier.git/blobdiff_plain/b8217d4cb0bdfea171cde633b0a196fc7dfd4a9d..1b28b0289cdcb6adcbd496be07fda3a5ec705bfd:/src/callnotifier/CallMonitor.php?ds=sidebyside diff --git a/src/callnotifier/CallMonitor.php b/src/callnotifier/CallMonitor.php index 428136f..4923967 100644 --- a/src/callnotifier/CallMonitor.php +++ b/src/callnotifier/CallMonitor.php @@ -13,12 +13,24 @@ class CallMonitor { protected $currentCalls = array(); + /** + * Array of objects that are able to load details for a call + * + * @var array + */ + protected $detaillers = array(); + public function __construct($config, $log) { $this->config = $config; $this->log = $log; } + public function addDetailler(CallMonitor_Detailler $detailler) + { + $this->detaillers[] = $detailler; + } + public function handle(EDSS1_Message $msg) { $callId = $msg->callRef; @@ -82,12 +94,16 @@ class CallMonitor unset($this->currentCalls[$otherCallId]); } } + $this->loadCallDetails($call); $this->log->log('startingCall', array('call' => $call)); break; case EDSS1_Message::RELEASE: case EDSS1_Message::RELEASE_COMPLETE: $call->end = time(); + //we need to load details here because they might not have been + //loaded yet, e.g. for calls to MSNs that have no phones. + $this->loadCallDetails($call); $this->log->log('finishedCall', array('call' => $call)); unset($this->currentCalls[$callId]); break; @@ -128,9 +144,24 @@ class CallMonitor { if ($type == EDSS1_Parameter_Names::NUMBER_NATIONAL) { return '0' . $number; + } else if ($type == EDSS1_Parameter_Names::NUMBER_INTERNATIONAL) { + return '+' . $number; } return $number; } + + /** + * Load details for a call, e.g. the name of the calling person + * or the area + * + * @return void + */ + protected function loadCallDetails($call) + { + foreach ($this->detaillers as $detailler) { + $detailler->loadCallDetails($call); + } + } } ?>