diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2012-08-10 20:17:08 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2012-08-10 20:17:08 +0200 |
| commit | b573abf6378e6d1b5c3df37c5aed40e5a2d49fc6 (patch) | |
| tree | ffaa5439f29fc85366541bd951efc6806b32d4bc /src/callnotifier/Logger/CallNotifySend.php | |
| parent | e839909cbd2ac51620fa1607d92b8b6d5a54f837 (diff) | |
| download | auerswald-callnotifier-b573abf6378e6d1b5c3df37c5aed40e5a2d49fc6.tar.gz auerswald-callnotifier-b573abf6378e6d1b5c3df37c5aed40e5a2d49fc6.zip | |
notify user with notify-send
Diffstat (limited to 'src/callnotifier/Logger/CallNotifySend.php')
| -rw-r--r-- | src/callnotifier/Logger/CallNotifySend.php | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/callnotifier/Logger/CallNotifySend.php b/src/callnotifier/Logger/CallNotifySend.php new file mode 100644 index 0000000..d5cb9dd --- /dev/null +++ b/src/callnotifier/Logger/CallNotifySend.php @@ -0,0 +1,65 @@ +<?php +namespace callnotifier; + +class Logger_CallNotifySend extends Logger_CallBase +{ + public function log($type, $arData) + { + switch ($type) { + case 'startingCall': + $this->displayStart($arData['call']); + break; + case 'finishedCall': + $this->displayFinished($arData['call']); + break; + } + } + + + protected function displayStart(CallMonitor_Call $call) + { + $this->addUnsetVars($call); + if ($call->type == CallMonitor_Call::INCOMING) { + $this->notify( + trim($this->getNumberString($call, 'from')), + 'Incoming call' + ); + } else { + $this->notify( + trim($this->getNumberString($call, 'to')), + 'Outgoing call' + ); + } + } + + protected function displayFinished(CallMonitor_Call $call) + { + $this->addUnsetVars($call); + if ($call->type == CallMonitor_Call::INCOMING) { + $title = trim($this->getNumberString($call, 'from')); + $msg = 'End of incoming call'; + } else { + $title = trim($this->getNumberString($call, 'to')); + $msg = 'End of outgoing call'; + } + $this->notify( + $title, + $msg + . ', length ' . date('H:i:s', $call->end - $call->start - 3600) + ); + } + + protected function notify($title, $msg) + { + exec( + 'notify-send' + . ' -u low' + . ' --expire-time=1000' + . ' -i phone' + . ' -c callmonitor' + . ' ' . escapeshellarg($title) + . ' ' . escapeshellarg($msg) + ); + } +} +?> |
