[Freeswitch-svn] [commit] r13188 - in freeswitch/trunk: libs/esl/perl src/mod/endpoints/mod_sofia

FreeSWITCH SVN anthm at freeswitch.org
Tue Apr 28 21:15:52 PDT 2009


Author: anthm
Date: Tue Apr 28 23:15:52 2009
New Revision: 13188

Log:
update last commit

Added:
   freeswitch/trunk/libs/esl/perl/send_notify.pl
Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c

Added: freeswitch/trunk/libs/esl/perl/send_notify.pl
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/esl/perl/send_notify.pl	Tue Apr 28 23:15:52 2009
@@ -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);
+

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Tue Apr 28 23:15:52 2009
@@ -2807,30 +2807,62 @@
 			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;
+				}
 
-				sofia_glue_release_profile(profile);
-				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);
+				}
+
+				return;
 			}
-			
+
 			if (uuid && ct && es) {
 				switch_core_session_t *session;
 				private_object_t *tech_pvt;
@@ -2944,28 +2976,27 @@
 			char buf[1024] = "";
 			char *p;
 
-			
 			if (!profile_name) {
-				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 (!from_uri) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing From-URI header\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 (!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);



More information about the Freeswitch-svn mailing list