<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][17416] </title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=17416">17416</a></dd>
<dt>Author</dt> <dd>dyatsin</dd>
<dt>Date</dt> <dd>2010-04-27 13:32:55 -0500 (Tue, 27 Apr 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge branch 'master' of git@git.freeswitch.org:freeswitch</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunkMakefileam">freeswitch/trunk/Makefile.am</a></li>
<li><a href="#freeswitchtrunkconfigurein">freeswitch/trunk/configure.in</a></li>
<li><a href="#freeswitchtrunklibseslsrceslc">freeswitch/trunk/libs/esl/src/esl.c</a></li>
<li><a href="#freeswitchtrunklibslibdingalingsrclibdingalingc">freeswitch/trunk/libs/libdingaling/src/libdingaling.c</a></li>
<li><a href="#freeswitchtrunksrcincludeg711h">freeswitch/trunk/src/include/g711.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_dsoh">freeswitch/trunk/src/include/switch_dso.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_nath">freeswitch/trunk/src/include/switch_nat.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_stunh">freeswitch/trunk/src/include/switch_stun.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_typesh">freeswitch/trunk/src/include/switch_types.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_xmlh">freeswitch/trunk/src/include/switch_xml.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_conferencemod_conferencec">freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_exprconioh">freeswitch/trunk/src/mod/applications/mod_expr/conio.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_fifomod_fifoc">freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_spymod_spyc">freeswitch/trunk/src/mod/applications/mod_spy/mod_spy.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_t38gatewayudptlh">freeswitch/trunk/src/mod/applications/mod_t38gateway/udptl.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_voicemailmod_voicemailc">freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c</a></li>
<li><a href="#freeswitchtrunksrcmoddialplansmod_dialplan_xmlmod_dialplan_xmlc">freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_portaudiopablioh">freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiamod_sofiac">freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiamod_sofiah">freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofiac">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_presencec">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_regc">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c</a></li>
<li><a href="#freeswitchtrunksrcmodevent_handlersmod_json_cdrmod_json_cdrc">freeswitch/trunk/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c</a></li>
<li><a href="#freeswitchtrunksrcmodxml_intmod_xml_cdrmod_xml_cdrc">freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c</a></li>
<li><a href="#freeswitchtrunksrcmodxml_intmod_xml_ldaplutil_ldaph">freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/lutil_ldap.h</a></li>
<li><a href="#freeswitchtrunksrcswitch_channelc">freeswitch/trunk/src/switch_channel.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_sqldbc">freeswitch/trunk/src/switch_core_sqldb.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_state_machinec">freeswitch/trunk/src/switch_core_state_machine.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_dsoc">freeswitch/trunk/src/switch_dso.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_ivr_asyncc">freeswitch/trunk/src/switch_ivr_async.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_ivr_originatec">freeswitch/trunk/src/switch_ivr_originate.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_loadable_modulec">freeswitch/trunk/src/switch_loadable_module.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_rtpc">freeswitch/trunk/src/switch_rtp.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_xmlc">freeswitch/trunk/src/switch_xml.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunkMakefileam"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/Makefile.am (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/Makefile.am        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/Makefile.am        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -350,7 +350,7 @@
</span><span class="cx">           touch .version ; \
</span><span class="cx">         else \
</span><span class="cx">           if [ -d .git ] ; then \
</span><del>-            version=`git log --format=&quot;%h %ci&quot; -1 HEAD | head -1 || echo hacked` ; \
</del><ins>+            version=`git log --format=&quot;%h %ci&quot; -1 HEAD | head -1 | sed -e 's|:|-|g' || echo hacked` ; \
</ins><span class="cx">             if [ &quot;x$$version&quot; == &quot;xhacked&quot; ] ; then \
</span><span class="cx">               version=&quot;hacked-`date -u +%Y%m%dT%H%M%SZ`&quot; ; \
</span><span class="cx">             else \
</span></span></pre></div>
<a id="freeswitchtrunkconfigurein"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/configure.in (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/configure.in        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/configure.in        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -353,7 +353,6 @@
</span><span class="cx"> 
</span><span class="cx"> AM_CONDITIONAL([ENABLE_ZRTP],[test &quot;x$enable_zrtp&quot; != &quot;xno&quot;])
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> AM_CONDITIONAL([WANT_DEBUG],[test &quot;${enable_debug}&quot; = &quot;yes&quot;])
</span><span class="cx"> 
</span><span class="cx"> AC_ARG_ENABLE(core-odbc-support,     
</span><span class="lines">@@ -363,6 +362,11 @@
</span><span class="cx">   enable_core_odbc_support=&quot;yes&quot;
</span><span class="cx"> fi
</span><span class="cx"> 
</span><ins>+AC_CHECK_LIB(z, inflateReset, have_libz=yes, have_libz=no)
+if test &quot;x$have_libz&quot; = &quot;xyes&quot;  ; then
+APR_ADDTO(SWITCH_AM_LDFLAGS, -lz)
+fi
+
</ins><span class="cx"> ESL_LDFLAGS=
</span><span class="cx"> PLATFORM_CORE_DEPLIBS=
</span><span class="cx"> # tweak platform specific flags
</span></span></pre></div>
<a id="freeswitchtrunklibseslsrceslc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/esl/src/esl.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/esl/src/esl.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/libs/esl/src/esl.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -786,7 +786,7 @@
</span><span class="cx">                 return ESL_FAIL;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (esl_mutex_trylock(handle-&gt;mutex) != ESL_SUCCESS) {
</del><ins>+        if (activity == 0 || !FD_ISSET(handle-&gt;sock, &amp;rfds) || (esl_mutex_trylock(handle-&gt;mutex) != ESL_SUCCESS)) {
</ins><span class="cx">                 return ESL_BREAK;
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunklibslibdingalingsrclibdingalingc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/libdingaling/src/libdingaling.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/libs/libdingaling/src/libdingaling.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -2179,7 +2179,11 @@
</span><span class="cx"> 
</span><span class="cx"> ldl_status ldl_global_terminate(void)
</span><span class="cx"> {
</span><del>-        ldl_clear_flag_locked((&amp;globals), LDL_FLAG_READY);
</del><ins>+        if (globals.flag_mutex) {
+                ldl_clear_flag_locked((&amp;globals), LDL_FLAG_READY);
+        } else {
+                ldl_clear_flag((&amp;globals), LDL_FLAG_READY);
+        }
</ins><span class="cx">         return LDL_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeg711h"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/g711.h (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/g711.h        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/include/g711.h        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -39,8 +39,8 @@
</span><span class="cx"> specification by other means.
</span><span class="cx"> */
</span><span class="cx"> 
</span><del>-#if !defined(_G711_H_)
-#define _G711_H_
</del><ins>+#if !defined(FREESWITCH_G711_H)
+#define FREESWITCH_G711_H
</ins><span class="cx"> 
</span><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> extern &quot;C&quot; {
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_dsoh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_dso.h (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_dso.h        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/include/switch_dso.h        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -18,8 +18,8 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-#ifndef _SWITCH_DSO_H
-#define _SWITCH_DSO_H
</del><ins>+#ifndef FREESWITCH_DSO_H
+#define FREESWITCH_DSO_H
</ins><span class="cx"> 
</span><span class="cx"> typedef int (*switch_dso_func_t) (void);
</span><span class="cx"> #ifdef WIN32
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_nath"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_nat.h (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_nat.h        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/include/switch_nat.h        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -35,8 +35,8 @@
</span><span class="cx">   \ingroup core1
</span><span class="cx">   \{
</span><span class="cx"> */
</span><del>-#ifndef _SWITCH_NAT_H
-#define _SWITCH_NAT_H
</del><ins>+#ifndef FREESWITCH_NAT_H
+#define FREESWITCH_NAT_H
</ins><span class="cx"> 
</span><span class="cx"> SWITCH_BEGIN_EXTERN_C typedef enum {
</span><span class="cx">         SWITCH_NAT_TYPE_NONE,
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_stunh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_stun.h (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_stun.h        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/include/switch_stun.h        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -34,8 +34,8 @@
</span><span class="cx">   \ingroup core1
</span><span class="cx">   \{
</span><span class="cx"> */
</span><del>-#ifndef _SWITCH_STUN_PARSER_H
-#define _SWITCH_STUN_PARSER_H
</del><ins>+#ifndef FREESWITCH_STUN_PARSER_H
+#define FREESWITCH_STUN_PARSER_H
</ins><span class="cx"> 
</span><span class="cx"> SWITCH_BEGIN_EXTERN_C
</span><span class="cx"> #define SWITCH_STUN_DEFAULT_PORT 3478
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_typesh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_types.h (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_types.h        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/include/switch_types.h        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -141,6 +141,7 @@
</span><span class="cx"> #define SWITCH_API_HANGUP_HOOK_VARIABLE &quot;api_hangup_hook&quot;
</span><span class="cx"> #define SWITCH_SESSION_IN_HANGUP_HOOK_VARIABLE &quot;session_in_hangup_hook&quot;
</span><span class="cx"> #define SWITCH_PROCESS_CDR_VARIABLE &quot;process_cdr&quot;
</span><ins>+#define SWITCH_FORCE_PROCESS_CDR_VARIABLE &quot;force_process_cdr&quot;
</ins><span class="cx"> #define SWITCH_BRIDGE_CHANNEL_VARIABLE &quot;bridge_channel&quot;
</span><span class="cx"> #define SWITCH_CHANNEL_NAME_VARIABLE &quot;channel_name&quot;
</span><span class="cx"> #define SWITCH_BRIDGE_UUID_VARIABLE &quot;bridge_uuid&quot;
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_xmlh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_xml.h (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_xml.h        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/include/switch_xml.h        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -53,8 +53,8 @@
</span><span class="cx">  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-#ifndef _SWITCH_XML_H
-#define _SWITCH_XML_H
</del><ins>+#ifndef FREESWITCH_XML_H
+#define FREESWITCH_XML_H
</ins><span class="cx"> #include &lt;switch.h&gt;
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -413,6 +413,8 @@
</span><span class="cx"> ///\return the section mask
</span><span class="cx"> SWITCH_DECLARE(switch_xml_section_t) switch_xml_parse_section_string(_In_opt_z_ const char *str);
</span><span class="cx"> 
</span><ins>+SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond);
+
</ins><span class="cx"> SWITCH_END_EXTERN_C
</span><span class="cx"> ///\}
</span><span class="cx"> #endif // _SWITCH_XML_H
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_conferencemod_conferencec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -262,6 +262,7 @@
</span><span class="cx">         char *sound_prefix;
</span><span class="cx">         char *special_announce;
</span><span class="cx">         char *auto_record;
</span><ins>+        uint32_t terminate_on_silence;
</ins><span class="cx">         uint32_t max_members;
</span><span class="cx">         char *maxmember_sound;
</span><span class="cx">         uint32_t announce_count;
</span><span class="lines">@@ -336,6 +337,8 @@
</span><span class="cx">         int32_t energy_level;
</span><span class="cx">         int32_t volume_in_level;
</span><span class="cx">         int32_t volume_out_level;
</span><ins>+        switch_time_t join_time;
+        switch_time_t last_talking;
</ins><span class="cx">         uint32_t native_rate;
</span><span class="cx">         switch_audio_resampler_t *read_resampler;
</span><span class="cx">         int16_t *resample_out;
</span><span class="lines">@@ -638,6 +641,7 @@
</span><span class="cx">         switch_mutex_lock(conference-&gt;member_mutex);
</span><span class="cx"> 
</span><span class="cx">         switch_clear_flag(conference, CFLAG_DESTRUCT);
</span><ins>+        member-&gt;join_time = switch_epoch_time_now(NULL);
</ins><span class="cx">         member-&gt;conference = conference;
</span><span class="cx">         member-&gt;next = conference-&gt;members;
</span><span class="cx">         member-&gt;energy_level = conference-&gt;energy_level;
</span><span class="lines">@@ -1045,6 +1049,23 @@
</span><span class="cx">                         switch_mutex_unlock(imember-&gt;audio_in_mutex);
</span><span class="cx">                 }
</span><span class="cx"> 
</span><ins>+                /* Find if no one talked for more than x number of second */
+                if (conference-&gt;terminate_on_silence &amp;&amp; conference-&gt;count &gt; 1) {
+                        int is_talking = 0;
+
+                        for (imember = conference-&gt;members; imember; imember = imember-&gt;next) {
+                                if (switch_epoch_time_now(NULL) - imember-&gt;join_time &lt;= conference-&gt;terminate_on_silence) {
+                                        is_talking++;
+                                } else if (imember-&gt;last_talking != 0 &amp;&amp; switch_epoch_time_now(NULL) - imember-&gt;last_talking &lt;= conference-&gt;terminate_on_silence) {
+                                        is_talking++;
+                                }
+                        }
+                        if (is_talking == 0) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Conference has been idle for over %d seconds, terminating\n&quot;, conference-&gt;terminate_on_silence);
+                                switch_set_flag(conference, CFLAG_DESTRUCT);
+                        }
+                }
+
</ins><span class="cx">                 /* Start recording if there's more than one participant. */
</span><span class="cx">                 if (conference-&gt;auto_record &amp;&amp; !conference-&gt;is_recording &amp;&amp; conference-&gt;count &gt; 1) {
</span><span class="cx">                         conference-&gt;is_recording = 1;
</span><span class="lines">@@ -1912,6 +1933,7 @@
</span><span class="cx"> 
</span><span class="cx">                                 if (diff &gt;= diff_level || ++hangunder_hits &gt;= hangunder) {
</span><span class="cx">                                         hangover_hits = hangunder_hits = 0;
</span><ins>+                                        member-&gt;last_talking = switch_epoch_time_now(NULL);
</ins><span class="cx"> 
</span><span class="cx">                                         if (!switch_test_flag(member, MFLAG_TALKING)) {
</span><span class="cx">                                                 switch_event_t *event;
</span><span class="lines">@@ -3616,6 +3638,12 @@
</span><span class="cx">                 add_x_tag(x_member, &quot;caller_id_number&quot;, profile-&gt;caller_id_number, toff++);
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+                switch_snprintf(i, sizeof(i), &quot;%d&quot;, switch_epoch_time_now(NULL) - member-&gt;join_time);
+                add_x_tag(x_member, &quot;join_time&quot;, i, toff++);
+
+                switch_snprintf(i, sizeof(i), &quot;%d&quot;, switch_epoch_time_now(NULL) - member-&gt;last_talking);
+                add_x_tag(x_member, &quot;last_talking&quot;, member-&gt;last_talking ? i : &quot;N/A&quot;, toff++);
+
</ins><span class="cx">                 x_flags = switch_xml_add_child_d(x_member, &quot;flags&quot;, count++);
</span><span class="cx">                 switch_assert(x_flags);
</span><span class="cx"> 
</span><span class="lines">@@ -5793,6 +5821,7 @@
</span><span class="cx">         char *suppress_events = NULL;
</span><span class="cx">         char *verbose_events = NULL;
</span><span class="cx">         char *auto_record = NULL;
</span><ins>+        char *terminate_on_silence = NULL;
</ins><span class="cx"> 
</span><span class="cx">         /* Validate the conference name */
</span><span class="cx">         if (zstr(name)) {
</span><span class="lines">@@ -5922,6 +5951,8 @@
</span><span class="cx">                                 verbose_events = val;
</span><span class="cx">                         } else if (!strcasecmp(var, &quot;auto-record&quot;) &amp;&amp; !zstr(val)) {
</span><span class="cx">                                 auto_record = val;
</span><ins>+                        } else if (!strcasecmp(var, &quot;terminate-on-silence&quot;) &amp;&amp; !zstr(val)) {
+                                terminate_on_silence = val;
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -6093,6 +6124,9 @@
</span><span class="cx">         if (!zstr(auto_record)) {
</span><span class="cx">                 conference-&gt;auto_record = switch_core_strdup(conference-&gt;pool, auto_record);
</span><span class="cx">         }
</span><ins>+        if (!zstr(terminate_on_silence)) {
+                conference-&gt;terminate_on_silence = atoi(terminate_on_silence);
+        }
</ins><span class="cx"> 
</span><span class="cx">         if (!zstr(verbose_events) &amp;&amp; switch_true(verbose_events)) {
</span><span class="cx">                 conference-&gt;verbose_events = 1;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_exprconioh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_expr/conio.h (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_expr/conio.h        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/applications/mod_expr/conio.h        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -8,8 +8,8 @@
</span><span class="cx">  * Offered for use in the public domain without any warranty.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-#ifndef _CONIO_H_
-#define _CONIO_H_
</del><ins>+#ifndef CONIO_H
+#define CONIO_H
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> #include &lt;stdio.h&gt;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_fifomod_fifoc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -75,6 +75,15 @@
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static switch_bool_t match_key(const char *caller_exit_key, char key)
+{
+        while (caller_exit_key &amp;&amp; *caller_exit_key) {
+                if (*caller_exit_key++ == key) {
+                        return SWITCH_TRUE;
+                }
+        }
+        return SWITCH_FALSE;
+}
</ins><span class="cx"> 
</span><span class="cx"> static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
</span><span class="cx"> {
</span><span class="lines">@@ -131,7 +140,7 @@
</span><span class="cx">                         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">                         const char *caller_exit_key = switch_channel_get_variable(channel, &quot;fifo_caller_exit_key&quot;);
</span><span class="cx"> 
</span><del>-                        if (caller_exit_key &amp;&amp; dtmf-&gt;digit == *caller_exit_key) {
</del><ins>+                        if (match_key(caller_exit_key, dtmf-&gt;digit)) {
</ins><span class="cx">                                 char *bp = buf;
</span><span class="cx">                                 *bp = dtmf-&gt;digit;
</span><span class="cx">                                 return SWITCH_STATUS_BREAK;
</span><span class="lines">@@ -230,9 +239,10 @@
</span><span class="cx">                                 return SWITCH_STATUS_FALSE;
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        if (caller_exit_key &amp;&amp; *buf == *caller_exit_key) {
</del><ins>+                        if (match_key(caller_exit_key, *buf)) {
</ins><span class="cx">                                 cd-&gt;abort = 1;
</span><span class="cx">                                 return SWITCH_STATUS_FALSE;
</span><ins>+                                switch_channel_set_variable(channel, &quot;fifo_caller_exit_key&quot;, (char *)buf);
</ins><span class="cx">                         }
</span><span class="cx">                         cd-&gt;next = switch_epoch_time_now(NULL) + cd-&gt;freq;
</span><span class="cx">                         cd-&gt;index++;
</span><span class="lines">@@ -1051,7 +1061,8 @@
</span><span class="cx">                                 switch_ivr_collect_digits_callback(session, &amp;args, 0, 0);
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        if (caller_exit_key &amp;&amp; *buf == *caller_exit_key) {
</del><ins>+                        if (match_key(caller_exit_key, *buf)) {
+                                switch_channel_set_variable(channel, &quot;fifo_caller_exit_key&quot;, (char *)buf);
</ins><span class="cx">                                 aborted = 1;
</span><span class="cx">                                 goto abort;
</span><span class="cx">                         }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_spymod_spyc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_spy/mod_spy.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_spy/mod_spy.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/applications/mod_spy/mod_spy.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -128,16 +128,17 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void event_handler(switch_event_t *event)
</del><ins>+static switch_status_t process_event(switch_event_t *event)
</ins><span class="cx"> {
</span><span class="cx">         switch_core_session_t *session = NULL;
</span><span class="cx">         switch_channel_t *channel;
</span><del>-        char *username[2] = { 0 };
-        char *domain[2] = { 0 };
</del><ins>+        char *username[3] = { 0 };
+        char *domain[3] = { 0 };
</ins><span class="cx">         char key[512];
</span><span class="cx">         char *uuid = NULL, *my_uuid = NULL;
</span><span class="cx">         int i;
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx">         switch_thread_rwlock_rdlock(globals.spy_hash_lock);
</span><span class="cx"> 
</span><span class="cx">         if (!globals.spy_count) {
</span><span class="lines">@@ -146,10 +147,15 @@
</span><span class="cx"> 
</span><span class="cx">         username[0] = switch_event_get_header(event, &quot;Caller-Username&quot;);
</span><span class="cx">         domain[0] = switch_event_get_header(event, &quot;variable_domain_name&quot;);
</span><ins>+
</ins><span class="cx">         domain[1] = switch_event_get_header(event, &quot;variable_dialed_domain&quot;);
</span><span class="cx">         username[1] = switch_event_get_header(event, &quot;variable_dialed_user&quot;);
</span><span class="cx"> 
</span><del>-        for (i = 0; i &lt; 2; i++) {
</del><ins>+        username[2] = switch_event_get_header(event, &quot;variable_user_name&quot;);
+        domain[2] = switch_event_get_header(event, &quot;variable_domain_name&quot;);
+
+        for (i = 0; i &lt; 3; i++) {
+
</ins><span class="cx">                 if (username[i] &amp;&amp; domain[i]) {
</span><span class="cx">                         switch_snprintf(key, sizeof(key), &quot;%s@%s&quot;, username[i], domain[i]);
</span><span class="cx"> 
</span><span class="lines">@@ -159,11 +165,11 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-  done:
</del><ins>+ done:
</ins><span class="cx">         switch_thread_rwlock_unlock(globals.spy_hash_lock);
</span><span class="cx"> 
</span><span class="cx">         if (!uuid) {
</span><del>-                return;
</del><ins>+                return SWITCH_STATUS_FALSE;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         session = switch_core_session_locate(uuid);
</span><span class="lines">@@ -178,9 +184,46 @@
</span><span class="cx">         switch_channel_set_flag(channel, CF_BREAK);
</span><span class="cx"> 
</span><span class="cx">         switch_core_session_rwunlock(session);
</span><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void event_handler(switch_event_t *event)
+{
+        if (process_event(event) != SWITCH_STATUS_SUCCESS) {
+                const char *peer_uuid = switch_event_get_header(event, &quot;variable_signal_bond&quot;);
+                switch_core_session_t *peer_session = NULL;
+                switch_channel_t *peer_channel = NULL;
+                switch_event_t *peer_event = NULL;
+                
+                if (!peer_uuid) {
+                        return;
+                }
+
+                if (!(peer_session = switch_core_session_locate(peer_uuid))) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Cant locate peer session for uuid %s\n&quot;, peer_uuid);
+                        return;
+                }
+
+                peer_channel = switch_core_session_get_channel(peer_session);
+                
+                if (switch_event_create(&amp;peer_event, SWITCH_EVENT_CHANNEL_BRIDGE) != SWITCH_STATUS_SUCCESS) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Cant create bridge event for peer channel %s\n&quot;, peer_uuid);
+                        goto end;
+                }
+
+                switch_channel_event_set_data(peer_channel, peer_event);
+
+        end:
+                switch_core_session_rwunlock(peer_session);
+
+                if (peer_event) {
+                        process_event(peer_event);
+                        switch_event_destroy(&amp;peer_event);
+                }
+        }
+}
+
</ins><span class="cx"> #define USERSPY_SYNTAX &quot;&lt;user@domain&gt; [uuid]&quot;
</span><span class="cx"> SWITCH_STANDARD_APP(userspy_function)
</span><span class="cx"> {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_t38gatewayudptlh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_t38gateway/udptl.h (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_t38gateway/udptl.h        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/applications/mod_t38gateway/udptl.h        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -22,8 +22,8 @@
</span><span class="cx">  *
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-#if !defined(_UDPTL_H_)
-#define _UDPTL_H_
</del><ins>+#if !defined(FREESWITCH_UDPTL_H)
+#define FREESWITCH_UDPTL_H
</ins><span class="cx"> 
</span><span class="cx"> #define LOCAL_FAX_MAX_DATAGRAM      400
</span><span class="cx"> #define LOCAL_FAX_MAX_FEC_PACKETS   5
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_voicemailmod_voicemailc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -1524,7 +1524,7 @@
</span><span class="cx">                                         TRY_CODE(switch_ivr_phrase_macro(session, VM_INVALID_EXTENSION_MACRO, vm_cc, NULL, NULL));
</span><span class="cx">                                         goto get_exten;
</span><span class="cx">                                 }
</span><del>-                        } else if (!strcmp(input, profile-&gt;delete_file_key) || !strcmp(input, profile-&gt;email_key)) {
</del><ins>+                        } else if (!strcmp(input, profile-&gt;delete_file_key) || (!strcmp(input, profile-&gt;email_key) &amp;&amp; !zstr(cbt-&gt;email))) {
</ins><span class="cx">                                 char *sql = switch_mprintf(&quot;update voicemail_msgs set flags='delete' where uuid='%s'&quot;, cbt-&gt;uuid);
</span><span class="cx">                                 vm_execute_sql(profile, sql, profile-&gt;mutex);
</span><span class="cx">                                 switch_safe_free(sql);
</span><span class="lines">@@ -1681,7 +1681,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-#define FREE_DOMAIN_ROOT() if (x_domain_root) switch_xml_free(x_domain_root); x_user = x_domain = x_domain_root = NULL
</del><ins>+#define FREE_DOMAIN_ROOT() if (x_user) switch_xml_free(x_user); x_user = NULL
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *profile, const char *domain_name, const char *id, int auth)
</span><span class="lines">@@ -1689,7 +1689,7 @@
</span><span class="cx">         vm_check_state_t vm_check_state = VM_CHECK_START;
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_caller_profile_t *caller_profile = switch_channel_get_caller_profile(channel);
</span><del>-        switch_xml_t x_domain = NULL, x_domain_root = NULL, x_user = NULL, x_params, x_param;
</del><ins>+        switch_xml_t x_user = NULL, x_params, x_param;
</ins><span class="cx">         switch_status_t status;
</span><span class="cx">         char pass_buf[80] = &quot;&quot;, *mypass = NULL, id_buf[80] = &quot;&quot;, *myfolder = NULL;
</span><span class="cx">         const char *thepass = NULL, *myid = id, *thehash = NULL, *vmhash = NULL;
</span><span class="lines">@@ -2083,18 +2083,37 @@
</span><span class="cx">                                         switch_event_t *params;
</span><span class="cx">                                         int ok = 1;
</span><span class="cx"> 
</span><del>-
</del><span class="cx">                                         switch_event_create(&amp;params, SWITCH_EVENT_GENERAL);
</span><span class="cx">                                         switch_assert(params);
</span><span class="cx">                                         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;destination_number&quot;, caller_profile-&gt;destination_number);
</span><span class="cx">                                         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;caller_id_number&quot;, caller_id_number);
</span><span class="cx"> 
</span><del>-
-                                        if (switch_xml_locate_user(&quot;id&quot;, myid, domain_name, switch_channel_get_variable(channel, &quot;network_addr&quot;),
-                                                                                           &amp;x_domain_root, &amp;x_domain, &amp;x_user, NULL, params) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                        if (switch_xml_locate_user_merged(&quot;id&quot;, myid, domain_name, switch_channel_get_variable(channel, &quot;network_addr&quot;),
+                                                                                           &amp;x_user, params) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Can't find user [%s@%s]\n&quot;, myid, domain_name);
</span><span class="cx">                                                 ok = 0;
</span><span class="cx">                                         } else {
</span><ins>+                                                switch_bool_t vm_enabled = SWITCH_TRUE;
+
+                                                x_params = switch_xml_child(x_user, &quot;params&quot;);
+
+                                                for (x_param = switch_xml_child(x_params, &quot;param&quot;); x_param; x_param = x_param-&gt;next) {
+                                                        const char *var = switch_xml_attr_soft(x_param, &quot;name&quot;);
+                                                        const char *val = switch_xml_attr_soft(x_param, &quot;value&quot;);
+
+                                                        if (zstr(var) || zstr(val)) {
+                                                                continue; /* Ignore empty entires */
+                                                        }
+
+                                                        if (!strcasecmp(var, &quot;vm-enabled&quot;)) {
+                                                                vm_enabled = !switch_false(val);
+                                                        }
+                                                }
+
+                                                if (!vm_enabled) {
+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;User [%s@%s] have voicemail disabled\n&quot;, myid, domain_name);
+                                                        ok = 0;
+                                                }
</ins><span class="cx">                                                 myid = switch_core_session_strdup(session, switch_xml_attr(x_user, &quot;id&quot;));
</span><span class="cx">                                         }
</span><span class="cx"> 
</span><span class="lines">@@ -2261,9 +2280,9 @@
</span><span class="cx">                 status = switch_ivr_phrase_macro(session, VM_GOODBYE_MACRO, NULL, NULL, NULL);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (x_domain_root) {
-                switch_xml_free(x_domain_root);
-                x_domain_root = NULL;
</del><ins>+        if (x_user) {
+                switch_xml_free(x_user);
+                x_user = NULL;
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2836,6 +2855,7 @@
</span><span class="cx">         int disk_quota = 0;
</span><span class="cx">         switch_bool_t skip_greeting = switch_true(switch_channel_get_variable(channel, &quot;skip_greeting&quot;));
</span><span class="cx">         switch_bool_t skip_instructions = switch_true(switch_channel_get_variable(channel, &quot;skip_instructions&quot;));
</span><ins>+        switch_bool_t vm_enabled = SWITCH_TRUE;
</ins><span class="cx"> 
</span><span class="cx">         switch_channel_set_variable(channel, &quot;skip_greeting&quot;, NULL);
</span><span class="cx">         switch_channel_set_variable(channel, &quot;skip_instructions&quot;, NULL);
</span><span class="lines">@@ -2888,12 +2908,19 @@
</span><span class="cx">                                                 disk_quota = atoi(val);
</span><span class="cx">                                         } else if (!strcasecmp(var, &quot;vm-alternate-greet-id&quot;)) {
</span><span class="cx">                                                 read_id = switch_core_session_strdup(session, val);
</span><ins>+                                        } else if (!strcasecmp(var, &quot;vm-enabled&quot;)) {
+                                                vm_enabled = !switch_false(val);
</ins><span class="cx">                                         } else if (!strcasecmp(var, &quot;vm-message-ext&quot;)) {
</span><span class="cx">                                                 vm_ext = switch_core_session_strdup(session, val);
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx"> 
</span><ins>+                        if (!vm_enabled) {
+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;User [%s@%s] have voicemail disabled\n&quot;, id, domain_name);
+                                ok = 0;
+                        }
+
</ins><span class="cx">                         if (send_main &amp;&amp; zstr(vm_email) &amp;&amp; !zstr(email_addr)) {
</span><span class="cx">                                 vm_email = switch_core_session_strdup(session, email_addr);
</span><span class="cx">                                 if (zstr(vm_email)) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmoddialplansmod_dialplan_xmlmod_dialplan_xmlc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -101,19 +101,7 @@
</span><span class="cx">                 switch_bool_t anti_action = SWITCH_TRUE;
</span><span class="cx">                 break_t do_break_i = BREAK_ON_FALSE;
</span><span class="cx"> 
</span><del>-                const char *xyear = switch_xml_attr(xcond, &quot;year&quot;);
-                const char *xyday = switch_xml_attr(xcond, &quot;yday&quot;);
-                const char *xmon = switch_xml_attr(xcond, &quot;mon&quot;);
-                const char *xmday = switch_xml_attr(xcond, &quot;mday&quot;);
-                const char *xweek = switch_xml_attr(xcond, &quot;week&quot;);
-                const char *xmweek = switch_xml_attr(xcond, &quot;mweek&quot;);
-                const char *xwday = switch_xml_attr(xcond, &quot;wday&quot;);
-                const char *xhour = switch_xml_attr(xcond, &quot;hour&quot;);
-                const char *xminute = switch_xml_attr(xcond, &quot;minute&quot;);
-                const char *xminday = switch_xml_attr(xcond, &quot;minute-of-day&quot;);
-                switch_time_t ts = switch_micro_time_now();
-                int time_match = -1;
-                switch_time_exp_t tm;
</del><ins>+                int time_match = switch_xml_std_datetime_check(xcond);
</ins><span class="cx"> 
</span><span class="cx">                 switch_safe_free(field_expanded);
</span><span class="cx">                 switch_safe_free(expression_expanded);
</span><span class="lines">@@ -124,81 +112,6 @@
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                switch_time_exp_lt(&amp;tm, ts);
-
-                if (time_match &amp;&amp; xyear) {
-                        int test = tm.tm_year + 1900;
-                        time_match = switch_number_cmp(xyear, test);
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
-                                                          &quot;Dialplan: year[%d] =~ %s (%s)\n&quot;, test, xyear, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
-                }
-
-                if (time_match &amp;&amp; xyday) {
-                        int test = tm.tm_yday + 1;
-                        time_match = switch_number_cmp(xyday, test);
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
-                                                          &quot;Dialplan: day of year[%d] =~ %s (%s)\n&quot;, test, xyday, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
-                }
-
-                if (time_match &amp;&amp; xmon) {
-                        int test = tm.tm_mon + 1;
-                        time_match = switch_number_cmp(xmon, test);
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
-                                                          &quot;Dialplan: month[%d] =~ %s (%s)\n&quot;, test, xmon, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
-                }
-
-                if (time_match &amp;&amp; xmday) {
-                        int test = tm.tm_mday;
-                        time_match = switch_number_cmp(xmday, test);
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
-                                                          &quot;Dialplan: day of month[%d] =~ %s (%s)\n&quot;, test, xmday, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
-                }
-
-                if (time_match &amp;&amp; xweek) {
-                        int test = (int) (tm.tm_yday / 7 + 1);
-                        time_match = switch_number_cmp(xweek, test);
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
-                                                          &quot;Dialplan: week of year[%d] =~ %s (%s)\n&quot;, test, xweek, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
-                }
-
-                if (time_match &amp;&amp; xmweek) {
-                        /* calculate the day of the week of the first of the month (0-6) */
-                        int firstdow = (int) (7 - (tm.tm_mday - (tm.tm_wday + 1)) % 7) % 7;
-                        /* calculate the week of the month (1-6) */
-                        int test = (int) ceil((tm.tm_mday + firstdow) / 7.0);
-                        time_match = switch_number_cmp(xmweek, test);
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
-                                                          &quot;Dialplan: week of month[%d] =~ %s (%s)\n&quot;, test, xmweek, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
-                }
-
-                if (time_match &amp;&amp; xwday) {
-                        int test = tm.tm_wday + 1;
-                        time_match = switch_number_cmp(xwday, test);
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
-                                                          &quot;Dialplan: day of week[%d] =~ %s (%s)\n&quot;, test, xwday, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
-                }
-
-                if (time_match &amp;&amp; xhour) {
-                        int test = tm.tm_hour;
-                        time_match = switch_number_cmp(xhour, test);
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
-                                                          &quot;Dialplan: hour[%d] =~ %s (%s)\n&quot;, test, xhour, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
-                }
-
-                if (time_match &amp;&amp; xminute) {
-                        int test = tm.tm_min;
-                        time_match = switch_number_cmp(xminute, test);
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
-                                                          &quot;Dialplan: minute[%d] =~ %s (%s)\n&quot;, test, xminute, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
-                }
-
-                if (time_match &amp;&amp; xminday) {
-                        int test = (tm.tm_hour * 60) + (tm.tm_min + 1);
-                        time_match = switch_number_cmp(xminday, test);
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
-                                                          &quot;Dialplan: minute of day[%d] =~ %s (%s)\n&quot;, test, xminday, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
-                }
-
</del><span class="cx">                 field = (char *) switch_xml_attr(xcond, &quot;field&quot;);
</span><span class="cx"> 
</span><span class="cx">                 if ((xexpression = switch_xml_child(xcond, &quot;expression&quot;))) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_portaudiopablioh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.h (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.h        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.h        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><del>-#ifndef _PABLIO_H
-#define _PABLIO_H
</del><ins>+#ifndef PORTAUDIO_PABLIO_H
+#define PORTAUDIO_PABLIO_H
</ins><span class="cx"> 
</span><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> extern &quot;C&quot; {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiamod_sofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -392,7 +392,13 @@
</span><span class="cx">         switch_call_cause_t cause = switch_channel_get_cause(channel);
</span><span class="cx">         int sip_cause = hangup_cause_to_sip(cause);
</span><span class="cx">         const char *ps_cause = NULL, *use_my_cause;
</span><ins>+        const char *gateway_name = NULL;
+        sofia_gateway_t *gateway_ptr = NULL;
</ins><span class="cx"> 
</span><ins>+        if ((gateway_name = switch_channel_get_variable(channel, &quot;sip_gateway_name&quot;))) {
+                gateway_ptr = sofia_reg_find_gateway(gateway_name);
+        }
+        
</ins><span class="cx">         switch_mutex_lock(tech_pvt-&gt;sofia_mutex);
</span><span class="cx"> 
</span><span class="cx">         sofia_clear_flag(tech_pvt, TFLAG_RECOVERING);
</span><span class="lines">@@ -405,7 +411,19 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         tech_pvt-&gt;profile-&gt;ib_failed_calls++;
</span><span class="cx">                 }
</span><ins>+                
+                if (gateway_ptr) {
+                        if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
+                                gateway_ptr-&gt;ob_failed_calls++;
+                        } else {
+                                gateway_ptr-&gt;ib_failed_calls++;
+                        }
+                }                
</ins><span class="cx">         }
</span><ins>+        
+        if (gateway_ptr) {
+                sofia_reg_release_gateway(gateway_ptr);
+        }
</ins><span class="cx"> 
</span><span class="cx">         if (!((use_my_cause = switch_channel_get_variable(channel, &quot;sip_ignore_remote_cause&quot;)) &amp;&amp; switch_true(use_my_cause))) {
</span><span class="cx">                 ps_cause = switch_channel_get_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE);
</span><span class="lines">@@ -2086,7 +2104,14 @@
</span><span class="cx">         return sofia_state_names[state];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+struct cb_helper_sql2str {
+        char *buf;
+        size_t len;
+        int matches;
+};
+
</ins><span class="cx"> struct cb_helper {
</span><ins>+        uint32_t row_process;
</ins><span class="cx">         sofia_profile_t *profile;
</span><span class="cx">         switch_stream_handle_t *stream;
</span><span class="cx"> };
</span><span class="lines">@@ -2097,12 +2122,17 @@
</span><span class="cx"> {
</span><span class="cx">         struct cb_helper *cb = (struct cb_helper *) pArg;
</span><span class="cx">         char exp_buf[128] = &quot;&quot;;
</span><ins>+        int exp_secs = 0;
</ins><span class="cx">         switch_time_exp_t tm;
</span><span class="cx"> 
</span><ins>+        cb-&gt;row_process++;
+
</ins><span class="cx">         if (argv[6]) {
</span><ins>+                time_t now = switch_epoch_time_now(NULL);
</ins><span class="cx">                 switch_time_t etime = atoi(argv[6]);
</span><span class="cx">                 switch_size_t retsize;
</span><del>-
</del><ins>+                
+                exp_secs = etime - now;
</ins><span class="cx">                 switch_time_exp_lt(&amp;tm, switch_time_from_sec(etime));
</span><span class="cx">                 switch_strftime_nocheck(exp_buf, &amp;retsize, sizeof(exp_buf), &quot;%Y-%m-%d %T&quot;, &amp;tm);
</span><span class="cx">         }
</span><span class="lines">@@ -2112,7 +2142,7 @@
</span><span class="cx">                                                            &quot;User:       \t%s@%s\n&quot;
</span><span class="cx">                                                            &quot;Contact:    \t%s\n&quot;
</span><span class="cx">                                                            &quot;Agent:      \t%s\n&quot;
</span><del>-                                                           &quot;Status:     \t%s(%s) EXP(%s)\n&quot;
</del><ins>+                                                           &quot;Status:     \t%s(%s) EXP(%s) EXPSECS(%d)\n&quot;
</ins><span class="cx">                                                            &quot;Host:       \t%s\n&quot;
</span><span class="cx">                                                            &quot;IP:         \t%s\n&quot;
</span><span class="cx">                                                            &quot;Port:       \t%s\n&quot;
</span><span class="lines">@@ -2120,7 +2150,7 @@
</span><span class="cx">                                                            &quot;Auth-Realm: \t%s\n&quot;
</span><span class="cx">                                                            &quot;MWI-Account:\t%s@%s\n\n&quot;,
</span><span class="cx">                                                            switch_str_nil(argv[0]), switch_str_nil(argv[1]), switch_str_nil(argv[2]), switch_str_nil(argv[3]),
</span><del>-                                                           switch_str_nil(argv[7]), switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf, switch_str_nil(argv[11]),
</del><ins>+                                                           switch_str_nil(argv[7]), switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf, exp_secs, switch_str_nil(argv[11]),
</ins><span class="cx">                                                            switch_str_nil(argv[12]), switch_str_nil(argv[13]), switch_str_nil(argv[14]), switch_str_nil(argv[15]),
</span><span class="cx">                                                            switch_str_nil(argv[16]), switch_str_nil(argv[17]));
</span><span class="cx">         return 0;
</span><span class="lines">@@ -2133,11 +2163,16 @@
</span><span class="cx">         switch_time_exp_t tm;
</span><span class="cx">         const int buflen = 2048;
</span><span class="cx">         char xmlbuf[2048];
</span><ins>+        int exp_secs = 0;
</ins><span class="cx"> 
</span><ins>+        cb-&gt;row_process++;
+
</ins><span class="cx">         if (argv[6]) {
</span><ins>+                time_t now = switch_epoch_time_now(NULL);
</ins><span class="cx">                 switch_time_t etime = atoi(argv[6]);
</span><span class="cx">                 switch_size_t retsize;
</span><span class="cx"> 
</span><ins>+                exp_secs = etime - now;
</ins><span class="cx">                 switch_time_exp_lt(&amp;tm, switch_time_from_sec(etime));
</span><span class="cx">                 switch_strftime_nocheck(exp_buf, &amp;retsize, sizeof(exp_buf), &quot;%Y-%m-%d %T&quot;, &amp;tm);
</span><span class="cx">         }
</span><span class="lines">@@ -2147,7 +2182,7 @@
</span><span class="cx">         cb-&gt;stream-&gt;write_function(cb-&gt;stream,&quot;        &lt;user&gt;%s@%s&lt;/user&gt;\n&quot;, switch_str_nil(argv[1]), switch_str_nil(argv[2]));
</span><span class="cx">         cb-&gt;stream-&gt;write_function(cb-&gt;stream,&quot;        &lt;contact&gt;%s&lt;/contact&gt;\n&quot;, switch_amp_encode(switch_str_nil(argv[3]), xmlbuf, buflen));
</span><span class="cx">         cb-&gt;stream-&gt;write_function(cb-&gt;stream,&quot;        &lt;agent&gt;%s&lt;/agent&gt;\n&quot;, switch_str_nil(argv[7]));
</span><del>-        cb-&gt;stream-&gt;write_function(cb-&gt;stream,&quot;        &lt;status&gt;%s(%s) exp(%s)&lt;/status&gt;\n&quot;, switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf);
</del><ins>+        cb-&gt;stream-&gt;write_function(cb-&gt;stream,&quot;        &lt;status&gt;%s(%s) exp(%s) expsecs(%d)&lt;/status&gt;\n&quot;, switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf, exp_secs);
</ins><span class="cx">         cb-&gt;stream-&gt;write_function(cb-&gt;stream,&quot;        &lt;host&gt;%s&lt;/host&gt;\n&quot;, switch_str_nil(argv[11]));
</span><span class="cx">         cb-&gt;stream-&gt;write_function(cb-&gt;stream,&quot;        &lt;network-ip&gt;%s&lt;/network-ip&gt;\n&quot;, switch_str_nil(argv[12]));
</span><span class="cx">         cb-&gt;stream-&gt;write_function(cb-&gt;stream,&quot;        &lt;network-port&gt;%s&lt;/network-port&gt;\n&quot;, switch_str_nil(argv[13]));
</span><span class="lines">@@ -2175,7 +2210,56 @@
</span><span class="cx"> 
</span><span class="cx">         if (argc &gt; 0) {
</span><span class="cx">                 if (argc == 1) {
</span><del>-                        stream-&gt;write_function(stream, &quot;Invalid Syntax!\n&quot;);
</del><ins>+                        /* show summary of all gateways*/
+
+                        uint32_t ib_failed = 0;
+                        uint32_t ib = 0;
+                        uint32_t ob_failed = 0;
+                        uint32_t ob = 0;
+
+                        stream-&gt;write_function(stream, &quot;%25s\t%32s\t%s\t%s\t%s\n&quot;, &quot;Profile::Gateway-Name&quot;, &quot;    Data    &quot;, &quot;State&quot;, &quot;IB Calls(F/T)&quot;, &quot;OB Calls(F/T)&quot;);
+                        stream-&gt;write_function(stream, &quot;%s\n&quot;, line);
+                        switch_mutex_lock(mod_sofia_globals.hash_mutex);
+                        for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+                                switch_hash_this(hi, &amp;vvar, NULL, &amp;val);
+                                profile = (sofia_profile_t *) val;
+                                if (sofia_test_pflag(profile, PFLAG_RUNNING)) {
+
+                                        if (!strcmp(vvar, profile-&gt;name)) { /* not an alias */
+                                                for (gp = profile-&gt;gateways; gp; gp = gp-&gt;next) {
+                                                        char *pkey = switch_mprintf(&quot;%s::%s&quot;, profile-&gt;name, gp-&gt;name);
+
+                                                        switch_assert(gp-&gt;state &lt; REG_STATE_LAST);
+
+                                                        c++;
+                                                        ib_failed += gp-&gt;ib_failed_calls;
+                                                        ib += gp-&gt;ib_calls;
+                                                        ob_failed += gp-&gt;ob_failed_calls;
+                                                        ob += gp-&gt;ob_calls;
+
+                                                        stream-&gt;write_function(stream, &quot;%25s\t%32s\t%s\t%ld/%ld\t%ld/%ld&quot;, 
+                                                                pkey, gp-&gt;register_to, sofia_state_names[gp-&gt;state],
+                                                                gp-&gt;ib_failed_calls, gp-&gt;ib_calls, gp-&gt;ob_failed_calls, gp-&gt;ob_calls);
+
+                                                        if (gp-&gt;state == REG_STATE_FAILED || gp-&gt;state == REG_STATE_TRYING) {
+                                                                time_t now = switch_epoch_time_now(NULL);
+                                                                if (gp-&gt;retry &gt; now) {
+                                                                        stream-&gt;write_function(stream, &quot; (retry: %ds)&quot;, gp-&gt;retry - now);
+                                                                } else {
+                                                                        stream-&gt;write_function(stream, &quot; (retry: NEVER)&quot;);
+                                                                }
+                                                        }
+                                                        stream-&gt;write_function(stream, &quot;\n&quot;);
+                                                }
+                                        }
+                                }
+                        }
+                        switch_mutex_unlock(mod_sofia_globals.hash_mutex);
+                        stream-&gt;write_function(stream, &quot;%s\n&quot;, line);
+                        stream-&gt;write_function(stream, &quot;%d gateway%s: Inound(Failed/Total): %ld/%ld,&quot;
+                                &quot;Outbound(Failed/Total):%ld/%ld\n&quot;, c, c == 1 ? &quot;&quot; : &quot;s&quot;,
+                                ib_failed, ib, ob_failed, ob);
+
</ins><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -2205,6 +2289,8 @@
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;Status  \t%s%s\n&quot;, status_names[gp-&gt;status], gp-&gt;pinging ? &quot; (ping)&quot; : &quot;&quot;);
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;CallsIN \t%d\n&quot;, gp-&gt;ib_calls);
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;CallsOUT\t%d\n&quot;, gp-&gt;ob_calls);
</span><ins>+                                stream-&gt;write_function(stream, &quot;FailedCallsIN\t%d\n&quot;, gp-&gt;ib_failed_calls);
+                                stream-&gt;write_function(stream, &quot;FailedCallsOUT\t%d\n&quot;, gp-&gt;ob_failed_calls);
</ins><span class="cx">                                 stream-&gt;write_function(stream, &quot;%s\n&quot;, line);
</span><span class="cx">                                 sofia_reg_release_gateway(gp);
</span><span class="cx">                         } else {
</span><span class="lines">@@ -2213,7 +2299,7 @@
</span><span class="cx">                 } else if (!strcasecmp(argv[0], &quot;profile&quot;)) {
</span><span class="cx">                         struct cb_helper cb;
</span><span class="cx">                         char *sql = NULL;
</span><del>-
</del><ins>+                        cb.row_process = 0;
</ins><span class="cx">                         if ((argv[1]) &amp;&amp; (profile = sofia_glue_find_profile(argv[1]))) {
</span><span class="cx">                                 if (!argv[2] || (strcasecmp(argv[2], &quot;reg&quot;) &amp;&amp; strcasecmp(argv[2], &quot;user&quot;))) {
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;%s\n&quot;, line);
</span><span class="lines">@@ -2334,6 +2420,7 @@
</span><span class="cx">                                 sofia_glue_execute_sql_callback(profile, profile-&gt;ireg_mutex, sql, show_reg_callback, &amp;cb);
</span><span class="cx">                                 switch_safe_free(sql);
</span><span class="cx"> 
</span><ins>+                                stream-&gt;write_function(stream, &quot;Total items returned: %d\n&quot;, cb.row_process);
</ins><span class="cx">                                 stream-&gt;write_function(stream, &quot;%s\n&quot;, line);
</span><span class="cx"> 
</span><span class="cx">                                 sofia_glue_release_profile(profile);
</span><span class="lines">@@ -2412,7 +2499,46 @@
</span><span class="cx"> 
</span><span class="cx">         if (argc &gt; 0) {
</span><span class="cx">                 if (argc == 1) {
</span><del>-                        stream-&gt;write_function(stream, &quot;Invalid Syntax!\n&quot;);
</del><ins>+                         /* show summary of all gateways */
+
+                         stream-&gt;write_function(stream, &quot;%s\n&quot;, header);
+                         stream-&gt;write_function(stream, &quot;&lt;gateways&gt;\n&quot;, header);
+                         
+                         switch_mutex_lock(mod_sofia_globals.hash_mutex);
+                         for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+                                 switch_hash_this(hi, &amp;vvar, NULL, &amp;val);
+                                 profile = (sofia_profile_t *) val;
+                                 if (sofia_test_pflag(profile, PFLAG_RUNNING)) {

+                                         if (!strcmp(vvar, profile-&gt;name)) { /* not an alias */
+                                                 for (gp = profile-&gt;gateways; gp; gp = gp-&gt;next) {
+                                                         switch_assert(gp-&gt;state &lt; REG_STATE_LAST);
+                                                         
+                                                         stream-&gt;write_function(stream, &quot;\t&lt;gateway&gt;\n&quot;);
+                                                         stream-&gt;write_function(stream, &quot;\t\t&lt;profile&gt;%s&lt;/profile&gt;\n&quot;, profile-&gt;name);
+                                                         stream-&gt;write_function(stream, &quot;\t\t&lt;to&gt;%s&lt;/to&gt;\n&quot;, gp-&gt;register_to);
+                                                         stream-&gt;write_function(stream, &quot;\t\t&lt;state&gt;%s&lt;/state&gt;\n&quot;, sofia_state_names[gp-&gt;state]);
+                                                         stream-&gt;write_function(stream, &quot;\t\t&lt;calls-in&gt;%ld&lt;/calls-in&gt;\n&quot;, gp-&gt;ib_calls);
+                                                         stream-&gt;write_function(stream, &quot;\t\t&lt;calls-out&gt;%ld&lt;/calls-out&gt;\n&quot;, gp-&gt;ob_calls);
+                                                         stream-&gt;write_function(stream, &quot;\t\t&lt;failed-calls-in&gt;%ld&lt;/failed-calls-in&gt;\n&quot;, gp-&gt;ib_failed_calls);
+                                                         stream-&gt;write_function(stream, &quot;\t\t&lt;failed-calls-out&gt;%ld&lt;/failed-calls-out&gt;\n&quot;, gp-&gt;ob_failed_calls);

+                                                         if (gp-&gt;state == REG_STATE_FAILED || gp-&gt;state == REG_STATE_TRYING) {
+                                                                 time_t now = switch_epoch_time_now(NULL);
+                                                                 if (gp-&gt;retry &gt; now) {
+                                                                         stream-&gt;write_function(stream, &quot;\t\t&lt;retry&gt;%ds&lt;/retry&gt;\n&quot;, gp-&gt;retry - now);
+                                                                 } else {
+                                                                         stream-&gt;write_function(stream, &quot;\t\t&lt;retry&gt;NEVER&lt;/retry&gt;\n&quot;);
+                                                                 }
+                                                         }
+                                                         stream-&gt;write_function(stream, &quot;\t&lt;/gateway&gt;\n&quot;);
+                                                 }
+                                         }
+                                 }
+                         }
+                         switch_mutex_unlock(mod_sofia_globals.hash_mutex);                         
+                         stream-&gt;write_function(stream, &quot;&lt;/gateways&gt;\n&quot;);
+
</ins><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 }
</span><span class="cx">                 if (!strcasecmp(argv[0], &quot;gateway&quot;)) {
</span><span class="lines">@@ -2440,7 +2566,8 @@
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;    &lt;status&gt;%s%s&lt;/status&gt;\n&quot;, status_names[gp-&gt;status], gp-&gt;pinging ? &quot; (ping)&quot; : &quot;&quot;);
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;    &lt;calls-in&gt;%d&lt;/calls-in&gt;\n&quot;, gp-&gt;ib_calls);
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;    &lt;calls-out&gt;%d&lt;/calls-out&gt;\n&quot;, gp-&gt;ob_calls);
</span><del>-
</del><ins>+                                stream-&gt;write_function(stream, &quot;    &lt;failed-calls-in&gt;%d&lt;/calls-in&gt;\n&quot;, gp-&gt;ib_failed_calls);
+                                stream-&gt;write_function(stream, &quot;    &lt;failed-calls-out&gt;%d&lt;/calls-out&gt;\n&quot;, gp-&gt;ob_failed_calls);
</ins><span class="cx">                                 stream-&gt;write_function(stream, &quot;  &lt;/gateway&gt;\n&quot;);
</span><span class="cx">                                 sofia_reg_release_gateway(gp);
</span><span class="cx">                         } else {
</span><span class="lines">@@ -2449,6 +2576,7 @@
</span><span class="cx">                 } else if (!strcasecmp(argv[0], &quot;profile&quot;)) {
</span><span class="cx">                         struct cb_helper cb;
</span><span class="cx">                         char *sql = NULL;
</span><ins>+                        cb.row_process = 0;
</ins><span class="cx"> 
</span><span class="cx">                         if ((argv[1]) &amp;&amp; (profile = sofia_glue_find_profile(argv[1]))) {
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;%s\n&quot;, header);
</span><span class="lines">@@ -2867,6 +2995,8 @@
</span><span class="cx">         struct cb_helper *cb = (struct cb_helper *) pArg;
</span><span class="cx">         char *contact;
</span><span class="cx"> 
</span><ins>+        cb-&gt;row_process++;
+
</ins><span class="cx">         if (!zstr(argv[0]) &amp;&amp; (contact = sofia_glue_get_url_from_contact(argv[0], 1))) {
</span><span class="cx">                 cb-&gt;stream-&gt;write_function(cb-&gt;stream, &quot;%ssofia/%s/sip:%s,&quot;, argv[2], argv[1], sofia_glue_strip_proto(contact));
</span><span class="cx">                 free(contact);
</span><span class="lines">@@ -2874,7 +3004,115 @@
</span><span class="cx"> 
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><ins>+static int sql2str_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
+        struct cb_helper_sql2str *cbt = (struct cb_helper_sql2str *) pArg;
</ins><span class="cx"> 
</span><ins>+        switch_copy_string(cbt-&gt;buf, argv[0], cbt-&gt;len);
+        cbt-&gt;matches++;
+        return 0;
+}
+
+SWITCH_STANDARD_API(sofia_count_reg_function) {
+        char *data;
+        char *user = NULL;
+        char *domain = NULL;
+        char *concat = NULL;
+        char *profile_name = NULL;
+        char *p;
+        char *reply = &quot;-1&quot;;
+        sofia_profile_t *profile = NULL;
+        
+        if (!cmd) {
+                stream-&gt;write_function(stream, &quot;%s&quot;, &quot;&quot;);
+                return SWITCH_STATUS_SUCCESS;
+        }
+
+        data = strdup(cmd);
+        switch_assert(data);
+
+        if ((p = strchr(data, '/'))) {
+                profile_name = data;
+                *p++ = '\0';
+                user = p;
+        } else {
+                user = data;
+        }
+
+        if ((domain = strchr(user, '@'))) {
+                *domain++ = '\0';
+                if ( (concat = strchr( domain, '/')) ) {
+                    *concat++ = '\0';
+                }
+        }
+        else {
+                if ( (concat = strchr( user, '/')) ) {
+                    *concat++ = '\0';
+                }
+        }
+
+        if (!profile_name &amp;&amp; domain) {
+                profile_name = domain;
+        }
+
+        if (user &amp;&amp; profile_name) {
+                char *sql;
+
+                if (!(profile = sofia_glue_find_profile(profile_name))) {
+                        profile_name = domain;
+                        domain = NULL;
+                }
+
+                if (!profile &amp;&amp; profile_name) {
+                        profile = sofia_glue_find_profile(profile_name);
+                }
+
+                if (profile) {
+                        struct cb_helper_sql2str cb;
+                        char reg_count[80] = &quot;&quot;;
+
+                        cb.buf = reg_count;
+                        cb.len = sizeof(reg_count);
+
+                        if (!domain || !strchr(domain, '.')) {
+                                domain = profile-&gt;name;
+                        }
+
+                        if (zstr(user)) {
+                                sql = switch_mprintf(&quot;select count(*) &quot;
+                                                &quot;from sip_registrations where (sip_host='%q' or presence_hosts like '%%%q%%')&quot;,
+                                                ( concat != NULL ) ? concat : &quot;&quot;, domain, domain);
+
+                        } else {
+                                sql = switch_mprintf(&quot;select count(*) &quot;
+                                                &quot;from sip_registrations where (sip_user='%q' or dir_user='%q') and (sip_host='%q' or presence_hosts like '%%%q%%')&quot;, 
+                                                ( concat != NULL ) ? concat : &quot;&quot;, user, user, domain, domain);
+                        }
+                        switch_assert(sql);
+                        sofia_glue_execute_sql_callback(profile, profile-&gt;ireg_mutex, sql, sql2str_callback, &amp;cb);
+                        switch_safe_free(sql);
+                        if (!zstr(reg_count)) {
+                                stream-&gt;write_function(stream, &quot;%s&quot;, reg_count);
+                        } else {
+                                stream-&gt;write_function(stream, &quot;0&quot;);
+                        }
+                        reply = NULL;
+                        
+                }
+        }
+
+        if (reply) {
+                stream-&gt;write_function(stream, &quot;%s&quot;, reply);
+        }
+
+        switch_safe_free(data);
+
+        if (profile) {
+                sofia_glue_release_profile(profile);
+        }
+
+        return SWITCH_STATUS_SUCCESS;
+}
</ins><span class="cx"> SWITCH_STANDARD_API(sofia_contact_function)
</span><span class="cx"> {
</span><span class="cx">         char *data;
</span><span class="lines">@@ -2940,6 +3178,8 @@
</span><span class="cx">                         struct cb_helper cb;
</span><span class="cx">                         switch_stream_handle_t mystream = { 0 };
</span><span class="cx"> 
</span><ins>+                        cb.row_process = 0;
+
</ins><span class="cx">                         if (!domain || (!strchr(domain, '.') &amp;&amp; strcmp(profile_name, domain))) {
</span><span class="cx">                                 domain = profile-&gt;name;
</span><span class="cx">                         }
</span><span class="lines">@@ -3255,6 +3495,7 @@
</span><span class="cx">                 if (gateway_ptr-&gt;status != SOFIA_GATEWAY_UP) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Gateway is down!\n&quot;);
</span><span class="cx">                         cause = SWITCH_CAUSE_NETWORK_OUT_OF_ORDER;
</span><ins>+                        gateway_ptr-&gt;ob_failed_calls++;
</ins><span class="cx">                         sofia_reg_release_gateway(gateway_ptr);
</span><span class="cx">                         gateway_ptr = NULL;
</span><span class="cx">                         goto error;
</span><span class="lines">@@ -3280,6 +3521,7 @@
</span><span class="cx">                                 tech_pvt-&gt;transport = sofia_glue_str2transport(tp_param);
</span><span class="cx">                                 if (tech_pvt-&gt;transport == SOFIA_TRANSPORT_UNKNOWN) {
</span><span class="cx">                                         cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</span><ins>+                                        gateway_ptr-&gt;ob_failed_calls++;
</ins><span class="cx">                                         goto error;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="lines">@@ -4161,6 +4403,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">         SWITCH_ADD_API(api_interface, &quot;sofia_contact&quot;, &quot;Sofia Contacts&quot;, sofia_contact_function, &quot;[profile/]&lt;user&gt;@&lt;domain&gt;&quot;);
</span><ins>+        SWITCH_ADD_API(api_interface, &quot;sofia_count_reg&quot;, &quot;Count Sofia registration&quot;, sofia_count_reg_function, &quot;[profile/]&lt;user&gt;@&lt;domain&gt;&quot;);
</ins><span class="cx">         SWITCH_ADD_API(api_interface, &quot;sofia_dig&quot;, &quot;SIP DIG&quot;, sip_dig_function, &quot;&lt;url&gt;&quot;);
</span><span class="cx">         SWITCH_ADD_CHAT(chat_interface, SOFIA_CHAT_PROTO, sofia_presence_chat_send);
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiamod_sofiah"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -402,6 +402,8 @@
</span><span class="cx">         switch_event_t *ob_vars;
</span><span class="cx">         uint32_t ib_calls;
</span><span class="cx">         uint32_t ob_calls;
</span><ins>+        uint32_t ib_failed_calls;
+        uint32_t ob_failed_calls;
</ins><span class="cx">         char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
</span><span class="cx">         int failures;
</span><span class="cx">         struct sofia_gateway *next;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -1758,6 +1758,10 @@
</span><span class="cx">                         gateway-&gt;ping_max = 0;
</span><span class="cx">                         gateway-&gt;ping_min = 0;
</span><span class="cx">                         gateway-&gt;ping_count = 0;
</span><ins>+                        gateway-&gt;ib_calls = 0;
+                        gateway-&gt;ob_calls = 0;
+                        gateway-&gt;ib_failed_calls = 0;
+                        gateway-&gt;ob_failed_calls = 0;
</ins><span class="cx"> 
</span><span class="cx">                         if ((x_params = switch_xml_child(gateway_tag, &quot;variables&quot;))) {
</span><span class="cx">                                 param = switch_xml_child(x_params, &quot;variable&quot;);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -2189,6 +2189,7 @@
</span><span class="cx"> 
</span><span class="cx">         if (tech_pvt-&gt;local_sdp_video_port &gt; 0 &amp;&amp; !zstr(tech_pvt-&gt;remote_ip) &amp;&amp; sofia_glue_check_nat(tech_pvt-&gt;profile, tech_pvt-&gt;remote_ip)) {
</span><span class="cx">                 switch_nat_del_mapping((switch_port_t) tech_pvt-&gt;local_sdp_video_port, SWITCH_NAT_UDP);
</span><ins>+                switch_nat_del_mapping((switch_port_t) tech_pvt-&gt;local_sdp_video_port + 1, SWITCH_NAT_UDP);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -2200,6 +2201,7 @@
</span><span class="cx"> 
</span><span class="cx">         if (tech_pvt-&gt;local_sdp_audio_port &gt; 0 &amp;&amp; !zstr(tech_pvt-&gt;remote_ip) &amp;&amp; sofia_glue_check_nat(tech_pvt-&gt;profile, tech_pvt-&gt;remote_ip)) {
</span><span class="cx">                 switch_nat_del_mapping((switch_port_t) tech_pvt-&gt;local_sdp_audio_port, SWITCH_NAT_UDP);
</span><ins>+                switch_nat_del_mapping((switch_port_t) tech_pvt-&gt;local_sdp_audio_port + 1, SWITCH_NAT_UDP);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_presencec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -1901,7 +1901,7 @@
</span><span class="cx">                 full_from = sip_header_as_string(profile-&gt;home, (void *) sip-&gt;sip_from);
</span><span class="cx">                 full_via = sip_header_as_string(profile-&gt;home, (void *) sip-&gt;sip_via);
</span><span class="cx"> 
</span><del>-                if (sip-&gt;sip_expires-&gt;ex_delta &gt; 31536000) {
</del><ins>+                if (sip &amp;&amp; sip-&gt;sip_expires &amp;&amp; sip-&gt;sip_expires-&gt;ex_delta &gt; 31536000) {
</ins><span class="cx">                         sip-&gt;sip_expires-&gt;ex_delta = 31536000;
</span><span class="cx">                 }
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_regc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -1688,6 +1688,7 @@
</span><span class="cx">         const char *passwd = NULL;
</span><span class="cx">         const char *a1_hash = NULL;
</span><span class="cx">         const char *mwi_account = NULL;
</span><ins>+        switch_bool_t allow_empty_password = SWITCH_TRUE;
</ins><span class="cx">         const char *call_id = NULL;
</span><span class="cx">         char *sql;
</span><span class="cx">         char *number_alias = NULL;
</span><span class="lines">@@ -1924,7 +1925,9 @@
</span><span class="cx">                         if (!strcasecmp(var, &quot;mwi-account&quot;)) {
</span><span class="cx">                                 mwi_account = val;
</span><span class="cx">                         }
</span><del>-
</del><ins>+                        if (!strcasecmp(var, &quot;allow-empty-password&quot;)) {
+                                allow_empty_password = switch_true(val);
+                        }
</ins><span class="cx">                         if (!strcasecmp(var, &quot;user-agent-filter&quot;)) {
</span><span class="cx">                                 user_agent_filter = val;
</span><span class="cx">                         }
</span><span class="lines">@@ -1958,7 +1961,9 @@
</span><span class="cx">                         if (!strcasecmp(var, &quot;mwi-account&quot;)) {
</span><span class="cx">                                 mwi_account = val;
</span><span class="cx">                         }
</span><del>-
</del><ins>+                        if (!strcasecmp(var, &quot;allow-empty-password&quot;)) {
+                                allow_empty_password = switch_true(val);
+                        }
</ins><span class="cx">                         if (!strcasecmp(var, &quot;user-agent-filter&quot;)) {
</span><span class="cx">                                 user_agent_filter = val;
</span><span class="cx">                         }
</span><span class="lines">@@ -1992,6 +1997,9 @@
</span><span class="cx">                         if (!strcasecmp(var, &quot;mwi-account&quot;)) {
</span><span class="cx">                                 mwi_account = val;
</span><span class="cx">                         }
</span><ins>+                        if (!strcasecmp(var, &quot;allow-empty-password&quot;)) {
+                                allow_empty_password = switch_true(val);
+                        }
</ins><span class="cx">                         if (!strcasecmp(var, &quot;user-agent-filter&quot;)) {
</span><span class="cx">                                 user_agent_filter = val;
</span><span class="cx">                         }
</span><span class="lines">@@ -2058,6 +2066,12 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        if (!allow_empty_password &amp;&amp; zstr(passwd) &amp;&amp; zstr(a1_hash)) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Empty password denied for user %s@%s\n&quot;, username, domain_name);
+                ret = AUTH_FORBIDDEN;
+                goto end;
+        }
+        
</ins><span class="cx">         if (zstr(passwd) &amp;&amp; zstr(a1_hash)) {
</span><span class="cx">                 ret = AUTH_OK;
</span><span class="cx">                 goto skip_auth;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodevent_handlersmod_json_cdrmod_json_cdrc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -620,7 +620,10 @@
</span><span class="cx"> 
</span><span class="cx">         is_b = channel &amp;&amp; switch_channel_get_originator_caller_profile(channel);
</span><span class="cx">         if (!globals.log_b &amp;&amp; is_b) {
</span><del>-                return SWITCH_STATUS_SUCCESS;
</del><ins>+                const char *force_cdr = switch_channel_get_variable(channel, SWITCH_FORCE_PROCESS_CDR_VARIABLE);
+                if (!switch_true(force_cdr)) {
+                        return SWITCH_STATUS_SUCCESS;
+                }
</ins><span class="cx">         }
</span><span class="cx">         if (!is_b &amp;&amp; globals.prefix_a)
</span><span class="cx">                 a_prefix = &quot;a_&quot;;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodxml_intmod_xml_cdrmod_xml_cdrc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -200,7 +200,10 @@
</span><span class="cx"> 
</span><span class="cx">         is_b = channel &amp;&amp; switch_channel_get_originator_caller_profile(channel);
</span><span class="cx">         if (!globals.log_b &amp;&amp; is_b) {
</span><del>-                return SWITCH_STATUS_SUCCESS;
</del><ins>+                const char *force_cdr = switch_channel_get_variable(channel, SWITCH_FORCE_PROCESS_CDR_VARIABLE);
+                if (!switch_true(force_cdr)) {
+                        return SWITCH_STATUS_SUCCESS;
+                }
</ins><span class="cx">         }
</span><span class="cx">         if (!is_b &amp;&amp; globals.prefix_a)
</span><span class="cx">                 a_prefix = &quot;a_&quot;;
</span><span class="lines">@@ -334,7 +337,8 @@
</span><span class="cx">                                 switch_yield(globals.delay * 1000000);
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        destUrl = switch_mprintf(&quot;%s?uuid=%s&quot;, globals.urls[globals.url_index], switch_core_session_get_uuid(session));
</del><ins>+                        destUrl = switch_mprintf(&quot;%s?uuid=%s&amp;leg=%c&quot;, globals.urls[globals.url_index], switch_core_session_get_uuid(session), 
+                                is_b ? 'b' : 'a');
</ins><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_URL, destUrl);
</span><span class="cx"> 
</span><span class="cx">                         if (!strncasecmp(destUrl, &quot;https&quot;, 5)) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodxml_intmod_xml_ldaplutil_ldaph"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/lutil_ldap.h (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/lutil_ldap.h        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/lutil_ldap.h        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -13,8 +13,8 @@
</span><span class="cx">  * &lt;http://www.OpenLDAP.org/license.html&gt;.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-#ifndef _LUTIL_LDAP_H
-#define _LUTIL_LDAP_H 1
</del><ins>+#ifndef LUTIL_LDAP_H
+#define LUTIL_LDAP_H
</ins><span class="cx"> 
</span><span class="cx"> #include &lt;ldap_cdefs.h&gt;
</span><span class="cx"> #include &lt;lber_types.h&gt;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_channelc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_channel.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_channel.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/switch_channel.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -241,6 +241,7 @@
</span><span class="cx">         (*channel)-&gt;hangup_cause = SWITCH_CAUSE_NONE;
</span><span class="cx">         (*channel)-&gt;name = &quot;&quot;;
</span><span class="cx">         (*channel)-&gt;direction = direction;
</span><ins>+        switch_channel_set_variable(*channel, &quot;direction&quot;, switch_channel_direction(*channel) == SWITCH_CALL_DIRECTION_OUTBOUND ? &quot;outbound&quot; : &quot;inbound&quot;);
</ins><span class="cx"> 
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_sqldbc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_sqldb.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_sqldb.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/switch_core_sqldb.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -958,6 +958,7 @@
</span><span class="cx">         case SWITCH_EVENT_CHANNEL_DESTROY:
</span><span class="cx">                 sql = switch_mprintf(&quot;delete from channels where uuid='%q' and hostname='%q'&quot;,
</span><span class="cx">                                                          switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;));
</span><ins>+                printf(&quot;%s\n&quot;, sql);
</ins><span class="cx">                 break;
</span><span class="cx">         case SWITCH_EVENT_CHANNEL_UUID:
</span><span class="cx">                 {
</span><span class="lines">@@ -1143,7 +1144,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (sql) {
</span><del>-                if (switch_stristr(&quot;update channels&quot;, sql)) {
</del><ins>+                if (switch_stristr(&quot;update channels&quot;, sql) || switch_stristr(&quot;delete from channels&quot;, sql)) {
</ins><span class="cx">                         switch_queue_push(sql_manager.sql_queue[1], sql);
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_queue_push(sql_manager.sql_queue[0], sql);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_state_machinec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_state_machine.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_state_machine.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/switch_core_state_machine.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -526,8 +526,9 @@
</span><span class="cx"> 
</span><span class="cx">                 switch_api_execute(cmd, expanded, use_session, &amp;stream);
</span><span class="cx"> 
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Hangup Command %s(%s):\n%s\n&quot;, cmd, switch_str_nil(expanded),
-                                                  switch_str_nil((char *) stream.data));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Hangup Command %s %s(%s):\n%s\n&quot;,
+                                                  use_session ? &quot;with Session&quot; : &quot;with no Session&quot;, cmd, switch_str_nil(expanded),
+                                                  switch_str_nil((char *) stream.data) );
</ins><span class="cx"> 
</span><span class="cx">                 if (expanded != arg) {
</span><span class="cx">                         switch_safe_free(expanded);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_dsoc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_dso.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_dso.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/switch_dso.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -131,7 +131,7 @@
</span><span class="cx">                 dlerror();
</span><span class="cx"> 
</span><span class="cx">                 if (!(addr = dlsym(lib, sym))) {
</span><del>-                        err_str = dlerror();
</del><ins>+                        err_str = (char *)dlerror();
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if (err_str) {
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_ivr_asyncc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_ivr_async.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_ivr_async.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/switch_ivr_async.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -353,10 +353,15 @@
</span><span class="cx">         switch_media_bug_t *bug;
</span><span class="cx">         switch_status_t status;
</span><span class="cx">         time_t to = 0;
</span><ins>+        char *ext;
+        const char *prefix;
</ins><span class="cx">         displace_helper_t *dh;
</span><span class="cx">         switch_codec_implementation_t read_impl = { 0 };
</span><span class="cx">         switch_core_session_get_read_impl(session, &amp;read_impl);
</span><span class="cx"> 
</span><ins>+        if (zstr(file)) {
+                return SWITCH_STATUS_FALSE;
+        }
</ins><span class="cx"> 
</span><span class="cx">         if ((status = switch_channel_pre_answer(channel)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -376,7 +381,35 @@
</span><span class="cx">                 return SWITCH_STATUS_MEMERR;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        if (!(prefix = switch_channel_get_variable(channel, &quot;sound_prefix&quot;))) {
+                prefix = SWITCH_GLOBAL_dirs.base_dir;
+        }
</ins><span class="cx"> 
</span><ins>+        if (!strstr(file, SWITCH_URL_SEPARATOR)) {
+                if (!switch_is_file_path(file)) {
+                        char *tfile = NULL;
+                        char *e;
+
+                        if (*file == '[') {
+                                tfile = switch_core_session_strdup(session, file);
+                                if ((e = switch_find_end_paren(tfile, '[', ']'))) {
+                                        *e = '\0';
+                                        file = e + 1;
+                                } else {
+                                        tfile = NULL;
+                                }
+                        }
+
+                        file = switch_core_session_sprintf(session, &quot;%s%s%s%s%s&quot;, switch_str_nil(tfile), tfile ? &quot;]&quot; : &quot;&quot;, prefix, SWITCH_PATH_SEPARATOR, file);
+                }
+                if ((ext = strrchr(file, '.'))) {
+                        ext++;
+                } else {
+                        ext = read_impl.iananame;
+                        file = switch_core_session_sprintf(session, &quot;%s.%s&quot;, file, ext);
+                }
+        }
+
</ins><span class="cx">         dh-&gt;fh.channels = read_impl.number_of_channels;
</span><span class="cx">         dh-&gt;fh.samplerate = read_impl.actual_samples_per_second;
</span><span class="cx">         dh-&gt;file = switch_core_session_strdup(session, file);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_ivr_originatec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_ivr_originate.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_ivr_originate.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/switch_ivr_originate.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -372,6 +372,38 @@
</span><span class="cx">         return SWITCH_FALSE;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void inherit_codec(switch_channel_t *caller_channel, switch_core_session_t *session)
+{
+        const char *var = switch_channel_get_variable(caller_channel, &quot;inherit_codec&quot;);
+        switch_channel_t *channel = switch_core_session_get_channel(session);
+        
+        if (switch_true(var)) {
+                switch_codec_implementation_t impl = { 0 };
+                switch_codec_implementation_t video_impl = { 0 };
+                char tmp[128] = &quot;&quot;;
+
+
+                if (switch_core_session_get_read_impl(session, &amp;impl) == SWITCH_STATUS_SUCCESS) {
+                        if (switch_core_session_get_video_read_impl(session, &amp;impl) == SWITCH_STATUS_SUCCESS) {
+                                switch_snprintf(tmp, sizeof(tmp), &quot;%s@%uh@%ui,%s&quot;,
+                                                                impl.iananame, impl.samples_per_second, impl.microseconds_per_packet / 1000,
+                                                                video_impl.iananame);
+                        } else {
+                                switch_snprintf(tmp, sizeof(tmp), &quot;%s@%uh@%ui&quot;,
+                                                                impl.iananame, impl.samples_per_second, impl.microseconds_per_packet / 1000);
+                        }
+                        switch_channel_set_variable(caller_channel, &quot;absolute_codec_string&quot;, tmp);
+                        switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_DEBUG, &quot;Setting codec string on %s to %s\n&quot;,
+                                                          switch_channel_get_name(caller_channel), tmp);
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_WARNING,
+                                                          &quot;Error inheriting codec.  Channel %s has no read codec yet.\n&quot;,
+                                                          switch_channel_get_name(channel));
+                }
+
+        }
+}
+
</ins><span class="cx"> static uint8_t check_channel_status(originate_global_t *oglobals, originate_status_t *originate_status, uint32_t len)
</span><span class="cx"> {
</span><span class="cx"> 
</span><span class="lines">@@ -671,32 +703,7 @@
</span><span class="cx">   end:
</span><span class="cx"> 
</span><span class="cx">         if (pindex &gt; -1 &amp;&amp; caller_channel &amp;&amp; switch_channel_ready(caller_channel) &amp;&amp; !switch_channel_media_ready(caller_channel)) {
</span><del>-                const char *var = switch_channel_get_variable(caller_channel, &quot;inherit_codec&quot;);
-                if (switch_true(var)) {
-                        switch_codec_implementation_t impl = { 0 };
-                        switch_codec_implementation_t video_impl = { 0 };
-                        char tmp[128] = &quot;&quot;;
-
-
-                        if (switch_core_session_get_read_impl(originate_status[pindex].peer_session, &amp;impl) == SWITCH_STATUS_SUCCESS) {
-                                if (switch_core_session_get_video_read_impl(originate_status[pindex].peer_session, &amp;impl) == SWITCH_STATUS_SUCCESS) {
-                                        switch_snprintf(tmp, sizeof(tmp), &quot;%s@%uh@%ui,%s&quot;,
-                                                                        impl.iananame, impl.samples_per_second, impl.microseconds_per_packet / 1000,
-                                                                        video_impl.iananame);
-                                } else {
-                                        switch_snprintf(tmp, sizeof(tmp), &quot;%s@%uh@%ui&quot;,
-                                                                        impl.iananame, impl.samples_per_second, impl.microseconds_per_packet / 1000);
-                                }
-                                switch_channel_set_variable(caller_channel, &quot;absolute_codec_string&quot;, tmp);
-                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_DEBUG, &quot;Setting codec string on %s to %s\n&quot;,
-                                                                  switch_channel_get_name(caller_channel), tmp);
-                        } else {
-                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(originate_status[pindex].peer_channel), SWITCH_LOG_WARNING,
-                                                                  &quot;Error inheriting codec.  Channel %s has no read codec yet.\n&quot;,
-                                                                  switch_channel_get_name(originate_status[pindex].peer_channel));
-                        }
-
-                }
</del><ins>+                inherit_codec(caller_channel, originate_status[pindex].peer_session);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (send_ringback) {
</span><span class="lines">@@ -1051,7 +1058,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static switch_status_t setup_ringback(originate_global_t *oglobals,
</del><ins>+static switch_status_t setup_ringback(originate_global_t *oglobals, originate_status_t *originate_status, int len,
</ins><span class="cx">                                                                           const char *ringback_data, ringback_t *ringback, switch_frame_t *write_frame, switch_codec_t *write_codec)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -1061,6 +1068,10 @@
</span><span class="cx"> 
</span><span class="cx">         if (!switch_channel_test_flag(caller_channel, CF_ANSWERED)
</span><span class="cx">                 &amp;&amp; !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
</span><ins>+                if (oglobals-&gt;bridge_early_media &gt; -1  &amp;&amp; len == 1 &amp;&amp; originate_status[0].peer_session &amp;&amp; 
+                        switch_channel_media_ready(originate_status[0].peer_channel)) {                                
+                        inherit_codec(caller_channel, originate_status[0].peer_session);
+                }
</ins><span class="cx">                 if ((status = switch_channel_pre_answer(caller_channel)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_DEBUG, &quot;%s Media Establishment Failed.\n&quot;,
</span><span class="cx">                                                           switch_channel_get_name(caller_channel));
</span><span class="lines">@@ -1073,6 +1084,25 @@
</span><span class="cx">                         if (!(strrchr(ringback_data, '.') || strstr(ringback_data, SWITCH_URL_SEPARATOR))) {
</span><span class="cx">                                 ringback-&gt;asis++;
</span><span class="cx">                         }
</span><ins>+                } else if (oglobals-&gt;bridge_early_media &gt; -1 &amp;&amp; zstr(ringback_data) &amp;&amp; len == 1 &amp;&amp; originate_status[0].peer_session) {
+                        switch_codec_implementation_t read_impl = { 0 }, write_impl = { 0 };
+                        
+                        if (switch_channel_ready(originate_status[0].peer_channel)
+                                &amp;&amp; switch_core_session_get_read_impl(originate_status[0].peer_session, &amp;read_impl) == SWITCH_STATUS_SUCCESS
+                                &amp;&amp; switch_core_session_get_write_impl(oglobals-&gt;session, &amp;write_impl) == SWITCH_STATUS_SUCCESS) {
+                                if (read_impl.impl_id == write_impl.impl_id &amp;&amp; 
+                                        read_impl.microseconds_per_packet == write_impl.microseconds_per_packet &amp;&amp;
+                                        read_impl.actual_samples_per_second == write_impl.actual_samples_per_second) {
+                                                ringback-&gt;asis++;
+                                                write_frame-&gt;codec = switch_core_session_get_write_codec(originate_status[0].peer_session);
+                                                write_frame-&gt;datalen = write_frame-&gt;codec-&gt;implementation-&gt;decoded_bytes_per_packet;
+                                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_DEBUG, &quot;bridge_early_media: passthrough enabled\n&quot;);
+                                        } else {
+                                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_DEBUG, &quot;bridge_early_media: codecs don't match (%s@%uh@%di / %s@%uh@%di)\n&quot;,
+                                                        read_impl.iananame, read_impl.actual_samples_per_second, read_impl.microseconds_per_packet / 1000, 
+                                                        write_impl.iananame, write_impl.actual_samples_per_second, write_impl.microseconds_per_packet / 1000);
+                                        }
+                        }
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if (!ringback-&gt;asis) {
</span><span class="lines">@@ -1553,6 +1583,7 @@
</span><span class="cx">         switch_mutex_t *mutex;
</span><span class="cx">         switch_buffer_t *buffer;
</span><span class="cx">         int ready;
</span><ins>+        ringback_t *ringback;
</ins><span class="cx"> };
</span><span class="cx"> typedef struct early_state early_state_t;
</span><span class="cx"> 
</span><span class="lines">@@ -1591,38 +1622,52 @@
</span><span class="cx">                                         answered++;
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><del>-                                if (!switch_core_codec_ready((&amp;read_codecs[i]))) {
-                                        read_codec = switch_core_session_get_read_codec(session);
</del><ins>+                                if (!state-&gt;ringback-&gt;asis) {
+                                        if (!switch_core_codec_ready((&amp;read_codecs[i]))) {
+                                                read_codec = switch_core_session_get_read_codec(session);
</ins><span class="cx"> 
</span><del>-                                        if (switch_core_codec_init(&amp;read_codecs[i],
-                                                                                           &quot;L16&quot;,
-                                                                                           NULL,
-                                                                                           read_codec-&gt;implementation-&gt;actual_samples_per_second,
-                                                                                           read_codec-&gt;implementation-&gt;microseconds_per_packet / 1000,
-                                                                                           1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
-                                                                                           switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
-                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Codec Error!\n&quot;);
-                                        } else {
-                                                switch_core_session_set_read_codec(session, &amp;read_codecs[i]);
</del><ins>+                                                if (switch_core_codec_init(&amp;read_codecs[i],
+                                                                                                   &quot;L16&quot;,
+                                                                                                   NULL,
+                                                                                                   read_codec-&gt;implementation-&gt;actual_samples_per_second,
+                                                                                                   read_codec-&gt;implementation-&gt;microseconds_per_packet / 1000,
+                                                                                                   1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
+                                                                                                   switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Codec Error!\n&quot;);
+                                                } else {
+                                                        switch_core_session_set_read_codec(session, &amp;read_codecs[i]);
+                                                }
</ins><span class="cx">                                         }
</span><del>-                                }
-                                status = switch_core_session_read_frame(session, &amp;read_frame, SWITCH_IO_FLAG_NONE, 0);
-                                if (SWITCH_READ_ACCEPTABLE(status)) {
-                                        data = (int16_t *) read_frame-&gt;data;
-                                        if (datalen &lt; read_frame-&gt;datalen) {
</del><ins>+                                        status = switch_core_session_read_frame(session, &amp;read_frame, SWITCH_IO_FLAG_NONE, 0);
+                                        if (SWITCH_READ_ACCEPTABLE(status)) {
+                                                data = (int16_t *) read_frame-&gt;data;
+                                                if (datalen &lt; read_frame-&gt;datalen) {
+                                                        datalen = read_frame-&gt;datalen;
+                                                }
+                                                for (x = 0; x &lt; (int) read_frame-&gt;datalen / 2; x++) {
+                                                        sample = data[x] + mux_data[x];
+                                                        switch_normalize_to_16bit(sample);
+                                                        mux_data[x] = (int16_t) sample;
+                                                }
+                                        }
+                                } else {
+                                        status = switch_core_session_read_frame(session, &amp;read_frame, SWITCH_IO_FLAG_NONE, 0);
+                                        if (SWITCH_READ_ACCEPTABLE(status)) {
</ins><span class="cx">                                                 datalen = read_frame-&gt;datalen;
</span><span class="cx">                                         }
</span><del>-                                        for (x = 0; x &lt; (int) read_frame-&gt;datalen / 2; x++) {
-                                                sample = data[x] + mux_data[x];
-                                                switch_normalize_to_16bit(sample);
-                                                mux_data[x] = (int16_t) sample;
-                                        }
-
</del><ins>+                                        break;
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                if (datalen) {
</del><ins>+                
+                if (state-&gt;ringback-&gt;asis &amp;&amp; datalen) {
+                        uint16_t flen = (uint16_t)datalen;
</ins><span class="cx">                         switch_mutex_lock(state-&gt;mutex);
</span><ins>+                        switch_buffer_write(state-&gt;buffer, &amp;flen, sizeof(uint16_t));
+                        switch_buffer_write(state-&gt;buffer, read_frame-&gt;data, datalen);
+                        switch_mutex_unlock(state-&gt;mutex);
+                } else if (datalen) {
+                        switch_mutex_lock(state-&gt;mutex);
</ins><span class="cx">                         switch_buffer_write(state-&gt;buffer, mux_data, datalen);
</span><span class="cx">                         switch_mutex_unlock(state-&gt;mutex);
</span><span class="cx">                 }
</span><span class="lines">@@ -2758,9 +2803,10 @@
</span><span class="cx">                                         if (oglobals.ringback_ok &amp;&amp; (oglobals.ring_ready || oglobals.instant_ringback ||
</span><span class="cx">                                                                                                  oglobals.sending_ringback &gt; 1 || oglobals.bridge_early_media &gt; -1)) {
</span><span class="cx">                                                 if (oglobals.ringback_ok == 1) {
</span><del>-                                                        switch_status_t rst = setup_ringback(&amp;oglobals, ringback_data, &amp;ringback, &amp;write_frame, &amp;write_codec);
-
-
</del><ins>+                                                        switch_status_t rst;
+                                                        
+                                                        rst = setup_ringback(&amp;oglobals, originate_status, and_argc, ringback_data, &amp;ringback, &amp;write_frame, &amp;write_codec);
+                                                        
</ins><span class="cx">                                                         if (oglobals.bridge_early_media &gt; -1) {
</span><span class="cx">                                                                 switch_threadattr_t *thd_attr = NULL;
</span><span class="cx">                                                                 switch_threadattr_create(&amp;thd_attr, switch_core_session_get_pool(session));
</span><span class="lines">@@ -2768,6 +2814,7 @@
</span><span class="cx">                                                                 early_state.oglobals = &amp;oglobals;
</span><span class="cx">                                                                 early_state.originate_status = originate_status;
</span><span class="cx">                                                                 early_state.ready = 1;
</span><ins>+                                                                early_state.ringback = &amp;ringback;
</ins><span class="cx">                                                                 switch_mutex_init(&amp;early_state.mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
</span><span class="cx">                                                                 switch_buffer_create_dynamic(&amp;early_state.buffer, 1024, 1024, 0);
</span><span class="cx">                                                                 switch_thread_create(&amp;oglobals.ethread, thd_attr, early_thread_run, &amp;early_state, switch_core_session_get_pool(session));
</span><span class="lines">@@ -2794,12 +2841,24 @@
</span><span class="cx">                                                         continue;
</span><span class="cx">                                                 }
</span><span class="cx"> 
</span><del>-                                                if (oglobals.bridge_early_media &gt; -1) {
</del><ins>+                                                if (oglobals.bridge_early_media &gt; -1) {                                                        
</ins><span class="cx">                                                         write_frame.datalen = 0;
</span><span class="cx">                                                         switch_mutex_lock(early_state.mutex);
</span><del>-                                                        if (switch_buffer_inuse(early_state.buffer) &gt;= write_frame.codec-&gt;implementation-&gt;decoded_bytes_per_packet) {
-                                                                write_frame.datalen = switch_buffer_read(early_state.buffer, write_frame.data,
-                                                                                                                                                 write_frame.codec-&gt;implementation-&gt;decoded_bytes_per_packet);
</del><ins>+                                                        if (ringback.asis) {
+                                                                uint16_t mlen;
+                                                                switch_size_t buflen = switch_buffer_inuse(early_state.buffer);
+                                                                if (buflen &gt; sizeof(uint16_t)) {
+                                                                        switch_buffer_peek(early_state.buffer, &amp;mlen, sizeof(uint16_t));
+                                                                        if (buflen &gt;= (mlen + sizeof(uint16_t))) {
+                                                                                switch_buffer_toss(early_state.buffer, sizeof(uint16_t));
+                                                                                write_frame.datalen = switch_buffer_read(early_state.buffer, write_frame.data, mlen);
+                                                                        }
+                                                                }
+                                                        } else {
+                                                                if (switch_buffer_inuse(early_state.buffer) &gt;= write_frame.codec-&gt;implementation-&gt;decoded_bytes_per_packet) {
+                                                                        write_frame.datalen = switch_buffer_read(early_state.buffer, write_frame.data,
+                                                                                                                                                         write_frame.codec-&gt;implementation-&gt;decoded_bytes_per_packet);
+                                                                }
</ins><span class="cx">                                                         }
</span><span class="cx">                                                         switch_mutex_unlock(early_state.mutex);
</span><span class="cx">                                                 } else if (ringback.fh) {
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_loadable_modulec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_loadable_module.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_loadable_module.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/switch_loadable_module.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -1176,13 +1176,20 @@
</span><span class="cx">                         for (ld = switch_xml_child(mods, &quot;load&quot;); ld; ld = ld-&gt;next) {
</span><span class="cx">                                 switch_bool_t global = SWITCH_FALSE;
</span><span class="cx">                                 const char *val = switch_xml_attr_soft(ld, &quot;module&quot;);
</span><ins>+                                const char *critical = switch_xml_attr_soft(ld, &quot;critical&quot;);
</ins><span class="cx">                                 const char *sglobal = switch_xml_attr_soft(ld, &quot;global&quot;);
</span><span class="cx">                                 if (zstr(val) || (strchr(val, '.') &amp;&amp; !strstr(val, ext) &amp;&amp; !strstr(val, EXT))) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Invalid extension for %s\n&quot;, val);
</span><span class="cx">                                         continue;
</span><span class="cx">                                 }
</span><span class="cx">                                 global = switch_true(sglobal);
</span><del>-                                switch_loadable_module_load_module_ex((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) val, SWITCH_FALSE, global, &amp;err);
</del><ins>+                                
+                                if (switch_loadable_module_load_module_ex((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) val, SWITCH_FALSE, global, &amp;err) == SWITCH_STATUS_FALSE) {
+                                        if (critical &amp;&amp; switch_true(critical)) {
+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Failed to load critical module '%s', abort()\n&quot;, val);
+                                                abort();
+                                        }
+                                }
</ins><span class="cx">                                 count++;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_rtpc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_rtp.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_rtp.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/switch_rtp.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -2130,7 +2130,7 @@
</span><span class="cx">                                                                   &quot;Sender Packet Count = %u, &quot; \
</span><span class="cx">                                                                   &quot;Sender Octet Count = %u\n&quot;,
</span><span class="cx">                                                                   rtp_session-&gt;rtcp_recv_msg.header.count,
</span><del>-                                                                  ntohs(rtp_session-&gt;rtcp_recv_msg.header.length),
</del><ins>+                                                                  ntohs((uint16_t)rtp_session-&gt;rtcp_recv_msg.header.length),
</ins><span class="cx">                                                                   ntohl(sr-&gt;ssrc),
</span><span class="cx">                                                                   ntohl(sr-&gt;ntp_msw),
</span><span class="cx">                                                                   ntohl(sr-&gt;ntp_lsw),
</span><span class="lines">@@ -2907,7 +2907,7 @@
</span><span class="cx">                 rtp_session-&gt;rtcp_fresh_frame = 0;
</span><span class="cx"> 
</span><span class="cx">                 frame-&gt;ssrc = ntohl(sr-&gt;ssrc);
</span><del>-                frame-&gt;packet_type = rtp_session-&gt;rtcp_recv_msg.header.type;
</del><ins>+                frame-&gt;packet_type = (uint16_t)rtp_session-&gt;rtcp_recv_msg.header.type;
</ins><span class="cx">                 frame-&gt;ntp_msw = ntohl(sr-&gt;ntp_msw);
</span><span class="cx">                 frame-&gt;ntp_lsw = ntohl(sr-&gt;ntp_lsw);
</span><span class="cx">                 frame-&gt;timestamp = ntohl(sr-&gt;ts);
</span><span class="lines">@@ -3337,8 +3337,8 @@
</span><span class="cx">                         struct switch_rtcp_senderinfo* sr = (struct switch_rtcp_senderinfo*)rtp_session-&gt;rtcp_send_msg.body;
</span><span class="cx"> 
</span><span class="cx">                         sr-&gt;ssrc = send_msg-&gt;header.ssrc;
</span><del>-                        sr-&gt;ntp_msw = htonl(rtp_session-&gt;send_time / 1000000 + 2208988800UL);
-                        sr-&gt;ntp_lsw = htonl(rtp_session-&gt;send_time % 1000000 * ((UINT_MAX * 1.0)/ 1000000.0));
</del><ins>+                        sr-&gt;ntp_msw = htonl((u_long)rtp_session-&gt;send_time / 1000000 + 2208988800UL);
+                        sr-&gt;ntp_lsw = htonl((u_long)(rtp_session-&gt;send_time % 1000000 * ((UINT_MAX * 1.0)/ 1000000.0)));
</ins><span class="cx">                         sr-&gt;ts = send_msg-&gt;header.ts;
</span><span class="cx">                         sr-&gt;pc = htonl(rtp_session-&gt;stats.outbound.packet_count);
</span><span class="cx">                         sr-&gt;oc = htonl((rtp_session-&gt;stats.outbound.raw_bytes - rtp_session-&gt;stats.outbound.packet_count * sizeof(srtp_hdr_t)));
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_xmlc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_xml.c (17415 => 17416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_xml.c        2010-04-27 18:32:36 UTC (rev 17415)
+++ freeswitch/trunk/src/switch_xml.c        2010-04-27 18:32:55 UTC (rev 17416)
</span><span class="lines">@@ -403,6 +403,10 @@
</span><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        if (!root-&gt;attr) {
+                return NULL;
+        }
+        
</ins><span class="cx">         for (i = 0; root-&gt;attr[i] &amp;&amp; xml-&gt;name &amp;&amp; strcmp(xml-&gt;name, root-&gt;attr[i][0]); i++);
</span><span class="cx">         if (!root-&gt;attr[i])
</span><span class="cx">                 return NULL;                        /* no matching default attributes */
</span><span class="lines">@@ -451,6 +455,9 @@
</span><span class="cx">                 return (const char **) SWITCH_XML_NIL;
</span><span class="cx">         while (root-&gt;xml.parent)
</span><span class="cx">                 root = (switch_xml_root_t) root-&gt;xml.parent;        /* root tag */
</span><ins>+        if (!root || !root-&gt;pi) {
+                return (const char **) SWITCH_XML_NIL;
+        }
</ins><span class="cx">         while (root-&gt;pi[i] &amp;&amp; strcmp(target, root-&gt;pi[i][0]))
</span><span class="cx">                 i++;                                        /* find target */
</span><span class="cx">         return (const char **) ((root-&gt;pi[i]) ? root-&gt;pi[i] + 1 : SWITCH_XML_NIL);
</span><span class="lines">@@ -463,6 +470,10 @@
</span><span class="cx">         int line = 1;
</span><span class="cx">         char *t, fmt[SWITCH_XML_ERRL];
</span><span class="cx"> 
</span><ins>+        if (!root || !root-&gt;s) {
+                return NULL;
+        }
+
</ins><span class="cx">         for (t = root-&gt;s; t &amp;&amp; t &lt; s; t++)
</span><span class="cx">                 if (*t == '\n')
</span><span class="cx">                         line++;
</span><span class="lines">@@ -578,8 +589,14 @@
</span><span class="cx"> /* called when parser finds start of new tag */
</span><span class="cx"> static void switch_xml_open_tag(switch_xml_root_t root, char *name, char **attr)
</span><span class="cx"> {
</span><del>-        switch_xml_t xml = root-&gt;cur;
</del><ins>+        switch_xml_t xml;
</ins><span class="cx"> 
</span><ins>+        if (!root || !root-&gt;cur) {
+                return;
+        }
+
+        xml = root-&gt;cur;
+
</ins><span class="cx">         if (xml-&gt;name)
</span><span class="cx">                 xml = switch_xml_add_child(xml, name, strlen(xml-&gt;txt));
</span><span class="cx">         else
</span><span class="lines">@@ -592,10 +609,16 @@
</span><span class="cx"> /* called when parser finds character content between open and closing tag */
</span><span class="cx"> static void switch_xml_char_content(switch_xml_root_t root, char *s, switch_size_t len, char t)
</span><span class="cx"> {
</span><del>-        switch_xml_t xml = root-&gt;cur;
</del><ins>+        switch_xml_t xml;
</ins><span class="cx">         char *m = s;
</span><span class="cx">         switch_size_t l;
</span><span class="cx"> 
</span><ins>+        if (!root || !root-&gt;cur) {
+                return;
+        }
+
+        xml = root-&gt;cur;
+
</ins><span class="cx">         if (!xml || !xml-&gt;name || !len)
</span><span class="cx">                 return;                                        /* sanity check */
</span><span class="cx"> 
</span><span class="lines">@@ -632,7 +655,7 @@
</span><span class="cx"> /* called when parser finds closing tag */
</span><span class="cx"> static switch_xml_t switch_xml_close_tag(switch_xml_root_t root, char *name, char *s)
</span><span class="cx"> {
</span><del>-        if (!root-&gt;cur || !root-&gt;cur-&gt;name || strcmp(name, root-&gt;cur-&gt;name))
</del><ins>+        if (!root || !root-&gt;cur || !root-&gt;cur-&gt;name || strcmp(name, root-&gt;cur-&gt;name))
</ins><span class="cx">                 return switch_xml_err(root, s, &quot;unexpected closing tag &lt;/%s&gt;&quot;, name);
</span><span class="cx"> 
</span><span class="cx">         root-&gt;cur = root-&gt;cur-&gt;parent;
</span><span class="lines">@@ -681,7 +704,7 @@
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (!root-&gt;pi[0]) {
</del><ins>+        if (!root-&gt;pi || !root-&gt;pi[0]) {
</ins><span class="cx">                 root-&gt;pi = (char ***) malloc(sizeof(char **));
</span><span class="cx">                 if (!root-&gt;pi)
</span><span class="cx">                         return;
</span><span class="lines">@@ -2601,6 +2624,107 @@
</span><span class="cx">         return xml;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond) {
+
+        const char *xyear = switch_xml_attr(xcond, &quot;year&quot;);
+        const char *xyday = switch_xml_attr(xcond, &quot;yday&quot;);
+        const char *xmon = switch_xml_attr(xcond, &quot;mon&quot;);
+        const char *xmday = switch_xml_attr(xcond, &quot;mday&quot;);
+        const char *xweek = switch_xml_attr(xcond, &quot;week&quot;);
+        const char *xmweek = switch_xml_attr(xcond, &quot;mweek&quot;);
+        const char *xwday = switch_xml_attr(xcond, &quot;wday&quot;);
+        const char *xhour = switch_xml_attr(xcond, &quot;hour&quot;);
+        const char *xminute = switch_xml_attr(xcond, &quot;minute&quot;);
+        const char *xminday = switch_xml_attr(xcond, &quot;minute-of-day&quot;);
+
+        switch_time_t ts = switch_micro_time_now();
+        int time_match = -1;
+        switch_time_exp_t tm;
+
+        switch_time_exp_lt(&amp;tm, ts);
+
+        if (time_match &amp;&amp; xyear) {
+                int test = tm.tm_year + 1900;
+                time_match = switch_number_cmp(xyear, test);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
+                                &quot;XML DateTime Check: year[%d] =~ %s (%s)\n&quot;, test, xyear, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
+        }
+
+        if (time_match &amp;&amp; xyday) {
+                int test = tm.tm_yday + 1;
+                time_match = switch_number_cmp(xyday, test);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
+                                &quot;XML DateTime Check: day of year[%d] =~ %s (%s)\n&quot;, test, xyday, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
+        }
+
+        if (time_match &amp;&amp; xmon) {
+                int test = tm.tm_mon + 1;
+                time_match = switch_number_cmp(xmon, test);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
+                                &quot;XML DateTime Check: month[%d] =~ %s (%s)\n&quot;, test, xmon, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
+        }
+
+        if (time_match &amp;&amp; xmday) {
+                int test = tm.tm_mday;
+                time_match = switch_number_cmp(xmday, test);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
+                                &quot;XML DateTime Check: day of month[%d] =~ %s (%s)\n&quot;, test, xmday, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
+        }
+
+        if (time_match &amp;&amp; xweek) {
+                int test = (int) (tm.tm_yday / 7 + 1);
+                time_match = switch_number_cmp(xweek, test);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
+                                &quot;XML DateTime Check: week of year[%d] =~ %s (%s)\n&quot;, test, xweek, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
+        }
+        if (time_match &amp;&amp; xweek) {
+                int test = (int) (tm.tm_yday / 7 + 1);
+                time_match = switch_number_cmp(xweek, test);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
+                                &quot;XML DateTime Check: week of year[%d] =~ %s (%s)\n&quot;, test, xweek, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
+        }
+
+        if (time_match &amp;&amp; xmweek) {
+                /* calculate the day of the week of the first of the month (0-6) */
+                int firstdow = (int) (7 - (tm.tm_mday - (tm.tm_wday + 1)) % 7) % 7;
+                /* calculate the week of the month (1-6)*/
+                int test = (int) ceil((tm.tm_mday + firstdow) / 7.0);
+                time_match = switch_number_cmp(xmweek, test);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
+                                &quot;XML DateTime: week of month[%d] =~ %s (%s)\n&quot;, test, xmweek, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
+        }
+
+        if (time_match &amp;&amp; xwday) {
+                int test = tm.tm_wday + 1;
+                time_match = switch_number_cmp(xwday, test);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
+                                &quot;XML DateTime Check: day of week[%d] =~ %s (%s)\n&quot;, test, xwday, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
+        }
+        if (time_match &amp;&amp; xhour) {
+                int test = tm.tm_hour;
+                time_match = switch_number_cmp(xhour, test);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
+                                &quot;XML DateTime Check: hour[%d] =~ %s (%s)\n&quot;, test, xhour, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
+        }
+
+        if (time_match &amp;&amp; xminute) {
+                int test = tm.tm_min;
+                time_match = switch_number_cmp(xminute, test);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
+                                &quot;XML DateTime Check: minute[%d] =~ %s (%s)\n&quot;, test, xminute, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
+        }
+
+        if (time_match &amp;&amp; xminday) {
+                int test = (tm.tm_hour * 60) + (tm.tm_min + 1);
+                time_match = switch_number_cmp(xminday, test);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
+                                &quot;XML DateTime Check: minute of day[%d] =~ %s (%s)\n&quot;, test, xminday, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
+        }
+
+        return time_match;
+}
+
+
</ins><span class="cx"> #ifdef WIN32
</span><span class="cx"> /* 
</span><span class="cx">  * globbing functions for windows, part of libc on unix, this code was cut and paste from  
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>