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_number(pims_ipc_data_h ipc_data, const char *view_uri,
25 contacts_record_h record)
27 ctsvc_number_s * number_p = (ctsvc_number_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, &number_p->is_default) != CONTACTS_ERROR_NONE)
35 if (ctsvc_ipc_unmarshal_int(ipc_data, &number_p->id) != CONTACTS_ERROR_NONE)
37 if (ctsvc_ipc_unmarshal_int(ipc_data, &number_p->contact_id) != CONTACTS_ERROR_NONE)
39 if (ctsvc_ipc_unmarshal_int(ipc_data, &number_p->type) != CONTACTS_ERROR_NONE)
41 if (ctsvc_ipc_unmarshal_string(ipc_data, &number_p->label) != CONTACTS_ERROR_NONE)
43 if (ctsvc_ipc_unmarshal_string(ipc_data, &number_p->number) != CONTACTS_ERROR_NONE)
46 return CONTACTS_ERROR_NONE;
50 ERR("__ctsvc_ipc_unmarshal_number() Fail");
51 return CONTACTS_ERROR_INVALID_PARAMETER;
55 static int __ctsvc_ipc_marshal_number(const contacts_record_h record,
56 pims_ipc_data_h ipc_data)
58 ctsvc_number_s *number_p = (ctsvc_number_s*)record;
60 RETV_IF(NULL == ipc_data, CONTACTS_ERROR_NO_DATA);
61 RETV_IF(number_p == NULL, CONTACTS_ERROR_NO_DATA);
64 if (ctsvc_ipc_marshal_bool((number_p->is_default), ipc_data) != CONTACTS_ERROR_NONE)
66 if (ctsvc_ipc_marshal_int((number_p->id), ipc_data) != CONTACTS_ERROR_NONE)
68 if (ctsvc_ipc_marshal_int((number_p->contact_id), ipc_data) != CONTACTS_ERROR_NONE)
70 if (ctsvc_ipc_marshal_int((number_p->type), ipc_data) != CONTACTS_ERROR_NONE)
72 if (ctsvc_ipc_marshal_string((number_p->label), ipc_data) != CONTACTS_ERROR_NONE)
74 if (ctsvc_ipc_marshal_string((number_p->number), ipc_data) != CONTACTS_ERROR_NONE)
77 return CONTACTS_ERROR_NONE;
80 ERR("_ctsvc_ipc_marshal() Fail");
81 return CONTACTS_ERROR_INVALID_PARAMETER;
85 ctsvc_ipc_marshal_record_plugin_cb_s _ctsvc_ipc_record_number_plugin_cb = {
86 .unmarshal_record = __ctsvc_ipc_unmarshal_number,
87 .marshal_record = __ctsvc_ipc_marshal_number