<!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][16271] </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=16271">16271</a></dd>
<dt>Author</dt> <dd>brian</dd>
<dt>Date</dt> <dd>2010-01-12 19:40:11 -0600 (Tue, 12 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>SCA tweaks</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcincludeswitch_odbch">freeswitch/trunk/src/include/switch_odbc.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_easyroutemod_easyroutec">freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_nibblebillmod_nibblebillc">freeswitch/trunk/src/mod/applications/mod_nibblebill/mod_nibblebill.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_dingalingmod_dingalingc">freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c</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="#freeswitchtrunksrcmodlanguagesmod_spidermonkey_odbcmod_spidermonkey_odbcc">freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c</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_odbcc">freeswitch/trunk/src/switch_odbc.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcincludeswitch_odbch"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_odbc.h (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_odbc.h        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/include/switch_odbc.h        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -56,11 +56,12 @@
</span><span class="cx"> SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_connect(switch_odbc_handle_t *handle);
</span><span class="cx"> SWITCH_DECLARE(void) switch_odbc_handle_destroy(switch_odbc_handle_t **handlep);
</span><span class="cx"> SWITCH_DECLARE(switch_odbc_state_t) switch_odbc_handle_get_state(switch_odbc_handle_t *handle);
</span><del>-SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec(switch_odbc_handle_t *handle, const char *sql, switch_odbc_statement_handle_t * rstmt);
</del><ins>+SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec(switch_odbc_handle_t *handle, const char *sql, switch_odbc_statement_handle_t *rstmt, char **err);
</ins><span class="cx"> SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec_string(switch_odbc_handle_t *handle,
</span><span class="cx">                                                                                                                                         const char *sql,
</span><span class="cx">                                                                                                                                         char *resbuf,
</span><del>-                                                                                                                                        size_t len);
</del><ins>+                                                                                                                                        size_t len,
+                                                                                                                                        char **err);
</ins><span class="cx"> SWITCH_DECLARE(switch_bool_t) switch_odbc_available(void);
</span><span class="cx"> SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_statement_handle_free(switch_odbc_statement_handle_t * stmt);
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_easyroutemod_easyroutec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -152,10 +152,10 @@
</span><span class="cx">                 }
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Connected ODBC DSN: %s\n&quot;, globals.db_dsn);
</span><span class="cx">                 if (!globals.custom_query){
</span><del>-                        if (switch_odbc_handle_exec(globals.master_odbc, &quot;select count(*) from numbers&quot;, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                        if (switch_odbc_handle_exec(globals.master_odbc, &quot;select count(*) from numbers&quot;, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Cannot find  SQL Database! (Where\'s the numbers table\?\?)\n&quot;);
</span><span class="cx">                         }
</span><del>-                        if (switch_odbc_handle_exec(globals.master_odbc, &quot;select count(*) from gateways&quot;, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                        if (switch_odbc_handle_exec(globals.master_odbc, &quot;select count(*) from gateways&quot;, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Cannot find  SQL Database! (Where\'s the gateways table\?\?)\n&quot;);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_nibblebillmod_nibblebillc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_nibblebill/mod_nibblebill.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_nibblebill/mod_nibblebill.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/applications/mod_nibblebill/mod_nibblebill.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -308,7 +308,7 @@
</span><span class="cx">         switch_snprintf(sql, 1024, SQL_SAVE, globals.db_table, globals.db_column_cash, globals.db_column_cash, billamount, globals.db_column_account, billaccount);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,  &quot;Doing update query\n[%s]\n&quot;, sql);
</span><span class="cx"> 
</span><del>-        if (switch_odbc_handle_exec(globals.master_odbc, sql, &amp;stmt) != SWITCH_ODBC_SUCCESS) {
</del><ins>+        if (switch_odbc_handle_exec(globals.master_odbc, sql, &amp;stmt, NULL) != SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                 char *err_str;
</span><span class="cx">                 err_str = switch_odbc_handle_get_error(globals.master_odbc, stmt);
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;ERR: [%s]\n[%s]\n&quot;, sql, switch_str_nil(err_str));
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_dingalingmod_dingalingc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -271,7 +271,7 @@
</span><span class="cx"> 
</span><span class="cx">         if (switch_odbc_available() &amp;&amp; profile-&gt;odbc_dsn) {
</span><span class="cx">                 switch_odbc_statement_handle_t stmt;
</span><del>-                if (switch_odbc_handle_exec(profile-&gt;master_odbc, sql, &amp;stmt) != SWITCH_ODBC_SUCCESS) {
</del><ins>+                if (switch_odbc_handle_exec(profile-&gt;master_odbc, sql, &amp;stmt, NULL) != SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                         char *err_str;
</span><span class="cx">                         err_str = switch_odbc_handle_get_error(profile-&gt;master_odbc, stmt);
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;ERR: [%s]\n[%s]\n&quot;, sql, switch_str_nil(err_str));
</span><span class="lines">@@ -2432,7 +2432,7 @@
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Connected ODBC DSN: %s\n&quot;, profile-&gt;odbc_dsn);
</span><del>-                                switch_odbc_handle_exec(profile-&gt;master_odbc, sub_sql, NULL);
</del><ins>+                                switch_odbc_handle_exec(profile-&gt;master_odbc, sub_sql, NULL, NULL);
</ins><span class="cx">                                 //mdl_execute_sql(profile, sub_sql, NULL);
</span><span class="cx">                         } else {
</span><span class="cx">                                 if ((db = switch_core_db_open_file(profile-&gt;dbname))) {
</span><span class="lines">@@ -2581,7 +2581,7 @@
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Connected ODBC DSN: %s\n&quot;, profile-&gt;odbc_dsn);
</span><del>-                                switch_odbc_handle_exec(profile-&gt;master_odbc, sub_sql, NULL);
</del><ins>+                                switch_odbc_handle_exec(profile-&gt;master_odbc, sub_sql, NULL, NULL);
</ins><span class="cx">                                 //mdl_execute_sql(profile, sub_sql, NULL);
</span><span class="cx">                         } else {
</span><span class="cx">                                 if ((db = switch_core_db_open_file(profile-&gt;dbname))) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -3436,7 +3436,7 @@
</span><span class="cx">                                 if (sip &amp;&amp; 
</span><span class="cx">                                         sip-&gt;sip_from &amp;&amp; sip-&gt;sip_from-&gt;a_url &amp;&amp; sip-&gt;sip_from-&gt;a_url-&gt;url_user &amp;&amp; sip-&gt;sip_from-&gt;a_url-&gt;url_host &amp;&amp;
</span><span class="cx">                                         sip-&gt;sip_to &amp;&amp; sip-&gt;sip_to-&gt;a_url &amp;&amp; sip-&gt;sip_to-&gt;a_url-&gt;url_user &amp;&amp; sip-&gt;sip_to-&gt;a_url-&gt;url_host) {
</span><del>-                                        sql = switch_mprintf(&quot;select 'appearance-index=1' from sip_subscriptions where expires &gt; -1 &amp;&amp; hostname='%q' and event='call-info' and &quot;
</del><ins>+                                        sql = switch_mprintf(&quot;select 'appearance-index=1' from sip_subscriptions where expires &gt; -1 and hostname='%q' and event='call-info' and &quot;
</ins><span class="cx">                                                                                  &quot;sub_to_user='%q' and sub_to_host='%q'&quot;, 
</span><span class="cx">                                                                                  mod_sofia_globals.hostname, sip-&gt;sip_to-&gt;a_url-&gt;url_user, sip-&gt;sip_from-&gt;a_url-&gt;url_host);
</span><span class="cx">                                         sofia_glue_execute_sql2str(profile, profile-&gt;ireg_mutex, sql, buf, sizeof(buf));
</span><span class="lines">@@ -4242,9 +4242,20 @@
</span><span class="cx">                                                                 switch_channel_presence(tech_pvt-&gt;channel, &quot;unknown&quot;, &quot;unhold&quot;, NULL);
</span><span class="cx">                                                         }
</span><span class="cx">                                                 } else if (switch_stristr(&quot;sendonly&quot;, r_sdp)) {
</span><ins>+                                                        const char *msg = &quot;hold&quot;;
+                                                        
+                                                        if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
+                                                                const char *info = switch_channel_get_variable(channel, &quot;presence_call_info&quot;);
+                                                                if (info) {
+                                                                        if (switch_stristr(&quot;private&quot;, info)) {
+                                                                                msg = &quot;hold-private&quot;;
+                                                                        }
+                                                                }
+                                                        }
+
</ins><span class="cx">                                                         sofia_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
</span><span class="cx">                                                         switch_channel_set_flag(channel, CF_LEG_HOLDING);
</span><del>-                                                        switch_channel_presence(tech_pvt-&gt;channel, &quot;unknown&quot;, &quot;hold&quot;, NULL);
</del><ins>+                                                        switch_channel_presence(tech_pvt-&gt;channel, &quot;unknown&quot;, msg, NULL);
</ins><span class="cx">                                                 }
</span><span class="cx">                                         
</span><span class="cx">                                                 switch_core_session_queue_message(other_session, msg);
</span><span class="lines">@@ -5693,6 +5704,11 @@
</span><span class="cx">         if (!destination_number &amp;&amp; sip-&gt;sip_to &amp;&amp; sip-&gt;sip_to-&gt;a_url) {
</span><span class="cx">                 destination_number = sip-&gt;sip_to-&gt;a_url-&gt;url_user;
</span><span class="cx">         }
</span><ins>+
+        /* The human network, OH THE HUMANITY!!! lets send invites with no number! */
+        if (!destination_number &amp;&amp; sip-&gt;sip_from &amp;&amp; sip-&gt;sip_from-&gt;a_url) {
+                destination_number = sip-&gt;sip_from-&gt;a_url-&gt;url_user;
+        }
</ins><span class="cx">         
</span><span class="cx">         if (destination_number) {
</span><span class="cx">                 check_decode(destination_number, session);
</span><span class="lines">@@ -5957,20 +5973,36 @@
</span><span class="cx">                 char cid[512] = &quot;&quot;;
</span><span class="cx">                 char *str;
</span><span class="cx">                 char *p = NULL;
</span><ins>+                const char *user = NULL, *host = NULL;
+                
+                if (sip-&gt;sip_to &amp;&amp; sip-&gt;sip_to-&gt;a_url) {
+                        user = sip-&gt;sip_to-&gt;a_url-&gt;url_user;
+                        host = sip-&gt;sip_to-&gt;a_url-&gt;url_host;
+                }
</ins><span class="cx"> 
</span><ins>+                if (!user || !host) {
+                        if (sip-&gt;sip_from &amp;&amp; sip-&gt;sip_from-&gt;a_url) {
+                                if (!user) user = sip-&gt;sip_from-&gt;a_url-&gt;url_user;
+                                if (!host) host = sip-&gt;sip_from-&gt;a_url-&gt;url_host;
+                        }
+                }
</ins><span class="cx"> 
</span><del>-                if (sip-&gt;sip_to &amp;&amp; sip-&gt;sip_to-&gt;a_url) {
</del><ins>+                if (user &amp;&amp; host) {
</ins><span class="cx">                         if ((p = strchr(call_info_str, ';'))) {
</span><span class="cx">                                 p++;
</span><span class="cx">                         }
</span><ins>+                        
+                        sql = switch_mprintf(&quot;select call_id from sip_dialogs where call_info='%q' and sip_from_user='%q' and sip_from_host='%q' and call_id is not null&quot;, 
+                                                                 switch_str_nil(p), user, host);
</ins><span class="cx"> 
</span><del>-                        sql = switch_mprintf(&quot;select call_id from sip_dialogs where call_info='%q' and sip_from_user='%q' and sip_from_host='%q'&quot;, 
-                                                                 switch_str_nil(p), sip-&gt;sip_to-&gt;a_url-&gt;url_user, sip-&gt;sip_to-&gt;a_url-&gt;url_host);
-                        
</del><span class="cx">                         if ((str = sofia_glue_execute_sql2str(profile, profile-&gt;ireg_mutex, sql, cid, sizeof(cid)))) {
</span><span class="cx">                                 bnh = nua_handle_by_call_id(nua, str);
</span><span class="cx">                         }
</span><span class="cx"> 
</span><ins>+                        if (mod_sofia_globals.debug_sla &gt; 1) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;PICK SQL %s [%s] [%s] %d\n&quot;, sql, str, cid, !!bnh);
+                        }
+                        
</ins><span class="cx">                         free(sql);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -5991,7 +6023,7 @@
</span><span class="cx">                                 private_object_t *b_tech_pvt = NULL;
</span><span class="cx">                                 const char *app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE);
</span><span class="cx">                                 const char *data = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                                 if (app &amp;&amp; data &amp;&amp; !strcasecmp(app, &quot;conference&quot;)) {
</span><span class="cx">                                         destination_number = switch_core_session_sprintf(b_session, &quot;answer,conference:%s&quot;, data);
</span><span class="cx">                                         dialplan = &quot;inline&quot;;
</span><span class="lines">@@ -5999,7 +6031,7 @@
</span><span class="cx">                                         if (switch_core_session_check_interface(b_session, sofia_endpoint_interface)) {
</span><span class="cx">                                                 b_tech_pvt = switch_core_session_get_private(b_session);
</span><span class="cx">                                         }
</span><del>-
</del><ins>+                                        
</ins><span class="cx">                                         if ((uuid = switch_channel_get_variable(b_channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
</span><span class="cx">                                                 switch_channel_set_variable(b_channel, &quot;presence_call_info&quot;, NULL);
</span><span class="cx">                                                 one_leg = 0;
</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 (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -3934,9 +3934,6 @@
</span><span class="cx">                         &quot;create index ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)&quot;,
</span><span class="cx">                         &quot;create index ssa_aor on sip_shared_appearance_subscriptions (aor)&quot;,
</span><span class="cx">                         &quot;create index ssd_profile_name on sip_shared_appearance_dialogs (profile_name)&quot;,
</span><del>-                        &quot;create index ssd_contact on sip_shared_appearance_dialogs (contact)&quot;,
-                        &quot;create index ssd_presence_id on sip_shared_appearance_dialogs (presence_id)&quot;,
-                        &quot;create index ssd_presence_data on sip_shared_appearance_dialogs (presence_data)&quot;,
</del><span class="cx">                         &quot;create index ssd_hostname on sip_shared_appearance_dialogs (hostname)&quot;,
</span><span class="cx">                         &quot;create index ssd_contact_str on sip_shared_appearance_dialogs (contact_str)&quot;,
</span><span class="cx">                         &quot;create index ssd_call_id on sip_shared_appearance_dialogs (call_id)&quot;,
</span><span class="lines">@@ -3963,9 +3960,9 @@
</span><span class="cx">                                                                   &quot;like '%%' and mwi_user  like '%%' and mwi_host like '%%'&quot;, 
</span><span class="cx">                                                                   mod_sofia_globals.hostname);
</span><span class="cx"> 
</span><del>-                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
-                        switch_odbc_handle_exec(odbc_dbh, &quot;DROP TABLE sip_registrations&quot;, NULL);
-                        switch_odbc_handle_exec(odbc_dbh, reg_sql, NULL);
</del><ins>+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, &quot;DROP TABLE sip_registrations&quot;, NULL, NULL);
+                        switch_odbc_handle_exec(odbc_dbh, reg_sql, NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -3973,7 +3970,7 @@
</span><span class="cx">                 if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
</span><span class="cx">                         char *test2 = switch_mprintf(&quot;%s;%s&quot;, test_sql, test_sql);
</span><span class="cx"> 
</span><del>-                        if (switch_odbc_handle_exec(odbc_dbh, test2, NULL) != SWITCH_ODBC_SUCCESS) {
</del><ins>+                        if (switch_odbc_handle_exec(odbc_dbh, test2, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;GREAT SCOTT!!! Cannot execute batched statements!\n&quot;
</span><span class="cx">                                                                   &quot;If you are using mysql, make sure you are using MYODBC 3.51.18 or higher and enable FLAG_MULTI_STATEMENTS\n&quot;);
</span><span class="cx">                                 sofia_clear_pflag(profile, PFLAG_SQL_IN_TRANS);
</span><span class="lines">@@ -3988,55 +3985,55 @@
</span><span class="cx">                 test_sql = switch_mprintf(&quot;delete from sip_subscriptions where hostname='%q' and network_ip like '%%' and network_port like '%%'&quot;, 
</span><span class="cx">                                                                   mod_sofia_globals.hostname);
</span><span class="cx"> 
</span><del>-                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
-                        switch_odbc_handle_exec(odbc_dbh, &quot;DROP TABLE sip_subscriptions&quot;, NULL);
-                        switch_odbc_handle_exec(odbc_dbh, sub_sql, NULL);
</del><ins>+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, &quot;DROP TABLE sip_subscriptions&quot;, NULL, NULL);
+                        switch_odbc_handle_exec(odbc_dbh, sub_sql, NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 free(test_sql);
</span><span class="cx">                 test_sql = switch_mprintf(&quot;delete from sip_dialogs where hostname='%q' and expires &gt; 0&quot;, mod_sofia_globals.hostname);
</span><span class="cx"> 
</span><del>-                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
-                        switch_odbc_handle_exec(odbc_dbh, &quot;DROP TABLE sip_dialogs&quot;, NULL);
-                        switch_odbc_handle_exec(odbc_dbh, dialog_sql, NULL);
</del><ins>+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, &quot;DROP TABLE sip_dialogs&quot;, NULL, NULL);
+                        switch_odbc_handle_exec(odbc_dbh, dialog_sql, NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 test_sql = switch_mprintf(&quot;delete from sip_presence where hostname='%q' &quot;, mod_sofia_globals.hostname);
</span><span class="cx"> 
</span><del>-                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
-                        switch_odbc_handle_exec(odbc_dbh, &quot;DROP TABLE sip_presence&quot;, NULL);
-                        switch_odbc_handle_exec(odbc_dbh, pres_sql, NULL);
</del><ins>+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, &quot;DROP TABLE sip_presence&quot;, NULL, NULL);
+                        switch_odbc_handle_exec(odbc_dbh, pres_sql, NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 free(test_sql);
</span><span class="cx">                 test_sql = switch_mprintf(&quot;delete from sip_authentication where hostname='%q' or last_nc &gt;= 0&quot;, mod_sofia_globals.hostname);
</span><span class="cx"> 
</span><del>-                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
-                        switch_odbc_handle_exec(odbc_dbh, &quot;DROP TABLE sip_authentication&quot;, NULL);
-                        switch_odbc_handle_exec(odbc_dbh, auth_sql, NULL);
</del><ins>+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, &quot;DROP TABLE sip_authentication&quot;, NULL, NULL);
+                        switch_odbc_handle_exec(odbc_dbh, auth_sql, NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx">                 free(test_sql);
</span><span class="cx"> 
</span><span class="cx">                 test_sql = switch_mprintf(&quot;delete from sip_shared_appearance_subscriptions where contact_str='' or hostname='%q' and network_ip like '%%'&quot;,
</span><span class="cx">                                                                   mod_sofia_globals.hostname);
</span><del>-                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
-                        switch_odbc_handle_exec(odbc_dbh, &quot;DROP TABLE sip_shared_appearance_subscriptions&quot;, NULL);
-                        switch_odbc_handle_exec(odbc_dbh, shared_appearance_sql, NULL);
</del><ins>+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, &quot;DROP TABLE sip_shared_appearance_subscriptions&quot;, NULL, NULL);
+                        switch_odbc_handle_exec(odbc_dbh, shared_appearance_sql, NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx">                 free(test_sql);
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">                 test_sql = switch_mprintf(&quot;delete from sip_shared_appearance_dialogs where contact_str='' or hostname='%q' and network_ip like '%%'&quot;,
</span><span class="cx">                                                                   mod_sofia_globals.hostname);
</span><del>-                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
-                        switch_odbc_handle_exec(odbc_dbh, &quot;DROP TABLE sip_shared_appearance_dialogs&quot;, NULL);
-                        switch_odbc_handle_exec(odbc_dbh, shared_appearance_dialogs_sql, NULL);
</del><ins>+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, &quot;DROP TABLE sip_shared_appearance_dialogs&quot;, NULL, NULL);
+                        switch_odbc_handle_exec(odbc_dbh, shared_appearance_dialogs_sql, NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx">                 free(test_sql);
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">                 for (x = 0; indexes[x]; x++) {
</span><del>-                        switch_odbc_handle_exec(odbc_dbh, indexes[x], NULL);
</del><ins>+                        switch_odbc_handle_exec(odbc_dbh, indexes[x], NULL, NULL);
</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 (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -599,25 +599,37 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if (call_info) {
</span><ins>+                        const char *uuid = switch_event_get_header(event, &quot;unique-id&quot;);
</ins><span class="cx">                         
</span><ins>+
</ins><span class="cx"> #if 0
</span><span class="cx">                         if (mod_sofia_globals.debug_sla &gt; 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;SLA EVENT:\n&quot;);
</span><span class="cx">                                 DUMP_EVENT(event);
</span><span class="cx">                         }
</span><span class="cx"> #endif
</span><del>-                        
-                        sql = switch_mprintf(&quot;update sip_dialogs set call_info_state='%q' where hostname='%q' and sip_dialogs.sip_from_user='%q' &quot;
-                                                                 &quot;and sip_dialogs.sip_from_host='%q' and call_info='%q'&quot;, 
-                                                                 call_info_state, 
-                                                                 mod_sofia_globals.hostname,
-                                                                 euser, host, call_info);
</del><span class="cx"> 
</span><ins>+                        if (uuid) {
+                                sql = switch_mprintf(&quot;update sip_dialogs set call_info_state='%q' where hostname='%q' and uuid='%q'&quot;,
+                                                                         call_info_state, 
+                                                                         mod_sofia_globals.hostname,
+                                                                         uuid);
+                        } else {
+                                sql = switch_mprintf(&quot;update sip_dialogs set call_info_state='%q' where hostname='%q' and sip_dialogs.sip_from_user='%q' &quot;
+                                                                         &quot;and sip_dialogs.sip_from_host='%q' and call_info='%q'&quot;, 
+                                                                         call_info_state, 
+                                                                         mod_sofia_globals.hostname,
+                                                                         euser, host, call_info);
+                                
+                        }
+
</ins><span class="cx">                         if (mod_sofia_globals.debug_sla &gt; 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;STATE SQL %s\n&quot;, sql);
</span><span class="cx">                         }
</span><span class="cx">                         sofia_glue_execute_sql_now(profile, &amp;sql, SWITCH_TRUE);
</span><span class="cx">                         
</span><ins>+
+
</ins><span class="cx">                         if (mod_sofia_globals.debug_sla &gt; 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;PROCESS PRESENCE EVENT\n&quot;);
</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 (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -768,14 +768,23 @@
</span><span class="cx">         authorization = sip-&gt;sip_authorization;
</span><span class="cx">         contact = sip-&gt;sip_contact;
</span><span class="cx">         to = sip-&gt;sip_to;
</span><ins>+        from = sip-&gt;sip_from;
</ins><span class="cx"> 
</span><ins>+        if (from) {
+                from_user = from-&gt;a_url-&gt;url_user;
+                from_host = from-&gt;a_url-&gt;url_host;
+        }
+        
</ins><span class="cx">         if (to) {
</span><span class="cx">                 to_user = to-&gt;a_url-&gt;url_user;
</span><span class="cx">                 to_host = to-&gt;a_url-&gt;url_host;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        if (!to_user) to_user = from_user;
+        if (!to_host) to_host = from_host;
+
</ins><span class="cx">         if (!to_user || !to_host) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Can not do authorization without a complete from header\n&quot;);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Can not do authorization without a complete header\n&quot;);
</ins><span class="cx">                 nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS(nua), TAG_END());
</span><span class="cx">                 switch_goto_int(r, 1, end);
</span><span class="cx">         }
</span><span class="lines">@@ -784,13 +793,6 @@
</span><span class="cx">                 reg_host = to_host;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        from = sip-&gt;sip_from;
-
-        if (from) {
-                from_user = from-&gt;a_url-&gt;url_user;
-                from_host = from-&gt;a_url-&gt;url_host;
-        }
-
</del><span class="cx">         if (contact-&gt;m_url) {
</span><span class="cx">                 const char *port = contact-&gt;m_url-&gt;url_port;
</span><span class="cx">                 char new_port[25] = &quot;&quot;;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_spidermonkey_odbcmod_spidermonkey_odbcc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -215,7 +215,7 @@
</span><span class="cx"> 
</span><span class="cx">         sql = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
</span><span class="cx"> 
</span><del>-        if (switch_odbc_handle_exec(odbc_obj-&gt;handle, sql, &amp;stmt) != SWITCH_ODBC_SUCCESS) {
</del><ins>+        if (switch_odbc_handle_exec(odbc_obj-&gt;handle, sql, &amp;stmt, NULL) != SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;[ODBC] Execute failed for: %s\n&quot;, sql);
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="lines">@@ -253,7 +253,7 @@
</span><span class="cx"> 
</span><span class="cx">         sql = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
</span><span class="cx"> 
</span><del>-        if (switch_odbc_handle_exec(odbc_obj-&gt;handle, sql, &amp;odbc_obj-&gt;stmt) != SWITCH_ODBC_SUCCESS) {
</del><ins>+        if (switch_odbc_handle_exec(odbc_obj-&gt;handle, sql, &amp;odbc_obj-&gt;stmt, NULL) != SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;[ODBC] query failed: %s\n&quot;, sql);
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_channelc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_channel.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_channel.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/switch_channel.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -505,6 +505,8 @@
</span><span class="cx">                                 call_info_state = &quot;idle&quot;;
</span><span class="cx">                         } else if (!strcasecmp(status, &quot;hold&quot;)) {
</span><span class="cx">                                 call_info_state = &quot;held&quot;;
</span><ins>+                        } else if (!strcasecmp(status, &quot;hold-private&quot;)) {
+                                call_info_state = &quot;held-private&quot;;
</ins><span class="cx">                         } else if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
</span><span class="cx">                                 if (channel-&gt;direction == SWITCH_CALL_DIRECTION_OUTBOUND) {
</span><span class="cx">                                         call_info_state = &quot;progressing&quot;;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_sqldbc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_sqldb.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_sqldb.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/switch_core_sqldb.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -380,7 +380,7 @@
</span><span class="cx">         case SCDB_TYPE_ODBC:
</span><span class="cx">                 {
</span><span class="cx">                         switch_odbc_statement_handle_t stmt = NULL;
</span><del>-                        if ((status = switch_odbc_handle_exec(dbh-&gt;native_handle.odbc_dbh, sql, &amp;stmt)) != SWITCH_ODBC_SUCCESS) {
</del><ins>+                        if ((status = switch_odbc_handle_exec(dbh-&gt;native_handle.odbc_dbh, sql, &amp;stmt, NULL)) != SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                                 errmsg = switch_odbc_handle_get_error(dbh-&gt;native_handle.odbc_dbh, stmt);
</span><span class="cx">                         }
</span><span class="cx">                         switch_odbc_statement_handle_free(&amp;stmt);
</span><span class="lines">@@ -548,7 +548,7 @@
</span><span class="cx">                 break;
</span><span class="cx">         case SCDB_TYPE_ODBC:
</span><span class="cx">                 {
</span><del>-                        status = switch_odbc_handle_exec_string(dbh-&gt;native_handle.odbc_dbh, sql, str, len);
</del><ins>+                        status = switch_odbc_handle_exec_string(dbh-&gt;native_handle.odbc_dbh, sql, str, len, err);
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="lines">@@ -738,12 +738,12 @@
</span><span class="cx">         switch (dbh-&gt;type) {
</span><span class="cx">         case SCDB_TYPE_ODBC:
</span><span class="cx">                 {
</span><del>-                        if (switch_odbc_handle_exec(dbh-&gt;native_handle.odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
</del><ins>+                        if (switch_odbc_handle_exec(dbh-&gt;native_handle.odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                                 r = SWITCH_FALSE;
</span><span class="cx">                                 if (drop_sql) {
</span><del>-                                        switch_odbc_handle_exec(dbh-&gt;native_handle.odbc_dbh, drop_sql, NULL);
</del><ins>+                                        switch_odbc_handle_exec(dbh-&gt;native_handle.odbc_dbh, drop_sql, NULL, NULL);
</ins><span class="cx">                                 }
</span><del>-                                switch_odbc_handle_exec(dbh-&gt;native_handle.odbc_dbh, reactive_sql, NULL);
</del><ins>+                                switch_odbc_handle_exec(dbh-&gt;native_handle.odbc_dbh, reactive_sql, NULL, NULL);
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_odbcc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_odbc.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_odbc.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/switch_odbc.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -344,7 +344,8 @@
</span><span class="cx"> SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec_string(switch_odbc_handle_t *handle,
</span><span class="cx">                                                                                                                                         const char *sql,
</span><span class="cx">                                                                                                                                         char *resbuf,
</span><del>-                                                                                                                                        size_t len)
</del><ins>+                                                                                                                                        size_t len,
+                                                                                                                                        char **err)
</ins><span class="cx"> {
</span><span class="cx"> #ifdef SWITCH_HAVE_ODBC
</span><span class="cx">         switch_odbc_status_t sstatus = SWITCH_ODBC_FAIL;
</span><span class="lines">@@ -352,21 +353,27 @@
</span><span class="cx">         SQLCHAR name[1024];
</span><span class="cx">         SQLLEN m = 0;
</span><span class="cx"> 
</span><del>-        if (switch_odbc_handle_exec(handle, sql, &amp;stmt) == SWITCH_ODBC_SUCCESS) {
</del><ins>+        if (switch_odbc_handle_exec(handle, sql, &amp;stmt, err) == SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                 SQLSMALLINT NameLength, DataType, DecimalDigits, Nullable;
</span><span class="cx">                 SQLULEN ColumnSize;
</span><ins>+                int result;
+                
</ins><span class="cx">                 SQLRowCount(stmt, &amp;m);
</span><span class="cx"> 
</span><span class="cx">                 if (m &lt;= 0) {
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if (SQLFetch(stmt) != SQL_SUCCESS) {
</del><ins>+                result = SQLExecute(stmt);
+                result = SQLFetch(stmt);
+                
+                if (result != SQL_SUCCESS &amp;&amp; result != SQL_SUCCESS_WITH_INFO &amp;&amp; result != SQL_NO_DATA) {
</ins><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><del>-
</del><ins>+                
</ins><span class="cx">                 SQLDescribeCol(stmt, 1, name, sizeof(name), &amp;NameLength, &amp;DataType, &amp;ColumnSize, &amp;DecimalDigits, &amp;Nullable);
</span><span class="cx">                 SQLGetData(stmt, 1, SQL_C_CHAR, (SQLCHAR *) resbuf, (SQLLEN) len, NULL);
</span><ins>+                
</ins><span class="cx">                 sstatus = SWITCH_ODBC_SUCCESS;
</span><span class="cx">         } else {
</span><span class="cx">                 return sstatus;
</span><span class="lines">@@ -380,11 +387,12 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec(switch_odbc_handle_t *handle, const char *sql, switch_odbc_statement_handle_t * rstmt)
</del><ins>+SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec(switch_odbc_handle_t *handle, const char *sql, switch_odbc_statement_handle_t *rstmt, char **err)
</ins><span class="cx"> {
</span><span class="cx"> #ifdef SWITCH_HAVE_ODBC
</span><span class="cx">         SQLHSTMT stmt = NULL;
</span><span class="cx">         int result;
</span><ins>+        char *err_str = NULL;
</ins><span class="cx"> 
</span><span class="cx">         if (!db_is_up(handle)) {
</span><span class="cx">                 goto error;
</span><span class="lines">@@ -413,6 +421,22 @@
</span><span class="cx">         return SWITCH_ODBC_SUCCESS;
</span><span class="cx"> 
</span><span class="cx">   error:
</span><ins>+
+        if (stmt) {
+                err_str = switch_odbc_handle_get_error(handle, stmt);
+        }
+
+        if (err_str) {
+                if (!switch_stristr(&quot;already exists&quot;, err_str)) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;ERR: [%s]\n[%s]\n&quot;, sql, switch_str_nil(err_str));
+                }
+                if (err) {
+                        *err = err_str;
+                } else {
+                        free(err_str);
+                }
+        }
+
</ins><span class="cx">         if (rstmt) {
</span><span class="cx">                 *rstmt = stmt;
</span><span class="cx">         } else if (stmt) {
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>