Modify a duplicate code to use a function 57/188357/2 accepted/tizen_5.0_unified tizen_5.0 accepted/tizen/5.0/unified/20181102.020711 accepted/tizen/unified/20180910.172034 submit/tizen/20180907.083718 submit/tizen_5.0/20181101.000004
authorsinikang <sinikang@samsung.com>
Tue, 4 Sep 2018 07:07:28 +0000 (16:07 +0900)
committersinikang <sinikang@samsung.com>
Tue, 4 Sep 2018 07:53:45 +0000 (16:53 +0900)
Change-Id: I6802a58f6f706abab295f463fe0a1a2e9c5fa01f

packaging/tel-plugin-dbus_tapi.spec
src/dtapi_sim.c

index 2cf772f..980b208 100644 (file)
@@ -1,6 +1,6 @@
 %define major 0
 %define minor 3
-%define patchlevel 98
+%define patchlevel 99
 
 Name:           tel-plugin-dbus_tapi
 Version:        %{major}.%{minor}.%{patchlevel}
index 44b8b49..5bcdead 100644 (file)
@@ -398,6 +398,47 @@ static void __return_fail_response(GDBusMethodInvocation *invocation,
        }
 }
 
+static gint __convert_sim_facility_type(enum tel_sim_facility_type type)
+{
+       gint f_type = 0;
+
+       switch (type) {
+       case SIM_FACILITY_PS:
+               f_type = 1;
+       break;
+
+       case SIM_FACILITY_SC:
+               f_type = 3;
+       break;
+
+       case SIM_FACILITY_FD:
+               f_type = 4;
+       break;
+
+       case SIM_FACILITY_PN:
+               f_type = 5;
+       break;
+
+       case SIM_FACILITY_PU:
+               f_type = 6;
+       break;
+
+       case SIM_FACILITY_PP:
+               f_type = 7;
+       break;
+
+       case SIM_FACILITY_PC:
+               f_type = 8;
+       break;
+
+       default:
+               err("Unhandled/Unknown Facility type: [0x%x]", type);
+       break;
+       }
+
+       return f_type;
+}
+
 static gboolean on_sim_get_init_status(TelephonySim *sim,
        GDBusMethodInvocation *invocation, gpointer user_data)
 {
@@ -460,7 +501,7 @@ static gboolean on_sim_get_imsi(TelephonySim *sim,
                FAIL_RESPONSE(invocation, DBUS_SIM_RESPONSE_DATA_ERROR);
        } else {
                dbg("[%s] IMSI - PLMN: [%s] MSIN: [%cX%cX%cX%cX%cX]", GET_CP_NAME(invocation),
-                       imsi->plmn, imsi->msin[0],imsi->msin[2],imsi->msin[4],imsi->msin[6],imsi->msin[8]);
+                       imsi->plmn, imsi->msin[0], imsi->msin[2], imsi->msin[4], imsi->msin[6], imsi->msin[8]);
 
                telephony_sim_complete_get_imsi(sim,
                        invocation, imsi->plmn, imsi->msin);
@@ -661,7 +702,7 @@ static gboolean on_sim_set_call_forwarding(TelephonySim *sim,
                req.cf.cfu_status = cfu_status;
                req.cf.ton = ton;
                req.cf.npi = npi;
-               memcpy(&req.cf.cfu_num, number, (strlen(number) <= SIM_XDN_NUMBER_LEN_MAX ? strlen(number): SIM_XDN_NUMBER_LEN_MAX));
+               memcpy(&req.cf.cfu_num, number, (strlen(number) <= SIM_XDN_NUMBER_LEN_MAX ? strlen(number) : SIM_XDN_NUMBER_LEN_MAX));
                req.cf.cc2_id = cc2_id;
                req.cf.ext7_id = ext7_id;
 
@@ -813,11 +854,11 @@ static gboolean on_sim_set_mailbox(TelephonySim *sim,
        req.mb_info.profile_number = profile_number;
        req.mb_info.number_info.alpha_id_max_len = alpha_id_max_len;
        if (strlen(alpha_id))
-               memcpy(&req.mb_info.number_info.alpha_id, alpha_id, (strlen(alpha_id) <= SIM_XDN_ALPHA_ID_LEN_MAX ? strlen(alpha_id): SIM_XDN_ALPHA_ID_LEN_MAX));
+               memcpy(&req.mb_info.number_info.alpha_id, alpha_id, (strlen(alpha_id) <= SIM_XDN_ALPHA_ID_LEN_MAX ? strlen(alpha_id) : SIM_XDN_ALPHA_ID_LEN_MAX));
        req.mb_info.number_info.ton = ton;
        req.mb_info.number_info.npi = npi;
        if (strlen(number))
-               memcpy(&req.mb_info.number_info.num, number, (strlen(number) <= SIM_XDN_NUMBER_LEN_MAX ? strlen(number): SIM_XDN_NUMBER_LEN_MAX));
+               memcpy(&req.mb_info.number_info.num, number, (strlen(number) <= SIM_XDN_NUMBER_LEN_MAX ? strlen(number) : SIM_XDN_NUMBER_LEN_MAX));
        req.mb_info.number_info.cc_id = cc_id;
        req.mb_info.number_info.ext1_id = ext1_id;
 
@@ -1210,7 +1251,7 @@ static gboolean on_sim_verify_sec(TelephonySim *sim,
        memset(&req, 0x0, sizeof(struct treq_sim_verify_pins));
 
        req.pin_type = pin_type;
-       req.pin_length = (strlen(pin) <= SIM_PIN_LEN_MAX)? strlen(pin): SIM_PIN_LEN_MAX;
+       req.pin_length = (strlen(pin) <= SIM_PIN_LEN_MAX) ? strlen(pin) : SIM_PIN_LEN_MAX;
        memcpy(req.pin, pin, req.pin_length);
 
        dbg("[%s] PIN - type: [0x%02x] len: [%d]",
@@ -1241,9 +1282,9 @@ static gboolean on_sim_verify_puk(TelephonySim *sim,
        memset(&req, 0x0, sizeof(struct treq_sim_verify_puks));
 
        req.puk_type = puk_type;
-       req.puk_length = (strlen(puk) <= SIM_PIN_LEN_MAX)?strlen(puk):SIM_PIN_LEN_MAX;
+       req.puk_length = (strlen(puk) <= SIM_PIN_LEN_MAX) ? strlen(puk) : SIM_PIN_LEN_MAX;
        memcpy(req.puk, puk, req.puk_length);
-       req.pin_length = (strlen(new_pin) <= SIM_PIN_LEN_MAX)?strlen(new_pin):SIM_PIN_LEN_MAX;
+       req.pin_length = (strlen(new_pin) <= SIM_PIN_LEN_MAX) ? strlen(new_pin) : SIM_PIN_LEN_MAX;
        memcpy(req.pin, new_pin, req.pin_length);
 
        dbg("[%s] PUK - type: [0x%02x] len: [%d] PIN len: [%d]",
@@ -1274,9 +1315,9 @@ static gboolean on_sim_change_pin(TelephonySim *sim,
        memset(&req, 0x0, sizeof(struct treq_sim_change_pins));
 
        req.type = pin_type;
-       req.old_pin_length = (strlen(old_pin) <= SIM_PIN_LEN_MAX) ? strlen(old_pin): SIM_PIN_LEN_MAX;
+       req.old_pin_length = (strlen(old_pin) <= SIM_PIN_LEN_MAX) ? strlen(old_pin) : SIM_PIN_LEN_MAX;
        memcpy(req.old_pin, old_pin, req.old_pin_length);
-       req.new_pin_length = (strlen(new_pin) <= SIM_PIN_LEN_MAX)? strlen(new_pin): SIM_PIN_LEN_MAX;
+       req.new_pin_length = (strlen(new_pin) <= SIM_PIN_LEN_MAX) ? strlen(new_pin) : SIM_PIN_LEN_MAX;
        memcpy(req.new_pin, new_pin, req.new_pin_length);
 
        dbg("[%s] PIN - type: [0x%02x] Old PIN len: [%d] New PIN len: [%d]",
@@ -1343,7 +1384,7 @@ static gboolean on_sim_disable_facility(TelephonySim *sim,
                return TRUE;
        }
 
-       req.password_length = (strlen(password) <= SIM_FACILITY_PW_LEN_MAX) ? strlen(password): SIM_FACILITY_PW_LEN_MAX;
+       req.password_length = (strlen(password) <= SIM_FACILITY_PW_LEN_MAX) ? strlen(password) : SIM_FACILITY_PW_LEN_MAX;
        memcpy(req.password, password, req.password_length);
 
        dbg("[%s] Facility - type: [0x%02x] Passowrd len: [%d]",
@@ -1411,7 +1452,7 @@ static gboolean on_sim_enable_facility(TelephonySim *sim, GDBusMethodInvocation
                return TRUE;
        }
 
-       req.password_length = (strlen(password) <= SIM_FACILITY_PW_LEN_MAX) ? strlen(password): SIM_FACILITY_PW_LEN_MAX;
+       req.password_length = (strlen(password) <= SIM_FACILITY_PW_LEN_MAX) ? strlen(password) : SIM_FACILITY_PW_LEN_MAX;
        memcpy(req.password, password, req.password_length);
 
        dbg("[%s] Facility - type: [0x%02x] Passowrd len: [%d]",
@@ -1606,7 +1647,7 @@ static gboolean on_sim_access_rsim_io(TelephonySim *sim,
 
        memset(&req, 0x0, sizeof(struct treq_sim_access_rsim_io));
        req.field = field;
-       req.rec_index= rec_index;
+       req.rec_index = rec_index;
 
        inner_gv = g_variant_get_variant(rsimio);
 
@@ -2736,39 +2777,7 @@ gboolean dbus_plugin_sim_response(struct custom_data *ctx,
                        cpname, (resp_dis_facility->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"),
                        resp_dis_facility->type, resp_dis_facility->retry_count);
 
-               switch (resp_dis_facility->type) {
-               case SIM_FACILITY_PS:
-                       f_type = 1;
-               break;
-
-               case SIM_FACILITY_SC:
-                       f_type = 3;
-               break;
-
-               case SIM_FACILITY_FD:
-                       f_type = 4;
-               break;
-
-               case SIM_FACILITY_PN:
-                       f_type = 5;
-               break;
-
-               case SIM_FACILITY_PU:
-                       f_type = 6;
-               break;
-
-               case SIM_FACILITY_PP:
-                       f_type = 7;
-               break;
-
-               case SIM_FACILITY_PC:
-                       f_type = 8;
-               break;
-
-               default:
-                       err("Unhandled/Unknown Facility type: [0x%x]", resp_dis_facility->type);
-               break;
-               }
+               f_type = __convert_sim_facility_type(resp_dis_facility->type);
 
                telephony_sim_complete_disable_facility(dbus_info->interface_object,
                        dbus_info->invocation, resp_dis_facility->result,
@@ -2784,39 +2793,7 @@ gboolean dbus_plugin_sim_response(struct custom_data *ctx,
                        cpname, (resp_en_facility->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"),
                        resp_en_facility->type, resp_en_facility->retry_count);
 
-               switch (resp_en_facility->type) {
-               case SIM_FACILITY_PS:
-                       f_type = 1;
-               break;
-
-               case SIM_FACILITY_SC:
-                       f_type = 3;
-               break;
-
-               case SIM_FACILITY_FD:
-                       f_type = 4;
-               break;
-
-               case SIM_FACILITY_PN:
-                       f_type = 5;
-               break;
-
-               case SIM_FACILITY_PU:
-                       f_type = 6;
-               break;
-
-               case SIM_FACILITY_PP:
-                       f_type = 7;
-               break;
-
-               case SIM_FACILITY_PC:
-                       f_type = 8;
-               break;
-
-               default:
-                       err("Unhandled/Unknown Facility type: [0x%x]", resp_en_facility->type);
-               break;
-               }
+               f_type = __convert_sim_facility_type(resp_en_facility->type);
 
                telephony_sim_complete_enable_facility(dbus_info->interface_object,
                        dbus_info->invocation, resp_en_facility->result,
@@ -2833,39 +2810,7 @@ gboolean dbus_plugin_sim_response(struct custom_data *ctx,
                        resp_get_facility->type,
                        (resp_get_facility->b_enable ? "Yes" : "No"));
 
-               switch (resp_get_facility->type) {
-               case SIM_FACILITY_PS:
-                       f_type = 1;
-               break;
-
-               case SIM_FACILITY_SC:
-                       f_type = 3;
-               break;
-
-               case SIM_FACILITY_FD:
-                       f_type = 4;
-               break;
-
-               case SIM_FACILITY_PN:
-                       f_type = 5;
-               break;
-
-               case SIM_FACILITY_PU:
-                       f_type = 6;
-               break;
-
-               case SIM_FACILITY_PP:
-                       f_type = 7;
-               break;
-
-               case SIM_FACILITY_PC:
-                       f_type = 8;
-               break;
-
-               default:
-                       err("Unhandled/Unknown Facility type: [0x%x]", resp_get_facility->type);
-               break;
-               }
+               f_type = __convert_sim_facility_type(resp_get_facility->type);
 
                telephony_sim_complete_get_facility(dbus_info->interface_object,
                        dbus_info->invocation, resp_get_facility->result,
@@ -2881,39 +2826,7 @@ gboolean dbus_plugin_sim_response(struct custom_data *ctx,
                        cpname, (resp_lock->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"),
                        resp_lock->type, resp_lock->retry_count);
 
-               switch (resp_lock->type) {
-               case SIM_FACILITY_PS:
-                       f_type = 1;
-               break;
-
-               case SIM_FACILITY_SC:
-                       f_type = 3;
-               break;
-
-               case SIM_FACILITY_FD:
-                       f_type = 4;
-               break;
-
-               case SIM_FACILITY_PN:
-                       f_type = 5;
-               break;
-
-               case SIM_FACILITY_PU:
-                       f_type = 6;
-               break;
-
-               case SIM_FACILITY_PP:
-                       f_type = 7;
-               break;
-
-               case SIM_FACILITY_PC:
-                       f_type = 8;
-               break;
-
-               default:
-                       err("Unhandled/Unknown Lock type: [0x%x]", resp_lock->type);
-               break;
-               }
+               f_type = __convert_sim_facility_type(resp_lock->type);
 
                telephony_sim_complete_get_lock_info(dbus_info->interface_object,
                        dbus_info->invocation, resp_lock->result,