Skinny: Line state
Avoid the use of TFLAG_WAITING_DEST an replace by a line_state corresponding to the softkey events git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16787 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
99ce7a4b01
commit
afbab7bc7b
|
@ -238,7 +238,29 @@ switch_bool_t skinny_execute_sql_callback(skinny_profile_t *profile,
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* CHANNEL FUNCTIONS */
|
/* CHANNEL FUNCTIONS */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
uint32_t skinny_line_perform_set_state(listener_t *listener, const char *file, const char *func, int line, uint32_t instance, uint32_t state, uint32_t call_id)
|
||||||
|
{
|
||||||
|
switch_assert(listener);
|
||||||
|
|
||||||
|
if(listener->session[instance]) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(listener->session[instance]), SWITCH_LOG_DEBUG, "Device %s, line %d State Change %d -> %d\n",
|
||||||
|
listener->device_name, instance, listener->line_state[instance], state);
|
||||||
|
} else {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Device %s, line %d State Change %d -> %d (no session)\n",
|
||||||
|
listener->device_name, instance, listener->line_state[instance], state);
|
||||||
|
}
|
||||||
|
send_select_soft_keys(listener, instance, call_id, state, 0xffff);
|
||||||
|
listener->line_state[instance] = state;
|
||||||
|
|
||||||
|
return listener->line_state[instance];
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t skinny_line_get_state(listener_t *listener, uint32_t instance)
|
||||||
|
{
|
||||||
|
switch_assert(listener);
|
||||||
|
|
||||||
|
return listener->line_state[instance];
|
||||||
|
}
|
||||||
switch_status_t skinny_tech_set_codec(private_t *tech_pvt, int force)
|
switch_status_t skinny_tech_set_codec(private_t *tech_pvt, int force)
|
||||||
{
|
{
|
||||||
int ms;
|
int ms;
|
||||||
|
|
|
@ -112,6 +112,7 @@ struct listener {
|
||||||
skinny_profile_t *profile;
|
skinny_profile_t *profile;
|
||||||
char device_name[16];
|
char device_name[16];
|
||||||
switch_core_session_t *session[SKINNY_MAX_LINES];
|
switch_core_session_t *session[SKINNY_MAX_LINES];
|
||||||
|
uint32_t line_state[SKINNY_MAX_LINES]; /* See enum skinny_key_set */
|
||||||
|
|
||||||
switch_socket_t *sock;
|
switch_socket_t *sock;
|
||||||
switch_memory_pool_t *pool;
|
switch_memory_pool_t *pool;
|
||||||
|
@ -145,9 +146,7 @@ typedef enum {
|
||||||
TFLAG_BREAK = (1 << 8),
|
TFLAG_BREAK = (1 << 8),
|
||||||
|
|
||||||
TFLAG_READING = (1 << 9),
|
TFLAG_READING = (1 << 9),
|
||||||
TFLAG_WRITING = (1 << 10),
|
TFLAG_WRITING = (1 << 10)
|
||||||
|
|
||||||
TFLAG_WAITING_DEST = (1 << 11)
|
|
||||||
} TFLAGS;
|
} TFLAGS;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -204,6 +203,11 @@ switch_status_t keepalive_listener(listener_t *listener, void *pvt);
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* CHANNEL FUNCTIONS */
|
/* CHANNEL FUNCTIONS */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
uint32_t skinny_line_perform_set_state(listener_t *listener, const char *file, const char *func, int line, uint32_t instance, uint32_t state, uint32_t call_id);
|
||||||
|
#define skinny_line_set_state(listener, instance, state, call_id) skinny_line_perform_set_state(listener, __FILE__, __SWITCH_FUNC__, __LINE__, instance, state, call_id)
|
||||||
|
|
||||||
|
uint32_t skinny_line_get_state(listener_t *listener, uint32_t instance);
|
||||||
|
|
||||||
switch_status_t skinny_tech_set_codec(private_t *tech_pvt, int force);
|
switch_status_t skinny_tech_set_codec(private_t *tech_pvt, int force);
|
||||||
void tech_init(private_t *tech_pvt, switch_core_session_t *session);
|
void tech_init(private_t *tech_pvt, switch_core_session_t *session);
|
||||||
switch_status_t channel_on_init(switch_core_session_t *session);
|
switch_status_t channel_on_init(switch_core_session_t *session);
|
||||||
|
|
|
@ -308,8 +308,6 @@ switch_status_t skinny_pick_up(listener_t *listener, uint32_t line)
|
||||||
|
|
||||||
tech_init(tech_pvt, session);
|
tech_init(tech_pvt, session);
|
||||||
|
|
||||||
switch_set_flag_locked(tech_pvt, TFLAG_WAITING_DEST);
|
|
||||||
|
|
||||||
set_ringer(listener, SKINNY_RING_OFF, SKINNY_RING_FOREVER, 0);
|
set_ringer(listener, SKINNY_RING_OFF, SKINNY_RING_FOREVER, 0);
|
||||||
set_speaker_mode(listener, SKINNY_SPEAKER_ON);
|
set_speaker_mode(listener, SKINNY_SPEAKER_ON);
|
||||||
set_lamp(listener, SKINNY_BUTTON_LINE, tech_pvt->line, SKINNY_LAMP_ON);
|
set_lamp(listener, SKINNY_BUTTON_LINE, tech_pvt->line, SKINNY_LAMP_ON);
|
||||||
|
@ -317,8 +315,7 @@ switch_status_t skinny_pick_up(listener_t *listener, uint32_t line)
|
||||||
SKINNY_OFF_HOOK,
|
SKINNY_OFF_HOOK,
|
||||||
tech_pvt->line,
|
tech_pvt->line,
|
||||||
tech_pvt->call_id);
|
tech_pvt->call_id);
|
||||||
send_select_soft_keys(listener, tech_pvt->line, tech_pvt->call_id,
|
skinny_line_set_state(listener, tech_pvt->line, SKINNY_KEY_SET_OFF_HOOK, tech_pvt->call_id);
|
||||||
SKINNY_KEY_SET_OFF_HOOK, 0xffff);
|
|
||||||
display_prompt_status(listener,
|
display_prompt_status(listener,
|
||||||
0,
|
0,
|
||||||
"\200\000",
|
"\200\000",
|
||||||
|
@ -368,11 +365,7 @@ switch_status_t skinny_answer(switch_core_session_t *session)
|
||||||
SKINNY_CONNECTED,
|
SKINNY_CONNECTED,
|
||||||
tech_pvt->line,
|
tech_pvt->line,
|
||||||
tech_pvt->call_id);
|
tech_pvt->call_id);
|
||||||
send_select_soft_keys(listener,
|
skinny_line_set_state(listener, tech_pvt->line, SKINNY_KEY_SET_CONNECTED, tech_pvt->call_id);
|
||||||
tech_pvt->line,
|
|
||||||
tech_pvt->call_id,
|
|
||||||
SKINNY_KEY_SET_CONNECTED,
|
|
||||||
0xffff);
|
|
||||||
display_prompt_status(listener,
|
display_prompt_status(listener,
|
||||||
0,
|
0,
|
||||||
"\200\030",
|
"\200\030",
|
||||||
|
@ -1474,21 +1467,20 @@ switch_status_t skinny_handle_keypad_button_message(listener_t *listener, skinny
|
||||||
|
|
||||||
/* TODO check call_id and line */
|
/* TODO check call_id and line */
|
||||||
|
|
||||||
if(switch_test_flag(tech_pvt, TFLAG_WAITING_DEST)) {
|
if((skinny_line_get_state(listener, tech_pvt->line) == SKINNY_KEY_SET_OFF_HOOK)
|
||||||
|
|| (skinny_line_get_state(listener, tech_pvt->line) == SKINNY_KEY_SET_DIGITS_AFTER_DIALING_FIRST_DIGIT)) {
|
||||||
char name[128];
|
char name[128];
|
||||||
switch_channel_t *channel;
|
switch_channel_t *channel;
|
||||||
char *cid_name = "TODO-soft_key_event"; /* TODO */
|
char *cid_name = "TODO-soft_key_event"; /* TODO */
|
||||||
char *cid_num = "00000"; /* TODO */
|
char *cid_num = "00000"; /* TODO */
|
||||||
if(strlen(tech_pvt->dest) == 0) {/* first digit */
|
if(strlen(tech_pvt->dest) == 0) {/* first digit */
|
||||||
stop_tone(listener, tech_pvt->line, tech_pvt->call_id);
|
stop_tone(listener, tech_pvt->line, tech_pvt->call_id);
|
||||||
send_select_soft_keys(listener, tech_pvt->line, tech_pvt->call_id,
|
skinny_line_set_state(listener, tech_pvt->line, SKINNY_KEY_SET_DIGITS_AFTER_DIALING_FIRST_DIGIT, tech_pvt->call_id);
|
||||||
SKINNY_KEY_SET_DIGITS_AFTER_DIALING_FIRST_DIGIT, 0xffff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tech_pvt->dest[strlen(tech_pvt->dest)] = digit;
|
tech_pvt->dest[strlen(tech_pvt->dest)] = digit;
|
||||||
|
|
||||||
if(strlen(tech_pvt->dest) >= 4) { /* TODO Number is complete */
|
if(strlen(tech_pvt->dest) >= 4) { /* TODO Number is complete */
|
||||||
switch_clear_flag_locked(tech_pvt, TFLAG_WAITING_DEST);
|
|
||||||
if (!(tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(listener->session[line]),
|
if (!(tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(listener->session[line]),
|
||||||
NULL, listener->profile->dialplan, cid_name, cid_num, listener->remote_ip, NULL, NULL, NULL, "skinny" /* modname */, listener->profile->context, tech_pvt->dest)) != 0) {
|
NULL, listener->profile->dialplan, cid_name, cid_num, listener->remote_ip, NULL, NULL, NULL, "skinny" /* modname */, listener->profile->context, tech_pvt->dest)) != 0) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(listener->session[line]), SWITCH_LOG_CRIT, "Error Creating Session caller profile\n");
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(listener->session[line]), SWITCH_LOG_CRIT, "Error Creating Session caller profile\n");
|
||||||
|
@ -1510,11 +1502,7 @@ switch_status_t skinny_handle_keypad_button_message(listener_t *listener, skinny
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
send_select_soft_keys(listener,
|
skinny_line_set_state(listener, tech_pvt->line, SKINNY_KEY_SET_CONNECTED, tech_pvt->call_id);
|
||||||
tech_pvt->line,
|
|
||||||
tech_pvt->call_id,
|
|
||||||
SKINNY_KEY_SET_CONNECTED,
|
|
||||||
0xffff);
|
|
||||||
send_dialed_number(listener, tech_pvt->dest, tech_pvt->line, tech_pvt->call_id);
|
send_dialed_number(listener, tech_pvt->dest, tech_pvt->line, tech_pvt->call_id);
|
||||||
skinny_answer(listener->session[line]);
|
skinny_answer(listener->session[line]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue