[asterisk-commits] russell: branch russell/applicationmap_fixup r39055 - in /team/russell/applic...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Aug 5 22:32:46 MST 2006


Author: russell
Date: Sun Aug  6 00:32:46 2006
New Revision: 39055

URL: http://svn.digium.com/view/asterisk?rev=39055&view=rev
Log:
- document the new syntax for the applicationmap
- implement control over which channel is allowed to activate a feature
  in the applicationmap

Modified:
    team/russell/applicationmap_fixup/configs/features.conf.sample
    team/russell/applicationmap_fixup/res/res_features.c

Modified: team/russell/applicationmap_fixup/configs/features.conf.sample
URL: http://svn.digium.com/view/asterisk/team/russell/applicationmap_fixup/configs/features.conf.sample?rev=39055&r1=39054&r2=39055&view=diff
==============================================================================
--- team/russell/applicationmap_fixup/configs/features.conf.sample (original)
+++ team/russell/applicationmap_fixup/configs/features.conf.sample Sun Aug  6 00:32:46 2006
@@ -42,9 +42,44 @@
 ; Note that the DYNAMIC_FEATURES channel variable must be set to use the features
 ; defined here.  The value of DYNAMIC_FEATURES should be the names of the features
 ; to allow the channel to use separated by '#'.  For example:
