[Freeswitch-svn] [commit] r1613 - in freeswitch/branches/mishehu/src: . include mod/loggers/mod_cdr

mishehu at freeswitch.org mishehu at freeswitch.org
Mon Jun 12 21:54:37 EDT 2006


Author: mishehu
Date: Mon Jun 12 21:54:36 2006
New Revision: 1613

Modified:
   freeswitch/branches/mishehu/src/include/switch_channel.h
   freeswitch/branches/mishehu/src/include/switch_ivr.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/baseregistry.h
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.cpp
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.h
   freeswitch/branches/mishehu/src/switch_channel.c

Log:
Some error fixes in code, update to trunk r1612

Modified: freeswitch/branches/mishehu/src/include/switch_channel.h
==============================================================================
--- freeswitch/branches/mishehu/src/include/switch_channel.h	(original)
+++ freeswitch/branches/mishehu/src/include/switch_channel.h	Mon Jun 12 21:54:36 2006
@@ -204,6 +204,15 @@
 SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel_t *channel, char *varname);
 
 /*!
+ * Start iterating over the entries in the channel variable list.
+ * @param channel the channel to intterate the variales for
+ * @param pool The pool to allocate the switch_hash_index_t iterator. If this
+ *          pool is NULL, then an internal, non-thread-safe iterator is used.
+ * @remark  Use switch_hash_next and switch_hash_this with this function to iterate all the channel variables
+ */
+SWITCH_DECLARE(switch_hash_index_t *) switch_channel_variable_first(switch_channel_t *channel, switch_memory_pool_t *pool);
+
+/*!
   \brief Assign a caller extension to a given channel
   \param channel channel to assign extension to
   \param caller_extension extension to assign

Modified: freeswitch/branches/mishehu/src/include/switch_ivr.h
==============================================================================
--- freeswitch/branches/mishehu/src/include/switch_ivr.h	(original)
+++ freeswitch/branches/mishehu/src/include/switch_ivr.h	Mon Jun 12 21:54:36 2006
@@ -51,7 +51,6 @@
  */
 
 /*!
-<<<<<<< .working
   \brief Wait for DTMF digits calling a pluggable callback function when digits are collected.
   \param session the session to read.
   \param dtmf_callback code to execute if any dtmf is dialed during the recording
@@ -59,37 +58,6 @@
   \param buflen the size of buf
   \return SWITCH_STATUS_SUCCESS to keep the collection moving.
 */
-SWITCH_DECLARE(switch_status) switch_ivr_collect_digits_callback(switch_core_session *session,
-																 switch_dtmf_callback_function dtmf_callback,
-																 void *buf,
-																 unsigned int buflen);
-
-/*!
-  \brief Wait for specified number of DTMF digits, untile terminator is received or until the channel hangs up.
-  \param session the session to read.
-  \param buf strig to write to
-  \param buflen max size of buf
-  \param maxdigits max number of digits to read
-  \param terminators digits to end the collection
-  \param terminator actual digit that caused the collection to end (if any)
-  \return SWITCH_STATUS_SUCCESS to keep the collection moving.
-*/
-SWITCH_DECLARE(switch_status) switch_ivr_collect_digits_count(switch_core_session *session,
-															  char *buf,
-															  unsigned int buflen,
-															  unsigned int maxdigits,
-															  const char *terminators,
-															  char *terminator);
-	
-/*!
-=======
-  \brief Wait for DTMF digits calling a pluggable callback function when digits are collected.
-  \param session the session to read.
-  \param dtmf_callback code to execute if any dtmf is dialed during the recording
-  \param buf an object to maintain across calls
-  \param buflen the size of buf
-  \return SWITCH_STATUS_SUCCESS to keep the collection moving.
-*/
 SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session,
 																 switch_dtmf_callback_function_t dtmf_callback,
 																 void *buf,
@@ -115,7 +83,6 @@
 																unsigned int timeout);
 	
 /*!
->>>>>>> .merge-right.r1490
   \brief play a file from the disk to the session
   \param session the session to play the file too
   \param fh file handle to use (NULL for builtin one)
@@ -131,15 +98,9 @@
 												   switch_file_handle_t *fh,
 												   char *file,
 												   char *timer_name,
-<<<<<<< .working
-												   switch_dtmf_callback_function dtmf_callback,
-												   void *buf,
-												   unsigned int buflen);
-=======
 												   switch_dtmf_callback_function_t dtmf_callback,
 												   void *buf,
 												   unsigned int buflen);
->>>>>>> .merge-right.r1490
 
 
 
@@ -157,13 +118,6 @@
 SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *session,
 													 switch_file_handle_t *fh,
 													 char *file,
-<<<<<<< .working
-													 switch_dtmf_callback_function dtmf_callback,
-													 void *buf,
-													 unsigned int buflen);
-
-
-=======
 													 switch_dtmf_callback_function_t dtmf_callback,
 													 void *buf,
 													 unsigned int buflen);
@@ -229,7 +183,6 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, char *extension, char *dialplan, char *context);
 
->>>>>>> .merge-right.r1490
 /** @} */
 
 END_EXTERN_C

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 21:54:36 2006
@@ -22,7 +22,7 @@
 
 BaseCDR::BaseCDR(switch_mod_cdr_newchannel_t *newchannel)
 {
-	if(channel != 0)
+	if(newchannel != 0)
 	{
 		memset(clid,0,80);
 		memset(dialplan,0,80);
@@ -63,15 +63,15 @@
 	if(newchannel->callerprofile->ani != 0)
 		strncpy(ani,newchannel->callerprofile->ani,strlen(newchannel->callerprofile->ani));
 	if(newchannel->callerprofile->ani2 != 0)
-		strncpy(ani2,tempcallerprofile->ani2,strlen(newchannel->callerprofile->ani2));
+		strncpy(ani2,newchannel->callerprofile->ani2,strlen(newchannel->callerprofile->ani2));
 	
 	if(newchannel->callerprofile->dialplan != 0)
-		strncpy(dialplan,tempcallerprofile->dialplan,strlen(newchannel->callerprofile->dialplan));
+		strncpy(dialplan,newchannel->callerprofile->dialplan,strlen(newchannel->callerprofile->dialplan));
 	
 	if(newchannel->callerprofile->network_addr != 0)
 		strncpy(network_addr,newchannel->callerprofile->network_addr,strlen(newchannel->callerprofile->network_addr));
 		
-	switch_console_printf(SWITCH_CHANNEL_CONSOLE, "BaseCDR::BaseCDR(switch_mod_cdr_newchannel*) - Channel caller_profile loaded.\n");
+	switch_console_printf(SWITCH_CHANNEL_LOG, "BaseCDR::BaseCDR(switch_mod_cdr_newchannel*) - Channel caller_profile loaded.\n");
 		
 	originated = newchannel->originate;
 	
@@ -116,7 +116,7 @@
 	hangupcause = switch_channel_get_cause(newchannel->channel);
 	hangupcause_text = switch_channel_cause2str(hangupcause);
 	
-	switch_console_printf(SWITCH_CHANNEL_CONSOLE, "BaseCDR::BaseCDR(switch_mod_cdr_newchannel*) - Call state & length calculated.\n");
+	switch_console_printf(SWITCH_CHANNEL_LOG, "BaseCDR::BaseCDR(switch_mod_cdr_newchannel*) - Call state & length calculated.\n");
 		
 	if(newchannel->callerextension != 0)
 		if(newchannel->callerextension->last_application != 0)
@@ -133,7 +133,7 @@
 	strncpy(uniqueid," ",1);  // I don't see any of the user stuff in the docs yet
 	strncpy(userfield," ",1); // So we can't add these yet
 	*/
-	switch_console_printf(SWITCH_CHANNEL_CONSOLE, "BaseCDR::BaseCDR(switch_mod_cdr_newchannel*) - Processing completed.\n");
+	switch_console_printf(SWITCH_CHANNEL_LOG, "BaseCDR::BaseCDR(switch_mod_cdr_newchannel*) - Processing completed.\n");
 
 }
 
@@ -142,24 +142,24 @@
 
 }
 
