[svn-commits] oej: branch group/multiparking r104051 - /team/group/multiparking/main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Feb 23 09:30:14 CST 2008


Author: oej
Date: Sat Feb 23 09:30:13 2008
New Revision: 104051

URL: http://svn.digium.com/view/asterisk?view=rev&rev=104051
Log:
Build configuration

Modified:
    team/group/multiparking/main/features.c

Modified: team/group/multiparking/main/features.c
URL: http://svn.digium.com/view/asterisk/team/group/multiparking/main/features.c?view=diff&rev=104051&r1=104050&r2=104051
==============================================================================
--- team/group/multiparking/main/features.c (original)
+++ team/group/multiparking/main/features.c Sat Feb 23 09:30:13 2008
@@ -143,7 +143,7 @@
 	int parkfindnext;
 	int parkingtime;				/*!< Default parking time */
 	struct parkeduser *occupiedlots;
-	char parkmohclass[MAX_MUSICCLASS];                  /*!< Music class used for parking */
+	char mohclass[MAX_MUSICCLASS];                  /*!< Music class used for parking */
 	struct parkinglot_parklist parkings;		/*!< List of active parkings in this parkinglot */
 };
 
@@ -2683,8 +2683,11 @@
 		confvar = confvar->next;
 	}
 
-	if (!var)	/* Default parking lot */
+	if (!var) {	/* Default parking lot */
 		ast_copy_string(parkinglot->parking_con, "parkedcalls", sizeof(parkinglot->parking_con));
+		ast_copy_string(parkinglot->parking_con_dial, "park-dial", sizeof(parkinglot->parking_con_dial));
+		ast_copy_string(parkinglot->mohclass, "default", sizeof(parkinglot->mohclass));
+	}
 
 	/* Check for errors */
 	if (ast_strlen_zero(parkinglot->parking_con)) {
@@ -2770,21 +2773,39 @@
 		strcpy(old_parking_con, parking_con);
 	} 
 
+	if (default_parkinglot) {
+		strcpy(old_parking_con, default_parkinglot->parking_con);
+	} else {
+		default_parkinglot = build_parkinglot(DEFAULT_PARKINGLOT, NULL);
+		if (default_parkinglot) {
+			ASTOBJ_WRLOCK(default_parkinglot);
+			default_parkinglot->parking_start = 701;
+			default_parkinglot->parking_stop = 750;
+			default_parkinglot->parking_offset = 0;
+			default_parkinglot->parkfindnext = 0;
+			default_parkinglot->parkingtime = 0;
+			default_parkinglot->occupiedlots = NULL;
+		}
+	}
+	if (default_parkinglot) {
+		if (option_debug)
+			ast_log(LOG_DEBUG, "Configuration of default parkinglot done.\n");
+	} else {
+		ast_log(LOG_ERROR, "Configuration of default parkinglot failed.\n");
+		return -1;
+	}
+	
+
 	/* Reset to defaults */
-	strcpy(parking_con, "parkedcalls");
-	strcpy(parking_con_dial, "park-dial");
 	strcpy(parking_ext, "700");
 	strcpy(pickup_ext, "*8");
-	strcpy(parkmohclass, "default");
 	courtesytone[0] = '\0';
 	strcpy(xfersound, "beep");
 	strcpy(xferfailsound, "pbx-invalid");
-	parking_start = 701;
-	parking_stop = 750;
-	parkfindnext = 0;
 	adsipark = 0;
 	comebacktoorigin = 1;
-	parkaddhints = 0;
+
+	parkaddhints = 0;		/*! MVANBAAK-OEJ: Should these be move to the parkinglot structure????? */
 	parkedcalltransfers = 0;
 	parkedcallreparking = 0;
 
