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"
23 static int __ctsvc_ipc_unmarshal_simple_contact(pims_ipc_data_h ipc_data,
24 const char *view_uri, contacts_record_h record)
26 ctsvc_simple_contact_s *pcontact = (ctsvc_simple_contact_s*)record;
28 RETV_IF(NULL == ipc_data, CONTACTS_ERROR_NO_DATA);
29 RETV_IF(NULL == record, CONTACTS_ERROR_NO_DATA);
32 if (ctsvc_ipc_unmarshal_bool(ipc_data, &pcontact->is_favorite) != CONTACTS_ERROR_NONE)
34 if (ctsvc_ipc_unmarshal_int(ipc_data, &pcontact->changed_time) != CONTACTS_ERROR_NONE)
36 if (ctsvc_ipc_unmarshal_bool(ipc_data, &pcontact->has_phonenumber) != CONTACTS_ERROR_NONE)
38 if (ctsvc_ipc_unmarshal_bool(ipc_data, &pcontact->has_email) != CONTACTS_ERROR_NONE)
40 if (ctsvc_ipc_unmarshal_int(ipc_data, &pcontact->person_id) != CONTACTS_ERROR_NONE)
42 if (ctsvc_ipc_unmarshal_int(ipc_data, &pcontact->contact_id) != CONTACTS_ERROR_NONE)
44 if (ctsvc_ipc_unmarshal_int(ipc_data, &pcontact->addressbook_id) != CONTACTS_ERROR_NONE)
46 if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->image_thumbnail_path) != CONTACTS_ERROR_NONE)
48 if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->ringtone_path) != CONTACTS_ERROR_NONE)
50 if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->vibration) != CONTACTS_ERROR_NONE)
52 if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->message_alert) != CONTACTS_ERROR_NONE)
54 if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->display_name) != CONTACTS_ERROR_NONE)
56 if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->uid) != CONTACTS_ERROR_NONE)
58 if (ctsvc_ipc_unmarshal_int(ipc_data, &pcontact->display_source_type) != CONTACTS_ERROR_NONE)
61 return CONTACTS_ERROR_NONE;
64 ERR("__ctsvc_ipc_unmarshal_simple_contact() Fail");
65 return CONTACTS_ERROR_INVALID_PARAMETER;
69 static int __ctsvc_ipc_marshal_simple_contact(const contacts_record_h record,
70 pims_ipc_data_h ipc_data)
72 ctsvc_simple_contact_s *pcontact = (ctsvc_simple_contact_s*)record;
74 RETV_IF(NULL == ipc_data, CONTACTS_ERROR_NO_DATA);
75 RETV_IF(NULL == pcontact, CONTACTS_ERROR_NO_DATA);
78 if (ctsvc_ipc_marshal_bool((pcontact->is_favorite), ipc_data) != CONTACTS_ERROR_NONE)
80 if (ctsvc_ipc_marshal_int((pcontact->changed_time), ipc_data) != CONTACTS_ERROR_NONE)
82 if (ctsvc_ipc_marshal_bool((pcontact->has_phonenumber), ipc_data) != CONTACTS_ERROR_NONE)
84 if (ctsvc_ipc_marshal_bool((pcontact->has_email), ipc_data) != CONTACTS_ERROR_NONE)
86 if (ctsvc_ipc_marshal_int((pcontact->person_id), ipc_data) != CONTACTS_ERROR_NONE)
88 if (ctsvc_ipc_marshal_int((pcontact->contact_id), ipc_data) != CONTACTS_ERROR_NONE)
90 if (ctsvc_ipc_marshal_int((pcontact->addressbook_id), ipc_data) != CONTACTS_ERROR_NONE)
92 if (ctsvc_ipc_marshal_string((pcontact->image_thumbnail_path), ipc_data) != CONTACTS_ERROR_NONE)
94 if (ctsvc_ipc_marshal_string((pcontact->ringtone_path), ipc_data) != CONTACTS_ERROR_NONE)
96 if (ctsvc_ipc_marshal_string((pcontact->vibration), ipc_data) != CONTACTS_ERROR_NONE)
98 if (ctsvc_ipc_marshal_string((pcontact->message_alert), ipc_data) != CONTACTS_ERROR_NONE)
100 if (ctsvc_ipc_marshal_string((pcontact->display_name), ipc_data) != CONTACTS_ERROR_NONE)
102 if (ctsvc_ipc_marshal_string((pcontact->uid), ipc_data) != CONTACTS_ERROR_NONE)
104 if (ctsvc_ipc_marshal_int((pcontact->display_source_type), ipc_data) != CONTACTS_ERROR_NONE)
107 return CONTACTS_ERROR_NONE;
109 /* LCOV_EXCL_START */
110 ERR("_ctsvc_ipc_marshal() Fail");
111 return CONTACTS_ERROR_INVALID_PARAMETER;
115 ctsvc_ipc_marshal_record_plugin_cb_s _ctsvc_ipc_record_simple_contact_plugin_cb = {
116 .unmarshal_record = __ctsvc_ipc_unmarshal_simple_contact,
117 .marshal_record = __ctsvc_ipc_marshal_simple_contact