revise packaging
[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         int ret;
28         WARN(DEPRECATED_STRING_FORMAT, __FUNCTION__);
29
30         ctsvc_mutex_lock(CTS_MUTEX_SOCKET_FD);
31         ret = ctsvc_request_sim_import(0, NULL, NULL);
32         ctsvc_mutex_unlock(CTS_MUTEX_SOCKET_FD);
33
34         return ret;
35 }
36
37 EXPORT_API int contacts_sim_get_initialization_status(bool *completed)
38 {
39         int ret;
40         WARN(DEPRECATED_STRING_FORMAT, __FUNCTION__);
41         RETV_IF(NULL == completed, CONTACTS_ERROR_INVALID_PARAMETER);
42
43         ctsvc_mutex_lock(CTS_MUTEX_SOCKET_FD);
44         ret = ctsvc_request_sim_get_initialization_status(0, completed);
45         ctsvc_mutex_unlock(CTS_MUTEX_SOCKET_FD);
46
47         return ret;
48 }
49
50 EXPORT_API int contacts_sim_import_all_contacts_by_sim_slot_no(int sim_slot_no,
51                 contacts_sim_import_progress_cb callback, void *user_data)
52 {
53         int ret;
54
55         RETV_IF(sim_slot_no < 0, CONTACTS_ERROR_INVALID_PARAMETER);
56
57         ctsvc_mutex_lock(CTS_MUTEX_SOCKET_FD);
58         ret = ctsvc_request_sim_import(sim_slot_no, callback, user_data);
59         ctsvc_mutex_unlock(CTS_MUTEX_SOCKET_FD);
60
61         return ret;
62 }
63
64 EXPORT_API int contacts_sim_get_initialization_status_by_sim_slot_no(int sim_slot_no, bool *completed)
65 {
66         int ret;
67
68         RETV_IF(NULL == completed, CONTACTS_ERROR_INVALID_PARAMETER);
69         RETV_IF(sim_slot_no < 0, CONTACTS_ERROR_INVALID_PARAMETER);
70
71         ctsvc_mutex_lock(CTS_MUTEX_SOCKET_FD);
72         ret = ctsvc_request_sim_get_initialization_status(sim_slot_no, completed);
73         ctsvc_mutex_unlock(CTS_MUTEX_SOCKET_FD);
74
75         return ret;
76 }
77