[Freeswitch-svn] [commit] r9363 - in freeswitch/trunk/src: . include mod/applications/mod_dptools mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Mon Aug 25 12:30:29 EDT 2008


Author: anthm
Date: Mon Aug 25 12:30:28 2008
New Revision: 9363

Modified:
   freeswitch/trunk/src/include/switch_channel.h
   freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
   freeswitch/trunk/src/switch_channel.c
   freeswitch/trunk/src/switch_core_session.c

Log:
presence tweak

Modified: freeswitch/trunk/src/include/switch_channel.h
==============================================================================
--- freeswitch/trunk/src/include/switch_channel.h	(original)
+++ freeswitch/trunk/src/include/switch_channel.h	Mon Aug 25 12:30:28 2008
@@ -145,8 +145,9 @@
   \param channel the channel to initilize
   \param rpid the rpid if for the icon to use
   \param status the status message
+  \param id presence id
 */
-SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const char *rpid, const char *status);
+SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const char *rpid, const char *status, const char *id);
 
 /*!
   \brief Uninitalize a channel

Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	Mon Aug 25 12:30:28 2008
@@ -606,6 +606,26 @@
 	switch_channel_answer(switch_core_session_get_channel(session));
 }
 
+SWITCH_STANDARD_APP(presence_function)
+{
+	char *argv[6] = { 0 };
+    int argc;
+    char *mydata = NULL;
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+
+	if (switch_strlen_zero(data) || !(mydata = switch_core_session_strdup(session, data))) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID ARGS!\n");
+        return;
+    }
+
+	if ((argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]))) < 2) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID ARGS!\n");
+		return;
+	}
+
+	switch_channel_presence(channel, argv[0], argv[1], argv[2]);	
+}
+
 SWITCH_STANDARD_APP(pre_answer_function)
 {
 	switch_channel_pre_answer(switch_core_session_get_channel(session));
@@ -2248,6 +2268,7 @@
 	SWITCH_ADD_APP(app_interface, "answer", "Answer the call", "Answer the call for a channel.", answer_function, "", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "hangup", "Hangup the call", "Hangup the call for a channel.", hangup_function, "[<cause>]", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "set_name", "Name the channel", "Name the channel", set_name_function, "<name>", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "presence", "Send Presence", "Send Presence.", presence_function, "<rpid> <status> [<id>]", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "log", "Logs to the logger", LOG_LONG_DESC, log_function, "<log_level> <log_string>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "info", "Display Call Info", "Display Call Info", info_function, "", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "event", "Fire an event", "Fire an event", event_function, "", SAF_SUPPORT_NOMEDIA);

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	Mon Aug 25 12:30:28 2008
@@ -242,7 +242,7 @@
 		if (tech_pvt->max_missed_packets) {
 			switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets);
 		}
-		switch_channel_presence(tech_pvt->channel, "unknown", "unhold");
+		switch_channel_presence(tech_pvt->channel, "unknown", "unhold", NULL);
 
 		if ((buuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
 			if ((bsession = switch_core_session_locate(buuid))) {

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	Mon Aug 25 12:30:28 2008
@@ -2389,11 +2389,11 @@
 						if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
 							if (!switch_stristr("sendonly", r_sdp)) {
 								switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
-								switch_channel_presence(tech_pvt->channel, "unknown", "unhold");
+								switch_channel_presence(tech_pvt->channel, "unknown", "unhold", NULL);
 							}
 						} else if (switch_stristr("sendonly", r_sdp)) {
 							switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
-							switch_channel_presence(tech_pvt->channel, "unknown", "hold");
+							switch_channel_presence(tech_pvt->channel, "unknown", "hold", NULL);
 						}
 					
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	Mon Aug 25 12:30:28 2008
@@ -2087,7 +2087,7 @@
 			const char *stream;
 
 			switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
-			switch_channel_presence(tech_pvt->channel, "unknown", "hold");
+			switch_channel_presence(tech_pvt->channel, "unknown", "hold", NULL);
 
 			if (tech_pvt->max_missed_hold_packets) {
 				switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_hold_packets);
@@ -2134,7 +2134,7 @@
 			}
 
 			switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
-			switch_channel_presence(tech_pvt->channel, "unknown", "unhold");
+			switch_channel_presence(tech_pvt->channel, "unknown", "unhold", NULL);
 		}
 	}
 

Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c	(original)
+++ freeswitch/trunk/src/switch_channel.c	Mon Aug 25 12:30:28 2008
@@ -389,9 +389,8 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const char *rpid, const char *status)
+SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const char *rpid, const char *status, const char *id)
 {
-	const char *id = switch_channel_get_variable(channel, "presence_id");
 	switch_event_t *event;
 	switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN;
 
@@ -400,6 +399,10 @@
 	}
 
 	if (!id) {
+		id = switch_channel_get_variable(channel, "presence_id");
+	}
+
+	if (!id) {
 		return;
 	}
 
@@ -783,7 +786,7 @@
 
 	if (channel->state >= CS_ROUTING) {
 		switch_clear_flag(channel, CF_TRANSFER);
-		switch_channel_presence(channel, "unknown", (char *) state_names[state]);
+		switch_channel_presence(channel, "unknown", (char *) state_names[state], NULL);
 	}
 
 	if (state < CS_HANGUP) {
@@ -1360,7 +1363,7 @@
 		}
 
 		switch_channel_set_variable(channel, "hangup_cause", switch_channel_cause2str(channel->hangup_cause));
-		switch_channel_presence(channel, "unavailable", switch_channel_cause2str(channel->hangup_cause));
+		switch_channel_presence(channel, "unavailable", switch_channel_cause2str(channel->hangup_cause), NULL);
 
 		switch_core_session_kill_channel(channel->session, SWITCH_SIG_KILL);
 		switch_core_session_signal_state_change(channel->session);

Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c	(original)
+++ freeswitch/trunk/src/switch_core_session.c	Mon Aug 25 12:30:28 2008
@@ -1028,6 +1028,7 @@
 {
 	const switch_application_interface_t *application_interface;
 	char *expanded = NULL;
+	const char *var;
 
 	if ((application_interface = switch_loadable_module_get_application_interface(app)) == 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Application %s\n", app);
@@ -1058,7 +1059,7 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Expanded String %s(%s)\n", switch_channel_get_name(session->channel), app, expanded);
 	}
 
-	if (switch_channel_get_variable(session->channel, "presence_id")) {
+	if ((var = switch_channel_get_variable(session->channel, "verbose_presence")) && switch_true(var)) {
 		char *myarg = NULL;
 		if (expanded) {
 			myarg = switch_mprintf("%s(%s)", app, expanded);
@@ -1068,7 +1069,7 @@
 			myarg = switch_mprintf("%s", app);
 		}
 		if (myarg) {
-			switch_channel_presence(session->channel, "unknown", myarg);
+			switch_channel_presence(session->channel, "unknown", myarg, NULL);
 			switch_safe_free(myarg);
 		}
 	}



More information about the Freeswitch-svn mailing list