aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2012-08-02 07:39:00 +0200
committerChristian Weiske <cweiske@cweiske.de>2012-08-02 07:39:00 +0200
commit8e42bcadf70dffd3e6cdf52c5582ce7fd0dce868 (patch)
tree8d7b85a2c99477eb369c7ec0bd8072be2089055c /src
parent0ecfe5252028e1d2da82bc1ebe48307df288a611 (diff)
downloadauerswald-callnotifier-8e42bcadf70dffd3e6cdf52c5582ce7fd0dce868.tar.gz
auerswald-callnotifier-8e42bcadf70dffd3e6cdf52c5582ce7fd0dce868.zip
add incoming/outgoing type to calls
Diffstat (limited to 'src')
-rw-r--r--src/callnotifier/CLI.php2
-rw-r--r--src/callnotifier/CallMonitor.php8
-rw-r--r--src/callnotifier/CallMonitor/Call.php11
-rw-r--r--src/callnotifier/Log.php2
-rw-r--r--src/callnotifier/Logger/CallEcho.php18
5 files changed, 33 insertions, 8 deletions
diff --git a/src/callnotifier/CLI.php b/src/callnotifier/CLI.php
index 6ec9a7e..2a6d3ca 100644
--- a/src/callnotifier/CLI.php
+++ b/src/callnotifier/CLI.php
@@ -32,7 +32,7 @@ class CLI
}
}
$log->addLogger(
- new Logger_CallEcho(), array('incomingCall', 'finishedCall')
+ new Logger_CallEcho(), array('startingCall', 'finishedCall')
);
$callMonitor = new CallMonitor($this->config, $log);
diff --git a/src/callnotifier/CallMonitor.php b/src/callnotifier/CallMonitor.php
index af72e0a..29ee5a2 100644
--- a/src/callnotifier/CallMonitor.php
+++ b/src/callnotifier/CallMonitor.php
@@ -43,6 +43,12 @@ class CallMonitor
{
$call = $this->currentCalls[$callId];
$call->start = time();
+ if ($msg->tei == 127) {
+ $call->type = CallMonitor_Call::INCOMING;
+ } else {
+ $call->type = CallMonitor_Call::OUTGOING;
+ }
+
$this->handleParams($call, $msg);
}
@@ -56,7 +62,7 @@ class CallMonitor
$this->handleParams($call, $msg);
break;
case EDSS1_Message::CALL_PROCEEDING:
- $this->log->log('incomingCall', array('call' => $call));
+ $this->log->log('startingCall', array('call' => $call));
break;
case EDSS1_Message::RELEASE:
diff --git a/src/callnotifier/CallMonitor/Call.php b/src/callnotifier/CallMonitor/Call.php
index 3ebd251..0f16ead 100644
--- a/src/callnotifier/CallMonitor/Call.php
+++ b/src/callnotifier/CallMonitor/Call.php
@@ -3,6 +3,17 @@ namespace callnotifier;
class CallMonitor_Call
{
+ const INCOMING = 'i';
+ const OUTGOING = 'o';
+
+ /**
+ * Type of call: "i"ncoming or "o"utgoing
+ *
+ * @var string
+ */
+ public $type;
+
+
/**
* Telephone number of caller
*
diff --git a/src/callnotifier/Log.php b/src/callnotifier/Log.php
index 8a6b79a..d2ee0c8 100644
--- a/src/callnotifier/Log.php
+++ b/src/callnotifier/Log.php
@@ -13,7 +13,7 @@ class Log
protected $logger = array(
'msgData' => array(),
'edss1msg' => array(),
- 'incomingCall' => array(),
+ 'startingCall' => array(),
'finishedCall' => array(),
);
diff --git a/src/callnotifier/Logger/CallEcho.php b/src/callnotifier/Logger/CallEcho.php
index fe8b9b4..825bc24 100644
--- a/src/callnotifier/Logger/CallEcho.php
+++ b/src/callnotifier/Logger/CallEcho.php
@@ -6,8 +6,8 @@ class Logger_CallEcho implements Logger
public function log($type, $arData)
{
switch ($type) {
- case 'incomingCall':
- $this->displayIncoming($arData['call']);
+ case 'startingCall':
+ $this->displayStart($arData['call']);
break;
case 'finishedCall':
$this->displayFinished($arData['call']);
@@ -16,18 +16,26 @@ class Logger_CallEcho implements Logger
}
- protected function displayIncoming(CallMonitor_Call $call)
+ protected function displayStart(CallMonitor_Call $call)
{
- echo 'Incoming call from ' . $call->from
+ echo 'Starting ' . $this->getTypeName($call)
+ . ' call from ' . $call->from
. ' to ' . $call->to . "\n";
}
protected function displayFinished(CallMonitor_Call $call)
{
- echo 'Finished call from ' . $call->from
+ echo 'Finished ' . $this->getTypeName($call)
+ . ' call from ' . $call->from
. ' to ' . $call->to
. ', length ' . date('H:i:s', $call->end - $call->start - 3600)
. "\n";
}
+
+ protected function getTypeName($call)
+ {
+ return $call->type == CallMonitor_Call::INCOMING
+ ? 'incoming' : 'outgoing';
+ }
}
?>