]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix MODENDP-35
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 15 Nov 2007 16:55:46 +0000 (16:55 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 15 Nov 2007 16:55:46 +0000 (16:55 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6275 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_limit/mod_limit.c
src/mod/applications/mod_voicemail/mod_voicemail.c
src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_presence.c
src/mod/endpoints/mod_sofia/sofia_reg.c

index b3134329e6c36d3184b0ecb8202ded2a150667e6..7d332a43d186ca4bde5dab09fd8e0d3618f61ca5 100644 (file)
@@ -202,14 +202,14 @@ static switch_status_t do_config()
             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");
index 93ca73b8ad9a2a5e37ca17ec709ce7314f6f4262..429c36c7ae41d820fb7bba16ae14f005334f2bae 100644 (file)
@@ -416,14 +416,14 @@ static switch_status_t load_config(void)
                 } 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");
index 52d558af85ce852062b7bb754b02f7f193adbb5d..e3d342523d9e930bf3af16feb337245c1e7583b3 100644 (file)
@@ -1918,14 +1918,14 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val)
                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';
+                       }
                }
                
                
index 8bf9a0c7f5a193830717c9073fa2f25b4d356d47..b0a4ce308fe0bea1af538bfa8d5fa6486015c044 100644 (file)
@@ -1353,7 +1353,7 @@ SWITCH_STANDARD_API(sofia_contact_function)
                        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);
index ac3f0b29d3881fed98f5f72b14d8eb52cbacb5c1..d48e2400ada8a3dd182976d4859999cbeab1ad7b 100644 (file)
@@ -167,7 +167,7 @@ void sofia_event_callback(nua_event_t event,
                                        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 @@ void event_handler(switch_event_t *event)
                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 @@ switch_status_t config_sofia(int reload, char *profile_name)
                                        } 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
index 8b9070c869efb51192b93bdc79e158c510f01c69..71c68271d613c6b89f5f1db0c69f45a92d5d8687 100644 (file)
@@ -1716,19 +1716,20 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
        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 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
                "   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 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
 
                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 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
                        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
index fe3452cdfefe90877d56f1a739a6eb20ac0f9486..94a7b94ba9caf68bbbcd88191946b168cb955452 100644 (file)
@@ -136,7 +136,7 @@ void sofia_presence_establish_presence(sofia_profile_t *profile)
 {
 
        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 @@ void sofia_presence_event_handler(switch_event_t *event)
                        }
 
                        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 @@ void sofia_presence_handle_sip_i_subscribe(int status,
 
                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 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n
                                }
 
                                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);
index 92ed4b334186753823f1552ca5a7176d99c1f080..706cb7cbbc00ffb09bf7719bf655af414759ef09 100644 (file)
@@ -269,9 +269,9 @@ char *sofia_reg_find_reg_url(sofia_profile_t *profile, const char *user, const c
        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 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
                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 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
                        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 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
                        }
                        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;