Author: anthm Date: Thu Nov 15 11:55:46 2007 New Revision: 6275 Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Log: fix MODENDP-35 Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (original) +++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Thu Nov 15 11:55:46 2007 @@ -202,14 +202,14 @@ var = (char *) switch_xml_attr_soft(param, "name"); val = (char *) switch_xml_attr_soft(param, "value"); - if (!strcasecmp(var, "odbc-dsn")) { + if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) { #ifdef SWITCH_HAVE_ODBC globals.odbc_dsn = switch_core_strdup(globals.pool, val); if ((odbc_user = strchr(globals.odbc_dsn, ':'))) { *odbc_user++ = '\0'; - } - if ((odbc_pass = strchr(odbc_user, ':'))) { - *odbc_pass++ = '\0'; + if ((odbc_pass = strchr(odbc_user, ':'))) { + *odbc_pass++ = '\0'; + } } #else switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n"); Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (original) +++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Thu Nov 15 11:55:46 2007 @@ -416,14 +416,14 @@ } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "invalid attempts [%s] must be between 1 and 10000s\n", val); } - } else if (!strcasecmp(var, "odbc-dsn")) { + } else if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) { #ifdef SWITCH_HAVE_ODBC odbc_dsn = switch_core_strdup(globals.pool, val); if ((odbc_user = strchr(odbc_dsn, ':'))) { *odbc_user++ = '\0'; - } - if ((odbc_pass = strchr(odbc_user, ':'))) { - *odbc_pass++ = '\0'; + if ((odbc_pass = strchr(odbc_user, ':'))) { + *odbc_pass++ = '\0'; + } } #else switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n"); Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Thu Nov 15 11:55:46 2007 @@ -1918,14 +1918,14 @@ profile->password = switch_core_strdup(module_pool, val); } else if (!strcasecmp(var, "avatar")) { profile->avatar = switch_core_strdup(module_pool, val); - } else if (!strcasecmp(var, "odbc-dsn")) { + } else if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) { #ifdef SWITCH_HAVE_ODBC profile->odbc_dsn = switch_core_strdup(module_pool, val); if ((profile->odbc_user = strchr(profile->odbc_dsn, ':'))) { *profile->odbc_user++ = '\0'; - } - if ((profile->odbc_pass = strchr(profile->odbc_user, ':'))) { - *profile->odbc_pass++ = '\0'; + if ((profile->odbc_pass = strchr(profile->odbc_user, ':'))) { + *profile->odbc_pass++ = '\0'; + } } Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Thu Nov 15 11:55:46 2007 @@ -1353,7 +1353,7 @@ cb.profile = profile; cb.stream = &mystream; - sql = switch_mprintf("select contact from sip_registrations where user='%q' and host='%q'", user, domain); + sql = switch_mprintf("select contact from sip_registrations where sip_user='%q' and sip_host='%q'", user, domain); assert(sql); sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, contact_callback, &cb); switch_safe_free(sql); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Thu Nov 15 11:55:46 2007 @@ -167,7 +167,7 @@ user = sip->sip_to->a_url->url_user; host = sip->sip_to->a_url->url_host; - sql = switch_mprintf("delete from sip_registrations where user='%q' and host='%q'", user, host); + sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", user, host); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Deleting registration for %s@%s\n", user, host); sofia_glue_execute_sql(profile, SWITCH_TRUE, sql, NULL); switch_safe_free(sql); @@ -287,7 +287,7 @@ if (sofia_test_pflag(profile, PFLAG_MULTIREG)) { sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id); } else { - sql = switch_mprintf("delete from sip_registrations where user='%q' and host='%q'", from_user, from_host); + sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", from_user, from_host); } switch_mutex_lock(profile->ireg_mutex); @@ -820,14 +820,14 @@ } else if (!strcasecmp(var, "use-rtp-timer") && switch_true(val)) { switch_set_flag(profile, TFLAG_TIMER); - } else if (!strcasecmp(var, "odbc-dsn")) { + } else if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) { #ifdef SWITCH_HAVE_ODBC profile->odbc_dsn = switch_core_strdup(profile->pool, val); if ((profile->odbc_user = strchr(profile->odbc_dsn, ':'))) { *profile->odbc_user++ = '\0'; - } - if ((profile->odbc_pass = strchr(profile->odbc_user, ':'))) { - *profile->odbc_pass++ = '\0'; + if ((profile->odbc_pass = strchr(profile->odbc_user, ':'))) { + *profile->odbc_pass++ = '\0'; + } } #else Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Thu Nov 15 11:55:46 2007 @@ -1716,19 +1716,20 @@ char reg_sql[] = "CREATE TABLE sip_registrations (\n" " call_id VARCHAR(255),\n" - " user VARCHAR(255),\n" - " host VARCHAR(255),\n" + " sip_user VARCHAR(255),\n" + " sip_host VARCHAR(255),\n" " contact VARCHAR(1024),\n" " status VARCHAR(255),\n" " rpid VARCHAR(255),\n" - " expires INTEGER(8)" ");\n"; + " expires INTEGER" + ");\n"; char sub_sql[] = "CREATE TABLE sip_subscriptions (\n" " proto VARCHAR(255),\n" - " user VARCHAR(255),\n" - " host VARCHAR(255),\n" + " sip_user VARCHAR(255),\n" + " sip_host VARCHAR(255),\n" " sub_to_user VARCHAR(255),\n" " sub_to_host VARCHAR(255),\n" " event VARCHAR(255),\n" @@ -1736,13 +1737,14 @@ " call_id VARCHAR(255),\n" " full_from VARCHAR(255),\n" " full_via VARCHAR(255),\n" - " expires INTEGER(8)" ");\n"; + " expires INTEGER" + ");\n"; char auth_sql[] = "CREATE TABLE sip_authentication (\n" " nonce VARCHAR(255),\n" - " expires INTEGER(8)" + " expires INTEGER" ");\n"; #ifdef SWITCH_HAVE_ODBC @@ -1757,12 +1759,12 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected ODBC DSN: %s\n", profile->odbc_dsn); - if (switch_odbc_handle_exec(profile->master_odbc, "select call_id from sip_registrations", NULL) != SWITCH_ODBC_SUCCESS) { + if (switch_odbc_handle_exec(profile->master_odbc, "select sip_user from sip_registrations", NULL) != SWITCH_ODBC_SUCCESS) { switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_registrations", NULL); switch_odbc_handle_exec(profile->master_odbc, reg_sql, NULL); } - if (switch_odbc_handle_exec(profile->master_odbc, "delete from sip_subscriptions", NULL) != SWITCH_ODBC_SUCCESS) { + if (switch_odbc_handle_exec(profile->master_odbc, "delete from sip_subscriptions where sip_user != ''", NULL) != SWITCH_ODBC_SUCCESS) { switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_subscriptions", NULL); switch_odbc_handle_exec(profile->master_odbc, sub_sql, NULL); } @@ -1777,8 +1779,8 @@ return 0; } - switch_core_db_test_reactive(profile->master_db, "select call_id from sip_registrations", "DROP TABLE sip_registrations", reg_sql); - switch_core_db_test_reactive(profile->master_db, "delete from sip_subscriptions", "DROP TABLE sip_subscriptions", sub_sql); + switch_core_db_test_reactive(profile->master_db, "select sip_user from sip_registrations", "DROP TABLE sip_registrations", reg_sql); + switch_core_db_test_reactive(profile->master_db, "delete from sip_subscriptions where sip_user != ''", "DROP TABLE sip_subscriptions", sub_sql); switch_core_db_test_reactive(profile->master_db, "select * from sip_authentication", "DROP TABLE sip_authentication", auth_sql); #ifdef SWITCH_HAVE_ODBC Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Thu Nov 15 11:55:46 2007 @@ -136,7 +136,7 @@ { if (sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, - "select user,host,'Registered','unknown','' from sip_registrations", + "select sip_user,sip_host,'Registered','unknown','' from sip_registrations", sofia_presence_resub_callback, profile) != SWITCH_TRUE) { return; } @@ -364,7 +364,7 @@ } if (euser && host && - (sql = switch_mprintf("select user,host,status,rpid,'' from sip_registrations where user='%q' and host='%q'", + (sql = switch_mprintf("select user,host,status,rpid,'' from sip_registrations where sip_user='%q' and sip_host='%q'", euser, host)) && (profile = sofia_glue_find_profile(host))) { sofia_glue_execute_sql_callback(profile, @@ -846,7 +846,7 @@ switch_safe_free(sstr); - if ((sql = switch_mprintf("select * from sip_subscriptions where user='%q' and host='%q'", to_user, to_host, to_user, to_host))) { + if ((sql = switch_mprintf("select * from sip_subscriptions where sip_user='%q' and sip_host='%q'", to_user, to_host, to_user, to_host))) { sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, @@ -941,7 +941,7 @@ } if ((sql = - switch_mprintf("update sip_registrations set status='%q',rpid='%q' where user='%q' and host='%q'", + switch_mprintf("update sip_registrations set status='%q',rpid='%q' where sip_user='%q' and sip_host='%q'", note_txt, rpid, from_user, from_host))) { sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex); switch_safe_free(sql); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Thu Nov 15 11:55:46 2007 @@ -269,9 +269,9 @@ cbt.len = len; if (host) { - snprintf(val, len, "select contact from sip_registrations where user='%s' and host='%s'", user, host); + snprintf(val, len, "select contact from sip_registrations where sip_user='%s' and sip_host='%s'", user, host); } else { - snprintf(val, len, "select contact from sip_registrations where user='%s'", user); + snprintf(val, len, "select contact from sip_registrations where sip_user='%s'", user); } @@ -483,7 +483,7 @@ if (sofia_test_pflag(profile, PFLAG_MULTIREG)) { sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id); } else { - sql = switch_mprintf("delete from sip_registrations where user='%q' and host='%q'", to_user, to_host); + sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", to_user, to_host); } switch_mutex_lock(profile->ireg_mutex); sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, NULL); @@ -536,7 +536,7 @@ if ((p = strchr(icontact + 4, ':'))) { *p = '\0'; } - if ((sql = switch_mprintf("delete from sip_subscriptions where user='%q' and host='%q' and contact like '%%%q%%'", to_user, to_host, icontact))) { + if ((sql = switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q' and contact like '%%%q%%'", to_user, to_host, icontact))) { sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex); switch_safe_free(sql); sql = NULL; @@ -549,13 +549,13 @@ } switch_safe_free(icontact); } else { - if ((sql = switch_mprintf("delete from sip_subscriptions where user='%q' and host='%q'", to_user, to_host))) { + if ((sql = switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q'", to_user, to_host))) { sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex); switch_safe_free(sql); sql = NULL; } - if ((sql = switch_mprintf("delete from sip_registrations where user='%q' and host='%q'", to_user, to_host))) { + if ((sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", to_user, to_host))) { sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex); switch_safe_free(sql); sql = NULL;