[asterisk-commits] rmudgett: trunk r365951 - in /trunk: apps/ configs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 9 12:58:15 CDT 2012


Author: rmudgett
Date: Wed May  9 12:58:11 2012
New Revision: 365951

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=365951
Log:
Improve FollowMe accept/decline DTMF string matching.

If you hit the wrong DTMF digit trying to accept/decline a FollowMe call,
you had to wait for the prompt to repeat to try again.

* Make FollowMe compare the last DTMF digits received to the
accept/decline matching strings.

Modified:
    trunk/apps/app_followme.c
    trunk/configs/followme.conf.sample

Modified: trunk/apps/app_followme.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_followme.c?view=diff&rev=365951&r1=365950&r2=365951
==============================================================================
--- trunk/apps/app_followme.c (original)
+++ trunk/apps/app_followme.c Wed May  9 12:58:11 2012
@@ -887,20 +887,31 @@
 					}
 				} 
 				if (tmpuser && tmpuser->state == 3 && f->frametype == AST_FRAME_DTMF) {
+					int cmp_len;
+
 					if (ast_channel_stream(winner))
 						ast_stopstream(winner);
 					tmpuser->digts = 0;
 					ast_debug(1, "DTMF received: %c\n", (char) f->subclass.integer);
 					if (tmpuser->ynidx < ARRAY_LEN(tmpuser->yn) - 1) {
-						tmpuser->yn[tmpuser->ynidx++] = (char) f->subclass.integer;
+						tmpuser->yn[tmpuser->ynidx++] = f->subclass.integer;
+					} else {
+						/* Discard oldest digit. */
+						memmove(tmpuser->yn, tmpuser->yn + 1,
+							sizeof(tmpuser->yn) - 2 * sizeof(tmpuser->yn[0]));
+						tmpuser->yn[ARRAY_LEN(tmpuser->yn) - 2] = f->subclass.integer;
 					}
 					ast_debug(1, "DTMF string: %s\n", tmpuser->yn);
-					if (!strcmp(tmpuser->yn, tpargs->takecall)) {
+					cmp_len = strlen(tpargs->takecall);
+					if (cmp_len <= tmpuser->ynidx
+						&& !strcmp(tmpuser->yn + (tmpuser->ynidx - cmp_len), tpargs->takecall)) {
 						ast_debug(1, "Match to take the call!\n");
 						ast_frfree(f);
 						return tmpuser->ochan;
 					}
-					if (!strcmp(tmpuser->yn, tpargs->nextindp)) {
+					cmp_len = strlen(tpargs->nextindp);
+					if (cmp_len <= tmpuser->ynidx
+						&& !strcmp(tmpuser->yn + (tmpuser->ynidx - cmp_len), tpargs->nextindp)) {
 						ast_debug(1, "Declined to take the call.\n");
 						clear_caller(tmpuser);
 					}

Modified: trunk/configs/followme.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/followme.conf.sample?view=diff&rev=365951&r1=365950&r2=365951
==============================================================================
--- trunk/configs/followme.conf.sample (original)
+++ trunk/configs/followme.conf.sample Wed May  9 12:58:11 2012
@@ -8,10 +8,12 @@
 takecall=>1
 ; The global default keypress for the callee to take taking the current call. This can be
 ; a single digit or multiple digits. Default is "1".
+; Note this string must not be a substring of declinecall.
 ;
 declinecall=>2
 ; The global default keypress for the callee to decline taking the current call. This can
 ; be a single digit or multiple digits. Default is "2".
+; Note this string must not be a substring of takecall.
 ;
 call_from_prompt=>followme/call-from
 ; The global default for the 'Incoming call from' message.
@@ -55,10 +57,12 @@
 takecall=>1
 ; The keypress for the callee to take taking the current call. This can be
 ; a single digit or multiple digits. Default is the global default.
+; Note this string must not be a substring of declinecall.
 ;
 declinecall=>2
 ; The keypress for the callee to decline taking the current call. This can
 ; be a single digit or multiple digits. Default is the global default.
+; Note this string must not be a substring of takecall.
 ;
 call_from_prompt=>followme/call-from
 ; The 'Incoming call from' message prompt. Default is the global default.




More information about the asterisk-commits mailing list