From 5a6c0ba4c8ca27e0756c61ed949e2029ced29b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Mesquita?= Date: Sat, 23 Jan 2010 19:08:44 +0000 Subject: [PATCH] Do right it right this time. MODENDP-284 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16484 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.c | 5 ----- src/mod/endpoints/mod_sofia/sofia_reg.c | 7 +++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index f57a103319..998303ac7c 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -2512,7 +2512,6 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t char *profile_name = argv[0]; const char *err; switch_xml_t xml_root; - switch_event_t *event; if (argc < 2) { stream->write_function(stream, "Invalid Args!\n"); @@ -2555,10 +2554,6 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t sofia_glue_del_gateway(gateway_ptr); sofia_reg_release_gateway(gateway_ptr); stream->write_function(stream, "+OK gateway marked for deletion.\n"); - if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_GATEWAY_DEL) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Gateway", argv[2]); - switch_event_fire(&event); - } } else { stream->write_function(stream, "-ERR no such gateway.\n"); } diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 424c0a0495..201ad05810 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -237,6 +237,7 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now) void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now) { sofia_gateway_t *gateway_ptr, *last = NULL; + switch_event_t *event; for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) { if (gateway_ptr->deleted && gateway_ptr->state == REG_STATE_NOREG) { @@ -250,6 +251,11 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now) switch_core_hash_delete(mod_sofia_globals.gateway_hash, gateway_ptr->register_from); switch_core_hash_delete(mod_sofia_globals.gateway_hash, gateway_ptr->register_contact); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deleted gateway %s\n", gateway_ptr->name); + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_GATEWAY_DEL) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "profile-name", gateway_ptr->profile->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Gateway", gateway_ptr->name); + switch_event_fire(&event); + } if (gateway_ptr->ob_vars) { switch_event_destroy(&gateway_ptr->ob_vars); } @@ -2359,6 +2365,7 @@ switch_status_t sofia_reg_add_gateway(char *key, sofia_gateway_t *gateway) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Added gateway '%s' to profile '%s'\n", gateway->name, gateway->profile->name); if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_GATEWAY_ADD) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "Gateway", gateway->name); + switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile-name", gateway->profile->name); switch_event_fire(&s_event); } }