5324a591d2b7d72048fe3230168ae437e6fac25a
[platform/core/pim/contacts-service.git] / common / ipc / ctsvc_ipc_phonelog.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_phonelog(pims_ipc_data_h ipc_data, const char *view_uri,
25                 contacts_record_h record)
26 {
27         ctsvc_phonelog_s *phonelog_p = (ctsvc_phonelog_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, &phonelog_p->id) != CONTACTS_ERROR_NONE)
34                         break;
35                 if (ctsvc_ipc_unmarshal_string(ipc_data, &phonelog_p->address) != CONTACTS_ERROR_NONE)
36                         break;
37                 if (ctsvc_ipc_unmarshal_int(ipc_data, &phonelog_p->person_id) != CONTACTS_ERROR_NONE)
38                         break;
39                 if (ctsvc_ipc_unmarshal_int(ipc_data, &phonelog_p->log_time) != CONTACTS_ERROR_NONE)
40                         break;
41                 if (ctsvc_ipc_unmarshal_int(ipc_data, &phonelog_p->log_type) != CONTACTS_ERROR_NONE)
42                         break;
43                 if (ctsvc_ipc_unmarshal_int(ipc_data, &phonelog_p->extra_data1) != CONTACTS_ERROR_NONE)
44                         break;
45                 if (ctsvc_ipc_unmarshal_string(ipc_data, &phonelog_p->extra_data2) != CONTACTS_ERROR_NONE)
46                         break;
47                 if (ctsvc_ipc_unmarshal_int(ipc_data, &phonelog_p->sim_slot_no) != CONTACTS_ERROR_NONE)
48                         break;
49
50                 return CONTACTS_ERROR_NONE;
51         } while (0);
52
53         ERR("__ctsvc_ipc_unmarshal_phonelog() Fail");
54         return CONTACTS_ERROR_INVALID_PARAMETER;
55 }
56
57 static int __ctsvc_ipc_marshal_phonelog(const contacts_record_h record,
58                 pims_ipc_data_h ipc_data)
59 {
60         ctsvc_phonelog_s *phonelog_p = (ctsvc_phonelog_s*)record;
61
62         RETV_IF(NULL == ipc_data, CONTACTS_ERROR_NO_DATA);
63         RETV_IF(phonelog_p == NULL, CONTACTS_ERROR_NO_DATA);
64
65         do {
66                 if (ctsvc_ipc_marshal_int((phonelog_p->id), ipc_data) != CONTACTS_ERROR_NONE)
67                         break;
68                 if (ctsvc_ipc_marshal_string((phonelog_p->address), ipc_data) != CONTACTS_ERROR_NONE)
69                         break;
70                 if (ctsvc_ipc_marshal_int((phonelog_p->person_id), ipc_data) != CONTACTS_ERROR_NONE)
71                         break;
72                 if (ctsvc_ipc_marshal_int((phonelog_p->log_time), ipc_data) != CONTACTS_ERROR_NONE)
73                         break;
74                 if (ctsvc_ipc_marshal_int((phonelog_p->log_type), ipc_data) != CONTACTS_ERROR_NONE)
75                         break;
76                 if (ctsvc_ipc_marshal_int((phonelog_p->extra_data1), ipc_data) != CONTACTS_ERROR_NONE)
77                         break;
78                 if (ctsvc_ipc_marshal_string((phonelog_p->extra_data2), ipc_data) != CONTACTS_ERROR_NONE)
79                         break;
80                 if (ctsvc_ipc_marshal_int((phonelog_p->sim_slot_no), ipc_data) != CONTACTS_ERROR_NONE)
81                         break;
82
83                 return CONTACTS_ERROR_NONE;
84         } while (0);
85
86         ERR("_ctsvc_ipc_marshal() Fail");
87         return CONTACTS_ERROR_INVALID_PARAMETER;
88 }
89
90 ctsvc_ipc_marshal_record_plugin_cb_s _ctsvc_ipc_record_phonelog_plugin_cb = {
91         .unmarshal_record = __ctsvc_ipc_unmarshal_phonelog,
92         .marshal_record = __ctsvc_ipc_marshal_phonelog
93 };
94