fix language handling (bug #3023)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@4481 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2004-12-19 13:06:11 +00:00
parent 8a987daf3b
commit a97bf16d2d

View File

@@ -178,6 +178,7 @@ static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, s
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 @@ static int get_folder(struct ast_channel *chan, int start)
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 @@ static void close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu)
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 @@ static int vm_intro_cz(struct ast_channel *chan,struct vm_state *vms)
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 @@ static int vm_instructions(struct ast_channel *chan, struct vm_state *vms, int s
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 @@ static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct
}
/* 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 @@ static int vm_browse_messages_pt(struct ast_channel *chan, struct vm_state *vms,
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 @@ static int vm_execmain(struct ast_channel *chan, void *data)
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 @@ static int vm_execmain(struct ast_channel *chan, void *data)
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 @@ static int vm_execmain(struct ast_channel *chan, void *data)
}
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 @@ static int vm_execmain(struct ast_channel *chan, void *data)
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 @@ static int vm_execmain(struct ast_channel *chan, void *data)
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 @@ static int vm_delete(char *file)
return ast_filedelete(file, NULL);
}
int usecount(void)
{
int res;