[Freeswitch-svn] [commit] r4415 - freeswitch/trunk/src/mod/event_handlers/mod_cdr

Freeswitch SVN mishehu at freeswitch.org
Wed Feb 28 17:28:03 EST 2007


Author: mishehu
Date: Wed Feb 28 17:28:03 2007
New Revision: 4415

Added:
   freeswitch/trunk/src/mod/event_handlers/mod_cdr/mod_cdr.conf.xml
Modified:
   freeswitch/trunk/src/mod/event_handlers/mod_cdr/basecdr.cpp

Log:
Minor changes for MikeJ's switch_strlen_zero() and a minor refactor of BaseCDR::BaseCDR(switch_mod_cdr_newchannel_t*).  Added a sample config file, perhaps somebody can edit the makefile to copy this into the configuration when this module is enabled for build.

Modified: freeswitch/trunk/src/mod/event_handlers/mod_cdr/basecdr.cpp
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_cdr/basecdr.cpp	(original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_cdr/basecdr.cpp	Wed Feb 28 17:28:03 2007
@@ -89,76 +89,71 @@
 			calltransferdate = newchannel->callerprofile->times->transferred;
 			callenddate = newchannel->callerprofile->times->hungup;
 
-			if(newchannel->callerprofile->caller_id_name != 0)
-			{
+			if(!switch_strlen_zero(newchannel->callerprofile->caller_id_name))
 				strncpy(clid,newchannel->callerprofile->caller_id_name,strlen(newchannel->callerprofile->caller_id_name));
-				strncat(clid," <",2);
-				if(newchannel->callerprofile->caller_id_number != 0 )
-					strncat(clid,newchannel->callerprofile->caller_id_number,strlen(clid)+strlen(newchannel->callerprofile->caller_id_number));
-				strncat(clid,">",1);
-			}
 			
 			// Get the ANI information if it's set
-			if(newchannel->callerprofile->ani != 0)
+			if(!switch_strlen_zero(newchannel->callerprofile->ani))
 				strncpy(ani,newchannel->callerprofile->ani,strlen(newchannel->callerprofile->ani));
-			if(newchannel->callerprofile->aniii != 0)
+			if(!switch_strlen_zero(newchannel->callerprofile->aniii))
 				strncpy(aniii,newchannel->callerprofile->aniii,strlen(newchannel->callerprofile->aniii));
 		
-			if(newchannel->callerprofile->dialplan != 0)
+			if(!switch_strlen_zero(newchannel->callerprofile->dialplan))
 				strncpy(dialplan,newchannel->callerprofile->dialplan,strlen(newchannel->callerprofile->dialplan));
 		
-			if(newchannel->callerprofile->network_addr != 0)
+			if(!switch_strlen_zero(newchannel->callerprofile->network_addr))
 				strncpy(network_addr,newchannel->callerprofile->network_addr,strlen(newchannel->callerprofile->network_addr));
-		}
-		
-		//switch_caller_profile_t *originateprofile = switch_channel_get_originator_caller_profile(newchannel->channel->callerprofile);
 		
