[Asterisk-Users] res parking patch

Brancaleoni Matteo mbrancaleoni at espia.it
Thu Jul 3 14:36:15 MST 2003


Ok, a little patch that adds a little functionality to call parking.
With that, you can pickup the older parked call, if many are in the
parking lot. The default exten to do that is 750, but can be changed
by setting "parkpick => exten" on parking.conf , like

[general]
parkext => 800               ; What ext. to dial to park
parkpos => 801-820           ; What extensions to park calls on
parkpick => 821              ; What exten for picking older call on park
context => parkedcalls       ; Which context parked calls are in
parkingtime => 60            

I've done that since a customer asked me a such function.
Feel free to try it.
Disclaimer : I haven't tested it heavily... just seems to work ;)

Matteo.

-------------- next part --------------
--- asterisk/res/res_parking.c	2003-07-02 16:06:12.000000000 +0200
+++ myasterisk/res/res_parking.c	2003-07-03 23:28:52.000000000 +0200
@@ -49,6 +49,7 @@
 
 /* Extension you type to park the call */
 static char parking_ext[AST_MAX_EXTENSION] = "700";
+static char parking_pick[AST_MAX_EXTENSION] = "750";
 
 static char pickup_ext[AST_MAX_EXTENSION] = "*8";
 
@@ -507,7 +508,23 @@
 	park = atoi((char *)data);
 	ast_pthread_mutex_lock(&parking_lock);
 	pu = parkinglot;
-	while(pu) {
+	if (park == atoi((char *)parking_pick)) {
+	ast_log(LOG_NOTICE,"Picking up the older parked call!\n");
+  	   while(pu) {
+                if (!pu->next) {
+                        if (pl)
+                                pl->next = pu->next;
+                        else
+                                parkinglot = pu->next;
+      			break;
+                }
+    		pl = pu;
+                pu = pu->next;
+           }
+	}
+	else {
+	ast_log(LOG_NOTICE,"Normally picking up a parked call!\n");
+	   while(pu) {
 		if (pu->parkingnum == park) {
 			if (pl)
 				pl->next = pu->next;
@@ -517,6 +534,7 @@
 		}
 		pl = pu;
 		pu = pu->next;
+	   }
 	}
 	ast_pthread_mutex_unlock(&parking_lock);
 	if (pu) {
@@ -611,6 +629,8 @@
 		while(var) {
 			if (!strcasecmp(var->name, "parkext")) {
 				strncpy(parking_ext, var->value, sizeof(parking_ext) - 1);
+			} else if (!strcasecmp(var->name, "parkpick")) {
+				strncpy(parking_pick, var->value, sizeof(parking_pick) - 1);
 			} else if (!strcasecmp(var->name, "context")) {
 				strncpy(parking_con, var->value, sizeof(parking_con) - 1);
 			} else if (!strcasecmp(var->name, "parkingtime")) {
@@ -639,6 +659,11 @@
 			return -1;
 		}
 	}
+	// Adding the parkpick exten
+	snprintf(exten, sizeof(exten), "%s", parking_pick);
+	ast_add_extension2(con, 1, exten, 1, NULL, parkedcall, strdup(exten), free, registrar);
+	ast_log(LOG_NOTICE, "Created Older Parked Call Pick Exten as %s\n", parking_pick);
+	// end of the parkpick exten
 	for(x=parking_start; x<=parking_stop;x++) {
 		snprintf(exten, sizeof(exten), "%d", x);
 		ast_add_extension2(con, 1, exten, 1, NULL, parkedcall, strdup(exten), free, registrar);


More information about the asterisk-users mailing list