[Freeswitch-svn] [commit] r1877 - in freeswitch/branches/cypromis/trunk: . conf src src/include src/mod/applications/mod_dptools src/mod/codecs/mod_speex

Freeswitch SVN cypromis at freeswitch.org
Fri Jul 14 09:45:12 EDT 2006


Author: cypromis
Date: Fri Jul 14 09:45:10 2006
New Revision: 1877

Added:
   freeswitch/branches/cypromis/trunk/src/mod/applications/mod_dptools/
   freeswitch/branches/cypromis/trunk/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/branches/cypromis/trunk/src/mod/applications/mod_dptools/mod_dptools.vcproj
Modified:
   freeswitch/branches/cypromis/trunk/   (props changed)
   freeswitch/branches/cypromis/trunk/conf/freeswitch.xml
   freeswitch/branches/cypromis/trunk/modules.conf.in
   freeswitch/branches/cypromis/trunk/src/include/switch.h
   freeswitch/branches/cypromis/trunk/src/include/switch_ivr.h
   freeswitch/branches/cypromis/trunk/src/mod/codecs/mod_speex/mod_speex.c
   freeswitch/branches/cypromis/trunk/src/switch_channel.c
   freeswitch/branches/cypromis/trunk/src/switch_core.c
   freeswitch/branches/cypromis/trunk/src/switch_ivr.c

Log:
merge to trunk 
r11632 at free (orig r1203):  michal | 2006-07-13 10:42:34 +0200
 upgrade to trunk
  r11627 at free (orig r1857):  anthm | 2006-07-13 03:06:06 +0200
  fix sql stmts
 
 r11655 at free (orig r1204):  michal | 2006-07-14 13:46:03 +0200
 merge to trunk 
 r11635 at free (orig r1864):  anthm | 2006-07-13 15:20:20 +0200
  add mod_dptools, for set variable and sleep from the dialplan
  r11638 at free (orig r1867):  anthm | 2006-07-13 19:58:28 +0200
  add effective callerid variables
  r11642 at free (orig r1871):  anthm | 2006-07-14 00:14:52 +0200
  tweak speex
  r11647 at free (orig r1876):  anthm | 2006-07-14 14:17:01 +0200
  dox
 


Modified: freeswitch/branches/cypromis/trunk/conf/freeswitch.xml
==============================================================================
--- freeswitch/branches/cypromis/trunk/conf/freeswitch.xml	(original)
+++ freeswitch/branches/cypromis/trunk/conf/freeswitch.xml	Fri Jul 14 09:45:10 2006
@@ -36,6 +36,7 @@
         <!-- Applications -->
         <load module="mod_bridgecall"/>
         <load module="mod_echo"/>
+        <load module="mod_dptools"/>
         <!-- <load module="mod_ivrtest"/> -->
         <load module="mod_playback"/>
         <load module="mod_commands"/>

Modified: freeswitch/branches/cypromis/trunk/modules.conf.in
==============================================================================
--- freeswitch/branches/cypromis/trunk/modules.conf.in	(original)
+++ freeswitch/branches/cypromis/trunk/modules.conf.in	Fri Jul 14 09:45:10 2006
@@ -1,5 +1,6 @@
 loggers/mod_console
 loggers/mod_syslog
+applications/mod_dptools
 applications/mod_commands
 applications/mod_conference
 applications/mod_bridgecall

Modified: freeswitch/branches/cypromis/trunk/src/include/switch.h
==============================================================================
--- freeswitch/branches/cypromis/trunk/src/include/switch.h	(original)
+++ freeswitch/branches/cypromis/trunk/src/include/switch.h	Fri Jul 14 09:45:10 2006
@@ -100,19 +100,19 @@
  *
  *	Additionally, the experimental external modules make use of several external modules:
  *
