Add contact feature
[platform/core/pim/contacts-service.git] / common / ctsvc_sim.c
1 /*
2  * Contacts Service
3  *
4  * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include "contacts.h"
21 #include "ctsvc_internal.h"
22 #include "ctsvc_mutex.h"
23 #include "ctsvc_socket.h"
24
25 EXPORT_API int contacts_sim_import_all_contacts()
26 {
27         CHECK_CONTACT_SUPPORTED(CONTACT_FEATURE);
28         int ret;
29         WARN(DEPRECATED_STRING_FORMAT, __FUNCTION__);
30
31         ctsvc_mutex_lock(CTS_MUTEX_SOCKET_FD);
32         ret = ctsvc_request_sim_import(0, NULL, NULL);
33         ctsvc_mutex_unlock(CTS_MUTEX_SOCKET_FD);
34
35         return ret;
36 }
37
38 EXPORT_API int contacts_sim_get_initialization_status(bool *completed)
39 {
40         CHECK_CONTACT_SUPPORTED(CONTACT_FEATURE);
41         int ret;
42         WARN(DEPRECATED_STRING_FORMAT, __FUNCTION__);
43         RETV_IF(NULL == completed, CONTACTS_ERROR_INVALID_PARAMETER);
44
45         ctsvc_mutex_lock(CTS_MUTEX_SOCKET_FD);
46         ret = ctsvc_request_sim_get_initialization_status(0, completed);
47         ctsvc_mutex_unlock(CTS_MUTEX_SOCKET_FD);
48
49         return ret;
50 }
51
52 EXPORT_API int contacts_sim_import_all_contacts_by_sim_slot_no(int sim_slot_no,
53                 contacts_sim_import_progress_cb callback, void *user_data)
54 {
55         CHECK_CONTACT_SUPPORTED(CONTACT_FEATURE);
56         int ret;
57
58         RETV_IF(sim_slot_no < 0, CONTACTS_ERROR_INVALID_PARAMETER);
59
60         ctsvc_mutex_lock(CTS_MUTEX_SOCKET_FD);
61         ret = ctsvc_request_sim_import(sim_slot_no, callback, user_data);
62         ctsvc_mutex_unlock(CTS_MUTEX_SOCKET_FD);
63
64         return ret;
65 }
66
67 EXPORT_API int contacts_sim_get_initialization_status_by_sim_slot_no(int sim_slot_no, bool *completed)
68 {
69         CHECK_CONTACT_SUPPORTED(CONTACT_FEATURE);
70         int ret;
71
72         RETV_IF(NULL == completed, CONTACTS_ERROR_INVALID_PARAMETER);
73         RETV_IF(sim_slot_no < 0, CONTACTS_ERROR_INVALID_PARAMETER);
74
75         ctsvc_mutex_lock(CTS_MUTEX_SOCKET_FD);
76         ret = ctsvc_request_sim_get_initialization_status(sim_slot_no, completed);
77         ctsvc_mutex_unlock(CTS_MUTEX_SOCKET_FD);
78
79         return ret;
80 }
81