[asterisk-commits] qwell: trunk r113452 - in /trunk: include/asterisk/features.h main/features.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 8 12:32:42 CDT 2008


Author: qwell
Date: Tue Apr  8 12:32:42 2008
New Revision: 113452

URL: http://svn.digium.com/view/asterisk?view=rev&rev=113452
Log:
Move AST_FEATURE_FLAG_* and FEATURE_RETURN_* to features.h so that they can be used by modules.

(closes issue #12384)
Reported by: fnordian
Patches:
      features.patch uploaded by fnordian (license 110)

(patch modified by me, to give FEATURE_RETURN_* an AST_ prefix)

Modified:
    trunk/include/asterisk/features.h
    trunk/main/features.c

Modified: trunk/include/asterisk/features.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/features.h?view=diff&rev=113452&r1=113451&r2=113452
==============================================================================
--- trunk/include/asterisk/features.h (original)
+++ trunk/include/asterisk/features.h Tue Apr  8 12:32:42 2008
@@ -24,6 +24,8 @@
 #ifndef _AST_FEATURES_H
 #define _AST_FEATURES_H
 
+#include "asterisk/pbx.h"
+
 #define FEATURE_MAX_LEN		11
 #define FEATURE_APP_LEN		64
 #define FEATURE_APP_ARGS_LEN	256
@@ -32,6 +34,16 @@
 #define FEATURE_MOH_LEN		80  /* same as MAX_MUSICCLASS from channel.h */
 
 /*! \brief main call feature structure */
+
+enum {
+	AST_FEATURE_FLAG_NEEDSDTMF = (1 << 0),
+	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),
+};
+
 struct ast_call_feature {
 	int feature_mask;
 	char *fname;
@@ -46,6 +58,15 @@
 	AST_LIST_ENTRY(ast_call_feature) feature_entry;
 };
 
+
+#define AST_FEATURE_RETURN_HANGUP            -1
+#define AST_FEATURE_RETURN_SUCCESSBREAK      0
+#define AST_FEATURE_RETURN_PBX_KEEPALIVE     AST_PBX_KEEPALIVE
+#define AST_FEATURE_RETURN_NO_HANGUP_PEER    AST_PBX_NO_HANGUP_PEER
+#define AST_FEATURE_RETURN_PASSDIGITS        21
+#define AST_FEATURE_RETURN_STOREDIGITS       22
+#define AST_FEATURE_RETURN_SUCCESS           23
+#define AST_FEATURE_RETURN_KEEPTRYING        24
 
 
 /*!

Modified: trunk/main/features.c
URL: http://svn.digium.com/view/asterisk/trunk/main/features.c?view=diff&rev=113452&r1=113451&r2=113452
==============================================================================
--- trunk/main/features.c (original)
+++ trunk/main/features.c Tue Apr  8 12:32:42 2008
@@ -65,15 +65,6 @@
 
 #define AST_MAX_WATCHERS 256
 
-enum {
-	AST_FEATURE_FLAG_NEEDSDTMF = (1 << 0),
-	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),
-};
-
 struct feature_group_exten {
 	AST_LIST_ENTRY(feature_group_exten) entry;
 	AST_DECLARE_STRING_FIELDS(
@@ -552,15 +543,6 @@
 }
 
 
-#define FEATURE_RETURN_HANGUP		-1
-#define FEATURE_RETURN_SUCCESSBREAK	 0
-#define FEATURE_RETURN_PBX_KEEPALIVE	AST_PBX_KEEPALIVE
-#define FEATURE_RETURN_NO_HANGUP_PEER	AST_PBX_NO_HANGUP_PEER
-#define FEATURE_RETURN_PASSDIGITS	 21
-#define FEATURE_RETURN_STOREDIGITS	 22
-#define FEATURE_RETURN_SUCCESS	 	 23
-#define FEATURE_RETURN_KEEPTRYING    24
-
 #define FEATURE_SENSE_CHAN	(1 << 0)
 #define FEATURE_SENSE_PEER	(1 << 1)
 
@@ -633,7 +615,7 @@
  * \param data
  * Check monitor app enabled, setup channels, both caller/callee chans not null
  * get TOUCH_MONITOR variable for filename if exists, exec monitor app.
- * \retval FEATURE_RETURN_SUCCESS on success.
+ * \retval AST_FEATURE_RETURN_SUCCESS on success.
  * \retval -1 on error.
 */
 static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense, void *data)
@@ -671,7 +653,7 @@
 	if (callee_chan->monitor) {
 		ast_verb(4, "User hit '%s' to stop recording call.\n", code);
 		callee_chan->monitor->stop(callee_chan, 1);
-		return FEATURE_RETURN_SUCCESS;
+		return AST_FEATURE_RETURN_SUCCESS;
 	}
 
 	if (caller_chan && callee_chan) {
@@ -715,7 +697,7 @@
 		pbx_builtin_setvar_helper(callee_chan, "TOUCH_MONITOR_OUTPUT", touch_filename);
 		pbx_builtin_setvar_helper(caller_chan, "TOUCH_MONITOR_OUTPUT", touch_filename);
 	
-		return FEATURE_RETURN_SUCCESS;
+		return AST_FEATURE_RETURN_SUCCESS;
 	}
 	
 	ast_log(LOG_NOTICE,"Cannot record the call. One or both channels have gone away.\n");	
