[Freeswitch-svn] [commit] r1611 - in freeswitch/branches/mishehu/src/mod: applications/mod_rss loggers/mod_cdr

mishehu at freeswitch.org mishehu at freeswitch.org
Mon Jun 12 17:23:15 EDT 2006


Author: mishehu
Date: Mon Jun 12 17:23:14 2006
New Revision: 1611

Modified:
   freeswitch/branches/mishehu/src/mod/applications/mod_rss/mod_rss.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

Log:
Added chanvar handling to MysqlCDR.  Merged to trunk r1610.

Modified: freeswitch/branches/mishehu/src/mod/applications/mod_rss/mod_rss.c
==============================================================================
--- freeswitch/branches/mishehu/src/mod/applications/mod_rss/mod_rss.c	(original)
+++ freeswitch/branches/mishehu/src/mod/applications/mod_rss/mod_rss.c	Mon Jun 12 17:23:14 2006
@@ -118,8 +118,8 @@
 		return SWITCH_STATUS_BREAK;
 		break;
 	case '2':
-		if (dtb->speed < 220) {
-			dtb->speed += 20;
+		if (dtb->speed < 260) {
+			dtb->speed += 30;
 			switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
 			switch_set_flag(dtb, SFLAG_INFO);
 			return SWITCH_STATUS_BREAK;
@@ -132,7 +132,7 @@
 		return SWITCH_STATUS_BREAK;
 	case '8':
 		if (dtb->speed > 80) {
-			dtb->speed -= 20;
+			dtb->speed -= 30;
 			switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
 			switch_set_flag(dtb, SFLAG_INFO);
 			return SWITCH_STATUS_BREAK;
@@ -341,7 +341,7 @@
 #endif
 				char term;
 				char *cp;
-				int blen = sizeof(cmd) - strlen(cmd);
+				int blen = sizeof(cmd) - (int)strlen(cmd);
 
 				cp = cmd + blen;
 				switch_ivr_collect_digits_count(session, cp, blen, blen, "#", &term, 5000);
@@ -474,7 +474,7 @@
 			switch_strftime(date, &retsize, sizeof(date), "%A, %B %d, %Y. %I:%M %p", &tm);
 
 
-			snprintf(buf, sizeof(buf), "%s. %s. %s. local time: %s, Press 0 for options or pound to return to the main menu. ", 
+			snprintf(buf, sizeof(buf), "%s. %s. %s. local time: %s, Press 0 for options, 5 to change voice, or pound to return to the main menu. ", 
 					 title_txt, description_txt, rights_txt, date);
 			status = switch_ivr_speak_text_handle(session,
 												  &sh,
@@ -552,7 +552,7 @@
 								 "Press star to pause or resume speech. "
 								 "To go to the next item, press six. "
 								 "To go back, press 4. "
-								 "Press eight to go faster, two to slow down, or 7 to resume normal speed. "
+								 "Press two to go faster, eight to slow down, or 7 to resume normal speed. "
 								 "To change voices, press five. To restore the original voice press 9. "
 								 "To hear these options again, press zero or press pound to return to the main menu. ");
 					} else {
@@ -560,7 +560,7 @@
 						len = (uint32_t)strlen(buf);
 
 						if (entries[dtb.index].subject_txt) {
-							snprintf(buf + len, sizeof(buf) - len, "Subject %s. ", entries[dtb.index].subject_txt);
+							snprintf(buf + len, sizeof(buf) - len, "Subject: %s. ", entries[dtb.index].subject_txt);
 							len = (uint32_t)strlen(buf);
 						}
 				

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	Mon Jun 12 17:23:14 2006
@@ -74,7 +74,7 @@
 				outputfile_path = val;
 				tempcount++;
 			}
-			else if (!strcmp(var, "channel_variables")) 
+			else if (!strcmp(var, "chanvars")) 
 			{
 				std::string unparsed;
 				unparsed = val;
@@ -82,7 +82,7 @@
 				{
 					chanvars_list = parse_channel_variables_xconfig(unparsed);
 					logchanvars=1;
-				};
+				}
 			}
 		}
 		
@@ -131,7 +131,7 @@
 			iBeg = chanvars.begin();
 			iEnd = chanvars.end();
 			for(iItr = iBeg; iItr != iEnd; iItr++)
-				outputfile << "\t\t\'" << iItr->first << "\' = \'" << iItr.second << "\'," << std::endl;
+				outputfile << "\t\t\'" << iItr->first << "\' = \'" << iItr->second << "\'," << std::endl;
 		}
 		outputfile << "\t}," << std::endl << "};" << std::endl << std::endl;
 	}

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	Mon Jun 12 17:23:14 2006
@@ -185,12 +185,15 @@
 	if(stringlist.front() == "*")
 	{
 		switch_hash_index_t *hi;
-		char *var,*val;
+		void *var,*val;
 
 		for (hi = switch_hash_first(0, channel->variables); hi; hi = switch_hash_next(hi)) 
 		{
 			switch_hash_this(hi, &var, NULL, &val);
-			chanvars[*var] = *val;
+			std::string tempstring_first, tempstring_second;
+			tempstring_first = (char *) var;
+			tempstring_second = (char *) val;
+			chanvars[tempstring_first] = tempstring_second;
 		}
 	}
 	else

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	Mon Jun 12 17:23:14 2006
@@ -54,6 +54,10 @@
 	memset(sql_query,0,1024);
 	strncpy(sql_query,tmpsql_query,strlen(tmpsql_query));
 	
