Add user space access control
[platform/core/pim/contacts-service.git] / client / ctsvc_client_utils.c
1 /*\r
2  * Contacts Service\r
3  *\r
4  * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.\r
5  *\r
6  * Licensed under the Apache License, Version 2.0 (the "License");\r
7  * you may not use this file except in compliance with the License.\r
8  * You may obtain a copy of the License at\r
9  *\r
10  * http://www.apache.org/licenses/LICENSE-2.0\r
11  *\r
12  * Unless required by applicable law or agreed to in writing, software\r
13  * distributed under the License is distributed on an "AS IS" BASIS,\r
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
15  * See the License for the specific language governing permissions and\r
16  * limitations under the License.\r
17  *\r
18  */\r
19 \r
20 #include <glib.h>\r
21 #include <pims-ipc-data.h>\r
22 \r
23 #include "contacts.h"\r
24 #include "ctsvc_internal.h"\r
25 #include "ctsvc_ipc_define.h"\r
26 #include "ctsvc_ipc_marshal.h"\r
27 #include "ctsvc_client_ipc.h"\r
28 \r
29 API int contacts_utils_get_index_characters(char **index_string)\r
30 {\r
31         int ret = CONTACTS_ERROR_NONE;\r
32         pims_ipc_data_h outdata = NULL;\r
33 \r
34         RETVM_IF(index_string == NULL, CONTACTS_ERROR_INVALID_PARAMETER, "The out param is NULL");\r
35         *index_string = NULL;\r
36         RETVM_IF(ctsvc_get_ipc_handle() == NULL,CONTACTS_ERROR_IPC, "contacts not connected");\r
37 \r
38         if (ctsvc_ipc_call(CTSVC_IPC_UTILS_MODULE, CTSVC_IPC_SERVER_UTILS_GET_INDEX_CHARACTERS, NULL, &outdata) != 0) {\r
39                 CTS_ERR("ctsvc_ipc_call failed");\r
40                 return CONTACTS_ERROR_IPC;\r
41         }\r
42 \r
43         if (outdata) {\r
44                 unsigned int size = 0;\r
45                 ret = *(int*) pims_ipc_data_get(outdata, &size);\r
46                 if (CONTACTS_ERROR_NONE == ret) {\r
47                         ret = ctsvc_ipc_unmarshal_string(outdata, index_string);\r
48                         if (CONTACTS_ERROR_NONE != ret) {\r
49                                 CTS_ERR("ctsvc_ipc_unmarshal_string Fail9(%d)", ret);\r
50                         }\r
51                 }\r
52                 pims_ipc_data_destroy(outdata);\r
53         }\r
54 \r
55         return ret;\r
56 }\r
57 \r