diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-08-11 10:47:58 +0300 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-08-11 10:47:58 +0300 |
commit | cec5e081ffd40aa34867ef8e3b6754b935fa856d (patch) | |
tree | 7c055604dea47c7cb9bcb9ac9d516a418d7c6b92 /main/asterisk | |
parent | df525ea1ee2084d50f60da5209b863c5dd06fc5f (diff) | |
download | aports-cec5e081ffd40aa34867ef8e3b6754b935fa856d.tar.bz2 aports-cec5e081ffd40aa34867ef8e3b6754b935fa856d.tar.xz |
main/asterisk: backport Incomplete() application
it's needed for overlapped dialing.
Diffstat (limited to 'main/asterisk')
-rw-r--r-- | main/asterisk/201-incomplete.patch | 121 | ||||
-rw-r--r-- | main/asterisk/APKBUILD | 6 |
2 files changed, 125 insertions, 2 deletions
diff --git a/main/asterisk/201-incomplete.patch b/main/asterisk/201-incomplete.patch new file mode 100644 index 0000000000..2566134f38 --- /dev/null +++ b/main/asterisk/201-incomplete.patch @@ -0,0 +1,121 @@ +Index: include/asterisk/pbx.h +=================================================================== +--- a/include/asterisk/pbx.h (revision 112598) ++++ b/include/asterisk/pbx.h (working copy) +@@ -42,6 +42,7 @@ + + /*! \brief Special return values from applications to the PBX { */ + #define AST_PBX_ERROR 1 /*!< Jump to the 'e' exten */ ++#define AST_PBX_INCOMPLETE 12 /*!< Return to PBX matching, allowing more digits for the extension */ + /*! } */ + + #define PRIORITY_HINT -1 /*!< Special Priority for a hint */ +Index: main/pbx.c +=================================================================== +--- a/main/pbx.c (revision 112598) ++++ b/main/pbx.c (working copy) +@@ -302,6 +302,7 @@ + static int pbx_builtin_background(struct ast_channel *, void *); + static int pbx_builtin_wait(struct ast_channel *, void *); + static int pbx_builtin_waitexten(struct ast_channel *, void *); ++static int pbx_builtin_incomplete(struct ast_channel *, void *); + static int pbx_builtin_resetcdr(struct ast_channel *, void *); + static int pbx_builtin_setamaflags(struct ast_channel *, void *); + static int pbx_builtin_ringing(struct ast_channel *, void *); +@@ -579,6 +580,16 @@ + "value.\n" + }, + ++ { "Incomplete", pbx_builtin_incomplete, ++ "returns AST_PBX_INCOMPLETE value", ++ " Incomplete([n]): Signals the PBX routines that the previous matched extension\n" ++ "is incomplete and that further input should be allowed before matching can\n" ++ "be considered to be complete. Can be used within a pattern match when\n" ++ "certain criteria warrants a longer match.\n" ++ " If the 'n' option is specified, then Incomplete will not attempt to answer\n" ++ "the channel first. Note that most channel types need to be in Answer state\n" ++ "in order to receive DTMF.\n" ++ }, + { "NoOp", pbx_builtin_noop, + "Do Nothing (No Operation)", + " NoOp(): This application does nothing. However, it is useful for debugging\n" +@@ -3539,6 +3551,8 @@ + char dst_exten[256]; /* buffer to accumulate digits */ + int pos = 0; /* XXX should check bounds */ + int digit = 0; ++ int invalid = 0; ++ int timeout = 0; + + /* loop on priorities in this context/exten */ + while ( !(res = ast_spawn_extension(c, c->context, c->exten, c->priority, c->cid.cid_num, &found,1))) { +@@ -3574,6 +3588,18 @@ + pos = 0; + dst_exten[pos++] = digit = res; + dst_exten[pos] = '\0'; ++ } else if (res == AST_PBX_INCOMPLETE) { ++ ast_debug(1, "Spawn extension (%s,%s,%d) exited INCOMPLETE on '%s'\n", c->context, c->exten, c->priority, c->name); ++ ast_verb(2, "Spawn extension (%s, %s, %d) exited INCOMPLETE on '%s'\n", c->context, c->exten, c->priority, c->name); ++ ++ /* Don't cycle on incomplete - this will happen if the only extension that matches is our "incomplete" extension */ ++ if (!ast_matchmore_extension(c, c->context, c->exten, c->priority, c->cid.cid_num)) { ++ invalid = 1; ++ } else { ++ ast_copy_string(dst_exten, c->exten, sizeof(dst_exten)); ++ digit = 1; ++ pos = strlen(dst_exten); ++ } + } else { + ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name); + ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name); +@@ -3610,7 +3636,7 @@ + * hangup. We have options, here. We can either catch the failure + * and continue, or we can drop out entirely. */ + +- if (!ast_exists_extension(c, c->context, c->exten, 1, c->cid.cid_num)) { ++ if (invalid || !ast_exists_extension(c, c->context, c->exten, 1, c->cid.cid_num)) { + /*!\note + * If there is no match at priority 1, it is not a valid extension anymore. + * Try to continue at "i" (for invalid) or "e" (for exception) or exit if +@@ -3654,11 +3680,13 @@ + + if (collect_digits(c, waittime, dst_exten, sizeof(dst_exten), pos)) + break; +- if (ast_exists_extension(c, c->context, dst_exten, 1, c->cid.cid_num)) /* Prepare the next cycle */ ++ if (res == AST_PBX_INCOMPLETE && ast_strlen_zero(&dst_exten[pos])) ++ timeout = 1; ++ if (!timeout && ast_exists_extension(c, c->context, dst_exten, 1, c->cid.cid_num)) /* Prepare the next cycle */ + set_ext_pri(c, dst_exten, 1); + else { + /* No such extension */ +- if (!ast_strlen_zero(dst_exten)) { ++ if (!timeout && !ast_strlen_zero(dst_exten)) { + /* An invalid extension */ + if (ast_exists_extension(c, c->context, "i", 1, c->cid.cid_num)) { + ast_verb(3, "Invalid extension '%s' in context '%s' on %s\n", dst_exten, c->context, c->name); +@@ -7315,6 +7343,26 @@ + return AST_PBX_KEEPALIVE; + } + ++static int pbx_builtin_incomplete(struct ast_channel *chan, void *data) ++{ ++ char *options = data; ++ int answer = 1; ++ ++ /* Some channels can receive DTMF in unanswered state; some cannot */ ++ if (!ast_strlen_zero(options) && strchr(options, 'n')) { ++ answer = 0; ++ } ++ ++ /* If the channel is hungup, stop waiting */ ++ if (ast_check_hangup(chan)) { ++ return -1; ++ } else if (chan->_state != AST_STATE_UP && answer) { ++ __ast_answer(chan, 0, 1); ++ } ++ ++ return AST_PBX_INCOMPLETE; ++} ++ + AST_APP_OPTIONS(resetcdr_opts, { + AST_APP_OPTION('w', AST_CDR_FLAG_POSTED), + AST_APP_OPTION('a', AST_CDR_FLAG_LOCKED), diff --git a/main/asterisk/APKBUILD b/main/asterisk/APKBUILD index 7e8bb1d182..e68397ea30 100644 --- a/main/asterisk/APKBUILD +++ b/main/asterisk/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Timo Teras <timo.teras@iki.fi> pkgname=asterisk pkgver=1.6.0.10 -pkgrel=1 +pkgrel=2 pkgdesc="Asterisk: A Module Open Source PBX System" url="http://www.asterisk.org/" license="GPL" @@ -17,7 +17,8 @@ source="http://downloads.digium.com/pub/asterisk/releases/$pkgname-$pkgver.tar.g 100-uclibc-daemon.patch 101-caps-uclibc.patch 102-gsm-pic.patch - 103-rundir.patch + 103-rundir.patch + 201-incomplete.patch asterisk.pre-install asterisk.post-install asterisk.initd @@ -90,6 +91,7 @@ b00c9d98ce2ad445501248a197c6e436 100-uclibc-daemon.patch 929f740db7043b4553544ebcc7315c91 101-caps-uclibc.patch 97b39fd9777a2521d4f9f095482b7ac2 102-gsm-pic.patch 5008f51c737ec91f5047519bc9f25b85 103-rundir.patch +57825b74526187075ff7cb6816c55467 201-incomplete.patch b4a97cb1ec3cc3f71a10ce8c067ab430 asterisk.pre-install 62ecffc90b6714b85f377d1fac73c58b asterisk.post-install c618b7fdf4a9edf4cde6d8ccd1e32ee6 asterisk.initd |