[Asterisk-cvs] asterisk/apps app_voicemail.c,1.151.2.8,1.151.2.9
russell at lists.digium.com
russell at lists.digium.com
Sun Dec 19 08:10:07 CST 2004
Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv4054/apps
Modified Files:
Tag: v1-0
app_voicemail.c
Log Message:
fix language handling (bug #3023)
Index: app_voicemail.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_voicemail.c,v
retrieving revision 1.151.2.8
retrieving revision 1.151.2.9
diff -u -d -r1.151.2.8 -r1.151.2.9
--- app_voicemail.c 15 Dec 2004 23:05:28 -0000 1.151.2.8
+++ app_voicemail.c 19 Dec 2004 13:06:11 -0000 1.151.2.9
@@ -178,6 +178,7 @@
static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context);
static int play_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int outsidecaller, struct ast_vm_user *vmu, int *duration);
static int vm_delete(char *file);
+static int vm_play_folder_name(struct ast_channel *chan, char *mbox);
static char ext_pass_cmd[128];
@@ -2135,23 +2136,10 @@
d = ast_play_and_wait(chan, "vm-for"); /* "for" */
if (d)
return d;
- if (!strcasecmp(chan->language, "es") || !strcasecmp(chan->language, "fr") || !strcasecmp(chan->language, "pt")) { /* Spanish, French or Portuguese syntax */
- d = ast_play_and_wait(chan, "vm-messages"); /* "messages */
- if (d)
- return d;
- snprintf(fn, sizeof(fn), "vm-%s", mbox(x)); /* Folder name */
- d = ast_play_and_wait(chan, fn);
- if (d)
- return d;
- } else { /* Default English */
- snprintf(fn, sizeof(fn), "vm-%s", mbox(x)); /* Folder name */
- d = ast_play_and_wait(chan, fn);
- if (d)
- return d;
- d = ast_play_and_wait(chan, "vm-messages"); /* "messages */
- if (d)
- return d;
- }
+ snprintf(fn, sizeof(fn), "vm-%s", mbox(x)); /* Folder name */
+ d = vm_play_folder_name(chan, fn);
+ if (d)
+ return d;
d = ast_waitfordigit(chan, 500);
if (d)
return d;
@@ -2662,8 +2650,25 @@
memset(vms->heard, 0, sizeof(vms->heard));
}
+static int vm_play_folder_name(struct ast_channel *chan, char *mbox)
+{
+ int cmd;
+
+ if (!strcasecmp(chan->language, "es") || !strcasecmp(chan->language, "fr") || !strcasecmp(chan->language, "pt")) { /*Spanish, French or Portuguese syntax */
+ cmd = ast_play_and_wait(chan, "vm-messages"); /* "messages */
+ if (cmd)
+ return cmd;
+ return ast_play_and_wait(chan, mbox);
+ } else { /* Default English */
+ cmd = ast_play_and_wait(chan, mbox);
+ if (cmd)
+ return cmd;
+ return ast_play_and_wait(chan, "vm-messages"); /* "messages */
+ }
+}
+
/* Default English syntax */
-static int vm_intro(struct ast_channel *chan,struct vm_state *vms)
+static int vm_intro_en(struct ast_channel *chan,struct vm_state *vms)
{
/* Introduce messages they have */
int res;
@@ -3025,6 +3030,26 @@
return res;
}
+static int vm_intro(struct ast_channel *chan,struct vm_state *vms)
+{
+ /* Play voicemail intro - syntax is different for different languages */
+ if (!strcasecmp(chan->language, "de")) { /* GERMAN syntax */
+ return vm_intro_de(chan, vms);
+ } else if (!strcasecmp(chan->language, "es")) { /* SPANISH syntax */
+ return vm_intro_es(chan, vms);
+ } else if (!strcasecmp(chan->language, "fr")) { /* FRENCH syntax */
+ return vm_intro_fr(chan, vms);
+ } else if (!strcasecmp(chan->language, "nl")) { /* DUTCH syntax */
+ return vm_intro_nl(chan, vms);
+ } else if (!strcasecmp(chan->language, "pt")) { /* PORTUGUESE syntax */
+ return vm_intro_pt(chan, vms);
+ } else if (!strcasecmp(chan->language, "cz")) { /* CZECH syntax */
+ return vm_intro_cz(chan, vms);
+ } else { /* Default to ENGLISH */
+ return vm_intro_en(chan, vms);
+ }
+}
+
static int vm_instructions(struct ast_channel *chan, struct vm_state *vms, int skipadvanced)
{
int res = 0;
@@ -3033,17 +3058,8 @@
if (vms->starting) {
if (vms->lastmsg > -1) {
res = ast_play_and_wait(chan, "vm-onefor");
- if (!strcasecmp(chan->language, "es") || !strcasecmp(chan->language, "fr") || !strcasecmp(chan->language, "pt")) { /* Spanish, French & Portuguese Syntax */
- if (!res)
- res = ast_play_and_wait(chan, "vm-messages");
- if (!res)
- res = ast_play_and_wait(chan, vms->vmbox);
- } else { /* Default English syntax */
- if (!res)
- res = ast_play_and_wait(chan, vms->vmbox);
- if (!res)
- res = ast_play_and_wait(chan, "vm-messages");
- }
+ if (!res)
+ res = vm_play_folder_name(chan, vms->vmbox);
}
if (!res)
res = ast_play_and_wait(chan, "vm-opts");
@@ -3173,7 +3189,7 @@
}
/* Default English syntax */
-static int vm_browse_messages(struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu)
+static int vm_browse_messages_en(struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu)
{
int cmd=0;
@@ -3231,6 +3247,17 @@
return cmd;
}
+static int vm_browse_messages(struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu)
+{
+ if (!strcasecmp(chan->language, "es")) { /* SPANISH */
+ return vm_browse_messages_es(chan, vms, vmu);
+ } else if (!strcasecmp(chan->language, "pt")) { /* PORTUGUESE */
+ return vm_browse_messages_pt(chan, vms, vmu);
+ } else { /* Default to English syntax */
+ return vm_browse_messages_en(chan, vms, vmu);
+ }
+}
+
static int vm_execmain(struct ast_channel *chan, void *data)
{
/* XXX This is, admittedly, some pretty horrendus code. For some
@@ -3414,22 +3441,7 @@
if (useadsi)
adsi_status(chan, &vms);
res = 0;
- /* Play voicemail intro - syntax is different for different languages */
- if (!strcasecmp(chan->language, "de")) { /* GERMAN syntax */
- cmd = vm_intro_de(chan, &vms);
- } else if (!strcasecmp(chan->language, "es")) { /* SPANISH syntax */
- cmd = vm_intro_es(chan, &vms);
- } else if (!strcasecmp(chan->language, "fr")) { /* FRENCH syntax */
- cmd = vm_intro_fr(chan, &vms);
- } else if (!strcasecmp(chan->language, "nl")) { /* DUTCH syntax */
- cmd = vm_intro_nl(chan, &vms);
- } else if (!strcasecmp(chan->language, "pt")) { /* PORTUGUESE syntax */
- cmd = vm_intro_pt(chan, &vms);
- } else if (!strcasecmp(chan->language, "cz")) { /* CZECH syntax */
- cmd = vm_intro_cz(chan, &vms);
- } else { /* Default to ENGLISH */
- cmd = vm_intro(chan, &vms);
- }
+ cmd = vm_intro(chan, &vms);
vms.repeats = 0;
vms.starting = 1;
while((cmd > -1) && (cmd != 't') && (cmd != '#')) {
@@ -3439,13 +3451,7 @@
vms.curmsg = 0;
/* Fall through */
case '5':
- if (!strcasecmp(chan->language, "es")) { /* SPANISH */
- cmd = vm_browse_messages_es(chan, &vms, vmu);
- } else if (!strcasecmp(chan->language, "pt")) { /* PORTUGUESE */
- cmd = vm_browse_messages_pt(chan, &vms, vmu);
- } else { /* Default to English syntax */
- cmd = vm_browse_messages(chan, &vms, vmu);
- }
+ cmd = vm_browse_messages(chan, &vms, vmu);
break;
case '2': /* Change folders */
if (useadsi)
@@ -3461,17 +3467,8 @@
}
if (useadsi)
adsi_status2(chan, &vms);
- if (!strcasecmp(chan->language, "es") || !strcasecmp(chan->language, "pt")) { /* SPANISH or PORTUGUESE */
- if (!cmd)
- cmd = ast_play_and_wait(chan, "vm-messages");
- if (!cmd)
- cmd = ast_play_and_wait(chan, vms.vmbox);
- } else { /* Default to English syntax */
- if (!cmd)
- cmd = ast_play_and_wait(chan, vms.vmbox);
- if (!cmd)
- cmd = ast_play_and_wait(chan, "vm-messages");
- }
+ if (!cmd)
+ cmd = vm_play_folder_name(chan, vms.vmbox);
vms.starting = 1;
break;
case '3': /* Advanced options */
@@ -3630,21 +3627,9 @@
cmd = say_and_wait(chan, vms.curmsg + 1, chan->language);
if (!cmd)
cmd = ast_play_and_wait(chan, "vm-savedto");
- if (!strcasecmp(chan->language, "es") || !strcasecmp(chan->language, "pt")) { /* SPANISH or PORTUGUESE */
- if (!cmd)
- cmd = ast_play_and_wait(chan, "vm-messages");
- if (!cmd) {
- snprintf(vms.fn, sizeof(vms.fn), "vm-%s", mbox(box));
- cmd = ast_play_and_wait(chan, vms.fn);
- }
- } else { /* Default to English */
- if (!cmd) {
- snprintf(vms.fn, sizeof(vms.fn), "vm-%s", mbox(box));
- cmd = ast_play_and_wait(chan, vms.fn);
- }
- if (!cmd)
- cmd = ast_play_and_wait(chan, "vm-messages");
- }
+ snprintf(vms.fn, sizeof(vms.fn), "vm-%s", mbox(box));
+ if (!cmd)
+ cmd = vm_play_folder_name(chan, vms.fn);
if (skipaftercmd) {
if (vms.curmsg < vms.lastmsg) {
vms.curmsg++;
@@ -3658,17 +3643,8 @@
case '*':
if (!vms.starting) {
cmd = ast_play_and_wait(chan, "vm-onefor");
- if (!strcasecmp(chan->language, "es") || !strcasecmp(chan->language, "pt")) { /* Spanish or Portuguese syntax */
- if (!cmd)
- cmd = ast_play_and_wait(chan, "vm-messages");
- if (!cmd)
- cmd = ast_play_and_wait(chan, vms.vmbox);
- } else {
- if (!cmd)
- cmd = ast_play_and_wait(chan, vms.vmbox);
- if (!cmd)
- cmd = ast_play_and_wait(chan, "vm-messages");
- }
+ if (!cmd)
+ cmd = vm_play_folder_name(chan, vms.vmbox);
if (!cmd)
cmd = ast_play_and_wait(chan, "vm-opts");
if (!cmd)
@@ -4780,6 +4756,7 @@
return ast_filedelete(file, NULL);
}
+
int usecount(void)
{
int res;
More information about the svn-commits
mailing list