-std::list<std::string>& BaseCDR::parse_channel_variables_xconfig(std::string& unparsed)
+std::list<std::string> BaseCDR::parse_channel_variables_xconfig(std::string& unparsed)
 {
 	std::list<std::string> stringlist;
 	std::string tempstring;
 	long j = 0;
 	for(std::string::size_type i = 0; j != -1; )
 	{
-		j = string1.find(',',i);
+		j = unparsed.find(',',i);
 		if(j > 0)
 		{
 			tempstring = unparsed.substr(i,(j-i));
-			stringlist.push(tempstring);
+			stringlist.push_back(tempstring);
 			i =j+1;
 		}
 		else
 		{
 			tempstring = unparsed.substr(i);
-			stringlist.push(tempstring);
+			stringlist.push_back(tempstring);
 		}
 	}
 	
@@ -167,13 +167,14 @@
 	std::list<std::string>::iterator iBeg,iItr,iEnd;
 	iBeg = stringlist.begin();
 	iEnd = stringlist.end();
-	for(bool testvalue = 1; iItr = stringlist.begin(); iItr != iEnd && testvalue ; iItr++)
+	bool testvalue = 1;
+	for(iItr = stringlist.begin(); iItr != iEnd && testvalue ; iItr++)
 	{
-		if(iItr == "*")
+		if(*iItr == "*")
 		{
 			std::string tempstring = "*";
 			stringlist.clear();
-			stringlist.push(tempstring);
+			stringlist.push_back(tempstring);
 			testvalue = 0;
 		}
 	}

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	Mon Jun 12 21:54:36 2006
@@ -16,7 +16,7 @@
 #ifdef __cplusplus
 #include <vector>
 #include <list>
-#include <queue>
+#include <map>
 #include <switch.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -46,7 +46,7 @@
 		virtual void tempdump_record() = 0;
 		virtual void reread_tempdumped_records() = 0;
 	protected:
-		std::list<std::string>& parse_channel_variables_xconfig(std::string& unparsed);
+		std::list<std::string> parse_channel_variables_xconfig(std::string& unparsed);
 		void process_channel_variables(const std::list<std::string>& stringlist,switch_channel_t *channel);
 		//switch_channel_t *tempchannel;
 		switch_time_t callstartdate;

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/baseregistry.h
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/baseregistry.h	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/baseregistry.h	Mon Jun 12 21:54:36 2006
@@ -6,7 +6,7 @@
 #ifdef __cplusplus
 #include <vector>
 
-template<class T> BaseCDR* basecdr_factory(newchannel)
+template<class T> BaseCDR* basecdr_factory(switch_mod_cdr_newchannel_t *newchannel)
 {
 	return new T(newchannel);
 }

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.cpp	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.cpp	Mon Jun 12 21:54:36 2006
@@ -7,29 +7,27 @@
 
 }
 
