1 #include "ctsvc_ipc_macros.h"
4 #include "ctsvc_internal.h"
5 #include "ctsvc_ipc_marshal.h"
6 #include "contacts_record.h"
8 static int __ctsvc_ipc_unmarshal_image(pims_ipc_data_h ipc_data, const char* view_uri, contacts_record_h record);
9 static int __ctsvc_ipc_marshal_image(const contacts_record_h record, pims_ipc_data_h ipc_data);
10 static int __ctsvc_ipc_marshal_image_get_primary_id(const contacts_record_h record, unsigned int *property_id, int *id);
12 ctsvc_ipc_marshal_record_plugin_cb_s _ctsvc_ipc_record_image_plugin_cb = {
13 .unmarshal_record = __ctsvc_ipc_unmarshal_image,
14 .marshal_record = __ctsvc_ipc_marshal_image,
15 .get_primary_id = __ctsvc_ipc_marshal_image_get_primary_id
19 static int __ctsvc_ipc_unmarshal_image(pims_ipc_data_h ipc_data, const char* view_uri, contacts_record_h record)
21 RETV_IF(ipc_data==NULL,CONTACTS_ERROR_NO_DATA);
22 RETV_IF(record==NULL,CONTACTS_ERROR_NO_DATA);
24 ctsvc_image_s* image_p = (ctsvc_image_s*) record;
27 if (ctsvc_ipc_unmarshal_int(ipc_data, &image_p->id) != CONTACTS_ERROR_NONE) break;
28 if (ctsvc_ipc_unmarshal_int(ipc_data, &image_p->contact_id) != CONTACTS_ERROR_NONE) break;
29 if (ctsvc_ipc_unmarshal_int(ipc_data, &image_p->type) != CONTACTS_ERROR_NONE) break;
30 if (ctsvc_ipc_unmarshal_string(ipc_data, &image_p->label) != CONTACTS_ERROR_NONE) break;
31 if (ctsvc_ipc_unmarshal_string(ipc_data, &image_p->path) != CONTACTS_ERROR_NONE) break;
32 if (ctsvc_ipc_unmarshal_bool(ipc_data, &image_p->is_default) != CONTACTS_ERROR_NONE) break;
34 return CONTACTS_ERROR_NONE;
37 CTS_ERR("_ctsvc_ipc_unmarshal fail");
38 return CONTACTS_ERROR_INVALID_PARAMETER;
41 static int __ctsvc_ipc_marshal_image(const contacts_record_h record, pims_ipc_data_h ipc_data)
43 ctsvc_image_s* image_p = (ctsvc_image_s*)record;
44 RETV_IF(ipc_data==NULL,CONTACTS_ERROR_NO_DATA);
45 RETV_IF(image_p==NULL,CONTACTS_ERROR_NO_DATA);
48 if (ctsvc_ipc_marshal_int((image_p->id),ipc_data) != CONTACTS_ERROR_NONE) break;
49 if (ctsvc_ipc_marshal_int((image_p->contact_id),ipc_data) != CONTACTS_ERROR_NONE) break;
50 if (ctsvc_ipc_marshal_int((image_p->type),ipc_data) != CONTACTS_ERROR_NONE) break;
51 if (ctsvc_ipc_marshal_string((image_p->label),ipc_data) != CONTACTS_ERROR_NONE) break;
52 if (ctsvc_ipc_marshal_string((image_p->path),ipc_data) != CONTACTS_ERROR_NONE) break;
53 if (ctsvc_ipc_marshal_bool((image_p->is_default),ipc_data) != CONTACTS_ERROR_NONE) break;
55 return CONTACTS_ERROR_NONE;
58 CTS_ERR("_ctsvc_ipc_marshal fail");
59 return CONTACTS_ERROR_INVALID_PARAMETER;
62 static int __ctsvc_ipc_marshal_image_get_primary_id(const contacts_record_h record, unsigned int *property_id, int *id)
64 *property_id = CTSVC_PROPERTY_IMAGE_ID;
65 return contacts_record_get_int(record, *property_id, id );