[Freeswitch-svn] [commit] r1645 - in freeswitch/branches/mishehu: . conf src src/mod/applications/mod_commands src/mod/endpoints/mod_exosip src/mod/loggers/mod_cdr

mishehu at freeswitch.org mishehu at freeswitch.org
Sat Jun 17 20:29:15 EDT 2006


Author: mishehu
Date: Sat Jun 17 20:29:14 2006
New Revision: 1645

Modified:
   freeswitch/branches/mishehu/AUTHORS
   freeswitch/branches/mishehu/conf/freeswitch.xml
   freeswitch/branches/mishehu/src/mod/applications/mod_commands/mod_commands.c
   freeswitch/branches/mishehu/src/mod/endpoints/mod_exosip/mod_exosip.c
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.cpp
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.cpp
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.cpp
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/schema-update.mysql
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/schema.sql
   freeswitch/branches/mishehu/src/switch_ivr.c

Log:
Houston, we have chanvar logging working!  Cleared up some dumb debug stuff, merged to trunk r1644

Modified: freeswitch/branches/mishehu/AUTHORS
==============================================================================
--- freeswitch/branches/mishehu/AUTHORS	(original)
+++ freeswitch/branches/mishehu/AUTHORS	Sat Jun 17 20:29:14 2006
@@ -21,6 +21,7 @@
   and moral support.
  Michal "cypromis" Bielicki (michal.bielicki  AT halo2.pl) - Solaris porting, and autotools enhancements.
  James Martelletti <james at nerdc0re.com> - All around cool guy (mod_syslog)
+ Johny Kadarisman <jkr888 at gmail.com>
  
 A big THANK YOU goes to:
 

Modified: freeswitch/branches/mishehu/conf/freeswitch.xml
==============================================================================
--- freeswitch/branches/mishehu/conf/freeswitch.xml	(original)
+++ freeswitch/branches/mishehu/conf/freeswitch.xml	Sat Jun 17 20:29:14 2006
@@ -275,7 +275,7 @@
     <!-- *NOTE* The special context name 'any' will match any context -->
     <context name="default">
 			<extension name="tollfree">
-      	<condition field="destination_number" expression="^(18[0{2}8{2}7{2}6{2}].*)$">
+      	<condition field="destination_number" expression="^(18[0{2}8{2}7{2}6{2}]\d{7})">
 					<action application="bridge" data="exosip/$1-freeswitch at voip.trxtel.com"/>
 				</condition>
 			</extension>

Modified: freeswitch/branches/mishehu/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/branches/mishehu/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/branches/mishehu/src/mod/applications/mod_commands/mod_commands.c	Sat Jun 17 20:29:14 2006
@@ -24,6 +24,8 @@
  * Contributor(s):
  * 
  * Anthony Minessale II <anthmct at yahoo.com>
+ * Michael Jerris <mike at jerris.com>
+ * Johny Kadarisman <jkr888 at gmail.com>
  *
  * 
  * mod_commands.c -- Misc. Command Module
@@ -185,7 +187,7 @@
 static int show_callback(void *pArg, int argc, char **argv, char **columnNames){
 	switch_stream_handle_t *stream = (switch_stream_handle_t *) pArg;
 
-	stream->write_function(stream, "%s\n", argv[1]);
+	stream->write_function(stream, "%s|%s\n", argv[0], argv[1] ? argv[1] : "NULL");
 	return 0;
 }
 
@@ -196,7 +198,22 @@
 	char *errmsg;
 	switch_core_db_t *db = switch_core_db_handle();
 
