Review Board 1.7.16


VoicemailMain and VMauthenticate: Like VoiceMail allow escape to the 'a' extension when a single '*' is entered in Mailbox or Password

Review Request #489 - Created Feb. 4, 2010 and submitted

Alec Davis
trunk
Reviewers
asterisk-dev
Asterisk
VoiceMail() already has the ability to escape to the single digit 'a' extension.

Where a site uses VoiceMailMain(mailbox), the users have to be at their own extension to clear their voicemail, they have no way of escaping VoiceMailMain to allow entering there own mailbox.
There are other reasons to require escape also.

The only option currently is to dial another number where VoiceMailMain() is called without the mailbox parmeter, and asks for Mailbox and Password.

This patch, allows a site to include to 'a' extension in the current dialplan context, to allow an escape.

If the 'a' priority doesn't exist in the context VoicemailMain is called from, then it acts as the old behaviour.
Tested both VoiceMailMain and VMauthenticate with the 'a' extension present and not. All 4 senarios performed as expected.
Using the following dialplan:

[voicemail-main]
exten => s,1,Answer()

exten => s,n,VMAuthenticate()
exten => s,n,VoiceMailMain()
exten => s,n,Verbose(0,After VoiceMailMain)
exten => s,n,Hangup

exten => a,1,Verbose(0,User entered *)
exten => a,n,Playback(connecting)
exten => a,n,Goto(s,1)

Diff revision 1

This is not the most recent revision of the diff. The latest diff is revision 4. See what's changed.

1 2 3 4
1 2 3 4

  1. trunk/apps/app_voicemail.c: Loading...
trunk/apps/app_voicemail.c
Revision 244887 New Change
[20] 9240 lines
[+20] [+] static int vm_authenticate(struct ast_channel *chan, char *mailbox, int mailbox_size,
9241
				ast_copy_string(mailbox, chan->cid.cid_num, mailbox_size);
9241
				ast_copy_string(mailbox, chan->cid.cid_num, mailbox_size);
9242
			} else {
9242
			} else {
9243
				ast_verb(3, "Username not entered\n");	
9243
				ast_verb(3, "Username not entered\n");	
9244
				return -1;
9244
				return -1;
9245
			}
9245
			}

    
   
9246
		} else if (mailbox[0] == '*') {

    
   
9247
			/* user entered '*' */

    
   
9248
			if (ast_exists_extension(chan, chan->context, "a", 1, "")) {

    
   
9249
				return -1;

    
   
9250
			} 

    
   
9251
			mailbox[0] = '\0';
9246
		}
9252
		}

    
   
9253

   
9247
		if (useadsi)
9254
		if (useadsi)
9248
			adsi_password(chan);
9255
			adsi_password(chan);
9249

    
   
9256

   
9250
		if (!ast_strlen_zero(prefix)) {
9257
		if (!ast_strlen_zero(prefix)) {
9251
			char fullusername[80] = "";
9258
			char fullusername[80] = "";
[+20] [20] 13 lines
[+20] static int vm_authenticate(struct ast_channel *chan, char *mailbox, int mailbox_size,
9265
				return -1;
9272
				return -1;
9266
			}
9273
			}
9267
			if (ast_readstring(chan, password, sizeof(password) - 1, 2000, 10000, "#") < 0) {
9274
			if (ast_readstring(chan, password, sizeof(password) - 1, 2000, 10000, "#") < 0) {
9268
				ast_log(AST_LOG_WARNING, "Unable to read password\n");
9275
				ast_log(AST_LOG_WARNING, "Unable to read password\n");
9269
				return -1;
9276
				return -1;

    
   
9277
			} else if (password[0] == '*') {

    
   
9278
				/* user entered '*' */

    
   
9279
				if (ast_exists_extension(chan, chan->context, "a", 1, "")) {

    
   
9280
					mailbox[0] = '*';

    
   
9281
					return -1;

    
   
9282
				} 

    
   
9283
				mailbox[0] = '\0';
9270
			}
9284
			}
9271
		}
9285
		}
9272

    
   
9286

   
9273
		if (vmu) {
9287
		if (vmu) {
9274
			passptr = vmu->password;
9288
			passptr = vmu->password;
[+20] [20] 155 lines
[+20] [+] static int vm_execmain(struct ast_channel *chan, const char *data)
9430

    
   
9444

   
9431
	if (!valid)
9445
	if (!valid)
9432
		res = vm_authenticate(chan, vms.username, sizeof(vms.username), &vmus, context, prefixstr, skipuser, maxlogins, 0);
9446
		res = vm_authenticate(chan, vms.username, sizeof(vms.username), &vmus, context, prefixstr, skipuser, maxlogins, 0);
9433

    
   
9447

   
9434
	ast_debug(1, "After vm_authenticate\n");
9448
	ast_debug(1, "After vm_authenticate\n");

    
   
9449

   

    
   
9450
	if (vms.username[0] == '*') {

    
   
9451
		ast_debug(1, "user pressed * in context '%s'\n", chan->context);

    
   
9452

   

    
   
9453
  		/* user entered '*' */

    
   
9454
		if (!ast_goto_if_exists(chan, chan->context, "a", 1)) {

    
   
9455
			res = 0;	/* prevent hangup */

    
   
9456
			goto out;

    
   
9457
		}

    
   
9458
	}

    
   
9459

   
9435
	if (!res) {
9460
	if (!res) {
9436
		valid = 1;
9461
		valid = 1;
9437
		if (!skipuser)
9462
		if (!skipuser)
9438
			vmu = &vmus;
9463
			vmu = &vmus;
9439
	} else {
9464
	} else {
[+20] [20] 827 lines
[+20] [+] static int vmauthenticate(struct ast_channel *chan, const char *data)
10267
	if (!vm_authenticate(chan, mailbox, sizeof(mailbox), &vmus, context, NULL, skipuser, 3, silent)) {
10292
	if (!vm_authenticate(chan, mailbox, sizeof(mailbox), &vmus, context, NULL, skipuser, 3, silent)) {
10268
		pbx_builtin_setvar_helper(chan, "AUTH_MAILBOX", mailbox);
10293
		pbx_builtin_setvar_helper(chan, "AUTH_MAILBOX", mailbox);
10269
		pbx_builtin_setvar_helper(chan, "AUTH_CONTEXT", vmus.context);
10294
		pbx_builtin_setvar_helper(chan, "AUTH_CONTEXT", vmus.context);
10270
		ast_play_and_wait(chan, "auth-thankyou");
10295
		ast_play_and_wait(chan, "auth-thankyou");
10271
		res = 0;
10296
		res = 0;

    
   
10297
	} else if (mailbox[0] == '*') {

    
   
10298
  		/* user entered '*' */

    
   
10299
		if (!ast_goto_if_exists(chan, chan->context, "a", 1)) {

    
   
10300
			res = 0;	/* prevent hangup */

    
   
10301
		}
10272
	}
10302
	}
10273

    
   
10303

   
10274
	return res;
10304
	return res;
10275
}
10305
}
10276

    
   
10306

   
[+20] [20] 1864 lines
  1. trunk/apps/app_voicemail.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.