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