[Freeswitch-branches] [commit] r5478 - in freeswitch/branches/greenlizard: . build build/config conf scripts/contrib/trixter scripts/socket src src/include src/mod/applications/mod_commands src/mod/applications/mod_conference src/mod/applications/mod_dptools src/mod/endpoints/mod_dingaling src/mod/endpoints/mod_portaudio src/mod/endpoints/mod_sofia src/mod/event_handlers/mod_cdr src/mod/event_handlers/mod_event_socket src/mod/event_handlers/mod_radius_cdr src/mod/formats/mod_local_stream src/mod/languages/mod_mono src/mod/languages/mod_python src/mod/languages/mod_spidermonkey src/mod/languages/mod_spidermonkey_core_db src/mod/languages/mod_spidermonkey_odbc src/mod/timers/mod_softtimer src/mod/xml_int/mod_xml_cdr

Freeswitch SVN greenlizard at freeswitch.org
Wed Jun 27 13:11:16 EDT 2007


Author: greenlizard
Date: Wed Jun 27 13:11:14 2007
New Revision: 5478

Added:
   freeswitch/branches/greenlizard/conf/xml_cdr.conf.xml
      - copied unchanged from r5476, /freeswitch/trunk/conf/xml_cdr.conf.xml
   freeswitch/branches/greenlizard/scripts/contrib/trixter/regexptest.pl
      - copied unchanged from r5476, /freeswitch/trunk/scripts/contrib/trixter/regexptest.pl
   freeswitch/branches/greenlizard/src/mod/formats/mod_local_stream/
      - copied from r5476, /freeswitch/trunk/src/mod/formats/mod_local_stream/
   freeswitch/branches/greenlizard/src/mod/formats/mod_local_stream/Makefile
      - copied unchanged from r5476, /freeswitch/trunk/src/mod/formats/mod_local_stream/Makefile
   freeswitch/branches/greenlizard/src/mod/formats/mod_local_stream/mod_local_stream.c
      - copied unchanged from r5476, /freeswitch/trunk/src/mod/formats/mod_local_stream/mod_local_stream.c
   freeswitch/branches/greenlizard/src/mod/formats/mod_local_stream/mod_local_stream.vcproj
      - copied unchanged from r5476, /freeswitch/trunk/src/mod/formats/mod_local_stream/mod_local_stream.vcproj
Modified:
   freeswitch/branches/greenlizard/Freeswitch.sln
   freeswitch/branches/greenlizard/build/config/config.sub
   freeswitch/branches/greenlizard/build/modules.conf.in
   freeswitch/branches/greenlizard/conf/freeswitch.xml
   freeswitch/branches/greenlizard/conf/modules.conf.xml
   freeswitch/branches/greenlizard/scripts/contrib/trixter/conf-dtmf.pl
   freeswitch/branches/greenlizard/scripts/socket/sock.pl
   freeswitch/branches/greenlizard/src/include/switch_apr.h
   freeswitch/branches/greenlizard/src/include/switch_types.h
   freeswitch/branches/greenlizard/src/mod/applications/mod_commands/mod_commands.c
   freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_dingaling/mod_dingaling.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_portaudio/pablio.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c
   freeswitch/branches/greenlizard/src/mod/event_handlers/mod_cdr/basecdr.cpp
   freeswitch/branches/greenlizard/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
   freeswitch/branches/greenlizard/src/mod/event_handlers/mod_radius_cdr/Makefile.am
   freeswitch/branches/greenlizard/src/mod/languages/mod_mono/mod_mono.c
   freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python.i
   freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
   freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c
   freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c
   freeswitch/branches/greenlizard/src/mod/timers/mod_softtimer/mod_softtimer.c
   freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
   freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.vcproj
   freeswitch/branches/greenlizard/src/switch_apr.c
   freeswitch/branches/greenlizard/src/switch_channel.c
   freeswitch/branches/greenlizard/src/switch_core_session.c
   freeswitch/branches/greenlizard/src/switch_core_state_machine.c
   freeswitch/branches/greenlizard/src/switch_event.c
   freeswitch/branches/greenlizard/src/switch_ivr.c
   freeswitch/branches/greenlizard/src/switch_ivr_async.c
   freeswitch/branches/greenlizard/src/switch_ivr_bridge.c
   freeswitch/branches/greenlizard/src/switch_ivr_play_say.c
   freeswitch/branches/greenlizard/src/switch_rtp.c

Log:
merge trunk revision 5440 to 5476

Modified: freeswitch/branches/greenlizard/Freeswitch.sln
==============================================================================
--- freeswitch/branches/greenlizard/Freeswitch.sln	(original)
+++ freeswitch/branches/greenlizard/Freeswitch.sln	Wed Jun 27 13:11:14 2007
@@ -434,8 +434,9 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_xml_cdr", "src\mod\xml_int\mod_xml_cdr\mod_xml_cdr.vcproj", "{08DAD348-9E0A-4A2E-97F1-F1E7E24A7836}"
 	ProjectSection(ProjectDependencies) = postProject
