--- app_voicemail.good 2004-07-17 00:03:10.000000000 -0400 +++ app_voicemail.c 2004-07-17 18:51:52.000000000 -0400 @@ -3315,9 +3315,9 @@ return res; } -static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc) +static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, int cmd) { - int cmd = 0; + //int cmd = 0; int retries = 0; int duration = 0; char newpassword[80] = ""; @@ -3352,6 +3352,10 @@ cmd = play_record_review(chan,"vm-rec-name",prefile, maxgreet, fmtc, 0, vmu, &duration); break; case '4': + retries=0; +retype_new_password: + retries++; + if (retries > 4) { cmd='*'; break; } newpassword[1] = '\0'; newpassword[0] = cmd = play_and_wait(chan,"vm-newpassword"); if (cmd < 0) @@ -3370,6 +3374,7 @@ if (strcmp(newpassword, newpassword2)) { ast_log(LOG_NOTICE,"Password mismatch for user %s (%s != %s)\n", vms->username, newpassword, newpassword2); cmd = play_and_wait(chan, "vm-mismatch"); + goto retype_new_password; break; } vm_change_password(vmu,newpassword); @@ -3380,6 +3385,7 @@ cmd = 't'; break; default: + if (!strcasecmp(vms->username, vmu->password)) { cmd='t'; break; } cmd = play_and_wait(chan,"vm-options"); if (!cmd) cmd = ast_waitfordigit(chan,6000); @@ -3589,6 +3595,19 @@ } if (valid) { + /* Check to see if password equals the mailbox number, if so then process as a new user + so they can record all their greetings and change their password before being able + to use their voicemail */ + if (!strcasecmp(vms.username, vmu->password)) { + ast_verbose( VERBOSE_PREFIX_3 "Flagged ext %s as a new user\n", vms.username); + cmd = play_and_wait(chan, "vm-newuser"); + vm_options(chan, vmu, &vms, vmfmts, 51); //Record their name + vm_options(chan, vmu, &vms, vmfmts, 49); //Record unavil message + vm_options(chan, vmu, &vms, vmfmts, 50); //Record busy message + vm_options(chan, vmu, &vms, vmfmts, 52); //Change their password + } + + /* Set language from config to override channel language */ if (vmu->language && !ast_strlen_zero(vmu->language)) strncpy(chan->language, vmu->language, sizeof(chan->language)-1); @@ -3864,7 +3883,7 @@ cmd = 0; break; case '0': - cmd = vm_options(chan, vmu, &vms, vmfmts); + cmd = vm_options(chan, vmu, &vms, vmfmts, 0); if (useadsi) adsi_status(chan, &vms); break;