[asterisk-commits] kpfleming: branch jdixon/chan_usbradio-1.4 r114812 - in /team/jdixon/chan_usb...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Apr 28 16:13:13 CDT 2008
Author: kpfleming
Date: Mon Apr 28 16:13:13 2008
New Revision: 114812
URL: http://svn.digium.com/view/asterisk?view=rev&rev=114812
Log:
resolve, reset once again
Modified:
team/jdixon/chan_usbradio-1.4/ (props changed)
team/jdixon/chan_usbradio-1.4/apps/app_chanspy.c
team/jdixon/chan_usbradio-1.4/apps/app_queue.c
team/jdixon/chan_usbradio-1.4/apps/app_voicemail.c
team/jdixon/chan_usbradio-1.4/channels/chan_gtalk.c
team/jdixon/chan_usbradio-1.4/channels/chan_iax2.c
team/jdixon/chan_usbradio-1.4/channels/chan_local.c
team/jdixon/chan_usbradio-1.4/channels/chan_sip.c
team/jdixon/chan_usbradio-1.4/configs/iax.conf.sample
team/jdixon/chan_usbradio-1.4/configs/iaxprov.conf.sample
team/jdixon/chan_usbradio-1.4/configs/sip.conf.sample
team/jdixon/chan_usbradio-1.4/configs/zapata.conf.sample
team/jdixon/chan_usbradio-1.4/configure
team/jdixon/chan_usbradio-1.4/configure.ac
team/jdixon/chan_usbradio-1.4/contrib/scripts/vmail.cgi
Propchange: team/jdixon/chan_usbradio-1.4/
------------------------------------------------------------------------------
automerge = yes
Propchange: team/jdixon/chan_usbradio-1.4/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Apr 28 16:13:13 2008
@@ -1,1 +1,1 @@
-/branches/1.4:1-82381,82383-114611
+/branches/1.4:1-82381,82383-114811
Modified: team/jdixon/chan_usbradio-1.4/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/apps/app_chanspy.c?view=diff&rev=114812&r1=114811&r2=114812
==============================================================================
--- team/jdixon/chan_usbradio-1.4/apps/app_chanspy.c (original)
+++ team/jdixon/chan_usbradio-1.4/apps/app_chanspy.c Mon Apr 28 16:13:13 2008
@@ -208,12 +208,9 @@
res = ast_audiohook_attach(chan, audiohook);
- if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan))) {
- ast_channel_unlock(chan);
+ if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan))) {
ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE);
- } else
- ast_channel_unlock(chan);
-
+ }
return res;
}
@@ -263,16 +260,18 @@
ast_audiohook_init(&csth.spy_audiohook, AST_AUDIOHOOK_TYPE_SPY, "ChanSpy");
- if (start_spying(spyee, spyer_name, &csth.spy_audiohook)) { /* Unlocks spyee */
+ if (start_spying(spyee, spyer_name, &csth.spy_audiohook)) {
ast_audiohook_destroy(&csth.spy_audiohook);
+ ast_channel_unlock(spyee);
return 0;
}
if (ast_test_flag(flags, OPTION_WHISPER)) {
ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy");
- start_spying(spyee, spyer_name, &csth.whisper_audiohook); /* Unlocks spyee */
- }
-
+ start_spying(spyee, spyer_name, &csth.whisper_audiohook);
+ }
+
+ ast_channel_unlock(spyee);
spyee = NULL;
csth.volfactor = *volfactor;
Modified: team/jdixon/chan_usbradio-1.4/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/apps/app_queue.c?view=diff&rev=114812&r1=114811&r2=114812
==============================================================================
--- team/jdixon/chan_usbradio-1.4/apps/app_queue.c (original)
+++ team/jdixon/chan_usbradio-1.4/apps/app_queue.c Mon Apr 28 16:13:13 2008
@@ -1761,10 +1761,10 @@
j += 9;
}
}
- if (j > len - 1)
- j = len - 1;
- vars[j - 2] = '\r';
- vars[j - 1] = '\n';
+ if (j > len - 3)
+ j = len - 3;
+ vars[j++] = '\r';
+ vars[j++] = '\n';
vars[j] = '\0';
} else {
/* there are no channel variables; leave it blank */
Modified: team/jdixon/chan_usbradio-1.4/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/apps/app_voicemail.c?view=diff&rev=114812&r1=114811&r2=114812
==============================================================================
--- team/jdixon/chan_usbradio-1.4/apps/app_voicemail.c (original)
+++ team/jdixon/chan_usbradio-1.4/apps/app_voicemail.c Mon Apr 28 16:13:13 2008
@@ -7933,8 +7933,13 @@
char *adsi_loaded = ast_module_helper("", "res_adsi.so", 0, 0, 0, 0);
free(adsi_loaded);
if (!adsi_loaded) {
- ast_log(LOG_ERROR, "app_voicemail.so depends upon res_adsi.so\n");
- return AST_MODULE_LOAD_DECLINE;
+ /* If embedded, res_adsi may be known as "res_adsi" not "res_adsi.so" */
+ adsi_loaded = ast_module_helper("", "res_adsi", 0, 0, 0, 0);
+ ast_free(adsi_loaded);
+ if (!adsi_loaded) {
+ ast_log(LOG_ERROR, "app_voicemail.so depends upon res_adsi.so\n");
+ return AST_MODULE_LOAD_DECLINE;
+ }
}
my_umask = umask(0);
Modified: team/jdixon/chan_usbradio-1.4/channels/chan_gtalk.c
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/channels/chan_gtalk.c?view=diff&rev=114812&r1=114811&r2=114812
==============================================================================
--- team/jdixon/chan_usbradio-1.4/channels/chan_gtalk.c (original)
+++ team/jdixon/chan_usbradio-1.4/channels/chan_gtalk.c Mon Apr 28 16:13:13 2008
@@ -1961,8 +1961,13 @@
char *jabber_loaded = ast_module_helper("", "res_jabber.so", 0, 0, 0, 0);
free(jabber_loaded);
if (!jabber_loaded) {
- ast_log(LOG_ERROR, "chan_gtalk.so depends upon res_jabber.so\n");
- return AST_MODULE_LOAD_DECLINE;
+ /* If embedded, check for a different module name */
+ jabber_loaded = ast_module_helper("", "res_jabber", 0, 0, 0, 0);
+ free(jabber_loaded);
+ if (!jabber_loaded) {
+ ast_log(LOG_ERROR, "chan_gtalk.so depends upon res_jabber.so\n");
+ return AST_MODULE_LOAD_DECLINE;
+ }
}
#ifdef HAVE_GNUTLS
Modified: team/jdixon/chan_usbradio-1.4/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/channels/chan_iax2.c?view=diff&rev=114812&r1=114811&r2=114812
==============================================================================
--- team/jdixon/chan_usbradio-1.4/channels/chan_iax2.c (original)
+++ team/jdixon/chan_usbradio-1.4/channels/chan_iax2.c Mon Apr 28 16:13:13 2008
@@ -1345,7 +1345,7 @@
if (new <= NEW_ALLOW) {
/* Look for an existing connection first */
- for (x=1;(res < 1) && (x<maxnontrunkcall);x++) {
+ for (x = 1; !res && x < maxnontrunkcall; x++) {
ast_mutex_lock(&iaxsl[x]);
if (iaxs[x]) {
/* Look for an exact match */
@@ -1353,10 +1353,10 @@
res = x;
}
}
- if (!res || (res && !return_locked))
+ if (!res || !return_locked)
ast_mutex_unlock(&iaxsl[x]);
}
- for (x=TRUNK_CALL_START;(res < 1) && (x<maxtrunkcall);x++) {
+ for (x = TRUNK_CALL_START; !res && x < maxtrunkcall; x++) {
ast_mutex_lock(&iaxsl[x]);
if (iaxs[x]) {
/* Look for an exact match */
@@ -1364,11 +1364,11 @@
res = x;
}
}
- if (!res || (res && !return_locked))
+ if (!res || !return_locked)
ast_mutex_unlock(&iaxsl[x]);
}
}
- if ((res < 1) && (new >= NEW_ALLOW)) {
+ if (!res && (new >= NEW_ALLOW)) {
int start, found = 0;
/* It may seem odd that we look through the peer list for a name for
Modified: team/jdixon/chan_usbradio-1.4/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/channels/chan_local.c?view=diff&rev=114812&r1=114811&r2=114812
==============================================================================
--- team/jdixon/chan_usbradio-1.4/channels/chan_local.c (original)
+++ team/jdixon/chan_usbradio-1.4/channels/chan_local.c Mon Apr 28 16:13:13 2008
@@ -471,6 +471,7 @@
p->chan->cid.cid_pres = p->owner->cid.cid_pres;
ast_string_field_set(p->chan, language, p->owner->language);
ast_string_field_set(p->chan, accountcode, p->owner->accountcode);
+ ast_cdr_update(p->chan);
p->chan->cdrflags = p->owner->cdrflags;
/* copy the channel variables from the incoming channel to the outgoing channel */
@@ -514,7 +515,13 @@
/* Deadlock avoidance */
while (p->owner && ast_channel_trylock(p->owner)) {
ast_mutex_unlock(&p->lock);
+ if (ast) {
+ ast_channel_unlock(ast);
+ }
usleep(1);
+ if (ast) {
+ ast_channel_lock(ast);
+ }
ast_mutex_lock(&p->lock);
}
if (p->owner) {
Modified: team/jdixon/chan_usbradio-1.4/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/channels/chan_sip.c?view=diff&rev=114812&r1=114811&r2=114812
==============================================================================
--- team/jdixon/chan_usbradio-1.4/channels/chan_sip.c (original)
+++ team/jdixon/chan_usbradio-1.4/channels/chan_sip.c Mon Apr 28 16:13:13 2008
@@ -3804,6 +3804,13 @@
ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, p->owner);
else {
p->owner = newchan;
+ /* Re-invite RTP back to Asterisk. Needed if channel is masqueraded out of a native
+ RTP bridge (i.e., RTP not going through Asterisk): RTP bridge code might not be
+ able to do this if the masquerade happens before the bridge breaks (e.g., AMI
+ redirect of both channels). Note that a channel can not be masqueraded *into*
+ a native bridge. So there is no danger that this breaks a native bridge that
+ should stay up. */
+ sip_set_rtp_peer(newchan, NULL, NULL, 0, 0);
ret = 0;
}
if (option_debug > 2)
Modified: team/jdixon/chan_usbradio-1.4/configs/iax.conf.sample
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/configs/iax.conf.sample?view=diff&rev=114812&r1=114811&r2=114812
==============================================================================
--- team/jdixon/chan_usbradio-1.4/configs/iax.conf.sample (original)
+++ team/jdixon/chan_usbradio-1.4/configs/iax.conf.sample Mon Apr 28 16:13:13 2008
@@ -198,7 +198,7 @@
;
;authdebug=no
;
-; See doc/README.tos for a description of the tos parameters.
+; See doc/ip-tos.txt for a description of the tos parameters.
;tos=ef
;
; If regcontext is specified, Asterisk will dynamically create and destroy
Modified: team/jdixon/chan_usbradio-1.4/configs/iaxprov.conf.sample
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/configs/iaxprov.conf.sample?view=diff&rev=114812&r1=114811&r2=114812
==============================================================================
--- team/jdixon/chan_usbradio-1.4/configs/iaxprov.conf.sample (original)
+++ team/jdixon/chan_usbradio-1.4/configs/iaxprov.conf.sample Mon Apr 28 16:13:13 2008
@@ -53,7 +53,7 @@
;
flags=register,heartbeat
;
-; See doc/README.tos for a description of this parameter.
+; See doc/ip-tos.txt for a description of this parameter.
;tos=ef
;
; Example iaxy provisioning
Modified: team/jdixon/chan_usbradio-1.4/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/configs/sip.conf.sample?view=diff&rev=114812&r1=114811&r2=114812
==============================================================================
--- team/jdixon/chan_usbradio-1.4/configs/sip.conf.sample (original)
+++ team/jdixon/chan_usbradio-1.4/configs/sip.conf.sample Mon Apr 28 16:13:13 2008
@@ -53,7 +53,7 @@
; and multiline formatted headers for strict
; SIP compatibility (defaults to "no")
-; See doc/README.tos for a description of these parameters.
+; See doc/ip-tos.txt for a description of these parameters.
;tos_sip=cs3 ; Sets TOS for SIP packets.
;tos_audio=ef ; Sets TOS for RTP audio packets.
;tos_video=af41 ; Sets TOS for RTP video packets.
@@ -567,7 +567,7 @@
;allow=g723.1 ; Asterisk only supports g723.1 pass-thru!
;allow=g729 ; Pass-thru only unless g729 license obtained
;callingpres=allowed_passed_screen ; Set caller ID presentation
- ; See README.callingpres for more information
+ ; See doc/callingpres.txt for more information
;[xlite1]
Modified: team/jdixon/chan_usbradio-1.4/configs/zapata.conf.sample
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/configs/zapata.conf.sample?view=diff&rev=114812&r1=114811&r2=114812
==============================================================================
--- team/jdixon/chan_usbradio-1.4/configs/zapata.conf.sample (original)
+++ team/jdixon/chan_usbradio-1.4/configs/zapata.conf.sample Mon Apr 28 16:13:13 2008
@@ -276,7 +276,7 @@
;
; Whether or not use the caller ID presentation for the outgoing call that the
; calling switch is sending.
-; See README.callingpres
+; See doc/callingpres.txt
;
usecallingpres=yes
;
Modified: team/jdixon/chan_usbradio-1.4/configure.ac
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/configure.ac?view=diff&rev=114812&r1=114811&r2=114812
==============================================================================
--- team/jdixon/chan_usbradio-1.4/configure.ac (original)
+++ team/jdixon/chan_usbradio-1.4/configure.ac Mon Apr 28 16:13:13 2008
@@ -1280,9 +1280,19 @@
AST_EXT_LIB_CHECK([FREETDS], [tds], [tds_version], [tds.h])
if test "${PBX_FREETDS}" != "0";
then
- case `grep TDS_VERSION_NO ${FREETDS_DIR:-/usr}/include/tdsver.h` in
- *0.64*)
- FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_64"
+ if test "${FREETDS_DIR}x" = "x";
+ then
+ for tds_dir in /usr /usr/local;
+ do
+ if test -f "${tds_dir}/include/tdsver.h";
+ then
+ FREETDS_DIR="${tds_dir}"
+ fi
+ done
+ fi
+ case `${GREP} TDS_VERSION_NO ${FREETDS_DIR:-/usr}/include/tdsver.h` in
+ *0.64*)
+ FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_64"
;;
*0.63*)
FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_63"
Modified: team/jdixon/chan_usbradio-1.4/contrib/scripts/vmail.cgi
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/contrib/scripts/vmail.cgi?view=diff&rev=114812&r1=114811&r2=114812
==============================================================================
--- team/jdixon/chan_usbradio-1.4/contrib/scripts/vmail.cgi (original)
+++ team/jdixon/chan_usbradio-1.4/contrib/scripts/vmail.cgi Mon Apr 28 16:13:13 2008
@@ -21,7 +21,7 @@
use Fcntl qw ( O_WRONLY O_CREAT O_EXCL );
use Time::HiRes qw ( usleep );
-$context=""; # Define here your by default context (so you dont need to put voicemail at context in the login
+$context=""; # Define here your by default context (so you dont need to put voicemail at context in the login)
@validfolders = ( "INBOX", "Old", "Work", "Family", "Friends", "Cust1", "Cust2", "Cust3", "Cust4", "Cust5" );
@@ -46,10 +46,10 @@
$astpath = "/_asterisk";
$stdcontainerstart = "<table align=center width=600><tr><td>\n";
-$footer = "<hr><font size=-1><a href=\"http://www.asterisk.org\">The Asterisk Open Source PBX</a> Copyright 2004, <a href=\"http://www.digium.com\">Digium, Inc.</a></a>";
+$footer = "<hr><font size=-1><a href=\"http://www.asterisk.org\">The Asterisk Open Source PBX</a> Copyright 2004-2008, <a href=\"http://www.digium.com\">Digium, Inc.</a></a>";
$stdcontainerend = "</td></tr><tr><td align=right>$footer</td></tr></table>\n";
-sub lock_path() {
+sub lock_path($) {
my($path) = @_;
my $rand;
@@ -80,14 +80,14 @@
}
}
-sub unlock_path() {
+sub unlock_path($) {
my($path) = @_;
unlink("$path/.lock");
}
-sub untaint() {
+sub untaint($) {
my($data) = @_;
@@ -100,7 +100,7 @@
return $data;
}
-sub login_screen() {
+sub login_screen($) {
print header;
my ($message) = @_;
print <<_EOH;
@@ -126,7 +126,7 @@
}
-sub check_login()
+sub check_login($$)
{
local ($filename, $startcat) = @_;
local ($mbox, $context) = split(/\@/, param('mailbox'));
@@ -160,28 +160,28 @@
}
} elsif (/\[(.*)\]/) {
$category = $1;
- } elsif ($category eq "general") {
- if (/([^\s]+)\s*\=\s*(.*)/) {
- if ($1 eq "dbname") {
- $dbname = $2;
- } elsif ($1 eq "dbpass") {
- $dbpass = $2;
- } elsif ($1 eq "dbhost") {
- $dbhost = $2;
- } elsif ($1 eq "dbuser") {
- $dbuser = $2;
- }
- }
- if ($dbname and $dbpass and $dbhost and $dbuser) {
-
- # db variables are present. Use db for authentication.
- my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost",$dbuser,$dbpass);
- my $sth = $dbh->prepare(qq{select fullname,context from voicemail where mailbox='$mbox' and password='$pass' and context='$context'});
- $sth->execute();
- if (($fullname, $category) = $sth->fetchrow_array()) {;
- return ($fullname ? $fullname : "Extension $mbox in $context",$category);
- }
- }
+ } elsif ($category eq "general") {
+ if (/([^\s]+)\s*\=\s*(.*)/) {
+ if ($1 eq "dbname") {
+ $dbname = $2;
+ } elsif ($1 eq "dbpass") {
+ $dbpass = $2;
+ } elsif ($1 eq "dbhost") {
+ $dbhost = $2;
+ } elsif ($1 eq "dbuser") {
+ $dbuser = $2;
+ }
+ }
+ if ($dbname and $dbpass and $dbhost and $dbuser) {
+
+ # db variables are present. Use db for authentication.
+ my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost",$dbuser,$dbpass);
+ my $sth = $dbh->prepare(qq{select fullname,context from voicemail where mailbox='$mbox' and password='$pass' and context='$context'});
+ $sth->execute();
+ if (($fullname, $category) = $sth->fetchrow_array()) {
+ return ($fullname ? $fullname : "Extension $mbox in $context",$category);
+ }
+ }
} elsif (($category ne "general") && ($category ne "zonemessages")) {
if (/([^\s]+)\s*\=\>?\s*(.*)/) {
@fields = split(/\,\s*/, $2);
@@ -196,7 +196,7 @@
return ("", $category);
}
-sub validmailbox()
+sub validmailbox($$$$)
{
local ($context, $mbox, $filename, $startcat) = @_;
local $category = $startcat;
@@ -215,7 +215,7 @@
$category = "general";
}
open(VMAIL, "<$filename") || die("Bleh, no $filename");
- while(<VMAIL>) {
+ while (<VMAIL>) {
chomp;
if (/include\s\"([^\"]+)\"$/) {
($tmp, $category) = &validmailbox($mbox, $context, "/etc/asterisk/$1");
@@ -224,28 +224,28 @@
}
} elsif (/\[(.*)\]/) {
$category = $1;
- } elsif ($category eq "general") {
- if (/([^\s]+)\s*\=\s*(.*)/) {
- if ($1 eq "dbname") {
- $dbname = $2;
- } elsif ($1 eq "dbpass") {
- $dbpass = $2;
- } elsif ($1 eq "dbhost") {
- $dbhost = $2;
- } elsif ($1 eq "dbuser") {
- $dbuser = $2;
- }
- }
- if ($dbname and $dbpass and $dbhost and $dbuser) {
-
- # db variables are present. Use db for authentication.
- my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost",$dbuser,$dbpass);
- my $sth = $dbh->prepare(qq{select fullname,context from voicemail where mailbox='$mbox' and password='$pass' and context='$context'});
- $sth->execute();
- if (($fullname, $context) = $sth->fetchrow_array()) {;
- return ($fullname ? $fullname : "unknown", $category);
- }
- }
+ } elsif ($category eq "general") {
+ if (/([^\s]+)\s*\=\s*(.*)/) {
+ if ($1 eq "dbname") {
+ $dbname = $2;
+ } elsif ($1 eq "dbpass") {
+ $dbpass = $2;
+ } elsif ($1 eq "dbhost") {
+ $dbhost = $2;
+ } elsif ($1 eq "dbuser") {
+ $dbuser = $2;
+ }
+ }
+ if ($dbname and $dbpass and $dbhost and $dbuser) {
+
+ # db variables are present. Use db for authentication.
+ my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost",$dbuser,$dbpass);
+ my $sth = $dbh->prepare(qq{select fullname,context from voicemail where mailbox='$mbox' and password='$pass' and context='$context'});
+ $sth->execute();
+ if (($fullname, $context) = $sth->fetchrow_array()) {
+ return ($fullname ? $fullname : "unknown", $category);
+ }
+ }
} elsif (($category ne "general") && ($category ne "zonemessages") && ($category eq $context)) {
if (/([^\s]+)\s*\=\>?\s*(.*)/) {
@fields = split(/\,\s*/, $2);
@@ -282,37 +282,37 @@
$tmp .= $tmp2;
} elsif (/\[(.*)\]/) {
$category = $1;
- } elsif ($category eq "general") {
- if (/([^\s]+)\s*\=\s*(.*)/) {
- if ($1 eq "dbname") {
- $dbname = $2;
- } elsif ($1 eq "dbpass") {
- $dbpass = $2;
- } elsif ($1 eq "dbhost") {
- $dbhost = $2;
- } elsif ($1 eq "dbuser") {
- $dbuser = $2;
- }
- }
- if ($dbname and $dbpass and $dbhost and $dbuser) {
-
- # db variables are present. Use db for authentication.
- my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost",$dbuser,$dbpass);
- my $sth = $dbh->prepare(qq{select mailbox,fullname,context from voicemail where context='$context' order by mailbox});
- $sth->execute();
- while (($mailbox, $fullname, $category) = $sth->fetchrow_array()) {
- $text = $mailbox;
- if ($fullname) {
- $text .= " (".$fullname.")";
- }
- if ($mailbox eq $current) {
- $tmp .= "<OPTION SELECTED>$text</OPTION>\n";
- } else {
- $tmp .= "<OPTION>$text</OPTION>\n";
- }
- }
- return ($tmp, $category);
- }
+ } elsif ($category eq "general") {
+ if (/([^\s]+)\s*\=\s*(.*)/) {
+ if ($1 eq "dbname") {
+ $dbname = $2;
+ } elsif ($1 eq "dbpass") {
+ $dbpass = $2;
+ } elsif ($1 eq "dbhost") {
+ $dbhost = $2;
+ } elsif ($1 eq "dbuser") {
+ $dbuser = $2;
+ }
+ }
+ if ($dbname and $dbpass and $dbhost and $dbuser) {
+
+ # db variables are present. Use db for authentication.
+ my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost",$dbuser,$dbpass);
+ my $sth = $dbh->prepare(qq{select mailbox,fullname,context from voicemail where context='$context' order by mailbox});
+ $sth->execute();
+ while (($mailbox, $fullname, $category) = $sth->fetchrow_array()) {
+ $text = $mailbox;
+ if ($fullname) {
+ $text .= " (".$fullname.")";
+ }
+ if ($mailbox eq $current) {
+ $tmp .= "<OPTION SELECTED>$text</OPTION>\n";
+ } else {
+ $tmp .= "<OPTION>$text</OPTION>\n";
+ }
+ }
+ return ($tmp, $category);
+ }
} elsif (($category ne "general") && ($category ne "zonemessages")) {
if (/([^\s]+)\s*\=\>?\s*(.*)/) {
@fields = split(/\,\s*/, $2);
@@ -587,7 +587,7 @@
my $message2;
my $msgcount;
my $hasmsg;
- my $newmessages, $oldmessages;
+ my ($newmessages, $oldmessages);
my $format = param('format');
if (!$format) {
$format = &getcookie('format');
@@ -737,14 +737,14 @@
sub message_rename()
{
my ($context, $mbox, $oldfolder, $old, $newfolder, $new) = @_;
- my $oldfile, $newfile;
+ my ($oldfile, $newfile);
return if ($old eq $new) && ($oldfolder eq $newfolder);
- if ($context =~ /^(\w+)$/) {
- $context = $1;
- } else {
- die("Invalid Context<BR>\n");
- }
+ if ($context =~ /^(\w+)$/) {
+ $context = $1;
+ } else {
+ die("Invalid Context<BR>\n");
+ }
if ($mbox =~ /^(\w+)$/) {
$mbox = $1;
@@ -780,7 +780,7 @@
$path =~ /^(.*)$/;
$path = $1;
mkdir $path, 0770;
- my $path = "/var/spool/asterisk/voicemail/$context/$mbox/$oldfolder";
+ $path = "/var/spool/asterisk/voicemail/$context/$mbox/$oldfolder";
opendir(DIR, $path) || die("Unable to open directory\n");
my @files = grep /^msg${old}\.\w+$/, readdir(DIR);
closedir(DIR);
@@ -818,7 +818,7 @@
sub message_copy()
{
my ($context, $mbox, $newmbox, $oldfolder, $old, $new) = @_;
- my $oldfile, $newfile;
+ my ($oldfile, $newfile);
return if ($mbox eq $newmbox);
if ($mbox =~ /^(\w+)$/) {
@@ -855,11 +855,11 @@
$path =~ /^(.*)$/;
$path = $1;
mkdir $path, 0770;
- my $path = "/var/spool/asterisk/voicemail/$context/$newmbox/INBOX";
+ $path = "/var/spool/asterisk/voicemail/$context/$newmbox/INBOX";
$path =~ /^(.*)$/;
$path = $1;
mkdir $path, 0770;
- my $path = "/var/spool/asterisk/voicemail/$context/$mbox/$oldfolder";
+ $path = "/var/spool/asterisk/voicemail/$context/$mbox/$oldfolder";
opendir(DIR, $path) || die("Unable to open directory\n");
my @files = grep /^msg${old}\.\w+$/, readdir(DIR);
closedir(DIR);
@@ -936,23 +936,27 @@
$context = &untaint($context);
$newmbox = &untaint($newmbox);
my $path = "/var/spool/asterisk/voicemail/$context/$newmbox/INBOX";
- if (&lock_path($path) == 0) {
- $msgcount = &msgcount($context, $newmbox, "INBOX");
-
- if ($newmbox ne $mbox) {
-# print header;
- foreach $msg (@msgs) {
-# print "Forwarding $msg from $mbox to $newmbox<BR>\n";
- &message_copy($context, $mbox, $newmbox, $folder, $msg, sprintf "%04d", $msgcount);
- $msgcount++;
- }
- $txt = "Forwarded messages " . join(', ', @msgs) . "to $newmbox";
+ if ($msgs[0]) {
+ if (&lock_path($path) == 0) {
+ $msgcount = &msgcount($context, $newmbox, "INBOX");
+
+ if ($newmbox ne $mbox) {
+ # print header;
+ foreach $msg (@msgs) {
+ # print "Forwarding $msg from $mbox to $newmbox<BR>\n";
+ &message_copy($context, $mbox, $newmbox, $folder, $msg, sprintf "%04d", $msgcount);
+ $msgcount++;
+ }
+ $txt = "Forwarded messages " . join(', ', @msgs) . "to $newmbox";
+ } else {
+ $txt = "Can't forward messages to yourself!\n";
+ }
+ &unlock_path($path);
} else {
- $txt = "Can't forward messages to yourself!\n";
- }
- &unlock_path($path);
- } else {
- $txt = "Cannot forward messages: Unable to lock path.\n";
+ $txt = "Cannot forward messages: Unable to lock path.\n";
+ }
+ } else {
+ $txt = "Please Select Message(s) for this action.\n";
}
if ($toindex) {
&message_index($folder, $txt);
@@ -966,7 +970,7 @@
my ($toindex, $del, @msgs) = @_;
my $txt;
my $path;
- my $y, $x;
+ my ($y, $x);
my $folder = param('folder');
my $newfolder = param('newfolder') unless $del;
$newfolder =~ s/^(\w+)\s+.*$/$1/;
@@ -981,39 +985,43 @@
$context = &untaint($context);
$mbox = &untaint($mbox);
$folder = &untaint($folder);
- my $path = "/var/spool/asterisk/voicemail/$context/$mbox/$folder";
- if (&lock_path($path) == 0) {
- my $msgcount = &msgcount($context, $mbox, $folder);
- my $omsgcount = &msgcount($context, $mbox, $newfolder) if $newfolder;
- # print header;
- if ($newfolder ne $folder) {
- $y = 0;
- for ($x=0;$x<$msgcount;$x++) {
- my $msg = sprintf "%04d", $x;
- my $newmsg = sprintf "%04d", $y;
- if (grep(/^$msg$/, @msgs)) {
- if ($newfolder) {
- &message_rename($context, $mbox, $folder, $msg, $newfolder, sprintf "%04d", $omsgcount);
- $omsgcount++;
+ $path = "/var/spool/asterisk/voicemail/$context/$mbox/$folder";
+ if ($msgs[0]) {
+ if (&lock_path($path) == 0) {
+ my $msgcount = &msgcount($context, $mbox, $folder);
+ my $omsgcount = &msgcount($context, $mbox, $newfolder) if $newfolder;
+ # print header;
+ if ($newfolder ne $folder) {
+ $y = 0;
+ for ($x=0;$x<$msgcount;$x++) {
+ my $msg = sprintf "%04d", $x;
+ my $newmsg = sprintf "%04d", $y;
+ if (grep(/^$msg$/, @msgs)) {
+ if ($newfolder) {
+ &message_rename($context, $mbox, $folder, $msg, $newfolder, sprintf "%04d", $omsgcount);
+ $omsgcount++;
+ } else {
+ &message_delete($context, $mbox, $folder, $msg);
+ }
} else {
- &message_delete($context, $mbox, $folder, $msg);
+ &message_rename($context, $mbox, $folder, $msg, $folder, $newmsg);
+ $y++;
}
+ }
+ if ($del) {
+ $txt = "Deleted messages " . join (', ', @msgs);
} else {
- &message_rename($context, $mbox, $folder, $msg, $folder, $newmsg);
- $y++;
- }
- }
- if ($del) {
- $txt = "Deleted messages " . join (', ', @msgs);
+ $txt = "Moved messages " . join (', ', @msgs) . " to $newfolder";
+ }
} else {
- $txt = "Moved messages " . join (', ', @msgs) . " to $newfolder";
- }
+ $txt = "Can't move a message to the same folder they're in already";
+ }
+ &unlock_path($path);
} else {
- $txt = "Can't move a message to the same folder they're in already";
- }
- &unlock_path($path);
- } else {
- $txt = "Cannot move/delete messages: Unable to lock path.\n";
+ $txt = "Cannot move/delete messages: Unable to lock path.\n";
+ }
+ } else {
+ $txt = "Please Select Message(s) for this action.\n";
}
# Not as many messages now
$msgcount--;
More information about the asterisk-commits
mailing list