-		// Were we the receiver of the call?
-		if(newchannel->callerprofile->originator_caller_profile)
-		{
-			originated = 0;
-			if(newchannel->callerprofile->originator_caller_profile->uuid != 0)
-				strncpy(destuuid,newchannel->callerprofile->originator_caller_profile->uuid,strlen(newchannel->callerprofile->originator_caller_profile->uuid));
-			if(newchannel->callerprofile)
+			// Were we the receiver of the call?
+			if(newchannel->callerprofile->originator_caller_profile)
 			{
-				if(newchannel->callerprofile->destination_number)
+				originated = 0;
+				if(!switch_strlen_zero(newchannel->callerprofile->originator_caller_profile->uuid))
+					strncpy(destuuid,newchannel->callerprofile->originator_caller_profile->uuid,strlen(newchannel->callerprofile->originator_caller_profile->uuid));
+				
+				if(!switch_strlen_zero(newchannel->callerprofile->destination_number))
 					strncpy(src,newchannel->callerprofile->destination_number,strlen(newchannel->callerprofile->destination_number));
-				if(newchannel->callerprofile->caller_id_number != 0)
+				if(!switch_strlen_zero(newchannel->callerprofile->caller_id_number))
 					strncpy(dst,newchannel->callerprofile->caller_id_number,strlen(newchannel->callerprofile->caller_id_number));
 			}
-		}
-		else
-		{
-			//originateprofile = switch_channel_get_originatee_profile(newchannel->channel->callerprofile);
-			// Or were we maybe we were the caller?
-			if(newchannel->callerprofile->originatee_caller_profile)
+			else
 			{
-				if (newchannel->callerprofile) {
-					if(newchannel->callerprofile->caller_id_number != 0)
+				//originateprofile = switch_channel_get_originatee_profile(newchannel->channel->callerprofile);
+				// Or were we maybe we were the caller?
+				if(newchannel->callerprofile->originatee_caller_profile)
+				{
+					if(!switch_strlen_zero(newchannel->callerprofile->caller_id_number))
 						strncpy(src,newchannel->callerprofile->caller_id_number,strlen(newchannel->callerprofile->caller_id_number));
-					if(newchannel->callerprofile->destination_number != 0)
+					if(!switch_strlen_zero(newchannel->callerprofile->destination_number))
 						strncpy(dst,newchannel->callerprofile->destination_number,strlen(newchannel->callerprofile->destination_number));
+					if(!switch_strlen_zero(newchannel->callerprofile->originatee_caller_profile->chan_name))
+						strncpy(dstchannel,newchannel->callerprofile->originatee_caller_profile->chan_name,strlen(newchannel->callerprofile->originatee_caller_profile->chan_name));
 				}
-				if(newchannel->callerprofile->originatee_caller_profile->chan_name != 0)
-					strncpy(dstchannel,newchannel->callerprofile->originatee_caller_profile->chan_name,strlen(newchannel->callerprofile->originatee_caller_profile->chan_name));
 			}
 		}
 		
-		strncpy(myuuid,newchannel->callerprofile->uuid,strlen(newchannel->callerprofile->uuid));
-		strncpy(srcchannel,newchannel->callerprofile->chan_name,strlen(newchannel->callerprofile->chan_name));
+		if(!switch_strlen_zero(newchannel->callerprofile->uuid))
+			strncpy(myuuid,newchannel->callerprofile->uuid,strlen(newchannel->callerprofile->uuid));
+		
+		if(!switch_strlen_zero(newchannel->callerprofile->chan_name))
+			strncpy(srcchannel,newchannel->callerprofile->chan_name,strlen(newchannel->callerprofile->chan_name));
 		
 		if(switch_channel_test_flag(newchannel->channel,CF_ANSWERED))
 		{
 			disposition=1;
-			if(callstartdate)
-				billusec = callenddate - callanswerdate;
-			else
-				billusec = callenddate - calltransferdate;
+			if(callstartdate && callanswerdate)
+			{
+				if(callenddate)
+					billusec = callenddate - callanswerdate;
+				else if(calltransferdate)
+					billusec = calltransferdate - callanswerdate;
+			}
 		}
 		else if(switch_channel_test_flag(newchannel->channel,CF_TRANSFER))
 		{
 			disposition=1;
-			billusec = callenddate - calltransferdate;
+			if(callanswerdate && calltransferdate)
+				billusec = calltransferdate - callanswerdate;
 		}
 		else
 		{
@@ -170,12 +165,12 @@
 		hangupcause = switch_channel_get_cause(newchannel->channel);
 		hangupcause_text = switch_channel_cause2str(hangupcause);
 	
-		if(newchannel->callerextension != 0)
-			if(newchannel->callerextension->last_application != 0)
+		if(newchannel->callerextension)
+			if(!newchannel->callerextension->last_application)
 			{
-				if(newchannel->callerextension->last_application->application_name != 0)
+				if(!switch_strlen_zero(newchannel->callerextension->last_application->application_name))
 					strncpy(lastapp,newchannel->callerextension->last_application->application_name,strlen(newchannel->callerextension->last_application->application_name));
-				if(newchannel->callerextension->last_application->application_data != 0)
+				if(!switch_strlen_zero(newchannel->callerextension->last_application->application_data))
 					strncpy(lastdata,newchannel->callerextension->last_application->application_data,strlen(newchannel->callerextension->last_application->application_data));
 			}
 		
@@ -320,7 +315,7 @@
 		std::pair<std::string,std::string> temppair;
 		temppair.first = *iItr;
 			
-		if(tempvariable != 0)
+		if(!switch_strlen_zero(tempvariable))
 			temppair.second = tempvariable;
 		
 		chanvars_fixed.push_back(temppair);
@@ -359,7 +354,7 @@
 
 			char *tempvariable;
 			tempvariable = switch_channel_get_variable(channel,tempstring);
-			if(tempvariable != 0)
+			if(!switch_strlen_zero(tempvariable))
 				chanvars_supp[*iItr] = tempvariable;
 		}
 	}

Added: freeswitch/trunk/src/mod/event_handlers/mod_cdr/mod_cdr.conf.xml
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/mod/event_handlers/mod_cdr/mod_cdr.conf.xml	Wed Feb 28 17:28:03 2007
@@ -0,0 +1,32 @@
+<!-- Please see the information in src/mod/event_handlers/mod_cdr/README for an explanation of these settings. -->
+
+<configuration name="mod_cdr.conf" description="CDR Configuration">
+  <pddcdr>
+    <param name="path" value="/tmp/pddcdr"/>
+    <param name="chanvars" value="foo,accountcode"/>
+    <param name="chanvars_fixed" value="*"/>
+  </pddcdr>
+           <!--
+           <mysqlcdr>
+                   <param name="hostname" value=""/>
+                   <param name="username" value=""/>
+                   <param name="password" value=""/>
+                   <param name="dbname" value=""/>
+                   <param name="chanvars_supp" value="*"/>
+           </mysqlcdr>
+           <xmlcdr>
+                   <param name="path" value="/tmp/xmlcdr"/>
+           </xmlcdr>
+           -->
+  <csvcdr>
+    <param name="path" value="/tmp/csvcdr"/>
+  </csvcdr>
+  <sqlitecdr>
+    <param name="path" value="/tmp/sqlitecdr"/>
+    <param name="chanvars_fixed" value="The_Kow=i,username=s"/>
+    <param name="chanvars_supp" value="*"/>
+    <param name="repeat_fixed_in_supp" value="1"/>
+    <param name="timezone" value="utc"/>
+  </sqlitecdr>
+</configuration>
+



More information about the Freeswitch-svn mailing list