static int __ctsvc_event_get_int(contacts_record_h record, unsigned int property_id, int *out);
static int __ctsvc_event_get_str(contacts_record_h record, unsigned int property_id, char** out_str);
static int __ctsvc_event_get_str_p(contacts_record_h record, unsigned int property_id, char** out_str);
+static int __ctsvc_event_get_bool(contacts_record_h record, unsigned int property_id, bool *value);
static int __ctsvc_event_set_int(contacts_record_h record, unsigned int property_id, int value);
static int __ctsvc_event_set_str(contacts_record_h record, unsigned int property_id, const char* str);
+static int __ctsvc_event_set_bool(contacts_record_h record, unsigned int property_id, bool value);
static int __ctsvc_extension_create(contacts_record_h *out_record);
static int __ctsvc_extension_destroy(contacts_record_h record, bool delete_child);
static int __ctsvc_group_relation_get_str(contacts_record_h record, unsigned int property_id, char** out_str);
static int __ctsvc_group_relation_get_str_p(contacts_record_h record, unsigned int property_id, char** out_str);
static int __ctsvc_group_relation_set_int(contacts_record_h record, unsigned int property_id, int value);
+static int __ctsvc_group_relation_set_str(contacts_record_h record, unsigned int property_id, const char* str);
static int __ctsvc_messenger_create(contacts_record_h *out_record);
static int __ctsvc_messenger_destroy(contacts_record_h record, bool delete_child);
static int __ctsvc_simple_contact_get_int(contacts_record_h record, unsigned int property_id, int *out);
static int __ctsvc_simple_contact_get_str(contacts_record_h record, unsigned int property_id, char** out_str);
static int __ctsvc_simple_contact_get_str_p(contacts_record_h record, unsigned int property_id, char** out_str);
+static int __ctsvc_simple_contact_set_int(contacts_record_h record, unsigned int property_id, int value);
+static int __ctsvc_simple_contact_set_str(contacts_record_h record, unsigned int property_id, const char* str);
static int __ctsvc_url_create(contacts_record_h *out_record);
static int __ctsvc_url_destroy(contacts_record_h record, bool delete_child);
.get_str = __ctsvc_event_get_str,
.get_str_p = __ctsvc_event_get_str_p,
.get_int = __ctsvc_event_get_int,
- .get_bool = NULL,
+ .get_bool = __ctsvc_event_get_bool,
.get_lli = NULL,
.get_double = NULL,
.set_str = __ctsvc_event_set_str,
.set_int = __ctsvc_event_set_int,
- .set_bool = NULL,
+ .set_bool = __ctsvc_event_set_bool,
.set_lli = NULL,
.set_double = NULL,
.add_child_record = NULL,
.get_bool = NULL,
.get_lli = NULL,
.get_double = NULL,
- .set_str = NULL,
+ .set_str = __ctsvc_group_relation_set_str,
.set_int = __ctsvc_group_relation_set_int,
.set_bool = NULL,
.set_lli = NULL,
.get_bool = __ctsvc_simple_contact_get_bool,
.get_lli = NULL,
.get_double = NULL,
- .set_str = NULL,
- .set_int = NULL,
+ .set_str = __ctsvc_simple_contact_set_str,
+ .set_int = __ctsvc_simple_contact_set_int,
.set_bool = NULL,
.set_lli = NULL,
.set_double = NULL,
return CONTACTS_ERROR_NONE;
}
+static int __ctsvc_simple_contact_set_int(contacts_record_h record, unsigned int property_id, int value)
+{
+ ctsvc_simple_contact_s *contact = (ctsvc_simple_contact_s *)record;
+
+ switch(property_id) {
+ case CTSVC_PROPERTY_CONTACT_ID:
+ contact->contact_id = value;
+ break;
+ case CTSVC_PROPERTY_CONTACT_DISPLAY_SOURCE_DATA_ID:
+ contact->display_source_type = value;
+ break;
+ case CTSVC_PROPERTY_CONTACT_PERSON_ID:
+ contact->person_id = value;
+ break;
+ case CTSVC_PROPERTY_CONTACT_ADDRESSBOOK_ID:
+ RETVM_IF(0 < contact->contact_id, CONTACTS_ERROR_INVALID_PARAMETER,
+ "Invalide parameter : property_id(%d) is a read-only value (contact)", property_id);
+ contact->addressbook_id = value;
+ break;
+ default:
+ CTS_ERR("Invalid parameter : property_id(%d) is not supported in value(simple contact)", property_id);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
static int __ctsvc_name_set_int(contacts_record_h record, unsigned int property_id, int value)
{
ctsvc_name_s *name = (ctsvc_name_s *)record;
}
+static int __ctsvc_simple_contact_set_str(contacts_record_h record, unsigned int property_id, const char* str)
+{
+ ctsvc_simple_contact_s *contact = (ctsvc_simple_contact_s *)record;
+
+ switch(property_id) {
+ case CTSVC_PROPERTY_CONTACT_DISPLAY_NAME:
+ FREEandSTRDUP(contact->display_name, str);
+ break;
+/*
+ CTS_ERR("Invalid parameter : property_id(%d) is a read-only value (contact)", property_id);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+*/
+ case CTSVC_PROPERTY_CONTACT_RINGTONE:
+ FREEandSTRDUP(contact->ringtone_path, str);
+ break;
+ case CTSVC_PROPERTY_CONTACT_IMAGE_THUMBNAIL:
+ FREEandSTRDUP(contact->image_thumbnail_path, str);
+ break;
+ case CTSVC_PROPERTY_CONTACT_UID:
+ FREEandSTRDUP(contact->uid, str);
+ break;
+ case CTSVC_PROPERTY_CONTACT_VIBRATION:
+ FREEandSTRDUP(contact->vibration, str);
+ break;
+ case CTSVC_PROPERTY_CONTACT_MESSAGE_ALERT:
+ FREEandSTRDUP(contact->message_alert, str);
+ break;
+ default :
+ CTS_ERR("Invalid parameter : property_id(%d) is not supported in value(simple_contact)", property_id);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
static int __ctsvc_name_set_str(contacts_record_h record, unsigned int property_id, const char* str)
{
ctsvc_name_s *name = (ctsvc_name_s *)record;
return CONTACTS_ERROR_NONE;
}
+static int __ctsvc_group_relation_set_str(contacts_record_h record, unsigned int property_id, const char* str)
+{
+ ctsvc_group_relation_s *group_relation = (ctsvc_group_relation_s *)record;
+
+ switch(property_id) {
+ case CTSVC_PROPERTY_GROUP_RELATION_GROUP_NAME:
+ FREEandSTRDUP(group_relation->group_name, str);
+ break;
+/*
+ CTS_ERR("Invalid parameter : property_id(%d) is a read-only value (group_relation)", property_id);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+*/
+ default :
+ CTS_ERR("Invalid parameter : property_id(%d) is not supported in value(group_relation)", property_id);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
static int __ctsvc_activity_set_str(contacts_record_h record, unsigned int property_id, const char* str)
{
ctsvc_activity_s *activity = (ctsvc_activity_s *)record;
return CONTACTS_ERROR_NONE;
}
+static int __ctsvc_event_get_bool(contacts_record_h record, unsigned int property_id, bool *value)
+{
+ ctsvc_event_s *event = (ctsvc_event_s *)record;
+ switch (property_id) {
+ case CTSVC_PROPERTY_EVENT_IS_LEAP_MONTH: /* deprecated */
+ *value = event->is_leap_month;
+ break;
+ default:
+ CTS_ERR("Invalid parameter : property_id(0x%x) is not supported in value(event)", property_id);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
static int __ctsvc_image_get_bool(contacts_record_h record, unsigned int property_id, bool *value)
{
ctsvc_image_s *image = (ctsvc_image_s *)record;
return CONTACTS_ERROR_NONE;
}
+static int __ctsvc_event_set_bool(contacts_record_h record, unsigned int property_id, bool value)
+{
+ ctsvc_event_s *event = (ctsvc_event_s *)record;
+
+ switch(property_id) {
+ case CTSVC_PROPERTY_EVENT_IS_LEAP_MONTH: /* deprecated */
+ event->is_leap_month = value;
+ break;
+ default:
+ CTS_ERR("Invalid parameter : property_id(%d) is not supported in value(event)", property_id);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
static int __ctsvc_image_set_bool(contacts_record_h record, unsigned int property_id, bool value)
{
ctsvc_image_s *image = (ctsvc_image_s *)record;
static int __ctsvc_person_get_str_p(contacts_record_h record, unsigned int property_id, char** out_str);
static int __ctsvc_person_get_str(contacts_record_h record, unsigned int property_id, char** out_str);
static int __ctsvc_person_get_bool(contacts_record_h record, unsigned int property_id, bool *value);
+static int __ctsvc_person_set_int(contacts_record_h record, unsigned int property_id, int value);
static int __ctsvc_person_set_str(contacts_record_h record, unsigned int property_id, const char* str);
static int __ctsvc_person_set_bool(contacts_record_h record, unsigned int property_id, bool value);
.get_lli = NULL,
.get_double = NULL,
.set_str = __ctsvc_person_set_str,
- .set_int = NULL,
+ .set_int = __ctsvc_person_set_int,
.set_bool = __ctsvc_person_set_bool,
.set_lli = NULL,
.set_double = NULL,
return CONTACTS_ERROR_NONE;
}
+static int __ctsvc_person_set_int(contacts_record_h record, unsigned int property_id, int value)
+{
+ ctsvc_person_s *person = (ctsvc_person_s *)record;
+
+ switch(property_id) {
+ case CTSVC_PROPERTY_PERSON_DISPLAY_CONTACT_ID:
+ person->name_contact_id = value;
+ break;
+ case CTSVC_PROPERTY_PERSON_ID:
+ person->person_id = value;
+ break;
+ case CTSVC_PROPERTY_PERSON_LINK_COUNT:
+ person->link_count = value;
+ break;
+ default:
+ CTS_ERR("This field(0x%0x) is not supported in value(person)", property_id);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
static int __ctsvc_person_set_str(contacts_record_h record, unsigned int property_id, const char* str)
{
ctsvc_person_s *person = (ctsvc_person_s *)record;
static int __ctsvc_result_get_str_p(contacts_record_h record, unsigned int property_id, char** out_str);
static int __ctsvc_result_get_str(contacts_record_h record, unsigned int property_id, char** out_str);
static int __ctsvc_result_get_int(contacts_record_h record, unsigned int property_id, int* out_value);
+static int __ctsvc_result_get_bool(contacts_record_h record, unsigned int property_id, bool* out_value);
+static int __ctsvc_result_set_int(contacts_record_h record, unsigned int property_id, int value);
+static int __ctsvc_result_set_bool(contacts_record_h record, unsigned int property_id, bool value);
+static int __ctsvc_result_set_str(contacts_record_h record, unsigned int property_id, const char *str);
ctsvc_record_plugin_cb_s result_plugin_cbs = {
.create = __ctsvc_result_create,
.get_str = __ctsvc_result_get_str,
.get_str_p = __ctsvc_result_get_str_p,
.get_int = __ctsvc_result_get_int,
- .get_bool = NULL,
+ .get_bool = __ctsvc_result_get_bool,
.get_lli = NULL,
.get_double = NULL,
- .set_str = NULL,
- .set_int = NULL,
- .set_bool = NULL,
+ .set_str = __ctsvc_result_set_str,
+ .set_int = __ctsvc_result_set_int,
+ .set_bool = __ctsvc_result_set_bool,
.set_lli = NULL,
.set_double = NULL,
.add_child_record = NULL,
return CONTACTS_ERROR_NO_DATA;
}
+static int __ctsvc_result_set_int(contacts_record_h record, unsigned int property_id, int value)
+{
+ ctsvc_result_s* result = (ctsvc_result_s *)record;
+ GSList *cursor;
+ ctsvc_result_value_s *data;
+
+ /* TODO: check the value type of property_id is int */
+ for (cursor = result->values;cursor;cursor=cursor->next) {
+ data = cursor->data;
+ if (data->property_id == property_id) {
+ if (data->type == CTSVC_VIEW_DATA_TYPE_INT) {
+#ifdef _CONTACTS_IPC_SERVER
+ if (property_id == CTSVC_PROPERTY_PHONELOG_SIM_SLOT_NO)
+ data->value.i = ctsvc_server_sim_get_sim_slot_no_by_info_id(value);
+ else
+#endif /* _CONTACTS_IPC_SERVER */
+ data->value.i = value;
+ return CONTACTS_ERROR_NONE;
+ }
+ else {
+ CTS_ERR("use another get_type API, (type : %d)", data->type);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ data = calloc(1, sizeof(ctsvc_result_value_s));
+ if (NULL == data) {
+ CTS_ERR("calloc() Fail");
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ data->property_id = property_id;
+ data->type = CTSVC_VIEW_DATA_TYPE_INT;
+#ifdef _CONTACTS_IPC_SERVER
+ if (property_id == CTSVC_PROPERTY_PHONELOG_SIM_SLOT_NO)
+ data->value.i = ctsvc_server_sim_get_sim_slot_no_by_info_id(value);
+ else
+#endif /* _CONTACTS_IPC_SERVER */
+ data->value.i = value;
+ result->values = g_slist_append(result->values, (void*)data);
+ return CONTACTS_ERROR_NONE;
+}
+
+static int __ctsvc_result_set_bool(contacts_record_h record, unsigned int property_id, bool value)
+{
+ ctsvc_result_s* result = (ctsvc_result_s *)record;
+ GSList *cursor;
+ ctsvc_result_value_s *data;
+
+ /* TODO: check the value type of property_id is int */
+ for (cursor = result->values;cursor;cursor=cursor->next) {
+ data = cursor->data;
+ if (data->property_id == property_id) {
+ if (data->type == CTSVC_VIEW_DATA_TYPE_BOOL) {
+ data->value.b = value;
+ return CONTACTS_ERROR_NONE;
+ }
+ else {
+ CTS_ERR("use another get_type API, (type : %d)", data->type);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ data = calloc(1, sizeof(ctsvc_result_value_s));
+ if (NULL == data) {
+ CTS_ERR("calloc() Fail");
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ data->property_id = property_id;
+ data->type = CTSVC_VIEW_DATA_TYPE_BOOL;
+ data->value.i = value;
+ result->values = g_slist_append(result->values, (void*)data);
+ return CONTACTS_ERROR_NONE;
+}
+
+static int __ctsvc_result_set_str(contacts_record_h record, unsigned int property_id, const char *str)
+{
+ ctsvc_result_s* result = (ctsvc_result_s *)record;
+ GSList *cursor;
+ ctsvc_result_value_s *data;
+ char *full_path = NULL;
+ int str_len;
+
+ /* TODO: check the value type of property_id is int */
+ for (cursor = result->values;cursor;cursor=cursor->next) {
+ data = cursor->data;
+ if (data->property_id == property_id) {
+ if (data->type == CTSVC_VIEW_DATA_TYPE_STR) {
+ switch (property_id) {
+ case CTSVC_PROPERTY_PERSON_IMAGE_THUMBNAIL:
+ case CTSVC_PROPERTY_CONTACT_IMAGE_THUMBNAIL:
+ if (str) {
+ str_len = strlen(CTSVC_CONTACT_IMG_FULL_LOCATION) + strlen(str) + 2;
+ full_path = calloc(1, str_len);
+ if (NULL == full_path) {
+ CTS_ERR("calloc() Fail");
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ snprintf(full_path, str_len, "%s/%s", CTSVC_CONTACT_IMG_FULL_LOCATION, str);
+ }
+ free(data->value.s);
+ data->value.s = full_path;
+ return CONTACTS_ERROR_NONE;
+ default:
+ FREEandSTRDUP(data->value.s, str);
+ return CONTACTS_ERROR_NONE;
+ }
+ }
+ else {
+ CTS_ERR("use another get_type API, (type : %d)", data->type);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ data = calloc(1, sizeof(ctsvc_result_value_s));
+ if (NULL == data) {
+ CTS_ERR("calloc() Fail");
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ data->property_id = property_id;
+ data->type = CTSVC_VIEW_DATA_TYPE_STR;
+ switch (property_id) {
+ case CTSVC_PROPERTY_PERSON_IMAGE_THUMBNAIL:
+ case CTSVC_PROPERTY_CONTACT_IMAGE_THUMBNAIL:
+ if (str) {
+ str_len = strlen(CTSVC_CONTACT_IMG_FULL_LOCATION) + strlen(str) + 2;
+ full_path = calloc(1, str_len);
+ if (NULL == full_path) {
+ CTS_ERR("calloc() Fail");
+ free(data);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ snprintf(full_path, str_len, "%s/%s", CTSVC_CONTACT_IMG_FULL_LOCATION, str);
+ }
+ free(data->value.s);
+ data->value.s = full_path;
+ break;
+ default:
+ data->value.s = SAFE_STRDUP(str);
+ break;
+ }
+
+ result->values = g_slist_append(result->values, (void*)data);
+ return CONTACTS_ERROR_NONE;
+}
+
+static int __ctsvc_result_get_bool(contacts_record_h record, unsigned int property_id, bool* out_value)
+{
+ ctsvc_result_s* result = (ctsvc_result_s *)record;
+ GSList *cursor;
+ for (cursor = result->values;cursor;cursor=cursor->next) {
+ ctsvc_result_value_s *data = cursor->data;
+ if (data->property_id == property_id) {
+ if (data->type == CTSVC_VIEW_DATA_TYPE_BOOL) {
+ *out_value = data->value.b;
+ return CONTACTS_ERROR_NONE;
+ }
+ else {
+ CTS_ERR("use another get_type API, (type : %d)", data->type);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ return CONTACTS_ERROR_NO_DATA;
+}
+
static int __ctsvc_sdn_get_int(contacts_record_h record, unsigned int property_id, int *out);
static int __ctsvc_sdn_get_str(contacts_record_h record, unsigned int property_id, char** out_str);
static int __ctsvc_sdn_get_str_p(contacts_record_h record, unsigned int property_id, char** out_str);
+static int __ctsvc_sdn_set_int(contacts_record_h record, unsigned int property_id, int value);
+static int __ctsvc_sdn_set_str(contacts_record_h record, unsigned int property_id, const char* str);
ctsvc_record_plugin_cb_s sdn_plugin_cbs = {
.create = __ctsvc_sdn_create,
.get_bool = NULL,
.get_lli = NULL,
.get_double = NULL,
- .set_str = NULL,
- .set_int = NULL,
+ .set_str = __ctsvc_sdn_set_str,
+ .set_int = __ctsvc_sdn_set_int,
.set_bool = NULL,
.set_lli = NULL,
.set_double = NULL,
return __ctsvc_sdn_get_str_real(record, property_id, out_str, true);
}
+static int __ctsvc_sdn_set_int(contacts_record_h record, unsigned int property_id, int value)
+{
+ ctsvc_sdn_s* sdn = (ctsvc_sdn_s*)record;
+
+ switch(property_id) {
+ case CTSVC_PROPERTY_SDN_ID:
+ sdn->id = value;
+ break;
+ case CTSVC_PROPERTY_SDN_SIM_SLOT_NO:
+ sdn->sim_slot_no = value;
+ break;
+ default:
+ CTS_ERR("This field(%d) is not supported in value(sdn)", property_id);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
+static int __ctsvc_sdn_set_str(contacts_record_h record, unsigned int property_id, const char* str)
+{
+ ctsvc_sdn_s* sdn = (ctsvc_sdn_s*)record;
+
+ switch(property_id) {
+ case CTSVC_PROPERTY_SDN_NAME:
+ FREEandSTRDUP(sdn->name, str);
+ break;
+ case CTSVC_PROPERTY_SDN_NUMBER:
+ FREEandSTRDUP(sdn->number, str);
+ break;
+ default :
+ CTS_ERR("This field(%d) is not supported in value(sdn)", property_id);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
static int __ctsvc_speeddial_get_str(contacts_record_h record, unsigned int property_id, char** out_str);
static int __ctsvc_speeddial_get_str_p(contacts_record_h record, unsigned int property_id, char** out_str);
static int __ctsvc_speeddial_set_int(contacts_record_h record, unsigned int property_id, int value);
+static int __ctsvc_speeddial_set_str(contacts_record_h record, unsigned int property_id, const char* str);
ctsvc_record_plugin_cb_s speeddial_plugin_cbs = {
.get_bool = NULL,
.get_lli = NULL,
.get_double = NULL,
- .set_str = NULL,
+ .set_str = __ctsvc_speeddial_set_str,
.set_int = __ctsvc_speeddial_set_int,
.set_bool = NULL,
.set_lli = NULL,
return CONTACTS_ERROR_NONE;
}
+static int __ctsvc_speeddial_set_str(contacts_record_h record, unsigned int property_id, const char* str)
+{
+ ctsvc_speeddial_s *speeddial = (ctsvc_speeddial_s*)record;
+
+ switch(property_id) {
+ case CTSVC_PROPERTY_SPEEDDIAL_DISPLAY_NAME:
+ FREEandSTRDUP(speeddial->display_name, str);
+ break;
+ case CTSVC_PROPERTY_SPEEDDIAL_NUMBER:
+ FREEandSTRDUP(speeddial->number, str);
+ break;
+ case CTSVC_PROPERTY_SPEEDDIAL_IMAGE_THUMBNAIL:
+ FREEandSTRDUP(speeddial->image_thumbnail_path, str);
+ break;
+ case CTSVC_PROPERTY_SPEEDDIAL_NUMBER_LABEL:
+ FREEandSTRDUP(speeddial->label, str);
+ break;
+ default :
+ CTS_ERR("This field(%d) is not supported in value(speeddial)", property_id);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ return CONTACTS_ERROR_NONE;
+}