From: Jongkyu Koo Date: Wed, 10 Aug 2016 07:49:28 +0000 (+0900) Subject: add progress callback to the API importing SIM contacts X-Git-Tag: accepted/tizen/common/20160831.161801^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7942052cc9593256862ce387065f090034f5ac00;p=platform%2Fcore%2Fpim%2Fcontacts-service.git add progress callback to the API importing SIM contacts Change-Id: I613c329e4d714a29425b7c96f58c1cc2cedd750f Signed-off-by: Jongkyu Koo --- diff --git a/common/ctsvc_sim.c b/common/ctsvc_sim.c index 3a21edf..cdee3c0 100644 --- a/common/ctsvc_sim.c +++ b/common/ctsvc_sim.c @@ -28,7 +28,7 @@ EXPORT_API int contacts_sim_import_all_contacts() WARN(DEPRECATED_STRING_FORMAT, __FUNCTION__); ctsvc_mutex_lock(CTS_MUTEX_SOCKET_FD); - ret = ctsvc_request_sim_import(0); + ret = ctsvc_request_sim_import(0, NULL, NULL); ctsvc_mutex_unlock(CTS_MUTEX_SOCKET_FD); return ret; @@ -47,14 +47,15 @@ EXPORT_API int contacts_sim_get_initialization_status(bool *completed) return ret; } -EXPORT_API int contacts_sim_import_all_contacts_by_sim_slot_no(int sim_slot_no) +EXPORT_API int contacts_sim_import_all_contacts_by_sim_slot_no(int sim_slot_no, + contacts_sim_import_progress_cb callback, void *user_data) { 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); + ret = ctsvc_request_sim_import(sim_slot_no, callback, user_data); ctsvc_mutex_unlock(CTS_MUTEX_SOCKET_FD); return ret; diff --git a/common/ctsvc_socket.c b/common/ctsvc_socket.c index 3f07578..d837ba9 100644 --- a/common/ctsvc_socket.c +++ b/common/ctsvc_socket.c @@ -134,6 +134,44 @@ static int __ctsvc_socket_handle_return(int fd, ctsvc_socket_msg_s *msg) return CONTACTS_ERROR_NONE; } +static int __ctsvc_client_socket_response_handler(int fd, ctsvc_socket_msg_s *msg, contacts_sim_import_progress_cb callback, void *user_data) +{ + CTS_FN_CALL; + int ret; + + do { + ret = __ctsvc_safe_read(fd, (char *)msg, sizeof(ctsvc_socket_msg_s)); + RETVM_IF(-1 == ret, CONTACTS_ERROR_IPC, "__ctsvc_safe_read() Fail(errno = %d)", errno); + RETVM_IF(CTSVC_SOCKET_MSG_REQUEST_MAX_ATTACH < msg->attach_num, CONTACTS_ERROR_IPC, + "Invalid msg(attach_num = %d)", msg->attach_num); + + switch (msg->type) { + case CTSVC_SOCKET_MSG_TYPE_REQUEST_RETURN_VALUE: + break; + + case CTSVC_SOCKET_MSG_TYPE_REQUEST_INVOKE_CB: + DBG("total[%d], index[%d]", msg->val, msg->data); + if (callback) + callback(msg->val, msg->data, user_data); + else + WARN("No callback"); + break; + + /* LCOV_EXCL_START */ + default: + WARN("Unknown Type(%d), ret=%d, attach_num= %d," + "attach1 = %d, attach2 = %d, attach3 = %d, attach4 = %d", + msg->type, msg->val, msg->attach_num, + msg->attach_sizes[0], msg->attach_sizes[1], msg->attach_sizes[2], + msg->attach_sizes[3]); + break; + /* LCOV_EXCL_STOP */ + } + } while (CTSVC_SOCKET_MSG_TYPE_REQUEST_RETURN_VALUE != msg->type); + + return CONTACTS_ERROR_NONE; +} + static void __ctsvc_remove_invalid_msg(int fd, int size) { int ret; @@ -162,7 +200,8 @@ static void __ctsvc_remove_invalid_msg(int fd, int size) } } -int ctsvc_request_sim_import(int sim_slot_no) +int ctsvc_request_sim_import(int sim_slot_no, contacts_sim_import_progress_cb callback, + void *user_data) { int i, ret; ctsvc_socket_msg_s msg = {0}; @@ -182,7 +221,7 @@ int ctsvc_request_sim_import(int sim_slot_no) ret = __ctsvc_safe_write(__ctsvc_sockfd, src, msg.attach_sizes[0]); RETVM_IF(-1 == ret, CONTACTS_ERROR_IPC, "__ctsvc_safe_write() Fail(errno = %d)", errno); - ret = __ctsvc_socket_handle_return(__ctsvc_sockfd, &msg); + ret = __ctsvc_client_socket_response_handler(__ctsvc_sockfd, &msg, callback, user_data); RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "__ctsvc_socket_handle_return() Fail(%d)", ret); DBG("attach_num = %d", msg.attach_num); diff --git a/common/ctsvc_socket.h b/common/ctsvc_socket.h index d02093a..a4b4fd8 100644 --- a/common/ctsvc_socket.h +++ b/common/ctsvc_socket.h @@ -31,6 +31,7 @@ enum { CTSVC_SOCKET_MSG_TYPE_REQUEST_RETURN_VALUE, CTSVC_SOCKET_MSG_TYPE_REQUEST_IMPORT_SIM, CTSVC_SOCKET_MSG_TYPE_REQUEST_SIM_INIT_COMPLETE, + CTSVC_SOCKET_MSG_TYPE_REQUEST_INVOKE_CB, }; #define CTSVC_SOCKET_MSG_REQUEST_MAX_ATTACH 5 @@ -38,11 +39,13 @@ enum { typedef struct { int type; int val; + int data; int attach_num; int attach_sizes[CTSVC_SOCKET_MSG_REQUEST_MAX_ATTACH]; } ctsvc_socket_msg_s; -int ctsvc_request_sim_import(int sim_slot_no); +int ctsvc_request_sim_import(int sim_slot_no, + contacts_sim_import_progress_cb callback, void *user_data); int ctsvc_request_sim_get_initialization_status(int sim_slot_no, bool *completed); int ctsvc_socket_init(void); void ctsvc_socket_final(void); diff --git a/include/mobile/contacts_sim.h b/include/mobile/contacts_sim.h index 830aa38..becdddf 100644 --- a/include/mobile/contacts_sim.h +++ b/include/mobile/contacts_sim.h @@ -56,7 +56,7 @@ extern "C" /** * @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. + * @brief Imports all contacts from first SIM to the Contacts Database. * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif * @privlevel public @@ -74,7 +74,7 @@ extern "C" * @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. + * @pre contacts_connect() should be called to open a connection to the contacts service. * * @see contacts_connect() */ @@ -102,20 +102,39 @@ int contacts_sim_import_all_contacts(void) TIZEN_DEPRECATED_API; * @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. + * @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) TIZEN_DEPRECATED_API; /** - * @brief Imports all contacts from SIM of the given SIM slot number to Contacts Database. + * @brief Called whenever a contact is imported. + * + * @since_tizen 3.0 + * + * @param[in] total The number of contacts that will be imported + * @param[in] imported_cnt The number of already imported contacts + * @param[in] user_data The user data passed from the callback registration function + * + * @pre contacts_sim_import_all_contacts_by_sim_slot_no() will invoke this callback. + * + * @see contacts_sim_import_all_contacts_by_sim_slot_no() + */ +typedef void (*contacts_sim_import_progress_cb)(int total, int imported_cnt, void *user_data); + +/** + * @brief Imports all contacts from SIM of the given SIM slot number to the Contacts Database. + * + * @details This function invokes contacts_sim_import_progress_cb() to indicate the progress of imports whenever a contact is imported. * * @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 + * @param[in] sim_slot_no The SIM slot number; 0 means first SIM, 1 means second SIM + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function * * @return @c 0 on success, * otherwise a negative error value @@ -128,12 +147,13 @@ int contacts_sim_get_initialization_status(bool *completed) TIZEN_DEPRECATED_API * @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. + * @pre contacts_connect() should be called to open a connection to the contacts service. * * @see contacts_connect() + * @see contacts_sim_import_progress_cb() */ -int contacts_sim_import_all_contacts_by_sim_slot_no(int sim_slot_no); +int contacts_sim_import_all_contacts_by_sim_slot_no(int sim_slot_no, contacts_sim_import_progress_cb callback, void *user_data); /** * @brief Checks whether SIM of the given SIM slot number is initialized. @@ -142,7 +162,7 @@ int contacts_sim_import_all_contacts_by_sim_slot_no(int sim_slot_no); * @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[in] sim_slot_no The SIM slot number; 0 means first SIM, 1 means second SIM * @param[out] completed @c true if SIM is initialized, * otherwise @c false if SIM is not initialized * @@ -156,7 +176,7 @@ int contacts_sim_import_all_contacts_by_sim_slot_no(int sim_slot_no); * @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. + * @pre contacts_connect() should be called to open a connection to the contacts service. * * @see contacts_connect() */ diff --git a/include/wearable/contacts_sim.h b/include/wearable/contacts_sim.h index 49f6983..0a5fab9 100644 --- a/include/wearable/contacts_sim.h +++ b/include/wearable/contacts_sim.h @@ -54,13 +54,32 @@ extern "C" */ /** - * @brief Imports all contacts from SIM of the given SIM slot number to Contacts Database. + * @brief Called whenever a contact is imported. + * + * @since_tizen 3.0 + * + * @param[in] total The number of contacts that will be imported + * @param[in] imported_cnt The number of already imported contacts + * @param[in] user_data The user data passed from the callback registration function + * + * @pre contacts_sim_import_all_contacts_by_sim_slot_no() will invoke this callback. + * + * @see contacts_sim_import_all_contacts_by_sim_slot_no() + */ +typedef void (*contacts_sim_import_progress_cb)(int total, int imported_cnt, void *user_data); + +/** + * @brief Imports all contacts from SIM of the given SIM slot number to the Contacts Database. + * + * @details This function invokes contacts_sim_import_progress_cb() to indicate the progress of imports whenever a contact is imported. * * @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 + * @param[in] sim_slot_no The SIM slot number; 0 means first SIM, 1 means second SIM + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function * * @return @c 0 on success, * otherwise a negative error value @@ -73,12 +92,13 @@ extern "C" * @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. + * @pre contacts_connect() should be called to open a connection to the contacts service. * * @see contacts_connect() + * @see contacts_sim_import_progress_cb() */ -int contacts_sim_import_all_contacts_by_sim_slot_no(int sim_slot_no); +int contacts_sim_import_all_contacts_by_sim_slot_no(int sim_slot_no, contacts_sim_import_progress_cb callback, void *user_data); /** * @brief Checks whether SIM of the given SIM slot number is initialized. @@ -87,7 +107,7 @@ int contacts_sim_import_all_contacts_by_sim_slot_no(int sim_slot_no); * @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[in] sim_slot_no The SIM slot number; 0 means first SIM, 1 means second SIM * @param[out] completed @c true if SIM is initialized, * otherwise @c false if SIM is not initialized * @@ -101,7 +121,7 @@ int contacts_sim_import_all_contacts_by_sim_slot_no(int sim_slot_no); * @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. + * @pre contacts_connect() should be called to open a connection to the contacts service. * * @see contacts_connect() */ diff --git a/packaging/contacts-service.spec b/packaging/contacts-service.spec index da82641..e795c6d 100644 --- a/packaging/contacts-service.spec +++ b/packaging/contacts-service.spec @@ -1,6 +1,6 @@ Name: contacts-service Summary: Contacts Service -Version: 0.13.57 +Version: 0.13.58 Release: 0 Group: Social & Content/Service License: Apache-2.0 diff --git a/server/ctsvc_server_sim.c b/server/ctsvc_server_sim.c index 6a9e2e0..13dbeb2 100644 --- a/server/ctsvc_server_sim.c +++ b/server/ctsvc_server_sim.c @@ -80,8 +80,8 @@ typedef struct { /* Each sim file info (max index, max text length, used count) */ sim_file_s file_record[TAPI_PB_MAX_FILE_CNT]; - /* To bulk insert SIM contact, Free after insert them */ - GSList *import_contacts; + /* Number of Imported SIM contact*/ + int imported_cnt; /* * Set true after read SIM meta info @@ -353,76 +353,36 @@ int ctsvc_server_sim_get_sim_slot_no_by_info_id(int sim_info_id) return -1; } -static void __ctsvc_server_sim_destroy_records(gpointer data) -{ - sim_contact_s *record = data; - __ctsvc_server_sim_record_destroy(record); -} - -static void __ctsvc_server_sim_destroy_import_contacts(ctsvc_sim_info_s *info) +static void __ctsvc_server_sim_init_import_info(ctsvc_sim_info_s *info) { RET_IF(NULL == info); - RET_IF(NULL == info->import_contacts); - g_slist_free_full(info->import_contacts, __ctsvc_server_sim_destroy_records); - info->import_contacts = NULL; + info->imported_cnt = 0; } -static int __ctsvc_server_sim_insert_records_to_db(ctsvc_sim_info_s *info) +static int __ctsvc_server_sim_insert_record_to_db(sim_contact_s *record) { CTS_FN_CALL; - int i; int ret = 0; - int count = 0; - sim_contact_s *record = NULL; contacts_record_h contact = NULL; - contacts_list_h list = NULL; - GSList *cursor = NULL; - /* insert contacts to DB */ - ret = contacts_list_create(&list); + ret = __ctsvc_server_sim_ctsvc_record_clone(record, DEFAULT_ADDRESS_BOOK_ID, &contact); if (CONTACTS_ERROR_NONE != ret) { /* LCOV_EXCL_START */ - ERR("contacts_list_create() Fail(%d)", ret); + ERR("__ctsvc_server_sim_ctsvc_record_clone() Fail(%d)", ret); return CONTACTS_ERROR_INTERNAL; /* LCOV_EXCL_STOP */ } - for (cursor = info->import_contacts, i = 0; cursor; i++) { - record = cursor->data; - ret = __ctsvc_server_sim_ctsvc_record_clone(record, DEFAULT_ADDRESS_BOOK_ID, &contact); - if (CONTACTS_ERROR_NONE != ret) { - /* LCOV_EXCL_START */ - ERR("__ctsvc_server_sim_ctsvc_record_clone() Fail(%d)", ret); - contacts_list_destroy(list, true); - return CONTACTS_ERROR_INTERNAL; - /* LCOV_EXCL_STOP */ - } - ret = contacts_list_add(list, contact); - if (CONTACTS_ERROR_NONE != ret) { - /* LCOV_EXCL_START */ - ERR("contacts_list_add() Fail(%d)", ret); - contacts_list_destroy(list, true); - return CONTACTS_ERROR_INTERNAL; - /* LCOV_EXCL_STOP */ - } - cursor = cursor->next; - } - - contacts_list_get_count(list, &count); - DBG("records count:%d", count); - if (0 < count) { - ret = ctsvc_db_insert_records(list, NULL, NULL); - if (CONTACTS_ERROR_NONE != ret) { - /* LCOV_EXCL_START */ - ERR("ctsvc_db_insert_records() Fail(%d)", ret); - contacts_list_destroy(list, true); - return ret; - /* LCOV_EXCL_STOP */ - } + ret = ctsvc_db_insert_record(contact, NULL); + contacts_record_destroy(contact, true); + if (CONTACTS_ERROR_NONE != ret) { + /* LCOV_EXCL_START */ + ERR("ctsvc_db_insert_record() Fail(%d)", ret); + return ret; + /* LCOV_EXCL_STOP */ } - contacts_list_destroy(list, true); return CONTACTS_ERROR_NONE; } @@ -468,7 +428,7 @@ static void __ctsvc_server_sim_import_contact_cb(TapiHandle *handle, int result, info->file_record[TAPI_PB_3G_NAME].index_max); ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), CONTACTS_ERROR_INTERNAL, 0, NULL); WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret); - __ctsvc_server_sim_destroy_import_contacts(info); + __ctsvc_server_sim_init_import_info(info); __ctsvc_server_sim_set_return_data(NULL); return; /* LCOV_EXCL_STOP */ @@ -480,7 +440,7 @@ static void __ctsvc_server_sim_import_contact_cb(TapiHandle *handle, int result, ERR("SIM phonebook access Fail(%d) start_indext(%d)", access_rt, start_index); ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), CONTACTS_ERROR_SYSTEM, 0, NULL); WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret); - __ctsvc_server_sim_destroy_import_contacts(info); + __ctsvc_server_sim_init_import_info(info); __ctsvc_server_sim_set_return_data(NULL); return; /* LCOV_EXCL_STOP */ @@ -493,7 +453,7 @@ static void __ctsvc_server_sim_import_contact_cb(TapiHandle *handle, int result, ERR("SIM phonebook access Fail(%d)", access_rt); ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), CONTACTS_ERROR_SYSTEM, 0, NULL); WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret); - __ctsvc_server_sim_destroy_import_contacts(info); + __ctsvc_server_sim_init_import_info(info); __ctsvc_server_sim_set_return_data(NULL); return; /* LCOV_EXCL_STOP */ @@ -503,7 +463,14 @@ static void __ctsvc_server_sim_import_contact_cb(TapiHandle *handle, int result, case TAPI_SIM_PB_ADN: case TAPI_SIM_PB_3GSIM: record = __ctsvc_server_sim_record_clone(sim_info); - info->import_contacts = g_slist_append(info->import_contacts, (void*)record); + ret = __ctsvc_server_sim_insert_record_to_db(record); + __ctsvc_server_sim_record_destroy(record); + if (CONTACTS_ERROR_NONE != ret) + WARN("__ctsvc_server_sim_insert_record_to_db() Fail(%d)", ret); + else + info->imported_cnt++; + ctsvc_server_socket_invoke_cb(__ctsvc_server_sim_get_return_data(), + info->file_record[TAPI_PB_3G_NAME].used_count, info->imported_cnt); break; case TAPI_SIM_PB_FDN: case TAPI_SIM_PB_SDN: @@ -512,7 +479,7 @@ static void __ctsvc_server_sim_import_contact_cb(TapiHandle *handle, int result, ERR("Unknown storage type(%d)", sim_info->phonebook_type); ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), CONTACTS_ERROR_SYSTEM, 0, NULL); WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret); - __ctsvc_server_sim_destroy_import_contacts(info); + __ctsvc_server_sim_init_import_info(info); __ctsvc_server_sim_set_return_data(NULL); return; /* LCOV_EXCL_STOP */ @@ -528,17 +495,18 @@ static void __ctsvc_server_sim_import_contact_cb(TapiHandle *handle, int result, ERR("tel_read_sim_pb_record() Fail(%d)", ret); ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), CONTACTS_ERROR_SYSTEM, 0, NULL); WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret); - __ctsvc_server_sim_destroy_import_contacts(info); + __ctsvc_server_sim_init_import_info(info); __ctsvc_server_sim_set_return_data(NULL); return; /* LCOV_EXCL_STOP */ } } else { - /* insert imported contact to DB */ - ret = __ctsvc_server_sim_insert_records_to_db(info); - ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), ret, 0, NULL); + if (info->file_record[TAPI_PB_3G_NAME].used_count == info->imported_cnt) + ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), CONTACTS_ERROR_NONE, 0, NULL); + else + ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), CONTACTS_ERROR_SYSTEM, 0, NULL); WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret); - __ctsvc_server_sim_destroy_import_contacts(info); + __ctsvc_server_sim_init_import_info(info); __ctsvc_server_sim_set_return_data(NULL); } } @@ -894,7 +862,7 @@ static void __ctsvc_server_sim_noti_pb_status(TapiHandle *handle, const char *no /* FDN on : can not import sim contacts */ INFO("This is sim card is 2G and FDN on status. sim phonebook will be block"); info->initialized = false; - __ctsvc_server_sim_destroy_import_contacts(info); + __ctsvc_server_sim_init_import_info(info); } else { /* LCOV_EXCL_START */ ERR("This noti did not control !!!"); @@ -909,7 +877,7 @@ static void __ctsvc_server_sim_noti_sim_refreshed(TapiHandle *handle, const char INFO("Recieved SIM Refresh event"); info->initialized = false; - __ctsvc_server_sim_destroy_import_contacts(info); + __ctsvc_server_sim_init_import_info(info); } static void __ctsvc_server_sim_get_info(ctsvc_sim_info_s *info) @@ -996,7 +964,6 @@ static int __ctsvc_server_sim_init_info() info->sim_info_id = -1; info->sim_type = TAPI_SIM_PB_UNKNOWNN; info->initialized = false; - info->import_contacts = NULL; info->sim_unique_id = NULL; /* initialize file_record meta info */ @@ -1097,7 +1064,7 @@ int ctsvc_server_sim_final(void) WARN_IF(TAPI_API_SUCCESS != ret, "tel_deinit() Fail(%d)", ret); } - __ctsvc_server_sim_destroy_import_contacts(info); + __ctsvc_server_sim_init_import_info(info); free(info); } diff --git a/server/ctsvc_server_socket.c b/server/ctsvc_server_socket.c index a66d63e..8429f8c 100644 --- a/server/ctsvc_server_socket.c +++ b/server/ctsvc_server_socket.c @@ -124,6 +124,32 @@ int ctsvc_server_socket_return(GIOChannel *src, int value, int attach_num, int * return CONTACTS_ERROR_NONE; } +int ctsvc_server_socket_invoke_cb(GIOChannel *src, int total, int imported_cnt) +{ + CTS_FN_CALL; + int ret; + ctsvc_socket_msg_s msg = {0}; + + RETV_IF(NULL == src, CONTACTS_ERROR_INVALID_PARAMETER); + + msg.type = CTSVC_SOCKET_MSG_TYPE_REQUEST_INVOKE_CB; + msg.val = total; + msg.data = imported_cnt; + + DBG("fd = %d, MSG_TYPE=%d, MSG_VAL=%d, MSG_ATTACH_NUM=%d," + "MSG_ATTACH1=%d, MSG_ATTACH2=%d, MSG_ATTACH3=%d, MSG_ATTACH4=%d", + g_io_channel_unix_get_fd(src), msg.type, msg.val, msg.attach_num, + msg.attach_sizes[0], msg.attach_sizes[1], msg.attach_sizes[2], + msg.attach_sizes[3]); + + ret = __ctsvc_server_socket_safe_write(g_io_channel_unix_get_fd(src), (char *)&msg, sizeof(msg)); + RETVM_IF(-1 == ret, CONTACTS_ERROR_SYSTEM, + "__ctsvc_server_socket_safe_write() Fail(errno = %d)", errno); + + return CONTACTS_ERROR_NONE; +} + + static void __ctsvc_server_socket_import_sim(GIOChannel *src, int size) { CTS_FN_CALL; diff --git a/server/ctsvc_server_socket.h b/server/ctsvc_server_socket.h index 1718253..40aef73 100644 --- a/server/ctsvc_server_socket.h +++ b/server/ctsvc_server_socket.h @@ -25,6 +25,7 @@ int ctsvc_server_socket_init(void); int ctsvc_server_socket_deinit(void); int ctsvc_server_socket_return(GIOChannel *src, int value, int attach_num, int *attach_size); int ctsvc_server_socket_return_sim_int(GIOChannel *src, int value); +int ctsvc_server_socket_invoke_cb(GIOChannel *src, int total, int imported_cnt); #endif /* __CTSVC_SERVER_SOCKET_H__ */