[svn-commits] murf: branch murf/cel2cdr r179603 - in /team/murf/cel2cdr: apps/ cel/ channel...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Mar 2 23:07:52 CST 2009


Author: murf
Date: Mon Mar  2 23:07:46 2009
New Revision: 179603

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=179603
Log:
When using cel2cdr, turn off all other sources of CDR generation. NOTE: come back & take care of the apps that want to display how long a channel has existed, etc.

Modified:
    team/murf/cel2cdr/apps/app_authenticate.c
    team/murf/cel2cdr/apps/app_dial.c
    team/murf/cel2cdr/apps/app_followme.c
    team/murf/cel2cdr/apps/app_forkcdr.c
    team/murf/cel2cdr/apps/app_queue.c
    team/murf/cel2cdr/apps/app_rpt.c
    team/murf/cel2cdr/cel/cel_cel2cdr.c
    team/murf/cel2cdr/channels/chan_agent.c
    team/murf/cel2cdr/channels/chan_local.c
    team/murf/cel2cdr/channels/chan_misdn.c
    team/murf/cel2cdr/include/asterisk/cdr.h
    team/murf/cel2cdr/main/cdr.c
    team/murf/cel2cdr/main/channel.c
    team/murf/cel2cdr/main/features.c
    team/murf/cel2cdr/main/pbx.c
    team/murf/cel2cdr/res/res_agi.c
    team/murf/cel2cdr/res/res_monitor.c

