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_company(pims_ipc_data_h ipc_data,
25 const char *view_uri, contacts_record_h record)
27 ctsvc_company_s *company_p = (ctsvc_company_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, &company_p->id) != CONTACTS_ERROR_NONE)
35 if (ctsvc_ipc_unmarshal_int(ipc_data, &company_p->contact_id) != CONTACTS_ERROR_NONE)
37 if (ctsvc_ipc_unmarshal_bool(ipc_data, &company_p->is_default) != CONTACTS_ERROR_NONE)
39 if (ctsvc_ipc_unmarshal_int(ipc_data, &company_p->type) != CONTACTS_ERROR_NONE)
42 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->label) != CONTACTS_ERROR_NONE)
44 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->name) != CONTACTS_ERROR_NONE)
46 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->department) != CONTACTS_ERROR_NONE)
48 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->job_title) != CONTACTS_ERROR_NONE)
50 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->role) != CONTACTS_ERROR_NONE)
52 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->assistant_name) != CONTACTS_ERROR_NONE)
54 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->logo) != CONTACTS_ERROR_NONE)
56 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->location) != CONTACTS_ERROR_NONE)
58 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->description) != CONTACTS_ERROR_NONE)
60 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->phonetic_name) != CONTACTS_ERROR_NONE)
63 return CONTACTS_ERROR_NONE;
66 ERR("__ctsvc_ipc_unmarshal_company() Fail");
67 return CONTACTS_ERROR_INVALID_PARAMETER;
70 static int __ctsvc_ipc_marshal_company(const contacts_record_h record,
71 pims_ipc_data_h ipc_data)
73 ctsvc_company_s *company_p = (ctsvc_company_s*)record;
75 RETV_IF(NULL == ipc_data, CONTACTS_ERROR_NO_DATA);
76 RETV_IF(company_p == NULL, CONTACTS_ERROR_NO_DATA);
79 if (ctsvc_ipc_marshal_int((company_p->id), ipc_data) != CONTACTS_ERROR_NONE)
81 if (ctsvc_ipc_marshal_int((company_p->contact_id), ipc_data) != CONTACTS_ERROR_NONE)
83 if (ctsvc_ipc_marshal_bool((company_p->is_default), ipc_data) != CONTACTS_ERROR_NONE)
85 if (ctsvc_ipc_marshal_int((company_p->type), ipc_data) != CONTACTS_ERROR_NONE)
87 if (ctsvc_ipc_marshal_string((company_p->label), ipc_data) != CONTACTS_ERROR_NONE)
89 if (ctsvc_ipc_marshal_string((company_p->name), ipc_data) != CONTACTS_ERROR_NONE)
91 if (ctsvc_ipc_marshal_string((company_p->department), ipc_data) != CONTACTS_ERROR_NONE)
93 if (ctsvc_ipc_marshal_string((company_p->job_title), ipc_data) != CONTACTS_ERROR_NONE)
95 if (ctsvc_ipc_marshal_string((company_p->role), ipc_data) != CONTACTS_ERROR_NONE)
97 if (ctsvc_ipc_marshal_string((company_p->assistant_name), ipc_data) != CONTACTS_ERROR_NONE)
99 if (ctsvc_ipc_marshal_string((company_p->logo), ipc_data) != CONTACTS_ERROR_NONE)
101 if (ctsvc_ipc_marshal_string((company_p->location), ipc_data) != CONTACTS_ERROR_NONE)
103 if (ctsvc_ipc_marshal_string((company_p->description), ipc_data) != CONTACTS_ERROR_NONE)
105 if (ctsvc_ipc_marshal_string((company_p->phonetic_name), ipc_data) != CONTACTS_ERROR_NONE)
108 return CONTACTS_ERROR_NONE;
111 ERR("_ctsvc_ipc_marshal() Fail");
112 return CONTACTS_ERROR_INVALID_PARAMETER;
115 ctsvc_ipc_marshal_record_plugin_cb_s _ctsvc_ipc_record_company_plugin_cb = {
116 .unmarshal_record = __ctsvc_ipc_unmarshal_company,
117 .marshal_record = __ctsvc_ipc_marshal_company