-		{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
 		{F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+		{87EE9DA4-DE1E-4448-8324-183C98DCA588} = {87EE9DA4-DE1E-4448-8324-183C98DCA588}
+		{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
 	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_amr", "src\mod\codecs\mod_amr\mod_amr.vcproj", "{8DEB383C-4091-4F42-A56F-C9E46D552D79}"
@@ -472,6 +473,7 @@
 		conf\syslog.conf.xml = conf\syslog.conf.xml
 		conf\wanpipe.conf.xml = conf\wanpipe.conf.xml
 		conf\woomera.conf.xml = conf\woomera.conf.xml
+		conf\xml_cdr.conf.xml = conf\xml_cdr.conf.xml
 		conf\xml_curl.conf.xml = conf\xml_curl.conf.xml
 		conf\xml_rpc.conf.xml = conf\xml_rpc.conf.xml
 		conf\xmpp_event.conf.xml = conf\xmpp_event.conf.xml
@@ -505,6 +507,7 @@
 		release\conf\syslog.conf.xml = release\conf\syslog.conf.xml
 		release\conf\wanpipe.conf.xml = release\conf\wanpipe.conf.xml
 		release\conf\woomera.conf.xml = release\conf\woomera.conf.xml
+		release\conf\xml_cdr.conf.xml = release\conf\xml_cdr.conf.xml
 		release\conf\xml_curl.conf.xml = release\conf\xml_curl.conf.xml
 		release\conf\xml_rpc.conf.xml = release\conf\xml_rpc.conf.xml
 		release\conf\xmpp_event.conf.xml = release\conf\xmpp_event.conf.xml
@@ -538,6 +541,7 @@
 		debug\conf\syslog.conf.xml = debug\conf\syslog.conf.xml
 		debug\conf\wanpipe.conf.xml = debug\conf\wanpipe.conf.xml
 		debug\conf\woomera.conf.xml = debug\conf\woomera.conf.xml
+		debug\conf\xml_cdr.conf.xml = debug\conf\xml_cdr.conf.xml
 		debug\conf\xml_curl.conf.xml = debug\conf\xml_curl.conf.xml
 		debug\conf\xml_rpc.conf.xml = debug\conf\xml_rpc.conf.xml
 		debug\conf\xmpp_event.conf.xml = debug\conf\xmpp_event.conf.xml
@@ -582,6 +586,11 @@
 		{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
 	EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_local_stream", "src\mod\formats\mod_local_stream\mod_local_stream.vcproj", "{2CA40887-1622-46A1-A7F9-17FD7E7E545B}"
+	ProjectSection(ProjectDependencies) = postProject
+		{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+	EndProjectSection
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Win32 = Debug|Win32
@@ -1086,6 +1095,12 @@
 		{3850D93A-5F24-4922-BC1C-74D08C37C256}.Release|Win32.ActiveCfg = Release|Win32
 		{3850D93A-5F24-4922-BC1C-74D08C37C256}.Release|Win32.Build.0 = Release|Win32
 		{3850D93A-5F24-4922-BC1C-74D08C37C256}.Release|x64.ActiveCfg = Release|Win32
+		{2CA40887-1622-46A1-A7F9-17FD7E7E545B}.Debug|Win32.ActiveCfg = Debug|Win32
+		{2CA40887-1622-46A1-A7F9-17FD7E7E545B}.Debug|Win32.Build.0 = Debug|Win32
+		{2CA40887-1622-46A1-A7F9-17FD7E7E545B}.Debug|x64.ActiveCfg = Debug|Win32
+		{2CA40887-1622-46A1-A7F9-17FD7E7E545B}.Release|Win32.ActiveCfg = Release|Win32
+		{2CA40887-1622-46A1-A7F9-17FD7E7E545B}.Release|Win32.Build.0 = Release|Win32
+		{2CA40887-1622-46A1-A7F9-17FD7E7E545B}.Release|x64.ActiveCfg = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -1110,6 +1125,7 @@
 		{3D1EED36-A510-4EDB-B4D9-4E0F4A5EC2A8} = {9ADF1E48-2F5C-4ED7-A893-596259FABFE0}
 		{AFAC0568-7548-42D5-9F6A-8D3400A1E4F6} = {A5A27244-AD24-46E5-B01B-840CD296C91D}
 		{9254C4B0-6F60-42B6-BB3A-36D63FC001C7} = {A5A27244-AD24-46E5-B01B-840CD296C91D}
+		{2CA40887-1622-46A1-A7F9-17FD7E7E545B} = {A5A27244-AD24-46E5-B01B-840CD296C91D}
 		{5FD31A25-5D83-4794-8BEE-904DAD84CE71} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C}
 		{FE3540C5-3303-46E0-A69E-D92F775687F1} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C}
 		{3A5B9131-F20C-4A85-9447-6C1610941CEE} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C}

Modified: freeswitch/branches/greenlizard/build/config/config.sub
==============================================================================
--- freeswitch/branches/greenlizard/build/config/config.sub	(original)
+++ freeswitch/branches/greenlizard/build/config/config.sub	Wed Jun 27 13:11:14 2007
@@ -226,6 +226,7 @@
 	# Recognize the basic CPU types without company name.
 	# Some are omitted here because they have special meanings below.
 	1750a | 580 \
+	| bfin \
 	| a29k \
 	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
 	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
@@ -292,6 +293,7 @@
 		;;
 	# Recognize the basic CPU types with company name.
 	580-* \
+	| bfin-* \
 	| a29k-* \
 	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
 	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \

Modified: freeswitch/branches/greenlizard/build/modules.conf.in
==============================================================================
--- freeswitch/branches/greenlizard/build/modules.conf.in	(original)
+++ freeswitch/branches/greenlizard/build/modules.conf.in	Wed Jun 27 13:11:14 2007
@@ -38,6 +38,7 @@
 formats/mod_native_file
 formats/mod_sndfile
 #formats/mod_shout
+#formats/mod_local_stream
 #languages/mod_perl
 #languages/mod_python
 #languages/mod_spidermonkey

Modified: freeswitch/branches/greenlizard/conf/freeswitch.xml
==============================================================================
--- freeswitch/branches/greenlizard/conf/freeswitch.xml	(original)
+++ freeswitch/branches/greenlizard/conf/freeswitch.xml	Wed Jun 27 13:11:14 2007
@@ -74,6 +74,7 @@
 
     <!-- XML Interfaces --> 
     <!--#include "xml_rpc.conf.xml"-->
+    <!--#include "xml_cdr.conf.xml"-->
     <!--#include "xml_curl.conf.xml"-->
     <!-- none for mod_xml_cdr -->
 
@@ -124,6 +125,7 @@
     <!-- Say -->
     <!-- none for mod_say_en -->
     <!--#include "mod_cdr.conf.xml"-->
+    <!--#include "mod_local_stream.conf.xml"-->
   </section>
   
   <section name="dialplan" description="Regex/XML Dialplan">

Modified: freeswitch/branches/greenlizard/conf/modules.conf.xml
==============================================================================
--- freeswitch/branches/greenlizard/conf/modules.conf.xml	(original)
+++ freeswitch/branches/greenlizard/conf/modules.conf.xml	Wed Jun 27 13:11:14 2007
@@ -53,6 +53,8 @@
     <load module="mod_native_file"/>
     <!--For icecast/mp3 streams/files-->
     <!--<load module="mod_shout"/>-->
+    <!--For local streams (play all the files in a directory)-->
+    <!--<load module="mod_local_stream"/>-->
 
     <!-- Timers -->
     <load module="mod_softtimer"/>

Modified: freeswitch/branches/greenlizard/scripts/contrib/trixter/conf-dtmf.pl
==============================================================================
--- freeswitch/branches/greenlizard/scripts/contrib/trixter/conf-dtmf.pl	(original)
+++ freeswitch/branches/greenlizard/scripts/contrib/trixter/conf-dtmf.pl	Wed Jun 27 13:11:14 2007
@@ -1,4 +1,5 @@
 #!/usr/bin/perl
+# -*- mode:cperl; tab-width:4; c-basic-offset:4; c-indent-level:4; indent-tabs-mode:nil;  -*-
 use FreeSWITCH::Client;
 use POSIX ':signal_h'; # used for alarm to ensure we get heartbeats
 use Data::Dumper; # used to print out myhash debug info
@@ -12,9 +13,9 @@
 
 # hash for music, default must be defined, if you define other entities then the conference name will be used to match against that
 my %soundfile = (
-		 'default' => '/sounds/fpm-calm-river.wav',
-		 '123'     => '/sounds/welcome.raw',
-	     );
+                 'default' => '/sounds/fpm-calm-river.wav',
+                 '123'     => '/sounds/welcome.raw',
+                );
 
 
 
@@ -25,31 +26,35 @@
 my $lastheartbeat;
 
 
-
 # this connects to the event socket
 sub es_connect()
-{
+  {
     print "Connecting to $host:$port\n";
-    $fs = init FreeSWITCH::Client {-password => $password, -host => $host, -port => $port};
-    if(defined $fs) {
-	$fs->sendmsg({'command' => 'event plain heartbeat CUSTOM conference::maintenence'});
-	$lastheartbeat = time;
+    eval {
+      $fs = init FreeSWITCH::Client {-password => $password, -host => $host, -port => $port};
+      if(defined $fs) {
+        $fs->sendmsg({'command' => 'event plain heartbeat CUSTOM conference::maintenence'});
+        $lastheartbeat = time;
+      }
+    } or do {
+      print "Error connecting - waiting for retry\n";
     }
-}
+
+  }
 
 
 sigaction SIGALRM, new POSIX::SigAction sub { 
-    if ($lastheartbeat < (time - $timeout)) {
+  if ($lastheartbeat < (time - $timeout)) {
 	print "Did not receive a heartbeat in the specified timeout\n";
 	if (defined $fs) {
-	    $fs->disconnect();
-	    undef $fs;
+      $fs->disconnect();
+      undef $fs;
 	}
 	es_connect();
-    }
-
-    # reset the alarm
-    alarm $timeout;
+  }
+  
+  # reset the alarm
+  alarm $timeout;
 } or die "Error setting SIGALRM handler: $!\n";
 
 
@@ -59,36 +64,37 @@
 
 while (1) {
     if(defined $fs) {
-	my $reply = $fs->readhash(undef);
-	if ($reply->{socketerror}) {
+      my $reply = $fs->readhash(undef);
+      if ($reply->{socketerror}) {
 	    es_connect();
-	}
+      }
       
-	if ($reply->{body}) {
+      if ($reply->{body}) {
 	    $myhash = $reply->{event};
-
+        
 	    if ($myhash->{'event-name'} eq "HEARTBEAT") {   ## Deal with heartbeats
-		$lastheartbeat = time;
-		print "Got a heartbeat\n";
-		
+          $lastheartbeat = time;
+          print "Got a heartbeat\n";
+          
 	    } elsif ($myhash->{'event-subclass'} eq "conference::maintenence") {   ## deal with Conference stuff
-		
-		if($myhash->{'action'} eq 'dtmf') {  ## DTMF event
+          
+          if($myhash->{'action'} eq 'dtmf') {  ## DTMF event
 		    print "conf: $myhash->{'conference-name'}\tmember: $myhash->{'member-id'}\tDTMF: $myhash->{'dtmf-key'}\n";
 		    if(defined $soundfile{$myhash->{'conference-name'}}) {
-			$fs->sendmsg({'command' => "api conference $myhash->{'conference-name'} play $soundfile{$myhash->{'conference-name'}}"});
+              $fs->sendmsg({'command' => "api conference $myhash->{'conference-name'} play $soundfile{$myhash->{'conference-name'}}"});
 		    } else {
-			$fs->sendmsg({'command' => "api conference $myhash->{'conference-name'} play $soundfile{'default'}"});
+              $fs->sendmsg({'command' => "api conference $myhash->{'conference-name'} play $soundfile{'default'}"});
 		    }
 		    
-		} else {  ## Just print out all other events
+          } else {  ## Just print out all other events
 		    print "conf: $myhash->{'conference-name'}\tmemid: $myhash->{'member-id'}\taction: $myhash->{'action'}\tCLID: $myhash->{'caller-caller-id-number'}\n";
-		}
+          }
 	    } else {  ## Unknown event
-		print Dumper $myhash;
-#	    print "$reply->{body}\n"; # print out what was sent, myhash is translated by Client.pm
+          print Dumper $myhash;
+          #	    print "$reply->{body}\n"; # print out what was sent, myhash is translated by Client.pm
 	    }
 	    
-	} 
+      } 
     }
 }
+

Modified: freeswitch/branches/greenlizard/scripts/socket/sock.pl
==============================================================================
--- freeswitch/branches/greenlizard/scripts/socket/sock.pl	(original)
+++ freeswitch/branches/greenlizard/scripts/socket/sock.pl	Wed Jun 27 13:11:14 2007
@@ -21,12 +21,12 @@
 
 $o = $fs->call_command("answer");
 #to turn on events when in async mode
-#$o = $fs->raw_command("myevents");
+$o = $fs->raw_command("myevents");
 $o = $fs->call_command("playback", "/ram/swimp.raw");
-$o = $fs->call_command("hangup");
+
 
 #comment exit in async mode
-exit;
+#exit;
 
 while(my $r = $fs->readhash(undef)) {
   if ($r->{socketerror}) {
@@ -36,7 +36,11 @@
   if ($r->{has_event}) {
     print Dumper $r->{event};
   }
-
+  if ($r->{event}->{'event-name'} !~ /execute/i) {
+    printf "wtf $data->{'unique-id'}\n";
+    $o = $fs->call_command("break");
+    $o = $fs->call_command("hangup");
+  }
 }
 
 $fs->disconnect();

Modified: freeswitch/branches/greenlizard/src/include/switch_apr.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_apr.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_apr.h	Wed Jun 27 13:11:14 2007
@@ -744,7 +744,7 @@
 
 SWITCH_DECLARE(switch_status_t) switch_dir_open(switch_dir_t **new_dir, const char *dirname, switch_memory_pool_t *pool);
 SWITCH_DECLARE(switch_status_t) switch_dir_close(switch_dir_t *thedir);
-SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir);
+SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *buf, switch_size_t len);
 
 /** @} */
 

Modified: freeswitch/branches/greenlizard/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_types.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_types.h	Wed Jun 27 13:11:14 2007
@@ -573,6 +573,7 @@
 CF_BROADCAST    = (1 << 20) - Channel is broadcasting
 CF_UNICAST      = (1 << 21) - Channel has a unicast connection
 CF_VIDEO		= (1 << 22) - Channel has video
+CF_EVENT_LOCK   = (1 << 23) - Don't parse events
 </pre>
  */
 
@@ -599,7 +600,8 @@
 	CF_BREAK = (1 << 19),
 	CF_BROADCAST = (1 << 20),
 	CF_UNICAST = (1 << 21),
-	CF_VIDEO = (1 << 22)
+	CF_VIDEO = (1 << 22),
+	CF_EVENT_LOCK = (1 << 23)
 } switch_channel_flag_t;
 
 
