]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-5882 --resolve
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 17 Oct 2013 17:39:55 +0000 (22:39 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 17 Oct 2013 17:40:07 +0000 (22:40 +0500)
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_reg.c

index c27fcb55a36aa404334a036de122c3a69a2425ca..952fce2f9f1c518022712847c03cf1071a358058 100644 (file)
@@ -171,6 +171,8 @@ struct sofia_private {
        char *network_ip;
        char *network_port;
        char *key;
+       char *user;
+       char *realm;
        int destroy_nh;
        int destroy_me;
        int is_call;
index fcd9c5870f67f330fc64ca7b62afa220b331bddf..9000ec96b33444ac3b40a4aafe258350c3c86144 100644 (file)
@@ -1454,6 +1454,7 @@ static void our_sofia_event_callback(nua_event_t event,
 
                        if (sofia_private && sofia_private->call_id && sofia_private->network_ip && sofia_private->network_port) {
                                char *sql;
+                               switch_event_t *event = NULL;
 
                                sql = switch_mprintf("delete from sip_registrations where call_id='%q' and network_ip='%q' and network_port='%q'",
                                                                                   sofia_private->call_id, sofia_private->network_ip, sofia_private->network_port);
@@ -1461,6 +1462,34 @@ static void our_sofia_event_callback(nua_event_t event,
                                                                  sofia_private->call_id, sofia_private->network_ip, sofia_private->network_port);
                                sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
 
+                               switch_core_del_registration(sofia_private->user, sofia_private->realm, sofia_private->call_id);
+
+
+
+                               if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", profile->url);
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "user-agent",
+                                                                                                  (sip && sip->sip_user_agent) ? sip->sip_user_agent->g_string : "unknown");
+                                       switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", sofia_private->user, sofia_private->realm);
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", "Unregistered");
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-source", "register");
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
+                                       switch_event_fire(&event);
+                               }
+
+                               
+                               if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_UNREGISTER) == SWITCH_STATUS_SUCCESS) {
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "profile-name", profile->name);
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from-user", sofia_private->user);
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from-host", sofia_private->realm);
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-id", sofia_private->call_id);
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "reason", "socket-disconnection");
+                                       switch_event_fire(&event);
+                               }
+                               
 
                                sofia_reg_check_socket(profile, sofia_private->call_id, sofia_private->network_ip, sofia_private->network_port);
                        }
index 1514d4be4f54d6aa4431b8710274b9989db5935d..821a08688051a46d503f3600607d076d6776a340 100644 (file)
@@ -1758,6 +1758,9 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
                                sofia_private->network_ip = su_strdup(nh->nh_home, network_ip);
                                sofia_private->network_port = su_strdup(nh->nh_home, network_port_c);
                                sofia_private->key = su_strdup(nh->nh_home, key);
+                               sofia_private->user = su_strdup(nh->nh_home, to_user);
+                               sofia_private->realm = su_strdup(nh->nh_home, reg_host);
+
                                sofia_private->is_static++;
                                *sofia_private_p = sofia_private;
                                nua_handle_bind(nh, sofia_private);