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_name(pims_ipc_data_h ipc_data, const char *view_uri,
25 contacts_record_h record)
27 ctsvc_name_s *name_p = (ctsvc_name_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_bool(ipc_data, &name_p->is_default) != CONTACTS_ERROR_NONE)
35 if (ctsvc_ipc_unmarshal_int(ipc_data, &name_p->id) != CONTACTS_ERROR_NONE)
37 if (ctsvc_ipc_unmarshal_int(ipc_data, &name_p->contact_id) != CONTACTS_ERROR_NONE)
39 if (ctsvc_ipc_unmarshal_int(ipc_data, &name_p->language_type) != CONTACTS_ERROR_NONE)
41 if (ctsvc_ipc_unmarshal_string(ipc_data, &name_p->first) != CONTACTS_ERROR_NONE)
43 if (ctsvc_ipc_unmarshal_string(ipc_data, &name_p->last) != CONTACTS_ERROR_NONE)
45 if (ctsvc_ipc_unmarshal_string(ipc_data, &name_p->addition) != CONTACTS_ERROR_NONE)
47 if (ctsvc_ipc_unmarshal_string(ipc_data, &name_p->prefix) != CONTACTS_ERROR_NONE)
49 if (ctsvc_ipc_unmarshal_string(ipc_data, &name_p->suffix) != CONTACTS_ERROR_NONE)
51 if (ctsvc_ipc_unmarshal_string(ipc_data, &name_p->phonetic_first) != CONTACTS_ERROR_NONE)
53 if (ctsvc_ipc_unmarshal_string(ipc_data, &name_p->phonetic_middle) != CONTACTS_ERROR_NONE)
55 if (ctsvc_ipc_unmarshal_string(ipc_data, &name_p->phonetic_last) != CONTACTS_ERROR_NONE)
57 if (ctsvc_ipc_unmarshal_string(ipc_data, &name_p->lookup) != CONTACTS_ERROR_NONE)
59 if (ctsvc_ipc_unmarshal_string(ipc_data, &name_p->reverse_lookup) != CONTACTS_ERROR_NONE)
62 return CONTACTS_ERROR_NONE;
66 ERR("__ctsvc_ipc_unmarshal_name() Fail");
67 return CONTACTS_ERROR_INVALID_PARAMETER;
71 static int __ctsvc_ipc_marshal_name(const contacts_record_h record,
72 pims_ipc_data_h ipc_data)
74 ctsvc_name_s *name_p = (ctsvc_name_s*)record;
76 RETV_IF(NULL == ipc_data, CONTACTS_ERROR_NO_DATA);
77 RETV_IF(name_p == NULL, CONTACTS_ERROR_NO_DATA);
80 if (ctsvc_ipc_marshal_bool((name_p->is_default), ipc_data) != CONTACTS_ERROR_NONE)
82 if (ctsvc_ipc_marshal_int((name_p->id), ipc_data) != CONTACTS_ERROR_NONE)
84 if (ctsvc_ipc_marshal_int((name_p->contact_id), ipc_data) != CONTACTS_ERROR_NONE)
86 if (ctsvc_ipc_marshal_int((name_p->language_type), ipc_data) != CONTACTS_ERROR_NONE)
88 if (ctsvc_ipc_marshal_string((name_p->first), ipc_data) != CONTACTS_ERROR_NONE)
90 if (ctsvc_ipc_marshal_string((name_p->last), ipc_data) != CONTACTS_ERROR_NONE)
92 if (ctsvc_ipc_marshal_string((name_p->addition), ipc_data) != CONTACTS_ERROR_NONE)
94 if (ctsvc_ipc_marshal_string((name_p->prefix), ipc_data) != CONTACTS_ERROR_NONE)
96 if (ctsvc_ipc_marshal_string((name_p->suffix), ipc_data) != CONTACTS_ERROR_NONE)
98 if (ctsvc_ipc_marshal_string((name_p->phonetic_first), ipc_data) != CONTACTS_ERROR_NONE)
100 if (ctsvc_ipc_marshal_string((name_p->phonetic_middle), ipc_data) != CONTACTS_ERROR_NONE)
102 if (ctsvc_ipc_marshal_string((name_p->phonetic_last), ipc_data) != CONTACTS_ERROR_NONE)
104 if (ctsvc_ipc_marshal_string((name_p->lookup), ipc_data) != CONTACTS_ERROR_NONE)
106 if (ctsvc_ipc_marshal_string((name_p->reverse_lookup), ipc_data) != CONTACTS_ERROR_NONE)
109 return CONTACTS_ERROR_NONE;
112 /* LCOV_EXCL_START */
113 ERR("_ctsvc_ipc_marshal() Fail");
114 return CONTACTS_ERROR_INVALID_PARAMETER;
118 ctsvc_ipc_marshal_record_plugin_cb_s _ctsvc_ipc_record_name_plugin_cb = {
119 .unmarshal_record = __ctsvc_ipc_unmarshal_name,
120 .marshal_record = __ctsvc_ipc_marshal_name