- *	mod_Exosip:
+ *	mod_exosip:
  *		- eXoSIP (http://savannah.nongnu.org/projects/exosip/)
  *
- *	mod_iaxchan:
+ *	mod_iax:
  *		- libiax2 (forked from http://iaxclient.sourceforge.net/)
  *
- *	mod_speexcodec
+ *	mod_speex
  *		- libspeex (http://www.speex.org/)
  *
  *	mod_portaudio
  *		- portaudio (http://www.portaudio.com/)
  *
- *	mod_woomerachan
+ *	mod_woomera
  *		- openh323/woomera (http://www.voxgratia.org/)
  *
  *	mod_xmpp_event

Modified: freeswitch/branches/cypromis/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/branches/cypromis/trunk/src/include/switch_ivr.h	(original)
+++ freeswitch/branches/cypromis/trunk/src/include/switch_ivr.h	Fri Jul 14 09:45:10 2006
@@ -50,6 +50,15 @@
  * @{
  */
 
+
+/*!
+  \brief Wait for time to pass for a specified number of milliseconds
+  \param session the session to wait for.
+  \param ms the number of milliseconds
+  \return SWITCH_STATUS_SUCCESS if the channel is still up
+*/
+SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms);
+
 /*!
   \brief Wait for DTMF digits calling a pluggable callback function when digits are collected.
   \param session the session to read.

Added: freeswitch/branches/cypromis/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- (empty file)
+++ freeswitch/branches/cypromis/trunk/src/mod/applications/mod_dptools/mod_dptools.c	Fri Jul 14 09:45:10 2006
@@ -0,0 +1,111 @@
+/* 
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005/2006, Anthony Minessale II <anthmct at yahoo.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * Anthony Minessale II <anthmct at yahoo.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * 
+ * Anthony Minessale II <anthmct at yahoo.com>
+ *
+ *
+ * mod_dptools.c -- Raw Audio File Streaming Application Module
+ *
+ */
+#include <switch.h>
+
+static const char modname[] = "mod_dptools";
+
+
+static void sleep_function(switch_core_session_t *session, char *data)
+{
+
+	if (switch_strlen_zero(data)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No timeout specified.\n");
+	} else {
+		uint32_t ms = atoi(data);
+		switch_ivr_sleep(session, ms);
+	}
+}
+
+static void set_function(switch_core_session_t *session, char *data)
+{
+	switch_channel_t *channel;
+	char *var, *val = NULL;
+
+	channel = switch_core_session_get_channel(session);
+    assert(channel != NULL);
+
+	if (switch_strlen_zero(data)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
+	} else {
+		var = switch_core_session_strdup(session, data);
+		val = strchr(var, '=');
+
+		if (val) {
+			*val++ = '\0';
+			if (!strcmp(val, "_UNDEF_")) {
+				val = NULL;
+			}
+		}
+		
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SET [%s]=[%s]\n", var, val ? val : "UNDEF");
+		switch_channel_set_variable(channel, var, val);
+	}
+}
+
+static const switch_application_interface_t set_application_interface = {
+	/*.interface_name */ "set",
+	/*.application_function */ set_function
+};
+
+static const switch_application_interface_t sleep_application_interface = {
+	/*.interface_name */ "sleep",
+	/*.application_function */ sleep_function,
+	NULL,NULL,NULL,
+	&set_application_interface
+};
+
+static const switch_loadable_module_interface_t mod_dptools_module_interface = {
+	/*.module_name = */ modname,
+	/*.endpoint_interface = */ NULL,
+	/*.timer_interface = */ NULL,
+	/*.dialplan_interface = */ NULL,
+	/*.codec_interface = */ NULL,
+	/*.application_interface */ &sleep_application_interface
+};
+
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+{
+
+	/* connect my internal structure to the blank pointer passed to me */
+	*module_interface = &mod_dptools_module_interface;
+
+
+	/* indicate that the module should continue to be loaded */
+	return SWITCH_STATUS_SUCCESS;
+}
+
+/* 'switch_module_runtime' will start up in a thread by itself just by having it exist 
+if it returns anything but SWITCH_STATUS_TERM it will be called again automaticly
+*/
+
+
+//switch_status_t switch_module_runtime(void)

Added: freeswitch/branches/cypromis/trunk/src/mod/applications/mod_dptools/mod_dptools.vcproj
==============================================================================
--- (empty file)
+++ freeswitch/branches/cypromis/trunk/src/mod/applications/mod_dptools/mod_dptools.vcproj	Fri Jul 14 09:45:10 2006
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="mod_dptools"
+	ProjectGUID="{78100236-7CEA-4948-96CC-E8ED3160329C}"
+	RootNamespace="mod_dptools"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="Debug"
+			IntermediateDirectory="Debug"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				UsePrecompiledHeader="0"
+				WarningLevel="4"
+				WarnAsError="true"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dptools.dll"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)/mod_dptools.pdb"
+				SubSystem="2"
+				ImportLibrary="$(OutDir)/mod_dptools.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="Release"
+			IntermediateDirectory="Release"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
+				RuntimeLibrary="0"
+				UsePrecompiledHeader="0"
+				WarningLevel="4"
+				WarnAsError="true"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dptools.dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				ImportLibrary="$(OutDir)/mod_dptools.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath=".\mod_dptools.c"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

Modified: freeswitch/branches/cypromis/trunk/src/mod/codecs/mod_speex/mod_speex.c
==============================================================================
--- freeswitch/branches/cypromis/trunk/src/mod/codecs/mod_speex/mod_speex.c	(original)
+++ freeswitch/branches/cypromis/trunk/src/mod/codecs/mod_speex/mod_speex.c	Fri Jul 14 09:45:10 2006
@@ -269,7 +269,7 @@
 /* Registration */
 static const switch_codec_implementation_t speex_32k_implementation = {
 	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
-	/*.ianacode */ 98,
+	/*.ianacode */ 102,
 	/*.iananame */ "speex",
 	/*.samples_per_second */ 32000,
 	/*.bits_per_second */ 512000,
@@ -288,7 +288,7 @@
 
 static const switch_codec_implementation_t speex_16k_implementation = {
 	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
-	/*.ianacode */ 98,
+	/*.ianacode */ 100,
 	/*.iananame */ "speex",
 	/*.samples_per_second */ 16000,
 	/*.bits_per_second */ 256000,

Modified: freeswitch/branches/cypromis/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/branches/cypromis/trunk/src/switch_channel.c	(original)
+++ freeswitch/branches/cypromis/trunk/src/switch_channel.c	Fri Jul 14 09:45:10 2006
@@ -339,11 +339,18 @@
 SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *channel, char *varname, char *value)
 {
 	assert(channel != NULL);
-	switch_core_hash_delete(channel->variables, varname);
 
-	switch_core_hash_insert_dup(channel->variables, varname, switch_core_session_strdup(channel->session, value));
+	if (varname) {
+		switch_core_hash_delete(channel->variables, varname);
+		if (value) {
+			switch_core_hash_insert_dup(channel->variables, varname, switch_core_session_strdup(channel->session, value));
+		} else {
+			switch_core_hash_delete(channel->variables, varname);
+		}
+		return SWITCH_STATUS_SUCCESS;
+	}
 
-	return SWITCH_STATUS_SUCCESS;
+	return SWITCH_STATUS_FALSE;
 }
 
 SWITCH_DECLARE(int) switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flags)

Modified: freeswitch/branches/cypromis/trunk/src/switch_core.c
==============================================================================
--- freeswitch/branches/cypromis/trunk/src/switch_core.c	(original)
+++ freeswitch/branches/cypromis/trunk/src/switch_core.c	Fri Jul 14 09:45:10 2006
@@ -965,6 +965,8 @@
 	switch_io_event_hook_outgoing_channel_t *ptr;
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	const switch_endpoint_interface_t *endpoint_interface;
+	switch_channel_t *channel = NULL;
+	switch_caller_profile_t *outgoing_profile = caller_profile;
 
 	if ((endpoint_interface = switch_loadable_module_get_endpoint_interface(endpoint_name)) == 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not locate channel type %s\n", endpoint_name);
@@ -972,9 +974,36 @@
 	}
 
 	if (endpoint_interface->io_routines->outgoing_channel) {
-		if ((status =
-			 endpoint_interface->io_routines->outgoing_channel(session, caller_profile,
-															   new_session, pool)) == SWITCH_STATUS_SUCCESS) {
+		if (session) {
+			char *ecaller_id_name = NULL, *ecaller_id_number = NULL;
+			channel = switch_core_session_get_channel(session);
+			
+			ecaller_id_name = switch_channel_get_variable(channel, "effective_caller_id_name");
+			ecaller_id_number = switch_channel_get_variable(channel, "effective_caller_id_number");
+			
+			if (ecaller_id_name || ecaller_id_number) {
+				if (caller_profile) {
+					outgoing_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
+																 caller_profile->username,
+																 caller_profile->dialplan,
+																 ecaller_id_name ? ecaller_id_name : caller_profile->caller_id_name,
+																 ecaller_id_number ? ecaller_id_number : caller_profile->caller_id_number,
+																 caller_profile->network_addr,
+																 caller_profile->ani,
+																 caller_profile->ani2, 
+																 caller_profile->rdnis,
+																 caller_profile->source,
+																 caller_profile->context,
+																 caller_profile->destination_number);
+					
+				}
+			}
+		}
+		
+		if ((status = endpoint_interface->io_routines->outgoing_channel(session,
+																		outgoing_profile,
+																		new_session,
+																		pool)) == SWITCH_STATUS_SUCCESS) {
 			if (session) {
 				for (ptr = session->event_hooks.outgoing_channel; ptr; ptr = ptr->next) {
 					if ((status = ptr->outgoing_channel(session, caller_profile, *new_session)) != SWITCH_STATUS_SUCCESS) {
@@ -985,13 +1014,16 @@
 		} else {
 			return status;
 		}
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not locate outgoing channel interface for %s\n", endpoint_name);
+		return SWITCH_STATUS_FALSE;
 	}
 
 	if (*new_session) {
 		switch_caller_profile_t *profile = NULL, *peer_profile = NULL, *cloned_profile = NULL;
-		switch_channel_t *channel = NULL, *peer_channel = NULL;
+		switch_channel_t *peer_channel = NULL;
 
-		if (session && (channel = switch_core_session_get_channel(session)) != 0) {
+		if (session && channel) {
 			profile = switch_channel_get_caller_profile(channel);
 		}
 		if ((peer_channel = switch_core_session_get_channel(*new_session)) != 0) {
@@ -2680,7 +2712,7 @@
 				if (switch_core_db_persistant_execute(runtime.event_db, sql, 25) != SWITCH_STATUS_SUCCESS) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL exec error! [%s]\n", sql);
 				}
-				free(sql);
+				switch_core_db_free(sql);
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "SQL thread ending\n");
 				break;
@@ -2727,33 +2759,26 @@
 
 static void core_event_handler(switch_event_t *event)
 {
-	char buf[1024];
 	char *sql = NULL;
 
-
-
 	switch (event->event_id) {
-
 	case SWITCH_EVENT_CHANNEL_DESTROY:
-		snprintf(buf, sizeof(buf), "delete from channels where uuid='%s'", switch_event_get_header(event, "unique-id"));
-		sql = buf;
+		switch_core_db_mprintf("delete from channels where uuid='%s'", switch_event_get_header(event, "unique-id"));
 		break;
 	case SWITCH_EVENT_CHANNEL_CREATE:
-		snprintf(buf, sizeof(buf), "insert into channels (uuid,created,name,state) values('%s','%s','%s','%s')",
-				 switch_event_get_header(event, "unique-id"),
-				 switch_event_get_header(event, "event-date-local"),
-				 switch_event_get_header(event, "channel-name"),
-				 switch_event_get_header(event, "channel-state")
-				 );
-		sql = buf;
+		sql = switch_core_db_mprintf("insert into channels (uuid,created,name,state) values('%q','%q','%q','%q')",
+									 switch_event_get_header(event, "unique-id"),
+									 switch_event_get_header(event, "event-date-local"),
+									 switch_event_get_header(event, "channel-name"),
+									 switch_event_get_header(event, "channel-state")
+									 );
 		break;
 	case SWITCH_EVENT_CHANNEL_EXECUTE:
-		snprintf(buf, sizeof(buf), "update channels set application='%s',application_data='%s' where uuid='%s'",
-				 switch_event_get_header(event, "application"),
-				 switch_event_get_header(event, "application-data"),
-				 switch_event_get_header(event, "unique-id")
-				 );
-		sql = buf;
+		sql = switch_core_db_mprintf("update channels set application='%q',application_data='%q' where uuid='%q'",
+									 switch_event_get_header(event, "application"),
+									 switch_event_get_header(event, "application-data"),
+									 switch_event_get_header(event, "unique-id")
+									 );
 		break;
 	case SWITCH_EVENT_CHANNEL_STATE:
 		if (event) {
@@ -2765,60 +2790,54 @@
 			case CS_DONE:
 				break;
 			case CS_RING:
-				snprintf(buf, sizeof(buf), "update channels set state='%s',cid_name='%s',cid_num='%s',ip_addr='%s',dest='%s'"
-						 "where uuid='%s'",
-						 switch_event_get_header(event, "channel-state"),
-						 switch_event_get_header(event, "caller-caller-id-name"),
-						 switch_event_get_header(event, "caller-caller-id-number"),
-						 switch_event_get_header(event, "caller-network-addr"),
-						 switch_event_get_header(event, "caller-destination-number"),
-						 switch_event_get_header(event, "unique-id")
-						 );
-				sql = buf;
+				sql = switch_core_db_mprintf("update channels set state='%s',cid_name='%q',cid_num='%q',ip_addr='%s',dest='%q'"
+											 "where uuid='%s'",
+											 switch_event_get_header(event, "channel-state"),
+											 switch_event_get_header(event, "caller-caller-id-name"),
+											 switch_event_get_header(event, "caller-caller-id-number"),
+											 switch_event_get_header(event, "caller-network-addr"),
+											 switch_event_get_header(event, "caller-destination-number"),
+											 switch_event_get_header(event, "unique-id")
+											 );
 				break;
 			default:
-				snprintf(buf, sizeof(buf), "update channels set state='%s' where uuid='%s'", 
-						 switch_event_get_header(event, "channel-state"),
-						 switch_event_get_header(event, "unique-id")
-						 );
-				sql = buf;
+				sql = switch_core_db_mprintf("update channels set state='%s' where uuid='%s'", 
+											 switch_event_get_header(event, "channel-state"),
+											 switch_event_get_header(event, "unique-id")
+											 );
 				break;
 			}
 		
 		}
 		break;
 	case SWITCH_EVENT_CHANNEL_BRIDGE:
-		snprintf(buf, sizeof(buf), "insert into calls values ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
-				 switch_event_get_header(event, "event-calling-function"),
-				 switch_event_get_header(event, "caller-caller-id-name"),
-				 switch_event_get_header(event, "caller-caller-id-number"),
-				 switch_event_get_header(event, "caller-destination-number"),
-				 switch_event_get_header(event, "caller-channel-name"),
-				 switch_event_get_header(event, "caller-unique-id"),
-				 switch_event_get_header(event, "originatee-caller-id-name"),
-				 switch_event_get_header(event, "originatee-caller-id-number"),
-				 switch_event_get_header(event, "originatee-destination-number"),
-				 switch_event_get_header(event, "originatee-channel-name"),
-				 switch_event_get_header(event, "originatee-unique-id")
-				 );
-		sql = buf;
+		sql = switch_core_db_mprintf("insert into calls values ('%s','%q','%q','%q','%q','%s','%q','%q','%q','%q','%s')",
+									 switch_event_get_header(event, "event-calling-function"),
+									 switch_event_get_header(event, "caller-caller-id-name"),
+									 switch_event_get_header(event, "caller-caller-id-number"),
+									 switch_event_get_header(event, "caller-destination-number"),
+									 switch_event_get_header(event, "caller-channel-name"),
+									 switch_event_get_header(event, "caller-unique-id"),
+									 switch_event_get_header(event, "originatee-caller-id-name"),
+									 switch_event_get_header(event, "originatee-caller-id-number"),
+									 switch_event_get_header(event, "originatee-destination-number"),
+									 switch_event_get_header(event, "originatee-channel-name"),
+									 switch_event_get_header(event, "originatee-unique-id")
+									 );
 		break;
 	case SWITCH_EVENT_CHANNEL_UNBRIDGE:
-		snprintf(buf, sizeof(buf), "delete from calls where caller_uuid='%s'", switch_event_get_header(event, "caller-unique-id"));
-		sql = buf;
+		sql = switch_core_db_mprintf("delete from calls where caller_uuid='%s'", switch_event_get_header(event, "caller-unique-id"));
 		break;
 	case SWITCH_EVENT_SHUTDOWN:
-		snprintf(buf, sizeof(buf), "delete from channels;delete from interfaces;delete from calls");
-		sql = buf;
+		sql = switch_core_db_mprintf("delete from channels;delete from interfaces;delete from calls");
 		break;
 	case SWITCH_EVENT_LOG:
 		return;
 	case SWITCH_EVENT_MODULE_LOAD:
-		snprintf(buf, sizeof(buf), "insert into interfaces (type,name) values('%s','%s')",
-				 switch_event_get_header(event, "type"),
-				 switch_event_get_header(event, "name")
-				 );
-		sql = buf;
+		sql = switch_core_db_mprintf("insert into interfaces (type,name) values('%q','%q')",
+									 switch_event_get_header(event, "type"),
+									 switch_event_get_header(event, "name")
+									 );
 		break;
 	default:
 		//buf[0] = '\0';
@@ -2828,7 +2847,8 @@
 	}
 
 	if (sql) {
-		switch_queue_push(runtime.sql_queue, strdup(sql));
+		switch_queue_push(runtime.sql_queue, sql);
+		sql = NULL;
 	}
 }
 

Modified: freeswitch/branches/cypromis/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/branches/cypromis/trunk/src/switch_ivr.c	(original)
+++ freeswitch/branches/cypromis/trunk/src/switch_ivr.c	Fri Jul 14 09:45:10 2006
@@ -34,6 +34,46 @@
 
 static const switch_state_handler_table_t audio_bridge_peer_state_handlers;
 
+SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms)
+{
+	switch_channel_t *channel;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_time_t start, now, done = switch_time_now() + (ms * 1000);
+	switch_frame_t *read_frame;
+	int32_t left, elapsed;
+
+	channel = switch_core_session_get_channel(session);
+    assert(channel != NULL);
+
+	start = switch_time_now();
+
+	for(;;) {
+		now = switch_time_now();
+		elapsed = (int32_t)((now - start) / 1000);
+		left = ms - elapsed;
+
+		if (!switch_channel_ready(channel)) {
+			status = SWITCH_STATUS_FALSE;
+			break;
+		}
+
+		if (now > done || left <= 0) {
+			break;
+		}
+
+		if (switch_channel_test_flag(channel, CF_SERVICE)) {
+			switch_yield(1000);
+		} else {
+			status = switch_core_session_read_frame(session, &read_frame, left, 0);
+			if (!SWITCH_READ_ACCEPTABLE(status)) {
+				break;
+			}
+		}
+	}
+	
+
+	return status;
+}
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session,
 																 switch_input_callback_function_t input_callback,



More information about the Freeswitch-svn mailing list