diff options
Diffstat (limited to 'common/ipc/ctsvc_ipc_extension.c')
-rw-r--r-- | common/ipc/ctsvc_ipc_extension.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/common/ipc/ctsvc_ipc_extension.c b/common/ipc/ctsvc_ipc_extension.c new file mode 100644 index 0000000..c69c163 --- /dev/null +++ b/common/ipc/ctsvc_ipc_extension.c @@ -0,0 +1,86 @@ +#include "ctsvc_ipc_macros.h" + + + +#include "ctsvc_internal.h" +#include "ctsvc_ipc_marshal.h" +#include "contacts_record.h" + +static int __ctsvc_ipc_unmarshal_extension(pims_ipc_data_h ipc_data, const char* view_uri, contacts_record_h record); +static int __ctsvc_ipc_marshal_extension(const contacts_record_h record, pims_ipc_data_h ipc_data); +static int __ctsvc_ipc_marshal_extension_get_primary_id(const contacts_record_h record, unsigned int *property_id, int *id); + +ctsvc_ipc_marshal_record_plugin_cb_s _ctsvc_ipc_record_extension_plugin_cb = { + .unmarshal_record = __ctsvc_ipc_unmarshal_extension, + .marshal_record = __ctsvc_ipc_marshal_extension, + .get_primary_id = __ctsvc_ipc_marshal_extension_get_primary_id +}; + + +static int __ctsvc_ipc_unmarshal_extension(pims_ipc_data_h ipc_data, const char* view_uri, contacts_record_h record) +{ + RETV_IF(ipc_data==NULL,CONTACTS_ERROR_NO_DATA); + RETV_IF(record==NULL,CONTACTS_ERROR_NO_DATA); + + ctsvc_extension_s* extend_p = (ctsvc_extension_s*) record; + + do { + if (ctsvc_ipc_unmarshal_int(ipc_data, &extend_p->id) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_int(ipc_data, &extend_p->contact_id) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_int(ipc_data, &extend_p->data1) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_string(ipc_data, &extend_p->data2) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_string(ipc_data, &extend_p->data3) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_string(ipc_data, &extend_p->data4) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_string(ipc_data, &extend_p->data5) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_string(ipc_data, &extend_p->data6) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_string(ipc_data, &extend_p->data7) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_string(ipc_data, &extend_p->data8) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_string(ipc_data, &extend_p->data9) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_string(ipc_data, &extend_p->data10) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_string(ipc_data, &extend_p->data11) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_string(ipc_data, &extend_p->data12) != CONTACTS_ERROR_NONE) break; + + return CONTACTS_ERROR_NONE; + + } while(0); + + CTS_ERR("_ctsvc_ipc_unmarshal fail"); + return CONTACTS_ERROR_INVALID_PARAMETER; +} + +static int __ctsvc_ipc_marshal_extension(const contacts_record_h record, pims_ipc_data_h ipc_data) +{ + ctsvc_extension_s* extend_p = (ctsvc_extension_s*)record; + RETV_IF(ipc_data==NULL,CONTACTS_ERROR_NO_DATA); + RETV_IF(extend_p==NULL,CONTACTS_ERROR_NO_DATA); + + do { + if (ctsvc_ipc_marshal_int((extend_p->id),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_int((extend_p->contact_id),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_int((extend_p->data1),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_string((extend_p->data2),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_string((extend_p->data3),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_string((extend_p->data4),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_string((extend_p->data5),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_string((extend_p->data6),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_string((extend_p->data7),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_string((extend_p->data8),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_string((extend_p->data9),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_string((extend_p->data10),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_string((extend_p->data11),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_string((extend_p->data12),ipc_data) != CONTACTS_ERROR_NONE) break; + + return CONTACTS_ERROR_NONE; + + } while(0); + + CTS_ERR("_ctsvc_ipc_marshal fail"); + return CONTACTS_ERROR_INVALID_PARAMETER; +} + +static int __ctsvc_ipc_marshal_extension_get_primary_id(const contacts_record_h record, unsigned int *property_id, int *id) +{ + *property_id = CTSVC_PROPERTY_EXTENSION_ID; + return contacts_record_get_int(record, *property_id, id ); +} + |