[Asterisk-cvs] asterisk/apps app_voicemail.c,1.152,1.153
markster at lists.digium.com
markster at lists.digium.com
Fri Oct 1 22:59:17 CDT 2004
Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv32406/apps
Modified Files:
app_voicemail.c
Log Message:
Implement voicemail force account setup (bug #2077)
Index: app_voicemail.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_voicemail.c,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -d -r1.152 -r1.153
--- app_voicemail.c 2 Oct 2004 00:58:31 -0000 1.152
+++ app_voicemail.c 2 Oct 2004 03:01:20 -0000 1.153
@@ -148,6 +148,8 @@
int review;
int operator;
int envelope;
+ int forcename;
+ int forcegreetings;
struct ast_vm_user *next;
};
@@ -264,6 +266,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")) {
@@ -3012,6 +3030,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 = ast_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 = ast_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 = ast_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 = ast_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;
@@ -3322,7 +3409,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 */
@@ -3332,6 +3418,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 (ast_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);
@@ -3348,6 +3452,7 @@
} else { /* Default to ENGLISH */
cmd = vm_intro(chan, &vms);
}
+
vms.repeats = 0;
vms.starting = 1;
while((cmd > -1) && (cmd != 't') && (cmd != '#')) {
@@ -4018,6 +4123,18 @@
}
}
+ /* 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);
stringp = ast_strdupa(s);
More information about the svn-commits
mailing list