summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2003-06-15 11:42:48 +0000
committerMark Spencer <markster@digium.com>2003-06-15 11:42:48 +0000
commit226e31d86d90ef282995c35dbdf4adf4edf8f1ea (patch)
treec57a0bed391a67adf03124c9b15d5371a8f58ade
parent3664ca0cbba21c2b090a6bc4892b0c1d9ccdd4c2 (diff)
Internationalize DISA and fix Voicemail when receiving messages and you're checking them too
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1092 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rwxr-xr-xapps/app_disa.c117
-rwxr-xr-xapps/app_voicemail2.c10
2 files changed, 69 insertions, 58 deletions
diff --git a/apps/app_disa.c b/apps/app_disa.c
index 1377adc73..cb43a45e8 100755
--- a/apps/app_disa.c
+++ b/apps/app_disa.c
@@ -7,6 +7,8 @@
*
* Jim Dixon <jim@lambdatel.com>
*
+ * Made only slightly more sane by Mark Spencer <markster@digium.com>
+ *
* This program is free software, distributed under the terms of
* the GNU General Public License
*/
@@ -179,7 +181,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
{
ast_log(LOG_DEBUG,"DISA %s entry timeout on chan %s\n",
((k) ? "extension" : "password"),chan->name);
- goto reorder;
+ break;
}
if ((res = ast_waitfor(chan, -1) < 0)) {
ast_log(LOG_DEBUG, "Waitfor returned %d\n", res);
@@ -296,66 +298,71 @@ static int disa_exec(struct ast_channel *chan, void *data)
exten[i] = 0;
if (!k) continue; /* if getting password, continue doing it */
/* if this exists */
- if (ast_exists_extension(chan,ourcontext,exten,1, chan->callerid))
- {
- if (ourcallerid && *ourcallerid)
- {
- if (chan->callerid) free(chan->callerid);
- chan->callerid = strdup(ourcallerid);
- }
- strcpy(chan->exten,exten);
- strcpy(chan->context,ourcontext);
- strcpy(chan->accountcode,acctcode);
- chan->priority = 0;
- ast_cdr_init(chan->cdr,chan);
- LOCAL_USER_REMOVE(u);
- return 0;
- }
+
/* if can do some more, do it */
- if (ast_canmatch_extension(chan,ourcontext,exten,1, chan->callerid)) continue;
+ if (!ast_matchmore_extension(chan,ourcontext,exten,1, chan->callerid))
+ break;
+ }
+ }
+
+ if (k && ast_exists_extension(chan,ourcontext,exten,1, chan->callerid))
+ {
+ /* We're authenticated and have a valid extension */
+ if (ourcallerid && *ourcallerid)
+ {
+ if (chan->callerid) free(chan->callerid);
+ chan->callerid = strdup(ourcallerid);
}
+ strcpy(chan->exten,exten);
+ strcpy(chan->context,ourcontext);
+ strcpy(chan->accountcode,acctcode);
+ chan->priority = 0;
+ ast_cdr_init(chan->cdr,chan);
+ LOCAL_USER_REMOVE(u);
+ return 0;
+ }
+
reorder:
- /* something is invalid, give em reorder forever */
- x = 0;
- k = 0; /* k = 0 means busy tone, k = 1 means silence) */
- i = 0; /* Number of samples we've done */
- for(;;)
- {
- if (ast_waitfor(chan, -1) < 0)
- break;
- f = ast_read(chan);
- if (!f)
- break;
- if (f->frametype == AST_FRAME_VOICE) {
- wf.frametype = AST_FRAME_VOICE;
- wf.subclass = AST_FORMAT_ULAW;
- wf.offset = AST_FRIENDLY_OFFSET;
- wf.mallocd = 0;
- wf.data = tone_block;
- wf.datalen = f->datalen;
- wf.samples = wf.datalen;
- if (k)
- memset(tone_block, 0x7f, wf.datalen);
- else
- make_tone_block(tone_block,480.0, 620.0,wf.datalen, &x);
- i += wf.datalen / 8;
- if (i > 250) {
- i = 0;
- k = !k;
- }
- if (ast_write(chan, &wf))
- {
- ast_log(LOG_WARNING, "DISA Failed to write frame on %s\n",chan->name);
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ /* something is invalid, give em reorder forever */
+ x = 0;
+ k = 0; /* k = 0 means busy tone, k = 1 means silence) */
+ i = 0; /* Number of samples we've done */
+ for(;;)
+ {
+ if (ast_waitfor(chan, -1) < 0)
+ break;
+ f = ast_read(chan);
+ if (!f)
+ break;
+ if (f->frametype == AST_FRAME_VOICE) {
+ wf.frametype = AST_FRAME_VOICE;
+ wf.subclass = AST_FORMAT_ULAW;
+ wf.offset = AST_FRIENDLY_OFFSET;
+ wf.mallocd = 0;
+ wf.data = tone_block;
+ wf.datalen = f->datalen;
+ wf.samples = wf.datalen;
+ if (k)
+ memset(tone_block, 0x7f, wf.datalen);
+ else
+ make_tone_block(tone_block,480.0, 620.0,wf.datalen, &x);
+ i += wf.datalen / 8;
+ if (i > 250) {
+ i = 0;
+ k = !k;
+ }
+ if (ast_write(chan, &wf))
+ {
+ ast_log(LOG_WARNING, "DISA Failed to write frame on %s\n",chan->name);
+ LOCAL_USER_REMOVE(u);
+ return -1;
}
- ast_frfree(f);
}
- LOCAL_USER_REMOVE(u);
- return -1;
+ ast_frfree(f);
}
+ LOCAL_USER_REMOVE(u);
+ return -1;
}
int unload_module(void)
@@ -381,7 +388,7 @@ int usecount(void)
return res;
}
-char *key()
+char *key(void)
{
return ASTERISK_GPL_KEY;
}
diff --git a/apps/app_voicemail2.c b/apps/app_voicemail2.c
index 9f7a4ff4f..bba7b31d2 100755
--- a/apps/app_voicemail2.c
+++ b/apps/app_voicemail2.c
@@ -1894,11 +1894,13 @@ static void close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu)
if (vms->lastmsg > -1) {
/* Get the deleted messages fixed */
vms->curmsg = -1;
- for (x=0;x<=vms->lastmsg;x++) {
+ for (x=0;x < MAXMSG;x++) {
if (!vms->deleted[x] && (strcasecmp(vms->curbox, "INBOX") || !vms->heard[x])) {
/* Save this message. It's not in INBOX or hasn't been heard */
- vms->curmsg++;
make_file(vms->fn, sizeof(vms->fn), vms->curdir, x);
+ if (ast_fileexists(vms->fn, NULL, NULL) < 1)
+ break;
+ vms->curmsg++;
make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
if (strcmp(vms->fn, vms->fn2)) {
snprintf(txt, sizeof(txt), "%s.txt", vms->fn);
@@ -1911,8 +1913,10 @@ static void close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu)
save_to_folder(vms->curdir, x, vmu->context, vms->username, 1);
}
}
- for (x = vms->curmsg + 1; x<=vms->lastmsg; x++) {
+ for (x = vms->curmsg + 1; x <= MAXMSG; x++) {
make_file(vms->fn, sizeof(vms->fn), vms->curdir, x);
+ if (ast_fileexists(vms->fn, NULL, NULL) < 1)
+ break;
snprintf(txt, sizeof(txt), "%s.txt", vms->fn);
ast_filedelete(vms->fn, NULL);
unlink(txt);