Skinny: manage shared lines from the calling POV

Called POV already implemented
This commit is contained in:
Mathieu Parent 2010-04-09 14:59:18 +02:00
parent 924e960d0a
commit 7e3c29c600
1 changed files with 50 additions and 0 deletions

View File

@ -547,6 +547,49 @@ done:
return SWITCH_STATUS_SUCCESS;
}
struct skinny_session_process_dest_helper {
private_t *tech_pvt;
listener_t *listener;
uint32_t line_instance;
};
int skinny_session_process_dest_callback(void *pArg, int argc, char **argv, char **columnNames)
{
struct skinny_session_process_dest_helper *helper = pArg;
listener_t *listener = NULL;
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]); */
skinny_profile_find_listener_by_device_name_and_instance(helper->tech_pvt->profile, device_name, device_instance, &listener);
if(listener) {
if(!strcmp(device_name, helper->listener->device_name)
&& (device_instance == helper->listener->device_instance)
&& (line_instance == helper->line_instance)) {/* the calling line */
/* nothing */
} else {
/* TODO: capture and check what should happen here*/
skinny_line_set_state(listener, line_instance, helper->tech_pvt->call_id, SKINNY_IN_USE_REMOTELY);
}
}
return 0;
}
switch_status_t skinny_session_process_dest(switch_core_session_t *session, listener_t *listener, uint32_t line_instance, char *dest, char append_dest, uint32_t backspace)
{
switch_channel_t *channel = NULL;
@ -577,10 +620,17 @@ switch_status_t skinny_session_process_dest(switch_core_session_t *session, list
}
/* TODO Number is complete -> check against dialplan */
if((strlen(tech_pvt->caller_profile->destination_number) >= 4) || dest) {
struct skinny_session_process_dest_helper helper = {0};
send_dialed_number(listener, tech_pvt->caller_profile->destination_number, line_instance, tech_pvt->call_id);
skinny_line_set_state(listener, line_instance, tech_pvt->call_id, SKINNY_PROCEED);
skinny_send_call_info(session, listener, line_instance);
skinny_session_start_media(session, listener, line_instance);
helper.tech_pvt = tech_pvt;
helper.listener = listener;
helper.line_instance = line_instance;
skinny_session_walk_lines(tech_pvt->profile, switch_core_session_get_uuid(session), skinny_session_process_dest_callback, &helper);
}
return SWITCH_STATUS_SUCCESS;