Diff
Modified: freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.c (17265 => 17266)
--- freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.c 2010-04-09 14:54:29 UTC (rev 17265)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.c 2010-04-09 16:02:14 UTC (rev 17266)
@@ -221,7 +221,7 @@
"SELECT channel_uuid, line_instance "
"FROM skinny_active_lines "
"WHERE %s AND %s AND %s "
- "ORDER BY channel_uuid DESC",
+ "ORDER BY call_state, channel_uuid", /* off hook first */
device_condition, line_instance_condition, call_id_condition
))) {
skinny_execute_sql_callback(profile, profile->sql_mutex, sql,
@@ -365,7 +365,9 @@
int skinny_line_get_state_callback(void *pArg, int argc, char **argv, char **columnNames)
{
struct skinny_line_get_state_helper *helper = pArg;
- helper->call_state = atoi(argv[0]);
+ if (helper->call_state == -1) {
+ helper->call_state = atoi(argv[0]);
+ }
return 0;
}
@@ -391,10 +393,12 @@
}
switch_assert(call_id_condition);
+ helper.call_state = -1;
if ((sql = switch_mprintf(
"SELECT call_state FROM skinny_active_lines "
"WHERE device_name='%s' AND device_instance=%d "
- "AND %s AND %s",
+ "AND %s AND %s "
+ "ORDER BY call_state, channel_uuid", /* off hook first */
listener->device_name, listener->device_instance,
line_instance_condition, call_id_condition
))) {
Modified: freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c (17265 => 17266)
--- freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c 2010-04-09 14:54:29 UTC (rev 17265)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c 2010-04-09 16:02:14 UTC (rev 17266)
@@ -451,7 +451,6 @@
*session = nsession;
return SWITCH_STATUS_SUCCESS;
}
- skinny_session_hold_line(nsession, listener, *line_instance_p);
switch_core_session_rwunlock(nsession);
}
*line_instance_p = line_instance;
@@ -459,6 +458,8 @@
*line_instance_p = 1;
}
+ skinny_hold_active_calls(listener);
+
skinny_line_get(listener, *line_instance_p, &button);
if (!button || !button->shortname) {
@@ -819,6 +820,7 @@
channel = switch_core_session_get_channel(session);
tech_pvt = switch_core_session_get_private(session);
+ skinny_hold_active_calls(listener);
send_set_ringer(listener, SKINNY_RING_OFF, SKINNY_RING_FOREVER, 0, tech_pvt->call_id);
send_set_speaker_mode(listener, SKINNY_SPEAKER_ON);
send_select_soft_keys(listener, line_instance, tech_pvt->call_id, SKINNY_KEY_SET_RING_OUT, 0xffff);
@@ -854,6 +856,65 @@
return SWITCH_STATUS_SUCCESS;
}
+struct skinny_hold_active_calls_helper {
+ listener_t *listener;
+};
+
+int skinny_hold_active_calls_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
+ struct skinny_hold_active_calls_helper *helper = pArg;
+ switch_core_session_t *session;
+
+ /* char *device_name = argv[0]; */
+ /* uint32_t device_instance = atoi(argv[1]); */
+ /* uint32_t position = atoi(argv[2]); */
+ uint32_t line_instance = atoi(argv[3]);
+ /* char *label = argv[4]; */
+ /* char *value = argv[5]; */
+ /* char *caller_name = argv[6]; */
+ /* uint32_t ring_on_idle = atoi(argv[7]); */
+ /* uint32_t ring_on_active = atoi(argv[8]); */
+ /* uint32_t busy_trigger = atoi(argv[9]); */
+ /* char *forward_all = argv[10]; */
+ /* char *forward_busy = argv[11]; */
+ /* char *forward_noanswer = argv[12]; */
+ /* uint32_t noanswer_duration = atoi(argv[13]); */
+ /* char *channel_uuid = argv[14]; */
+ uint32_t call_id = atoi(argv[15]);
+ /* uint32_t call_state = atoi(argv[16]); */
+
+ session = skinny_profile_find_session(helper->listener->profile, helper->listener, &line_instance, call_id);
+
+ if(session) {
+ skinny_session_hold_line(session, helper->listener, line_instance);
+ switch_core_session_rwunlock(session);
+ }
+
+ return 0;
+}
+
+switch_status_t skinny_hold_active_calls(listener_t *listener)
+{
+ struct skinny_hold_active_calls_helper helper = {0};
+ char *sql;
+
+ helper.listener = listener;
+
+ if ((sql = switch_mprintf(
+ "SELECT skinny_lines.*, channel_uuid, call_id, call_state "
+ "FROM skinny_active_lines "
+ "INNER JOIN skinny_lines "
+ "ON skinny_active_lines.device_name = skinny_lines.device_name "
+ "AND skinny_active_lines.device_instance = skinny_lines.device_instance "
+ "AND skinny_active_lines.line_instance = skinny_lines.line_instance "
+ "WHERE skinny_lines.device_name='%s' AND skinny_lines.device_instance=%d AND call_state=%d",
+ listener->device_name, listener->device_instance, SKINNY_CONNECTED))) {
+ skinny_execute_sql_callback(listener->profile, listener->profile->sql_mutex, sql, skinny_hold_active_calls_callback, &helper);
+ switch_safe_free(sql);
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
/*****************************************************************************/
/* SKINNY BUTTONS */
/*****************************************************************************/
@@ -1900,14 +1961,18 @@
message->data.soft_key_set.soft_key_set[SKINNY_KEY_SET_ON_HOOK].soft_key_template_index[1] = SOFTKEY_REDIAL;
message->data.soft_key_set.soft_key_set[SKINNY_KEY_SET_OFF_HOOK].soft_key_template_index[1] = SOFTKEY_REDIAL;
+ message->data.soft_key_set.soft_key_set[SKINNY_KEY_SET_OFF_HOOK].soft_key_template_index[2] = SOFTKEY_ENDCALL;
message->data.soft_key_set.soft_key_set[SKINNY_KEY_SET_DIGITS_AFTER_DIALING_FIRST_DIGIT].soft_key_template_index[0] = SOFTKEY_BACKSPACE;
+ message->data.soft_key_set.soft_key_set[SKINNY_KEY_SET_DIGITS_AFTER_DIALING_FIRST_DIGIT].soft_key_template_index[2] = SOFTKEY_ENDCALL;
message->data.soft_key_set.soft_key_set[SKINNY_KEY_SET_CONNECTED].soft_key_template_index[0] = SOFTKEY_ENDCALL;
message->data.soft_key_set.soft_key_set[SKINNY_KEY_SET_CONNECTED].soft_key_template_index[1] = SOFTKEY_HOLD;
+ message->data.soft_key_set.soft_key_set[SKINNY_KEY_SET_CONNECTED].soft_key_template_index[2] = SOFTKEY_NEWCALL;
message->data.soft_key_set.soft_key_set[SKINNY_KEY_SET_RING_IN].soft_key_template_index[0] = SOFTKEY_ANSWER;
message->data.soft_key_set.soft_key_set[SKINNY_KEY_SET_RING_IN].soft_key_template_index[1] = SOFTKEY_ENDCALL;
+ message->data.soft_key_set.soft_key_set[SKINNY_KEY_SET_RING_IN].soft_key_template_index[2] = SOFTKEY_NEWCALL;
message->data.soft_key_set.soft_key_set[SKINNY_KEY_SET_ON_HOLD].soft_key_template_index[0] = SOFTKEY_NEWCALL;
message->data.soft_key_set.soft_key_set[SKINNY_KEY_SET_ON_HOLD].soft_key_template_index[1] = SOFTKEY_RESUME;
Modified: freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.h (17265 => 17266)
--- freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.h 2010-04-09 14:54:29 UTC (rev 17265)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.h 2010-04-09 16:02:14 UTC (rev 17266)
@@ -631,6 +631,7 @@
switch_status_t skinny_session_hold_line(switch_core_session_t *session, listener_t *listener, uint32_t line_instance);
switch_status_t skinny_session_unhold_line(switch_core_session_t *session, listener_t *listener, uint32_t line_instance);
switch_status_t skinny_session_stop_media(switch_core_session_t *session, listener_t *listener, uint32_t line_instance);
+switch_status_t skinny_hold_active_calls(listener_t *listener);
void skinny_line_get(listener_t *listener, uint32_t instance, struct line_stat_res_message **button);
void skinny_speed_dial_get(listener_t *listener, uint32_t instance, struct speed_dial_stat_res_message **button);