@@ -823,12 +825,14 @@
     SWITCH_EVENT_CHANNEL_ANSWER		- A channel has been answered
     SWITCH_EVENT_CHANNEL_HANGUP		- A channel has been hungup
     SWITCH_EVENT_CHANNEL_EXECUTE	- A channel has executed a module's application
+    SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE	- A channel has finshed executing a module's application
 	SWITCH_EVENT_CHANNEL_BRIDGE     - A channel has bridged to another channel
 	SWITCH_EVENT_CHANNEL_UNBRIDGE   - A channel has unbridged from another channel
     SWITCH_EVENT_CHANNEL_PROGRESS	- A channel has been parked
     SWITCH_EVENT_CHANNEL_OUTGOING	- A channel has been unparked
 	SWITCH_EVENT_CHANNEL_PARK 		- A channel has been parked
 	SWITCH_EVENT_CHANNEL_UNPARK 	- A channel has been unparked
+	SWITCH_EVENT_CHANNEL_APPLICATION- A channel has called and event from an application
     SWITCH_EVENT_API				- An API call has been executed
     SWITCH_EVENT_LOG				- A LOG event has been triggered
     SWITCH_EVENT_INBOUND_CHAN		- A new inbound channel has been created
@@ -872,12 +876,14 @@
 	SWITCH_EVENT_CHANNEL_ANSWER,
 	SWITCH_EVENT_CHANNEL_HANGUP,
 	SWITCH_EVENT_CHANNEL_EXECUTE,
+	SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE,
 	SWITCH_EVENT_CHANNEL_BRIDGE,
 	SWITCH_EVENT_CHANNEL_UNBRIDGE,
 	SWITCH_EVENT_CHANNEL_PROGRESS,
 	SWITCH_EVENT_CHANNEL_OUTGOING,
 	SWITCH_EVENT_CHANNEL_PARK,
 	SWITCH_EVENT_CHANNEL_UNPARK,
+	SWITCH_EVENT_CHANNEL_APPLICATION,
 	SWITCH_EVENT_API,
 	SWITCH_EVENT_LOG,
 	SWITCH_EVENT_INBOUND_CHAN,

Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_commands/mod_commands.c	Wed Jun 27 13:11:14 2007
@@ -715,6 +715,31 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
+#define BREAK_SYNTAX "<uuid>"
+SWITCH_STANDARD_API(break_function)
+{
+	switch_core_session_t *psession = NULL;
+
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (switch_strlen_zero(cmd)) {
+		stream->write_function(stream, "USAGE: %s\n", BREAK_SYNTAX);
+	} else {
+		if ((psession = switch_core_session_locate(cmd))) {
+			switch_channel_t *channel = switch_core_session_get_channel(psession);
+			switch_channel_set_flag(channel, CF_BREAK);
+			switch_core_session_rwunlock(psession);
+		} else {
+			stream->write_function(stream, "No Such Channel!\n");
+		}
+	}
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+
 #define PAUSE_SYNTAX "<uuid> <on|off>"
 SWITCH_STANDARD_API(pause_function)
 {
@@ -1254,6 +1279,7 @@
 	SWITCH_ADD_API(commands_api_interface, "load", "Load Module", load_function, LOAD_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "transfer", "Transfer Module", transfer_function, TRANSFER_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "pause", "Pause", pause_function, PAUSE_SYNTAX);
+	SWITCH_ADD_API(commands_api_interface, "break", "Break", break_function, BREAK_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "show", "Show", show_function, SHOW_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "status", "status", status_function, "");
 	SWITCH_ADD_API(commands_api_interface, "uuid_bridge", "uuid_bridge", uuid_bridge_function, UUID_SYNTAX);

Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c	Wed Jun 27 13:11:14 2007
@@ -1576,6 +1576,8 @@
 		switch_event_t *event;
 		caller_control_action_t *caller_action = NULL;
 
+		switch_mutex_lock(member->flag_mutex);
+
 		if (switch_core_session_dequeue_event(member->session, &event) == SWITCH_STATUS_SUCCESS) {
 			char *from = switch_event_get_header(event, "from");
 			char *to = switch_event_get_header(event, "to");
@@ -1649,7 +1651,6 @@
 
 		/* handle file and TTS frames */
 		if (member->fnode) {
-			switch_mutex_lock(member->flag_mutex);
 			/* if we are done, clean it up */
 			if (member->fnode->done) {
 				conference_file_node_t *fnode;
@@ -1707,7 +1708,6 @@
 					}
 				}
 			}
-			switch_mutex_unlock(member->flag_mutex);
 		} else {				/* send the conferecne frame to the call leg */
 			switch_buffer_t *use_buffer = NULL;
 			uint32_t mux_used = (uint32_t) switch_buffer_inuse(member->mux_buffer);
@@ -1770,6 +1770,7 @@
 				switch_core_timer_next(&timer);
 			}
 		}
