add APIs for getting SIM init status and importing SIM contacts by sim slot no 25/69225/10 accepted/tizen/common/20160530.132116 accepted/tizen/ivi/20160602.022407 accepted/tizen/mobile/20160602.022435 accepted/tizen/wearable/20160602.022339 submit/tizen/20160530.064520
authorJongkyu Koo <jk.koo@samsung.com>
Thu, 12 May 2016 07:55:44 +0000 (16:55 +0900)
committerJongkyu Koo <jk.koo@samsung.com>
Thu, 26 May 2016 04:41:02 +0000 (13:41 +0900)
Change-Id: I05b63f6d76782229ad98122f45a6e36af1d368ff
Signed-off-by: Jongkyu Koo <jk.koo@samsung.com>
client/CMakeLists.txt
common/ctsvc_sim.c
include/mobile/contacts_sim.h [new file with mode: 0644]
include/wearable/contacts_sim.h [moved from include/contacts_sim.h with 85% similarity]
packaging/contacts-service.spec
server/CMakeLists.txt
server/ctsvc_server_sim.c
test/CMakeLists.txt

index c98cc5d..f07f3a4 100644 (file)
@@ -1,4 +1,10 @@
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+IF (TIZEN_WEARABLE)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/wearable)
+ENDIF (TIZEN_WEARABLE)
+IF (TIZEN_MOBILE)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/mobile)
+ENDIF (TIZEN_MOBILE)
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/client)
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common)
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common/ipc)
@@ -110,7 +116,12 @@ INSTALL(TARGETS ${CLIENT} DESTINATION ${LIB_INSTALL_DIR})
 
 # Install header file
 SET(DEST_INCLUDE_DIR "${INCLUDE_INSTALL_DIR}/contacts-svc")
