diff --git a/libs/esl/perl/send_notify.pl b/libs/esl/perl/send_notify.pl new file mode 100644 index 0000000000..629e6ca1e5 --- /dev/null +++ b/libs/esl/perl/send_notify.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl + +require ESL; + +ESL::eslSetLogLevel(7); + +my $con = ESL::ESLconnection->new("localhost", "8021", "ClueCon"); +my $e = ESL::ESLevent->new("NOTIFY"); + + +$e->addHeader("from-uri", "sip:1000\@dev.bkw.org"); +$e->addHeader("to-uri", "sip:1000\@dev.bkw.org"); +$e->addHeader("event-string", "message-summary"); +$e->addHeader("content-type", "application/simple-message-summary"); +$e->addHeader("profile", "internal"); + + +my $body ="Messages-Waiting: yes\nMessage-Account: me\@my.com\nVoice-Message: 0/0 (0/0)\n"; +$e->addBody($body); +$con->sendEvent($e); + diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 0476744c40..1356b2b4ad 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -2807,30 +2807,62 @@ static void general_event_handler(switch_event_t *event) const char *from_uri = switch_event_get_header(event, "from-uri"); sofia_profile_t *profile; - if (to_uri && from_uri && ct && es && profile_name && (profile = sofia_glue_find_profile(profile_name))) { - nua_handle_t *nh = nua_handle(profile->nua, - NULL, - NUTAG_URL(to_uri), - SIPTAG_FROM_STR(from_uri), - SIPTAG_TO_STR(to_uri), - SIPTAG_CONTACT_STR(profile->url), - TAG_END()); - - nua_handle_bind(nh, &mod_sofia_globals.destroy_private); - - nua_info(nh, - NUTAG_WITH_THIS(profile->nua), - TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), - TAG_IF(!switch_strlen_zero(body), SIPTAG_PAYLOAD_STR(body)), - TAG_END()); - + if (to_uri || from_uri) { + + if (!to_uri) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing To-URI header\n"); + return; + } + + if (!from_uri) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing From-URI header\n"); + return; + } + + if (!es) { + es = "message-summary"; + } + + if (!ct) { + ct = "application/simple-message-summary"; + } + + if (!profile_name) { + profile_name = "default"; + } + + if (!(profile = sofia_glue_find_profile(profile_name))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find profile %s\n", profile_name); + return; + } + + + if (to_uri && from_uri && ct && es && profile_name && (profile = sofia_glue_find_profile(profile_name))) { + nua_handle_t *nh = nua_handle(profile->nua, + NULL, + NUTAG_URL(to_uri), + SIPTAG_FROM_STR(from_uri), + SIPTAG_TO_STR(to_uri), + SIPTAG_CONTACT_STR(profile->url), + TAG_END()); + + nua_handle_bind(nh, &mod_sofia_globals.destroy_private); + + nua_notify(nh, + NUTAG_NEWSUB(1), + NUTAG_WITH_THIS(profile->nua), + SIPTAG_EVENT_STR(es), + TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), + TAG_IF(!switch_strlen_zero(body), SIPTAG_PAYLOAD_STR(body)), + TAG_END()); + + sofia_glue_release_profile(profile); + } - sofia_glue_release_profile(profile); return; - } - + if (uuid && ct && es) { switch_core_session_t *session; private_object_t *tech_pvt; @@ -2944,28 +2976,27 @@ static void general_event_handler(switch_event_t *event) char buf[1024] = ""; char *p; - if (!profile_name) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing Profile Name\n"); - goto done; - } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing Profile Name\n"); + goto done; + } - if (!to_uri && !local_user_full) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing To-URI header\n"); - goto done; - } + if (!to_uri && !local_user_full) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing To-URI header\n"); + goto done; + } - if (!from_uri) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing From-URI header\n"); - goto done; - } + if (!from_uri) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing From-URI header\n"); + goto done; + } + + + if (!(profile = sofia_glue_find_profile(profile_name))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find profile %s\n", profile_name); + goto done; + } - - if (!(profile = sofia_glue_find_profile(profile_name))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find profile %s\n", profile_name); - goto done; - } - if (local_user_full) { local_dup = strdup(local_user_full);