Modified: team/murf/cel2cdr/apps/app_authenticate.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/apps/app_authenticate.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/apps/app_authenticate.c (original)
+++ team/murf/cel2cdr/apps/app_authenticate.c Mon Mar  2 23:07:46 2009
@@ -203,13 +203,13 @@
 						continue;
 					ast_md5_hash(md5passwd, passwd);
 					if (!strcmp(md5passwd, md5secret)) {
-						if (ast_test_flag(&flags,OPT_ACCOUNT))
+						if (!ast_suppress_builtin_cdr && ast_test_flag(&flags,OPT_ACCOUNT))
 							ast_cdr_setaccount(chan, buf);
 						break;
 					}
 				} else {
 					if (!strcmp(passwd, buf)) {
-						if (ast_test_flag(&flags, OPT_ACCOUNT))
+						if (!ast_suppress_builtin_cdr && ast_test_flag(&flags, OPT_ACCOUNT))
 							ast_cdr_setaccount(chan, buf);
 						break;
 					}
@@ -232,7 +232,7 @@
 	}
 
 	if ((retries < 3) && !res) {
-		if (ast_test_flag(&flags,OPT_ACCOUNT) && !ast_test_flag(&flags,OPT_MULTIPLE))
+		if (!ast_suppress_builtin_cdr && ast_test_flag(&flags,OPT_ACCOUNT) && !ast_test_flag(&flags,OPT_MULTIPLE))
 			ast_cdr_setaccount(chan, passwd);
 		if (!(res = ast_streamfile(chan, "auth-thankyou", chan->language)))
 			res = ast_waitstream(chan, "");

Modified: team/murf/cel2cdr/apps/app_dial.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/apps/app_dial.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/apps/app_dial.c (original)
+++ team/murf/cel2cdr/apps/app_dial.c Mon Mar  2 23:07:46 2009
@@ -597,7 +597,7 @@
 static void handle_cause(int cause, struct cause_args *num)
 {
 	struct ast_cdr *cdr = num->chan->cdr;
-
+	/* if !ast_suppress_builtin_cdr, then cdr will be null */
 	switch(cause) {
 	case AST_CAUSE_BUSY:
 		if (cdr)
@@ -900,7 +900,7 @@
 					if (!peer) {
 						ast_verb(3, "%s answered %s\n", c->name, in->name);
 						peer = c;
-						if (peer->cdr) {
+						if (!ast_suppress_builtin_cdr && peer->cdr) {
 							peer->cdr->answer = ast_tvnow();
 							peer->cdr->disposition = AST_CDR_ANSWERED;
 						}
@@ -1024,7 +1024,9 @@
 				/* Got hung up */
 				*to = -1;
 				strcpy(pa->status, "CANCEL");
-				ast_cdr_noanswer(in->cdr);
+				if (in->cdr) {
+					ast_cdr_noanswer(in->cdr);
+				}
 				if (f) {
 					if (f->data.uint32) {
 						in->hangupcause = f->data.uint32;
@@ -1043,7 +1045,9 @@
 					if (onedigit_goto(in, context, (char) f->subclass, 1)) {
 						ast_verb(3, "User hit %c to disconnect call.\n", f->subclass);
 						*to = 0;
-						ast_cdr_noanswer(in->cdr);
+						if (in->cdr) {
+							ast_cdr_noanswer(in->cdr);
+						}
 						*result = f->subclass;
 						strcpy(pa->status, "CANCEL");
 						ast_frfree(f);
@@ -1058,7 +1062,9 @@
 					ast_verb(3, "User hit %c to disconnect call.\n", f->subclass);
 					*to = 0;
 					strcpy(pa->status, "CANCEL");
-					ast_cdr_noanswer(in->cdr);
+					if (in->cdr) {
+						ast_cdr_noanswer(in->cdr);
+					}
 					ast_frfree(f);
 					return NULL;
 				}
@@ -1085,8 +1091,9 @@
 		}
 		if (!*to)
 			ast_verb(3, "Nobody picked up in %d ms\n", orig);
-		if (!*to || ast_check_hangup(in))
+		if (!ast_suppress_builtin_cdr && (!*to || ast_check_hangup(in))) {
 			ast_cdr_noanswer(in->cdr);
+		}
 	}
 
 #ifdef HAVE_EPOLL
@@ -1581,7 +1588,7 @@
 			goto done;
 	}
 
-	if (ast_test_flag64(&opts, OPT_RESETCDR) && chan->cdr)
+	if (!ast_suppress_builtin_cdr && ast_test_flag64(&opts, OPT_RESETCDR) && chan->cdr)
 		ast_cdr_reset(chan->cdr, NULL);
 	if (ast_test_flag64(&opts, OPT_PRIVACY) && ast_strlen_zero(opt_args[OPT_ARG_PRIVACY]))
 		opt_args[OPT_ARG_PRIVACY] = ast_strdupa(chan->exten);
@@ -1769,7 +1776,7 @@
 		res = ast_call(tc, numsubst, 0); /* Place the call, but don't wait on the answer */
 
 		/* Save the info in cdr's that we called them */
-		if (chan->cdr)
+		if (!ast_suppress_builtin_cdr && chan->cdr)
 			ast_cdr_setdestchan(chan->cdr, tc->name);
 
 		/* check the results of ast_call */
@@ -1877,7 +1884,7 @@
 		hanguptree(outgoing, peer, 1);
 		outgoing = NULL;
 		/* If appropriate, log that we have a destination channel */
-		if (chan->cdr)
+		if (!ast_suppress_builtin_cdr && chan->cdr)
 			ast_cdr_setdestchan(chan->cdr, peer->name);
 		if (peer->name)
 			pbx_builtin_setvar_helper(chan, "DIALEDPEERNAME", peer->name);

Modified: team/murf/cel2cdr/apps/app_followme.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/apps/app_followme.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/apps/app_followme.c (original)
+++ team/murf/cel2cdr/apps/app_followme.c Mon Mar  2 23:07:46 2009
@@ -471,12 +471,12 @@
 
 	if (tmpuser && tmpuser->ochan && tmpuser->state >= 0) {
 		outbound = tmpuser->ochan;
-		if (!outbound->cdr) {
+		if (!ast_suppress_builtin_cdr && !outbound->cdr) {
 			outbound->cdr = ast_cdr_alloc();
 			if (outbound->cdr)
 				ast_cdr_init(outbound->cdr, outbound);
 		}
-		if (outbound->cdr) {
+		if (!ast_suppress_builtin_cdr && outbound->cdr) {
 			char tmp[256];
 
 			snprintf(tmp, sizeof(tmp), "%s/%s", "Local", tmpuser->dialarg);
@@ -487,8 +487,9 @@
 			/* If the cause wasn't handled properly */
 			if (ast_cdr_disposition(outbound->cdr, outbound->hangupcause))
 				ast_cdr_failed(outbound->cdr);
-		} else
+		} else if (!ast_suppress_builtin_cdr) {
 			ast_log(LOG_WARNING, "Unable to create Call Detail Record\n");
+		}
 		ast_hangup(tmpuser->ochan);
 	}
 
@@ -657,6 +658,14 @@
 					case AST_CONTROL_ANSWER:
 						ast_verb(3, "%s answered %s\n", winner->name, caller->name);
 						/* If call has been answered, then the eventual hangup is likely to be normal hangup */ 
+						
+						{
+							char buf3[25];
+							time_t now;
+							time(&now);
+							snprintf(buf3, sizeof(buf3), "%ld", now);
+							pbx_builtin_setvar_helper(caller, "ANSWER", buf);
+						}
 						winner->hangupcause = AST_CAUSE_NORMAL_CLEARING;
 						caller->hangupcause = AST_CAUSE_NORMAL_CLEARING;
 						ast_verb(3, "Starting playback of %s\n", callfromname);
@@ -804,6 +813,13 @@
 	AST_LIST_TRAVERSE(&tpargs->cnumbers, nm, entry)
 		if (nm->order == idx)
 			break;
+	{
+		char buf3[25];
+		time_t now;
+		time(&now);
+		snprintf(buf3, sizeof(buf3), "%ld", now);
+		pbx_builtin_setvar_helper(caller, "START", buf);
+	}
 
 	while (nm) {
 
@@ -844,9 +860,9 @@
 				} else {
 					ast_verb(3, "couldn't reach at this number.\n"); 
 					if (outbound) {
-						if (!outbound->cdr) 
+						if (!ast_suppress_builtin_cdr && !outbound->cdr) 
 							outbound->cdr = ast_cdr_alloc();
-						if (outbound->cdr) {
+						if (!ast_suppress_builtin_cdr && outbound->cdr) {
 							char tmp[256];
 
 							ast_cdr_init(outbound->cdr, outbound);
@@ -858,7 +874,7 @@
 							/* If the cause wasn't handled properly */
 							if (ast_cdr_disposition(outbound->cdr,outbound->hangupcause))
 								ast_cdr_failed(outbound->cdr);
-						} else {
+						} else if (!ast_suppress_builtin_cdr) {
 							ast_log(LOG_ERROR, "Unable to create Call Detail Record\n");
 							ast_hangup(outbound);
 							outbound = NULL;
@@ -973,19 +989,24 @@
 static void end_bridge_callback(void *data)
 {
 	char buf[80];
+	char *str;
 	time_t end;
 	struct ast_channel *chan = data;
 
 	time(&end);
 
 	ast_channel_lock(chan);
-	if (chan->cdr->answer.tv_sec) {
-		snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->answer.tv_sec);
+	str = pbx_builtin_getvar_helper(chan,"ANSWER");
+	if (str) {
+		time_t ans = atoi(str);
+		snprintf(buf, sizeof(buf), "%ld", end - ans);
 		pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
 	}
 
-	if (chan->cdr->start.tv_sec) {
-		snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->start.tv_sec);
+	str = pbx_builtin_getvar_helper(chan,"START");
+	if (str) {
+		time_t start = atoi(str);
+		snprintf(buf, sizeof(buf), "%ld", end - start);
 		pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
 	}
 	ast_channel_unlock(chan);

Modified: team/murf/cel2cdr/apps/app_forkcdr.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/apps/app_forkcdr.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/apps/app_forkcdr.c (original)
+++ team/murf/cel2cdr/apps/app_forkcdr.c Mon Mar  2 23:07:46 2009
@@ -254,7 +254,9 @@
 		ast_set2_flag(chan->cdr, keepvars, AST_CDR_FLAG_KEEP_VARS);
 	}
 	
-	ast_cdr_fork(chan, flags, opts[OPT_ARG_VARSET]);
+	if (!ast_suppress_builtin_cdr) {
+		ast_cdr_fork(chan, flags, opts[OPT_ARG_VARSET]);
+	}
 
 	return res;
 }

Modified: team/murf/cel2cdr/apps/app_queue.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/apps/app_queue.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/apps/app_queue.c (original)
+++ team/murf/cel2cdr/apps/app_queue.c Mon Mar  2 23:07:46 2009
@@ -2375,7 +2375,7 @@
 		(!tmp->lastqueue && qe->parent->wrapuptime && (time(NULL) - tmp->lastcall < qe->parent->wrapuptime))) {
 		ast_debug(1, "Wrapuptime not yet expired on queue %s for %s\n", 
 				(tmp->lastqueue ? tmp->lastqueue->name : qe->parent->name), tmp->interface);
-		if (qe->chan->cdr)
+		if (!ast_suppress_builtin_cdr && qe->chan->cdr)
 			ast_cdr_busy(qe->chan->cdr);
 		tmp->stillgoing = 0;
 		(*busies)++;
@@ -2384,7 +2384,7 @@
 
 	if (!qe->parent->ringinuse && (tmp->member->status != AST_DEVICE_NOT_INUSE) && (tmp->member->status != AST_DEVICE_UNKNOWN)) {
 		ast_debug(1, "%s in use, can't receive call\n", tmp->interface);
-		if (qe->chan->cdr)
+		if (!ast_suppress_builtin_cdr && qe->chan->cdr)
 			ast_cdr_busy(qe->chan->cdr);
 		tmp->stillgoing = 0;
 		return 0;
@@ -2392,14 +2392,14 @@
 
 	if (tmp->member->paused) {
 		ast_debug(1, "%s paused, can't receive call\n", tmp->interface);
-		if (qe->chan->cdr)
+		if (!ast_suppress_builtin_cdr && qe->chan->cdr)
 			ast_cdr_busy(qe->chan->cdr);
 		tmp->stillgoing = 0;
 		return 0;
 	}
 	if (use_weight && compare_weight(qe->parent,tmp->member)) {
 		ast_debug(1, "Priority queue delaying call to %s:%s\n", qe->parent->name, tmp->interface);
-		if (qe->chan->cdr)
+		if (!ast_suppress_builtin_cdr && qe->chan->cdr)
 			ast_cdr_busy(qe->chan->cdr);
 		tmp->stillgoing = 0;
 		(*busies)++;
@@ -2415,7 +2415,7 @@
 	/* Request the peer */
 	tmp->chan = ast_request(tech, qe->chan->nativeformats, location, &status);
 	if (!tmp->chan) {			/* If we can't, just go on to the next call */
-		if (qe->chan->cdr)
+		if (!ast_suppress_builtin_cdr && qe->chan->cdr)
 			ast_cdr_busy(qe->chan->cdr);
 		tmp->stillgoing = 0;	
 
@@ -2877,7 +2877,7 @@
 							break;
 						case AST_CONTROL_BUSY:
 							ast_verb(3, "%s is busy\n", o->chan->name);
-							if (in->cdr)
+							if (!ast_suppress_builtin_cdr && in->cdr)
 								ast_cdr_busy(in->cdr);
 							do_hang(o);
 							endtime = (long) time(NULL);
@@ -2892,7 +2892,7 @@
 							break;
 						case AST_CONTROL_CONGESTION:
 							ast_verb(3, "%s is circuit-busy\n", o->chan->name);
-							if (in->cdr)
+							if (!ast_suppress_builtin_cdr && in->cdr)
 								ast_cdr_busy(in->cdr);
 							endtime = (long) time(NULL);
 							endtime -= starttime;
@@ -3846,7 +3846,7 @@
 		else
 			ast_moh_stop(qe->chan);
 		/* If appropriate, log that we have a destination channel */
-		if (qe->chan->cdr)
+		if (!ast_suppress_builtin_cdr && qe->chan->cdr)
 			ast_cdr_setdestchan(qe->chan->cdr, peer->name);
 		/* Make sure channels are compatible */
 		res = ast_channel_make_compatible(qe->chan, peer);
@@ -3906,8 +3906,8 @@
 				ast_channel_unlock(qe->chan);
 				if (monitorfilename)
 					ast_monitor_start(which, qe->parent->monfmt, monitorfilename, 1, X_REC_IN | X_REC_OUT);
-				else if (qe->chan->cdr)
-					ast_monitor_start(which, qe->parent->monfmt, qe->chan->cdr->uniqueid, 1, X_REC_IN | X_REC_OUT);
+				else if (qe->chan->uniqueid)
+					ast_monitor_start(which, qe->parent->monfmt, qe->chan->uniqueid, 1, X_REC_IN | X_REC_OUT);
 				else {
 					/* Last ditch effort -- no CDR, make up something */
 					snprintf(tmpid, sizeof(tmpid), "chan-%lx", ast_random());
@@ -3922,8 +3922,8 @@
 				if (mixmonapp) {
 					ast_debug(1, "Starting MixMonitor as requested.\n");
 					if (!monitorfilename) {
-						if (qe->chan->cdr)
-							ast_copy_string(tmpid, qe->chan->cdr->uniqueid, sizeof(tmpid));
+						if (qe->chan->uniqueid)
+							ast_copy_string(tmpid, qe->chan->uniqueid, sizeof(tmpid));
 						else
 							snprintf(tmpid, sizeof(tmpid), "chan-%lx", ast_random());
 					} else {
@@ -3992,10 +3992,10 @@
 					
 					ast_debug(1, "Arguments being passed to MixMonitor: %s\n", mixmonargs);
 					/* We purposely lock the CDR so that pbx_exec does not update the application data */
-					if (qe->chan->cdr)
+					if (!ast_suppress_builtin_cdr && qe->chan->cdr)
 						ast_set_flag(qe->chan->cdr, AST_CDR_FLAG_LOCKED);
 					ret = pbx_exec(qe->chan, mixmonapp, mixmonargs);
-					if (qe->chan->cdr)
+					if (!ast_suppress_builtin_cdr && qe->chan->cdr)
 						ast_clear_flag(qe->chan->cdr, AST_CDR_FLAG_LOCKED);
 
 				} else {
@@ -4123,7 +4123,7 @@
 		qe->handled++;
 		ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "CONNECT", "%ld|%s|%ld", (long) time(NULL) - qe->start, peer->uniqueid,
 													(long)(orig - to > 0 ? (orig - to) / 1000 : 0));
-		if (update_cdr && qe->chan->cdr) 
+		if (!ast_suppress_builtin_cdr && update_cdr && qe->chan->cdr) 
 			ast_copy_string(qe->chan->cdr->dstchannel, member->membername, sizeof(qe->chan->cdr->dstchannel));
 		if (qe->parent->eventwhencalled)
 			manager_event(EVENT_FLAG_AGENT, "AgentConnect",

Modified: team/murf/cel2cdr/apps/app_rpt.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/apps/app_rpt.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/apps/app_rpt.c (original)
+++ team/murf/cel2cdr/apps/app_rpt.c Mon Mar  2 23:07:46 2009
@@ -5473,7 +5473,7 @@
 	ast_copy_string(mychannel->exten, myrpt->exten, sizeof(mychannel->exten) - 1);
 	ast_copy_string(mychannel->context, myrpt->patchcontext, sizeof(mychannel->context) - 1);
 	
-	if (myrpt->p.acctcode)
+	if (!ast_suppress_builtin_cdr && myrpt->p.acctcode)
 		ast_cdr_setaccount(mychannel,myrpt->p.acctcode);
 	mychannel->priority = 1;
 	ast_channel_undefer_dtmf(mychannel);

Modified: team/murf/cel2cdr/cel/cel_cel2cdr.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/cel/cel_cel2cdr.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/cel/cel_cel2cdr.c (original)
+++ team/murf/cel2cdr/cel/cel_cel2cdr.c Mon Mar  2 23:07:46 2009
@@ -115,6 +115,11 @@
 {
 	/* read the config file, set all the control variables. */
 
+	/* if this loads successfully, then set this var to suppress all the 
+	   builtin CDR stuff */
+
+	ast_suppress_builtin_cdr = 1;
+
 	/* set up the master table */
 	if (cel2cdr_enabled) {
 		if (!master_table) {
@@ -140,8 +145,7 @@
 static int mod_reload_func(void)
 {
 	mod_unload_func();
-	mod_load_func();
-	return AST_MODULE_LOAD_SUCCESS;
+	return mod_load_func();
 }
 
 

Modified: team/murf/cel2cdr/channels/chan_agent.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/channels/chan_agent.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/channels/chan_agent.c (original)
+++ team/murf/cel2cdr/channels/chan_agent.c Mon Mar  2 23:07:46 2009
@@ -501,9 +501,11 @@
 #if 0
 		ast_verbose("name is %s, link is %s\n",tmp, tmp2);
 #endif
-		if (!ast->cdr)
-			ast->cdr = ast_cdr_alloc();
-		ast_cdr_setuserfield(ast, tmp2);
+		if (!ast_suppress_builtin_cdr) {
+			if (!ast->cdr)
+				ast->cdr = ast_cdr_alloc();
+			ast_cdr_setuserfield(ast, tmp2);
+		}
 		res = 0;
 	} else
 		ast_log(LOG_ERROR, "Recording already started on that call.\n");
@@ -2299,7 +2301,9 @@
 			AST_LIST_LOCK(&agents);
 			AST_LIST_TRAVERSE(&agents, p, list) {
 				if (!strcasecmp(p->agent, tmp)) {
-					if (changeoutgoing) snprintf(chan->cdr->channel, sizeof(chan->cdr->channel), "Agent/%s", p->agent);
+					if (!ast_suppress_builtin_cdr && chan->cdr) {
+						if (changeoutgoing) snprintf(chan->cdr->channel, sizeof(chan->cdr->channel), "Agent/%s", p->agent);
+					}
 					__agent_start_monitoring(chan, p, 1);
 					break;
 				}

Modified: team/murf/cel2cdr/channels/chan_local.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/channels/chan_local.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/channels/chan_local.c (original)
+++ team/murf/cel2cdr/channels/chan_local.c Mon Mar  2 23:07:46 2009
@@ -524,7 +524,10 @@
 	ast_string_field_set(p->chan, language, p->owner->language);
 	ast_string_field_set(p->chan, accountcode, p->owner->accountcode);
 	ast_string_field_set(p->chan, musicclass, p->owner->musicclass);
-	ast_cdr_update(p->chan);
+	if (!ast_suppress_builtin_cdr) {
+		ast_cdr_update(p->chan);
+	}
+	
 	p->chan->cdrflags = p->owner->cdrflags;
 
 	if (!ast_exists_extension(NULL, p->chan->context, p->chan->exten, 1, p->owner->cid.cid_num)) {

Modified: team/murf/cel2cdr/channels/chan_misdn.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/channels/chan_misdn.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/channels/chan_misdn.c (original)
+++ team/murf/cel2cdr/channels/chan_misdn.c Mon Mar  2 23:07:46 2009
@@ -4485,7 +4485,9 @@
 				if (digits) {
 					strncat(bc->dad, bc->info_dad, sizeof(bc->dad) - strlen(bc->dad) - 1);
 					ast_copy_string(ch->ast->exten, bc->dad, sizeof(ch->ast->exten));
-					ast_cdr_update(ch->ast);
+					if (!ast_suppress_builtin_cdr) {
+						ast_cdr_update(ch->ast);
+					}
 				}
 				
 				ast_queue_frame(ch->ast, &fr);

Modified: team/murf/cel2cdr/include/asterisk/cdr.h
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/include/asterisk/cdr.h?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/include/asterisk/cdr.h (original)
+++ team/murf/cel2cdr/include/asterisk/cdr.h Mon Mar  2 23:07:46 2009
@@ -351,6 +351,8 @@
 
 extern char ast_default_accountcode[AST_MAX_ACCOUNT_CODE];
 
+extern int ast_suppress_builtin_cdr;
+
 struct ast_cdr *ast_cdr_append(struct ast_cdr *cdr, struct ast_cdr *newcdr);
 
 /*! \brief Reload the configuration file cdr.conf and start/stop CDR scheduling thread */

Modified: team/murf/cel2cdr/main/cdr.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/main/cdr.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/main/cdr.c (original)
+++ team/murf/cel2cdr/main/cdr.c Mon Mar  2 23:07:46 2009
@@ -1402,6 +1402,8 @@
 	if (config) {
 		if ((enabled_value = ast_variable_retrieve(config, "general", "enable"))) {
 			enabled = ast_true(enabled_value);
+			if (!enabled)
+				ast_suppress_builtin_cdr = 1; /* why fool around? */
 		}
 		if ((unanswered_value = ast_variable_retrieve(config, "general", "unanswered"))) {
 			unanswered = ast_true(unanswered_value);

Modified: team/murf/cel2cdr/main/channel.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/main/channel.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/main/channel.c (original)
+++ team/murf/cel2cdr/main/channel.c Mon Mar  2 23:07:46 2009
@@ -905,10 +905,12 @@
 		strcpy(tmp->exten, "s");
 
 	tmp->priority = 1;
-		
-	tmp->cdr = ast_cdr_alloc();
-	ast_cdr_init(tmp->cdr, tmp);
-	ast_cdr_start(tmp->cdr);
+	
+	if (!ast_suppress_builtin_cdr) {
+		tmp->cdr = ast_cdr_alloc();
+		ast_cdr_init(tmp->cdr, tmp);
+		ast_cdr_start(tmp->cdr);
+	}
 	
 	headp = &tmp->varshead;
 	AST_LIST_HEAD_INIT_NOLOCK(headp);
@@ -1729,7 +1731,7 @@
 			res = chan->tech->answer(chan);
 		}
 		ast_setstate(chan, AST_STATE_UP);
-		if (cdr_answer) {
+		if (!ast_suppress_builtin_cdr && cdr_answer) {
 			ast_cdr_answer(chan->cdr);
 		}
 		ast_channel_unlock(chan);
@@ -1770,7 +1772,7 @@
 		/* Calling ast_cdr_answer when it it has previously been called
 		 * is essentially a no-op, so it is safe.
 		 */
-		if (cdr_answer) {
+		if (!ast_suppress_builtin_cdr && cdr_answer) {
 			ast_cdr_answer(chan->cdr);
 		}
 		break;
@@ -3474,7 +3476,7 @@
 			ast_channel_inherit_variables(oh->parent_channel, chan);
 			ast_channel_datastore_inherit(oh->parent_channel, chan);
 		}
-		if (oh->account)
+		if (!ast_suppress_builtin_cdr && oh->account)
 			ast_cdr_setaccount(chan, oh->account);	
 	}
 	ast_set_callerid(chan, cid_num, cid_name, cid_num);
@@ -3543,7 +3545,7 @@
 	if (res <= 0) {
 		if ( AST_CONTROL_RINGING == last_subclass ) 
 			chan->hangupcause = AST_CAUSE_NO_ANSWER;
-		if (!chan->cdr && (chan->cdr = ast_cdr_alloc()))
+		if (!ast_suppress_builtin_cdr && !chan->cdr && (chan->cdr = ast_cdr_alloc()))
 			ast_cdr_init(chan->cdr, chan);
 		if (chan->cdr) {
 			char tmp[256];
@@ -4014,9 +4016,11 @@
 	clonechan->tech = t;
 
 	/* Swap the cdrs */
-	cdr = original->cdr;
-	original->cdr = clonechan->cdr;
-	clonechan->cdr = cdr;
+	if (!ast_suppress_builtin_cdr) {
+		cdr = original->cdr;
+		original->cdr = clonechan->cdr;
+		clonechan->cdr = cdr;
+	}
 
 	t_pvt = original->tech_pvt;
 	original->tech_pvt = clonechan->tech_pvt;

Modified: team/murf/cel2cdr/main/features.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/main/features.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/main/features.c (original)
+++ team/murf/cel2cdr/main/features.c Mon Mar  2 23:07:46 2009
@@ -1294,7 +1294,7 @@
 		pbx_builtin_setvar_helper(transferer, "BLINDTRANSFER", transferee->name);
 		pbx_builtin_setvar_helper(transferee, "BLINDTRANSFER", transferer->name);
 		res=finishup(transferee);
-		if (!transferer->cdr) { /* this code should never get called (in a perfect world) */
+		if (!ast_suppress_builtin_cdr && !transferer->cdr) { /* this code should never get called (in a perfect world) */
 			transferer->cdr=ast_cdr_alloc();
 			if (transferer->cdr) {
 				ast_cdr_init(transferer->cdr, transferer); /* initilize our channel's cdr */
@@ -2294,7 +2294,7 @@
 static struct ast_cdr *pick_unlocked_cdr(struct ast_cdr *cdr)
 {
 	struct ast_cdr *cdr_orig = cdr;
-	while (cdr) {
+	while (!ast_suppress_builtin_cdr && cdr) {
 		if (!ast_test_flag(cdr,AST_CDR_FLAG_LOCKED))
 			return cdr;
 		cdr = cdr->next;
@@ -2474,7 +2474,7 @@
 	ast_copy_string(orig_peername,peer->name,sizeof(orig_peername));
 	orig_peer_cdr = peer_cdr;
 	
-	if (!chan_cdr || (chan_cdr && !ast_test_flag(chan_cdr, AST_CDR_FLAG_POST_DISABLED))) {
+	if (!ast_suppress_builtin_cdr && (!chan_cdr || (chan_cdr && !ast_test_flag(chan_cdr, AST_CDR_FLAG_POST_DISABLED)))) {
 		
 		if (chan_cdr) {
 			ast_set_flag(chan_cdr, AST_CDR_FLAG_MAIN);
@@ -2705,7 +2705,7 @@
 	}
    before_you_go:
 
-	if (ast_test_flag(chan,AST_FLAG_BRIDGE_HANGUP_DONT)) {
+	if (!ast_suppress_builtin_cdr && ast_test_flag(chan,AST_FLAG_BRIDGE_HANGUP_DONT)) {
 		ast_clear_flag(chan,AST_FLAG_BRIDGE_HANGUP_DONT); /* its job is done */
 		if (bridge_cdr) {
 			ast_cdr_discard(bridge_cdr);
@@ -2714,7 +2714,7 @@
 		return res; /* if we shouldn't do the h-exten, we shouldn't do the bridge cdr, either! */
 	}
 
-	if (config->end_bridge_callback) {
+	if (!ast_suppress_builtin_cdr && config->end_bridge_callback) {
 		config->end_bridge_callback(config->end_bridge_callback_data);
 	}
 
@@ -2722,7 +2722,7 @@
 	 * if it were, then chan belongs to a different thread now, and might have been hung up long
      * ago.
 	 */
-	if (!ast_test_flag(&(config->features_caller),AST_FEATURE_NO_H_EXTEN) &&
+	if (!ast_suppress_builtin_cdr && !ast_test_flag(&(config->features_caller),AST_FEATURE_NO_H_EXTEN) &&
 		ast_exists_extension(chan, chan->context, "h", 1, chan->cid.cid_num)) {
 		struct ast_cdr *swapper = NULL;
 		char savelastapp[AST_MAX_EXTENSION];
@@ -2777,7 +2777,7 @@
 	
 	/* obey the NoCDR() wishes. -- move the DISABLED flag to the bridge CDR if it was set on the channel during the bridge... */
 	new_chan_cdr = pick_unlocked_cdr(chan->cdr); /* the proper chan cdr, if there are forked cdrs */
-	if (bridge_cdr && new_chan_cdr && ast_test_flag(new_chan_cdr, AST_CDR_FLAG_POST_DISABLED))
+	if (!ast_suppress_builtin_cdr && bridge_cdr && new_chan_cdr && ast_test_flag(new_chan_cdr, AST_CDR_FLAG_POST_DISABLED))
 		ast_set_flag(bridge_cdr, AST_CDR_FLAG_POST_DISABLED);
 
 	/* we can post the bridge CDR at this point */
@@ -2836,7 +2836,7 @@
  		}
 	}
 	
-	{
+	if(!ast_suppress_builtin_cdr) {
 		struct ast_channel *chan_ptr = NULL;
 		new_peer_cdr = pick_unlocked_cdr(peer->cdr); /* the proper chan cdr, if there are forked cdrs */
 		if (new_chan_cdr && ast_test_flag(new_chan_cdr, AST_CDR_FLAG_POST_DISABLED) && new_peer_cdr && !ast_test_flag(new_peer_cdr, AST_CDR_FLAG_POST_DISABLED))
@@ -3357,7 +3357,9 @@
 		ast_verb(3, "Channel %s connected to parked call %d\n", chan->name, park);
 
 		pbx_builtin_setvar_helper(chan, "PARKEDCHANNEL", peer->name);
-		ast_cdr_setdestchan(chan->cdr, peer->name);
+		if (!ast_suppress_builtin_cdr) {
+			ast_cdr_setdestchan(chan->cdr, peer->name);
+		}
 		memset(&config, 0, sizeof(struct ast_bridge_config));
 
 		/* Get datastore for peer and apply it's features to the callee side of the bridge config */
@@ -3399,8 +3401,9 @@
 		res = ast_bridge_call(chan, peer, &config);
 
 		pbx_builtin_setvar_helper(chan, "PARKEDCHANNEL", peer->name);
-		ast_cdr_setdestchan(chan->cdr, peer->name);
-
+		if (!ast_suppress_builtin_cdr) {
+			ast_cdr_setdestchan(chan->cdr, peer->name);
+		}
 		/* Simulate the PBX hanging up */
 		ast_hangup(peer);
 		return res;

Modified: team/murf/cel2cdr/main/pbx.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/main/pbx.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/main/pbx.c (original)
+++ team/murf/cel2cdr/main/pbx.c Mon Mar  2 23:07:46 2009
@@ -7920,7 +7920,7 @@
 		}
 
 		if (res < 0) { /* the call failed for some reason */
-			if (*reason == 0) { /* if the call failed (not busy or no answer)
+			if (!ast_suppress_builtin_cdr && *reason == 0) { /* if the call failed (not busy or no answer)
 				            * update the cdr with the failed message */
 				cdr_res = ast_pbx_outgoing_cdr_failed();
 				if (cdr_res != 0) {
@@ -7941,7 +7941,7 @@
 					ast_set_variables(chan, vars);
 					snprintf(failed_reason, sizeof(failed_reason), "%d", *reason);
 					pbx_builtin_setvar_helper(chan, "REASON", failed_reason);
-					if (account)
+					if (!ast_suppress_builtin_cdr && account)
 						ast_cdr_setaccount(chan, account);
 					if (ast_pbx_run(chan)) {
 						ast_log(LOG_ERROR, "Unable to run PBX on %s\n", chan->name);
@@ -7972,7 +7972,7 @@
 		set_ext_pri(as->chan,  exten, priority);
 		as->timeout = timeout;
 		ast_set_variables(chan, vars);
-		if (account)
+		if (!ast_suppress_builtin_cdr && account)
 			ast_cdr_setaccount(chan, account);
 		if (ast_pthread_create_detached(&as->p, NULL, async_wait, as)) {
 			ast_log(LOG_WARNING, "Failed to start async wait\n");
@@ -8036,7 +8036,7 @@
 		chan = __ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name, &oh);
 		if (chan) {
 			ast_set_variables(chan, vars);
-			if (account)
+			if (!ast_suppress_builtin_cdr && account)
 				ast_cdr_setaccount(chan, account);
 			if (chan->_state == AST_STATE_UP) {
 				res = 0;
@@ -8082,7 +8082,7 @@
 		}
 
 		if (res < 0) { /* the call failed for some reason */
-			if (*reason == 0) { /* if the call failed (not busy or no answer)
+			if (!ast_suppress_builtin_cdr && *reason == 0) { /* if the call failed (not busy or no answer)
 				            * update the cdr with the failed message */
 				cdr_res = ast_pbx_outgoing_cdr_failed();
 				if (cdr_res != 0) {
@@ -8110,7 +8110,7 @@
 			ast_copy_string(as->appdata,  appdata, sizeof(as->appdata));
 		as->timeout = timeout;
 		ast_set_variables(chan, vars);
-		if (account)
+		if (!ast_suppress_builtin_cdr && account)
 			ast_cdr_setaccount(chan, account);
 		/* Start a new thread, and get something handling this channel. */
 		if (locked_channel)
@@ -8482,8 +8482,9 @@
 		args = ast_strdupa(data);
 		ast_app_parse_options(resetcdr_opts, &flags, NULL, args);
 	}
-
-	ast_cdr_reset(chan->cdr, &flags);
+	if (!ast_suppress_builtin_cdr) {
+		ast_cdr_reset(chan->cdr, &flags);
+	}
 
 	return 0;
 }
@@ -8494,7 +8495,9 @@
 static int pbx_builtin_setamaflags(struct ast_channel *chan, void *data)
 {
 	/* Copy the AMA Flags as specified */
-	ast_cdr_setamaflags(chan, data ? data : "");
+	if (!ast_suppress_builtin_cdr) {
+		ast_cdr_setamaflags(chan, data ? data : "");
+	}
 	return 0;
 }
 

Modified: team/murf/cel2cdr/res/res_agi.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/res/res_agi.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/res/res_agi.c (original)
+++ team/murf/cel2cdr/res/res_agi.c Mon Mar  2 23:07:46 2009
@@ -2756,7 +2756,7 @@
 			ast_module_ref(c->mod);
 		/* If the AGI command being executed is an actual application (using agi exec)
 		the app field will be updated in pbx_exec via handle_exec */
-		if (chan->cdr && !ast_check_hangup(chan) && strcasecmp(argv[0], "EXEC"))
+		if (!ast_suppress_builtin_cdr && chan->cdr && !ast_check_hangup(chan) && strcasecmp(argv[0], "EXEC"))
 			ast_cdr_setapp(chan->cdr, "AGI", buf);
 
 		res = c->handler(chan, agi, argc, argv);

Modified: team/murf/cel2cdr/res/res_monitor.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/cel2cdr/res/res_monitor.c?view=diff&rev=179603&r1=179602&r2=179603
==============================================================================
--- team/murf/cel2cdr/res/res_monitor.c (original)
+++ team/murf/cel2cdr/res/res_monitor.c Mon Mar  2 23:07:46 2009
@@ -500,7 +500,7 @@
 		urlprefix = arg;
 	}
 
-	if (urlprefix) {
+	if (!ast_suppress_builtin_cdr && urlprefix) {
 		snprintf(tmp, sizeof(tmp), "%s/%s.%s", urlprefix, args.fname_base,
 			((strcmp(args.format, "gsm")) ? "wav" : "gsm"));
 		if (!chan->cdr && !(chan->cdr = ast_cdr_alloc()))




More information about the svn-commits mailing list