aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Bottomley <JBottomley@Parallels.com>2013-05-10 13:52:12 -0700
committerJames Bottomley <JBottomley@Parallels.com>2013-05-10 13:52:12 -0700
commitbbf40e92faf8891b1d6a3937e18093885ba22a13 (patch)
tree6e4d81bdd39b8a89d677b9d9ffcd8eac9be31314
parente3fdb2eb7f00060886da399d2938a7cb07407c14 (diff)
downloadasterisk-aastra-bbf40e92faf8891b1d6a3937e18093885ba22a13.tar.gz
Voicemail: Final updates for usability
Junk the pause/resume functionality because the 6739i is a bit buggy when it comes to sending DTMF via execute XML. Do stop from the AMI hangup. When the user presses back on a listened to INBOX message, move it to Old Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--etc/extensions-voicemail.conf10
-rw-r--r--include/Voicemail.class.php88
2 files changed, 44 insertions, 54 deletions
diff --git a/etc/extensions-voicemail.conf b/etc/extensions-voicemail.conf
index 68563b6..95a2389 100644
--- a/etc/extensions-voicemail.conf
+++ b/etc/extensions-voicemail.conf
@@ -3,5 +3,13 @@
; individual messages
;
exten => vmail,1,Set(file=${DB(vmail/${CALLERID(num)})})
-exten => vmail,n,ControlPlayback(${file})
+exten => vmail,n,Set(DB(vmail/chan-${CALLERID(num)})=${CHANNEL})
+exten => vmail,n,Noop(file is '${file}')
+exten => vmail,n,ControlPlayback(${file},4000,*,#,0,1,2)
+exten => vmail,n,Noop(${DB_DELETE(vmail/chan-${CALLERID(num)})})
exten => vmail,n,Hangup
+;
+; hangup handling is needed to delete the entry if the caller hangs up
+;
+exten => h,1,Noop(${DB_DELETE(vmail/chan-${CALLERID(num)})})
+
diff --git a/include/Voicemail.class.php b/include/Voicemail.class.php
index c1c78a5..37c58ec 100644
--- a/include/Voicemail.class.php
+++ b/include/Voicemail.class.php
@@ -79,6 +79,20 @@ class Voicemail extends BaseAastra {
unlink($this->path.'/'.$box.'/.lock');
}
+ function get_channel() {
+ $channel = null;
+ for ($i = 0; !$channel; $i++) {
+ $channel = $this->asm->database_get('vmail','chan-'.$this->user);
+ if (!$channel) {
+ $this->asm->wait_event(1);
+ }
+ if ($i > 10) {
+ throw new Exception("Timeout waiting for voicemail to play");
+ }
+ }
+ return $channel;
+ }
+
function locked_move($src, $msg, $dst) {
$this->lock($src);
$this->lock($dst);
@@ -95,7 +109,6 @@ class Voicemail extends BaseAastra {
$this->path.'/'.$dst.'/'.$y.'.'.$ext);
}
} else {
- error_log("box=$src, x=$x contents=".join(",",$this->box[$src][$x]));
foreach ($this->box[$src][$x] as $ext) {
unlink($this->path.'/'.$src.'/'.$x.'.'.$ext);
}
@@ -122,21 +135,13 @@ class Voicemail extends BaseAastra {
$this->do->addSoftkey(1, 'Play', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=play');
}
- function button_pause($box, $msg) {
- $this->do->addSoftkey(1, 'Pause', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=pause');
- }
-
- function button_resume($box, $msg) {
- $this->do->addSoftkey(1, 'Resume', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=resume');
- }
-
function button_stop($box, $msg) {
- $this->do->addSoftkey(2, 'Stop', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=stop');
+ $this->do->addSoftkey(1, 'Stop', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=stop');
}
function button_rest($box, $msg) {
- $this->do->addSoftkey(3, 'Delete', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=delete');
- $this->do->addSoftkey(4, 'Move', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=move');
+ $this->do->addSoftkey(2, 'Delete', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=delete');
+ $this->do->addSoftkey(3, 'Move', $this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=move');
}
@@ -144,7 +149,7 @@ class Voicemail extends BaseAastra {
# State diagram of voicemail play
##
- function play_override($box, $msg) {
+ function play_override($box, $msg, $i) {
$this->asm->database_put('vmail', $this->user, $this->path.'/'.$box.'/'.$msg);
$this->displayObject( new AastraIPPhoneExecute());
$this->do->addEntry('Dial:vmail');
@@ -153,48 +158,24 @@ class Voicemail extends BaseAastra {
$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) {
+ function stop_override($box, $msg, $i) {
+ $channel = $this->get_channel();
$this->displayObject( new AastraIPPhoneExecute());
- $this->do->addEntry('Key:KeyPad1');
- $this->do->addEntry($this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=playing');
+ # nop action: next transition done by onhook event
+ $this->do->addEntry(' ');
$this->do->setTriggerDestroyOnExit();
+ $err = $this->asm->hangup($channel);
}
function playing($box, $msg, $i) {
$this->title = 'Playing Voicemail '.$box.' Message: '.$i;
$this->do->setAllowDrop();
- $this->button_pause($box, $msg);
$this->button_stop($box, $msg);
$this->button_rest($box, $msg);
}
- function paused($box, $msg, $i) {
- $this->title = 'Paused Voicemail '.$box.' Message: '.$i;
- $this->do->setAllowDrop();
- $this->button_resume($box, $msg);
- $this->button_rest($box, $msg);
- }
-
- function stopped_override($box, $msg) {
+ function stopped_override($box, $msg, $i) {
$this->delActionHandler('onhook');
- if ($box == 'INBOX') {
- # move listened new messages to old messages
- $this->locked_move($box, $i - 1, 'Old');
- }
$this->displayObject( new AastraIPPhoneExecute());
$this->do->addEntry($this->url.'?action=message&box='.$box.'&msg='.$msg);
$this->do->setTriggerDestroyOnExit();
@@ -212,12 +193,11 @@ class Voicemail extends BaseAastra {
$this->title = 'Delete Message: '.$i.' in mailbox '.$box.'?';
}
- function really_delete_override($box, $msg) {
+ function really_delete_override($box, $msg, $i) {
$this->displayObject( new AastraIPPhoneExecute());
$this->do->addEntry($this->url.'?action=message&box='.$box.'&msg='.$msg);
$this->do->setTriggerDestroyOnExit();
- preg_match('/^msg(\d*)$/', $msg, $m);
- $this->locked_move($box, intval($m[1]), null);
+ $this->locked_move($box, $i - 1, null);
}
function move($box, $msg, $i) {
@@ -228,16 +208,14 @@ class Voicemail extends BaseAastra {
}
}
- function move_to_override($box, $msg) {
+ function move_to_override($box, $msg, $i) {
if (!isset($_GET['dst'])) {
return;
}
$this->displayObject( new AastraIPPhoneExecute());
- $this->do->addEntry('Key:KeyPad1');
$this->do->addEntry($this->url.'?action=message&box='.$box.'&msg='.$msg);
$this->do->setTriggerDestroyOnExit();
- preg_match('/^msg(\d*)$/', $msg, $m);
- $this->locked_move($box, intval($m[1]), $_GET['dst']);
+ $this->locked_move($box, $i - 1, $_GET['dst']);
}
function message() {
@@ -246,7 +224,7 @@ class Voicemail extends BaseAastra {
$this->displayObject(new AastraIPPhoneTextScreen());
$this->title = 'Mailbox '.$box;
$this->do->setText('is empty');
- error_log("EMPTY");
+ $this->back = $this->url;
return;
}
$msg = $_GET['msg'];
@@ -260,14 +238,18 @@ class Voicemail extends BaseAastra {
if (isset($_GET['state'])) {
$override = $_GET['state'].'_override';
if (method_exists($this, $override)) {
- $this->$override($box, $msg);
+ $this->$override($box, $msg, $i);
return;
}
if (method_exists($this, $_GET['state'])) {
$ordinary = $_GET['state'];
}
}
- $this->back = $this->url.'?action=mailbox&box='.$box;
+ if ($box == 'INBOX') {
+ $this->back = $this->url.'?action=message&box='.$box.'&msg='.$msg.'&state=move_to&dst=Old';
+ } else {
+ $this->back = $this->url.'?action=mailbox&box='.$box;
+ }
$c = new ConfigFile($this->path.'/'.$box.'/'.$msg.'.txt');
$m = $c->section('message');
$this->displayObject(new AastraIPPhoneTextScreen());