@@ -780,7 +762,7 @@
 				return -1;
 			} else {
 				pbx_exec(callee_chan, stopmixmonitor_app, "");
-				return FEATURE_RETURN_SUCCESS;
+				return AST_FEATURE_RETURN_SUCCESS;
 			}
 		}
 		
@@ -823,7 +805,7 @@
 		pbx_exec(callee_chan, mixmonitor_app, args);
 		pbx_builtin_setvar_helper(callee_chan, "TOUCH_MIXMONITOR_OUTPUT", touch_filename);
 		pbx_builtin_setvar_helper(caller_chan, "TOUCH_MIXMONITOR_OUTPUT", touch_filename);
-		return FEATURE_RETURN_SUCCESS;
+		return AST_FEATURE_RETURN_SUCCESS;
 	
 	}
 
@@ -835,7 +817,7 @@
 static int builtin_disconnect(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense, void *data)
 {
 	ast_verb(4, "User hit '%s' to disconnect call.\n", code);
-	return FEATURE_RETURN_HANGUP;
+	return AST_FEATURE_RETURN_HANGUP;
 }
 
 static int finishup(struct ast_channel *chan)
@@ -879,7 +861,7 @@
  * 
  * Place chan on hold, check if transferred to parkinglot extension,
  * otherwise check extension exists and transfer caller.
- * \retval FEATURE_RETURN_SUCCESS.
+ * \retval AST_FEATURE_RETURN_SUCCESS.
  * \retval -1 on failure.
 */
 static int builtin_blindtransfer(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense, void *data)
@@ -967,7 +949,7 @@
 		ast_verb(2, "Hungup during autoservice stop on '%s'\n", transferee->name);
 		return res;
 	}
-	return FEATURE_RETURN_SUCCESS;
+	return AST_FEATURE_RETURN_SUCCESS;
 }
 
 /*!
@@ -1045,7 +1027,7 @@
 		finishup(transferee);
 		if (ast_stream_and_wait(transferer, "beeperr", ""))
 			return -1;
-		return FEATURE_RETURN_SUCCESS;
+		return AST_FEATURE_RETURN_SUCCESS;
 	}
 
 	/* valid extension, res == 1 */
@@ -1054,7 +1036,7 @@
 		finishup(transferee);
 		if (ast_stream_and_wait(transferer, "beeperr", ""))
 			return -1;
-		return FEATURE_RETURN_SUCCESS;
+		return AST_FEATURE_RETURN_SUCCESS;
 	}
 
 	l = strlen(xferto);
@@ -1073,7 +1055,7 @@
 				return -1;
 			if (ast_stream_and_wait(transferer, xfersound, ""))
 				ast_log(LOG_WARNING, "Failed to play transfer sound!\n");
-			return FEATURE_RETURN_SUCCESS;
+			return AST_FEATURE_RETURN_SUCCESS;
 		}
 
 		if (check_compat(transferer, newchan)) {
@@ -1091,7 +1073,7 @@
 				ast_log(LOG_WARNING, "Failed to play transfer sound!\n");
 			finishup(transferee);
 			transferer->_softhangup = 0;
-			return FEATURE_RETURN_SUCCESS;
+			return AST_FEATURE_RETURN_SUCCESS;
 		}
 		if (check_compat(transferee, newchan)) {
 			finishup(transferee);
@@ -1157,7 +1139,7 @@
 				ast_log(LOG_WARNING, "Transferer has invalid channel name: '%s'\n", transferer->name);
 				if (ast_stream_and_wait(transferee, "beeperr", ""))
 					return -1;
-				return FEATURE_RETURN_SUCCESS;
+				return AST_FEATURE_RETURN_SUCCESS;
 			}
 
 			ast_log(LOG_NOTICE, "We're trying to call %s/%s\n", transferer_tech, transferer_name);
@@ -1446,7 +1428,7 @@
  * \param chan,peer,config,code,sense,data
  *
  * Find a feature, determine which channel activated
- * \retval FEATURE_RETURN_PBX_KEEPALIVE,FEATURE_RETURN_NO_HANGUP_PEER
+ * \retval AST_FEATURE_RETURN_PBX_KEEPALIVE,AST_FEATURE_RETURN_NO_HANGUP_PEER
  * \retval -1 error.
  * \retval -2 when an application cannot be found.
 */
