[asterisk-commits] mjordan: branch mjordan/cdrs-of-doom r384854 - in /team/mjordan/cdrs-of-doom:...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Apr 5 17:22:16 CDT 2013
Author: mjordan
Date: Fri Apr 5 17:22:10 2013
New Revision: 384854
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384854
Log:
Remove CDRs from Asterisk
Sorta.
(compilation is still coming along, but I wouldn't want to lose this work if
a meteor takes out my laptop)
Modified:
team/mjordan/cdrs-of-doom/CHANGES
team/mjordan/cdrs-of-doom/addons/cdr_mysql.c
team/mjordan/cdrs-of-doom/addons/chan_ooh323.c
team/mjordan/cdrs-of-doom/apps/app_authenticate.c
team/mjordan/cdrs-of-doom/apps/app_cdr.c
team/mjordan/cdrs-of-doom/apps/app_dial.c
team/mjordan/cdrs-of-doom/apps/app_disa.c
team/mjordan/cdrs-of-doom/apps/app_dumpchan.c
team/mjordan/cdrs-of-doom/apps/app_followme.c
team/mjordan/cdrs-of-doom/apps/app_forkcdr.c
team/mjordan/cdrs-of-doom/apps/app_osplookup.c
team/mjordan/cdrs-of-doom/apps/app_queue.c
team/mjordan/cdrs-of-doom/cdr/cdr_adaptive_odbc.c
team/mjordan/cdrs-of-doom/cdr/cdr_csv.c
team/mjordan/cdrs-of-doom/cdr/cdr_manager.c
team/mjordan/cdrs-of-doom/cdr/cdr_odbc.c
team/mjordan/cdrs-of-doom/cdr/cdr_pgsql.c
team/mjordan/cdrs-of-doom/cdr/cdr_radius.c
team/mjordan/cdrs-of-doom/cdr/cdr_tds.c
team/mjordan/cdrs-of-doom/cel/cel_manager.c
team/mjordan/cdrs-of-doom/cel/cel_radius.c
team/mjordan/cdrs-of-doom/cel/cel_tds.c
team/mjordan/cdrs-of-doom/channels/chan_agent.c
team/mjordan/cdrs-of-doom/channels/chan_dahdi.c
team/mjordan/cdrs-of-doom/channels/chan_h323.c
team/mjordan/cdrs-of-doom/channels/chan_iax2.c
team/mjordan/cdrs-of-doom/channels/chan_local.c
team/mjordan/cdrs-of-doom/channels/chan_mgcp.c
team/mjordan/cdrs-of-doom/channels/chan_sip.c
team/mjordan/cdrs-of-doom/channels/chan_skinny.c
team/mjordan/cdrs-of-doom/channels/chan_unistim.c
team/mjordan/cdrs-of-doom/funcs/func_callerid.c
team/mjordan/cdrs-of-doom/funcs/func_cdr.c
team/mjordan/cdrs-of-doom/funcs/func_channel.c
team/mjordan/cdrs-of-doom/include/asterisk/cdr.h
team/mjordan/cdrs-of-doom/include/asterisk/cel.h
team/mjordan/cdrs-of-doom/include/asterisk/channel.h
team/mjordan/cdrs-of-doom/include/asterisk/test.h
team/mjordan/cdrs-of-doom/include/asterisk/time.h
team/mjordan/cdrs-of-doom/main/cdr.c
team/mjordan/cdrs-of-doom/main/cel.c
team/mjordan/cdrs-of-doom/main/channel.c
team/mjordan/cdrs-of-doom/main/channel_internal_api.c
team/mjordan/cdrs-of-doom/main/cli.c
team/mjordan/cdrs-of-doom/main/features.c
team/mjordan/cdrs-of-doom/main/manager.c
team/mjordan/cdrs-of-doom/main/manager_channels.c
team/mjordan/cdrs-of-doom/main/pbx.c
team/mjordan/cdrs-of-doom/main/utils.c
team/mjordan/cdrs-of-doom/res/res_agi.c
team/mjordan/cdrs-of-doom/res/res_config_sqlite.c
team/mjordan/cdrs-of-doom/res/res_monitor.c
team/mjordan/cdrs-of-doom/tests/test_cdr.c
Modified: team/mjordan/cdrs-of-doom/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/cdrs-of-doom/CHANGES?view=diff&rev=384854&r1=384853&r2=384854
==============================================================================
--- team/mjordan/cdrs-of-doom/CHANGES (original)
+++ team/mjordan/cdrs-of-doom/CHANGES Fri Apr 5 17:22:10 2013
@@ -10,6 +10,12 @@
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 11 to Asterisk 12 --------------------
------------------------------------------------------------------------------
+
+CDR changes:
+
+Too many to list, but:
+
+NewPeerAccount AMI event is gone. Just listen for NewAccountCode.
AMI (Asterisk Manager Interface)
Modified: team/mjordan/cdrs-of-doom/addons/cdr_mysql.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/cdrs-of-doom/addons/cdr_mysql.c?view=diff&rev=384854&r1=384853&r2=384854
==============================================================================
--- team/mjordan/cdrs-of-doom/addons/cdr_mysql.c (original)
+++ team/mjordan/cdrs-of-doom/addons/cdr_mysql.c Fri Apr 5 17:22:10 2013
@@ -277,9 +277,9 @@
strstr(entry->type, "real") ||
strstr(entry->type, "numeric") ||
strstr(entry->type, "fixed"))) {
- ast_cdr_getvar(cdr, cdrname, &value, workspace, sizeof(workspace), 0, 1);
+ ast_cdr_format_var(cdr, cdrname, &value, workspace, sizeof(workspace), 0, 1);
} else {
- ast_cdr_getvar(cdr, cdrname, &value, workspace, sizeof(workspace), 0, 0);
+ ast_cdr_format_var(cdr, cdrname, &value, workspace, sizeof(workspace), 0, 0);
}
if (value) {
Modified: team/mjordan/cdrs-of-doom/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/cdrs-of-doom/addons/chan_ooh323.c?view=diff&rev=384854&r1=384853&r2=384854
==============================================================================
--- team/mjordan/cdrs-of-doom/addons/chan_ooh323.c (original)
+++ team/mjordan/cdrs-of-doom/addons/chan_ooh323.c Fri Apr 5 17:22:10 2013
@@ -2372,7 +2372,7 @@
ast_parse_allow_disallow(&user->prefs,
user->cap, tcodecs, 1);
} else if (!strcasecmp(v->name, "amaflags")) {
- user->amaflags = ast_cdr_amaflags2int(v->value);
+ user->amaflags = ast_channel_string2amaflag(v->value);
} else if (!strcasecmp(v->name, "ip") || !strcasecmp(v->name, "host")) {
struct ast_sockaddr p;
if (!ast_parse_arg(v->value, PARSE_ADDR, &p)) {
@@ -2556,7 +2556,7 @@
ast_parse_allow_disallow(&peer->prefs, peer->cap,
tcodecs, 1);
} else if (!strcasecmp(v->name, "amaflags")) {
- peer->amaflags = ast_cdr_amaflags2int(v->value);
+ peer->amaflags = ast_channel_string2amaflag(v->value);
} else if (!strcasecmp(v->name, "roundtrip")) {
sscanf(v->value, "%d,%d", &peer->rtdrcount, &peer->rtdrinterval);
} else if (!strcasecmp(v->name, "dtmfmode")) {
@@ -2915,7 +2915,7 @@
"'lowdelay', 'throughput', 'reliability', "
"'mincost', or 'none'\n", v->lineno);
} else if (!strcasecmp(v->name, "amaflags")) {
- gAMAFLAGS = ast_cdr_amaflags2int(v->value);
+ gAMAFLAGS = ast_channel_string2amaflag(v->value);
} else if (!strcasecmp(v->name, "accountcode")) {
ast_copy_string(gAccountcode, v->value, sizeof(gAccountcode));
} else if (!strcasecmp(v->name, "disallow")) {
@@ -3115,7 +3115,7 @@
}
ast_cli(a->fd, "%-15.15s%s\n", "AccountCode: ", peer->accountcode);
- ast_cli(a->fd, "%-15.15s%s\n", "AMA flags: ", ast_cdr_flags2str(peer->amaflags));
+ ast_cli(a->fd, "%-15.15s%s\n", "AMA flags: ", ast_channel_amaflags2string(peer->amaflags));
ast_cli(a->fd, "%-15.15s%s\n", "IP:Port: ", ip_port);
ast_cli(a->fd, "%-15.15s%d\n", "OutgoingLimit: ", peer->outgoinglimit);
ast_cli(a->fd, "%-15.15s%d\n", "rtptimeout: ", peer->rtptimeout);
@@ -3274,7 +3274,7 @@
}
ast_cli(a->fd, "%-15.15s%s\n", "AccountCode: ", user->accountcode);
- ast_cli(a->fd, "%-15.15s%s\n", "AMA flags: ", ast_cdr_flags2str(user->amaflags));
+ ast_cli(a->fd, "%-15.15s%s\n", "AMA flags: ", ast_channel_amaflags2string(user->amaflags));
ast_cli(a->fd, "%-15.15s%s\n", "Context: ", user->context);
ast_cli(a->fd, "%-15.15s%d\n", "IncomingLimit: ", user->incominglimit);
ast_cli(a->fd, "%-15.15s%d\n", "InUse: ", user->inUse);
@@ -3523,7 +3523,7 @@
ast_cli(a->fd, "%-20s%ld\n", "Call counter: ", callnumber);
ast_cli(a->fd, "%-20s%s\n", "AccountCode: ", gAccountcode);
- ast_cli(a->fd, "%-20s%s\n", "AMA flags: ", ast_cdr_flags2str(gAMAFLAGS));
+ ast_cli(a->fd, "%-20s%s\n", "AMA flags: ", ast_channel_amaflags2string(gAMAFLAGS));
pAlias = gAliasList;
if(pAlias) {
Modified: team/mjordan/cdrs-of-doom/apps/app_authenticate.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/cdrs-of-doom/apps/app_authenticate.c?view=diff&rev=384854&r1=384853&r2=384854
==============================================================================
--- team/mjordan/cdrs-of-doom/apps/app_authenticate.c (original)
+++ team/mjordan/cdrs-of-doom/apps/app_authenticate.c Fri Apr 5 17:22:10 2013
@@ -213,9 +213,9 @@
continue;
ast_md5_hash(md5passwd, passwd);
if (!strcmp(md5passwd, md5secret)) {
- if (ast_test_flag(&flags,OPT_ACCOUNT)) {
+ if (ast_test_flag(&flags, OPT_ACCOUNT)) {
ast_channel_lock(chan);
- ast_cdr_setaccount(chan, buf);
+ ast_channel_accountcode_set(chan, buf);
ast_channel_unlock(chan);
}
break;
@@ -224,7 +224,7 @@
if (!strcmp(passwd, buf)) {
if (ast_test_flag(&flags, OPT_ACCOUNT)) {
ast_channel_lock(chan);
- ast_cdr_setaccount(chan, buf);
+ ast_channel_accountcode_set(chan, buf);
ast_channel_unlock(chan);
}
break;
@@ -250,7 +250,7 @@
if ((retries < 3) && !res) {
if (ast_test_flag(&flags,OPT_ACCOUNT) && !ast_test_flag(&flags,OPT_MULTIPLE)) {
ast_channel_lock(chan);
- ast_cdr_setaccount(chan, passwd);
+ ast_channel_accountcode_set(chan, passwd);
ast_channel_unlock(chan);
}
if (!(res = ast_streamfile(chan, "auth-thankyou", ast_channel_language(chan))))
Modified: team/mjordan/cdrs-of-doom/apps/app_cdr.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/cdrs-of-doom/apps/app_cdr.c?view=diff&rev=384854&r1=384853&r2=384854
==============================================================================
--- team/mjordan/cdrs-of-doom/apps/app_cdr.c (original)
+++ team/mjordan/cdrs-of-doom/apps/app_cdr.c Fri Apr 5 17:22:10 2013
@@ -35,25 +35,109 @@
#include "asterisk/channel.h"
#include "asterisk/module.h"
+#include "asterisk/app.h"
/*** DOCUMENTATION
<application name="NoCDR" language="en_US">
<synopsis>
- Tell Asterisk to not maintain a CDR for the current call
+ Tell Asterisk to not maintain a CDR for this channel.
</synopsis>
<syntax />
<description>
- <para>This application will tell Asterisk not to maintain a CDR for the current call.</para>
+ <para>This application will tell Asterisk not to maintain a CDR for
+ the current channel. This does <emphasis>NOT</emphasis> mean that
+ information is not tracked; rather, if the channel is hung up no
+ CDRs will be created for that channel.</para>
+ <para>If a subsequent call to ResetCDR occurs, all CDRs created for
+ the channel will be enabled.</para>
</description>
+ <see-also>
+ <ref type="application">ResetCDR</ref>
+ </see-also>
+ </application>
+ <application name="ResetCDR" language="en_US">
+ <synopsis>
+ Resets the Call Data Record.
+ </synopsis>
+ <syntax>
+ <parameter name="options">
+ <optionlist>
+ <option name="o">
+ <para>Prevent dispatch of the current CDR. Note that
+ other CDRs in the chain are not affected by this flag.</para>
+ </option>
+ <option name="v">
+ <para>Save the CDR variables.</para>
+ </option>
+ <option name="e">
+ <para>Enable the CDRs for this channel only (negate
+ effects of NoCDR).</para>
+ </option>
+ </optionlist>
+ </parameter>
+ </syntax>
+ <description>
+ <para>This application causes the Call Data Record to be reset.
+ Depending on the flags passed in, this can have several effects.
+ With no options, a reset does the following:</para>
+ <para>1. The <literal>start</literal> time is set to the current time.</para>
+ <para>2. If the channel is answered, the <literal>answer</literal> time is set to the
+ current time.</para>
+ <para>3. All variables are wiped from the CDR. Note that this step
+ can be prevented with the <literal>v</literal> option.</para>
+ <para>4. The <literal>billsec</literal> and <literal>duration</literal>
+ are re-computed from the new times.</para>
+ <para>If the <literal>o</literal> option is specified, any CDRs
+ currently created for the channel will not be dispatched. Any
+ subsequent CDRs created for a channel will be dispatched normally.</para>
+ <para>If the <literal>e</literal> option is specified, the effects
+ of the NoCDR application will be lifted. CDRs will be re-enabled for
+ this channel.</para>
+ </description>
+ <see-also>
+ <ref type="application">ForkCDR</ref>
+ <ref type="application">NoCDR</ref>
+ </see-also>
</application>
***/
static const char nocdr_app[] = "NoCDR";
+static const char resetcdr_app[] = "ResetCDR";
+
+enum reset_cdr_options {
+ OPT_DISABLE_DISPATCH = (1 << 0),
+ OPT_KEEP_VARS = (1 << 1),
+ OPT_ENABLE = (1 << 2),
+};
+
+AST_APP_OPTIONS(resetcdr_opts, {
+ AST_APP_OPTION('o', AST_CDR_FLAG_DISABLE_DISPATCH),
+ AST_APP_OPTION('v', AST_CDR_FLAG_KEEP_VARS),
+ AST_APP_OPTION('e', AST_CDR_FLAG_DISABLE),
+});
+
+static int resetcdr_exec(struct ast_channel *chan, const char *data)
+{
+ char *args;
+ struct ast_flags flags = { 0 };
+
+ if (!ast_strlen_zero(data)) {
+ args = ast_strdupa(data);
+ ast_app_parse_options(resetcdr_opts, &flags, NULL, args);
+ }
+
+ if (ast_cdr_reset(ast_channel_name(chan), &flags)) {
+ ast_log(AST_LOG_WARNING, "Failed to reset CDR for channel %s\n", ast_channel_name(chan));
+ }
+
+ return 0;
+}
static int nocdr_exec(struct ast_channel *chan, const char *data)
{
- if (ast_channel_cdr(chan))
- ast_set_flag(ast_channel_cdr(chan), AST_CDR_FLAG_POST_DISABLED);
+ if (ast_cdr_disable(ast_channel_name(chan))) {
+ ast_log(AST_LOG_WARNING, "Failed to disable CDR on %s\n", ast_channel_name(chan));
+ }
return 0;
}
@@ -65,8 +149,14 @@
static int load_module(void)
{
- if (ast_register_application_xml(nocdr_app, nocdr_exec))
+ int res = 0;
+
+ res |= ast_register_application_xml(nocdr_app, nocdr_exec);
+ res |= ast_register_application_xml(resetcdr_app, resetcdr_exec);
+
+ if (res) {
return AST_MODULE_LOAD_FAILURE;
+ }
return AST_MODULE_LOAD_SUCCESS;
}
Modified: team/mjordan/cdrs-of-doom/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/cdrs-of-doom/apps/app_dial.c?view=diff&rev=384854&r1=384853&r2=384854
==============================================================================
--- team/mjordan/cdrs-of-doom/apps/app_dial.c (original)
+++ team/mjordan/cdrs-of-doom/apps/app_dial.c Fri Apr 5 17:22:10 2013
@@ -751,36 +751,20 @@
static void handle_cause(int cause, struct cause_args *num)
{
- struct ast_cdr *cdr = ast_channel_cdr(num->chan);
-
switch(cause) {
case AST_CAUSE_BUSY:
- if (cdr)
- ast_cdr_busy(cdr);
num->busy++;
break;
-
case AST_CAUSE_CONGESTION:
- if (cdr)
- ast_cdr_failed(cdr);
num->congestion++;
break;
-
case AST_CAUSE_NO_ROUTE_DESTINATION:
case AST_CAUSE_UNREGISTERED:
- if (cdr)
- ast_cdr_failed(cdr);
num->nochan++;
break;
-
case AST_CAUSE_NO_ANSWER:
- if (cdr) {
- ast_cdr_noanswer(cdr);
- }
- break;
case AST_CAUSE_NORMAL_CLEARING:
break;
-
default:
num->nochan++;
break;
@@ -1087,7 +1071,6 @@
*/
*to = -1;
strcpy(pa->status, "CONGESTION");
- ast_cdr_failed(ast_channel_cdr(in));
ast_channel_publish_dial(in, outgoing->chan, NULL, pa->status);
return NULL;
}
@@ -1292,10 +1275,6 @@
peer = c;
ast_channel_publish_dial(in, peer, NULL, "ANSWER");
publish_dial_end_event(in, out_chans, peer, "CANCEL");
- if (ast_channel_cdr(peer)) {
- ast_channel_cdr(peer)->answer = ast_tvnow();
- ast_channel_cdr(peer)->disposition = AST_CDR_ANSWERED;
- }
ast_copy_flags64(peerflags, o,
OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER |
OPT_CALLEE_HANGUP | OPT_CALLER_HANGUP |
@@ -1533,7 +1512,6 @@
/* Got hung up */
*to = -1;
strcpy(pa->status, "CANCEL");
- ast_cdr_noanswer(ast_channel_cdr(in));
publish_dial_end_event(in, out_chans, NULL, pa->status);
if (f) {
if (f->data.uint32) {
@@ -1556,7 +1534,6 @@
if (onedigit_goto(in, context, (char) f->subclass.integer, 1)) {
ast_verb(3, "User hit %c to disconnect call.\n", f->subclass.integer);
*to = 0;
- ast_cdr_noanswer(ast_channel_cdr(in));
*result = f->subclass.integer;
strcpy(pa->status, "CANCEL");
publish_dial_end_event(in, out_chans, NULL, pa->status);
@@ -1575,7 +1552,6 @@
ast_verb(3, "User requested call disconnect.\n");
*to = 0;
strcpy(pa->status, "CANCEL");
- ast_cdr_noanswer(ast_channel_cdr(in));
publish_dial_end_event(in, out_chans, NULL, pa->status);
ast_frfree(f);
if (is_cc_recall) {
@@ -1670,12 +1646,9 @@
}
}
- if (!*to) {
+ if (!*to || ast_check_hangup(in)) {
ast_verb(3, "Nobody picked up in %d ms\n", orig);
publish_dial_end_event(in, out_chans, NULL, "NOANSWER");
- }
- if (!*to || ast_check_hangup(in)) {
- ast_cdr_noanswer(ast_channel_cdr(in));
}
#ifdef HAVE_EPOLL
@@ -1983,22 +1956,13 @@
time_t end;
struct ast_channel *chan = data;
- if (!ast_channel_cdr(chan)) {
- return;
- }
-
time(&end);
ast_channel_lock(chan);
- if (ast_channel_cdr(chan)->answer.tv_sec) {
- snprintf(buf, sizeof(buf), "%ld", (long) end - ast_channel_cdr(chan)->answer.tv_sec);
- pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
- }
-
- if (ast_channel_cdr(chan)->start.tv_sec) {
- snprintf(buf, sizeof(buf), "%ld", (long) end - ast_channel_cdr(chan)->start.tv_sec);
- pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
- }
+ snprintf(buf, sizeof(buf), "%d", ast_channel_get_up_time(chan));
+ pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
+ snprintf(buf, sizeof(buf), "%d", ast_channel_get_duration(chan));
+ pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
ast_channel_unlock(chan);
}
@@ -2258,8 +2222,9 @@
ast_channel_unlock(chan);
}
- if (ast_test_flag64(&opts, OPT_RESETCDR) && ast_channel_cdr(chan))
- ast_cdr_reset(ast_channel_cdr(chan), NULL);
+ if (ast_test_flag64(&opts, OPT_RESETCDR)) {
+ ast_cdr_reset(ast_channel_name(chan), 0);
+ }
if (ast_test_flag64(&opts, OPT_PRIVACY) && ast_strlen_zero(opt_args[OPT_ARG_PRIVACY]))
opt_args[OPT_ARG_PRIVACY] = ast_strdupa(ast_channel_exten(chan));
@@ -2582,10 +2547,6 @@
res = ast_call(tmp->chan, tmp->number, 0); /* Place the call, but don't wait on the answer */
ast_channel_lock(chan);
- /* Save the info in cdr's that we called them */
- if (ast_channel_cdr(chan))
- ast_cdr_setdestchan(ast_channel_cdr(chan), ast_channel_name(tmp->chan));
-
/* check the results of ast_call */
if (res) {
/* Again, keep going even if there's an error */
@@ -2700,10 +2661,6 @@
conversation. */
hanguptree(&out_chans, peer, 1);
/* If appropriate, log that we have a destination channel and set the answer time */
- if (ast_channel_cdr(chan)) {
- ast_cdr_setdestchan(ast_channel_cdr(chan), ast_channel_name(peer));
- ast_cdr_setanswer(ast_channel_cdr(chan), ast_channel_cdr(peer)->answer);
- }
if (ast_channel_name(peer))
pbx_builtin_setvar_helper(chan, "DIALEDPEERNAME", ast_channel_name(peer));
@@ -2800,8 +2757,8 @@
if (chan && peer && ast_test_flag64(&opts, OPT_GOTO) && !ast_strlen_zero(opt_args[OPT_ARG_GOTO])) {
/* chan and peer are going into the PBX, they both
* should probably get CDR records. */
- ast_clear_flag(ast_channel_cdr(chan), AST_CDR_FLAG_DIALED);
- ast_clear_flag(ast_channel_cdr(peer), AST_CDR_FLAG_DIALED);
+ ast_clear_flag(ast_channel_flags(chan), AST_FLAG_OUTGOING);
+ ast_clear_flag(ast_channel_flags(peer), AST_FLAG_OUTGOING);
ast_replace_subargument_delimiter(opt_args[OPT_ARG_GOTO]);
ast_parseable_goto(chan, opt_args[OPT_ARG_GOTO]);
Modified: team/mjordan/cdrs-of-doom/apps/app_disa.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/cdrs-of-doom/apps/app_disa.c?view=diff&rev=384854&r1=384853&r2=384854
==============================================================================
--- team/mjordan/cdrs-of-doom/apps/app_disa.c (original)
+++ team/mjordan/cdrs-of-doom/apps/app_disa.c Fri Apr 5 17:22:10 2013
@@ -362,7 +362,7 @@
if (k == 3) {
int recheck = 0;
- struct ast_flags cdr_flags = { AST_CDR_FLAG_POSTED };
+ struct ast_flags cdr_flags = { AST_CDR_FLAG_DISABLE_DISPATCH, };
if (!ast_exists_extension(chan, args.context, exten, 1,
S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
@@ -384,8 +384,10 @@
if (!ast_strlen_zero(acctcode))
ast_channel_accountcode_set(chan, acctcode);
- if (special_noanswer) cdr_flags.flags = 0;
- ast_cdr_reset(ast_channel_cdr(chan), &cdr_flags);
+ if (special_noanswer) {
+ ast_clear_flag(&cdr_flags, AST_CDR_FLAG_DISABLE_DISPATCH);
+ }
+ ast_cdr_reset(ast_channel_name(chan), &cdr_flags);
ast_explicit_goto(chan, args.context, exten, 1);
return 0;
}
Modified: team/mjordan/cdrs-of-doom/apps/app_dumpchan.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/cdrs-of-doom/apps/app_dumpchan.c?view=diff&rev=384854&r1=384853&r2=384854
==============================================================================
--- team/mjordan/cdrs-of-doom/apps/app_dumpchan.c (original)
+++ team/mjordan/cdrs-of-doom/apps/app_dumpchan.c Fri Apr 5 17:22:10 2013
@@ -69,7 +69,6 @@
static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
{
- struct timeval now;
long elapsed_seconds = 0;
int hour = 0, min = 0, sec = 0;
char nf[256];
@@ -78,17 +77,15 @@
struct ast_str *write_transpath = ast_str_alloca(256);
struct ast_str *read_transpath = ast_str_alloca(256);
- now = ast_tvnow();
memset(buf, 0, size);
if (!c)
return 0;
- if (ast_channel_cdr(c)) {
- elapsed_seconds = now.tv_sec - ast_channel_cdr(c)->start.tv_sec;
- hour = elapsed_seconds / 3600;
- min = (elapsed_seconds % 3600) / 60;
- sec = elapsed_seconds % 60;
- }
+ elapsed_seconds = ast_channel_get_duration(c);
+ hour = elapsed_seconds / 3600;
+ min = (elapsed_seconds % 3600) / 60;
+ sec = elapsed_seconds % 60;
+
snprintf(buf,size,
"Name= %s\n"
Modified: team/mjordan/cdrs-of-doom/apps/app_followme.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/cdrs-of-doom/apps/app_followme.c?view=diff&rev=384854&r1=384853&r2=384854
==============================================================================
--- team/mjordan/cdrs-of-doom/apps/app_followme.c (original)
+++ team/mjordan/cdrs-of-doom/apps/app_followme.c Fri Apr 5 17:22:10 2013
@@ -567,29 +567,6 @@
}
outbound = tmpuser->ochan;
- ast_channel_lock(outbound);
- if (!ast_channel_cdr(outbound)) {
- ast_channel_cdr_set(outbound, ast_cdr_alloc());
- if (ast_channel_cdr(outbound)) {
- ast_cdr_init(ast_channel_cdr(outbound), outbound);
- }
- }
- if (ast_channel_cdr(outbound)) {
- char tmp[256];
-
- snprintf(tmp, sizeof(tmp), "Local/%s", tmpuser->dialarg);
- ast_cdr_setapp(ast_channel_cdr(outbound), "FollowMe", tmp);
- ast_cdr_update(outbound);
- ast_cdr_start(ast_channel_cdr(outbound));
- ast_cdr_end(ast_channel_cdr(outbound));
- /* If the cause wasn't handled properly */
- if (ast_cdr_disposition(ast_channel_cdr(outbound), ast_channel_hangupcause(outbound))) {
- ast_cdr_failed(ast_channel_cdr(outbound));
- }
- } else {
- ast_log(LOG_WARNING, "Unable to create Call Detail Record\n");
- }
- ast_channel_unlock(outbound);
ast_hangup(outbound);
tmpuser->ochan = NULL;
}
@@ -1111,9 +1088,9 @@
*/
while ((tmpuser = AST_LIST_REMOVE_HEAD(&new_user_list, entry))) {
ast_channel_lock(tmpuser->ochan);
- if (ast_channel_cdr(tmpuser->ochan)) {
+ /*if (ast_channel_cdr(tmpuser->ochan)) {
ast_cdr_init(ast_channel_cdr(tmpuser->ochan), tmpuser->ochan);
- }
+ }*/
ast_channel_unlock(tmpuser->ochan);
destroy_calling_node(tmpuser);
}
@@ -1137,9 +1114,9 @@
/* Destroy this failed new outgoing call. */
ast_channel_lock(tmpuser->ochan);
- if (ast_channel_cdr(tmpuser->ochan)) {
+ /*if (ast_channel_cdr(tmpuser->ochan)) {
ast_cdr_init(ast_channel_cdr(tmpuser->ochan), tmpuser->ochan);
- }
+ }*/
ast_channel_unlock(tmpuser->ochan);
destroy_calling_node(tmpuser);
}
@@ -1290,15 +1267,10 @@
time(&end);
ast_channel_lock(chan);
- if (ast_channel_cdr(chan)->answer.tv_sec) {
- snprintf(buf, sizeof(buf), "%ld", (long) end - ast_channel_cdr(chan)->answer.tv_sec);
- pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
- }
-
- if (ast_channel_cdr(chan)->start.tv_sec) {
- snprintf(buf, sizeof(buf), "%ld", (long) end - ast_channel_cdr(chan)->start.tv_sec);
- pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
- }
+ snprintf(buf, sizeof(buf), "%d", ast_channel_get_up_time(chan));
+ pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
+ snprintf(buf, sizeof(buf), "%d", ast_channel_get_duration(chan));
+ pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
ast_channel_unlock(chan);
}
Modified: team/mjordan/cdrs-of-doom/apps/app_forkcdr.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/cdrs-of-doom/apps/app_forkcdr.c?view=diff&rev=384854&r1=384853&r2=384854
==============================================================================
--- team/mjordan/cdrs-of-doom/apps/app_forkcdr.c (original)
+++ team/mjordan/cdrs-of-doom/apps/app_forkcdr.c Fri Apr 5 17:22:10 2013
@@ -50,92 +50,52 @@
<parameter name="options">
<optionlist>
<option name="a">
- <para>Update the answer time on the NEW CDR just after it's been inited.
- The new CDR may have been answered already. The reset that forkcdr does
- will erase the answer time. This will bring it back, but the answer time
- will be a copy of the fork/start time. It will only do this if the initial
- cdr was indeed already answered.</para>
- </option>
- <option name="A">
- <para>Lock the original CDR against the answer time being updated. This
- will allow the disposition on the original CDR to remain the same.</para>
- </option>
- <option name="d">
- <para>Copy the disposition forward from the old cdr, after the init.</para>
- </option>
- <option name="D">
- <para>Clear the <literal>dstchannel</literal> on the new CDR after
- reset.</para>
+ <para>If the channel is answered, set the answer time on
+ the forked CDR to the current time. If this option is
+ not used, the answer time on the forked CDR will be the
+ answer time on the original CDR. If the channel is not
+ answered, this option has no effect.</para>
+ <para>Note that this option only applies with the
+ <literal>r</literal> option. The forked CDR is reset
+ by default which will implicitly set the answer time to
+ the current time if the channel is answered.</para>
</option>
<option name="e">
- <para>End the original CDR. Do this after all the necessary data is copied
- from the original CDR to the new forked CDR.</para>
+ <para>End the original CDR.</para>
</option>
<option name="r">
- <para>Do <emphasis>NOT</emphasis> reset the new cdr.</para>
- </option>
- <option name="s(name=val)">
- <para>Set the CDR var <replaceable>name</replaceable> in the original CDR,
- with value <replaceable>val</replaceable>.</para>
- </option>
- <option name="T">
- <para>Mark the original CDR with a DONT_TOUCH flag. setvar, answer, and end
- cdr funcs will obey this flag; normally they don't honor the LOCKED flag
- set on the original CDR record.</para>
- <note><para>Using this flag may cause CDR's not to have their end times
- updated! It is suggested that if you specify this flag, you might wish
- to use the <literal>e</literal> flag as well!.</para></note>
+ <para>Do <emphasis>NOT</emphasis> reset the forked CDR.
+ By default, the forked CDR is reset. Resetting the CDR
+ causes the start and answer times (if the channel is
+ answered) to be set to the current time.</para>
</option>
<option name="v">
- <para>When the new CDR is forked, it gets a copy of the vars attached to
- the current CDR. The vars attached to the original CDR are removed unless
- this option is specified.</para>
+ <para>Do not copy CDR variables and attributes from the
+ original CDR to the forked CDR.</para>
+ <warning><para>This option has changed. Previously, the
+ variables were removed from the original CDR. This no
+ longer occurs - this option now controls whether or not
+ a forked CDR inherits the variables from the original
+ CDR.</para></warning>
</option>
</optionlist>
</parameter>
</syntax>
<description>
- <para> Causes the Call Data Record to fork an additional cdr record starting from the time
- of the fork call. This new cdr record will be linked to end of the list of cdr records attached
- to the channel. The original CDR has a LOCKED flag set, which forces most cdr operations to skip
- it, except for the functions that set the answer and end times, which ignore the LOCKED flag. This
- allows all the cdr records in the channel to be 'ended' together when the channel is closed.</para>
- <para>The CDR() func (when setting CDR values) normally ignores the LOCKED flag also, but has options
- to vary its behavior. The 'T' option (described below), can override this behavior, but beware
- the risks.</para>
- <para>First, this app finds the last cdr record in the list, and makes a copy of it. This new copy
- will be the newly forked cdr record. Next, this new record is linked to the end of the cdr record list.
- Next, The new cdr record is RESET (unless you use an option to prevent this)</para>
- <para>This means that:</para>
- <para> 1. All flags are unset on the cdr record</para>
- <para> 2. the start, end, and answer times are all set to zero.</para>
- <para> 3. the billsec and duration fields are set to zero.</para>
- <para> 4. the start time is set to the current time.</para>
- <para> 5. the disposition is set to NULL.</para>
- <para>Next, unless you specified the <literal>v</literal> option, all variables will be removed from
- the original cdr record. Thus, the <literal>v</literal> option allows any CDR variables to be replicated
- to all new forked cdr records. Without the <literal>v</literal> option, the variables on the original
- are effectively moved to the new forked cdr record.</para>
- <para>Next, if the <literal>s</literal> option is set, the provided variable and value are set on the
- original cdr record.</para>
- <para>Next, if the <literal>a</literal> option is given, and the original cdr record has an answer time
- set, then the new forked cdr record will have its answer time set to its start time. If the old answer
- time were carried forward, the answer time would be earlier than the start time, giving strange
- duration and billsec times.</para>
- <para>If the <literal>d</literal> option was specified, the disposition is copied from
- the original cdr record to the new forked cdr. If the <literal>D</literal> option was specified,
- the destination channel field in the new forked CDR is erased. If the <literal>e</literal> option
- was specified, the 'end' time for the original cdr record is set to the current time. Future hang-up or
- ending events will not override this time stamp. If the <literal>A</literal> option is specified,
- the original cdr record will have it ANS_LOCKED flag set, which prevent future answer events from updating
- the original cdr record's disposition. Normally, an <literal>ANSWERED</literal> event would mark all cdr
- records in the chain as <literal>ANSWERED</literal>. If the <literal>T</literal> option is specified,
- the original cdr record will have its <literal>DONT_TOUCH</literal> flag set, which will force the
- cdr_answer, cdr_end, and cdr_setvar functions to leave that cdr record alone.</para>
- <para>And, last but not least, the original cdr record has its LOCKED flag set. Almost all internal
- CDR functions (except for the funcs that set the end, and answer times, and set a variable) will honor
- this flag and leave a LOCKED cdr record alone. This means that the newly created forked cdr record
- will be affected by events transpiring within Asterisk, with the previously noted exceptions.</para>
+ <para>Causes the Call Data Record engine to fork a new CDR starting
+ from the time the application is executed. The forked CDR will be
+ linked to end of the CDRs associated with the channel.</para>
+ <para>The forking operation proceeds as follows:</para>
+ <para>1. A copy is made of the last CDR associated with the channel.
+ All attributes and variables are copied over.</para>
+ <para>2. The forked CDR is reset. This sets the start time to the
+ current time. If the channel is answered, the answered time is set
+ to the current time as well. This behavior can be altered using the
+ <literal>r</literal> and <literal>a</literal> options.</para>
+ <para>3. If the <literal>e</literal> option is set, the original
+ CDR is finalized. Its end time is set to the current time. The
+ disposition of the original CDR will reflect the state of the
+ channel.</para>
</description>
<see-also>
<ref type="function">CDR</ref>
@@ -147,126 +107,35 @@
static char *app = "ForkCDR";
-enum {
- OPT_SETANS = (1 << 0),
- OPT_SETDISP = (1 << 1),
- OPT_RESETDEST = (1 << 2),
- OPT_ENDCDR = (1 << 3),
- OPT_NORESET = (1 << 4),
- OPT_KEEPVARS = (1 << 5),
- OPT_VARSET = (1 << 6),
- OPT_ANSLOCK = (1 << 7),
- OPT_DONTOUCH = (1 << 8),
-};
-
-enum {
- OPT_ARG_VARSET = 0,
- /* note: this entry _MUST_ be the last one in the enum */
- OPT_ARG_ARRAY_SIZE,
-};
-
AST_APP_OPTIONS(forkcdr_exec_options, {
- AST_APP_OPTION('a', OPT_SETANS),
- AST_APP_OPTION('A', OPT_ANSLOCK),
- AST_APP_OPTION('d', OPT_SETDISP),
- AST_APP_OPTION('D', OPT_RESETDEST),
- AST_APP_OPTION('e', OPT_ENDCDR),
- AST_APP_OPTION('R', OPT_NORESET),
- AST_APP_OPTION_ARG('s', OPT_VARSET, OPT_ARG_VARSET),
- AST_APP_OPTION('T', OPT_DONTOUCH),
- AST_APP_OPTION('v', OPT_KEEPVARS),
+ AST_APP_OPTION('a', AST_CDR_FLAG_SET_ANSWER),
+ AST_APP_OPTION('e', AST_CDR_FLAG_FINALIZE),
+ AST_APP_OPTION('r', AST_CDR_FLAG_NORESET),
+ AST_APP_OPTION('R', AST_CDR_FLAG_NORESET), /* Kept for backwards compatiblity */
+ AST_APP_OPTION('v', AST_CDR_FLAG_KEEP_VARS),
});
-
-static void ast_cdr_fork(struct ast_channel *chan, struct ast_flags optflags, char *set)
-{
- struct ast_cdr *cdr;
- struct ast_cdr *newcdr;
- struct ast_flags flags = { AST_CDR_FLAG_KEEP_VARS };
-
- cdr = ast_channel_cdr(chan);
-
- while (cdr->next)
- cdr = cdr->next;
-
- if (!(newcdr = ast_cdr_dup_unique(cdr)))
- return;
-
- /*
- * End the original CDR if requested BEFORE appending the new CDR
- * otherwise we incorrectly end the new CDR also.
- */
- if (ast_test_flag(&optflags, OPT_ENDCDR)) {
- ast_cdr_end(cdr);
- }
-
- ast_cdr_append(cdr, newcdr);
-
- if (!ast_test_flag(&optflags, OPT_NORESET))
- ast_cdr_reset(newcdr, &flags);
-
- if (!ast_test_flag(cdr, AST_CDR_FLAG_KEEP_VARS))
- ast_cdr_free_vars(cdr, 0);
-
- if (!ast_strlen_zero(set)) {
- char *varname = ast_strdupa(set), *varval;
- varval = strchr(varname,'=');
- if (varval) {
- *varval = 0;
- varval++;
- ast_cdr_setvar(cdr, varname, varval, 0);
- }
- }
-
- if (ast_test_flag(&optflags, OPT_SETANS) && !ast_tvzero(cdr->answer))
- newcdr->answer = newcdr->start;
-
- if (ast_test_flag(&optflags, OPT_SETDISP))
- newcdr->disposition = cdr->disposition;
-
- if (ast_test_flag(&optflags, OPT_RESETDEST))
- newcdr->dstchannel[0] = 0;
-
- if (ast_test_flag(&optflags, OPT_ANSLOCK))
- ast_set_flag(cdr, AST_CDR_FLAG_ANSLOCKED);
-
- if (ast_test_flag(&optflags, OPT_DONTOUCH))
- ast_set_flag(cdr, AST_CDR_FLAG_DONT_TOUCH);
-
- ast_set_flag(cdr, AST_CDR_FLAG_CHILD | AST_CDR_FLAG_LOCKED);
-}
static int forkcdr_exec(struct ast_channel *chan, const char *data)
{
- int res = 0;
- char *argcopy = NULL;
- struct ast_flags flags = {0};
- char *opts[OPT_ARG_ARRAY_SIZE];
- AST_DECLARE_APP_ARGS(arglist,
+ char *parse;
+ struct ast_flags flags = { 0, };
+ AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(options);
);
- if (!ast_channel_cdr(chan)) {
- ast_log(LOG_WARNING, "Channel does not have a CDR\n");
- return 0;
+ parse = ast_strdupa(data);
+
+ AST_STANDARD_APP_ARGS(args, parse);
+
+ if (!ast_strlen_zero(args.options)) {
+ ast_app_parse_options(forkcdr_exec_options, &flags, NULL, args.options);
}
- argcopy = ast_strdupa(data);
+ if (ast_cdr_fork(ast_channel_name(chan), &flags)) {
+ ast_log(AST_LOG_WARNING, "Failed to fork CDR for channel %s\n", ast_channel_name(chan));
+ }
- AST_STANDARD_APP_ARGS(arglist, argcopy);
-
- opts[OPT_ARG_VARSET] = 0;
-
- if (!ast_strlen_zero(arglist.options))
- ast_app_parse_options(forkcdr_exec_options, &flags, opts, arglist.options);
-
- if (!ast_strlen_zero(data)) {
- int keepvars = ast_test_flag(&flags, OPT_KEEPVARS) ? 1 : 0;
- ast_set2_flag(ast_channel_cdr(chan), keepvars, AST_CDR_FLAG_KEEP_VARS);
- }
-
- ast_cdr_fork(chan, flags, opts[OPT_ARG_VARSET]);
-
- return res;
+ return 0;
}
static int unload_module(void)
Modified: team/mjordan/cdrs-of-doom/apps/app_osplookup.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/cdrs-of-doom/apps/app_osplookup.c?view=diff&rev=384854&r1=384853&r2=384854
==============================================================================
--- team/mjordan/cdrs-of-doom/apps/app_osplookup.c (original)
+++ team/mjordan/cdrs-of-doom/apps/app_osplookup.c Fri Apr 5 17:22:10 2013
@@ -2814,7 +2814,7 @@
int inhandle = OSP_INVALID_HANDLE;
int outhandle = OSP_INVALID_HANDLE;
int recorded = 0;
- time_t start, connect, end;
+ time_t start = 0, connect = 0, end = 0;
unsigned int release;
char buffer[OSP_SIZE_INTSTR];
char inqos[OSP_SIZE_QOSSTR] = { 0 };
@@ -2866,19 +2866,18 @@
}
ast_debug(1, "OSPFinish: cause '%d'\n", cause);
- if (ast_channel_cdr(chan)) {
- start = ast_channel_cdr(chan)->start.tv_sec;
- connect = ast_channel_cdr(chan)->answer.tv_sec;
- if (connect) {
- end = time(NULL);
- } else {
- end = connect;
- }
+ if (!ast_tvzero(ast_channel_creationtime(chan))) {
+ start = ast_channel_creationtime(chan).tv_sec;
+ }
+ if (!ast_tvzero(ast_channel_answertime(chan))) {
+ connect = ast_channel_answertime(chan).tv_sec;
+ }
+ if (connect) {
+ end = time(NULL);
} else {
- start = 0;
- connect = 0;
- end = 0;
- }
+ end = connect;
+ }
+
ast_debug(1, "OSPFinish: start '%ld'\n", start);
ast_debug(1, "OSPFinish: connect '%ld'\n", connect);
ast_debug(1, "OSPFinish: end '%ld'\n", end);
Modified: team/mjordan/cdrs-of-doom/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/cdrs-of-doom/apps/app_queue.c?view=diff&rev=384854&r1=384853&r2=384854
==============================================================================
--- team/mjordan/cdrs-of-doom/apps/app_queue.c (original)
+++ team/mjordan/cdrs-of-doom/apps/app_queue.c Fri Apr 5 17:22:10 2013
@@ -3644,9 +3644,9 @@
member_call_pending_clear(tmp->member);
- if (ast_channel_cdr(qe->chan)) {
+ /*if (ast_channel_cdr(qe->chan)) {
ast_cdr_busy(ast_channel_cdr(qe->chan));
- }
+ }*/
tmp->stillgoing = 0;
++*busies;
return 0;
@@ -3699,21 +3699,6 @@
ast_channel_exten_set(tmp->chan, macroexten);
} else {
ast_channel_exten_set(tmp->chan, ast_channel_exten(qe->chan));
- }
- if (ast_cdr_isset_unanswered()) {
- /* they want to see the unanswered dial attempts! */
- /* set up the CDR fields on all the CDRs to give sensical information */
- ast_cdr_setdestchan(ast_channel_cdr(tmp->chan), ast_channel_name(tmp->chan));
- strcpy(ast_channel_cdr(tmp->chan)->clid, ast_channel_cdr(qe->chan)->clid);
- strcpy(ast_channel_cdr(tmp->chan)->channel, ast_channel_cdr(qe->chan)->channel);
- strcpy(ast_channel_cdr(tmp->chan)->src, ast_channel_cdr(qe->chan)->src);
- strcpy(ast_channel_cdr(tmp->chan)->dst, ast_channel_exten(qe->chan));
- strcpy(ast_channel_cdr(tmp->chan)->dcontext, ast_channel_context(qe->chan));
- strcpy(ast_channel_cdr(tmp->chan)->lastapp, ast_channel_cdr(qe->chan)->lastapp);
[... 5746 lines stripped ...]
More information about the asterisk-commits
mailing list