-	sprintf (sql, "select * from interfaces");
+    if (!cmd) {
+        sprintf (sql, "select * from interfaces");
+    }
+    else if ( !strcmp(cmd,"codec") || !strcmp(cmd,"application") || 
+              !strcmp(cmd,"api") || !strcmp(cmd,"dialplan") || 
+              !strcmp(cmd,"file") || !strcmp(cmd,"timer") 
+            ) {
+        sprintf (sql, "select * from interfaces where type = '%s'", cmd);
+    }
+    else {
+        stream->write_function(stream, "Invalid interfaces type!\n");
+        stream->write_function(stream, "Example:\n");
+        stream->write_function(stream, "show <blank>|codec|application|api|dialplan|file|timer\n");
+        return SWITCH_STATUS_SUCCESS;
+    }
+    
 	switch_core_db_exec(db, sql, show_callback, stream, &errmsg);
 
 	if (errmsg) {

Modified: freeswitch/branches/mishehu/src/mod/endpoints/mod_exosip/mod_exosip.c
==============================================================================
--- freeswitch/branches/mishehu/src/mod/endpoints/mod_exosip/mod_exosip.c	(original)
+++ freeswitch/branches/mishehu/src/mod/endpoints/mod_exosip/mod_exosip.c	Sat Jun 17 20:29:14 2006
@@ -353,7 +353,7 @@
 			int i;
 			static const switch_codec_implementation_t *imp;
 			for (i = 0; i < tech_pvt->num_codecs; i++) {
-				int x = 1;
+				int x = 0;
 
 				snprintf(tmp, sizeof(tmp), "%u", tech_pvt->codecs[i]->ianacode);
 				sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(tmp));
@@ -1289,7 +1289,7 @@
 
 
 			for (i = 0; i < tech_pvt->num_codecs; i++) {
-				int x = 1;
+				int x = 0;
 
 				for (imp = tech_pvt->codecs[i]->implementations; imp; imp = imp->next) {
 					sdp_add_codec(tech_pvt->sdp_config, tech_pvt->codecs[i]->codec_type, tech_pvt->codecs[i]->ianacode, tech_pvt->codecs[i]->iananame,

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.cpp	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.cpp	Sat Jun 17 20:29:14 2006
@@ -25,14 +25,19 @@
 		switch_time_exp_lt(&tempcallend, callenddate);
 		
 		// Format the times
-		size_t retsizecsd, retsizecad, retsizeced;
+		size_t retsizecsd, retsizecad, retsizeced, retsizeceff;  //csd == callstartdate, cad == callanswerdate, ced == callenddate, ceff == callenddate_forfile
 		char format[] = "%F %T";
 		switch_strftime(formattedcallstartdate,&retsizecsd,sizeof(formattedcallstartdate),format,&tempcallstart);
 		switch_strftime(formattedcallanswerdate,&retsizecad,sizeof(formattedcallanswerdate),format,&tempcallanswer);
 		switch_strftime(formattedcallenddate,&retsizeced,sizeof(formattedcallenddate),format,&tempcallend);
-	
+
+		char format_forfile[] = "%s";
+		char callenddate_forfile[25];
+		switch_strftime(callenddate_forfile,&retsizeceff,sizeof(callenddate_forfile),format_forfile,&tempcallend);
 		outputfile_name = outputfile_path;
 		outputfile_name.append("/");
+		outputfile_name.append(callenddate_forfile); // Make sorting a bit easier, kinda like Maildir does
+		outputfile_name.append(".");
 		outputfile_name.append(myuuid);  // The goal is to have a resulting filename of "/path/to/myuuid"
 		outputfile_name.append(".atm");  // The extension is in honor of anthm
 	

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.cpp	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.cpp	Sat Jun 17 20:29:14 2006
@@ -212,9 +212,10 @@
 			tempstringvector.push_back('\0');
 			char* tempstring= &tempstringvector[0];
 
-			std::string tempstring_formap = switch_channel_get_variable(channel,tempstring);
-			if(tempstring_formap.size() > 0)
-				chanvars[*iItr] = tempstring_formap;
+			char *tempvariable;
+			tempvariable = switch_channel_get_variable(channel,tempstring);
+			if(tempvariable != 0)
+				chanvars[*iItr] = tempvariable;
 		}
 	}
 }

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.cpp	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.cpp	Sat Jun 17 20:29:14 2006
@@ -25,7 +25,9 @@
 		dstchannel_length = strlen(dstchannel);
 		lastapp_length = strlen(lastapp);
 		lastdata_length = strlen(lastdata);
-	}
+		
+		process_channel_variables(chanvars_list,newchannel->channel);
+	}	
 }
 
 MysqlCDR::~MysqlCDR()
