diff options
author | James Bottomley <JBottomley@Parallels.com> | 2013-05-03 23:33:18 -0700 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2013-05-03 23:33:18 -0700 |
commit | c6d38e91994cf6e6c19b8fc0659ca89a1ee05aec (patch) | |
tree | 50e398b8a9abd5202f9137b98144a983a3460144 | |
parent | 7ff500a432bffa9c81e985ddc359fb371d69941a (diff) | |
download | asterisk-aastra-c6d38e91994cf6e6c19b8fc0659ca89a1ee05aec.tar.gz |
Voicemail: add pause and resume to playback
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r-- | include/BaseAastra.class.php | 2 | ||||
-rw-r--r-- | include/Voicemail.class.php | 83 |
2 files changed, 71 insertions, 14 deletions
diff --git a/include/BaseAastra.class.php b/include/BaseAastra.class.php index 1e98459..b01a845 100644 --- a/include/BaseAastra.class.php +++ b/include/BaseAastra.class.php @@ -61,6 +61,7 @@ abstract class BaseAastra { $this->do->addEntry(''); $this->do->setTriggerDestroyOnExit(); } + $this->do->setTitle($this->title); $this->do->output(); } @@ -95,7 +96,6 @@ abstract class BaseAastra { function displayObject($o) { $this->do = $o; - $o->setTitle($this->title); $o->setDestroyOnExit(); if($this->back) { $o->setCancelAction($this->back); diff --git a/include/Voicemail.class.php b/include/Voicemail.class.php index 01def46..9b9c9b6 100644 --- a/include/Voicemail.class.php +++ b/include/Voicemail.class.php @@ -2,6 +2,7 @@ require_once('BaseAastra.class.php'); require_once('AastraIPPhoneTextScreen.class.php'); require_once('VoicemailListManager.class.php'); +require_once('AastraIPPhoneExecute.class.php'); class Voicemail extends BaseAastra { @@ -54,30 +55,86 @@ class Voicemail extends BaseAastra { $this->__initvar(); } + ## + # State diagram of voicemail play + ## + + function play_override($box, $msg) { + $this->asm->database_put('vmail', $this->user, $this->path.'/'.$box.'/'.$msg); + $this->displayObject( new AastraIPPhoneExecute()); + $this->do->addEntry('Dial:vmail'); + $this->do->addEntry($this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=playing'); + $this->do->setTriggerDestroyOnExit(); + $this->setActionHandler('onhook',$this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=stopped'); + } + + function stop_override($box, $msg) { + $this->displayObject( new AastraIPPhoneExecute()); + $this->do->addEntry('SoftKey:Drop'); + # no URL, next transition done by onhook app to stopped state + $this->do->setTriggerDestroyOnExit(); + } + + function pause_override($box, $msg) { + $this->displayObject( new AastraIPPhoneExecute()); + $this->do->addEntry('Key:KeyPad1'); + $this->do->addEntry($this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=paused'); + $this->do->setTriggerDestroyOnExit(); + } + + function resume_override($box, $msg) { + $this->displayObject( new AastraIPPhoneExecute()); + $this->do->addEntry('Key:KeyPad1'); + $this->do->addEntry($this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=playing'); + $this->do->setTriggerDestroyOnExit(); + } + + function playing($box, $msg, $i) { + $this->title = 'Playing Voicemail '.$box.' Message: '.$i; + $this->do->addSoftkey(2, 'Stop', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=stop'); + $this->do->addSoftkey(1, 'Pause', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=pause'); + $this->do->setAllowDrop(); + } + + function paused($box, $msg, $i) { + $this->title = 'Paused Voicemail '.$box.' Message: '.$i; + $this->do->addSoftkey(2, 'Stop', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=stop'); + $this->do->addSoftkey(1, 'Resume', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=resume'); + $this->do->setAllowDrop(); + } + + function stopped($box, $msg, $i) { + $this->delActionHandler('onhook'); + $this->message_start($box, $msg, $i); + } + + function message_start($box, $msg, $i) { + $this->do->addSoftkey(1, 'Play', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=play'); + $this->title = 'Voicemail '.$box.' Message: '.$i; + } + function message() { $box = $_GET['box']; $msg = $_GET['msg']; - if (isset($_GET['play'])) { - $this->asm->database_put('vmail', $this->user, $this->path.'/'.$box.'/'.$msg); - require_once('AastraIPPhoneExecute.class.php'); - $this->displayObject( new AastraIPPhoneExecute()); - $this->do->addEntry('Dial:vmail'); - $this->setActionHandler('outgoing',$this->url.'?action=message&box='.$box.'&msg='.$msg.'&playing=1'); - return; + $ordinary='message_start'; + if (isset($_GET['state'])) { + $override = $_GET['state'].'_override'; + if (method_exists($this, $override)) { + $this->$override($box, $msg); + return; + } + if (method_exists($this, $_GET['state'])) { + $ordinary = $_GET['state']; + } } - $this->back = $this->url.'?action=mailbox&box='.$box; preg_match('/^msg(\d*)$/', $msg, $m); $i = intval($m[1]) + 1; $c = new ConfigFile($this->path.'/'.$box.'/'.$msg.'.txt'); $m = $c->section('message'); - $this->title = 'Mailbox '.$box.' Message: '.$i; $this->displayObject(new AastraIPPhoneTextScreen()); $this->do->setText('Received: '.$m['origdate'].' From: '.$m['callerid'].' length '.$m['duration'].' seconds'); - $this->do->addSoftkey(1, 'Play', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&play=1'); - if (isset($_GET['playing'])) { - $this->do->addSoftkey(2, 'Stop', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&play=1'); - } + $this->$ordinary($box, $msg, $i); } function mailbox() { |