Revision
17263
Author
math.parent
Date
2010-04-09 07:59:18 -0500 (Fri, 09 Apr 2010)

Log Message

Skinny: manage shared lines from the calling POV

Called POV already implemented

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c (17262 => 17263)


--- freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c	2010-04-09 12:40:33 UTC (rev 17262)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c	2010-04-09 12:59:18 UTC (rev 17263)
@@ -547,6 +547,49 @@
 	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 @@
 	}
 	/* 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;