@@ -50,7 +52,6 @@
 
 void MysqlCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param)
 {
-	switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::connect() - Trying to connect to the server.\n");
 	activated = 0; // Set it as inactive initially
 	connectionstate = 0; // Initialize it to false to show that we aren't yet connected.
 	char tmpsql_query[] = "INSERT INTO freeswitchcdr  (callstartdate,callanswerdate,callenddate,originated,clid,src,dst,ani,ani2,dialplan,myuuid,destuuid,srcchannel,dstchannel,lastapp,lastdata,billusec,disposition,hangupcause,amaflags) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
@@ -89,7 +90,6 @@
 		}
 		
 		activated = 1;
-		switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::connect() - Trying to init the MYSQL *conn pointer.\n");
 		conn = mysql_init(NULL);
 		mysql_options(conn, MYSQL_READ_DEFAULT_FILE, "");
 		if(mysql_real_connect(conn,hostname,username,password,dbname,0,NULL,0) == NULL)
@@ -198,16 +198,12 @@
 	add_parameter(disposition,MYSQL_TYPE_TINY,0);
 	add_parameter(hangupcause,MYSQL_TYPE_LONG,0);
 	add_parameter(amaflags,MYSQL_TYPE_TINY,0);
-	
-	switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::process_record() - Trying to process, bindme has %d elements.\n",bindme.size());
-	
+		
 	MYSQL_BIND *bindmetemp;
 	bindmetemp = new MYSQL_BIND[bindme.size()];
 	copy(bindme.begin(), bindme.end(), bindmetemp);
 	
-	switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::process_record() - Trying to bind the parameters.\n");
 	mysql_stmt_bind_param(stmt,bindmetemp);
-	switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::process_record() - Trying to execute the statement.\n");
 	int bah = mysql_stmt_execute(stmt);
 	switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::process_record() - Statement executed? Error: %d\n",bah);
 	
@@ -317,11 +313,7 @@
 	destination.day = param.tm_mday;
 	destination.hour = param.tm_hour;
 	destination.minute = param.tm_min;
-	destination.second = param.tm_sec;
-	
-	std::cout << "Original date: " << param.tm_year << "-" << param.tm_mon << "-" << param.tm_mday << " " << param.tm_hour << ":" << param.tm_min << ":" << param.tm_sec << std::endl;
-	std::cout <<  "Date added: " << destination.year;
-	std::cout << "-" << destination.month << "-" << destination.day << " " << destination.hour << ":" << destination.minute << ":" << destination.second << std::endl;
+	destination.second = param.tm_sec;	
 }
 
 AUTO_REGISTER_BASECDR(MysqlCDR);

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/schema-update.mysql
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/schema-update.mysql	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/schema-update.mysql	Sat Jun 17 20:29:14 2006
@@ -1,5 +1,4 @@
 ALTER TABLE freeswitchcdr modify callid bigint unsigned auto_increment;
 ALTER TABLE freeswitchcdr Engine=InnoDB;
 
-ALTER TABLE chanvars modify callid bigint unsigned auto_increment;
 ALTER TABLE chanvars Engine=InnoDB;
\ No newline at end of file

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/schema.sql
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/schema.sql	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/schema.sql	Sat Jun 17 20:29:14 2006
@@ -34,7 +34,7 @@
 create table chanvars (
 	callid bigint unsigned default 0,
 	varname varchar(80) NOT NULL,
-	varval varchar(255) default ""
+	varvalue varchar(255) default ""
 );
 
-create index callid_index on chanvars(callid);
\ No newline at end of file
+create index callid_index on chanvars(callid,varname);
\ No newline at end of file

Modified: freeswitch/branches/mishehu/src/switch_ivr.c
==============================================================================
--- freeswitch/branches/mishehu/src/switch_ivr.c	(original)
+++ freeswitch/branches/mishehu/src/switch_ivr.c	Sat Jun 17 20:29:14 2006
@@ -538,6 +538,7 @@
 	flags = 0;
 	switch_sleep(200000);
 	switch_core_speech_feed_tts(sh, text, &flags);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Speaking text: %s\n", text);
 
 	write_frame.rate = sh->rate;
 



More information about the Freeswitch-svn mailing list