From: Richard Mudgett Date: Wed, 9 May 2012 17:58:11 +0000 (+0000) Subject: Improve FollowMe accept/decline DTMF string matching. X-Git-Tag: 11.0.0-beta1~333 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=108f5fafd700470536a7d53a1c2d617e5a36aeaa;p=thirdparty%2Fasterisk.git 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. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@365951 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/apps/app_followme.c b/apps/app_followme.c index 04439e4bf3..8b894d6d24 100644 --- a/apps/app_followme.c +++ b/apps/app_followme.c @@ -887,20 +887,31 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us } } 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); } diff --git a/configs/followme.conf.sample b/configs/followme.conf.sample index 418ec582ea..a233948bf9 100644 --- a/configs/followme.conf.sample +++ b/configs/followme.conf.sample @@ -8,10 +8,12 @@ featuredigittimeout=>5000 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 @@ number=>01233456,25 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.