[asterisk-commits] oej: branch oej/multiparking r55331 - /team/oej/multiparking/res/res_features.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Feb 18 08:13:24 MST 2007


Author: oej
Date: Sun Feb 18 09:13:24 2007
New Revision: 55331

URL: http://svn.digium.com/view/asterisk?view=rev&rev=55331
Log:
Update

Modified:
    team/oej/multiparking/res/res_features.c

Modified: team/oej/multiparking/res/res_features.c
URL: http://svn.digium.com/view/asterisk/team/oej/multiparking/res/res_features.c?view=diff&rev=55331&r1=55330&r2=55331
==============================================================================
--- team/oej/multiparking/res/res_features.c (original)
+++ team/oej/multiparking/res/res_features.c Sun Feb 18 09:13:24 2007
@@ -1647,46 +1647,28 @@
 							snprintf(returnexten, sizeof(returnexten), "%s||t", peername);
 							ast_add_extension2(con, 1, peername, 1, NULL, NULL, "Dial", strdup(returnexten), ast_free, registrar);
 						}
-						ast_copy_string(pu->chan->exten, peername, sizeof(pu->chan->exten));
-						ast_copy_string(pu->chan->context, pu->parkinglot->parking_con_dial, sizeof(pu->chan->context));
-						pu->chan->priority = 1;
+						if (comebacktoorigin)
+							set_c_e_p(chan, pu->parkinglot->parking_con_dial, peername, 1);
+						else {
+							ast_log(LOG_WARNING, "now going to parkedcallstimeout,s,1 | ps is %d\n",pu->parkingnum);
+							snprintf(parkingslot, sizeof(parkingslot), "%d", pu->parkingnum);
+							pbx_builtin_setvar_helper(chan, "PARKINGSLOT", parkingslot);
+							set_c_e_p(chan, "parkedcallstimeout", peername, 1);
+						}
 
 					} else {
 						/* They've been waiting too long, send them back to where they came.  Theoretically they
 					   	should have their original extensions and such, but we copy to be on the safe side */
-						if (comebacktoorigin) { 
-							ast_copy_string(pu->chan->exten, pu->exten, sizeof(pu->chan->exten));
-							ast_copy_string(pu->chan->context, pu->parkinglot->parking_con_dial, sizeof(pu->chan->context));
-							pu->chan->priority = pu->priority;
-						} else {
-							if (option_verbose)
-								ast_verbose("Now going to parkedcallstimeout,s,1 | ps is %d\n", pu->parkingnum);
-							snprintf(parkingslot, sizeof(parkingslot), "%d", pu->parkingnum);
-							pbx_builtin_setvar_helper(pu->chan, "PARKINGSLOT", parkingslot);
-							ast_copy_string(pu->chan->exten, pu->exten, sizeof(pu->chan->exten));
-							ast_copy_string(pu->chan->context, pu->context, sizeof(pu->chan->context));
-							pu->chan->priority = pu->priority;
-						}
+						set_c_e_p(chan, pu->context, pu->exten, pu->priority);
+
 					}
-#ifdef OLD
-					manager_event(EVENT_FLAG_CALL, "ParkedCallTimeOut",
-						"Exten: %d\r\n"
-						"Channel: %s\r\n"
-						"Parkinglot: %s\r\n"
-						"CallerID: %s\r\n"
-						"CallerIDName: %s\r\n\r\n"
-						,pu->parkingnum, pu->chan->name, pu->parkinglot->name
-						,(pu->chan->cid.cid_num ? pu->chan->cid.cid_num : "<unknown>")
-						,(pu->chan->cid.cid_name ? pu->chan->cid.cid_name : "<unknown>")
-						);
-#endif
 
 					if (option_verbose > 1) 
 						ast_verbose(VERBOSE_PREFIX_2 "Timeout for %s parked on %d (%s). Returning to %s,%s,%d\n", pu->chan->name, pu->parkingnum, pu->parkinglot->name, pu->chan->context, pu->chan->exten, pu->chan->priority);
 					/* Start up the PBX, or hang them up */
-					if (ast_pbx_start(pu->chan))  {
+					if (ast_pbx_start(chan))  {
 						ast_log(LOG_WARNING, "Unable to restart the PBX for user on '%s', hanging them up...\n", pu->chan->name);
-						ast_hangup(pu->chan);
+						ast_hangup(chan);
 					}
 					/* And take them out of the parking lot */
 					if (pl) 
@@ -1704,80 +1686,75 @@
 					} else
 						ast_log(LOG_WARNING, "Whoa, no parking context?\n");
 					free(pt);