+		switch_mutex_unlock(member->flag_mutex);
 	}							/* Rinse ... Repeat */
 
 	if (member->digit_stream != NULL) {
@@ -3229,12 +3230,13 @@
 			}
 
 			/* move the member from the old conference to the new one */
+			switch_mutex_lock(member->flag_mutex);
 			conference_del_member(conference, member);
 			conference_add_member(new_conference, member);
 			switch_mutex_unlock(new_conference->mutex);
-
+			switch_mutex_unlock(member->flag_mutex);
 			stream->write_function(stream, "OK Members sent to conference %s.\n", argv[2]);
-
+			
 			/* tell them what happened */
 			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
 				switch_channel_event_set_data(channel, event);

Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c	Wed Jun 27 13:11:14 2007
@@ -94,6 +94,14 @@
 	switch_channel_ring_ready(channel);
 }
 
+SWITCH_STANDARD_APP(break_function)
+{
+	switch_channel_t *channel;
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+	switch_channel_set_flag(channel, CF_BREAK);
+}
+
 SWITCH_STANDARD_APP(queue_dtmf_function)
 {
 	switch_channel_t *channel;
@@ -443,6 +451,53 @@
 
 }
 
+
+
+SWITCH_STANDARD_APP(event_function)
+{
+	switch_channel_t *channel;
+	switch_event_t *event;
+	char *argv[25];
+	int argc = 0;
+	char *lbuf;
+
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+
+	if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_APPLICATION) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_event_set_data(channel, event);
+		if (data && (lbuf = switch_core_session_strdup(session, data))
+			&& (argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+			int x = 0;
+
+			for (x = 0; x < argc; x++) {
+				char *p, *this = argv[x];
+				p = this;
+				while(*p == ' ') *p++ = '\0';
+				this = p;
+				
+				if (this) {
+					char *var = this, *val = NULL;
+					if ((val = strchr(var, '='))) {
+						p = val - 1;
+						*val++ = '\0';
+						while(*p == ' ') *p-- = '\0';
+						p = val;
+						while(*p == ' ') *p++ = '\0';
+						val = p;
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, var, "%s", val);
+					}
+				}
+
+			}
+		}
+		
+		switch_event_fire(&event);
+	}
+
+}
+
+
 SWITCH_STANDARD_APP(privacy_function)
 {
 	switch_channel_t *channel;
@@ -1082,10 +1137,12 @@
 	SWITCH_ADD_APP(app_interface, "hangup", "Hangup the call", "Hangup the call for a channel.", hangup_function, "[<cause>]", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "log", "Logs a channel varaible", LOG_LONG_DESC, log_function, "<varname>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "info", "Display Call Info", "Display Call Info", info_function, "", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "event", "Fire an event", "Fire an event", event_function, "", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "export", "Export a channel varaible across a bridge", EXPORT_LONG_DESC, export_function, "<varname>=<value>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "set", "Set a channel varaible", SET_LONG_DESC, set_function, "<varname>=<value>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "unset", "Unset a channel varaible", UNSET_LONG_DESC, unset_function, "<varname>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "ring_ready", "Indicate Ring_Ready", "Indicate Ring_Ready on a channel.", ring_ready_function, "", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "break", "Break", "Set the break flag.", break_function, "", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "detect_speech", "Detect speech", "Detect speech on a channel.", detect_speech_function, DETECT_SPEECH_SYNTAX, SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "ivr", "Run an ivr menu", "Run an ivr menu.", ivr_application_function, "<menu_name>", SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "redirect", "Send session redirect", "Send a redirect message to a session.", redirect_function, "<redirect_data>", SAF_SUPPORT_NOMEDIA);

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_dingaling/mod_dingaling.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_dingaling/mod_dingaling.c	Wed Jun 27 13:11:14 2007
@@ -859,7 +859,7 @@
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SETUP RTP %s:%d -> %s:%d\n", tech_pvt->profile->ip,
 					  tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port);
 	
-	flags = SWITCH_RTP_FLAG_GOOGLEHACK | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_AUTO_CNG;
+	flags = SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_GOOGLEHACK | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_AUTO_CNG;
 
 	if (switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
 		flags |= SWITCH_RTP_FLAG_USE_TIMER;
@@ -1817,7 +1817,7 @@
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 	channel_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
-	channel_endpoint_interface->interface_name = "digngaling";
+	channel_endpoint_interface->interface_name = "dingaling";
 	channel_endpoint_interface->io_routines = &channel_io_routines;
 	channel_endpoint_interface->state_handler = &channel_event_handlers;
 

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_portaudio/pablio.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_portaudio/pablio.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_portaudio/pablio.c	Wed Jun 27 13:11:14 2007
@@ -129,7 +129,6 @@
 		if (numBytes > 0) {
 			if (switch_core_timer_check(timer) == SWITCH_STATUS_SUCCESS) {
 				PaUtil_FlushRingBuffer(&aStream->outFIFO);
-				printf("ASS\n");
 				return 0;
 			}
 			switch_yield(1000);

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c	Wed Jun 27 13:11:14 2007
@@ -1055,6 +1055,7 @@
 	sdp_attribute_t *a;
 	int first = 0, last = 0;
 	int ptime = 0, dptime = 0;
+	int sendonly = 0;
 	int greedy = 0, x = 0, skip = 0, mine = 0;
 	switch_channel_t *channel = NULL;
 	char *val;
@@ -1080,33 +1081,44 @@
 		}
 	}
 
+	if (((m = sdp->sdp_media)) && m->m_mode == sdp_sendonly) {
+		sendonly = 1;
+	}
+
 	for (a = sdp->sdp_attributes; a; a = a->a_next) {
 		if (switch_strlen_zero(a->a_name)) {
 			continue;
 		}
 
 		if (!strcasecmp(a->a_name, "sendonly")) {
-			if (!switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
-				char *stream;
-				switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
-				if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
-					stream = tech_pvt->profile->hold_music;
-				}
-				if (stream) {
-					switch_ivr_broadcast(switch_core_session_get_uuid(tech_pvt->session), stream, SMF_ECHO_BLEG | SMF_LOOP);
-				}
-			}
-		} else if (!strcasecmp(a->a_name, "sendrecv")) {
-			if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
-				switch_channel_clear_flag_partner(tech_pvt->channel, CF_BROADCAST);
-				switch_channel_set_flag_partner(tech_pvt->channel, CF_BREAK);
-				switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
-			}
+			sendonly = 1;
+		} else if (!strcasecmp(a->a_name, "sendrecv")) {
+			sendonly = 0;
 		} else if (!strcasecmp(a->a_name, "ptime")) {
 			dptime = atoi(a->a_value);
 		}
 	}
 
+	if (sendonly) {
+		if (!switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
+			char *stream;
+			switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+			if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
+				stream = tech_pvt->profile->hold_music;
+			}
+			if (stream) {
+				switch_ivr_broadcast(switch_core_session_get_uuid(tech_pvt->session), stream, SMF_ECHO_BLEG | SMF_LOOP);
+			}
+		}
+	} else {
+		if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
+			switch_channel_clear_flag_partner(tech_pvt->channel, CF_BROADCAST);
+			switch_channel_set_flag_partner(tech_pvt->channel, CF_BREAK);
+			switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+		}
+	}
+
+
 	for (m = sdp->sdp_media; m; m = m->m_next) {
 		sdp_connection_t *connection;
 

Modified: freeswitch/branches/greenlizard/src/mod/event_handlers/mod_cdr/basecdr.cpp
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/event_handlers/mod_cdr/basecdr.cpp	(original)
+++ freeswitch/branches/greenlizard/src/mod/event_handlers/mod_cdr/basecdr.cpp	Wed Jun 27 13:11:14 2007
@@ -341,6 +341,7 @@
 			tempstring_second = (char *) val;
 			chanvars_supp[tempstring_first] = tempstring_second;
 		}
