From 1dc04136e29501d5eeccdde08d9206c267617c2a Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Mon, 23 Sep 2013 11:49:22 -0500 Subject: [PATCH] add functions for sending forward stat message (mod_skinny) --- src/mod/endpoints/mod_skinny/mod_skinny.h | 5 +++ src/mod/endpoints/mod_skinny/skinny_api.c | 33 +++++++++++++++++++ .../endpoints/mod_skinny/skinny_protocol.c | 32 ++++++++++++++++++ .../endpoints/mod_skinny/skinny_protocol.h | 5 +++ 4 files changed, 75 insertions(+) diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.h b/src/mod/endpoints/mod_skinny/mod_skinny.h index c6e83804f7..b252dd7e4a 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.h +++ b/src/mod/endpoints/mod_skinny/mod_skinny.h @@ -59,6 +59,11 @@ "[%s:%d @ %s:%d] " _fmt, skinny_undef_str(listener->device_name), listener->device_instance, skinny_undef_str(listener->remote_ip), \ listener->remote_port, __VA_ARGS__) +#define skinny_log_l_ffl_msg(listener, file, func, line, level, _fmt) switch_log_printf( \ + SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, level, \ + "[%s:%d @ %s:%d] " _fmt, skinny_undef_str(listener->device_name), listener->device_instance, skinny_undef_str(listener->remote_ip), \ + listener->remote_port) + #define skinny_log_ls(listener, session, level, _fmt, ...) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), level, \ "[%s:%d @ %s:%d] " _fmt, skinny_undef_str(listener->device_name), listener->device_instance, skinny_undef_str(listener->remote_ip), \ listener->remote_port, __VA_ARGS__) diff --git a/src/mod/endpoints/mod_skinny/skinny_api.c b/src/mod/endpoints/mod_skinny/skinny_api.c index 2d6c3b5275..daebbb9385 100644 --- a/src/mod/endpoints/mod_skinny/skinny_api.c +++ b/src/mod/endpoints/mod_skinny/skinny_api.c @@ -385,6 +385,28 @@ static switch_status_t skinny_api_cmd_profile_device_send_call_state_message(con return SWITCH_STATUS_SUCCESS; } +static switch_status_t skinny_api_cmd_profile_device_send_forward_stat_message(const char *profile_name, const char *device_name, const char *number, switch_stream_handle_t *stream) +{ + skinny_profile_t *profile; + + if ((profile = skinny_find_profile(profile_name))) { + listener_t *listener = NULL; + skinny_profile_find_listener_by_device_name(profile, device_name, &listener); + if(listener) { + + send_forward_stat(listener, number); + + stream->write_function(stream, "+OK\n"); + } else { + stream->write_function(stream, "Listener not found!\n"); + } + } else { + stream->write_function(stream, "Profile not found!\n"); + } + + return SWITCH_STATUS_SUCCESS; +} + static switch_status_t skinny_api_cmd_profile_device_send_reset_message(const char *profile_name, const char *device_name, const char *reset_type, switch_stream_handle_t *stream) { skinny_profile_t *profile; @@ -498,6 +520,7 @@ SWITCH_STANDARD_API(skinny_function) "skinny profile device send SetLampMessage \n" "skinny profile device send SetSpeakerModeMessage \n" "skinny profile device send CallStateMessage \n" + "skinny profile device send ForwardStatMessage \n" "skinny profile device send [ =;... ] \n" "skinny profile set \n" "--------------------------------------------------------------------------------\n"; @@ -561,6 +584,15 @@ SWITCH_STANDARD_API(skinny_function) status = skinny_api_cmd_profile_device_send_call_state_message(argv[1], argv[3], argv[6], argv[7], argv[8], stream); } break; + case FORWARD_STAT_MESSAGE: + if (argc == 7) { + /* ForwardStatMessage */ + status = skinny_api_cmd_profile_device_send_forward_stat_message(argv[1], argv[3], argv[6], stream); + } else if (argc == 6) { + /* ForwardStatMessage */ + status = skinny_api_cmd_profile_device_send_forward_stat_message(argv[1], argv[3], NULL, stream); + } + break; case RESET_MESSAGE: if (argc == 7) { /* ResetMessage */ @@ -611,6 +643,7 @@ switch_status_t skinny_api_register(switch_loadable_module_interface_t **module_ switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send SetLampMessage ::skinny::list_stimuli ::skinny::list_stimulus_instances ::skinny::list_stimulus_modes"); switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send SetSpeakerModeMessage ::skinny::list_speaker_modes"); switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send CallStateMessage ::skinny::list_call_states ::skinny::list_line_instances ::skinny::list_call_ids"); + switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send ForwardStatMessage"); switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send UserToDeviceDataMessage"); switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send UserToDeviceDataVersion1Message"); switch_console_set_complete("add skinny profile ::skinny::list_profiles set ::skinny::list_settings"); diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.c b/src/mod/endpoints/mod_skinny/skinny_protocol.c index ce756da34a..5498e5ebee 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.c +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.c @@ -592,6 +592,38 @@ switch_status_t perform_send_set_ringer(listener_t *listener, return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); } +switch_status_t perform_send_forward_stat(listener_t *listener, + const char *file, const char *func, int line, + const char *number) +{ + skinny_message_t *message; + + skinny_create_message(message, FORWARD_STAT_MESSAGE, forward_stat); + + if ( number && number[0] ) + { + message->data.forward_stat.active_forward = 1; + message->data.forward_stat.line_instance = 1; + message->data.forward_stat.forward_all_active = 1; + message->data.forward_stat.forward_busy_active = 1; + message->data.forward_stat.forward_noanswer_active = 1; + + strncpy(message->data.forward_stat.forward_all_number, number, sizeof(message->data.forward_stat.forward_all_number)); + strncpy(message->data.forward_stat.forward_busy_number, number, sizeof(message->data.forward_stat.forward_all_number)); + strncpy(message->data.forward_stat.forward_noanswer_number, number, sizeof(message->data.forward_stat.forward_all_number)); + skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG, + "Sending ForwardStat with Number (%s)\n", number); + } + else + { + skinny_log_l_ffl_msg(listener, file, func, line, SWITCH_LOG_DEBUG, + "Sending ForwardStat with No Number (Inactive)\n"); + } + + + return skinny_send_reply_quiet(listener, message, SWITCH_TRUE); +} + switch_status_t perform_send_set_lamp(listener_t *listener, const char *file, const char *func, int line, uint32_t stimulus, diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.h b/src/mod/endpoints/mod_skinny/skinny_protocol.h index 43b2502e81..8a5178302e 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.h +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.h @@ -1019,6 +1019,11 @@ switch_status_t perform_send_set_ringer(listener_t *listener, uint32_t call_id); #define send_set_ringer(listener, ...) perform_send_set_ringer(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) +switch_status_t perform_send_forward_stat(listener_t *listener, + const char *file, const char *func, int line, + const char *forward_to); +#define send_forward_stat(listener, ...) perform_send_forward_stat(listener, __FILE__, __SWITCH_FUNC__, __LINE__, __VA_ARGS__) + switch_status_t perform_send_set_lamp(listener_t *listener, const char *file, const char *func, int line, uint32_t stimulus,