]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Cleanup missing flags hack
authorMathieu Rene <mrene@avgs.ca>
Thu, 12 Feb 2009 14:46:14 +0000 (14:46 +0000)
committerMathieu Rene <mrene@avgs.ca>
Thu, 12 Feb 2009 14:46:14 +0000 (14:46 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11921 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/mod_sofia.h
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 bc58ee9ec04a3721120fbffdc7ee835569b604b4..8967a7bad8808c548affc4a5dd1be7ad112412be 100644 (file)
@@ -174,6 +174,9 @@ typedef enum {
        PFLAG_CALLID_AS_UUID,
        PFLAG_UUID_AS_CALLID,
        PFLAG_SCROOGE,
+       PFLAG_MANAGE_SHARED_APPEARANCE,
+       PFLAG_DISABLE_SRV,
+       PFLAG_DISABLE_NAPTR,
 
        /* No new flags below this line */
        PFLAG_MAX
@@ -451,9 +454,6 @@ struct sofia_profile {
        sofia_media_options_t media_options;
        uint32_t force_subscription_expires;
        switch_rtp_bug_flag_t auto_rtp_bugs;
-       char manage_shared_appearance;  /* pflags was all full up - MTK */
-       char disable_srv;
-       char disable_naptr;
 };
 
 struct private_object {
index 209780b13d3dcf5955553283a483f75aacbb309f..ca7230c267239ba2adf46037577da547389c639b 100644 (file)
@@ -101,7 +101,7 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status,
         * *and* for Linksys, I believe they use "sa" as their magic appearance agent name for those blind notifies, so
         * we'll probably have to change to match
        */
-       if (profile->manage_shared_appearance) {
+       if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
                
                if (sip->sip_request->rq_url->url_user && !strncmp(sip->sip_request->rq_url->url_user, "sla-agent", sizeof("sla-agent"))) {
                        int sub_state;
@@ -728,8 +728,8 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
                                                          TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), NUTAG_CERTIFICATE_DIR(profile->tls_cert_dir)), 
                                                          TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), TPTAG_TLS_VERSION(profile->tls_version)), 
                                                          TAG_IF(!strchr(profile->sipip, ':'), NTATAG_UDP_MTU(65535)), 
-                                                         TAG_IF(profile->disable_srv, NTATAG_USE_SRV(0)),
-                                                         TAG_IF(profile->disable_naptr, NTATAG_USE_NAPTR(0)),
+                                                         TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_SRV), NTATAG_USE_SRV(0)),
+                                                         TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_NAPTR), NTATAG_USE_NAPTR(0)),
                                                          NTATAG_DEFAULT_PROXY(profile->outbound_proxy),
                                                          NTATAG_SERVER_RPORT(profile->rport_level), 
                                                          TAG_IF(tportlog, TPTAG_LOG(1)), 
@@ -762,9 +762,9 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
                                   TAG_IF(profile->pres_type, NUTAG_ALLOW("SUBSCRIBE")),
                                   TAG_IF(profile->pres_type, NUTAG_ENABLEMESSAGE(1)),
                                   TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("presence")),
-                                  TAG_IF((profile->pres_type || profile->manage_shared_appearance), NUTAG_ALLOW_EVENTS("dialog")),
+                                  TAG_IF((profile->pres_type || sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)), NUTAG_ALLOW_EVENTS("dialog")),
                                   TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("call-info")),
-                                  TAG_IF((profile->pres_type || profile->manage_shared_appearance), NUTAG_ALLOW_EVENTS("sla")),
+                                  TAG_IF((profile->pres_type || sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)), NUTAG_ALLOW_EVENTS("sla")),
                                   TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("include-session-description")),
                                   TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("presence.winfo")),
                                   TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("message-summary")),
@@ -1807,9 +1807,6 @@ switch_status_t config_sofia(int reload, char *profile_name)
                                sofia_set_pflag(profile, PFLAG_STUN_ENABLED);
                                sofia_set_pflag(profile, PFLAG_DISABLE_100REL);
                                profile->auto_restart = 1;
