[asterisk-commits] jrose: branch jrose/bridge_projects r386328 - in /team/jrose/bridge_projects/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 22 16:57:59 CDT 2013


Author: jrose
Date: Mon Apr 22 16:57:55 2013
New Revision: 386328

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386328
Log:
Fix reloads again, remove unloads, and change parking_lot_states into parking lots

Modified:
    team/jrose/bridge_projects/res/parking/parking_applications.c
    team/jrose/bridge_projects/res/parking/parking_bridge.c
    team/jrose/bridge_projects/res/parking/parking_bridge_features.c
    team/jrose/bridge_projects/res/parking/parking_controller.c
    team/jrose/bridge_projects/res/parking/parking_manager.c
    team/jrose/bridge_projects/res/parking/parking_ui.c
    team/jrose/bridge_projects/res/parking/res_parking.h
    team/jrose/bridge_projects/res/res_parking.c

Modified: team/jrose/bridge_projects/res/parking/parking_applications.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/parking_applications.c?view=diff&rev=386328&r1=386327&r2=386328
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_applications.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_applications.c Mon Apr 22 16:57:55 2013
@@ -219,7 +219,7 @@
 	return 0;
 }
 
-int park_common_setup(struct parking_lot_state **lot_state, struct ast_bridge **parking_bridge, struct parked_user **pu,
+int park_common_setup(struct parking_lot **lot, struct ast_bridge **parking_bridge, struct parked_user **pu,
 		struct ast_channel *parker, struct ast_channel *parkee, const char *app_data)
 {
 	int silence_announcements = 0;
@@ -249,17 +249,17 @@
 		}
 	}
 
