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_address(pims_ipc_data_h ipc_data,
25 const char *view_uri, contacts_record_h record)
27 ctsvc_address_s *address_p = (ctsvc_address_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, &address_p->is_default) != CONTACTS_ERROR_NONE)
35 if (ctsvc_ipc_unmarshal_int(ipc_data, &address_p->id) != CONTACTS_ERROR_NONE)
37 if (ctsvc_ipc_unmarshal_int(ipc_data, &address_p->contact_id) != CONTACTS_ERROR_NONE)
39 if (ctsvc_ipc_unmarshal_int(ipc_data, &address_p->type) != CONTACTS_ERROR_NONE)
41 if (ctsvc_ipc_unmarshal_string(ipc_data, &address_p->label) != CONTACTS_ERROR_NONE)
43 if (ctsvc_ipc_unmarshal_string(ipc_data, &address_p->pobox) != CONTACTS_ERROR_NONE)
45 if (ctsvc_ipc_unmarshal_string(ipc_data, &address_p->postalcode) != CONTACTS_ERROR_NONE)
47 if (ctsvc_ipc_unmarshal_string(ipc_data, &address_p->region) != CONTACTS_ERROR_NONE)
49 if (ctsvc_ipc_unmarshal_string(ipc_data, &address_p->locality) != CONTACTS_ERROR_NONE)
51 if (ctsvc_ipc_unmarshal_string(ipc_data, &address_p->street) != CONTACTS_ERROR_NONE)
53 if (ctsvc_ipc_unmarshal_string(ipc_data, &address_p->extended) != CONTACTS_ERROR_NONE)
55 if (ctsvc_ipc_unmarshal_string(ipc_data, &address_p->country) != CONTACTS_ERROR_NONE)
58 return CONTACTS_ERROR_NONE;
61 ERR("__ctsvc_ipc_unmarshal_address() Fail");
63 return CONTACTS_ERROR_INVALID_PARAMETER;
66 static int __ctsvc_ipc_marshal_address(const contacts_record_h record,
67 pims_ipc_data_h ipc_data)
69 ctsvc_address_s *address_p = (ctsvc_address_s*)record;
71 RETV_IF(NULL == ipc_data, CONTACTS_ERROR_NO_DATA);
72 RETV_IF(NULL == address_p, CONTACTS_ERROR_NO_DATA);
75 if (ctsvc_ipc_marshal_bool((address_p->is_default), ipc_data) != CONTACTS_ERROR_NONE)
77 if (ctsvc_ipc_marshal_int((address_p->id), ipc_data) != CONTACTS_ERROR_NONE)
79 if (ctsvc_ipc_marshal_int((address_p->contact_id), ipc_data) != CONTACTS_ERROR_NONE)
81 if (ctsvc_ipc_marshal_int((address_p->type), ipc_data) != CONTACTS_ERROR_NONE)
83 if (ctsvc_ipc_marshal_string((address_p->label), ipc_data) != CONTACTS_ERROR_NONE)
85 if (ctsvc_ipc_marshal_string((address_p->pobox), ipc_data) != CONTACTS_ERROR_NONE)
87 if (ctsvc_ipc_marshal_string((address_p->postalcode), ipc_data) != CONTACTS_ERROR_NONE)
89 if (ctsvc_ipc_marshal_string((address_p->region), ipc_data) != CONTACTS_ERROR_NONE)
91 if (ctsvc_ipc_marshal_string((address_p->locality), ipc_data) != CONTACTS_ERROR_NONE)
93 if (ctsvc_ipc_marshal_string((address_p->street), ipc_data) != CONTACTS_ERROR_NONE)
95 if (ctsvc_ipc_marshal_string((address_p->extended), ipc_data) != CONTACTS_ERROR_NONE)
97 if (ctsvc_ipc_marshal_string((address_p->country), ipc_data) != CONTACTS_ERROR_NONE)
100 return CONTACTS_ERROR_NONE;
103 ERR("_ctsvc_ipc_marshal() Fail");
105 return CONTACTS_ERROR_INVALID_PARAMETER;
108 ctsvc_ipc_marshal_record_plugin_cb_s _ctsvc_ipc_record_address_plugin_cb = {
109 .unmarshal_record = __ctsvc_ipc_unmarshal_address,
110 .marshal_record = __ctsvc_ipc_marshal_address