Reduce the complexity of manager_call_process_request function 45/188445/2 accepted/tizen/5.0/unified/20181102.020858 accepted/tizen/unified/20180910.172022 submit/tizen/20180907.083718 submit/tizen_5.0/20181101.000004
authorsinikang <sinikang@samsung.com>
Wed, 5 Sep 2018 06:44:16 +0000 (15:44 +0900)
committersinikang <sinikang@samsung.com>
Wed, 5 Sep 2018 06:49:19 +0000 (15:49 +0900)
Change-Id: I9955d2dd7ce9433386f47cbd6b7def33db15e1b2

packaging/tel-plugin-manager.spec
src/manager_call.c

index 10194e9..fdc4985 100644 (file)
@@ -1,6 +1,6 @@
 %define major 0
 %define minor 1
-%define patchlevel 11
+%define patchlevel 12
 
 Name:           tel-plugin-manager
 Version:        %{major}.%{minor}.%{patchlevel}
index 52f3786..3c7c147 100644 (file)
@@ -352,105 +352,6 @@ static enum tcore_manager_return __call_search_ecc_rat(Server *server, UserReque
        return TCORE_MANAGER_RETURN_STOP;
 }
 
-static enum tcore_manager_return __call_handle_end_request(Server *server, UserRequest *ur)
-{
-       enum tcore_manager_return ret = TCORE_MANAGER_RETURN_CONTINUE;
-       enum tcore_request_command command = tcore_user_request_get_command(ur);
-
-       switch (command) {
-       case TREQ_CALL_END: {
-               struct treq_call_end *req_data = NULL;
-               int call_handle = INVALID_HANDLE;
-               CoreObject *co_call = manager_util_get_core_object(server, ur, CORE_OBJECT_TYPE_CALL);
-               CoreObject *co_network = manager_util_get_core_object(server, ur, CORE_OBJECT_TYPE_NETWORK);
-               CallObject *call_obj = NULL;
-               Manager *manager = tcore_server_ref_manager(server);
-               TcorePlugin *manager_plugin = tcore_manager_get_plugin(manager);
-               PrivateData *priv_data = tcore_plugin_ref_user_data(manager_plugin);
-               enum tcore_call_status call_status;
-
-               if (!co_network)
-                       return TCORE_MANAGER_RETURN_FAILURE;
-
-               if (priv_data->is_dial_noti_sent)
-                       priv_data->is_dial_noti_sent = FALSE;
-
-               req_data = (struct treq_call_end *)tcore_user_request_ref_data(ur, NULL);
-               call_handle = req_data->handle;
-
-               call_obj = tcore_call_object_find_by_handle(co_call, call_handle);
-               if (!call_obj) {
-                       err("invalid call handle - serious!");
-
-                       if (req_data->type == CALL_END_TYPE_ALL)
-                               info("END_ALL. call handle has no meaning. continue");
-                       else
-                               return TCORE_MANAGER_RETURN_FAILURE;
-               }
-
-               call_status = tcore_call_object_get_status(call_obj);
-               if ((TCORE_CALL_STATUS_SETUP == call_status)
-                   || (TCORE_CALL_STATUS_SETUP_PENDING == call_status)) {
-                       struct tresp_call_end resp;
-
-                       if (tfeature_is_supported(TFEATURE_FUNCTION_NET_CHECK_ECC_RAT)) {
-                               enum telephony_network_ecc_rat_search_status rat_search_status;
-
-                               tcore_network_get_ecc_rat_search_status(co_network, &rat_search_status);
-                               if (tcore_call_object_get_type(call_obj) == TCORE_CALL_TYPE_E911
-                                   && rat_search_status == NETWORK_ECC_RAT_SEARCH_STATUS_WAITING) {
-                                       struct tnoti_call_status_idle noti_data;
-
-                                       dbg("Call end requested during ECC RAT Searching, free call_obj");
-                                       tcore_network_set_ecc_rat_search_status(co_network, NETWORK_ECC_RAT_SEARCH_STATUS_IDLE);
-
-                                       resp.err = CALL_ERROR_NONE;
-                                       resp.type = req_data->type;
-                                       resp.handle = req_data->handle;
-                                       tcore_user_request_send_response(ur, TRESP_CALL_END, sizeof(struct tresp_call_end), &resp);
-                                       tcore_user_request_unref(ur);
-
-                                       noti_data.type = CALL_TYPE_E911;
-                                       noti_data.handle = tcore_call_object_get_handle(call_obj);
-                                       noti_data.cause = CALL_END_CAUSE_NONE;
-                                       tcore_call_object_free(co_call, call_obj);
-
-                                       tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(co_call)),
-                                                                      co_call, TNOTI_CALL_STATUS_IDLE,
-                                                                      sizeof(struct tnoti_call_status_idle), &noti_data);
-                                       return TCORE_MANAGER_RETURN_STOP;
-                               }
-                       }
-                       info("call %d release requested but SETUP/PENDING state - save release request into call obj and wait for call event", call_handle);
-                       info("SETUP state - wait for dialing notification then send release request to CP");
-                       info("PENDING state - wait for precondition result then release call_obj and notify CALL_END to application");
-
-                       tcore_call_object_set_is_release_pending(call_obj, TRUE);
-
-                       resp.err = CALL_ERROR_NONE;
-                       resp.type = req_data->type;
-                       resp.handle = req_data->handle;
-
-                       tcore_user_request_send_response(ur, TRESP_CALL_END, sizeof(struct tresp_call_end), &resp);
-                       tcore_user_request_unref(ur);
-                       ret = TCORE_MANAGER_RETURN_STOP;
-               } else {
-                       dbg("ordinary call release request - bypass request to modem plugin");
-                       if (tcore_call_object_check_cs_call_existence(co_call) == FALSE)
-                               ret = TCORE_MANAGER_RETURN_CONTINUE_IMS;
-                       else
-                               ret = TCORE_MANAGER_RETURN_CONTINUE;
-               }
-       }
-       break;
-
-       default:
-               break;
-       }
-
-       return ret;
-}
-
 static void on_resp_manager_silent_redial(UserRequest *ur,
                                          enum tcore_response_command command,
                                          unsigned int data_len, const void *data, void *user_data)