@@ -1464,7 +1446,7 @@
 
 	if (sense == FEATURE_SENSE_CHAN) {
 		if (!ast_test_flag(feature, AST_FEATURE_FLAG_BYCALLER))
-			return FEATURE_RETURN_KEEPTRYING;
+			return AST_FEATURE_RETURN_KEEPTRYING;
 		if (ast_test_flag(feature, AST_FEATURE_FLAG_ONSELF)) {
 			work = chan;
 			idle = peer;
@@ -1474,7 +1456,7 @@
 		}
 	} else {
 		if (!ast_test_flag(feature, AST_FEATURE_FLAG_BYCALLEE))
-			return FEATURE_RETURN_KEEPTRYING;
+			return AST_FEATURE_RETURN_KEEPTRYING;
 		if (ast_test_flag(feature, AST_FEATURE_FLAG_ONSELF)) {
 			work = peer;
 			idle = chan;
@@ -1502,13 +1484,13 @@
 	ast_autoservice_stop(idle);
 
 	if (res == AST_PBX_KEEPALIVE)
-		return FEATURE_RETURN_PBX_KEEPALIVE;
+		return AST_FEATURE_RETURN_PBX_KEEPALIVE;
 	else if (res == AST_PBX_NO_HANGUP_PEER)
-		return FEATURE_RETURN_NO_HANGUP_PEER;
+		return AST_FEATURE_RETURN_NO_HANGUP_PEER;
 	else if (res)
-		return FEATURE_RETURN_SUCCESSBREAK;
+		return AST_FEATURE_RETURN_SUCCESSBREAK;
 	
-	return FEATURE_RETURN_SUCCESS;	/*! \todo XXX should probably return res */
+	return AST_FEATURE_RETURN_SUCCESS;	/*! \todo XXX should probably return res */
 }
 
 static void unmap_features(void)
@@ -1551,7 +1533,7 @@
 {
 	int x;
 	struct ast_flags features;
-	int res = FEATURE_RETURN_PASSDIGITS;
+	int res = AST_FEATURE_RETURN_PASSDIGITS;
 	struct ast_call_feature *feature;
 	struct feature_group *fg = NULL;
 	struct feature_group_exten *fge;
@@ -1577,8 +1559,8 @@
 				res = builtin_features[x].operation(chan, peer, config, code, sense, NULL);
 				break;
 			} else if (!strncmp(builtin_features[x].exten, code, strlen(code))) {
-				if (res == FEATURE_RETURN_PASSDIGITS)
-					res = FEATURE_RETURN_STOREDIGITS;
+				if (res == AST_FEATURE_RETURN_PASSDIGITS)
+					res = AST_FEATURE_RETURN_STOREDIGITS;
 			}
 		}
 	}
@@ -1600,11 +1582,11 @@
 					continue;
 
 				res = fge->feature->operation(chan, peer, config, code, sense, fge->feature);
-				if (res != FEATURE_RETURN_KEEPTRYING) {
+				if (res != AST_FEATURE_RETURN_KEEPTRYING) {
 					AST_RWLIST_UNLOCK(&feature_groups);
 					break;
 				}
-				res = FEATURE_RETURN_PASSDIGITS;
+				res = AST_FEATURE_RETURN_PASSDIGITS;
 			}
 			if (fge)
 				break;
@@ -1622,13 +1604,13 @@
 		if (!strcmp(feature->exten, code)) {
 			ast_verb(3, " Feature Found: %s exten: %s\n",feature->sname, tok);
 			res = feature->operation(chan, peer, config, code, sense, feature);
-			if (res != FEATURE_RETURN_KEEPTRYING) {
+			if (res != AST_FEATURE_RETURN_KEEPTRYING) {
 				AST_LIST_UNLOCK(&feature_list);
 				break;
 			}
-			res = FEATURE_RETURN_PASSDIGITS;
+			res = AST_FEATURE_RETURN_PASSDIGITS;
 		} else if (!strncmp(feature->exten, code, strlen(code)))
-			res = FEATURE_RETURN_STOREDIGITS;
+			res = AST_FEATURE_RETURN_STOREDIGITS;
 
 		AST_LIST_UNLOCK(&feature_list);
 	}
@@ -2073,14 +2055,14 @@
 			config->feature_timer = backup_config.feature_timer;
 			res = ast_feature_interpret(chan, peer, config, featurecode, sense);
 			switch(res) {
-			case FEATURE_RETURN_PASSDIGITS:
+			case AST_FEATURE_RETURN_PASSDIGITS:
 				ast_dtmf_stream(other, who, featurecode, 0, 0);
 				/* Fall through */
-			case FEATURE_RETURN_SUCCESS:
+			case AST_FEATURE_RETURN_SUCCESS:
 				memset(featurecode, 0, sizeof(chan_featurecode));
 				break;
 			}
-			if (res >= FEATURE_RETURN_PASSDIGITS) {
+			if (res >= AST_FEATURE_RETURN_PASSDIGITS) {
 				res = 0;
 			} else 
 				break;




More information about the asterisk-commits mailing list