1238123533a7642b5644dc71e6fd99914fa68a40
[platform/core/pim/contacts-service.git] / common / ipc / ctsvc_ipc_activity_photo.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_activity_photo(pims_ipc_data_h ipc_data,
25                 const char *view_uri, contacts_record_h record)
26 {
27         ctsvc_activity_photo_s *photo_p = (ctsvc_activity_photo_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, &photo_p->id) != CONTACTS_ERROR_NONE)
34                         break;
35                 if (ctsvc_ipc_unmarshal_int(ipc_data, &photo_p->activity_id) != CONTACTS_ERROR_NONE)
36                         break;
37                 if (ctsvc_ipc_unmarshal_string(ipc_data, &photo_p->photo_url) != CONTACTS_ERROR_NONE)
38                         break;
39                 if (ctsvc_ipc_unmarshal_int(ipc_data, &photo_p->sort_index) != CONTACTS_ERROR_NONE)
40                         break;
41
42                 return CONTACTS_ERROR_NONE;
43
44         } while (0);
45
46         ERR("__ctsvc_ipc_unmarshal_activity_photo() Fail");
47         return CONTACTS_ERROR_INVALID_PARAMETER;
48 }
49
50 static int __ctsvc_ipc_marshal_activity_photo(const contacts_record_h record,
51                 pims_ipc_data_h ipc_data)
52 {
53         ctsvc_activity_photo_s *photo_p = (ctsvc_activity_photo_s*)record;
54
55         RETV_IF(NULL == ipc_data, CONTACTS_ERROR_NO_DATA);
56         RETV_IF(photo_p == NULL, CONTACTS_ERROR_NO_DATA);
57
58         do {
59                 if (ctsvc_ipc_marshal_int((photo_p->id), ipc_data) != CONTACTS_ERROR_NONE)
60                         break;
61                 if (ctsvc_ipc_marshal_int((photo_p->activity_id), ipc_data) != CONTACTS_ERROR_NONE)
62                         break;
63                 if (ctsvc_ipc_marshal_string((photo_p->photo_url), ipc_data) != CONTACTS_ERROR_NONE)
64                         break;
65                 if (ctsvc_ipc_marshal_int((photo_p->sort_index), ipc_data) != CONTACTS_ERROR_NONE)
66                         break;
67
68                 return CONTACTS_ERROR_NONE;
69         } while (0);
70
71         ERR("_ctsvc_ipc_marshal() Fail");
72
73         return CONTACTS_ERROR_INVALID_PARAMETER;
74
75 }
76
77 ctsvc_ipc_marshal_record_plugin_cb_s _ctsvc_ipc_record_activity_photo_plugin_cb = {
78         .unmarshal_record = __ctsvc_ipc_unmarshal_activity_photo,
79         .marshal_record = __ctsvc_ipc_marshal_activity_photo
80 };
81