-CDRContainer::CDRContainer(switch_memory_pool *module_pool)
+CDRContainer::CDRContainer(switch_memory_pool_t *module_pool)
 {
 	// Create the APR threadsafe queue, though I don't know if this is the current memory pool.
 	switch_queue_create(&cdrqueue,5224288, module_pool);
 	
-	switch_channel_t *channel = 0;
-
 	char *configfile = "mod_cdr.conf";
 	switch_xml_t cfg, xml, settings, param;
 	
 	switch_mod_cdr_newchannel_t *newchannel = new switch_mod_cdr_newchannel_t;
-	memset(0,newchannel,sizeof(newchannel));
+	memset(newchannel,0,sizeof(*newchannel));
 	
 	
-	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) 
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
+	if (!(xml = switch_xml_open_cfg(configfile, &cfg, NULL))) 
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", configfile);
 	else
 	{	
 		BaseRegistry& registry(BaseRegistry::get());
 		for(BaseRegistry::iterator it = registry.begin(); it != registry.end(); ++it)
 		{
 			basecdr_creator func = *it;
-			BaseCDR* _ptr = func(channel,temptimes,tempcallerextension,tempcallerprofile,temporiginateprofile,temporiginate);
+			BaseCDR* _ptr = func(newchannel);
 			std::auto_ptr<BaseCDR> ptr(_ptr);
 			ptr->connect(&cfg,&xml,&settings,&param);
 		}
@@ -45,26 +43,28 @@
 	if(switch_queue_size(cdrqueue) > 0)
 		process_records();
 	
-	switch_channel_t *channel = 0;
+	switch_mod_cdr_newchannel_t *newchannel = new switch_mod_cdr_newchannel_t;
+	memset(newchannel,0,sizeof(*newchannel));
 	
 	BaseRegistry& registry(BaseRegistry::get());
 	for(BaseRegistry::iterator it = registry.begin(); it != registry.end(); ++it)
 	{
 		basecdr_creator func = *it;
-		BaseCDR* _ptr = func(channel);
+		BaseCDR* _ptr = func(newchannel);
 		std::auto_ptr<BaseCDR> ptr(_ptr);
 		ptr->disconnect();
 	}
 		
-	switch_console_printf(SWITCH_CHANNEL_CONSOLE, "mod_cdr shutdown gracefully.");
+	switch_console_printf(SWITCH_CHANNEL_LOG, "mod_cdr shutdown gracefully.");
+	delete newchannel;
 }
 
 void CDRContainer::add_cdr(switch_channel_t *channel)
 {
 	switch_mod_cdr_newchannel_t *newchannel = new switch_mod_cdr_newchannel_t;
-	memset(0,newchannel,sizeof(*newchannel));
+	memset(newchannel,0,sizeof(*newchannel));
 	
-	newchannel->timetable = switch_channel_get_timetables(channel);
+	newchannel->timetable = switch_channel_get_timetable(channel);
 	newchannel->callerextension = switch_channel_get_caller_extension(channel);
 	newchannel->callerprofile = switch_channel_get_caller_profile(channel);
 	newchannel->originateprofile = switch_channel_get_originator_caller_profile(channel);	
@@ -82,22 +82,22 @@
 		if(newchannel->originateprofile != 0 )
 		{
 			BaseCDR* newloggerobject = func(newchannel);
-			switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding a new logger object to the queue.\n");
+			switch_console_printf(SWITCH_CHANNEL_LOG, "Adding a new logger object to the queue.\n");
 			switch_queue_push(cdrqueue,newloggerobject);
 			
 			if(newchannel->timetable->next != 0)
 			{
-				newchannel->originateprofile = switch_channel_get_originatee_profile(channel);
+				newchannel->originateprofile = switch_channel_get_originatee_caller_profile(channel);
 				newchannel->originate = 1;
 			}	
 		}
 		else
 		{
-			newchannel->originateprofile = switch_channel_get_originatee_profile(channel);
+			newchannel->originateprofile = switch_channel_get_originatee_caller_profile(channel);
 			newchannel->originate = 1;
 			
 			BaseCDR* newloggerobject = func(newchannel);
-			switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding a new logger object to the queue.\n");
+			switch_console_printf(SWITCH_CHANNEL_LOG, "Adding a new logger object to the queue.\n");
 			switch_queue_push(cdrqueue,newloggerobject);
 		}
 		
@@ -109,7 +109,7 @@
 			newchannel->originateprofile = newchannel->originateprofile->next;
 			
 			BaseCDR* newloggerobject = func(newchannel);
-			switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding a new logger object to the queue.\n");
+			switch_console_printf(SWITCH_CHANNEL_LOG, "Adding a new logger object to the queue.\n");
 			switch_queue_push(cdrqueue,newloggerobject);
 		}
 	}

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.h
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.h	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.h	Mon Jun 12 21:54:36 2006
@@ -34,7 +34,7 @@
 class CDRContainer {
 	public:
 		CDRContainer();
-		CDRContainer(switch_memory_pool *module_pool);
+		CDRContainer(switch_memory_pool_t *module_pool);
 		~CDRContainer();
 		void add_cdr(switch_channel_t *channel);
 		void process_records();

Modified: freeswitch/branches/mishehu/src/switch_channel.c
==============================================================================
--- freeswitch/branches/mishehu/src/switch_channel.c	(original)
+++ freeswitch/branches/mishehu/src/switch_channel.c	Mon Jun 12 21:54:36 2006
@@ -292,6 +292,11 @@
 	return switch_core_hash_find(channel->variables, varname);
 }
 
+SWITCH_DECLARE(switch_hash_index_t *) switch_channel_variable_first(switch_channel_t *channel, switch_memory_pool_t *pool)
+{
+	return switch_hash_first(pool, channel->variables);
+}
+
 SWITCH_DECLARE(switch_status_t) switch_channel_set_private(switch_channel_t *channel, void *private_info)
 {
 	assert(channel != NULL);



More information about the Freeswitch-svn mailing list