add functions for sending forward stat message (mod_skinny)

This commit is contained in:
Nathan Neulinger 2013-09-23 11:49:22 -05:00
parent cc806e21f1
commit 1dc04136e2
4 changed files with 75 additions and 0 deletions

View File

@ -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__)

View File

@ -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 <profile_name> device <device_name> send SetLampMessage <stimulus> <instance> <lamp_mode>\n"
"skinny profile <profile_name> device <device_name> send SetSpeakerModeMessage <speaker_mode>\n"
"skinny profile <profile_name> device <device_name> send CallStateMessage <call_state> <line_instance> <call_id>\n"
"skinny profile <profile_name> device <device_name> send ForwardStatMessage <number>\n"
"skinny profile <profile_name> device <device_name> send <UserToDeviceDataMessage|UserToDeviceDataVersion1Message> [ <param>=<value>;... ] <data>\n"
"skinny profile <profile_name> set <name> <value>\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 <number> */
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 <reset_type> */
@ -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");

View File

@ -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,

View File

@ -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,