+	char tempsql_query_chanvars[] = "INSERT INTO chanvars (callid,varname,varvalue) VALUES(?,?,?)";
+	memset(sql_query_chanvars,0,1024);
+	strncpy(sql_query_chanvars,tempsql_query_chanvars,strlen(tempsql_query_chanvars));
+	
 	if ((*settings = switch_xml_child(*cfg, "mysqlcdr"))) 
 	{
 		for (param = switch_xml_child(*settings, "param"); *param; *param = (*param)->next) 
@@ -71,8 +75,13 @@
 				strncpy(dbname,val,strlen(val));
 			else if(!strcmp(var,"chanvars")
 			{
-				logchanvars = 1;
-					
+				std::string unparsed;
+				unparsed = val;
+				if(unparsed.size() > 0)
+				{
+					chanvars_list = parse_channel_variables_xconfig(unparsed);
+					logchanvars=1;
+				}
 			}
 		}
 		
@@ -90,11 +99,12 @@
 		else
 			connectionstate = 1;
 
-		//mysql_autocommit(conn,0);
+		mysql_autocommit(conn,0);
 		stmt = mysql_stmt_init(conn);
 		mysql_stmt_prepare(stmt,sql_query,strlen(sql_query));
+		if(logchanvars)
+			mysql_stmt_prepare(stmt_chanvars,sql_query_chanvars,strlen(sql_query_chanvars));
 	
-		//memset(bind,0,sizeof(bind)); // Zero out the memory used for bind.	
 	}
 }
 
@@ -191,7 +201,42 @@
 	mysql_stmt_bind_param(stmt,bindmetemp);
 	switch_console_printf(SWITCH_CHANNEL_CONSOLE, "MysqlCDR::process_record() - Trying to execute the statement.\n");
 	mysql_stmt_execute(stmt);
+	long long insertid = mysql_stmt_insert_id();
 	
+	if(logchanvars && chanvars.size() > 0)
+	{
+		std::map<std::string,std::string>::iterator iItr,iBeg,iEnd;
+		iBeg = chanvars.begin();
+		iEnd = chanvars.end();
+		for(iItr = iBeg; iItr != iEnd; iItr++)
+		{
+			MYSQL_BIND bindme_chanvars[3];
+			memset(bindme_chanvars,0,sizeof(bindme_chanvars));
+			
+			bindme_chanvars[0].buffer_type = MYSQL_TYPE_LONGLONG;
+			bindme_chanvars[0].buffer = &insertid;
+			
+			bindme_chanvars[1].buffer_type = MYSQL_TYPE_VAR_STRING;
+			long unsigned int varname_length = iItr->first.size();
+			bindme_chanvars[1].length = &varname_length;
+			bindme_chanvars[1].buffer_length = varname_length;
+			char varname_temp[] = iItr->first.c_str();
+			bindme_chanvars[1].buffer = varname_temp;
+			
+			bindme_chanvars[2].buffer_type = MYSQL_TYPE_VAR_STRING;
+			long unsigned int varvalue_length = iItr->second.size();
+			bindme_chanvars[2].length = &varvalue_length;
+			bindme_chanvars[2].buffer_length = varvalue_length;
+			char varvalue_temp[] = iItr->second.c_str();
+			bindme_chanvars[1].buffer = varvalue_temp;
+			
+			mysql_stmt_bind_param(stmt_chanvars,bindme_chanvars);
+			mysql_stmt_execute(stmt_chanvars);
+		}
+	}
+	
+	mysql_commit(conn);
+	
 	/* For future use
 	if(!mysql_stmt_execute(stmt))
 	{
@@ -216,6 +261,7 @@
 void MysqlCDR::disconnect()
 {
 	mysql_stmt_close(stmt);
+	mysql_stmt_close(stmt_chanvars);
 	mysql_close(conn);
 }
 



More information about the Freeswitch-svn mailing list