+		switch_channel_variable_last(channel);
 	}
 	else
 	{

Modified: freeswitch/branches/greenlizard/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	Wed Jun 27 13:11:14 2007
@@ -642,12 +642,14 @@
 			listener->event_list[SWITCH_EVENT_CHANNEL_ANSWER] = 1;
 			listener->event_list[SWITCH_EVENT_CHANNEL_HANGUP] = 1;
 			listener->event_list[SWITCH_EVENT_CHANNEL_EXECUTE] = 1;
+			listener->event_list[SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE] = 1;
 			listener->event_list[SWITCH_EVENT_CHANNEL_BRIDGE] = 1;
 			listener->event_list[SWITCH_EVENT_CHANNEL_UNBRIDGE] = 1;
 			listener->event_list[SWITCH_EVENT_CHANNEL_PROGRESS] = 1;
 			listener->event_list[SWITCH_EVENT_CHANNEL_OUTGOING] = 1;
 			listener->event_list[SWITCH_EVENT_CHANNEL_PARK] = 1;
 			listener->event_list[SWITCH_EVENT_CHANNEL_UNPARK] = 1;
+			listener->event_list[SWITCH_EVENT_CHANNEL_APPLICATION] = 1;
 			listener->event_list[SWITCH_EVENT_TALK] = 1;
 			listener->event_list[SWITCH_EVENT_DTMF] = 1;
 			listener->event_list[SWITCH_EVENT_NOTALK] = 1;

Modified: freeswitch/branches/greenlizard/src/mod/event_handlers/mod_radius_cdr/Makefile.am
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/event_handlers/mod_radius_cdr/Makefile.am	(original)
+++ freeswitch/branches/greenlizard/src/mod/event_handlers/mod_radius_cdr/Makefile.am	Wed Jun 27 13:11:14 2007
@@ -13,7 +13,7 @@
 MODNAME=mod_radius_cdr
 mod_LTLIBRARIES = mod_radius_cdr.la
 mod_radius_cdr_la_SOURCES = mod_radius_cdr.c
-mod_radius_cdr_la_CFLAGS = $(AM_CFLAGS) -l
+mod_radius_cdr_la_CFLAGS = $(AM_CFLAGS) 
 mod_radius_cdr_la_CPPFLAGS = $(AM_CPPFLAGS)
 mod_radius_cdr_la_LIBADD=$(switch_builddir)/libfreeswitch.la
 mod_radius_cdr_la_LDFLAGS=-module -avoid-version -no-undefined

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_mono/mod_mono.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_mono/mod_mono.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_mono/mod_mono.c	Wed Jun 27 13:11:14 2007
@@ -194,12 +194,13 @@
 	iter = NULL;
 	mono_plugin *plugin = NULL;
     const char *fname = NULL;
+    char buf[512] = "";
 
 	if (switch_dir_open(&module_dir_handle, module_dir, mono_pool) != SWITCH_STATUS_SUCCESS)
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not open directory: %s\n", module_dir);
 
 	/* Read the modules directory */
-	while ((fname = switch_dir_next_file(module_dir_handle))) {
+	while ((fname = switch_dir_next_file(module_dir_handle, buf, sizeof(buf)))) {
 		assembly = (MonoAssembly *) switch_core_alloc(mono_pool, sizeof(assembly));
 		image = (MonoImage *) switch_core_alloc(mono_pool, sizeof(image));
 

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python.i
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python.i	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python.i	Wed Jun 27 13:11:14 2007
@@ -9,6 +9,7 @@
 %cstring_bounded_mutable(char *dtmf_buf, 128);
 %cstring_bounded_mutable(char *terminator, 8);
 
+
 /** insert the following includes into generated code so it compiles */
 %{
 #include "switch_cpp.h"

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	Wed Jun 27 13:11:14 2007
@@ -44,19 +44,32 @@
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spidermonkey_shutdown);
 SWITCH_MODULE_DEFINITION(mod_spidermonkey, mod_spidermonkey_load, mod_spidermonkey_shutdown, NULL);
 
-#define METHOD_SANITY_CHECK() do {												\
+#define METHOD_SANITY_CHECK() do {										\
 if (!jss || !jss->session) {											\
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n"); \
+	eval_some_js("~throw new Error(\"You must call the session.originate method before calling this method!\");", cx, obj, rval); \
 	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);									\
-	return JS_TRUE;														\
+	return JS_FALSE;													\
  }																		\
 	} while(foo == 1)
 
-#define CHANNEL_SANITY_CHECK() do {				\
+#define CHANNEL_SANITY_CHECK() do {										\
 		if (!switch_channel_ready(channel)) {							\
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n"); \
+			eval_some_js("~throw new Error(\"Session is not active!\");", cx, obj, rval); \
 			*rval = BOOLEAN_TO_JSVAL(JS_FALSE);							\
-			return JS_TRUE;												\
+			return JS_FALSE;											\
+		}																\
+		if (!((switch_channel_test_flag(channel, CF_ANSWERED) || switch_channel_test_flag(channel, CF_EARLY_MEDIA)))) {							\
+			eval_some_js("~throw new Error(\"Session is not answered!\");", cx, obj, rval); \
+			*rval = BOOLEAN_TO_JSVAL(JS_FALSE);							\
+			return JS_FALSE;											\
+		}																\
+	} while (foo == 1)
+
+#define CHANNEL_SANITY_CHECK_ANSWER() do {										\
+		if (!switch_channel_ready(channel)) {							\
+			eval_some_js("~throw new Error(\"Session is not active!\");", cx, obj, rval); \
+			*rval = BOOLEAN_TO_JSVAL(JS_FALSE);							\
+			return JS_FALSE;											\
 		}																\
 	} while (foo == 1)
 
@@ -838,6 +851,9 @@
 	jsval argv[4];
 	JSObject *Event = NULL;
 	jsval nval , *rval = &nval; 
+	JSContext *cx = cb_state->cx;
+	JSObject *obj = cb_state->obj;
+	
 
 	METHOD_SANITY_CHECK();
 
@@ -1600,12 +1616,27 @@
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-	CHANNEL_SANITY_CHECK();
+	CHANNEL_SANITY_CHECK_ANSWER();
 
 	switch_channel_answer(channel);
 	return JS_TRUE;
 }
 
