From d20dac2d9c934da251b87e766127df355972a5b8 Mon Sep 17 00:00:00 2001 From: Kim Kibum Date: Sun, 29 Apr 2012 16:58:32 +0900 Subject: [PATCH] upload tizen1.0 source --- CMakeLists.txt | 4 +- capi-telephony-sim.pc.in | 3 +- debian/changelog | 18 +++++- debian/control | 6 +- include/sim.h | 36 ++++++++++++ packaging/capi-telephony-sim.spec | 10 ++-- src/sim.c | 103 +++++++++++++++++++++++++++++++++ test/sim_get_cphs_operator_name_test.c | 79 +++++++++++++++++++++++++ test/sim_get_msin_test.c | 64 ++++++++++++++++++++ 9 files changed, 310 insertions(+), 13 deletions(-) create mode 100644 test/sim_get_cphs_operator_name_test.c create mode 100644 test/sim_get_msin_test.c diff --git a/CMakeLists.txt b/CMakeLists.txt index ecb1bcf..9e42ac5 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ SET(description "Telephony SIM Framework") SET(service "telephony") SET(submodule "sim") SET(dependents "dlog tapi glib-2.0 vconf capi-base-common") +SET(pc_dependents "capi-base-common") SET(deb_dependents "dlog-dev libslp-tapi-dev libglib2.0-dev libvconf-dev capi-base-common-dev") SET(Services @@ -93,9 +94,8 @@ INSTALL( ) SET(PC_NAME ${fw_name}) -SET(PC_REQUIRED ${dependents}) +SET(PC_REQUIRED ${pc_dependents}) SET(PC_LDFLAGS -l${fw_name}) -SET(PC_CFLAGS -I\${includedir}/${service}) CONFIGURE_FILE( capi-telephony-sim.pc.in diff --git a/capi-telephony-sim.pc.in b/capi-telephony-sim.pc.in index 9b898b7..8731238 100644 --- a/capi-telephony-sim.pc.in +++ b/capi-telephony-sim.pc.in @@ -11,5 +11,4 @@ Description: @PACKAGE_DESCRIPTION@ Version: @VERSION@ Requires: @PC_REQUIRED@ Libs: -L${libdir} @PC_LDFLAGS@ -Cflags: -I${includedir} @PC_CFLAGS@ - +Cflags: -I${includedir} diff --git a/debian/changelog b/debian/changelog index 25a182c..5ab3d50 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,23 @@ +capi-telephony-sim (0.1.0-12) unstable; urgency=low + + * Correct dependent packages + * Git: api/sim + * Tag: capi-telephony-sim_0.1.0-12 + + -- ByungWoo Lee Thu, 15 Mar 2012 13:32:00 +0900 + +capi-telephony-sim (0.1.0-11) unstable; urgency=low + + * Add new APIs(sim_get_msin, sim_get_cphs_operator_name),related TCs and test code + * Git: api/sim + * Tag: capi-telephony-sim_0.1.0-11 + + -- Kyeongchul Kim Wed, 07 Mar 2012 13:54:07 +0900 + capi-telephony-sim (0.1.0-10) unstable; urgency=low * Convert internal symbol to static - * Git: slp/api/sim + * Git: api/sim * Tag: capi-telephony-sim_0.1.0-10 -- ByungWoo Lee Mon, 20 Feb 2012 15:54:30 +0900 diff --git a/debian/control b/debian/control index 044074a..245f421 100644 --- a/debian/control +++ b/debian/control @@ -2,17 +2,17 @@ Source: capi-telephony-sim Section: libs Priority: extra -Maintainer: Kangho Hur , ByungWoo Lee +Maintainer: Kangho Hur , ByungWoo Lee , kyeongchul.kim , JaYoung Gu Build-Depends: debhelper (>= 5), dlog-dev, libslp-tapi-dev, libglib2.0-dev, libvconf-dev, capi-base-common-dev Package: capi-telephony-sim Architecture: any -Depends: ${shilbs:Depends}, ${misc:Depends} +Depends: ${shlibs:Depends}, ${misc:Depends} Description: A Telephony SIM library in Tizen Natvie API Package: capi-telephony-sim-dev Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, capi-telephony-sim (= ${Source-Version}), dlog-dev, libslp-tapi-dev, libglib2.0-dev, libvconf-dev, capi-base-common-dev +Depends: ${shlibs:Depends}, ${misc:Depends}, capi-telephony-sim (= ${Source-Version}), capi-base-common-dev Description: A Telephony SIM library in Tizen Natvie API (DEV) Package: capi-telephony-sim-dbg diff --git a/include/sim.h b/include/sim.h index 7bce0d2..575ad2c 100755 --- a/include/sim.h +++ b/include/sim.h @@ -119,6 +119,24 @@ int sim_get_mcc(char **mcc); int sim_get_mnc(char **mnc); /** + * @brief Gets the Mobile Subscription Identification Number (MSIN) of SIM provider. + * @details This function gets Mobile Subscription Identification Number embedded in SIM card. + * + * @remarks @c msin must be released with free() by you. + * @param[out] msin The Mobile Subscription Identification Number + * @return 0 on success, otherwise a negative error value. + * @retval #SIM_ERROR_NONE Successful + * @retval #SIM_ERROR_OUT_OF_MEMORY Out of memory + * @retval #SIM_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SIM_ERROR_OPERATION_FAILED Operation failed + * @retval #SIM_ERROR_NOT_AVAILABLE SIM is not available + * @pre The SIM state must be #SIM_STATE_AVAILABLE. + * @see sim_get_state() + * + */ +int sim_get_msin(char **msin); + +/** * @brief Gets the Service Provider Name (SPN) of SIM card. * @details This function gets Service Provider Name embedded in SIM card. * If this value is not stored in SIM card, NULL will be returned. @@ -136,6 +154,24 @@ int sim_get_mnc(char **mnc); int sim_get_spn(char **spn); /** + * @brief Gets the Operator Name String (ONS) of Common PCN Handset Specification (CPHS) in SIM card. + * @details This function gets the full name and the short name of CPHS operator embedded in SIM card. + * If this value is not stored in SIM card, NULL will be returned. + * @remarks @c full_name and @c short_name must be released with free() by you. + * @param[out] full_name The full name of CPHS operator + * @param[out] short_name The short name of CPHS operator + * @return 0 on success, otherwise a negative error value. + * @retval #SIM_ERROR_NONE Successful + * @retval #SIM_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SIM_ERROR_OPERATION_FAILED Operation failed + * @retval #SIM_ERROR_NOT_AVAILABLE SIM is not available + * @pre The SIM state must be #SIM_STATE_AVAILABLE. + * @see sim_get_state() + * + */ +int sim_get_cphs_operator_name(char** full_name, char** short_name); + +/** * @brief Gets the state of SIM. * * @param[out] sim_state The current state of SIM diff --git a/packaging/capi-telephony-sim.spec b/packaging/capi-telephony-sim.spec index 122c33c..536f1d6 100644 --- a/packaging/capi-telephony-sim.spec +++ b/packaging/capi-telephony-sim.spec @@ -1,7 +1,7 @@ Name: capi-telephony-sim Summary: Telephony SIM Framework Version: 0.1.0 -Release: 1 +Release: 12 Group: TO_BE/FILLED_IN License: Apache-2.0 Source0: %{name}-%{version}.tar.gz @@ -31,9 +31,8 @@ Requires: %{name} = %{version}-%{release} %build -FULLVER=%{version} -MAJORVER=`echo ${FULLVER} | cut -d '.' -f 1` -cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=${FULLVER} -DMAJORVER=${MAJORVER} +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` +cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} make %{?jobs:-j%jobs} @@ -48,10 +47,11 @@ rm -rf %{buildroot} %files -%{_libdir}/libcapi-telephony-sim.so* +%{_libdir}/libcapi-telephony-sim.so.* %files devel %{_includedir}/telephony/sim.h %{_libdir}/pkgconfig/*.pc +%{_libdir}/libcapi-telephony-sim.so diff --git a/src/sim.c b/src/sim.c index 23263c3..fb24a09 100644 --- a/src/sim.c +++ b/src/sim.c @@ -191,6 +191,49 @@ int sim_get_mnc(char** mnc) } +int sim_get_msin(char** msin) +{ + TelSimImsiInfo_t sim_imsi_info; + int error_code = SIM_ERROR_NONE; + int card_changed = 0; + TelSimCardStatus_t sim_card_state = 0x00; + + SIM_CHECK_INPUT_PARAMETER(msin); + SIM_INIT(); + + if( tel_get_sim_init_info(&sim_card_state, &card_changed) != 0 + || sim_card_state != TAPI_SIM_STATUS_SIM_INIT_COMPLETED ) + { + LOGE("[%s] NOT_AVAILABLE(0x%08x)", __FUNCTION__, SIM_ERROR_NOT_AVAILABLE); + error_code = SIM_ERROR_NOT_AVAILABLE; + } + else + { + if( tel_get_sim_imsi(&sim_imsi_info) != 0 ) + { + LOGE("[%s] OPERATION_FAILED(0x%08x)", __FUNCTION__, SIM_ERROR_OPERATION_FAILED); + error_code = SIM_ERROR_OPERATION_FAILED; + } + else + { + *msin = (char*)malloc(sizeof(char) * (TAPI_SIM_MSIN_CODE_LEN+1)); + if( *msin == NULL ) + { + LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, SIM_ERROR_OUT_OF_MEMORY); + error_code = SIM_ERROR_OUT_OF_MEMORY; + } + else + { + strncpy(*msin, sim_imsi_info.szMsin, TAPI_SIM_MSIN_CODE_LEN+1); + } + } + } + + tel_deinit(); + return error_code; +} + + int sim_get_spn(char** spn) { int error_code = SIM_ERROR_NONE; @@ -232,6 +275,66 @@ int sim_get_spn(char** spn) } +int sim_get_cphs_operator_name(char** full_name, char** short_name) +{ + TelSimCphsLocalInfo_t cphs_info; + int error_code = SIM_ERROR_NONE; + int card_changed = 0; + TelSimCardStatus_t sim_card_state = 0x00; + + SIM_CHECK_INPUT_PARAMETER(full_name); + SIM_CHECK_INPUT_PARAMETER(short_name); + SIM_INIT(); + + if( tel_get_sim_init_info(&sim_card_state, &card_changed) != 0 + || sim_card_state != TAPI_SIM_STATUS_SIM_INIT_COMPLETED ) + { + LOGE("[%s] NOT_AVAILABLE(0x%08x)", __FUNCTION__, SIM_ERROR_NOT_AVAILABLE); + error_code = SIM_ERROR_NOT_AVAILABLE; + } + else + { + if( tel_get_sim_cphs_info(&cphs_info) != 0 ) + { + LOGE("[%s] OPERATION_FAILED(0x%08x)", __FUNCTION__, SIM_ERROR_OPERATION_FAILED); + error_code = SIM_ERROR_OPERATION_FAILED; + } + else + { + if(cphs_info.opname.NameLength) + { + *full_name = strndup((const char*)cphs_info.opname.OperatorName, cphs_info.opname.NameLength); + if(*full_name == NULL) + { + LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, SIM_ERROR_OUT_OF_MEMORY); + error_code = SIM_ERROR_OUT_OF_MEMORY; + } + } + else + { + *full_name = NULL; + } + + if(cphs_info.opshortform.ShortNameLength) + { + *short_name = strndup((const char*)cphs_info.opshortform.OperatorShortName, cphs_info.opshortform.ShortNameLength); + if(*short_name == NULL) + { + LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, SIM_ERROR_OUT_OF_MEMORY); + error_code = SIM_ERROR_OUT_OF_MEMORY; + } + } + else + { + *short_name = NULL; + } + } + } + + tel_deinit(); + return error_code; +} + int sim_get_state(sim_state_e* sim_state) { int card_changed = 0; diff --git a/test/sim_get_cphs_operator_name_test.c b/test/sim_get_cphs_operator_name_test.c new file mode 100644 index 0000000..f5a752c --- /dev/null +++ b/test/sim_get_cphs_operator_name_test.c @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_SIM_TEST" + +int main() +{ + int ret = 0; + char* full_name = NULL; + char* short_name = NULL; + int ret_value = sim_get_cphs_operator_name(&full_name, &short_name); + + switch(ret_value) + { + case SIM_ERROR_NONE: + ret = 0; + if( full_name != NULL ) + { + LOGI("CPHS full ONS is %s", full_name); + free(full_name); + } + else + { + LOGI("CPHS full ONS is NULL"); + } + + if( short_name != NULL ) + { + LOGI("CPHS short ONS is %s", short_name); + free(short_name); + } + else + { + LOGI("CPHS short ONS is NULL"); + } + break; + case SIM_ERROR_INVALID_PARAMETER: + LOGE("Invalid parameter"); + ret = -1; + break; + case SIM_ERROR_OPERATION_FAILED: + LOGE("Cannot find SPN value"); + ret = -1; + break; + case SIM_ERROR_NOT_AVAILABLE: + LOGE("SIM is not available"); + ret = -1; + break; + default: + LOGE("Unexpected return value"); + ret = -1; + break; + } + + + return ret; +} diff --git a/test/sim_get_msin_test.c b/test/sim_get_msin_test.c new file mode 100644 index 0000000..a8530c1 --- /dev/null +++ b/test/sim_get_msin_test.c @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_SIM_TEST" + +int main() +{ + int ret = 0; + char* msin = NULL; + int ret_value = sim_get_msin(&msin); + + switch(ret_value) + { + case SIM_ERROR_NONE: + LOGI("MSIN is %s", msin); + ret = 0; + free(msin); + break; + case SIM_ERROR_OUT_OF_MEMORY: + LOGE("Out of memory"); + ret = -1; + break; + case SIM_ERROR_INVALID_PARAMETER: + LOGE("Invalid parameter"); + ret = -1; + break; + case SIM_ERROR_OPERATION_FAILED: + LOGE("Can not get MNC value"); + ret = -1; + break; + case SIM_ERROR_NOT_AVAILABLE: + LOGE("SIM is not available"); + ret = -1; + break; + default: + LOGE("Unexpected return value"); + ret = -1; + break; + } + + return ret; +} -- 2.7.4