498cbd94e72707fa95ef5e358381ffb7097b1829
[platform/core/pim/contacts-service.git] / common / ipc / ctsvc_ipc_company.c
1 /*
2  * Contacts Service
3  *
4  * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  */
19 #include "ctsvc_internal.h"
20 #include "ctsvc_ipc_marshal.h"
21 #include "contacts_record.h"
22
23
24 static int __ctsvc_ipc_unmarshal_company(pims_ipc_data_h ipc_data,
25                 const char *view_uri, contacts_record_h record)
26 {
27         ctsvc_company_s *company_p = (ctsvc_company_s*)record;
28
29         RETV_IF(NULL == ipc_data, CONTACTS_ERROR_NO_DATA);
30         RETV_IF(NULL == record, CONTACTS_ERROR_NO_DATA);
31
32         do {
33                 if (ctsvc_ipc_unmarshal_int(ipc_data, &company_p->id) != CONTACTS_ERROR_NONE)
34                         break;
35                 if (ctsvc_ipc_unmarshal_int(ipc_data, &company_p->contact_id) != CONTACTS_ERROR_NONE)
36                         break;
37                 if (ctsvc_ipc_unmarshal_bool(ipc_data, &company_p->is_default) != CONTACTS_ERROR_NONE)
38                         break;
39                 if (ctsvc_ipc_unmarshal_int(ipc_data, &company_p->type) != CONTACTS_ERROR_NONE)
40                         break;
41
42                 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->label) != CONTACTS_ERROR_NONE)
43                         break;
44                 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->name) != CONTACTS_ERROR_NONE)
45                         break;
46                 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->department) != CONTACTS_ERROR_NONE)
47                         break;
48                 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->job_title) != CONTACTS_ERROR_NONE)
49                         break;
50                 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->role) != CONTACTS_ERROR_NONE)
51                         break;
52                 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->assistant_name) != CONTACTS_ERROR_NONE)
53                         break;
54                 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->logo) != CONTACTS_ERROR_NONE)
55                         break;
56                 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->location) != CONTACTS_ERROR_NONE)
57                         break;
58                 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->description) != CONTACTS_ERROR_NONE)
59                         break;
60                 if (ctsvc_ipc_unmarshal_string(ipc_data, &company_p->phonetic_name) != CONTACTS_ERROR_NONE)
61                         break;
62
63                 return CONTACTS_ERROR_NONE;
64         } while (0);
65
66         ERR("__ctsvc_ipc_unmarshal_company() Fail");
67         return CONTACTS_ERROR_INVALID_PARAMETER;
68 }
69
70 static int __ctsvc_ipc_marshal_company(const contacts_record_h record,
71                 pims_ipc_data_h ipc_data)
72 {
73         ctsvc_company_s *company_p = (ctsvc_company_s*)record;
74
75         RETV_IF(NULL == ipc_data, CONTACTS_ERROR_NO_DATA);
76         RETV_IF(company_p == NULL, CONTACTS_ERROR_NO_DATA);
77
78         do {
79                 if (ctsvc_ipc_marshal_int((company_p->id), ipc_data) != CONTACTS_ERROR_NONE)
80                         break;
81                 if (ctsvc_ipc_marshal_int((company_p->contact_id), ipc_data) != CONTACTS_ERROR_NONE)
82                         break;
83                 if (ctsvc_ipc_marshal_bool((company_p->is_default), ipc_data) != CONTACTS_ERROR_NONE)
84                         break;
85                 if (ctsvc_ipc_marshal_int((company_p->type), ipc_data) != CONTACTS_ERROR_NONE)
86                         break;
87                 if (ctsvc_ipc_marshal_string((company_p->label), ipc_data) != CONTACTS_ERROR_NONE)
88                         break;
89                 if (ctsvc_ipc_marshal_string((company_p->name), ipc_data) != CONTACTS_ERROR_NONE)
90                         break;
91                 if (ctsvc_ipc_marshal_string((company_p->department), ipc_data) != CONTACTS_ERROR_NONE)
92                         break;
93                 if (ctsvc_ipc_marshal_string((company_p->job_title), ipc_data) != CONTACTS_ERROR_NONE)
94                         break;
95                 if (ctsvc_ipc_marshal_string((company_p->role), ipc_data) != CONTACTS_ERROR_NONE)
96                         break;
97                 if (ctsvc_ipc_marshal_string((company_p->assistant_name), ipc_data) != CONTACTS_ERROR_NONE)
98                         break;
99                 if (ctsvc_ipc_marshal_string((company_p->logo), ipc_data) != CONTACTS_ERROR_NONE)
100                         break;
101                 if (ctsvc_ipc_marshal_string((company_p->location), ipc_data) != CONTACTS_ERROR_NONE)
102                         break;
103                 if (ctsvc_ipc_marshal_string((company_p->description), ipc_data) != CONTACTS_ERROR_NONE)
104                         break;
105                 if (ctsvc_ipc_marshal_string((company_p->phonetic_name), ipc_data) != CONTACTS_ERROR_NONE)
106                         break;
107
108                 return CONTACTS_ERROR_NONE;
109         } while (0);
110
111         ERR("_ctsvc_ipc_marshal() Fail");
112         return CONTACTS_ERROR_INVALID_PARAMETER;
113 }
114
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
118 };
119