+static JSBool session_pre_answer(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
+{
+	struct js_session *jss = JS_GetPrivate(cx, obj);
+	switch_channel_t *channel;
+
+	METHOD_SANITY_CHECK();
+
+	channel = switch_core_session_get_channel(jss->session);
+	assert(channel != NULL);
+
+	CHANNEL_SANITY_CHECK_ANSWER();
+
+	switch_channel_pre_answer(channel);
+	return JS_TRUE;
+}
 
 static JSBool session_cdr(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
@@ -2009,6 +2040,7 @@
 	{"getVariable", session_get_variable, 1},
 	{"getDigits", session_get_digits, 1},
 	{"answer", session_answer, 0},
+	{"preAnswer", session_pre_answer, 0},
 	{"generateXmlCdr", session_cdr, 0},
 	{"ready", session_ready, 0},
 	{"waitForAnswer", session_wait_for_answer, 0},
@@ -2561,6 +2593,13 @@
 /*********************************************************************************/
 static JSBool js_exit(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
+	char *supplied_error, code_buf[256] = "";
+	
+	if (argc > 0 && (supplied_error = JS_GetStringBytes(JS_ValueToString(cx, argv[0])))) {
+		snprintf(code_buf, sizeof(code_buf), "~throw new Error(\"%s\");", supplied_error);
+		eval_some_js(code_buf, cx, obj, rval);
+	}
+
 	return JS_FALSE;
 }
 

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h	Wed Jun 27 13:11:14 2007
@@ -145,6 +145,7 @@
 
 JSBool DEFAULT_SET_PROPERTY(JSContext * cx, JSObject *obj, jsval id, jsval *vp)
 {
+	eval_some_js("~throw new Error(\"this property cannot be changed!\");", cx, obj, vp);
 	return JS_FALSE;
 }
 

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c	Wed Jun 27 13:11:14 2007
@@ -247,6 +247,7 @@
 	char *name = JS_GetStringBytes(JS_ValueToString(cx, id));
 
 	if (strcmp(name, "_dB_RoW_DaTa_")) {
+		eval_some_js("~throw new Error(\"this property cannot be changed!\");", cx, obj, vp);
 		*vp = BOOLEAN_TO_JSVAL(JS_FALSE);
 	}
 	return JS_TRUE;

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c	Wed Jun 27 13:11:14 2007
@@ -433,6 +433,7 @@
 	char *name = JS_GetStringBytes(JS_ValueToString(cx, id));
 
 	if (strcmp(name, "_oDbC_dB_RoW_DaTa_")) {
+		eval_some_js("~throw new Error(\"this property cannot be changed!\");", cx, obj, vp);
 		*vp = BOOLEAN_TO_JSVAL(JS_FALSE);
 	}
 	return JS_TRUE;

Modified: freeswitch/branches/greenlizard/src/mod/timers/mod_softtimer/mod_softtimer.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/timers/mod_softtimer/mod_softtimer.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/timers/mod_softtimer/mod_softtimer.c	Wed Jun 27 13:11:14 2007
@@ -43,6 +43,7 @@
 
 static struct {
 	int32_t RUNNING;
+	int32_t STARTED;
 	switch_mutex_t *mutex;
 } globals;
 
@@ -76,6 +77,14 @@
 static inline switch_status_t timer_init(switch_timer_t *timer)
 {
 	timer_private_t *private_info;
+	int sanity = 0;
+
+	while(globals.STARTED == 0) {
+		switch_yield(100000);
+		if (++sanity == 10) {
+			break;
+		}
+	}
 
 	if (globals.RUNNING != 1 || !globals.mutex) {
 		return SWITCH_STATUS_FALSE;
@@ -220,9 +229,9 @@
 
 	memset(&globals, 0, sizeof(globals));
 	switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
-
-	globals.RUNNING = 1;
-
+	
+	globals.STARTED = globals.RUNNING = 1;
+	
 	while (globals.RUNNING == 1) {
 		reference += STEP_MIC;
 

Modified: freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c	Wed Jun 27 13:11:14 2007
@@ -24,13 +24,23 @@
  * Contributor(s):
  * 
  * Brian West <brian.west at mac.com>
+ * Bret McDanel <trixter AT 0xdecafbad.com>
  *
- *
- * mod_xml_cdr.c -- XML CDR Module
+ * mod_xml_cdr.c -- XML CDR Module to files or curl
  *
  */
 #include <sys/stat.h>
 #include <switch.h>
+#include <curl/curl.h>
+
+static struct {
+	char *cred;
+	char *url;
+	char *logDir;
+	char *errLogDir;
+	uint32_t delay;
+	uint32_t retries;
+} globals;
 
 SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load);
 SWITCH_MODULE_DEFINITION(mod_xml_cdr, mod_xml_cdr_load, NULL, NULL);
@@ -38,25 +48,34 @@
 static switch_status_t my_on_hangup(switch_core_session_t *session)
 {
 	switch_xml_t cdr;
+	char *xml_text;
+	char *path;
+	int fd = -1;
+	uint32_t curTry;
+	long httpRes;
+	CURL *curl_handle = NULL;
+	char *curl_xml_text;
+	char *logdir;
+	switch_channel_t *channel = switch_core_session_get_channel(session);
 
 	if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
-		switch_channel_t *channel = switch_core_session_get_channel(session);
-		char *xml_text;
-		char *path;
-		int fd = -1;
-		const char *header = "<?xml version=\"1.0\"?>\n";
-		char *uuid_str = switch_core_session_get_uuid(session);
-		char *logdir = SWITCH_GLOBAL_dirs.log_dir;
-		char *alt;
 
-		if ((alt = switch_channel_get_variable(channel, "xml_cdr_base"))) {
-			logdir = alt;
+		/* build the XML */
+		if(!(xml_text = switch_mprintf("<?xml version=\"1.0\"?>\n%s",switch_xml_toxml(cdr)) )) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+			return SWITCH_STATUS_FALSE;
+		}
+
+		/* do we log to the disk no matter what? */
+		/* all previous functionality is retained */
+
+		if (!(logdir = switch_channel_get_variable(channel, "xml_cdr_base"))) {
+			logdir = globals.logDir;
 		}
 
-		if ((path = switch_mprintf("%s/xml_cdr/%s.cdr.xml", logdir, uuid_str))) {
-			if ((xml_text = switch_xml_toxml(cdr))) {
+		if(!switch_strlen_zero(logdir)) {
+			if ((path = switch_mprintf("%s/xml_cdr/%s.cdr.xml", logdir, switch_core_session_get_uuid(session)))) {
 				if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
-					write(fd, header, (unsigned) strlen(header));
 					write(fd, xml_text, (unsigned) strlen(xml_text));
 					close(fd);
 					fd = -1;
@@ -69,11 +88,75 @@
 #endif
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error![%s]\n", ebuf);
 				}
+				free(path);
+			}
+		}
+
+		/* try to post it to the web server */
+		if(!switch_strlen_zero(globals.url)) {
+			curl_handle = curl_easy_init();
+			if(!(curl_xml_text = switch_mprintf("cdr=%s",xml_text) )) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 				free(xml_text);
+				return SWITCH_STATUS_FALSE;
+			}
+
+			if (!switch_strlen_zero(globals.cred)) {
+				curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
+				curl_easy_setopt(curl_handle, CURLOPT_USERPWD, globals.cred);
+			}
+
+			curl_easy_setopt(curl_handle, CURLOPT_POST, 1);
+			curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, curl_xml_text);
+			curl_easy_setopt(curl_handle, CURLOPT_URL, globals.url);
+			curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-xml/1.0");
+
+			/* these were used for testing, optionally they may be enabled if someone desires
+			curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 120); // tcp timeout
+			curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1); // 302 recursion level
+			*/
+
+			for(curTry=0;curTry<=globals.retries;curTry++) {
+				curl_easy_perform(curl_handle);
+				curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE,&httpRes);
+				if(httpRes==200) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DEBUG XXX success posting\n");
+					curl_easy_cleanup(curl_handle);
+					free(curl_xml_text);
+					free(xml_text);
+					return SWITCH_STATUS_SUCCESS;
+				} else {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Got error [%ld] posting to web server\n",httpRes);
+				}
+
+				/* bug?  feature?  we sleep even on the last failure before writing the file */
+				switch_sleep(globals.delay * 1000);
+			}
+			free(curl_xml_text);
+			curl_easy_cleanup(curl_handle);
+		}
+
+		/* if we are here the web post failed for some reason */
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to post to web server, writing to file\n");
+
+		if ((path = switch_mprintf("%s/%s.cdr.xml", globals.errLogDir, switch_core_session_get_uuid(session)))) {
+			if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
+				write(fd, xml_text, (unsigned) strlen(xml_text));
+				close(fd);
+				fd = -1;
+			} else {
+				char ebuf[512] = { 0 };
+#ifdef WIN32
+				strerror_s(ebuf, sizeof(ebuf), errno);
+#else
+				strerror_r(errno, ebuf, sizeof(ebuf));
+#endif
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error![%s]\n", ebuf);
 			}
 			free(path);
 		}
 
+		free(xml_text);
 		switch_xml_free(cdr);
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Generating Data!\n");
@@ -82,6 +165,62 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
+static switch_status_t do_config(void)
+{
+	char *cf = "xml_cdr.conf";
+	switch_xml_t cfg, xml, settings, param;
+
+	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
+		return SWITCH_STATUS_TERM;
+	}
+
+	if ((settings = switch_xml_child(cfg, "settings"))) {
+		for (param = switch_xml_child(settings, "param"); param; param = param->next) {
+			char *var = (char *) switch_xml_attr_soft(param, "name");
+			char *val = (char *) switch_xml_attr_soft(param, "value");
+
+			if (!strcasecmp(var, "cred")) {
+				globals.cred = val;
+			} else if (!strcasecmp(var, "url")) {
+				globals.url = val;
+			} else if (!strcasecmp(var, "delay")) {
+				globals.delay = (uint32_t) atoi(val);
+			} else if (!strcasecmp(var, "retries")) {
+				globals.retries = (uint32_t) atoi(val);
+			} else if (!strcasecmp(var, "logDir")) {
+				if (switch_strlen_zero(val)) {
+					globals.logDir = SWITCH_GLOBAL_dirs.log_dir;
+				} else {
+					globals.logDir = val;
+				}
+			} else if (!strcasecmp(var, "errLogDir")) {
+				globals.errLogDir = val;
+			}
+
+		}
+	}
+	if(globals.retries < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "retries is negative, setting to 0\n");
+		globals.retries = 0;
+	}
+
+
+	if(globals.retries && globals.delay<=0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "retries set but delay 0 setting to 5000ms\n");
+		globals.delay = 5000;
+	}
+
+	if(!switch_strlen_zero(globals.url) && switch_strlen_zero(globals.errLogDir)) {
+		if ((globals.errLogDir = switch_mprintf("%s/xml_cdr", SWITCH_GLOBAL_dirs.log_dir))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+			return SWITCH_STATUS_FALSE;
+		}
+	}
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
 static switch_state_handler_table_t state_handlers = {
 	/*.on_init */ NULL,
 	/*.on_ring */ NULL,
@@ -98,6 +237,9 @@
 
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 
+	memset(&globals,0,sizeof(globals));
+	do_config();
+
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.vcproj
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.vcproj	(original)
+++ freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.vcproj	Wed Jun 27 13:11:14 2007
@@ -41,8 +41,8 @@
 			<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"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\curl\include&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;CURL_STATICLIB"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -63,6 +63,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
+				AdditionalDependencies="Ws2_32.lib Winmm.lib"
 				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
@@ -122,8 +123,8 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\curl\include&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;CURL_STATICLIB"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
 				WarningLevel="4"
@@ -142,6 +143,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
+				AdditionalDependencies="Ws2_32.lib Winmm.lib"
 				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"

Modified: freeswitch/branches/greenlizard/src/switch_apr.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_apr.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_apr.c	Wed Jun 27 13:11:14 2007
@@ -391,29 +391,51 @@
 SWITCH_DECLARE(switch_status_t) switch_dir_open(switch_dir_t **new_dir, const char *dirname, switch_memory_pool_t *pool)
 {
 	switch_status_t status;
-	switch_dir_t *dir = switch_core_alloc(pool, sizeof(switch_dir_t));
-	status = apr_dir_open(&(dir->dir_handle), dirname, pool);
-	*new_dir = dir;
+	switch_dir_t *dir = malloc(sizeof(*dir));
+
+	memset(dir, 0, sizeof(*dir));
+	if ((status = apr_dir_open(&(dir->dir_handle), dirname, pool)) == APR_SUCCESS) {
+		*new_dir = dir;
+	} else {
+		free(dir);
+		*new_dir = NULL;
+	}
+
 	return status;	 
 }
 
 SWITCH_DECLARE(switch_status_t) switch_dir_close(switch_dir_t *thedir)
 {
-	return apr_dir_close(thedir->dir_handle);
+	switch_status_t status = apr_dir_close(thedir->dir_handle);
+
+	free(thedir);
+	return status;
 }
 
-SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir) 
+SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *buf, switch_size_t len) 
 {
 	const char *fname = NULL;
 	apr_int32_t finfo_flags = APR_FINFO_DIRENT | APR_FINFO_TYPE | APR_FINFO_NAME;
+	const char *name;
+	
 	while (apr_dir_read(&(thedir->finfo), finfo_flags, thedir->dir_handle) == SWITCH_STATUS_SUCCESS) {
-		if (thedir->finfo.filetype != APR_REG)
+		if (thedir->finfo.filetype != APR_REG) {
+			continue;
+		}
+		if (!(name = thedir->finfo.fname)) {
+			name = thedir->finfo.name;
+		}
+		
+		if (!name) {
 			continue;
-		fname = thedir->finfo.fname;
-		if (!fname)
-			fname = thedir->finfo.name;
-		if (!fname)
+		}
+
+		if (name) {
+			switch_copy_string(buf, name, len);
+			fname = buf;
+		} else {
 			continue;
+		}
 	}
 	return fname;
 }

