]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Skinny: manage shared lines from the calling POV
authorMathieu Parent <math.parent@gmail.com>
Fri, 9 Apr 2010 12:59:18 +0000 (14:59 +0200)
committerMathieu Parent <math.parent@gmail.com>
Fri, 9 Apr 2010 12:59:18 +0000 (14:59 +0200)
Called POV already implemented

src/mod/endpoints/mod_skinny/skinny_protocol.c

index 8a96f7e6298788e265ac8dafe30d860994dc954d..3d72a22640fc1286b011b230d41f91deccad250f 100644 (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;