[asterisk-commits] oej: branch oej/multiparking r53055 -
/team/oej/multiparking/res/res_features.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Jan 31 17:48:28 MST 2007
Author: oej
Date: Wed Jan 31 18:48:27 2007
New Revision: 53055
URL: http://svn.digium.com/view/asterisk?view=rev&rev=53055
Log:
Let's try this version
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=53055&r1=53054&r2=53055
==============================================================================
--- team/oej/multiparking/res/res_features.c (original)
+++ team/oej/multiparking/res/res_features.c Wed Jan 31 18:48:27 2007
@@ -67,6 +67,7 @@
#define AST_MAX_WATCHERS 256
+/*! \bug Why isn't these flags documented? */
enum {
AST_FEATURE_FLAG_NEEDSDTMF = (1 << 0),
AST_FEATURE_FLAG_ONPEER = (1 << 1),
@@ -1590,13 +1591,8 @@
/*! \brief Take care of parked calls and unpark them if needed */
static void *do_parking_thread(void *ignore)
{
-<<<<<<< .working
struct ast_parkinglot *curlot;
- fd_set rfds, efds;
-=======
- char parkingslot[AST_MAX_EXTENSION];
fd_set rfds, efds; /* results from previous select, to be preserved across loops. */
->>>>>>> .merge-right.r52905
FD_ZERO(&rfds);
FD_ZERO(&efds);
@@ -1612,26 +1608,24 @@
ast_mutex_lock(&parking_lock);
pl = NULL;
-<<<<<<< .working
/* We need to do this for every parking lot */
AST_LIST_TRAVERSE(&parkinglots, curlot, list) {
pu = curlot->occupiedlots;
- FD_ZERO(&nrfds);
- FD_ZERO(&nefds);
+
while(pu) {
struct ast_channel *chan = pu->chan; /* shorthand */
int tms; /* timeout for this item */
int x; /* fd index in channel */
struct ast_context *con;
- if (pu->notquiteyet) {
- /* Pretend this one isn't here yet */
+
+ if (pu->notquiteyet) { /* Pretend this one isn't here yet */
pl = pu;
pu = pu->next;
continue;
+ }
tms = ast_tvdiff_ms(ast_tvnow(), pu->start);
if (tms > pu->parkingtime) {
/* Stop music on hold */
- ast_moh_stop(pu->chan);
ast_indicate(pu->chan, AST_CONTROL_UNHOLD);
/* Get chan, exten from derived kludge */
if (pu->peername[0]) {
@@ -1641,25 +1635,6 @@
if (cp)
*cp = 0;
con = ast_context_find(pu->parkinglot->parking_con_dial);
-=======
- if (pu->notquiteyet) { /* Pretend this one isn't here yet */
- pl = pu;
- pu = pu->next;
- continue;
- }
- tms = ast_tvdiff_ms(ast_tvnow(), pu->start);
- if (tms > pu->parkingtime) {
- ast_indicate(chan, AST_CONTROL_UNHOLD);
- /* Get chan, exten from derived kludge */
- if (pu->peername[0]) {
- char *peername = ast_strdupa(pu->peername);
- char *cp = strrchr(peername, '-');
- if (cp)
- *cp = 0;
- con = ast_context_find(parking_con_dial);
- if (!con) {
- con = ast_context_create(NULL, parking_con_dial, registrar);
->>>>>>> .merge-right.r52905
if (!con)
con = ast_context_create(NULL, pu->parkinglot->parking_con_dial, registrar);
if (!con) {
@@ -1669,7 +1644,7 @@
char returnexten[AST_MAX_EXTENSION];
snprintf(returnexten, sizeof(returnexten), "%s||t", peername);
- ast_add_extension2(con, 1, peername, 1, NULL, NULL, "Dial", strdup(returnexten), FREE, registrar);
+ 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));
@@ -1678,35 +1653,17 @@
} 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 */
- 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;
- }
-<<<<<<< .working
-=======
- if (con) {
- char returnexten[AST_MAX_EXTENSION];
- snprintf(returnexten, sizeof(returnexten), "%s||t", peername);
- ast_add_extension2(con, 1, peername, 1, NULL, NULL, "Dial", strdup(returnexten), ast_free, registrar);
- }
- if (comebacktoorigin) {
- set_c_e_p(chan, parking_con_dial, peername, 1);
- } else {
+ if (comebacktoorigin) {
+ 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;
+ } else {
ast_log(LOG_WARNING, "now going to parkedcallstimeout,s,1 | ps is %d\n",pu->parkingnum);
+ SKREP check with trunk
snprintf(parkingslot, sizeof(parkingslot), "%d", pu->parkingnum);
pbx_builtin_setvar_helper(pu->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 */
- set_c_e_p(chan, pu->context, pu->exten, pu->priority);
- }
->>>>>>> .merge-right.r52905
-
- post_manager_event("ParkedCallTimeOut", pu->parkingexten, chan);
-
-<<<<<<< .working
+ }
+ }
#ifdef OLD
manager_event(EVENT_FLAG_CALL, "ParkedCallTimeOut",
"Exten: %d\r\n"
@@ -1719,34 +1676,6 @@
,(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. Returning to %s,%s,%d\n", chan->name, pu->parkingnum, chan->context, chan->exten, chan->priority);
- /* Start up the PBX, or hang them up */
- if (ast_pbx_start(chan)) {
- ast_log(LOG_WARNING, "Unable to restart the PBX for user on '%s', hanging them up...\n", chan->name);
- ast_hangup(chan);
- }
- /* And take them out of the parking lot */
- if (pl)
- pl->next = pu->next;
- else
- parkinglot = pu->next;
- pt = pu;
- pu = pu->next;
- con = ast_context_find(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, parking_con);
- } else
- ast_log(LOG_WARNING, "Whoa, no parking context?\n");
- free(pt);
- } else { /* still within parking time, process descriptors */
- for (x = 0; x < AST_MAX_FDS; x++) {
- struct ast_frame *f;
->>>>>>> .merge-right.r52905
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);
@@ -1759,7 +1688,6 @@
if (pl)
pl->next = pu->next;
else
-<<<<<<< .working
curlot->occupiedlots = pu->next;
pt = pu;
pu = pu->next;
@@ -1767,6 +1695,8 @@
if (con) {
if (ast_context_remove_extension2(con, pt->parkingexten, 1, NULL))
ast_log(LOG_WARNING, "Whoa, failed to remove the parking extension!\n");
+ else
+ notify_metermaids(pt->parkingexten, curlot->parking_con);
} else
ast_log(LOG_WARNING, "Whoa, no parking context?\n");
free(pt);
@@ -1782,6 +1712,8 @@
/* 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"
@@ -1807,6 +1739,8 @@
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);
@@ -1816,54 +1750,13 @@
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_moh_start(pu->chan, NULL);
+ ast_indicate_data(pu->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 */
-=======
- ast_clear_flag(chan, AST_FLAG_EXCEPTION);
- chan->fdno = x;
-
- /* See if they need servicing */
- f = ast_read(chan);
- if (!f || (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP)) {
- if (f)
- ast_frfree(f);
- post_manager_event("ParkedCallGiveUp", pu->parkingexten, 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
- parkinglot = pu->next;
- pt = pu;
- pu = pu->next;
- con = ast_context_find(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, parking_con);
- } else
- ast_log(LOG_WARNING, "Whoa, no parking context?\n");
- free(pt);
- break;
- } else {
- /*! \todo 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.\n");
- ast_indicate_data(pu->chan, AST_CONTROL_HOLD,
- S_OR(parkmohclass, NULL),
- !ast_strlen_zero(parkmohclass) ? strlen(parkmohclass) + 1 : 0);
- pu->moh_trys++;
->>>>>>> .merge-right.r52905
}
}
if (x >= AST_MAX_FDS) {
@@ -1922,20 +1815,12 @@
{
/* Data is unused at the moment but could contain a parking
lot context eventually */
-<<<<<<< .working
- int res=0;
- struct localuser *u;
+ int res = 0;
+ struct ast_module_user *u;
const char *parkinglotname = DEFAULT_PARKINGLOT;
struct ast_parkinglot *parkinglot = NULL;
- LOCAL_USER_ADD(u);
-=======
- int res = 0;
- struct ast_module_user *u;
-
u = ast_module_user_add(chan);
-
->>>>>>> .merge-right.r52905
/* Check if the channel has a parking lot */
parkinglotname = findparkinglotname(chan);
@@ -2189,12 +2074,6 @@
}
ast_cli(fd, "---\n%d parked call%s in total.\n", numparked, (numparked != 1) ? "s" : "");
ast_mutex_unlock(&parking_lock);
-<<<<<<< .working
-=======
- ast_cli(fd, "%d parked call%s.\n", numparked, ESS(numparked));
-
-
->>>>>>> .merge-right.r52905
return RESULT_SUCCESS;
}
@@ -2207,16 +2086,12 @@
handle_showfeatures, "Lists configured features",
showfeatures_help },
-<<<<<<< .working
-/*! \brief Dump parking lot status in manager */
-=======
{ { "show", "parkedcalls", NULL },
handle_parkedcalls, "Lists parked calls",
showparked_help },
};
/*! \brief Dump lot status */
->>>>>>> .merge-right.r52905
static int manager_parking_status( struct mansession *s, const struct message *m)
{
struct parkeduser *cur;
@@ -2232,7 +2107,6 @@
/* Do we need to lock all of parking? */
ast_mutex_lock(&parking_lock);
-<<<<<<< .working
AST_LIST_TRAVERSE(&parkinglots, parkinglot, list) {
cur=parkinglot->occupiedlots;
while(cur) {
@@ -2242,7 +2116,7 @@
"From: %s\r\n"
"Parkinglot: %s\r\n"
"Timeout: %ld\r\n"
- "CallerID: %s\r\n"
+ "CallerIDNum: %s\r\n"
"CallerIDName: %s\r\n"
"%s"
"\r\n",
@@ -2252,24 +2126,6 @@
S_OR(cur->chan->cid.cid_num, ""), /* XXX in other places it is <unknown> */
S_OR(cur->chan->cid.cid_name, ""),
idText);
-=======
- for (cur=parkinglot; cur; cur = cur->next) {
- astman_append(s, "Event: ParkedCall\r\n"
- "Exten: %d\r\n"
- "Channel: %s\r\n"
- "From: %s\r\n"
- "Timeout: %ld\r\n"
- "CallerIDNum: %s\r\n"
- "CallerIDName: %s\r\n"
- "%s"
- "\r\n",
- cur->parkingnum, cur->chan->name, cur->peername,
- (long)cur->start.tv_sec + (long)(cur->parkingtime/1000) - (long)time(NULL),
- S_OR(cur->chan->cid.cid_num, ""), /* XXX in other places it is <unknown> */
- S_OR(cur->chan->cid.cid_name, ""),
- idText);
- }
->>>>>>> .merge-right.r52905
cur = cur->next;
}
@@ -2514,7 +2370,6 @@
char old_parking_con[AST_MAX_EXTENSION] = "";
-<<<<<<< .working
strcpy(old_parking_ext, parking_ext);
if (default_parkinglot) {
strcpy(old_parking_con, default_parkinglot->parking_con);
@@ -2540,16 +2395,6 @@
transferdigittimeout = DEFAULT_TRANSFER_DIGIT_TIMEOUT;
featuredigittimeout = DEFAULT_FEATURE_DIGIT_TIMEOUT;
-
-=======
- /* 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';
->>>>>>> .merge-right.r52905
strcpy(xfersound, "beep");
strcpy(xferfailsound, "pbx-invalid");
courtesytone[0] = '\0'; /* No default setting */
@@ -2563,76 +2408,16 @@
atxfernoanswertimeout = DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER;
cfg = ast_config_load("features.conf");
-<<<<<<< .working
- if (cfg) {
- for (var = ast_variable_browse(cfg, "general"); var; var = var->next) {
- if (!strcasecmp(var->name, "parkext")) {
- ast_copy_string(parking_ext, var->value, sizeof(parking_ext));
- } else if (!strcasecmp(var->name, "context")) {
- 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);
- parkingtime = DEFAULT_PARK_TIME;
- } else
- parkingtime = parkingtime * 1000;
- } else if (!strcasecmp(var->name, "parkpos")) {
- ast_log(LOG_DEBUG, "Found parking position in general: %s\n", var->value);
- 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 parking.conf\n", var->lineno);
- } 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")) {
- default_parkinglot->parkfindnext = (!strcasecmp(var->value, "next"));
- } else if (!strcasecmp(var->name, "parkinghints")) {
- parkaddhints = ast_true(var->value);
- } else if (!strcasecmp(var->name, "adsipark")) {
- adsipark = ast_true(var->value);
- } else if (!strcasecmp(var->name, "transferdigittimeout")) {
- if ((sscanf(var->value, "%d", &transferdigittimeout) != 1) || (transferdigittimeout < 1)) {
- ast_log(LOG_WARNING, "%s is not a valid transferdigittimeout\n", var->value);
- transferdigittimeout = DEFAULT_TRANSFER_DIGIT_TIMEOUT;
- } else
- transferdigittimeout = transferdigittimeout * 1000;
- } else if (!strcasecmp(var->name, "featuredigittimeout")) {
- if ((sscanf(var->value, "%d", &featuredigittimeout) != 1) || (featuredigittimeout < 1)) {
- ast_log(LOG_WARNING, "%s is not a valid featuredigittimeout\n", var->value);
- featuredigittimeout = DEFAULT_FEATURE_DIGIT_TIMEOUT;
- }
- } else if (!strcasecmp(var->name, "atxfernoanswertimeout")) {
- if ((sscanf(var->value, "%d", &atxfernoanswertimeout) != 1) || (atxfernoanswertimeout < 1)) {
- ast_log(LOG_WARNING, "%s is not a valid atxfernoanswertimeout\n", var->value);
- atxfernoanswertimeout = DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER;
- } else
- atxfernoanswertimeout = atxfernoanswertimeout * 1000;
- } else if (!strcasecmp(var->name, "courtesytone")) {
- ast_copy_string(courtesytone, var->value, sizeof(courtesytone));
- } else if (!strcasecmp(var->name, "parkedplay")) {
- if (!strcasecmp(var->value, "both"))
- parkedplay = 2;
- else if (!strcasecmp(var->value, "parked"))
- parkedplay = 1;
- else
- parkedplay = 0;
- } else if (!strcasecmp(var->name, "xfersound")) {
- ast_copy_string(xfersound, var->value, sizeof(xfersound));
- } else if (!strcasecmp(var->name, "xferfailsound")) {
- ast_copy_string(xferfailsound, var->value, sizeof(xferfailsound));
- } else if (!strcasecmp(var->name, "pickupexten")) {
- ast_copy_string(pickup_ext, var->value, sizeof(pickup_ext));
-=======
if (!cfg) {
ast_log(LOG_WARNING,"Could not load features.conf\n");
return AST_MODULE_LOAD_DECLINE;
}
+
for (var = ast_variable_browse(cfg, "general"); var; var = var->next) {
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);
@@ -2640,17 +2425,55 @@
} else
parkingtime = parkingtime * 1000;
} else if (!strcasecmp(var->name, "parkpos")) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Found parking position in general: %s\n", var->value);
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 parking.conf\n", var->lineno);
- } else {
- parking_start = start;
- parking_stop = end;
->>>>>>> .merge-right.r52905
+ } 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")) {
+ default_parkinglot->parkfindnext = (!strcasecmp(var->value, "next"));
+ } else if (!strcasecmp(var->name, "parkinghints")) {
+ parkaddhints = ast_true(var->value);
+ } else if (!strcasecmp(var->name, "adsipark")) {
+ adsipark = ast_true(var->value);
+ } else if (!strcasecmp(var->name, "transferdigittimeout")) {
+ if ((sscanf(var->value, "%d", &transferdigittimeout) != 1) || (transferdigittimeout < 1)) {
+ ast_log(LOG_WARNING, "%s is not a valid transferdigittimeout\n", var->value);
+ transferdigittimeout = DEFAULT_TRANSFER_DIGIT_TIMEOUT;
+ } else
+ transferdigittimeout = transferdigittimeout * 1000;
+ } else if (!strcasecmp(var->name, "featuredigittimeout")) {
+ if ((sscanf(var->value, "%d", &featuredigittimeout) != 1) || (featuredigittimeout < 1)) {
+ ast_log(LOG_WARNING, "%s is not a valid featuredigittimeout\n", var->value);
+ featuredigittimeout = DEFAULT_FEATURE_DIGIT_TIMEOUT;
}
+ } else if (!strcasecmp(var->name, "atxfernoanswertimeout")) {
+ if ((sscanf(var->value, "%d", &atxfernoanswertimeout) != 1) || (atxfernoanswertimeout < 1)) {
+ ast_log(LOG_WARNING, "%s is not a valid atxfernoanswertimeout\n", var->value);
+ atxfernoanswertimeout = DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER;
+ } else
+ atxfernoanswertimeout = atxfernoanswertimeout * 1000;
+ } else if (!strcasecmp(var->name, "courtesytone")) {
+ ast_copy_string(courtesytone, var->value, sizeof(courtesytone));
+ } else if (!strcasecmp(var->name, "parkedplay")) {
+ if (!strcasecmp(var->value, "both"))
+ parkedplay = 2;
+ else if (!strcasecmp(var->value, "parked"))
+ parkedplay = 1;
+ else
+ parkedplay = 0;
+ } else if (!strcasecmp(var->name, "xfersound")) {
+ ast_copy_string(xfersound, var->value, sizeof(xfersound));
+ } else if (!strcasecmp(var->name, "xferfailsound")) {
+ ast_copy_string(xferfailsound, var->value, sizeof(xferfailsound));
+ } else if (!strcasecmp(var->name, "pickupexten")) {
+ ast_copy_string(pickup_ext, var->value, sizeof(pickup_ext));
} else if (!strcasecmp(var->name, "findslot")) {
parkfindnext = (!strcasecmp(var->value, "next"));
- } else if (!strcasecmp(var->name, "parkinghints")) {
- parkaddhints = ast_true(var->value);
} else if (!strcasecmp(var->name, "parkedcalltransfers")) {
parkedcalltransfers = ast_true(var->value);
} else if (!strcasecmp(var->name, "adsipark")) {
More information about the asterisk-commits
mailing list