[asterisk-commits] branch oej/metermaids-trunk r36015 - /team/oej/metermaids-trunk/res/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Jun 26 02:37:40 MST 2006


Author: oej
Date: Mon Jun 26 04:37:39 2006
New Revision: 36015

URL: http://svn.digium.com/view/asterisk?rev=36015&view=rev
Log:
Add capability to direct parking to one specific parking lot
(that you subscribe to). If that parking space ext does not exist,
execution continues after park() in the dialplan so you can
pick another parking space.
Also, simplify code by adding a string version of the parking
lot to the actual structure, so that we don't have to do a lot
of snprintf's.

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

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=36015&r1=36014&r2=36015&view=diff
==============================================================================
--- team/oej/metermaids-trunk/res/res_features.c (original)
+++ team/oej/metermaids-trunk/res/res_features.c Mon Jun 26 04:37:39 2006
@@ -256,14 +256,14 @@
 	pthread_setschedparam(thread, SCHED_RR, &sched);
 }
 
-static int adsi_announce_park(struct ast_channel *chan, int parkingnum)
+static int adsi_announce_park(struct ast_channel *chan, char *parkingexten)
 {
 	int res;
 	int justify[5] = {ADSI_JUST_CENT, ADSI_JUST_CENT, ADSI_JUST_CENT, ADSI_JUST_CENT};
 	char tmp[256];
 	char *message[5] = {NULL, NULL, NULL, NULL, NULL};
 
-	snprintf(tmp, sizeof(tmp), "Parked on %d", parkingnum);
+	snprintf(tmp, sizeof(tmp), "Parked on %s", parkingexten);
 	message[0] = tmp;
 	res = adsi_load_session(chan, NULL, 0, 1);
 	if (res == -1)
@@ -406,7 +406,7 @@
 		);
 
 	if (peer && adsipark && adsi_available(peer)) {
-		adsi_announce_park(peer, pu->parkingnum);	/* Only supports parking numbers */
+		adsi_announce_park(peer, pu->parkingexten);	/* Only supports parking numbers */
 		adsi_unload_session(peer);
 	}
 
@@ -416,11 +416,11 @@
 	if (!con)	/* Still no context? Bad */
 		ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con);
 	else {		/* Add extension to context */
-		if (!ast_add_extension2(con, 1, pu->parkingexten, 1, NULL, NULL, parkedcall, strdup(exten), FREE, registrar))
-			notify_metermaids(exten, parking_con);
+		if (!ast_add_extension2(con, 1, pu->parkingexten, 1, NULL, NULL, parkedcall, strdup(pu->parkingexten), FREE, registrar))
+			notify_metermaids(pu->parkingexten, parking_con);
 	}
 	/* Tell the peer channel the number of the parking space */
-	if (peer && !pu->parkingnum == -1) 
+	if (peer && !pu->parkingnum == -1) /* Only say number if it's a number */
 		ast_say_digits(peer, pu->parkingnum, "", peer->language);
 	if (pu->notquiteyet) {
 		/* Wake up parking thread if we're really done */
@@ -1570,7 +1570,7 @@
 					if (ast_context_remove_extension2(con, pt->parkingexten, 1, NULL))
 						ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
 					else
-						notify_metermaids(exten, parking_con);
+						notify_metermaids(pu->parkingexten, parking_con);
 				} else
 					ast_log(LOG_WARNING, "Whoa, no parking context?\n");
 				free(pt);
@@ -1610,7 +1610,7 @@
 							if (ast_context_remove_extension2(con, pt->parkingexten, 1, NULL))
 								ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
 						else
-							notify_metermaids(exten, parking_con);
+							notify_metermaids(pt->parkingexten, parking_con);
 						} else
 							ast_log(LOG_WARNING, "Whoa, no parking context?\n");
 						free(pt);
@@ -1720,22 +1720,20 @@
 		peer = pu->chan;
 		con = ast_context_find(parking_con);
 		if (con) {
-			char exten[AST_MAX_EXTENSION];
-			snprintf(exten, sizeof(exten), "%d", pu->parkingnum);
-			if (ast_context_remove_extension2(con, exten, 1, NULL))
+			if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL))
 				ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
 			else
-				notify_metermaids(exten, parking_con);
+				notify_metermaids(pu->parkingexten, parking_con);
 		} else
 			ast_log(LOG_WARNING, "Whoa, no parking context?\n");
 
 		manager_event(EVENT_FLAG_CALL, "UnParkedCall",
-			"Exten: %d\r\n"
+			"Exten: %s\r\n"
 			"Channel: %s\r\n"
 			"From: %s\r\n"
 			"CallerID: %s\r\n"
 			"CallerIDName: %s\r\n",
-			pu->parkingnum, pu->chan->name, chan->name,
+			pu->parkingexten, pu->chan->name, chan->name,
 			S_OR(pu->chan->cid.cid_num, "<unknown>"),
 			S_OR(pu->chan->cid.cid_name, "<unknown>")
 			);
@@ -1901,7 +1899,7 @@
 	char idText[256] = "";
 
 	if (!ast_strlen_zero(id))
-		snprintf(idText,256,"ActionID: %s\r\n",id);
+		snprintf(idText, 256, "ActionID: %s\r\n", id);
 
 	astman_send_ack(s, m, "Parked calls will follow");
 



More information about the asterisk-commits mailing list