-	*lot_state = parking_lot_state_find_by_name(lot_name);
-
-	if (!*lot_state) {
+	*lot = parking_lot_find_by_name(lot_name);
+
+	if (!*lot) {
 		ast_log(LOG_ERROR, "Could not find parking lot: '%s'\n", lot_name);
 		ast_stream_and_wait(parker, "pbx-parkingfailed", "");
 		return -1;
 	}
 
-	ao2_lock(*lot_state);
-	*parking_bridge = parking_lot_state_get_bridge(*lot_state);
-	ao2_unlock(*lot_state);
+	ao2_lock(*lot);
+	*parking_bridge = parking_lot_get_bridge(*lot);
+	ao2_unlock(*lot);
 
 	if (!*parking_bridge) {
 		ast_log(LOG_ERROR, "Could not acquire holding bridge to park into\n");
@@ -267,7 +267,7 @@
 		return -1;
 	}
 
-	*pu = generate_parked_user(*lot_state, parkee, parker, randomize, time_limit);
+	*pu = generate_parked_user(*lot, parkee, parker, randomize, time_limit);
 
 	if (!*pu) {
 		ast_log(LOG_ERROR, "Failed to create parked user for channel %s, can not park.\n", ast_channel_name(parkee));
@@ -281,7 +281,7 @@
 	}
 
 	/* Apply relevant bridge roles and such to the parking channel */
-	parking_channel_set_roles(parkee, *lot_state, use_ringing);
+	parking_channel_set_roles(parkee, *lot, use_ringing);
 
 	/* If we need to go somewhere special after timeout, set special comeback arguments */
 	if (!ast_strlen_zero(comeback_override)) {
@@ -312,7 +312,7 @@
  */
 int park_app_exec(struct ast_channel *chan, const char *data)
 {
-	RAII_VAR(struct parking_lot_state *, lot_state, NULL, ao2_cleanup);
+	RAII_VAR(struct parking_lot *, lot, NULL, ao2_cleanup);
 	RAII_VAR(struct parked_user *, pu, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_bridge *, parking_bridge, NULL, ao2_cleanup);
 
@@ -325,7 +325,7 @@
 	}
 
 	/* Handle all the common aprking setup stuff */
-	if (park_common_setup(&lot_state, &parking_bridge, &pu, chan, chan, data)) {
+	if (park_common_setup(&lot, &parking_bridge, &pu, chan, chan, data)) {
 		return -1;
 	}
 
@@ -359,7 +359,7 @@
 
 int parked_call_app_exec(struct ast_channel *chan, const char *data)
 {
-	RAII_VAR(struct parking_lot_state *, lot_state, NULL, ao2_cleanup);
+	RAII_VAR(struct parking_lot *, lot, NULL, ao2_cleanup);
 	RAII_VAR(struct parked_user *, pu, NULL, ao2_cleanup); /* Parked user being retrieved */
 	RAII_VAR(struct ast_bridge *, parking_bridge, NULL, ao2_cleanup);
 	struct ast_bridge *retrieval_bridge;
@@ -397,9 +397,9 @@
 		lot_name = DEFAULT_PARKING_LOT;
 	}
 
-	lot_state = parking_lot_state_find_by_name(lot_name);
-
-	if (!lot_state) {
+	lot = parking_lot_find_by_name(lot_name);
+
+	if (!lot) {
 		ast_log(LOG_ERROR, "Could not find the requested parking lot\n");
 		ast_stream_and_wait(chan, "pbx-invalidpark", "");
 		return -1;
@@ -414,7 +414,7 @@
 	}
 
 	/* Attempt to get the parked user from the parking lot */
-	pu = parking_lot_state_retrieve_parked_user(lot_state, target_space);
+	pu = parking_lot_retrieve_parked_user(lot, target_space);
 	if (!pu) {
 		ast_stream_and_wait(chan, "pbx-invalidpark", "");
 		return -1;
@@ -430,7 +430,7 @@
 	}
 
 	/* Move the parkee into the new bridge */
-	if (ast_bridge_move(lot_state->parking_bridge, retrieval_bridge, pu->chan)) {
+	if (ast_bridge_move(lot->parking_bridge, retrieval_bridge, pu->chan)) {
 		ast_bridge_destroy(retrieval_bridge);
 		return -1;
 	}
@@ -443,11 +443,11 @@
 	}
 
 	/* Set the features */
-	parked_call_retrieve_enable_features(chan, lot_state, AST_FEATURE_FLAG_BYCALLER);
+	parked_call_retrieve_enable_features(chan, lot, AST_FEATURE_FLAG_BYCALLER);
 
 	/* If the parkedplay option is set for the caller to hear, play that tone now. */
-	if (lot_state->parkedplay & AST_FEATURE_FLAG_BYCALLER) {
-		ast_stream_and_wait(chan, lot_state->courtesytone, NULL);
+	if (lot->cfg->parkedplay & AST_FEATURE_FLAG_BYCALLER) {
+		ast_stream_and_wait(chan, lot->cfg->courtesytone, NULL);
 	}
 
 	/* Now we should try to join the new bridge ourselves... */

Modified: team/jrose/bridge_projects/res/parking/parking_bridge.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/parking_bridge.c?view=diff&rev=386328&r1=386327&r2=386328
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_bridge.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_bridge.c Mon Apr 22 16:57:55 2013
@@ -34,7 +34,7 @@
 	struct ast_bridge base;
 
 	/* private stuff for parking */
-	struct parking_lot_state *lot;
+	struct parking_lot *lot;
 };
 
 /*!
@@ -55,13 +55,13 @@
 
 static void bridge_parking_dissolving(struct ast_bridge_parking *self)
 {
-	struct parking_lot_state *lot_state = self->lot;
+	struct parking_lot *lot = self->lot;
 
 	ast_bridge_base_v_table.dissolving(&self->base);
 
-	/* Unlink the parking bridge from the parking lot state that owns it */
-	lot_state->parking_bridge = NULL;
-	ao2_ref(lot_state, -1);
+	/* Unlink the parking bridge from the parking lot that owns it */
+	lot->parking_bridge = NULL;
+	ao2_ref(lot, -1);
 
 	/* Disassociate the bridge from the parking lot as well. */
 	self->lot = NULL;
@@ -205,10 +205,10 @@
 		/* If answered or forced, the channel should be pulled from the bridge as part of that process and unlinked from
 		 * the parking lot afterwards. We do need to apply bridge features though and play the courtesy tone if set. */
 		publish_parked_call(pu, PARKED_CALL_UNPARKED);
-		parked_call_retrieve_enable_features(bridge_channel->chan, pu->lot_state, AST_FEATURE_FLAG_BYCALLEE);
-
-		if (pu->lot_state->parkedplay & AST_FEATURE_FLAG_BYCALLEE) {
-			ast_bridge_channel_queue_playfile(bridge_channel, NULL, pu->lot_state->courtesytone, NULL);
+		parked_call_retrieve_enable_features(bridge_channel->chan, pu->lot, AST_FEATURE_FLAG_BYCALLEE);
+
+		if (pu->lot->cfg->parkedplay & AST_FEATURE_FLAG_BYCALLEE) {
+			ast_bridge_channel_queue_playfile(bridge_channel, NULL, pu->lot->cfg->courtesytone, NULL);
 		}
 
 		return;
@@ -249,7 +249,7 @@
 	.notify_masquerade = (ast_bridge_notify_masquerade_fn) bridge_parking_notify_masquerade,
 };
 
-static struct ast_bridge *ast_bridge_parking_init(struct ast_bridge_parking *self, struct parking_lot_state *bridge_lot)
+static struct ast_bridge *ast_bridge_parking_init(struct ast_bridge_parking *self, struct parking_lot *bridge_lot)
 {
 	if (!self) {
 		return NULL;
@@ -261,13 +261,13 @@
 		return NULL;
 	}
 
-	/* It doesn't need to be a reference since the bridge only lives as long as the parking lot state lives. */
+	/* It doesn't need to be a reference since the bridge only lives as long as the parking lot lives. */
 	self->lot = bridge_lot;
 
 	return &self->base;
 }
 
-struct ast_bridge *bridge_parking_new(struct parking_lot_state *bridge_lot)
+struct ast_bridge *bridge_parking_new(struct parking_lot *bridge_lot)
 {
 	void *bridge;
 

Modified: team/jrose/bridge_projects/res/parking/parking_bridge_features.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/parking_bridge_features.c?view=diff&rev=386328&r1=386327&r2=386328
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_bridge_features.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_bridge_features.c Mon Apr 22 16:57:55 2013
@@ -40,7 +40,7 @@
 {
 	struct ast_bridge_channel *other;
 
-	RAII_VAR(struct parking_lot_state *, lot, NULL, ao2_cleanup);
+	RAII_VAR(struct parking_lot *, lot, NULL, ao2_cleanup);
 	RAII_VAR(struct parked_user *, pu, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_bridge *, parking_bridge, NULL, ao2_cleanup);
 
@@ -116,7 +116,7 @@
 	snprintf(parking_space, sizeof(parking_space), "%d", user->parking_space);
 	pbx_builtin_setvar_helper(chan, "PARKING_SPACE", parking_space);
 	pbx_builtin_setvar_helper(chan, "PARKINGSLOT", parking_space); /* Deprecated version of PARKING_SPACE */
-	pbx_builtin_setvar_helper(chan, "PARKEDLOT", user->lot_state->name);
+	pbx_builtin_setvar_helper(chan, "PARKEDLOT", user->lot->name);
 
 	peername = ast_strdupa(user->parker->name);
 	flatten_peername(peername);
@@ -127,7 +127,7 @@
 	if (!ast_strlen_zero(user->comeback)) {
 		ast_async_parseable_goto(chan, user->comeback);
 	} else {
-		comeback_goto(user, user->lot_state);
+		comeback_goto(user, user->lot);
 	}
 
 	return -1;

Modified: team/jrose/bridge_projects/res/parking/parking_controller.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/parking_controller.c?view=diff&rev=386328&r1=386327&r2=386328
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_controller.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_controller.c Mon Apr 22 16:57:55 2013
@@ -33,36 +33,36 @@
 #include "asterisk/features.h"
 #include "asterisk/bridging_basic.h"
 
-struct ast_bridge *parking_lot_state_get_bridge(struct parking_lot_state *state)
+struct ast_bridge *parking_lot_get_bridge(struct parking_lot *lot)
 {
 	struct ast_bridge *lot_bridge;
 
-	if (state->parking_bridge) {
-		ao2_ref(state->parking_bridge, +1);
-		return state->parking_bridge;
-	}
-
-	lot_bridge = bridge_parking_new(state);
+	if (lot->parking_bridge) {
+		ao2_ref(lot->parking_bridge, +1);
+		return lot->parking_bridge;
+	}
+
+	lot_bridge = bridge_parking_new(lot);
 	if (!lot_bridge) {
 		return NULL;
 	}
 
 	/* The parking lot needs a reference to the bridge as well. */
-	state->parking_bridge = lot_bridge;
-	ao2_ref(state->parking_bridge, +1);
+	lot->parking_bridge = lot_bridge;
+	ao2_ref(lot->parking_bridge, +1);
 
 	return lot_bridge;
 }
 
-void parking_channel_set_roles(struct ast_channel *chan, struct parking_lot_state *lot_state, int force_ringing)
+void parking_channel_set_roles(struct ast_channel *chan, struct parking_lot *lot, int force_ringing)
 {
 	ast_channel_add_bridge_role(chan, "holding_participant");
 	if (force_ringing) {
 		ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "ringing");
 	} else {
 		ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "musiconhold");
-		if (!ast_strlen_zero(lot_state->mohclass)) {
-			ast_channel_set_bridge_role_option(chan, "holding_participant", "moh_class", lot_state->mohclass);
+		if (!ast_strlen_zero(lot->cfg->mohclass)) {
+			ast_channel_set_bridge_role_option(chan, "holding_participant", "moh_class", lot->cfg->mohclass);
 		}
 	}
 }
@@ -73,16 +73,16 @@
 
 int unpark_parked_user(struct parked_user *pu)
 {
-	if (pu->lot_state) {
-		ao2_unlink(pu->lot_state->parked_users, pu);
-		parking_lot_state_remove_if_unused(pu->lot_state);
+	if (pu->lot) {
+		ao2_unlink(pu->lot->parked_users, pu);
+		parking_lot_remove_if_unused(pu->lot);
 		return 0;
 	}
 
 	return -1;
 }
 
-int parking_lot_state_get_space(struct parking_lot_state *lot, int target_override)
+int parking_lot_get_space(struct parking_lot *lot, int target_override)
 {
 	int original_target;
 	int current_target;
@@ -90,21 +90,21 @@
 	struct parked_user *user;
 	int wrap;
 
-	if (lot->parkfindnext) {
+	if (lot->cfg->parkfindnext) {
 		/* Use next_space if the lot has already has next_space set; otherwise use lot start. */
-		original_target = lot->next_space ? lot->next_space : lot->parking_start;
+		original_target = lot->next_space ? lot->next_space : lot->cfg->parking_start;
 	} else {
 		/* If not using find next mode, we just start at the start of the parking lot always. */
-		original_target = lot->parking_start;
-	}
-
-	if (target_override >= lot->parking_start && target_override <= lot->parking_stop) {
+		original_target = lot->cfg->parking_start;
+	}
+
+	if (target_override >= lot->cfg->parking_start && target_override <= lot->cfg->parking_stop) {
 		original_target = target_override;
 	}
 
 	current_target = original_target;
 
-	wrap = lot->parking_start;
+	wrap = lot->cfg->parking_start;
 
 	i = ao2_iterator_init(lot->parked_users, 0);
 	while ((user = ao2_iterator_next(&i))) {
@@ -131,11 +131,11 @@
 	}
 	ao2_iterator_destroy(&i);
 
-	if (current_target <= lot->parking_stop) {
+	if (current_target <= lot->cfg->parking_stop) {
 		return current_target;
 	}
 
-	if (wrap <= lot->parking_stop) {
+	if (wrap <= lot->cfg->parking_stop) {
 		return wrap;
 	}
 
@@ -164,7 +164,7 @@
 	return 0;
 }
 
-struct parked_user *parking_lot_state_retrieve_parked_user(struct parking_lot_state *lot, int target)
+struct parked_user *parking_lot_retrieve_parked_user(struct parking_lot *lot, int target)
 {
 	RAII_VAR(struct parked_user *, user, NULL, ao2_cleanup);
 
@@ -189,14 +189,14 @@
 	user->resolution = PARK_ANSWERED;
 	ao2_unlock(user);
 
-	parking_lot_state_remove_if_unused(user->lot_state);
+	parking_lot_remove_if_unused(user->lot);
 
 	/* Bump the ref count by 1 since the RAII_VAR will eat the reference otherwise */
 	ao2_ref(user, +1);
 	return user;
 }
 
-void parked_call_retrieve_enable_features(struct ast_channel *chan, struct parking_lot_state *lot_state, int recipient_mode)
+void parked_call_retrieve_enable_features(struct ast_channel *chan, struct parking_lot *lot, int recipient_mode)
 {
 	/* Enabling features here should be additive to features that are already on the channel. */
 	struct ast_flags feature_flags = { 0 };
@@ -206,20 +206,20 @@
 		feature_flags = *existing_features;
 	}
 
-	if (lot_state->parkedcalltransfers & recipient_mode) {
+	if (lot->cfg->parkedcalltransfers & recipient_mode) {
 		ast_set_flag(&feature_flags, AST_FEATURE_REDIRECT);
 		ast_set_flag(&feature_flags, AST_FEATURE_ATXFER);
 	}
 
-	if (lot_state->parkedcallreparking & recipient_mode) {
+	if (lot->cfg->parkedcallreparking & recipient_mode) {
 		ast_set_flag(&feature_flags, AST_FEATURE_PARKCALL);
 	}
 
-	if (lot_state->parkedcallhangup & recipient_mode) {
+	if (lot->cfg->parkedcallhangup & recipient_mode) {
 		ast_set_flag(&feature_flags, AST_FEATURE_DISCONNECT);
 	}
 
-	if (lot_state->parkedcallrecording & recipient_mode) {
+	if (lot->cfg->parkedcallrecording & recipient_mode) {
 		ast_set_flag(&feature_flags, AST_FEATURE_AUTOMON);
 		ast_set_flag(&feature_flags, AST_FEATURE_AUTOMIXMON);
 	}
@@ -233,8 +233,8 @@
 {
 	struct parked_user *pu = obj;
 
-	ao2_cleanup(pu->lot_state);
-	pu->lot_state = NULL;
+	ao2_cleanup(pu->lot);
+	pu->lot = NULL;
 
 	ao2_cleanup(pu->parker);
 	pu->parker = NULL;
@@ -260,7 +260,7 @@
 	}
 }
 
-int comeback_goto(struct parked_user *pu, struct parking_lot_state *lot_state)
+int comeback_goto(struct parked_user *pu, struct parking_lot *lot)
 {
 	struct ast_channel *chan = pu->chan;
 	char *peername = ast_strdupa(pu->parker->name);
@@ -268,7 +268,7 @@
 	/* Flatten the peername so that it can be used for performing the timeout PBX operations */
 	flatten_peername(peername);
 
-	if (lot_state->comebacktoorigin) {
+	if (lot->cfg->comebacktoorigin) {
 		if (ast_exists_extension(chan, PARK_DIAL_CONTEXT, peername, 1, NULL)) {
 			ast_async_goto(chan, PARK_DIAL_CONTEXT, peername, 1);
 		} else {
@@ -278,21 +278,21 @@
 		}
 	}
 
-	if (ast_exists_extension(chan, lot_state->comebackcontext, peername, 1, NULL)) {
-		ast_async_goto(chan, lot_state->comebackcontext, peername, 1);
+	if (ast_exists_extension(chan, lot->cfg->comebackcontext, peername, 1, NULL)) {
+		ast_async_goto(chan, lot->cfg->comebackcontext, peername, 1);
 		return 0;
 	}
 
-	if (ast_exists_extension(chan, lot_state->comebackcontext, "s", 1, NULL)) {
+	if (ast_exists_extension(chan, lot->cfg->comebackcontext, "s", 1, NULL)) {
 		ast_verb(2, "Could not start %s at %s,%s,1. Using 's@%s' instead.\n", ast_channel_name(chan),
-			lot_state->comebackcontext, peername, lot_state->comebackcontext);
-		ast_async_goto(chan, lot_state->comebackcontext, "s", 1);
+			lot->cfg->comebackcontext, peername, lot->cfg->comebackcontext);
+		ast_async_goto(chan, lot->cfg->comebackcontext, "s", 1);
 		return 0;
 	}
 
 	ast_verb(2, "Can not start %s at %s,%s,1 and exten 's@%s' does not exist. Using 's at default'\n",
 		ast_channel_name(chan),
-		lot_state->comebackcontext, peername, lot_state->comebackcontext);
+		lot->cfg->comebackcontext, peername, lot->cfg->comebackcontext);
 	ast_async_goto(chan, "default", "s", 1);
 
 	return 0;
@@ -303,14 +303,14 @@
 	pu->start = ast_tvnow();
 }
 
-struct parked_user *generate_parked_user(struct parking_lot_state *lot_state, struct ast_channel *chan, struct ast_channel *parker, int use_random_space, int time_limit)
+struct parked_user *generate_parked_user(struct parking_lot *lot, struct ast_channel *chan, struct ast_channel *parker, int use_random_space, int time_limit)
 {
 	struct parked_user *new_parked_user;
 	int preferred_space = -1; /* Initialize to use parking lot defaults */
 	int parking_space;
 	const char *parkingexten;
 
-	if (lot_state->parking_disabled) {
+	if (lot->mode == PARKINGLOT_DISABLED) {
 		ast_log(LOG_NOTICE, "Tried to park in a parking lot that is no longer able to be parked to.\n");
 		return NULL;
 	}
@@ -321,8 +321,8 @@
 	}
 
 	if (use_random_space) {
-		preferred_space = ast_random() % (lot_state->parking_stop - lot_state->parking_start + 1);
-		preferred_space += lot_state->parking_start;
+		preferred_space = ast_random() % (lot->cfg->parking_stop - lot->cfg->parking_start + 1);
+		preferred_space += lot->cfg->parking_start;
 	} else if ((parkingexten = ast_strdupa(S_OR(pbx_builtin_getvar_helper(chan, "PARKINGEXTEN"), "")))) {
 		if (!ast_strlen_zero(parkingexten)) {
 			if (sscanf(parkingexten, "%30d", &preferred_space) != 1 || preferred_space <= 0) {
@@ -333,37 +333,37 @@
 		}
 	}
 
-	/* We need to keep the lot state locked between parking_lot_state_get_space and actually placing it in the lot. Or until we decide not to. */
-	ao2_lock(lot_state);
-
-	parking_space = parking_lot_state_get_space(lot_state, preferred_space);
+	/* We need to keep the lot locked between parking_lot_get_space and actually placing it in the lot. Or until we decide not to. */
+	ao2_lock(lot);
+
+	parking_space = parking_lot_get_space(lot, preferred_space);
 	if (parking_space == -1) {
-		ast_log(LOG_NOTICE, "Failed to get parking space in lot '%s'. All full.\n", lot_state->name);
+		ast_log(LOG_NOTICE, "Failed to get parking space in lot '%s'. All full.\n", lot->name);
 		ao2_ref(new_parked_user, -1);
-		ao2_unlock(lot_state);
-		return NULL;
-	}
-
-	lot_state->next_space = ((parking_space + 1) - lot_state->parking_start) % (lot_state->parking_stop - lot_state->parking_start + 1) + lot_state->parking_start;
+		ao2_unlock(lot);
+		return NULL;
+	}
+
+	lot->next_space = ((parking_space + 1) - lot->cfg->parking_start) % (lot->cfg->parking_stop - lot->cfg->parking_start + 1) + lot->cfg->parking_start;
 	new_parked_user->chan = chan;
 	new_parked_user->parking_space = parking_space;
 
-	/* Have the parked user take a reference to the parking lot state. This reference should be immutable and released at destruction */
-	new_parked_user->lot_state = lot_state;
-	ao2_ref(lot_state, +1);
+	/* Have the parked user take a reference to the parking lot. This reference should be immutable and released at destruction */
+	new_parked_user->lot = lot;
+	ao2_ref(lot, +1);
 
 	new_parked_user->start = ast_tvnow();
-	new_parked_user->time_limit = (time_limit >= 0) ? time_limit : lot_state->parkingtime;
+	new_parked_user->time_limit = (time_limit >= 0) ? time_limit : lot->cfg->parkingtime;
 	new_parked_user->parker = ast_channel_snapshot_create(parker);
 	if (!new_parked_user->parker) {
 		ao2_ref(new_parked_user, -1);
-		ao2_unlock(lot_state);
+		ao2_unlock(lot);
 		return NULL;
 	}
 
 	/* Insert into the parking lot's parked user list. We can unlock the lot now. */
-	ao2_link(lot_state->parked_users, new_parked_user);
-	ao2_unlock(lot_state);
+	ao2_link(lot->parked_users, new_parked_user);
+	ao2_unlock(lot);
 
 	return new_parked_user;
 }

Modified: team/jrose/bridge_projects/res/parking/parking_manager.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/parking_manager.c?view=diff&rev=386328&r1=386327&r2=386328
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_manager.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_manager.c Mon Apr 22 16:57:55 2013
@@ -233,7 +233,7 @@
 	long int timeout;
 	long int duration;
 	struct timeval now = ast_tvnow();
-	const char *lot_name = pu->lot_state->name;
+	const char *lot_name = pu->lot->name;
 
 	if (!pu->parker) {
 		return NULL;
@@ -297,12 +297,12 @@
 
 static int manager_parking_status_single_lot(struct mansession *s, const struct message *m, const char *id_text, const char *lot_name)
 {
-	RAII_VAR(struct parking_lot_state *, curlot, NULL, ao2_cleanup);
+	RAII_VAR(struct parking_lot *, curlot, NULL, ao2_cleanup);
 	struct parked_user *curuser;
 	struct ao2_iterator iter_users;
 	int total = 0;
 
-	curlot = parking_lot_state_find_by_name(lot_name);
+	curlot = parking_lot_find_by_name(lot_name);
 
 	if (!curlot) {
 		astman_send_error(s, m, "Requested ParkingLot could not be found.");
@@ -345,10 +345,10 @@
 	struct ao2_container *lot_container;
 	struct ao2_iterator iter_lots;
 	struct ao2_iterator iter_users;
-	struct parking_lot_state *curlot;
+	struct parking_lot *curlot;
 	int total = 0;
 
-	lot_container = get_parking_lot_state_container();
+	lot_container = get_parking_lot_container();
 
 	if (!lot_container) {
 		ast_log(LOG_ERROR, "Failed to obtain parking lot list. Action canceled.\n");
@@ -414,7 +414,7 @@
 
 static int manager_append_event_parking_lot_data_cb(void *obj, void *arg, void *data, int flags)
 {
-	struct parking_lot_state *curlot = obj;
+	struct parking_lot *curlot = obj;
 	struct mansession *s = arg;
 	char *id_text = data;
 
@@ -426,9 +426,9 @@
 		"%s" /* The Action ID */
 		"\r\n",
 		curlot->name,
-		curlot->parking_start,
-		curlot->parking_stop,
-		curlot->parkingtime,
+		curlot->cfg->parking_start,
+		curlot->cfg->parking_stop,
+		curlot->cfg->parkingtime,
 		id_text);
 
 	return 0;
@@ -444,7 +444,7 @@
 		snprintf(id_text, sizeof(id_text), "ActionID: %s\r\n", id);
 	}
 
-	lot_container = get_parking_lot_state_container();
+	lot_container = get_parking_lot_container();
 
 	if (!lot_container) {
 		ast_log(LOG_ERROR, "Failed to obtain parking lot list. Action canceled.\n");

Modified: team/jrose/bridge_projects/res/parking/parking_ui.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/parking_ui.c?view=diff&rev=386328&r1=386327&r2=386328
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_ui.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_ui.c Mon Apr 22 16:57:55 2013
@@ -53,33 +53,33 @@
 	return 0;
 }
 
-static void display_parking_lot_state(struct parking_lot_state *lot, int fd)
+static void display_parking_lot(struct parking_lot *lot, int fd)
 {
 	ast_cli(fd, "Parking Lot: %s\n--------------------------------------------------------------------------\n", lot->name);
-	ast_cli(fd, "Parking Extension   :  %s\n", lot->parkext);
-	ast_cli(fd, "Parking Context     :  %s\n", lot->parking_con);
-	ast_cli(fd, "Parking Spaces      :  %d-%d\n", lot->parking_start, lot->parking_stop);
-	ast_cli(fd, "Parking Time        :  %u sec\n", lot->parkingtime);
-	ast_cli(fd, "Comeback to Origin  :  %s\n", lot->comebacktoorigin ? "yes" : "no");
-	ast_cli(fd, "Comeback Context    :  %s%s\n", lot->comebackcontext, lot->comebacktoorigin ? " (comebacktoorigin=yes, not used)" : "");
-	ast_cli(fd, "Comeback Dial Time  :  %u sec\n", lot->comebackdialtime);
-	ast_cli(fd, "MusicOnHold Class   :  %s\n", lot->mohclass);
-	ast_cli(fd, "Enabled             :  %s\n", lot->parking_disabled ? "no" : "yes");
+	ast_cli(fd, "Parking Extension   :  %s\n", lot->cfg->parkext);
+	ast_cli(fd, "Parking Context     :  %s\n", lot->cfg->parking_con);
+	ast_cli(fd, "Parking Spaces      :  %d-%d\n", lot->cfg->parking_start, lot->cfg->parking_stop);
+	ast_cli(fd, "Parking Time        :  %u sec\n", lot->cfg->parkingtime);
+	ast_cli(fd, "Comeback to Origin  :  %s\n", lot->cfg->comebacktoorigin ? "yes" : "no");
+	ast_cli(fd, "Comeback Context    :  %s%s\n", lot->cfg->comebackcontext, lot->cfg->comebacktoorigin ? " (comebacktoorigin=yes, not used)" : "");
+	ast_cli(fd, "Comeback Dial Time  :  %u sec\n", lot->cfg->comebackdialtime);
+	ast_cli(fd, "MusicOnHold Class   :  %s\n", lot->cfg->mohclass);
+	ast_cli(fd, "Enabled             :  %s\n", (lot->mode == PARKINGLOT_DISABLED) ? "no" : "yes");
 	ast_cli(fd, "\n");
 }
 
-static int display_parking_lot_state_cb(void *obj, void *arg, int flags)
+static int display_parking_lot_cb(void *obj, void *arg, int flags)
 {
 	int *fd = arg;
-	struct parking_lot_state *lot = obj;
-	display_parking_lot_state(lot, *fd);
+	struct parking_lot *lot = obj;
+	display_parking_lot(lot, *fd);
 	return 0;
 }
 
 static void cli_display_parking_lot(int fd, const char *name)
 {
-	RAII_VAR(struct parking_lot_state *, lot, NULL, ao2_cleanup);
-	lot = parking_lot_state_find_by_name(name);
+	RAII_VAR(struct parking_lot *, lot, NULL, ao2_cleanup);
+	lot = parking_lot_find_by_name(name);
 
 	/* If the parking lot couldn't be found with the search, also abort. */
 	if (!lot) {
@@ -87,7 +87,7 @@
 		return;
 	}
 
-	display_parking_lot_state(lot, fd);
+	display_parking_lot(lot, fd);
 
 	ast_cli(fd, "Parked Calls\n------------\n");
 
@@ -105,14 +105,14 @@
 {
 	struct ao2_container *lot_container;
 
-	lot_container = get_parking_lot_state_container();
+	lot_container = get_parking_lot_container();
 
 	if (!lot_container) {
 		ast_cli(fd, "Failed to obtain parking lot list.\n\n");
 		return;
 	}
 
-	ao2_callback(lot_container, OBJ_MULTIPLE | OBJ_NODATA, display_parking_lot_state_cb, &fd);
+	ao2_callback(lot_container, OBJ_MULTIPLE | OBJ_NODATA, display_parking_lot_cb, &fd);
 	ast_cli(fd, "\n");
 }
 
@@ -133,8 +133,8 @@
 static char *complete_parking_lot(const char *word, int seeking)
 {
 	char *ret = NULL;
-	struct parking_lot_state *lot;
-	struct ao2_container *global_lots = get_parking_lot_state_container();
+	struct parking_lot *lot;
+	struct ao2_container *global_lots = get_parking_lot_container();
 	struct parking_lot_complete search = {
 		.seeking = seeking,
 		};

Modified: team/jrose/bridge_projects/res/parking/res_parking.h
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/res_parking.h?view=diff&rev=386328&r1=386327&r2=386328
==============================================================================
--- team/jrose/bridge_projects/res/parking/res_parking.h (original)
+++ team/jrose/bridge_projects/res/parking/res_parking.h Mon Apr 22 16:57:55 2013
@@ -48,10 +48,31 @@
 	OPT_PARKEDRECORDING,
 };
 
-struct parking_lot_state {
+enum parking_lot_modes {
+	PARKINGLOT_NORMAL = 0,          /*! The parking lot is configured normally and can accept new calls. Disable on reload if the config isn't replaced.
+	                                 *  valid transitions: PARKINGLOT_DISABLED */
+	PARKINGLOT_DYNAMIC,             /*! The parking lot is a dynamically created parking lot. It can be parked to at any time. Disabled on last parked call leaving.
+	                                 *  valid transitions: PARKINGLOT_DISABLED */
+	PARKINGLOT_DISABLED,            /*! The parking lot is no longer linked to a parking lot in configuration. It can no longer be parked to.
+	                                 *  and it can not be parked to. Terminal Mode doest. */
+};
+
+struct parking_lot {
+	int next_space;                           /*!< When using parkfindnext, which space we should start searching from next time we park */
+	struct ast_bridge *parking_bridge;        /*!< Bridged where parked calls will rest until they are answered or otherwise leave */
+	struct ao2_container *parked_users;       /*!< List of parked users rigidly ordered by their parking space */
+	struct parking_lot_cfg *cfg;              /*!< Reference to configuration object for the parking lot */
+	enum parking_lot_modes mode;              /*!< Whether a parking lot is operational, being reconfigured, primed for deletion, or dynamically created. */
+	int disable_mark;                         /*!< On reload, disable this parking lot if it doesn't receive a new configuration. */
+
+	AST_DECLARE_STRING_FIELDS(
+		AST_STRING_FIELD(name);               /*!< Name of the parking lot object */
+	);
+};
+
+struct parking_lot_cfg {
 	int parking_start;                        /*!< First space in the parking lot */
 	int parking_stop;                         /*!< Last space in the parking lot */
-	int next_space;                           /*!< When using parkfindnext, which space we should start searching from next time we park */
 
 	unsigned int parkingtime;                 /*!< Analogous to parkingtime config option */
 	unsigned int comebackdialtime;            /*!< Analogous to comebackdialtime config option */
@@ -65,45 +86,6 @@
 	int parkedcallhangup;                     /*!< Analogous to parkedcallhangup config option */
 	int parkedcallrecording;                  /*!< Analogous to parkedcallrecording config option */
 
-	int parking_disabled;                     /*!< Used for reloading, keeps calls from being parked to a parking lot removed from configs */
-	struct ast_bridge *parking_bridge;        /*!< Bridged where parked calls will rest until they are answered or otherwise leave */
-	struct ao2_container *parked_users;   /*!< List of parked users rigidly ordered by their parking space */
-
-	int has_owner;                            /*!< Used for reloading, marks a parking lot to be removed from the list of parking lots when
-	                                           *   its last parked call has departed the parking_brige.
-	                                           */
-
-	AST_DECLARE_STRING_FIELDS(
-		AST_STRING_FIELD(name);               /*!< Name of the parking lot state object */
-		AST_STRING_FIELD(mohclass);           /*!< Analogous to mohclass config option */
-		AST_STRING_FIELD(parkext);            /*!< Analogous to parkext config option */
-		AST_STRING_FIELD(parking_con);        /*!< Analogous to context config option */
-		AST_STRING_FIELD(comebackcontext);    /*!< Analogous to comebackcontext config option */
-		AST_STRING_FIELD(courtesytone);       /*!< Analogous to courtesytone config option */
-	);
-};
-
-struct parking_lot_cfg {
-	int parking_start;                        /*!< First space in the parking lot */
-	int parking_stop;                         /*!< Last space in the parking lot */
-
-	unsigned int parkingtime;                 /*!< Analogous to parkingtime config option */
-	unsigned int comebackdialtime;            /*!< Analogous to comebackdialtime config option */
-	unsigned int parkfindnext;                /*!< Analogous to parkfindnext config option */
-	unsigned int parkext_exclusive;           /*!< Analogous to parkext_exclusive config option */
-	unsigned int parkaddhints;                /*!< Analogous to parkaddhints config option */
-	unsigned int comebacktoorigin;            /*!< Analogous to comebacktoorigin config option */
-	int parkedplay;                           /*!< Analogous to parkedplay config option */
-	int parkedcalltransfers;                  /*!< Analogous to parkedcalltransfers config option */
-	int parkedcallreparking;                  /*!< Analogous to parkedcallreparking config option */
-	int parkedcallhangup;                     /*!< Analogous to parkedcallhangup config option */
-	int parkedcallrecording;                  /*!< Analogous to parkedcallrecording config option */
-
-	struct parking_lot_state *state;          /*!< State of the parking lot, generated on creation of the parking lot and
-	                                           *   unlinked from the parking lot and destroyed if and only if its call list
-	                                           *   is empty and it is removed from configuration.
-	                                           */
-
 	AST_DECLARE_STRING_FIELDS(
 		AST_STRING_FIELD(name);               /*!< Name of the parking lot configuration object */
 		AST_STRING_FIELD(mohclass);           /*!< Analogous to mohclass config option */
@@ -122,37 +104,37 @@
 	int parking_space;                        /*!< Which parking space is used */
 	char comeback[AST_MAX_CONTEXT];           /*!< Where to go on parking timeout */
 	unsigned int time_limit;                  /*!< How long this specific channel may remain in the parking lot before timing out */
-	struct parking_lot_state *lot_state;      /*!< Which parking lot the user is parked to */
+	struct parking_lot *lot;      /*!< Which parking lot the user is parked to */
 	enum park_call_resolution resolution;     /*!< How did the parking session end? If the call is in a bridge, lock parked_user before checking/setting */
 	int bridged;                              /*!< Flag raised when parked user enters the parking bridge. Used to determine a parked user is retrievable. */
 };
 
 /*!
  * \since 12
- * \brief If a parking lot state exists in the state list already, update its status to match the provided
+ * \brief If a parking lot exists in the parking lot list already, update its status to match the provided
  *        configuration and return a reference return a reference to it. Otherwise, create a parking lot
- *        state struct based on a parking lot configuration and return a reference to the new one.
- *
- * \param lot The lot being used as a reference to build the parking lot state from.
- *
- * \retval A reference to the new parking lot state
+ *        struct based on a parking lot configuration and return a reference to the new one.
+ *
+ * \param cfg The configuration being used as a reference to build the parking lot from.
+ *
+ * \retval A reference to the new parking lot
  * \retval NULL if it was not found and could not be be allocated
  *
- * \note The state will need to be unreffed if it ever falls out of scope
- * \note The state will automatically be added to the state container if needed as part of this process
- */
-struct parking_lot_state *parking_lot_state_build_or_update(struct parking_lot_cfg *lot);
+ * \note The parking lot will need to be unreffed if it ever falls out of scope
+ * \note The parking lot will automatically be added to the parking lot container if needed as part of this process
+ */
+struct parking_lot *parking_lot_build_or_update(struct parking_lot_cfg *cfg);
 
 /*!
  * \since 12
  * \brief Remove a parking lot from the usable lists if it is no longer involved in any calls and no configuration currently claims it
  *
- * \param lot Which parking lot state is being checked for elimination
+ * \param lot Which parking lot is being checked for elimination
  *
  * \note This should generally be called when something is happening that could cause a parking lot to die such as a call being unparked or
  *       a parking lot no longer existing in configurations.
  */
-void parking_lot_state_remove_if_unused(struct parking_lot_state *lot);
+void parking_lot_remove_if_unused(struct parking_lot *lot);
 
 /*!
  * \since 12
@@ -163,7 +145,7 @@
  * \retval NULL if the bridge can not be created
  * \retval Newly created parking bridge
  */
-struct ast_bridge *bridge_parking_new(struct parking_lot_state *bridge_lot);
+struct ast_bridge *bridge_parking_new(struct parking_lot *bridge_lot);
 
 /*!
  * \since 12
@@ -176,7 +158,7 @@
  *
  * \note This bridge will need to be unreffed if it ever falls out of scope.
  */
-struct ast_bridge *parking_lot_state_get_bridge(struct parking_lot_state *state);
+struct ast_bridge *parking_lot_get_bridge(struct parking_lot *lot);
 
 /*!
  * \since 12
@@ -191,7 +173,7 @@
  * \note lot should be locked before this is called and unlocked only after a parked_user with the space
  *       returned has been added to the parking lot.
  */
-int parking_lot_state_get_space(struct parking_lot_state *lot, int target_override);
+int parking_lot_get_space(struct parking_lot *lot, int target_override);
 
 /*!
  * \since 12
@@ -207,28 +189,28 @@
  * \note The parked user will be removed from parking lot as part of this process
  * \note Remove this reference with ao2_cleanup once it falls out of scope.
  */
-struct parked_user *parking_lot_state_retrieve_parked_user(struct parking_lot_state *lot, int target);
+struct parked_user *parking_lot_retrieve_parked_user(struct parking_lot *lot, int target);
 
 /*!
  * \since 12
  * \brief Apply features based on the parking lot feature options
  *
  * \param chan Which channel's feature set is being modified
- * \param lot_state parking lot state which establishes the features used
+ * \param lot parking lot which establishes the features used
  * \param recipient_mode AST_FEATURE_FLAG_BYCALLER if the user is the retriever
  *                       AST_FEATURE_FLAG_BYCALLEE if the user is the parkee
  */
-void parked_call_retrieve_enable_features(struct ast_channel *chan, struct parking_lot_state *lot_state, int recipient_mode);
+void parked_call_retrieve_enable_features(struct ast_channel *chan, struct parking_lot *lot, int recipient_mode);
 
 /*!
  * \since 12
  * \brief Set necessary bridge roles on a channel that is about to enter a parking lot
  *
  * \param chan Entering channel
- * \param lot_state The parking lot state the channel will be entering
+ * \param lot The parking lot the channel will be entering
  * \param force_ringing Use ringing instead of music on hold
  */
-void parking_channel_set_roles(struct ast_channel *chan, struct parking_lot_state *lot_state, int force_ringing);
+void parking_channel_set_roles(struct ast_channel *chan, struct parking_lot *lot, int force_ringing);
 
 /*!
  * \since 12
@@ -241,23 +223,23 @@
 
 /*!
  * \since 12
- * \brief Get a pointer to the parking lot state container for purposes such as iteration
- *
- * \retval pointer to the parking lot state container.
- */
-struct ao2_container *get_parking_lot_state_container(void);
-/*!
- * \since 12
- * \brief Find a parking lot state based on its name
- *
- * \param lot_name Name of the parking lot state sought
- *
- * \retval The parking lot state if found
- * \retval NULL if no parking lot state with the name specified exists
+ * \brief Get a pointer to the parking lot container for purposes such as iteration
+ *
+ * \retval pointer to the parking lot container.
+ */
+struct ao2_container *get_parking_lot_container(void);
+/*!
+ * \since 12
+ * \brief Find a parking lot based on its name
+ *
+ * \param lot_name Name of the parking lot sought
+ *

[... 478 lines stripped ...]



More information about the asterisk-commits mailing list