@@ -798,7 +699,7 @@ void manager_call_process_modem_error(CoreObject *co_modem)
        }
 }
 
-enum tcore_manager_return manager_call_process_request(Server *server, UserRequest *ur)
+static enum tcore_manager_return __call_handle_dial_request(Server *server, UserRequest *ur)
 {
        enum tcore_request_command command = tcore_user_request_get_command(ur);
        enum tcore_manager_return mret = TCORE_MANAGER_RETURN_CONTINUE;
@@ -850,7 +751,7 @@ enum tcore_manager_return manager_call_process_request(Server *server, UserReque
                if (req_data->type == CALL_TYPE_E911) {
                        /*
                         * Emergency call handling -
-                        *   #step 1. check CS only based on Network Policy
+                        *      #step 1. check CS only based on Network Policy
                         */
                        if (TRUE == __is_emergency_only_via_cs()) {
                                info("This device only induce emergency call to CS");
@@ -864,7 +765,7 @@ enum tcore_manager_return manager_call_process_request(Server *server, UserReque
                        if (tfeature_is_supported(TFEATURE_FUNCTION_NET_CHECK_ECC_RAT)) {
                                dbg("S.LSI modem. Query RAT for Emergency call");
                                if (req_data->type == CALL_TYPE_E911) {
-                                       /*  For Every case request CP for ECC RAT information
+                                       /*      For Every case request CP for ECC RAT information
                                        enum telephony_network_access_technology act = NETWORK_ACT_UNKNOWN;
 
                                        tcore_network_get_access_technology(co_network, &act);
@@ -897,13 +798,13 @@ enum tcore_manager_return manager_call_process_request(Server *server, UserReque
 
                        /*
                         * Emergency call handling -
-                        *    #step 2. we can go CS or PS
+                        *      #step 2. we can go CS or PS
                         */
-                       /*  READ) cs/ps status
+                       /*      READ) cs/ps status
                         *      if) cs == NOSVC && ps == NOSVC : both No - NO SVC : FAIL : END
                         *      if) cs is over Emergency && ps is NOSVC => GOTO CS : END
                         *      if) cs is NOSVC && ps is over Emergency => GOTO PS : END
-                        *  if) both available => GOTO CS : END
+                        *      if) both available => GOTO CS : END
                         */
                        tcore_network_get_service_status(co_network,
                                TCORE_NETWORK_SERVICE_DOMAIN_TYPE_PACKET, &ps_status);
@@ -961,10 +862,10 @@ enum tcore_manager_return manager_call_process_request(Server *server, UserReque
                         * Video : NETWORK_IMS_REG_FEATURE_TYPE_VT
                         */
                        if ((req_data->type == CALL_TYPE_VOICE)
-                           && (!manager_util_is_ims_registered(server, ur, NETWORK_IMS_REG_FEATURE_TYPE_VOLTE))) {
+                               && (!manager_util_is_ims_registered(server, ur, NETWORK_IMS_REG_FEATURE_TYPE_VOLTE))) {
                                break;
                        } else if ((req_data->type == CALL_TYPE_VIDEO)
-                                  && (!manager_util_is_ims_registered(server, ur, NETWORK_IMS_REG_FEATURE_TYPE_VT))) {
+                               && (!manager_util_is_ims_registered(server, ur, NETWORK_IMS_REG_FEATURE_TYPE_VT))) {
                                break;
                        }
 
@@ -995,8 +896,8 @@ enum tcore_manager_return manager_call_process_request(Server *server, UserReque
 
                                if ((is_ignore == FALSE) && (ims_voice_status == FALSE)) {
                                        dbg("is_ignore: [%s] ims_voice_status: [%s]",
-                                           (is_ignore ? "TRUE" : "FALSE"),
-                                           (ims_voice_status ? "TRUE" : "FALSE"));
+                                               (is_ignore ? "TRUE" : "FALSE"),
+                                               (ims_voice_status ? "TRUE" : "FALSE"));
                                        break;
                                }
                        } else {
@@ -1014,6 +915,122 @@ enum tcore_manager_return manager_call_process_request(Server *server, UserReque
                }
        }
        break;
+       default:
+       break;
+       }
+
+       return mret;
+}
+
+static enum tcore_manager_return __call_handle_end_request(Server *server, UserRequest *ur)
+{
+       enum tcore_manager_return ret = TCORE_MANAGER_RETURN_CONTINUE;
+       enum tcore_request_command command = tcore_user_request_get_command(ur);
+
+       switch (command) {
+       case TREQ_CALL_END: {
+               struct treq_call_end *req_data = NULL;
+               int call_handle = INVALID_HANDLE;
+               CoreObject *co_call = manager_util_get_core_object(server, ur, CORE_OBJECT_TYPE_CALL);
+               CoreObject *co_network = manager_util_get_core_object(server, ur, CORE_OBJECT_TYPE_NETWORK);
+               CallObject *call_obj = NULL;
+               Manager *manager = tcore_server_ref_manager(server);
+               TcorePlugin *manager_plugin = tcore_manager_get_plugin(manager);
+               PrivateData *priv_data = tcore_plugin_ref_user_data(manager_plugin);
+               enum tcore_call_status call_status;
+
+               if (!co_network)
+                       return TCORE_MANAGER_RETURN_FAILURE;
+
+               if (priv_data->is_dial_noti_sent)
+                       priv_data->is_dial_noti_sent = FALSE;
+
+               req_data = (struct treq_call_end *)tcore_user_request_ref_data(ur, NULL);
+               call_handle = req_data->handle;
+
+               call_obj = tcore_call_object_find_by_handle(co_call, call_handle);
+               if (!call_obj) {
+                       err("invalid call handle - serious!");
+
+                       if (req_data->type == CALL_END_TYPE_ALL)
+                               info("END_ALL. call handle has no meaning. continue");
+                       else
+                               return TCORE_MANAGER_RETURN_FAILURE;
+               }
+
+               call_status = tcore_call_object_get_status(call_obj);
+               if ((TCORE_CALL_STATUS_SETUP == call_status)
+                   || (TCORE_CALL_STATUS_SETUP_PENDING == call_status)) {
+                       struct tresp_call_end resp;
+
+                       if (tfeature_is_supported(TFEATURE_FUNCTION_NET_CHECK_ECC_RAT)) {
+                               enum telephony_network_ecc_rat_search_status rat_search_status;
+
+                               tcore_network_get_ecc_rat_search_status(co_network, &rat_search_status);
+                               if (tcore_call_object_get_type(call_obj) == TCORE_CALL_TYPE_E911
+                                   && rat_search_status == NETWORK_ECC_RAT_SEARCH_STATUS_WAITING) {
+                                       struct tnoti_call_status_idle noti_data;
+
+                                       dbg("Call end requested during ECC RAT Searching, free call_obj");
+                                       tcore_network_set_ecc_rat_search_status(co_network, NETWORK_ECC_RAT_SEARCH_STATUS_IDLE);
+
+                                       resp.err = CALL_ERROR_NONE;
+                                       resp.type = req_data->type;
+                                       resp.handle = req_data->handle;
+                                       tcore_user_request_send_response(ur, TRESP_CALL_END, sizeof(struct tresp_call_end), &resp);
+                                       tcore_user_request_unref(ur);
+
+                                       noti_data.type = CALL_TYPE_E911;
+                                       noti_data.handle = tcore_call_object_get_handle(call_obj);
+                                       noti_data.cause = CALL_END_CAUSE_NONE;
+                                       tcore_call_object_free(co_call, call_obj);
+
+                                       tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(co_call)),
+                                                                      co_call, TNOTI_CALL_STATUS_IDLE,
+                                                                      sizeof(struct tnoti_call_status_idle), &noti_data);
+                                       return TCORE_MANAGER_RETURN_STOP;
+                               }
+                       }
+                       info("call %d release requested but SETUP/PENDING state - save release request into call obj and wait for call event", call_handle);
+                       info("SETUP state - wait for dialing notification then send release request to CP");
+                       info("PENDING state - wait for precondition result then release call_obj and notify CALL_END to application");
+
+                       tcore_call_object_set_is_release_pending(call_obj, TRUE);
+
+                       resp.err = CALL_ERROR_NONE;
+                       resp.type = req_data->type;
+                       resp.handle = req_data->handle;
+
+                       tcore_user_request_send_response(ur, TRESP_CALL_END, sizeof(struct tresp_call_end), &resp);
+                       tcore_user_request_unref(ur);
+                       ret = TCORE_MANAGER_RETURN_STOP;
+               } else {
+                       dbg("ordinary call release request - bypass request to modem plugin");
+                       if (tcore_call_object_check_cs_call_existence(co_call) == FALSE)
+                               ret = TCORE_MANAGER_RETURN_CONTINUE_IMS;
+                       else
+                               ret = TCORE_MANAGER_RETURN_CONTINUE;
+               }
+       }
+       break;
+       default:
+               break;
+       }
+
+       return ret;
+}
+
+enum tcore_manager_return manager_call_process_request(Server *server, UserRequest *ur)
+{
+       enum tcore_request_command command = tcore_user_request_get_command(ur);
+       enum tcore_manager_return mret = TCORE_MANAGER_RETURN_CONTINUE;
+       CoreObject *co_call = manager_util_get_core_object(server, ur, CORE_OBJECT_TYPE_CALL);
+
+       switch (command) {
+       case TREQ_CALL_DIAL: {
+               mret = __call_handle_dial_request(server, ur);
+       }
+       break;
 
        case TREQ_CALL_END: {
                mret = __call_handle_end_request(server, ur);