-                               profile->manage_shared_appearance = 0; /* Initialize default */
-                               profile->disable_srv = 0;
-                               profile->disable_naptr = 0;
 
                                for (param = switch_xml_child(settings, "param"); param; param = param->next) {
                                        char *var = (char *) switch_xml_attr_soft(param, "name");
@@ -2027,16 +2024,16 @@ switch_status_t config_sofia(int reload, char *profile_name)
                                                } 
                                        } else if (!strcasecmp(var, "manage-shared-appearance")) {
                                                if (switch_true(val)) {
-                                                       profile->manage_shared_appearance = 1;
+                                                       sofia_set_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE);
                                                        profile->sla_contact = switch_core_sprintf(profile->pool, "sip:sla-agent@%s", profile->sipip);
                                                }
                                        } else if (!strcasecmp(var, "disable-srv")) {
                                                if (switch_true(val)) {
-                                                       profile->disable_srv = 1;
+                                                       sofia_set_pflag(profile, PFLAG_DISABLE_SRV);
                                                }
                                        } else if (!strcasecmp(var, "disable-naptr")) {
                                                if (switch_true(val)) {
-                                                       profile->disable_naptr = 1;
+                                                       sofia_set_pflag(profile, PFLAG_DISABLE_NAPTR);
                                                }
                                        } else if (!strcasecmp(var, "unregister-on-options-fail")) {
                                                if (switch_true(val)) {
index 1dc25250c22238899be074a875211b391c7fa8ee..410f4979039c6a6df75c59bb06410b3681e7708d 100644 (file)
@@ -3127,7 +3127,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
                }
                free(test_sql);
 
-               if (profile->manage_shared_appearance) {
+               if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
                        test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str='' or hostname='%q'", mod_sofia_globals.hostname);
                        if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
                                switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_shared_appearance_subscriptions", NULL);
@@ -3167,7 +3167,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
                switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_authentication", auth_sql);
                free(test_sql);
 
-               if(profile->manage_shared_appearance) {
+               if(sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
                        test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str = '' or hostname='%q'", mod_sofia_globals.hostname);
                        switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_shared_appearance_subscriptions", shared_appearance_sql);
                        free(test_sql);
index dcb751ccf5fd3f2c79136d5f401d3423d66fd397..927a1fc40e95e503197ae1494c1b0e3567be74db 100644 (file)
@@ -1516,7 +1516,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
 
 
                /* the following could be refactored back to the calling event handler in sofia.c XXX MTK */
-               if (profile->manage_shared_appearance) {
+               if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
                        if (sip->sip_request->rq_url->url_user && !strncmp(sip->sip_request->rq_url->url_user, "sla-agent", sizeof("sla-agent"))) {
                                /* only fire this on <200 to try to avoid resubscribes. probably better ways to do this? */
                                if (status < 200) {
@@ -1784,7 +1784,7 @@ void sofia_presence_handle_sip_r_subscribe(int status,
        }
 
        /* the following could possibly be refactored back towards the calling event handler in sofia.c XXX MTK */
-       if (profile->manage_shared_appearance) {
+       if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
                if (!strcasecmp(o->o_type, "dialog") && msg_params_find(o->o_params, "sla")) {
                        sofia_sla_handle_sip_r_subscribe(nua, profile, nh, sip, tags);
                        return;
@@ -1835,7 +1835,7 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n
                char *event_type;
 
                /* the following could instead be refactored back to the calling event handler in sofia.c XXX MTK */
-               if (profile->manage_shared_appearance) {
+               if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
                        /* also it probably is unsafe to dereference so many things in a row without testing XXX MTK */
                        if (sip->sip_request->rq_url->url_user && !strncmp(sip->sip_request->rq_url->url_user, "sla-agent", sizeof("sla-agent"))) {
                                sofia_sla_handle_sip_i_publish(nua, profile, nh, sip, tags);
index b87b0885cb9817d19b89509dd62a1c2040b41207..8334ea90dcdbc61bcbb847d82e19a08d9d6c5b83 100644 (file)
@@ -1102,7 +1102,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
                        switch_event_fire(&s_event);
                }
 
-               if (profile->manage_shared_appearance) {
+               if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
                        sofia_sla_handle_register(nua, profile, sip);
                }