-FILE(GLOB HEADER_FILES ${CMAKE_SOURCE_DIR}/include/*.h)
+IF (TIZEN_WEARABLE)
+FILE(GLOB HEADER_FILES ${CMAKE_SOURCE_DIR}/include/*.h ${CMAKE_SOURCE_DIR}/include/wearable/*.h)
+ENDIF (TIZEN_WEARABLE)
+IF (TIZEN_MOBILE)
+FILE(GLOB HEADER_FILES ${CMAKE_SOURCE_DIR}/include/*.h ${CMAKE_SOURCE_DIR}/include/mobile/*.h)
+ENDIF (TIZEN_MOBILE)
 INSTALL(FILES ${HEADER_FILES} DESTINATION ${DEST_INCLUDE_DIR})
 
 CONFIGURE_FILE(${CLIENT}.pc.in ${CLIENT}.pc @ONLY)
index ba07bea..bdb3165 100644 (file)
@@ -46,3 +46,30 @@ API int contacts_sim_get_initialization_status(bool *completed)
        return ret;
 }
 
+API int contacts_sim_import_all_contacts_by_sim_slot_no(int sim_slot_no)
+{
+       int ret;
+
+       RETV_IF(sim_slot_no < 0, CONTACTS_ERROR_INVALID_PARAMETER);
+
+       ctsvc_mutex_lock(CTS_MUTEX_SOCKET_FD);
+       ret = ctsvc_request_sim_import(sim_slot_no);
+       ctsvc_mutex_unlock(CTS_MUTEX_SOCKET_FD);
+
+       return ret;
+}
+
+API int contacts_sim_get_initialization_status_by_sim_slot_no(int sim_slot_no, bool *completed)
+{
+       int ret;
+
+       RETV_IF(NULL == completed, CONTACTS_ERROR_INVALID_PARAMETER);
+       RETV_IF(sim_slot_no < 0, CONTACTS_ERROR_INVALID_PARAMETER);
+
+       ctsvc_mutex_lock(CTS_MUTEX_SOCKET_FD);
+       ret = ctsvc_request_sim_get_initialization_status(sim_slot_no, completed);
+       ctsvc_mutex_unlock(CTS_MUTEX_SOCKET_FD);
+
+       return ret;
+}
+
diff --git a/include/mobile/contacts_sim.h b/include/mobile/contacts_sim.h
new file mode 100644 (file)
index 0000000..b039acd
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2010 - 2015 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.
+ *
+ */
+#ifndef __TIZEN_SOCIAL_CONTACTS_SIM_H__
+#define __TIZEN_SOCIAL_CONTACTS_SIM_H__
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @file contacts_sim.h
+ */
+
+/**
+ * @ingroup CAPI_SOCIAL_CONTACTS_SVC_MODULE
+ * @defgroup CAPI_SOCIAL_CONTACTS_SVC_SIM_MODULE SIM
+ *
+ * @brief The contacts SIM API provides the set of definitions and interfaces that enable application developers to get/set data from/to SIM card.
+ *
+ * @section CAPI_SOCIAL_CONTACTS_SVC_SIM_MODULE_HEADER Required Header
+ *  \#include <contacts.h>
+ *
+ * @section CAPI_SOCIAL_CONTACTS_SVC_SIM_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ *  - http://tizen.org/feature/network.telephony\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
+ * <BR>
+ * @{
+ */
+
+/**
+ * @deprecated Deprecated since 3.0. Use contacts_sim_import_all_contacts_by_sim_slot_no() instead.
+ * @brief Imports all contacts from first SIM to Contacts Database.
+ *
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/contact.write
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval  #CONTACTS_ERROR_NONE                Successful
+ * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @retval  #CONTACTS_ERROR_NO_DATA             Requested data does not exist
+ * @retval  #CONTACTS_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
+ * @retval  #CONTACTS_ERROR_NOT_SUPPORTED       Not supported
+ * @retval  #CONTACTS_ERROR_IPC                 Unknown IPC error
+ * @retval  #CONTACTS_ERROR_SYSTEM              Internal system module error
+ * @retval  #CONTACTS_ERROR_INTERNAL            Implementation Error, Temporary Use
+ *
+ * @pre     contacts_connect() should be called to open a connection to the contacts service.
+ *
+ * @see  contacts_connect()
+ */
+int contacts_sim_import_all_contacts(void);
+
+
+/**
+ * @deprecated Deprecated since 3.0. Use contacts_sim_get_initialization_status_by_sim_slot_no() instead.
+ * @brief Checks whether first SIM initialization is completed.
+ *
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/contact.read
+ *
+ * @param[out]  completed    @c true if SIM is initialized,
+ *                           otherwise @c false if SIM is not initialized
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval  #CONTACTS_ERROR_NONE                Successful
+ * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @retval  #CONTACTS_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
+ * @retval  #CONTACTS_ERROR_NOT_SUPPORTED       Not supported
+ * @retval  #CONTACTS_ERROR_IPC                 Unknown IPC error
+ * @retval  #CONTACTS_ERROR_SYSTEM              Internal system module error
+ *
+ * @pre     contacts_connect() should be called to open a connection to the contacts service.
+ *
+ * @see  contacts_connect()
+ */
+int contacts_sim_get_initialization_status(bool *completed);
+
+/**
+ * @brief Imports all contacts from SIM of the given SIM slot number to Contacts Database.
+ *
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/contact.write
+ *
+ * @param[in]   sim_slot_no       It is related to the SIM slot number. sim_slot_no 0 means first SIM, sim_slot_no 1 means second SIM
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval  #CONTACTS_ERROR_NONE                Successful
+ * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @retval  #CONTACTS_ERROR_NO_DATA             Requested data does not exist
+ * @retval  #CONTACTS_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
+ * @retval  #CONTACTS_ERROR_NOT_SUPPORTED       Not supported
+ * @retval  #CONTACTS_ERROR_IPC                 Unknown IPC error
+ * @retval  #CONTACTS_ERROR_SYSTEM              Internal system module error
+ *
+ * @pre     contacts_connect() should be called to open a connection to the contacts service.
+ *
+ * @see  contacts_connect()
+ */
+int contacts_sim_import_all_contacts_by_sim_slot_no(int sim_slot_no);
+
+
+/**
+ * @brief Checks whether SIM of the given SIM slot number is initialized.
+ *
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/contact.read
+ *
+ * @param[in]   sim_slot_no       It is related to the SIM slot number. sim_slot_no 0 means first SIM, sim_slot_no 1 means second SIM
+ * @param[out]  completed    @c true if SIM is initialized,
+ *                           otherwise @c false if SIM is not initialized
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval  #CONTACTS_ERROR_NONE                Successful
+ * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @retval  #CONTACTS_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
+ * @retval  #CONTACTS_ERROR_NOT_SUPPORTED       Not supported
+ * @retval  #CONTACTS_ERROR_IPC                 Unknown IPC error
+ * @retval  #CONTACTS_ERROR_SYSTEM              Internal system module error
+ *
+ * @pre     contacts_connect() should be called to open a connection to the contacts service.
+ *
+ * @see  contacts_connect()
+ */
+int contacts_sim_get_initialization_status_by_sim_slot_no(int sim_slot_no, bool *completed);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_SIM_H__ */
+
similarity index 85%
rename from include/contacts_sim.h
rename to include/wearable/contacts_sim.h
index 38f6c19..49f6983 100644 (file)
@@ -54,12 +54,14 @@ extern "C"
  */
 
 /**
- * @brief Imports all contacts from SIM to Contacts Database.
+ * @brief Imports all contacts from SIM of the given SIM slot number to Contacts Database.
  *
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
+ * @since_tizen 3.0
  * @privlevel public
  * @privilege %http://tizen.org/privilege/contact.write
  *
+ * @param[in]   sim_slot_no       It is related to the SIM slot number. sim_slot_no 0 means first SIM, sim_slot_no 1 means second SIM
+ *
  * @return  @c 0 on success,
  *          otherwise a negative error value
  *
@@ -70,22 +72,22 @@ extern "C"
  * @retval  #CONTACTS_ERROR_NOT_SUPPORTED       Not supported
  * @retval  #CONTACTS_ERROR_IPC                 Unknown IPC error
  * @retval  #CONTACTS_ERROR_SYSTEM              Internal system module error
- * @retval  #CONTACTS_ERROR_INTERNAL            Implementation Error, Temporary Use
  *
  * @pre     contacts_connect() should be called to open a connection to the contacts service.
  *
  * @see  contacts_connect()
  */
-int contacts_sim_import_all_contacts(void);
+int contacts_sim_import_all_contacts_by_sim_slot_no(int sim_slot_no);
 
 
 /**
- * @brief Checks whether SIM initialization is completed.
+ * @brief Checks whether SIM of the given SIM slot number is initialized.
  *
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
+ * @since_tizen 3.0
  * @privlevel public
  * @privilege %http://tizen.org/privilege/contact.read
  *
+ * @param[in]   sim_slot_no       It is related to the SIM slot number. sim_slot_no 0 means first SIM, sim_slot_no 1 means second SIM
  * @param[out]  completed    @c true if SIM is initialized,
  *                           otherwise @c false if SIM is not initialized
  *
@@ -103,7 +105,7 @@ int contacts_sim_import_all_contacts(void);
  *
  * @see  contacts_connect()
  */
-int contacts_sim_get_initialization_status(bool *completed);
+int contacts_sim_get_initialization_status_by_sim_slot_no(int sim_slot_no, bool *completed);
 
 /**
  * @}
index c7b671b..435c958 100644 (file)
@@ -1,6 +1,6 @@
 Name:       contacts-service
 Summary:    Contacts Service
-Version:    0.13.53
+Version:    0.13.54
 Release:    0
 Group:      Social & Content/Service
 License:    Apache-2.0
@@ -72,7 +72,12 @@ export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
 
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 %cmake . -DCMAKE_VERBOSE_MAKEFILE=OFF -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DBIN_INSTALL_DIR:PATH=%{_bindir} \
-               -DTZ_SYS_ETC=%TZ_SYS_ETC -DENABLE_LOG_FEATURE:BOOL=ON
+               -DTZ_SYS_ETC=%TZ_SYS_ETC -DENABLE_LOG_FEATURE:BOOL=ON \
+%if "%{profile}" == "wearable"
+               -DTIZEN_WEARABLE=YES
+%else
+               -DTIZEN_MOBILE=YES
+%endif
 
 %__make %{?_smp_mflags}
 
index 5652cb6..f476f01 100644 (file)
@@ -1,4 +1,10 @@
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+IF (TIZEN_WEARABLE)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/wearable)
+ENDIF (TIZEN_WEARABLE)
+IF (TIZEN_MOBILE)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/mobile)
+ENDIF (TIZEN_MOBILE)
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/server)
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/server/db)
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common)
index 3b39647..e3a140a 100644 (file)
@@ -520,13 +520,16 @@ static void __ctsvc_server_sim_import_contact_cb(TapiHandle *handle, int result,
 int ctsvc_server_sim_import_contact(void *data, int sim_slot_no)
 {
        CTS_FN_CALL;
-       int ret;
+       int ret = TAPI_API_SUCCESS;
        ctsvc_sim_info_s *info;
+       unsigned int sim_slot_cnt = g_slist_length(__ctsvc_sim_info);
+
+       RETV_IF(sim_slot_cnt <= sim_slot_no, CONTACTS_ERROR_INVALID_PARAMETER);
 
        info = __ctsvc_server_sim_get_info_by_sim_slot_no(sim_slot_no);
        RETV_IF(NULL == info, CONTACTS_ERROR_SYSTEM);
-       RETV_IF(false == info->initialized, CONTACTS_ERROR_SYSTEM);
-       RETVM_IF(__ctsvc_server_sim_get_return_data(), CONTACTS_ERROR_INTERNAL,
+       RETV_IF(false == info->initialized, CONTACTS_ERROR_NO_DATA);
+       RETVM_IF(__ctsvc_server_sim_get_return_data(), CONTACTS_ERROR_SYSTEM,
                        "Server is already processing with sim");
 
        __ctsvc_server_sim_set_return_data(data);
@@ -553,6 +556,9 @@ int ctsvc_server_socket_get_sim_init_status(void *data, int sim_slot_no)
 {
        CTS_FN_CALL;
        ctsvc_sim_info_s *info;
+       unsigned int sim_slot_cnt = g_slist_length(__ctsvc_sim_info);
+
+       RETV_IF(sim_slot_cnt <= sim_slot_no, CONTACTS_ERROR_INVALID_PARAMETER);
 
        info = __ctsvc_server_sim_get_info_by_sim_slot_no(sim_slot_no);
        RETVM_IF(NULL == info, CONTACTS_ERROR_SYSTEM, "sim init is not completed");
index 51112a7..6709414 100644 (file)
@@ -2,6 +2,12 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(contacts-service-test C CXX)
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+IF (TIZEN_WEARABLE)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/wearable)
+ENDIF (TIZEN_WEARABLE)
+IF (TIZEN_MOBILE)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/mobile)
+ENDIF (TIZEN_MOBILE)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
 LINK_DIRECTORIES(${CMAKE_SOURCE_DIR})