+;
 ;    Set(DYNAMIC_FEATURES=myfeature1#myfeature2#myfeature3)
 ;
-;testfeature => #9,callee,Playback,tt-monkeys	;Play tt-monkeys to 
-						;callee if #9 was pressed
-;pauseMonitor   => #1,caller,Pausemonitor	;Pause monitoring on channel
-;unpauseMonitor => #3,caller,UnPauseMonitor	;Unpause monitoring on channel
+;
+; The syntax for declaring a dynaic feature is the following:
+;
+;<FeatureName> => <DTMF_sequence>,<ActivateOn>[/<ActivatedBy>],<Application>[,<AppArguments>]
+;
+;  FeatureName   -> This is the name of the feature used in when setting the
+;                   DYNAMIC_FEATURES variable to enable usage of this feature.
+;  DTMF_sequence -> This is the key sequence used to activate this feature.
+;  ActivateOn    -> This is the channel of the call that the application will be executed
+;                   on. Valid values are "self" and "peer". "self" means run the
+;                   application on the same channel that activated the feature. "peer"
+;                   means run the application on the opposite channel from the one that
+;                   has activated the feature.
+;  ActivatedBy   -> This is which channel is allowed to activated this feature. Valid
+;                   values are "caller", "callee", and "both". "both" is the default.
+;                   The "caller" is the channel that executed the Dial application, while
+;                   the "callee" is the channel called by the Dial application.
+;  Application   -> This is the application to execute.
+;  AppArguments  -> These are the arguments to be passed into the application.
+;
+;
+; IMPORTANT NOTE: The applicationmap is not intended to be used for all Asterisk
+;   applications. When applications are used in extensions.conf, they are executed
+;   by the PBX core. In this case, these applications are executed outside of the
+;   PBX core, so it does *not* make sense to use any application which has any
+;   concept of dialplan flow. Examples of this would be things like Macro, Goto,
+;   Background, WaitExten, and many more.
+;
+;
+; Example Usage:
+;
+;testfeature => #9,peer,Playback,tt-monkeys  ;Allow both the caller and callee to play
+;                                            ;tt-monkeys to the opposite channel
+;
+;pauseMonitor   => #1,self/callee,Pausemonitor     ;Allow the callee to pause monitoring
+;                                                  ;on their channel
+;unpauseMonitor => #3,self/callee,UnPauseMonitor   ;Allow the callee to unpause monitoring
+;                                                  ;on their channel

Modified: team/russell/applicationmap_fixup/res/res_features.c
URL: http://svn.digium.com/view/asterisk/team/russell/applicationmap_fixup/res/res_features.c?rev=39055&r1=39054&r2=39055&view=diff
==============================================================================
--- team/russell/applicationmap_fixup/res/res_features.c (original)
+++ team/russell/applicationmap_fixup/res/res_features.c Sun Aug  6 00:32:46 2006
@@ -77,8 +77,8 @@
 
 enum {
 	AST_FEATURE_FLAG_NEEDSDTMF = (1 << 0),
-	AST_FEATURE_FLAG_ONCALLEE =  (1 << 1),
-	AST_FEATURE_FLAG_ONCALLER =  (1 << 2),
+	AST_FEATURE_FLAG_ONPEER =    (1 << 1),
+	AST_FEATURE_FLAG_ONSELF =    (1 << 2),
 	AST_FEATURE_FLAG_BYCALLEE =  (1 << 3),
 	AST_FEATURE_FLAG_BYCALLER =  (1 << 4),
 	AST_FEATURE_FLAG_BYBOTH	 =   (3 << 3),
@@ -961,14 +961,23 @@
 		ast_log(LOG_NOTICE, "Found feature before, but at execing we've lost it??\n");
 		return -1; 
 	}
-	
+
+	if (sense == FEATURE_SENSE_CHAN) {
+		if (!ast_test_flag(feature, AST_FEATURE_FLAG_BYCALLER))
+			return FEATURE_RETURN_PASSDIGITS;
+		work = ast_test_flag(feature, AST_FEATURE_FLAG_ONSELF) ? chan : peer;
+		service = ast_test_flag(feature, AST_FEATURE_FLAG_ONPEER) ? peer : chan;
+	} else {
+		if (!ast_test_flag(feature, AST_FEATURE_FLAG_BYCALLEE))
+			return FEATURE_RETURN_PASSDIGITS;
+		work = ast_test_flag(feature, AST_FEATURE_FLAG_ONSELF) ? peer : chan;
+		service = ast_test_flag(feature, AST_FEATURE_FLAG_ONSELF) ? chan : peer;
+	}
+
 	if (!(app = pbx_findapp(feature->app))) {
 		ast_log(LOG_WARNING, "Could not find application (%s)\n", feature->app);
 		return -2;
 	}
-	
-	work = ast_test_flag(feature, AST_FEATURE_FLAG_ONCALLEE) ? peer : chan;
-	service = ast_test_flag(feature, AST_FEATURE_FLAG_ONCALLEE) ? chan : peer;
 
 	ast_autoservice_start(service);
 	res = pbx_exec(work, app, feature->app_args);
@@ -1049,10 +1058,7 @@
 				if (!strcmp(feature->exten, code)) {
 					if (option_verbose > 2)
 						ast_verbose(VERBOSE_PREFIX_3 " Feature Found: %s exten: %s\n",feature->sname, tok);
-					if (sense == FEATURE_SENSE_CHAN)
-						res = feature->operation(chan, peer, config, code, sense);
-					else
-						res = feature->operation(peer, chan, config, code, sense);
+					res = feature->operation(chan, peer, config, code, sense);
 					break;
 				} else if (!strncmp(feature->exten, code, strlen(code))) {
 					res = FEATURE_RETURN_STOREDIGITS;
@@ -2202,14 +2208,28 @@
 			feature->operation = feature_exec_app;
 			ast_set_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF);
 
-			ast_set_flag(feature, AST_FEATURE_FLAG_BYBOTH);
-
-			if (!strcasecmp(activateon, "caller"))
-				ast_set_flag(feature, AST_FEATURE_FLAG_ONCALLER);
-			else if (!strcasecmp(activateon, "callee"))
-				ast_set_flag(feature, AST_FEATURE_FLAG_ONCALLEE);
+			/* Allow caller and calle to be specified for backwards compatability */
+			if (!strcasecmp(activateon, "self") || !strcasecmp(activateon, "caller"))
+				ast_set_flag(feature, AST_FEATURE_FLAG_ONSELF);
+			else if (!strcasecmp(activateon, "peer") || !strcasecmp(activateon, "callee"))
+				ast_set_flag(feature, AST_FEATURE_FLAG_ONPEER);
 			else {
-				ast_log(LOG_NOTICE, "Invalid 'activateon' specification for feature '%s', must be caller, or callee\n", var->name);
+				ast_log(LOG_NOTICE, "Invalid 'ActivateOn' specification for feature '%s',"
+					" must be 'self', or 'peer'\n", var->name);
+				continue;
+			}
+
+			if (ast_strlen_zero(activatedby))
+				ast_set_flag(feature, AST_FEATURE_FLAG_BYBOTH);
+			else if (!strcasecmp(activatedby, "caller"))
+				ast_set_flag(feature, AST_FEATURE_FLAG_BYCALLER);
+			else if (!strcasecmp(activatedby, "callee"))
+				ast_set_flag(feature, AST_FEATURE_FLAG_BYCALLEE);
+			else if (!strcasecmp(activatedby, "both"))
+				ast_set_flag(feature, AST_FEATURE_FLAG_BYBOTH);
+			else {
+				ast_log(LOG_NOTICE, "Invalid 'ActivatedBy' specification for feature '%s',"
+					" must be 'caller', or 'callee', or 'both'\n", var->name);
 				continue;
 			}
 



More information about the asterisk-commits mailing list