From b8ab0abb83d164d3d788d5fbcc3f3b5926edb14f Mon Sep 17 00:00:00 2001
From: Joshua Colp <jcolp@digium.com>
Date: Fri, 16 Feb 2007 18:08:34 +0000
Subject: [PATCH] Allow the user to specify where to enable the respective
 features for when a parked call is picked up. (ie: transfers and parking)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@54910 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 configs/features.conf.sample |  6 ++++--
 res/res_features.c           | 22 ++++++++++++++++------
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/configs/features.conf.sample b/configs/features.conf.sample
index ea40a801cd..a35453f8cb 100644
--- a/configs/features.conf.sample
+++ b/configs/features.conf.sample
@@ -15,8 +15,10 @@ context => parkedcalls		; Which context parked calls are in
 				; or the Touch Monitor is activated/deactivated.
 ;parkedplay = caller		; Who to play the courtesy tone to when picking up a parked call
 				; one of: parked, caller, both  (default is caller)
-;parkedcalltransfers = yes      ; Enables or disables DTMF based transfers when picking up a parked call
-;parkedcallreparking = yes      ; Enables or disables DTMF based parking when picking up a parked call
+;parkedcalltransfers = caller   ; Enables or disables DTMF based transfers when picking up a parked call.
+                                ; one of: callee, caller, both, no (default is no)
+;parkedcallreparking = caller   ; Enables or disables DTMF based parking when picking up a parked call.
+                                ; one of: callee, caller, both, no (default is no)
 ;adsipark = yes			; if you want ADSI parking announcements
 ;findslot => next		; Continue to the 'next' free parking space. 
 				; Defaults to 'first' available
diff --git a/res/res_features.c b/res/res_features.c
index 06647c904d..8c0600e489 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -1830,14 +1830,14 @@ static int park_exec(struct ast_channel *chan, void *data)
 			ast_verbose(VERBOSE_PREFIX_3 "Channel %s connected to parked call %d\n", chan->name, park);
 
 		memset(&config, 0, sizeof(struct ast_bridge_config));
-		if (parkedcalltransfers) {
+		if ((parkedcalltransfers == AST_FEATURE_FLAG_BYCALLEE) || (parkedcalltransfers == AST_FEATURE_FLAG_BYBOTH))
 			ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT);
+		if ((parkedcalltransfers == AST_FEATURE_FLAG_BYCALLER) || (parkedcalltransfers == AST_FEATURE_FLAG_BYBOTH))
 			ast_set_flag(&(config.features_caller), AST_FEATURE_REDIRECT);
-		}
-		if (parkedcallreparking) {
+		if ((parkedcallreparking == AST_FEATURE_FLAG_BYCALLEE) || (parkedcallreparking == AST_FEATURE_FLAG_BYBOTH))
 			ast_set_flag(&(config.features_callee), AST_FEATURE_PARKCALL);
+		if ((parkedcallreparking == AST_FEATURE_FLAG_BYCALLER) || (parkedcallreparking == AST_FEATURE_FLAG_BYBOTH))
 			ast_set_flag(&(config.features_caller), AST_FEATURE_PARKCALL);
-		}
 		res = ast_bridge_call(chan, peer, &config);
 
 		pbx_builtin_setvar_helper(chan, "PARKEDCHANNEL", peer->name);
@@ -2162,9 +2162,19 @@ static int load_config(void)
 		} else if (!strcasecmp(var->name, "parkinghints")) {
 			parkaddhints = ast_true(var->value);
 		} else if (!strcasecmp(var->name, "parkedcalltransfers")) {
-			parkedcalltransfers = ast_true(var->value);
+			if (!strcasecmp(var->value, "both"))
+				parkedcalltransfers = AST_FEATURE_FLAG_BYBOTH;
+			else if (!strcasecmp(var->value, "caller"))
+				parkedcalltransfers = AST_FEATURE_FLAG_BYCALLER;
+			else if (!strcasecmp(var->value, "callee"))
+				parkedcalltransfers = AST_FEATURE_FLAG_BYCALLEE;
 		} else if (!strcasecmp(var->name, "parkedcallreparking")) {
-			parkedcallreparking = ast_true(var->value);
+			if (!strcasecmp(var->value, "both"))
+				parkedcalltransfers = AST_FEATURE_FLAG_BYBOTH;
+			else if (!strcasecmp(var->value, "caller"))
+				parkedcalltransfers = AST_FEATURE_FLAG_BYCALLER;
+			else if (!strcasecmp(var->value, "callee"))
+				parkedcalltransfers = AST_FEATURE_FLAG_BYCALLEE;
 		} else if (!strcasecmp(var->name, "adsipark")) {
 			adsipark = ast_true(var->value);
 		} else if (!strcasecmp(var->name, "transferdigittimeout")) {