-				} else {
+				} else {	/* still within parking time, process descriptors */
 					for (x = 0; x < AST_MAX_FDS; x++) {
 						struct ast_frame *f;
-						if ((pu->chan->fds[x] > -1) && (FD_ISSET(pu->chan->fds[x], &rfds) || FD_ISSET(pu->chan->fds[x], &efds))) {
-							if (FD_ISSET(pu->chan->fds[x], &efds))
-								ast_set_flag(pu->chan, AST_FLAG_EXCEPTION);
+
+						if ((chan->fds[x] == -1) && (!FD_ISSET(chan->fds[x], &rfds) && !FD_ISSET(pu->chan->fds[x], &efds))) 
+							continue;
+
+						if (FD_ISSET(chan->fds[x], &efds))
+							ast_set_flag(chan, AST_FLAG_EXCEPTION);
+						else
+							ast_clear_flag(chan, AST_FLAG_EXCEPTION);
+						chan->fdno = x;
+
+						/* See if they need servicing */
+						f = ast_read(pu->chan);
+						/* Hangup? */
+						if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass ==  AST_CONTROL_HANGUP))) {
+							if (f)
+								ast_frfree(f);
+							post_manager_event("ParkedCallGiveUp", pu->parkingnum, chan);
+							/* There's a problem, hang them up*/
+							if (option_verbose > 1) 
+								ast_verbose(VERBOSE_PREFIX_2 "%s got tired of being parked\n", chan->name);
+							ast_hangup(chan);
+							/* And take them out of the parking lot */
+							if (pl) 
+								pl->next = pu->next;
 							else
-								ast_clear_flag(pu->chan, AST_FLAG_EXCEPTION);
-							pu->chan->fdno = x;
-							/* See if they need servicing */
-							f = ast_read(pu->chan);
-							if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass ==  AST_CONTROL_HANGUP))) {
-								if (f)
-									ast_frfree(f);
-								// post_manager_event("ParkedCallGiveUp", pu->parkingnum, chan);
-								manager_event(EVENT_FLAG_CALL, "ParkedCallGiveUp",
-									"Exten: %s\r\n"
-									"Channel: %s\r\n"
-									"CallerID: %s\r\n"
-									"CallerIDName: %s\r\n\r\n"
-									,pu->parkingexten, pu->chan->name,
-									(pu->chan->cid.cid_num ? pu->chan->cid.cid_num : "<unknown>"),
-									(pu->chan->cid.cid_name ? pu->chan->cid.cid_name : "<unknown>")
-									);
-								/* There's a problem, hang them up*/
-								if (option_verbose > 1) 
-									ast_verbose(VERBOSE_PREFIX_2 "%s got tired of being parked\n", pu->chan->name);
-								ast_hangup(pu->chan);
-								/* And take them out of the parking lot */
-								if (pl) 
-									pl->next = pu->next;
+								curlot->occupiedlots = pu->next;
+							pt = pu;
+							pu = pu->next;
+							con = ast_context_find(curlot->parking_con);
+							if (con) {
+								if (ast_context_remove_extension2(con, pt->parkingexten, 1, NULL))
+									ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
 								else
-									curlot->occupiedlots = pu->next;
-								pt = pu;
-								pu = pu->next;
-								con = ast_context_find(curlot->parking_con);
-								if (con) {
-									if (ast_context_remove_extension2(con, pt->parkingexten, 1, NULL))
-										ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
-									else
-										notify_metermaids(pt->parkingexten, curlot->parking_con);
-								} else
-									ast_log(LOG_WARNING, "Whoa, no parking context for parking lot %s?\n", curlot->name);
-								free(pt);
-								break;
-							} else {
-								/* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
-								ast_frfree(f);
-								if (pu->moh_trys < 3 && !pu->chan->generatordata) {
-									ast_log(LOG_DEBUG, "MOH on parked call stopped by outside source.  Restarting.\n");
-									ast_indicate_data(pu->chan, AST_CONTROL_HOLD, 
-										S_OR(parkmohclass, NULL),
-										!ast_strlen_zero(parkmohclass) ? strlen(parkmohclass) + 1 : 0);
-									pu->moh_trys++;
-								}
+									notify_metermaids(pt->parkingexten, curlot->parking_con);
+							} else
+								ast_log(LOG_WARNING, "Whoa, no parking context for parking lot %s?\n", curlot->name);
+							free(pt);
+							break;
+						} else {
+							/* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
+							ast_frfree(f);
+							if (pu->moh_trys < 3 && !chan->generatordata) {
+								if (option_debug)
+									ast_log(LOG_DEBUG, "MOH on parked call stopped by outside source.  Restarting on channel %s.\n", chan->name);
+								ast_indicate_data(chan, AST_CONTROL_HOLD, 
+									S_OR(parkmohclass, NULL),
+									!ast_strlen_zero(parkmohclass) ? strlen(parkmohclass) + 1 : 0);
+								pu->moh_trys++;
 							}
 							goto std;	/* XXX Ick: jumping into an else statement??? XXX */
 						}
-					}
+					} /* End for */
 					if (x >= AST_MAX_FDS) {
 	std:					for (x=0; x<AST_MAX_FDS; x++) {	/* mark fds for next round */
 							if (chan->fds[x] > -1) {
 								FD_SET(chan->fds[x], &nrfds);
 								FD_SET(chan->fds[x], &nefds);
-								if (chan->fds[x] > max)
-									max = chan->fds[x];
-							}
+							if (chan->fds[x] > max)
+								max = chan->fds[x];
 						}
-						/* Keep track of our shortest wait */
-						if (tms < ms || ms < 0)
-							ms = tms;
-						pl = pu;
-						pu = pu->next;
 					}
+					/* Keep track of our shortest wait */
+					if (tms < ms || ms < 0)
+						ms = tms;
+					pl = pu;
+					pu = pu->next;
 				}
 			}
 		} /* end while */



More information about the asterisk-commits mailing list