]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
experimental support for send-message-query-on-register=first-only
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 10 Nov 2009 00:26:54 +0000 (00:26 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 10 Nov 2009 00:26:54 +0000 (00:26 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15405 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_reg.c

index 04a96447fb56f84c42ec7e1d2bb0fa9b67fd8e08..03132cceb6ce2c25232dde672eab16ee5c1911b7 100644 (file)
@@ -193,6 +193,7 @@ typedef enum {
        PFLAG_NAT_OPTIONS_PING,
        PFLAG_AUTOFIX_TIMING,
        PFLAG_MESSAGE_QUERY_ON_REGISTER,
+       PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER,
        PFLAG_RTP_AUTOFLUSH_DURING_BRIDGE,
        PFLAG_MANUAL_REDIRECT,
        PFLAG_AUTO_NAT,
index 5f04b1c085744659dacfa75033d2250fb0c4d670..5c8918f08ff5ebe00a0ccdbf3863b3efc3a87b00 100644 (file)
@@ -1863,6 +1863,8 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
                                        } else if (!strcasecmp(var, "send-message-query-on-register")) {
                                                if (switch_true(val)) {
                                                        sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER);
+                                               } else if (!strcasecmp(val, "first-only")) {
+                                                       sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER);
                                                } else {
                                                        sofia_clear_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER);
                                                }
@@ -2476,6 +2478,8 @@ switch_status_t config_sofia(int reload, char *profile_name)
                                        } else if (!strcasecmp(var, "send-message-query-on-register")) {
                                                if (switch_true(val)) {
                                                        sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER);
+                                               } else if (!strcasecmp(val, "first-only")) {
+                                                       sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER);
                                                } else {
                                                        sofia_clear_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER);
                                                }
index aed5890ee684b7db8f4b61e2bfa3c27c50deeaa0..0c41a3919260b9ca2d9c277f4e8f95f96b6d5187 100644 (file)
@@ -1213,14 +1213,28 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
        if (regtype == REG_REGISTER) {
                char exp_param[128] = "";
                char date[80] = "";
-
+               long nc_long = 0;               
+               
                s_event = NULL;
 
                if (exptime) {
                        switch_snprintf(exp_param, sizeof(exp_param), "expires=%ld", exptime);
                        sip_contact_add_param(nua_handle_home(nh), sip->sip_contact, exp_param);
+                       
+                       if (auth_params && sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER)) {
+                               const char *nc = NULL;
 
-                       if (sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER)) {
+                               if ((nc = switch_event_get_header(auth_params, "sip_auth_nc"))) {
+                                       nc_long = strtoul(nc, 0, 16);
+                               } else {
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, 
+                                                                         "No nonce count, cannot determine if this was the first register, sending notify implicitly.\n");
+                                       nc_long = 1;
+                               }
+                       }
+                       
+                       if (sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER) || 
+                               (nc_long == 1 && sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER))) {
                                if (switch_event_create(&s_event, SWITCH_EVENT_MESSAGE_QUERY) == SWITCH_STATUS_SUCCESS) {
                                        switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "Message-Account", "sip:%s@%s", mwi_user, mwi_host);
                                        switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "VM-Sofia-Profile", profile->name);