Modified: freeswitch/branches/greenlizard/src/switch_channel.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_channel.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_channel.c	Wed Jun 27 13:11:14 2007
@@ -513,11 +513,6 @@
 		ret++;
 	}
 
-	if (switch_test_flag(channel, CF_BREAK)) {
-		switch_clear_flag_locked(channel, CF_BREAK);
-		ret = (uint8_t) 0;
-	}
-
 	return ret;
 }
 
@@ -772,6 +767,8 @@
 	const void *var;
 	char state_num[25];
 
+	switch_mutex_lock(channel->profile_mutex);
+
 	if ((caller_profile = switch_channel_get_caller_profile(channel))) {
 		originator_caller_profile = caller_profile->originator_caller_profile;
 		originatee_caller_profile = caller_profile->originatee_caller_profile;
@@ -818,7 +815,7 @@
 		}
 	}
 
-
+	switch_mutex_unlock(channel->profile_mutex);
 
 }
 

Modified: freeswitch/branches/greenlizard/src/switch_core_session.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_session.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_session.c	Wed Jun 27 13:11:14 2007
@@ -567,11 +567,11 @@
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
-	if (switch_channel_test_flag(channel, CF_EVENT_PARSE)) {
+	
+	if (switch_channel_test_flag(channel, CF_EVENT_LOCK)) {
 		return status;
 	}
 
-
 	if (session->private_event_queue) {
 		if ((status = (switch_status_t) switch_queue_trypop(session->private_event_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
 			*event = (switch_event_t *) pop;
@@ -912,7 +912,9 @@
 SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *session,
 														 const switch_application_interface_t *application_interface, char *arg) {
 	switch_app_log_t *log, *lp;
-	
+	switch_event_t *event;
+	switch_channel_t *channel;
+
 	log = switch_core_session_alloc(session, sizeof(*log));
 
 	assert(log != NULL);
@@ -928,7 +930,23 @@
 		session->app_log = log;
 	}
 	
+	if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_event_set_data(session->channel, event);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application", "%s", application_interface->interface_name);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", arg);
+		switch_event_fire(&event);
+	}
+
+	channel = switch_core_session_get_channel(session);
+	switch_channel_clear_flag(channel, CF_BREAK);
 	application_interface->application_function(session, arg);
+	
+	if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_event_set_data(session->channel, event);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application", "%s", application_interface->interface_name);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", "%s", arg);
+		switch_event_fire(&event);
+	}
 
 	return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/branches/greenlizard/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_state_machine.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_state_machine.c	Wed Jun 27 13:11:14 2007
@@ -108,7 +108,6 @@
 static void switch_core_standard_on_execute(switch_core_session_t *session)
 {
 	switch_caller_extension_t *extension;
-	switch_event_t *event;
 	const switch_application_interface_t *application_interface;
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard EXECUTE\n");
@@ -149,15 +148,6 @@
 							  expanded);
 		}
 
-		if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE) == SWITCH_STATUS_SUCCESS) {
-			switch_channel_event_set_data(session->channel, event);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application", "%s", extension->current_application->application_name);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data-Orig", "%s", extension->current_application->application_data);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", "%s", expanded);
-			switch_event_fire(&event);
-		}
-
-
 		if (switch_channel_get_variable(session->channel, "presence_id")) {
 			char *arg = switch_mprintf("%s(%s)", extension->current_application->application_name, expanded);
 			if (arg) {

Modified: freeswitch/branches/greenlizard/src/switch_event.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_event.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_event.c	Wed Jun 27 13:11:14 2007
@@ -103,12 +103,14 @@
 	"CHANNEL_ANSWER",
 	"CHANNEL_HANGUP",
 	"CHANNEL_EXECUTE",
+	"CHANNEL_EXECUTE_COMPLETE",
 	"CHANNEL_BRIDGE",
 	"CHANNEL_UNBRIDGE",
 	"CHANNEL_PROGRESS",
 	"CHANNEL_OUTGOING",
 	"CHANNEL_PARK",
 	"CHANNEL_UNPARK",
+	"CHANNEL_APPLICATION",
 	"API",
 	"LOG",
 	"INBOUND_CHAN",
@@ -682,7 +684,7 @@
 			}
 		}
 
-		snprintf(buf + len, dlen - len, "%s: %s\n", hp->name, encode_buf);
+		snprintf(buf + len, dlen - len, "%s: %s\n", hp->name, switch_strlen_zero(encode_buf) ? "_undef_" : encode_buf);
 		len = strlen(buf);
 
 	}

