Index: asterisk/apps/app_voicemail.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_voicemail.c,v retrieving revision 1.147 diff -u -r1.147 app_voicemail.c --- asterisk/apps/app_voicemail.c 6 Sep 2004 15:43:43 -0000 1.147 +++ asterisk/apps/app_voicemail.c 8 Sep 2004 02:02:28 -0000 @@ -149,6 +149,8 @@ int review; int operator; int envelope; + int forcename; + int forcegreetings; struct ast_vm_user *next; }; @@ -268,6 +270,8 @@ static int svmailinfo; static int hearenv; static int skipaftercmd; +static int forcenm; +static int forcegrt; static char dialcontext[80]; static char callcontext[80]; static char exitcontext[80]; @@ -301,6 +305,10 @@ vmu->svmail = 1; if (hearenv) vmu->envelope = 1; + if (forcenm) + vmu->forcename = 1; + if (forcegrt) + vmu->forcegreetings = 1; if (callcontext) strncpy(vmu->callback, callcontext, sizeof(vmu->callback) -1); if (dialcontext) @@ -357,6 +365,16 @@ vmu->envelope = 1; else vmu->envelope = 0; + } else if (!strcasecmp(var, "forcename")){ + if(ast_true(value)) + vmu->forcename = 1; + else + vmu->forcename = 0; + } else if (!strcasecmp(var, "forcegreetings")){ + if(ast_true(value)) + vmu->forcegreetings = 1; + else + vmu->forcegreetings = 0; } else if (!strcasecmp(var, "callback")) { strncpy(vmu->callback, value, sizeof(vmu->callback) -1); } else if (!strcasecmp(var, "dialout")) { @@ -3450,6 +3468,75 @@ return res; } +static int vm_newuser(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc) +{ + int cmd = 0; + int duration = 0; + char newpassword[80] = ""; + char newpassword2[80] = ""; + char prefile[256]=""; + char buf[256]; + int bytes=0; + + if (adsi_available(chan)) + { + bytes += adsi_logo(buf + bytes); + bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "New User Setup", ""); + bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Not Done", ""); + bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); + bytes += adsi_voice_mode(buf + bytes, 0); + adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); + } + + /* First, have the user change their password + so they won't get here again */ + newpassword[1] = '\0'; + newpassword[0] = cmd = play_and_wait(chan,"vm-newpassword"); + if (cmd < 0 || cmd == 't' || cmd == '#') + return cmd; + cmd = ast_readstring(chan,newpassword + strlen(newpassword),sizeof(newpassword)-1,2000,10000,"#"); + if (cmd < 0 || cmd == 't' || cmd == '#') + return cmd; + newpassword2[1] = '\0'; + newpassword2[0] = cmd = play_and_wait(chan,"vm-reenterpassword"); + return cmd; + cmd = ast_readstring(chan,newpassword2 + strlen(newpassword2),sizeof(newpassword2)-1,2000,10000,"#"); + if (cmd < 0 || cmd == 't' || cmd == '#') + return cmd; + 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"); + } + if(ast_strlen_zero(ext_pass_cmd)) + vm_change_password(vmu,newpassword); + else + vm_change_password_shell(vmu,newpassword); + ast_log(LOG_DEBUG,"User %s set password to %s of length %i\n",vms->username,newpassword,(int)strlen(newpassword)); + cmd = play_and_wait(chan,"vm-passchanged"); + + /* If forcename is set, have the user record their name */ + if (vmu->forcename) { + snprintf(prefile,sizeof(prefile),"voicemail/%s/%s/greet",vmu->context, vms->username); + cmd = play_record_review(chan,"vm-rec-name",prefile, maxgreet, fmtc, 0, vmu, &duration); + if (cmd < 0 || cmd == 't' || cmd == '#') + return cmd; + } + + /* If forcegreetings is set, have the user record their greetings */ + if (vmu->forcegreetings) { + snprintf(prefile,sizeof(prefile),"voicemail/%s/%s/unavail",vmu->context, vms->username); + cmd = play_record_review(chan,"vm-rec-unv",prefile, maxgreet, fmtc, 0, vmu, &duration); + if (cmd < 0 || cmd == 't' || cmd == '#') + return cmd; + snprintf(prefile,sizeof(prefile),"voicemail/%s/%s/busy",vmu->context, vms->username); + cmd = play_record_review(chan,"vm-rec-busy",prefile, maxgreet, fmtc, 0, vmu, &duration); + if (cmd < 0 || cmd == 't' || cmd == '#') + return cmd; + } + + return cmd; +} + static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc) { int cmd = 0; @@ -3767,7 +3854,6 @@ open_mailbox(&vms, vmu, 0); vms.newmessages = vms.lastmsg + 1; - /* Select proper mailbox FIRST!! */ if (!vms.newmessages && vms.oldmessages) { /* If we only have old messages start here */ @@ -3777,6 +3863,24 @@ if (useadsi) adsi_status(chan, &vms); res = 0; + + /* Check to see if this is a new user */ + if (!strcasecmp(vmu->mailbox, vmu->password) && + (vmu->forcename || vmu->forcegreetings)) { + if (play_and_wait(chan, "vm-newuser") == -1) + ast_log(LOG_WARNING, "Couldn't stream new user file\n"); + cmd = vm_newuser(chan, vmu, &vms, vmfmts); + if ((cmd == 't') || (cmd == '#')) { + /* Timeout */ + res = 0; + goto out; + } else if (cmd < 0) { + /* Hangup */ + res = -1; + goto out; + } + } + /* Play voicemail intro - syntax is different for different languages */ if (!strcasecmp(chan->language, "de")) { /* GERMAN syntax */ cmd = vm_intro_de(chan, &vms); @@ -3793,6 +3897,7 @@ } else { /* Default to ENGLISH */ cmd = vm_intro(chan, &vms); } + vms.repeats = 0; vms.starting = 1; while((cmd > -1) && (cmd != 't') && (cmd != '#')) { @@ -4461,6 +4566,18 @@ ast_log(LOG_WARNING, "Invalid max failed login attempts\n"); } } + + /* Force new user to record name ? */ + forcenm = 0; + if (!(astattach = ast_variable_retrieve(cfg, "general", "forcename"))) + astattach = "no"; + forcenm = ast_true(astattach); + + /* Force new user to record greetings ? */ + forcegrt = 0; + if (!(astattach = ast_variable_retrieve(cfg, "general", "forcegreetings"))) + astattach = "no"; + forcegrt = ast_true(astattach); if ((s = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))){ ast_log(LOG_DEBUG,"VM_CID Internal context string: %s\n",s); Index: asterisk/configs/voicemail.conf.sample =================================================================== RCS file: /usr/cvsroot/asterisk/configs/voicemail.conf.sample,v retrieving revision 1.39 diff -u -r1.39 voicemail.conf.sample --- asterisk/configs/voicemail.conf.sample 6 Sep 2004 06:19:17 -0000 1.39 +++ asterisk/configs/voicemail.conf.sample 8 Sep 2004 02:02:29 -0000 @@ -116,7 +116,12 @@ ; This is intended for use with users who wish to receive their voicemail ONLY by email. ; nextaftercmd=yes ; Skips to the next message after hitting 7 or 9 to delete/save current message. ; [global option only at this time] - +; forcename=yes ; Forces a new user to record their name. A new user is + ; determined by the password being the same as + ; the mailbox number. The default is "no". +; forcegreetings=no ; This is the same as forcename, except for recording + ; greetings. The default is "no". + [zonemessages] eastern=America/New_York|'vm-received' Q 'digits/at' IMp central=America/Chicago|'vm-received' Q 'digits/at' IMp @@ -130,6 +135,8 @@ ;4069 => 6522,Matt Brooks,matt@marko.net,,|tz=central|attach=yes|saycid=yes|dialout=fromvm|callback=fromvm|review=yes|operator=yes|envelope=yes ;4073 => 1099,Bianca Paige,bianca@biancapaige.com,,delete=1 ;4110 => 3443,Rob Flynn,rflynn@blueridge.net +;4321 => 4321,Russell Bryant,russelb@clemson.edu,,|tz=central|attach=no|saycid=yes|dialout=fromvm|callback=fromvm|review=yes|operator=yes|envelope=yes|forcename=yes|forcegreetings=yes + ; ; Mailboxes may be organized into multiple contexts for