Revision
15221
Author
anthm
Date
2009-10-23 18:02:14 -0500 (Fri, 23 Oct 2009)

Log Message

add warning app and api for popup on phones (probably doesn't work yet

Modified Paths

Diff

Modified: freeswitch/trunk/src/include/switch_types.h (15220 => 15221)


--- freeswitch/trunk/src/include/switch_types.h	2009-10-23 22:37:49 UTC (rev 15220)
+++ freeswitch/trunk/src/include/switch_types.h	2009-10-23 23:02:14 UTC (rev 15221)
@@ -663,6 +663,7 @@
 	SWITCH_MESSAGE_INDICATE_AUDIO_SYNC,
 	SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA,
 	SWITCH_MESSAGE_INDICATE_UUID_CHANGE,
+	SWITCH_MESSAGE_INDICATE_WARNING,
 	SWITCH_MESSAGE_INVALID
 } switch_core_session_message_types_t;
 

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (15220 => 15221)


--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	2009-10-23 22:37:49 UTC (rev 15220)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	2009-10-23 23:02:14 UTC (rev 15221)
@@ -2059,6 +2059,43 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
+#define WARNING_SYNTAX "<uuid> <warning>"
+SWITCH_STANDARD_API(uuid_warning_function)
+{
+	char *mycmd = NULL, *argv[2] = { 0 };
+	int argc = 0;
+	switch_status_t status = SWITCH_STATUS_FALSE;
+
+	if (!zstr(cmd) && (mycmd = strdup(cmd))) {
+		argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+	}
+
+	if (zstr(cmd) || argc < 2 || zstr(argv[0]) || zstr(argv[1])) {
+		stream->write_function(stream, "-USAGE: %s\n", WARNING_SYNTAX);
+	} else {
+		switch_core_session_message_t msg = { 0 };
+		switch_core_session_t *lsession = NULL;
+
+		msg.message_id = SWITCH_MESSAGE_INDICATE_WARNING;
+		msg.string_arg = argv[1];
+		msg.from = __FILE__;
+
+		if ((lsession = switch_core_session_locate(argv[0]))) {
+			status = switch_core_session_receive_message(lsession, &msg);
+			switch_core_session_rwunlock(lsession);
+		}
+	}
+
+	if (status == SWITCH_STATUS_SUCCESS) {
+		stream->write_function(stream, "+OK Success\n");
+	} else {
+		stream->write_function(stream, "-ERR Operation Failed\n");
+	}
+
+	switch_safe_free(mycmd);
+	return SWITCH_STATUS_SUCCESS;
+}
+
 #define UUID_SYNTAX "<uuid> <other_uuid>"
 SWITCH_STANDARD_API(uuid_bridge_function)
 {
@@ -3664,6 +3701,7 @@
 	SWITCH_ADD_API(commands_api_interface, "uuid_broadcast", "broadcast", uuid_broadcast_function, BROADCAST_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "uuid_hold", "hold", uuid_hold_function, HOLD_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "uuid_display", "change display", uuid_display_function, DISPLAY_SYNTAX);
+	SWITCH_ADD_API(commands_api_interface, "uuid_warning", "send popup", uuid_warning_function, WARNING_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "uuid_media", "media", uuid_media_function, MEDIA_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "fsctl", "control messages", ctl_function, CTL_SYNTAX);
 	switch_console_set_complete("add fsctl hupall");

Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (15220 => 15221)


--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	2009-10-23 22:37:49 UTC (rev 15220)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	2009-10-23 23:02:14 UTC (rev 15221)
@@ -703,6 +703,17 @@
 	switch_core_session_receive_message(session, &msg);
 }
 
+SWITCH_STANDARD_APP(warning_function)
+{
+	switch_core_session_message_t msg = { 0 };
+
+	/* Tell the channel to redirect */
+	msg.from = __FILE__;
+	msg.string_arg = data;
+	msg.message_id = SWITCH_MESSAGE_INDICATE_WARNING;
+	switch_core_session_receive_message(session, &msg);
+}
+
 SWITCH_STANDARD_APP(respond_function)
 {
 	switch_core_session_message_t msg = { 0 };
@@ -2921,6 +2932,8 @@
 				   SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "send_display", "Send session a new display", "Send session a new display.", display_function, "<text>",
 				   SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "send_warning", "Send session a popup", "Send session a popup.", warning_function, "<text>",
+				   SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "respond", "Send session respond", "Send a respond message to a session.", respond_function, "<respond_data>",
 				   SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "deflect", "Send call deflect", "Send a call deflect.", deflect_function, "<deflect_data>", SAF_SUPPORT_NOMEDIA);

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (15220 => 15221)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-10-23 22:37:49 UTC (rev 15220)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-10-23 23:02:14 UTC (rev 15221)
@@ -1269,6 +1269,28 @@
 		}
 		break;
 
+	case SWITCH_MESSAGE_INDICATE_WARNING:
+		{
+			char *message;
+			if (!zstr(msg->string_arg)) {
+				const char *ua = switch_channel_get_variable(tech_pvt->channel, "sip_user_agent");
+				
+				if (!sofia_test_flag(tech_pvt, TFLAG_UPDATING_DISPLAY)) {
+						
+					if ((ua && (switch_stristr("polycom", ua)))) {
+						message = switch_mprintf("Warning: 300 freeswitch \"%s\"", msg->string_arg);
+						sofia_set_flag_locked(tech_pvt, TFLAG_UPDATING_DISPLAY);
+						nua_update(tech_pvt->nh,
+								   TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
+								   TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
+								   TAG_END());
+						free(message);
+					}
+
+				}
+			}
+		}
+		break;
 	case SWITCH_MESSAGE_INDICATE_DISPLAY:
 		{
 			const char *name = msg->string_array_arg[0], *number = msg->string_array_arg[1];