[Freeswitch-svn] [commit] r1674 - freeswitch/branches/mishehu/src/mod/loggers/mod_cdr
Freeswitch SVN
mishehu at freeswitch.org
Sun Jun 25 02:19:41 EDT 2006
Author: mishehu
Date: Sun Jun 25 02:19:40 2006
New Revision: 1674
Modified:
freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.cpp
freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.h
freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.cpp
freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.h
freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.cpp
Log:
Have added the code for parsing fixed and supplemental chanvars in BaseCDR. Need to thoroughly test though. Merged to trunk r1673.
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 Sun Jun 25 02:19:40 2006
@@ -43,7 +43,8 @@
outputfile.open(outputfile_name.c_str());
- process_channel_variables(chanvars_list,newchannel->channel);
+ //bool fixed = 0;
+ process_channel_variables(chanvars_supp_list,chanvars_fixed_list,newchannel->channel);
}
}
@@ -56,7 +57,8 @@
bool AnthmCDR::logchanvars=0;
bool AnthmCDR::connectionstate=0;
std::string AnthmCDR::outputfile_path;
-std::list<std::string> AnthmCDR::chanvars_list;
+std::list<std::string> AnthmCDR::chanvars_fixed_list;
+std::list<std::string> AnthmCDR::chanvars_supp_list;
void AnthmCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param)
{
@@ -87,14 +89,14 @@
if(unparsed.size() > 0)
{
bool fixed = 0;
- parse_channel_variables_xconfig(unparsed,chanvars_list,fixed);
+ parse_channel_variables_xconfig(unparsed,chanvars_supp_list,fixed);
logchanvars=1;
}
}
}
else if (!strcmp(var, "chanvars_fixed"))
{
- switch_console_printf(SWITCH_CHANNEL_LOG,"AnthmCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format. Please use the setting parameter of \"chanvars\" instead and try again.\n");
+ switch_console_printf(SWITCH_CHANNEL_LOG,"AnthmCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format. Please use the setting parameter of \"chanvars\" or \"chanvars_supp\" instead and try again.\n");
}
else if (!strcmp(var, "chanvars_supp"))
{
@@ -143,12 +145,10 @@
// Now to process chanvars
outputfile << "\t\'chanvars\' => {" << std::endl;
- if(chanvars.size() > 0 )
+ if(chanvars_supp.size() > 0 )
{
- std::map<std::string,std::string>::iterator iItr,iBeg,iEnd;
- iBeg = chanvars.begin();
- iEnd = chanvars.end();
- for(iItr = iBeg; iItr != iEnd; iItr++)
+ std::list<std::pair<std::string,std::string> >::iterator iItr,iEnd;
+ for(iItr = chanvars_fixed.begin(), iEnd = chanvars_fixed.end() ; iItr != iEnd; iItr++)
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/anthmcdr.h
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.h (original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.h Sun Jun 25 02:19:40 2006
@@ -28,7 +28,8 @@
static bool connectionstate; // What is the status of the connection?
static bool logchanvars;
static std::string outputfile_path; // The directory we'll dump these into
- static std::list<std::string> chanvars_list; // A list containing the list of chanvars to capture
+ static std::list<std::string> chanvars_fixed_list; // Normally this would be used, but not in this class
+ static std::list<std::string> chanvars_supp_list; // This will hold the list for all chanvars here
char formattedcallstartdate[100];
char formattedcallanswerdate[100];
char formattedcallenddate[100];
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 Sun Jun 25 02:19:40 2006
@@ -145,7 +145,7 @@
/* bool fixed is for checking if this is the fixed or supplemental list
*/
-void BaseCDR::parse_channel_variables_xconfig(std::string& unparsed,std::list<std::string>& chanvarlist,bool& fixed)
+void BaseCDR::parse_channel_variables_xconfig(std::string& unparsed,std::list<std::string>& chanvarlist,bool fixed)
{
std::string tempstring;
long j = 0;
@@ -241,8 +241,34 @@
}
-void BaseCDR::process_channel_variables(const std::list<std::string>& stringlist, switch_channel_t *channel)
+// This is for processing the fixed channel variables
+void BaseCDR::process_channel_variables(const std::list<std::string>& stringlist,switch_channel_t *channel)
{
+ std::list<std::string>::const_iterator iItr,iEnd;
+ iEnd = stringlist.end();
+
+ for(iItr = stringlist.begin(); iItr != iEnd; iItr++)
+ {
+ std::vector<char> tempstringvector(iItr->begin(), iItr->end());
+ tempstringvector.push_back('\0');
+ char* tempstring= &tempstringvector[0];
+
+ char *tempvariable;
+ tempvariable = switch_channel_get_variable(channel,tempstring);
+
+ std::pair<std::string,std::string> temppair;
+ temppair.first = *iItr;
+ if(tempvariable != 0)
+ temppair.second = tempvariable;
+
+ chanvars_fixed.push_back(temppair);
+ }
+
+}
+
+// This one is for processing of supplemental chanvars
+void BaseCDR::process_channel_variables(const std::list<std::string>& stringlist, const std::list<std::string>& fixedlist, switch_channel_t *channel,bool repeat)
+{
if(stringlist.front() == "*")
{
switch_hash_index_t *hi;
@@ -256,13 +282,12 @@
std::string tempstring_first, tempstring_second;
tempstring_first = (char *) var;
tempstring_second = (char *) val;
- chanvars[tempstring_first] = tempstring_second;
+ chanvars_supp[tempstring_first] = tempstring_second;
}
}
else
{
- std::list<std::string>::const_iterator iBeg,iItr,iEnd;
- iBeg = stringlist.begin();
+ std::list<std::string>::const_iterator iItr,iEnd;
iEnd = stringlist.end();
for(iItr = stringlist.begin(); iItr != iEnd; iItr++)
@@ -274,7 +299,19 @@
char *tempvariable;
tempvariable = switch_channel_get_variable(channel,tempstring);
if(tempvariable != 0)
- chanvars[*iItr] = tempvariable;
+ chanvars_supp[*iItr] = tempvariable;
+ }
+ }
+
+ if(!repeat)
+ {
+ std::map<std::string,std::string>::iterator MapItr;
+ std::list<std::string>::const_iterator iItr,iEnd;
+ for(iItr = fixedlist.begin(), iEnd = fixedlist.end(); iItr != iEnd; iItr++)
+ {
+ MapItr = chanvars_supp.find(*iItr);
+ if(MapItr != chanvars_supp.end() )
+ chanvars_supp.erase(MapItr);
}
}
}
Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.h
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.h (original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.h Sun Jun 25 02:19:40 2006
@@ -48,9 +48,10 @@
virtual void tempdump_record() = 0;
virtual void reread_tempdumped_records() = 0;
protected:
- void parse_channel_variables_xconfig(std::string& unparsed,std::list<std::string>& chanvarslist,bool& fixed);
- void parse_channel_variables_xconfig(std::string& unparsed,std::list<std::string>& chanvarslist,std::string& chanvars_fixed_types);
- void process_channel_variables(const std::list<std::string>& stringlist,switch_channel_t *channel);
+ void parse_channel_variables_xconfig(std::string& unparsed,std::list<std::string>& chanvarslist,bool fixed);
+ void parse_channel_variables_xconfig(std::string& unparsed,std::list<std::string>& chanvarslist,std::string& chanvars_fixed_types); // Typically used for SQL types
+ void process_channel_variables(const std::list<std::string>& stringlist,const std::list<std::string>& fixedlist,switch_channel_t *channel,bool repeat = 1); //This is used for supplemental chanvars
+ void process_channel_variables(const std::list<std::string>& stringlist,switch_channel_t *channel); // This is used for fixed chanvars
switch_time_t callstartdate;
switch_time_t callanswerdate;
switch_time_t callenddate;
@@ -74,7 +75,8 @@
int disposition; // Currently 0 = Busy/Unanswered, 1 = Answered
int amaflags;
switch_core_session_t *coresession;
- std::map<std::string,std::string> chanvars;
+ std::list<std::pair<std::string,std::string> > chanvars_fixed;
+ std::map<std::string,std::string> chanvars_supp;
/*
This is what happens when you base the ideas off of Asterisk... you end up with an inconvenient asteriskism.
char accountcode[20];
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 Sun Jun 25 02:19:40 2006
@@ -267,12 +267,11 @@
long long insertid = mysql_stmt_insert_id(stmt);
- if(logchanvars && chanvars.size() > 0)
+ if(logchanvars && chanvars_supp.size() > 0)
{
std::map<std::string,std::string>::iterator iItr,iBeg,iEnd;
- iBeg = chanvars.begin();
- iEnd = chanvars.end();
- for(iItr = iBeg; iItr != iEnd; iItr++)
+ iEnd = chanvars_supp.end();
+ for(iItr = chanvars_supp.begin(); iItr != iEnd; iItr++)
{
MYSQL_BIND bindme_chanvars[3];
memset(bindme_chanvars,0,sizeof(bindme_chanvars));
More information about the Freeswitch-svn
mailing list