4 * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include "ctsvc_internal.h"
24 #include "ctsvc_ipc_define.h"
25 #include "ctsvc_client_ipc.h"
26 #include <pims-ipc-data.h>
27 #include "ctsvc_ipc_marshal.h"
29 API int contacts_group_add_contact(int group_id, int contact_id)
31 int ret = CONTACTS_ERROR_NONE;
33 pims_ipc_data_h indata = NULL;
34 pims_ipc_data_h outdata = NULL;
36 RETVM_IF(group_id <= 0 || contact_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
39 indata = pims_ipc_data_create(0);
42 CTS_ERR("ipc data created fail!");
43 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
47 ret = ctsvc_ipc_marshal_int( group_id, indata);
48 if (ret != CONTACTS_ERROR_NONE)
50 CTS_ERR("marshal fail");
51 pims_ipc_data_destroy(indata);
54 ret = ctsvc_ipc_marshal_int( contact_id, indata);
55 if (ret != CONTACTS_ERROR_NONE)
57 CTS_ERR("marshal fail");
58 pims_ipc_data_destroy(indata);
63 if (ctsvc_ipc_call(CTSVC_IPC_GROUP_MODULE, CTSVC_IPC_SERVER_GROUP_ADD_CONTACT, indata, &outdata) != 0)
65 CTS_ERR("ctsvc_ipc_call failed");
66 pims_ipc_data_destroy(indata);
67 return CONTACTS_ERROR_IPC;
70 pims_ipc_data_destroy(indata);
75 unsigned int size = 0;
76 ret = *(int*) pims_ipc_data_get(outdata, &size);
78 if (CONTACTS_ERROR_NONE == ret) {
79 int transaction_ver = 0;
80 transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
81 ctsvc_client_ipc_set_change_version(transaction_ver);
84 pims_ipc_data_destroy(outdata);
90 API int contacts_group_remove_contact(int group_id, int contact_id)
92 int ret = CONTACTS_ERROR_NONE;
94 pims_ipc_data_h indata = NULL;
95 pims_ipc_data_h outdata = NULL;
97 RETVM_IF(group_id <= 0 || contact_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
100 indata = pims_ipc_data_create(0);
103 CTS_ERR("ipc data created fail!");
104 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
108 ret = ctsvc_ipc_marshal_int( group_id, indata);
109 if (ret != CONTACTS_ERROR_NONE)
111 CTS_ERR("marshal fail");
112 pims_ipc_data_destroy(indata);
115 ret = ctsvc_ipc_marshal_int( contact_id, indata);
116 if (ret != CONTACTS_ERROR_NONE)
118 CTS_ERR("marshal fail");
119 pims_ipc_data_destroy(indata);
124 if (ctsvc_ipc_call(CTSVC_IPC_GROUP_MODULE, CTSVC_IPC_SERVER_GROUP_REMOVE_CONTACT, indata, &outdata) != 0)
126 CTS_ERR("ctsvc_ipc_call failed");
127 pims_ipc_data_destroy(indata);
128 return CONTACTS_ERROR_IPC;
131 pims_ipc_data_destroy(indata);
136 unsigned int size = 0;
137 ret = *(int*) pims_ipc_data_get(outdata, &size);
139 if (CONTACTS_ERROR_NONE == ret) {
140 int transaction_ver = 0;
141 transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
142 ctsvc_client_ipc_set_change_version(transaction_ver);
145 pims_ipc_data_destroy(outdata);
151 API int contacts_group_set_group_order(int group_id, int previous_group_id, int next_group_id)
153 int ret = CONTACTS_ERROR_NONE;
155 pims_ipc_data_h indata = NULL;
156 pims_ipc_data_h outdata = NULL;
158 RETVM_IF(group_id <= 0 || previous_group_id < 0 || next_group_id < 0, CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
161 indata = pims_ipc_data_create(0);
164 CTS_ERR("ipc data created fail!");
165 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
169 ret = ctsvc_ipc_marshal_int( group_id, indata);
170 if (ret != CONTACTS_ERROR_NONE)
172 CTS_ERR("marshal fail");
173 pims_ipc_data_destroy(indata);
176 ret = ctsvc_ipc_marshal_int( previous_group_id, indata);
177 if (ret != CONTACTS_ERROR_NONE)
179 CTS_ERR("marshal fail");
180 pims_ipc_data_destroy(indata);
183 ret = ctsvc_ipc_marshal_int( next_group_id, indata);
184 if (ret != CONTACTS_ERROR_NONE)
186 CTS_ERR("marshal fail");
187 pims_ipc_data_destroy(indata);
192 if (ctsvc_ipc_call(CTSVC_IPC_GROUP_MODULE, CTSVC_IPC_SERVER_GROUP_SET_GROUP_ORDER, indata, &outdata) != 0)
194 CTS_ERR("ctsvc_ipc_call failed");
195 pims_ipc_data_destroy(indata);
196 return CONTACTS_ERROR_IPC;
199 pims_ipc_data_destroy(indata);
204 unsigned int size = 0;
205 ret = *(int*) pims_ipc_data_get(outdata, &size);
207 if (CONTACTS_ERROR_NONE == ret) {
208 int transaction_ver = 0;
209 transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
210 ctsvc_client_ipc_set_change_version(transaction_ver);
213 pims_ipc_data_destroy(outdata);