Modified: freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.c (16818 => 16819)
--- freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.c 2010-02-25 13:56:11 UTC (rev 16818)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.c 2010-02-25 14:34:43 UTC (rev 16819)
@@ -1545,6 +1545,25 @@
return SWITCH_STATUS_SUCCESS;
}
+static switch_status_t 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;
+
+ 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_reset(listener, skinny_str2device_reset_type(reset_type));
+ } else {
+ stream->write_function(stream, "Listener not found!\n");
+ }
+ } else {
+ stream->write_function(stream, "Profile not found!\n");
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
SWITCH_STANDARD_API(skinny_function)
{
char *argv[1024] = { 0 };
@@ -1556,10 +1575,11 @@
"skinny help\n"
"skinny status profile <profile_name>\n"
"skinny status profile <profile_name> device <device_name>\n"
+ "skinny profile <profile_name> device <device_name> send ResetMessage [DeviceReset|DeviceRestart]\n"
"skinny profile <profile_name> device <device_name> send SetRingerMessage <ring_type> <ring_mode>\n"
"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 CallState <call_state> <line_instance> <call_id>\n"
+ "skinny profile <profile_name> device <device_name> send CallStateMessage <call_state> <line_instance> <call_id>\n"
"--------------------------------------------------------------------------------\n";
if (session) {
return SWITCH_STATUS_FALSE;
@@ -1589,18 +1609,42 @@
} else if (argc == 5 && !strcasecmp(argv[0], "status") && !strcasecmp(argv[1], "profile") && !strcasecmp(argv[3], "device")) {
/* skinny status profile <profile_name> device <device_name> */
status = cmd_status_profile_device(argv[2], argv[4], stream);
- } else if (argc == 8 && !strcasecmp(argv[0], "profile") && !strcasecmp(argv[2], "device") && !strcasecmp(argv[4], "send") && !strcasecmp(argv[5], "SetRingerMessage")) {
- /* skinny profile <profile_name> device <device_name> send SetRingerMessage <stimulus> <instance> <lamp_mode> */
- status = cmd_profile_device_send_ringer_message(argv[1], argv[3], argv[6], argv[7], stream);
- } else if (argc == 9 && !strcasecmp(argv[0], "profile") && !strcasecmp(argv[2], "device") && !strcasecmp(argv[4], "send") && !strcasecmp(argv[5], "SetLampMessage")) {
- /* skinny profile <profile_name> device <device_name> send SetLampMessage <stimulus> <instance> <lamp_mode> */
- status = cmd_profile_device_send_lamp_message(argv[1], argv[3], argv[6], argv[7], argv[8], stream);
- } else if (argc == 7 && !strcasecmp(argv[0], "profile") && !strcasecmp(argv[2], "device") && !strcasecmp(argv[4], "send") && !strcasecmp(argv[5], "SetSpeakerModeMessage")) {
- /* skinny profile <profile_name> device <device_name> send SetSpeakerModeMessage <speaker_mode> */
- status = cmd_profile_device_send_speaker_mode_message(argv[1], argv[3], argv[6], stream);
- } else if (argc == 9 && !strcasecmp(argv[0], "profile") && !strcasecmp(argv[2], "device") && !strcasecmp(argv[4], "send") && !strcasecmp(argv[5], "CallState")) {
- /* skinny profile <profile_name> device <device_name> send CallState <call_state> <line_instance> <call_id> */
- status = cmd_profile_device_send_call_state_message(argv[1], argv[3], argv[6], argv[7], argv[8], stream);
+ } else if (argc >= 6 && !strcasecmp(argv[0], "profile") && !strcasecmp(argv[2], "device") && !strcasecmp(argv[4], "send")) {
+ /* skinny profile <profile_name> device <device_name> send ... */
+ switch(skinny_str2message_type(argv[5])) {
+ case SET_RINGER_MESSAGE:
+ if(argc == 8) {
+ /* SetRingerMessage <ring_type> <ring_mode> */
+ status = cmd_profile_device_send_ringer_message(argv[1], argv[3], argv[6], argv[7], stream);
+ }
+ break;
+ case SET_LAMP_MESSAGE:
+ if (argc == 9) {
+ /* SetLampMessage <stimulus> <instance> <lamp_mode> */
+ status = cmd_profile_device_send_lamp_message(argv[1], argv[3], argv[6], argv[7], argv[8], stream);
+ }
+ break;
+ case SET_SPEAKER_MODE_MESSAGE:
+ if (argc == 7) {
+ /* SetSpeakerModeMessage <speaker_mode> */
+ status = cmd_profile_device_send_speaker_mode_message(argv[1], argv[3], argv[6], stream);
+ }
+ break;
+ case CALL_STATE_MESSAGE:
+ if (argc == 9) {
+ /* CallStateMessage <call_state> <line_instance> <call_id> */
+ status = cmd_profile_device_send_call_state_message(argv[1], argv[3], argv[6], argv[7], argv[8], stream);
+ }
+ break;
+ case RESET_MESSAGE:
+ if (argc == 7) {
+ /* ResetMessage <reset_type> */
+ status = cmd_profile_device_send_reset_message(argv[1], argv[3], argv[6], stream);
+ }
+ break;
+ default:
+ stream->write_function(stream, "Unhandled message %s\n", argv[5]);
+ }
} else {
stream->write_function(stream, "Unknown Command [%s]\n", argv[0]);
}
@@ -1694,6 +1738,13 @@
return status;
}
+static switch_status_t skinny_list_reset_types(const char *line, const char *cursor, switch_console_callback_match_t **matches)
+{
+ switch_status_t status = SWITCH_STATUS_FALSE;
+ SKINNY_PUSH_DEVICE_RESET_TYPES
+ return status;
+}
+
static switch_status_t skinny_list_stimuli(const char *line, const char *cursor, switch_console_callback_match_t **matches)
{
switch_status_t status = SWITCH_STATUS_FALSE;
@@ -1701,14 +1752,14 @@
return status;
}
-static switch_status_t skinny_list_ring_type(const char *line, const char *cursor, switch_console_callback_match_t **matches)
+static switch_status_t skinny_list_ring_types(const char *line, const char *cursor, switch_console_callback_match_t **matches)
{
switch_status_t status = SWITCH_STATUS_FALSE;
SKINNY_PUSH_RING_TYPES
return status;
}
-static switch_status_t skinny_list_ring_mode(const char *line, const char *cursor, switch_console_callback_match_t **matches)
+static switch_status_t skinny_list_ring_modes(const char *line, const char *cursor, switch_console_callback_match_t **matches)
{
switch_status_t status = SWITCH_STATUS_FALSE;
SKINNY_PUSH_RING_MODES
@@ -1737,7 +1788,7 @@
return status;
}
-static switch_status_t skinny_list_speaker_mode(const char *line, const char *cursor, switch_console_callback_match_t **matches)
+static switch_status_t skinny_list_speaker_modes(const char *line, const char *cursor, switch_console_callback_match_t **matches)
{
switch_status_t status = SWITCH_STATUS_FALSE;
SKINNY_PUSH_SPEAKER_MODES
@@ -1830,19 +1881,21 @@
switch_console_set_complete("add skinny status profile ::skinny::list_profiles");
switch_console_set_complete("add skinny status profile ::skinny::list_profiles device ::skinny::list_devices");
- switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send SetRingerMessage ::skinny::list_ring_type ::skinny::list_ring_mode");
+ switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send ResetMessage ::skinny::list_reset_types");
+ switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send SetRingerMessage ::skinny::list_ring_types ::skinny::list_ring_modes");
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_mode");
- switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send CallState ::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 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_add_complete_func("::skinny::list_profiles", skinny_list_profiles);
switch_console_add_complete_func("::skinny::list_devices", skinny_list_devices);
- switch_console_add_complete_func("::skinny::list_ring_type", skinny_list_ring_type);
- switch_console_add_complete_func("::skinny::list_ring_mode", skinny_list_ring_mode);
+ switch_console_add_complete_func("::skinny::list_reset_types", skinny_list_reset_types);
+ switch_console_add_complete_func("::skinny::list_ring_types", skinny_list_ring_types);
+ switch_console_add_complete_func("::skinny::list_ring_modes", skinny_list_ring_modes);
switch_console_add_complete_func("::skinny::list_stimuli", skinny_list_stimuli);
switch_console_add_complete_func("::skinny::list_stimulus_instances", skinny_list_stimulus_instances);
switch_console_add_complete_func("::skinny::list_stimulus_modes", skinny_list_stimulus_modes);
- switch_console_add_complete_func("::skinny::list_speaker_mode", skinny_list_speaker_mode);
+ switch_console_add_complete_func("::skinny::list_speaker_modes", skinny_list_speaker_modes);
switch_console_add_complete_func("::skinny::list_call_states", skinny_list_call_states);
switch_console_add_complete_func("::skinny::list_line_instances", skinny_list_line_instances);
switch_console_add_complete_func("::skinny::list_call_ids", skinny_list_call_ids);
Modified: freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c (16818 => 16819)
--- freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c 2010-02-25 13:56:11 UTC (rev 16818)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c 2010-02-25 14:34:43 UTC (rev 16819)
@@ -76,7 +76,7 @@
{"AlarmMessage", ALARM_MESSAGE},
{"OpenReceiveChannelAckMessage", OPEN_RECEIVE_CHANNEL_ACK_MESSAGE},
{"SoftKeySetReqMessage", SOFT_KEY_SET_REQ_MESSAGE},
- {"SOftKeyEventMessage", SOFT_KEY_EVENT_MESSAGE},
+ {"SoftKeyEventMessage", SOFT_KEY_EVENT_MESSAGE},
{"UnregisterMessage", UNREGISTER_MESSAGE},
{"SoftKeyTemplateReqMessage", SOFT_KEY_TEMPLATE_REQ_MESSAGE},
{"FeatureStatReqMessage", FEATURE_STAT_REQ_MESSAGE},
@@ -98,7 +98,8 @@
{"ButtonTemplateResMessage", BUTTON_TEMPLATE_RES_MESSAGE},
{"CapabilitiesReqMessage", CAPABILITIES_REQ_MESSAGE},
{"RegisterRejMessage", REGISTER_REJ_MESSAGE},
- {"KeepAliveAckMessageMessage", KEEP_ALIVE_ACK_MESSAGE},
+ {"ResetMessage", RESET_MESSAGE},
+ {"KeepAliveAckMessage", KEEP_ALIVE_ACK_MESSAGE},
{"OpenReceiveChannelMessage", OPEN_RECEIVE_CHANNEL_MESSAGE},
{"OCloseReceiveChannelMessage", CLOSE_RECEIVE_CHANNEL_MESSAGE},
{"SoftKeyTemplateResMessage", SOFT_KEY_TEMPLATE_RES_MESSAGE},
@@ -198,6 +199,15 @@
};
SKINNY_DECLARE_ID2STR(skinny_call_state2str, SKINNY_CALL_STATES, "CallStateUnknown")
SKINNY_DECLARE_STR2ID(skinny_str2call_state, SKINNY_CALL_STATES, -1)
+
+struct skinny_table SKINNY_DEVICE_RESET_TYPES[] = {
+ {"DeviceReset", SKINNY_DEVICE_RESET},
+ {"DeviceRestart", SKINNY_DEVICE_RESTART},
+ {NULL, 0}
+};
+SKINNY_DECLARE_ID2STR(skinny_device_reset_type2str, SKINNY_DEVICE_RESET_TYPES, "DeviceResetTypeUnknown")
+SKINNY_DECLARE_STR2ID(skinny_str2device_reset_type, SKINNY_DEVICE_RESET_TYPES, -1)
+
/*****************************************************************************/
/* SKINNY FUNCTIONS */
/*****************************************************************************/
@@ -1081,6 +1091,18 @@
return SWITCH_STATUS_SUCCESS;
}
+switch_status_t send_reset(listener_t *listener,
+ uint32_t reset_type)
+{
+ skinny_message_t *message;
+ message = switch_core_alloc(listener->pool, 12+sizeof(message->data.reset));
+ message->type = RESET_MESSAGE;
+ message->length = 4 + sizeof(message->data.reset);
+ message->data.reset.reset_type = reset_type;
+ skinny_send_reply(listener, message);
+ return SWITCH_STATUS_SUCCESS;
+}
+
/* Message handling */
switch_status_t skinny_handle_alarm(listener_t *listener, skinny_message_t *request)
{