[svn-commits] branch oej/metermaids-trunk r35237 - in /team/oej/metermaids-trunk: ./ channe...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed Jun 21 07:14:30 MST 2006


Author: oej
Date: Wed Jun 21 09:14:29 2006
New Revision: 35237

URL: http://svn.digium.com/view/asterisk?rev=35237&view=rev
Log:
Trying to restore status notification after Kevin's changes to chan_local
devicestate that doesn't work with metermaids. Implementing a special
option for parking by adding "/park" to the device address...


Modified:
    team/oej/metermaids-trunk/channels/chan_local.c
    team/oej/metermaids-trunk/devicestate.c
    team/oej/metermaids-trunk/res/res_features.c

Modified: team/oej/metermaids-trunk/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/oej/metermaids-trunk/channels/chan_local.c?rev=35237&r1=35236&r2=35237&view=diff
==============================================================================
--- team/oej/metermaids-trunk/channels/chan_local.c (original)
+++ team/oej/metermaids-trunk/channels/chan_local.c Wed Jun 21 09:14:29 2006
@@ -123,11 +123,13 @@
 {
 	char *exten;
 	char *context;
-
+	char *option;
+	int parkmode = 0;
 	int res;
 		
 	exten = ast_strdupa(data);
 	context = strchr(exten, '@');
+	option = strchr(exten, '/');	/* Find parking option */
 
 	if (!context) {
 		ast_log(LOG_WARNING, "Someone used Local/%s somewhere without a @context. This is bad.\n", exten);
@@ -135,16 +137,23 @@
 	}
 
 	*context = '\0';
-	context = context + 1;
+	context++;
+
+	if (option) {
+		*option = '\0';
+		option++;
+		if (!strcasecmp(option, "park"))
+			parkmode = 1;
+	}
 
 	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "Checking if extension %s@%s exists (devicestate)\n", exten, context);
+		ast_log(LOG_DEBUG, "Checking if extension %s@%s exists (devicestate%s)\n", exten, context, parkmode ? ", parkmode" : "");
 	res = ast_exists_extension(NULL, context, exten, 1, NULL);
-	if (!res) {
-		
-		return AST_DEVICE_INVALID;
-	} else
-		return AST_DEVICE_UNKNOWN;
+
+	if (!res)
+		return parkmode ? AST_DEVICE_UNAVAILABLE : AST_DEVICE_INVALID;
+	else
+		return parkmode ? AST_DEVICE_NOT_INUSE : AST_DEVICE_UNKNOWN;
 }
 
 static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_frame *f, struct ast_channel *us)

Modified: team/oej/metermaids-trunk/devicestate.c
URL: http://svn.digium.com/view/asterisk/team/oej/metermaids-trunk/devicestate.c?rev=35237&r1=35236&r2=35237&view=diff
==============================================================================
--- team/oej/metermaids-trunk/devicestate.c (original)
+++ team/oej/metermaids-trunk/devicestate.c Wed Jun 21 09:14:29 2006
@@ -201,9 +201,14 @@
 	char *device, *tmp;
 	struct state_change *change;
 
+	if (option_debug > 2)
+		ast_log(LOG_DEBUG, "Notification of state change to be queued on device/channel %s\n", buf);
+
 	device = buf;
 	if ((tmp = strrchr(device, '-')))
 		*tmp = '\0';
+
+	
 
 	if (change_thread == AST_PTHREADT_NULL || !(change = ast_calloc(1, sizeof(*change) + strlen(device)))) {
 		/* we could not allocate a change struct, or */

Modified: team/oej/metermaids-trunk/res/res_features.c
URL: http://svn.digium.com/view/asterisk/team/oej/metermaids-trunk/res/res_features.c?rev=35237&r1=35236&r2=35237&view=diff
==============================================================================
--- team/oej/metermaids-trunk/res/res_features.c (original)
+++ team/oej/metermaids-trunk/res/res_features.c Wed Jun 21 09:14:29 2006
@@ -450,7 +450,7 @@
 		ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con);
 	else {		/* Add extension to context */
 		snprintf(exten, sizeof(exten), "%d", x);
-		if (ast_add_extension2(con, 1, exten, 1, NULL, NULL, parkedcall, strdup(exten), FREE, registrar))
+		if (!ast_add_extension2(con, 1, exten, 1, NULL, NULL, parkedcall, strdup(exten), FREE, registrar))
 			notify_metermaids(exten, parking_con);
 	}
 	/* Tell the peer channel the number of the parking space */
@@ -2065,7 +2065,7 @@
 {
 	if (option_debug > 1)
 		ast_log(LOG_DEBUG, "Got notification of state change for %s@%s\n", exten, context);
-	ast_device_state_changed("local/%s@%s", exten, context);
+	ast_device_state_changed("local/%s@%s/park", exten, context);
 }
 
 /*! \brief Add parking hints for all defined parking lots */



More information about the svn-commits mailing list