diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 42e6513e88..193908ef14 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -663,6 +663,7 @@ typedef enum { 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; diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 75cdef4f93..11968d014b 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -2059,6 +2059,43 @@ SWITCH_STANDARD_API(uuid_display_function) return SWITCH_STATUS_SUCCESS; } +#define WARNING_SYNTAX " " +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 " " SWITCH_STANDARD_API(uuid_bridge_function) { @@ -3664,6 +3701,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) 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"); diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 59e81a89db..d6a6b21edd 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -703,6 +703,17 @@ SWITCH_STANDARD_APP(display_function) 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 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "send_display", "Send session a new display", "Send session a new display.", display_function, "", SAF_SUPPORT_NOMEDIA); + SWITCH_ADD_APP(app_interface, "send_warning", "Send session a popup", "Send session a popup.", warning_function, "", + SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "respond", "Send session respond", "Send a respond message to a session.", respond_function, "", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "deflect", "Send call deflect", "Send a call deflect.", deflect_function, "", SAF_SUPPORT_NOMEDIA); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 43ccde721a..f43798d17b 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1269,6 +1269,28 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } 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];