Modified: freeswitch/branches/greenlizard/src/switch_ivr.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_ivr.c	Wed Jun 27 13:11:14 2007
@@ -272,7 +272,9 @@
 	unsigned long CMD_NOMEDIA = switch_hashfunc_default("nomedia", &hlen);
 	unsigned long CMD_UNICAST = switch_hashfunc_default("unicast", &hlen);
 	char *lead_frames = switch_event_get_header(event, "lead-frames");
-	
+	char *event_lock = switch_event_get_header(event, "event-lock");
+	switch_status_t status = SWITCH_STATUS_FALSE;
+
 	assert(channel != NULL);
 	assert(event != NULL);
 
@@ -286,15 +288,19 @@
 
 	switch_channel_set_flag(channel, CF_EVENT_PARSE);
 
+	if (switch_true(event_lock)) {
+		switch_channel_set_flag(channel, CF_EVENT_LOCK);
+	}
+
+
 	if (lead_frames) {
 		switch_frame_t *read_frame;
 		int frame_count = atoi(lead_frames);
-		switch_status_t status;
 
 		while(frame_count > 0) {
 			status = switch_core_session_read_frame(session, &read_frame, -1, 0);
 			if (!SWITCH_READ_ACCEPTABLE(status)) {
-				return status;
+				goto done;
 			}
 			if (!switch_test_flag(read_frame, SFF_CNG)) {
 				frame_count--;
@@ -308,12 +314,12 @@
 		char *app_arg = switch_event_get_header(event, "execute-app-arg");
 		char *loop_h = switch_event_get_header(event, "loops");
 		int loops = 1;
-	
+
 		if (loop_h) {
 			loops = atoi(loop_h);
 		}
-
-		if (app_name && app_arg) {
+		
+		if (app_name) {
 			if ((application_interface = switch_loadable_module_get_application_interface(app_name))) {
 				if (application_interface->application_function) {
 					int x;
@@ -368,9 +374,13 @@
 		switch_ivr_nomedia(uuid, SMF_REBRIDGE);
 	}
 
+	status = SWITCH_STATUS_SUCCESS;
 
+ done:
 	switch_channel_clear_flag(channel, CF_EVENT_PARSE);
-	return SWITCH_STATUS_SUCCESS;
+	switch_channel_clear_flag(channel, CF_EVENT_LOCK);
+
+	return status;
 
 }
 
@@ -906,6 +916,7 @@
 
 		switch_channel_set_caller_profile(channel, new_profile);
 		switch_channel_set_flag(channel, CF_TRANSFER);
+
 		switch_channel_set_state(channel, CS_RING);
 
 		msg.message_id = SWITCH_MESSAGE_INDICATE_TRANSFER;

Modified: freeswitch/branches/greenlizard/src/switch_ivr_async.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_async.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_async.c	Wed Jun 27 13:11:14 2007
@@ -1179,6 +1179,7 @@
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
 				if ((flags & SMF_LOOP)) {
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
 				}
@@ -1197,6 +1198,7 @@
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
 				if ((flags & SMF_LOOP)) {
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
 				}
@@ -1209,6 +1211,7 @@
 			if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "nomedia");
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "nomedia-uuid", "%s", uuid);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
 				switch_core_session_queue_private_event(master, &event);
 			}
 		}
@@ -1218,7 +1221,7 @@
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "hangup");
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", cause);
-
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
 				switch_core_session_queue_private_event(session, &event);
 			}
 		}

Modified: freeswitch/branches/greenlizard/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_bridge.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_bridge.c	Wed Jun 27 13:11:14 2007
@@ -274,6 +274,7 @@
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CUSTOM TRANSMIT\n");
 	switch_channel_clear_state_handler(channel, NULL);
 
+	switch_channel_set_flag(channel, CF_BREAK);
 
 	if (!switch_channel_test_flag(channel, CF_ORIGINATOR)) {
 		return SWITCH_STATUS_FALSE;
@@ -656,6 +657,9 @@
 			switch_channel_set_flag(originatee_channel, CF_TAGGED);
 			switch_channel_set_private(originator_channel, SWITCH_UUID_BRIDGE, originatee_session);
 
+			switch_channel_set_flag(originator_channel, CF_BREAK);
+			switch_channel_set_flag(originatee_channel, CF_BREAK);
+			
 			/* switch_channel_set_state_flag sets flags you want to be set when the next state change happens */
 			switch_channel_set_state_flag(originator_channel, CF_TRANSFER);
 			switch_channel_set_state_flag(originatee_channel, CF_TRANSFER);

Modified: freeswitch/branches/greenlizard/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_play_say.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_play_say.c	Wed Jun 27 13:11:14 2007
@@ -394,11 +394,14 @@
 
 	while (switch_channel_ready(channel)) {
 		switch_size_t len;
-		switch_event_t *event;
 
-		if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
-			switch_ivr_parse_event(session, event);
-			switch_event_destroy(&event);
+		if (switch_channel_test_flag(channel, CF_BREAK)) {
+			switch_channel_clear_flag(channel, CF_BREAK);
+			break;
+		}
+
+		if (switch_core_session_private_event_count(session)) {
+			switch_ivr_parse_all_events(session);
 		}
 
 		if (start && (time(NULL) - start) > limit) {
@@ -425,6 +428,8 @@
 			}
 
 			if (args->input_callback) {
+				switch_event_t *event = NULL;
+
 				if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
 					status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen);
 					switch_event_destroy(&event);
@@ -537,6 +542,11 @@
 	while(switch_channel_ready(channel)) {
 		switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
 		
+		if (switch_channel_test_flag(channel, CF_BREAK)) {
+			switch_channel_clear_flag(channel, CF_BREAK);
+			break;
+		}
+
 		if (!SWITCH_READ_ACCEPTABLE(status)) {
 			break;
 		}
@@ -781,12 +791,14 @@
 		int done = 0;
 		int do_speed = 1;
 		int last_speed = -1;
-		switch_event_t *event;
 
+		if (switch_channel_test_flag(channel, CF_BREAK)) {
+			switch_channel_clear_flag(channel, CF_BREAK);
+			break;
+		}
 
-		if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
-			switch_ivr_parse_event(session, event);
-			switch_event_destroy(&event);
+		if (switch_core_session_private_event_count(session)) {
+			switch_ivr_parse_all_events(session);
 		}
 
 		if (args && (args->input_callback || args->buf || args->buflen)) {
@@ -810,6 +822,8 @@
 			}
 
 			if (args->input_callback) {
+				switch_event_t *event;
+
 				if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
 					status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen);
 					switch_event_destroy(&event);
@@ -1151,6 +1165,11 @@
 	while (switch_channel_ready(channel)) {
 		switch_event_t *event;
 
+		if (switch_channel_test_flag(channel, CF_BREAK)) {
+			switch_channel_clear_flag(channel, CF_BREAK);
+			break;
+		}
+
 		if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
 			switch_ivr_parse_event(session, event);
 			switch_event_destroy(&event);

Modified: freeswitch/branches/greenlizard/src/switch_rtp.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_rtp.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_rtp.c	Wed Jun 27 13:11:14 2007
@@ -964,12 +964,7 @@
 
 		if (status == SWITCH_STATUS_BREAK || bytes == 0) {
 			if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DATAWAIT)) {
-				if (rtp_session->ms_per_packet) {
-					switch_yield((rtp_session->ms_per_packet / 1000) * 750);
-				} else {
-					switch_yield(1000);
-				}
-				continue;
+				goto do_continue;
 			}
 			return 0;
 		}
@@ -1005,9 +1000,9 @@
 
 
 		if (bytes && rtp_session->cng_pt && rtp_session->recv_msg.header.pt == rtp_session->cng_pt) {
-			continue;
+			goto do_continue;
 		}
-
+		
 
 		
 		if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_GOOGLEHACK) && rtp_session->recv_msg.header.pt == 102) {
@@ -1054,11 +1049,19 @@
 				}
 			}
 			
-			continue;
+			goto do_continue;
 		}
 	
 
 		break;
+
+	do_continue:
+
+		if (rtp_session->ms_per_packet) {
+			switch_yield((rtp_session->ms_per_packet / 1000) * 750);
+		} else {
+			switch_yield(1000);
+		}
 	}
 
 	*payload_type = (switch_payload_t) rtp_session->recv_msg.header.pt;



More information about the Freeswitch-branches mailing list