diff options
author | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-02-02 17:37:15 +0000 |
---|---|---|
committer | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-02-02 17:37:15 +0000 |
commit | 0fb5a8a2ff6259b9065d2e8fcd00d520489f4d3a (patch) | |
tree | e5da1d35ac494e009b4ab58a4c7fde6185ae5923 /apps/app_dial.c | |
parent | c223d3d18e2fd5d54057c3406569bf6f80f32020 (diff) |
This change allows the disconnect feature (as in "one-touch" in features.c)
to be used within the dial app, before a call is bridged.
Many thanks to sobomax for submitting this patch.
Quoting from bug 11582:
"So the goal of the patch was to use the user configured feature code during the
call setup phase. The original ast_feature_interpret() function is not well suited
for this purpose as it uses much call bridge specific data and doesn't separate a
detection of feature from a feature handler call. So a new function ast_feature_detect()
has been extracted off the ast_feature_interpret() function but keeping the original
logic intact except some insignificant changes to locking.
"Having created the ast_feature_detect() function the possibility to use feature detection
in almost any place of the asterisk code. So a call to this function has been added to
wait_for_answer() function of app_dial.so module. This code doesn't call the feature handler
however and uses old call leg disconnect logic to make the changes as small and simple as
possible to prevent unexpected problems. A disconnect feature currently is the only one
supported during call setup as other features as call parking and call transfer don't make much
sense during call setup. However if need in some of the features would arise it is much easier to
implement as the infrastructure changes are already in place with this patch."
I have cleaned up the patch somewhat, and verified that the existing functionality is not
harmed, and that the new functionality works. Terry has committed his stuff, and there were
no conflicts (see 14274).
(closes issue #11583)
Reported by: sobomax
Patches:
patch-apps__app_dial.c uploaded by sobomax (license 359)
patch-include__asterisk__features.h uploaded by sobomax (license 359)
patch-res__res_features.c uploaded by sobomax (license 359)
enable-features-during-call-setup.diff uploaded by sobomax (license 359)
11583.newdiff uploaded by murf (license 17)
enable-features-during-call-setup-1.diff uploaded by sobomax (license 359)
11583.latest-patch uploaded by murf (license 17)
Tested by: sobomax, murf
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@172890 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_dial.c')
-rw-r--r-- | apps/app_dial.c | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c index 849c0c527..3fff300ca 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -560,6 +560,7 @@ struct chanlist { uint64_t flags; }; +static int detect_disconnect(struct ast_channel *chan, char code); static void hanguptree(struct chanlist *outgoing, struct ast_channel *exception, int answered_elsewhere) { @@ -1054,8 +1055,8 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, } if (ast_test_flag64(peerflags, OPT_CALLER_HANGUP) && - (f->subclass == '*')) { /* hmm it it not guaranteed to be '*' anymore. */ - ast_verb(3, "User hit %c to disconnect call.\n", f->subclass); + detect_disconnect(in, f->subclass)) { + ast_verb(3, "User requested call disconnect.\n"); *to = 0; strcpy(pa->status, "CANCEL"); ast_cdr_noanswer(in->cdr); @@ -1099,6 +1100,58 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, return peer; } +static char featurecode[FEATURE_MAX_LEN + 1] = ""; + +static int detect_disconnect(struct ast_channel *chan, char code) +{ + struct feature_interpret_result result; + int x; + struct ast_flags features; + int res = FEATURE_RETURN_PASSDIGITS; + struct ast_call_feature *feature; + char *cptr; + const char *dynamic_features = pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES"); + int len; + + len = strlen(featurecode); + if (len >= FEATURE_MAX_LEN) { + featurecode[0] = '\0'; + } + cptr = &featurecode[strlen(featurecode)]; + cptr[0] = code; + cptr[1] = '\0'; + + memset(&features, 0, sizeof(struct ast_flags)); + ast_set_flag(&features, AST_FEATURE_DISCONNECT); + + ast_features_lock(); + + res = ast_feature_detect(chan, &features, featurecode, &result, dynamic_features); + + if (res != FEATURE_RETURN_STOREDIGITS) + featurecode[0] = '\0'; + + + if (result.builtin_feature && result.builtin_feature->feature_mask & AST_FEATURE_DISCONNECT) { + ast_features_unlock(); + return 1; + } + + for (x = 0; x < result.num_dyn_features; ++x) { + feature = result.dynamic_features[x]; + if (feature->feature_mask & AST_FEATURE_DISCONNECT) { + ast_features_unlock(); + return 1; + } + } + + ast_features_unlock(); + + return 0; +} + + + static void replace_macro_delimiter(char *s) { for (; *s; s++) |