4 * Copyright (c) 2010 - 2015 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.
19 #include "ctsvc_internal.h"
20 #include "ctsvc_ipc_marshal.h"
21 #include "contacts_record.h"
24 static int __ctsvc_ipc_unmarshal_group(pims_ipc_data_h ipc_data,
25 const char *view_uri, contacts_record_h record)
27 ctsvc_group_s *group_p = (ctsvc_group_s*)record;
29 RETV_IF(NULL == ipc_data, CONTACTS_ERROR_NO_DATA);
30 RETV_IF(NULL == record, CONTACTS_ERROR_NO_DATA);
33 if (ctsvc_ipc_unmarshal_int(ipc_data, &group_p->id) != CONTACTS_ERROR_NONE)
35 if (ctsvc_ipc_unmarshal_int(ipc_data, &group_p->addressbook_id) != CONTACTS_ERROR_NONE)
37 if (ctsvc_ipc_unmarshal_bool(ipc_data, &group_p->is_read_only) != CONTACTS_ERROR_NONE)
39 if (ctsvc_ipc_unmarshal_string(ipc_data, &group_p->name) != CONTACTS_ERROR_NONE)
41 if (ctsvc_ipc_unmarshal_string(ipc_data, &group_p->extra_data) != CONTACTS_ERROR_NONE)
43 if (ctsvc_ipc_unmarshal_string(ipc_data, &group_p->ringtone_path) != CONTACTS_ERROR_NONE)
45 if (ctsvc_ipc_unmarshal_string(ipc_data, &group_p->vibration) != CONTACTS_ERROR_NONE)
47 if (ctsvc_ipc_unmarshal_string(ipc_data, &group_p->message_alert) != CONTACTS_ERROR_NONE)
49 if (ctsvc_ipc_unmarshal_string(ipc_data, &group_p->image_thumbnail_path) != CONTACTS_ERROR_NONE)
52 return CONTACTS_ERROR_NONE;
56 ERR("__ctsvc_ipc_unmarshal_group() Fail");
57 return CONTACTS_ERROR_INVALID_PARAMETER;
61 static int __ctsvc_ipc_marshal_group(const contacts_record_h record,
62 pims_ipc_data_h ipc_data)
64 ctsvc_group_s *group_p = (ctsvc_group_s*)record;
66 RETV_IF(NULL == ipc_data, CONTACTS_ERROR_NO_DATA);
67 RETV_IF(group_p == NULL, CONTACTS_ERROR_NO_DATA);
70 if (ctsvc_ipc_marshal_int((group_p->id), ipc_data) != CONTACTS_ERROR_NONE)
72 if (ctsvc_ipc_marshal_int((group_p->addressbook_id), ipc_data) != CONTACTS_ERROR_NONE)
74 if (ctsvc_ipc_marshal_bool((group_p->is_read_only), ipc_data) != CONTACTS_ERROR_NONE)
76 if (ctsvc_ipc_marshal_string((group_p->name), ipc_data) != CONTACTS_ERROR_NONE)
78 if (ctsvc_ipc_marshal_string((group_p->extra_data), ipc_data) != CONTACTS_ERROR_NONE)
80 if (ctsvc_ipc_marshal_string((group_p->ringtone_path), ipc_data) != CONTACTS_ERROR_NONE)
82 if (ctsvc_ipc_marshal_string((group_p->vibration), ipc_data) != CONTACTS_ERROR_NONE)
84 if (ctsvc_ipc_marshal_string((group_p->message_alert), ipc_data) != CONTACTS_ERROR_NONE)
86 if (ctsvc_ipc_marshal_string((group_p->image_thumbnail_path), ipc_data) != CONTACTS_ERROR_NONE)
89 return CONTACTS_ERROR_NONE;
92 ERR("_ctsvc_ipc_marshal() Fail");
93 return CONTACTS_ERROR_INVALID_PARAMETER;
97 ctsvc_ipc_marshal_record_plugin_cb_s _ctsvc_ipc_record_group_plugin_cb = {
98 .unmarshal_record = __ctsvc_ipc_unmarshal_group,
99 .marshal_record = __ctsvc_ipc_marshal_group