@@ -2804,7 +2825,7 @@
 		if (!strcasecmp(var->name, "parkext")) {
 			ast_copy_string(parking_ext, var->value, sizeof(parking_ext));
 		} else if (!strcasecmp(var->name, "context")) {
-			ast_copy_string(parking_con, var->value, sizeof(parking_con));
+			ast_copy_string(default_parkinglot->parking_con, var->value, sizeof(default_parkinglot->parking_con));
 		} else if (!strcasecmp(var->name, "parkingtime")) {
 			if ((sscanf(var->value, "%d", &parkingtime) != 1) || (parkingtime < 1)) {
 				ast_log(LOG_WARNING, "%s is not a valid parkingtime\n", var->value);
@@ -2814,12 +2835,14 @@
 		} else if (!strcasecmp(var->name, "parkpos")) {
 			if (sscanf(var->value, "%d-%d", &start, &end) != 2) {
 				ast_log(LOG_WARNING, "Format for parking positions is a-b, where a and b are numbers at line %d of features.conf\n", var->lineno);
-			} else {
-				parking_start = start;
-				parking_stop = end;
+			} else if (default_parkinglot) {
+				default_parkinglot->parking_start = start;
+				default_parkinglot->parking_stop = end;
+			} else 
+				ast_log(LOG_WARNING, "No default parking lot!\n");
 			}
 		} else if (!strcasecmp(var->name, "findslot")) {
-			parkfindnext = (!strcasecmp(var->value, "next"));
+			default_parkinglot->parkfindnext = (!strcasecmp(var->value, "next"));
 		} else if (!strcasecmp(var->name, "parkinghints")) {
 			parkaddhints = ast_true(var->value);
 		} else if (!strcasecmp(var->name, "parkedcalltransfers")) {
@@ -2886,7 +2909,7 @@
 		} else if (!strcasecmp(var->name, "comebacktoorigin")) {
 			comebacktoorigin = ast_true(var->value);
 		} else if (!strcasecmp(var->name, "parkedmusicclass")) {
-			ast_copy_string(parkmohclass, var->value, sizeof(parkmohclass));
+			ast_copy_string(default_parkinglot->mohclass, var->value, sizeof(default_parkinglot->mohclass));
 		}
 	}
 
@@ -2982,6 +3005,16 @@
 
 	ctg = NULL;
 	while ((ctg = ast_category_browse(cfg, ctg))) {
+		/* Is this a parkinglot definition ? */
+		if (!strncasecmp(ctg, "parkinglot_", strlen("parkinglot_"))) {
+			ast_debug(2, "Found configuration section %s, assume parking context\n", ctg);
+			if(!build_parkinglot(ctg, ast_variable_browse(cfg, ctg)))
+				ast_log(LOG_ERROR, "Could not build parking lot %s. Configuration error.\n", ctg);
+			else
+				ast_debug(1, "Configured parking context %s\n", ctg);
+			continue;	
+		}
+		/* No, check if it's a group */
 		for (i = 0; i < ARRAY_LEN(categories); i++) {
 			if (!strcasecmp(categories[i], ctg))
 				break;
@@ -3020,15 +3053,17 @@
 		ast_debug(1, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con);
 	}
 	
-	if (!(con = ast_context_find(parking_con)) && !(con = ast_context_create(NULL, parking_con, registrar))) {
-		ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con);
-		return -1;
+	if (!(con = ast_context_find(default_parkinglot->parking_con))) {
+		if (!(con = ast_context_create(NULL, default_parkinglot->parking_con, registrar))) {
+			ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", default_parkinglot->parking_con);
+			return -1;
+		}
 	}
 	res = ast_add_extension2(con, 1, ast_parking_ext(), 1, NULL, NULL, parkcall, NULL, NULL, registrar);
 	if (parkaddhints)
-		park_add_hints(parking_con, parking_start, parking_stop);
+		park_add_hints(default_parkinglot->parking_con, default_parkinglot->parking_start, default_parkinglot->parking_stop);
 	if (!res)
-		notify_metermaids(ast_parking_ext(), parking_con, AST_DEVICE_INUSE);
+		notify_metermaids(ast_parking_ext(), default_parkinglot->parking_con, AST_DEVICE_INUSE);
 	return res;
 
 }




More information about the svn-commits mailing list