]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update 4579 stuff
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 31 Jul 2012 19:01:56 +0000 (14:01 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 31 Jul 2012 19:01:56 +0000 (14:01 -0500)
src/mod/endpoints/mod_sofia/sofia.c

index 3ded1dccd2af62c621510b62ba8f78149ab8cba4..6c7c0382b3722461aa2fe2b62e0f765ca4e19d48 100644 (file)
@@ -1216,38 +1216,49 @@ static void our_sofia_event_callback(nua_event_t event,
                        char *refer_to = NULL, *referred_by = NULL, *method = NULL, *full_url = NULL;
                        char *params = NULL;
                        switch_event_t *event;
+                       char *tmp;
 
                        if (sip->sip_refer_to) {
                                ref_to_user = sip->sip_refer_to->r_url->url_user;
                                ref_to_host = sip->sip_refer_to->r_url->url_host;
 
-                               refer_to = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_refer_to);
-                               if ((params = strchr(refer_to, ';'))) {
-                                       if (strchr(refer_to, '<')) {
-                                               *params++ = '>';
-                                       } else {
-                                               *params++ = '\0';
-                                       }
+                               if ((refer_to = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_refer_to))) {
 
-                                       if (!(method = switch_find_parameter(params, "method", NULL))) {
-                                               method = strdup("INVITE");
+                                       if ((params = strrchr(refer_to, ';'))) {
+                                               *params++ = '\0';
                                        }
                                        
-                                       full_url = switch_find_parameter(params, "full_url", NULL);
+                                       if ((tmp = sofia_glue_get_url_from_contact(refer_to, 0))) {
+                                               refer_to = tmp;
+                                       }
+                               }
 
-                                       if (!strcasecmp(method, "INVITE")) {
-                                               action = "call";
-                                       } else if (!strcasecmp(method, "BYE")) {
-                                               action = "end";
-                                       } else {
-                                               action = method;
+                               if (!params || !switch_stristr("method=", params)) {
+                                       if ((params = strchr(refer_to, ';'))) {
+                                               *params++ = '\0';
                                        }
                                }
 
-                               refer_to = sofia_glue_get_url_from_contact(refer_to, 0);
-                                       
+                               if (params) {
+                                       method = switch_find_parameter(params, "method", NULL);
+                                       full_url = switch_find_parameter(params, "full_url", NULL);
+                               }
+
+
                        }
                        
+                       if (!method) {
+                               method = strdup("INVITE");
+                       }
+
+                       if (!strcasecmp(method, "INVITE")) {
+                               action = "call";
+                       } else if (!strcasecmp(method, "BYE")) {
+                               action = "end";
+                       } else {
+                               action = method;
+                       }
+
                        if (sip->sip_referred_by) {
                                referred_by = sofia_glue_get_url_from_contact(sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_referred_by), 0);
                                ref_by_user = sip->sip_referred_by->b_url->url_user;
@@ -1278,6 +1289,7 @@ static void our_sofia_event_callback(nua_event_t event,
 
                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "var_origination_caller_id_number", ref_by_user);
                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "var_origination_caller_id_name", ref_by_user);
+                               DUMP_EVENT(event);
                                switch_event_fire(&event);
                        }