return CONTACTS_ERROR_NONE;
}
+static int __ctsvc_cancel_sim_import(int fd)
+{
+ int ret;
+ ctsvc_socket_msg_s msg = {0};
+
+ RETVM_IF(-1 == fd, CONTACTS_ERROR_IPC, "socket is not connected");
+
+ msg.type = CTSVC_SOCKET_MSG_TYPE_CANCEL_IMPORT_SIM;
+
+ ret = __ctsvc_safe_write(fd, (char *)&msg, sizeof(msg));
+ RETVM_IF(-1 == ret, CONTACTS_ERROR_IPC, "__ctsvc_safe_write() Fail(errno = %d)", errno);
+
+ 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;
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
+ if (callback) {
+ if (false == callback(msg->val, msg->data, user_data))
+ __ctsvc_cancel_sim_import(fd);
+ } else {
WARN("No callback");
+ }
break;
/* LCOV_EXCL_START */
CTSVC_SOCKET_MSG_TYPE_REQUEST_IMPORT_SIM,
CTSVC_SOCKET_MSG_TYPE_REQUEST_SIM_INIT_COMPLETE,
CTSVC_SOCKET_MSG_TYPE_REQUEST_INVOKE_CB,
+ CTSVC_SOCKET_MSG_TYPE_CANCEL_IMPORT_SIM,
};
#define CTSVC_SOCKET_MSG_REQUEST_MAX_ATTACH 5
* @param[in] imported_cnt The number of already imported contacts
* @param[in] user_data The user data passed from the callback registration function
*
+ * @return @c true to continue with the import of contacts
+ * otherwise @c false to stop the import of contacts
+ *
* @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);
+typedef bool (*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.
* @param[in] imported_cnt The number of already imported contacts
* @param[in] user_data The user data passed from the callback registration function
*
+ * @return @c true to continue with the import of contacts
+ * otherwise @c false to stop the import of contacts
+ *
* @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);
+typedef bool (*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.
Name: contacts-service
Summary: Contacts Service
-Version: 0.13.58
+Version: 0.13.59
Release: 0
Group: Social & Content/Service
License: Apache-2.0
static GSList *__ctsvc_sim_info = NULL;
static void *greturn_data = NULL;
static bool __ctsvc_tapi_cb = false;
+static bool sim_import_cancel = false;
static TapiHandle* __ctsvc_server_sim_get_tapi_handle(ctsvc_sim_info_s *info)
{
sim_contact_s *record = NULL;
ctsvc_sim_info_s *info;
+ if (sim_import_cancel) {
+ DBG("SIM contacts import is canceled");
+ ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), CONTACTS_ERROR_NONE, 0, NULL);
+ WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret);
+ __ctsvc_server_sim_set_return_data(NULL);
+ sim_import_cancel = false;
+ return;
+ }
+
if (NULL == sim_info) {
/* LCOV_EXCL_START */
ERR("sim_info is NULL, result = %d", access_rt);
return CONTACTS_ERROR_NONE;
}
+void ctsvc_server_sim_cancel_import()
+{
+ sim_import_cancel = true;
+}
+
int ctsvc_server_socket_get_sim_init_status(void *data, int sim_slot_no)
{
CTS_FN_CALL;
int ctsvc_server_sim_final(void);
int ctsvc_server_sim_import_contact(void *data, int sim_slot_no);
+void ctsvc_server_sim_cancel_import();
int ctsvc_server_sim_get_info_id_by_sim_slot_no(int sim_slot_no);
int ctsvc_server_sim_get_sim_slot_no_by_info_id(int sim_info_id);
int ctsvc_server_socket_get_sim_init_status(void *data, int sim_slot_no);
}
__ctsvc_server_socket_get_sim_init_status(src, msg.attach_sizes[0]);
break;
+ case CTSVC_SOCKET_MSG_TYPE_CANCEL_IMPORT_SIM:
+ ctsvc_server_sim_cancel_import();
+ break;
+
default:
/* LCOV_EXCL_START */
ERR("Unknown request type(%d)", msg.type);