/* * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include #include void _contacts_set_query_person_struct(contact_query_name_s* contact, CTSvalue* value) { contact->contact_db_id = contacts_svc_value_get_int(value, CTS_LIST_CONTACT_ID_INT); contact->first_name = _contacts_safe_strdup(contacts_svc_value_get_str(value, CTS_LIST_CONTACT_FIRST_STR)); contact->last_name = _contacts_safe_strdup(contacts_svc_value_get_str(value, CTS_LIST_CONTACT_LAST_STR)); contact->display_name = _contacts_safe_strdup(contacts_svc_value_get_str(value, CTS_LIST_CONTACT_DISPLAY_STR)); contact->address_book_db_id = contacts_svc_value_get_int(value, CTS_LIST_CONTACT_ADDRESSBOOK_ID_INT); contact->contact_image_path = _contacts_safe_strdup(contacts_svc_value_get_str(value, CTS_LIST_CONTACT_IMG_PATH_STR)); } void _contacts_free_query_person_struct_member_only(contact_query_name_s* person) { person->contact_db_id = -1; _contacts_safe_free(person->first_name); _contacts_safe_free(person->last_name); _contacts_safe_free(person->display_name); _contacts_safe_free(person->contact_image_path); } void _contacts_free_query_number_struct_member_only(contact_query_number_s* contact) { contact->contact_db_id = -1; _contacts_safe_free(contact->first_name); _contacts_safe_free(contact->last_name); _contacts_safe_free(contact->display_name); _contacts_safe_free(contact->phone_number); _contacts_safe_free(contact->contact_image_path); } void _contacts_free_query_email_struct_member_only(contact_query_email_s* email) { email->contact_db_id = -1; _contacts_safe_free(email->first_name); _contacts_safe_free(email->last_name); _contacts_safe_free(email->display_name); _contacts_safe_free(email->contact_image_path); _contacts_safe_free(email->email_address); } void _contacts_free_query_person_struct_all(gpointer data, gpointer user_data) { if(data == NULL) return; contact_query_name_s* person = (contact_query_name_s*)data; person->contact_db_id = -1; _contacts_safe_free(person->first_name); _contacts_safe_free(person->last_name); _contacts_safe_free(person->display_name); _contacts_safe_free(person->contact_image_path); _contacts_safe_free(data); } void _contacts_free_query_number_struct_all(gpointer data, gpointer user_data) { if(data == NULL) return; contact_query_number_s* person = (contact_query_number_s*)data; person->contact_db_id = -1; _contacts_safe_free(person->first_name); _contacts_safe_free(person->last_name); _contacts_safe_free(person->display_name); _contacts_safe_free(person->contact_image_path); _contacts_safe_free(person->phone_number); _contacts_safe_free(data); } void _contacts_free_query_email_struct_all(gpointer data, gpointer user_data) { if(data == NULL) return; contact_query_email_s* email = (contact_query_email_s*)data; email->contact_db_id = -1; _contacts_safe_free(email->first_name); _contacts_safe_free(email->last_name); _contacts_safe_free(email->display_name); _contacts_safe_free(email->contact_image_path); _contacts_safe_free(email->email_address); _contacts_safe_free(data); } void _contacts_free_query_group_struct_member_only(contacts_query_group_s* group) { group->group_db_id = -1; _contacts_safe_free(group->group_name); _contacts_safe_free(group->group_ringtonepath); } void _contacts_free_query_group_struct_all(gpointer data, gpointer user_data) { if(data == NULL) return; contacts_query_group_s* group = (contacts_query_group_s*)data; group->group_db_id = -1; _contacts_safe_free(group->group_name); _contacts_safe_free(group->group_ringtonepath); _contacts_safe_free(data); } void _contacts_set_query_address_book_struct(contacts_query_address_book_s* addressbook, CTSvalue* value) { addressbook->address_book_db_id = contacts_svc_value_get_int(value, CTS_LIST_ADDRESSBOOK_ID_INT); addressbook->address_book_name = _contacts_safe_strdup(contacts_svc_value_get_str(value, CTS_LIST_ADDRESSBOOK_NAME_STR)); addressbook->address_book_type = contacts_svc_value_get_int(value, CTS_LIST_ADDRESSBOOK_ACC_TYPE_INT); addressbook->account_db_id = contacts_svc_value_get_int(value, CTS_LIST_ADDRESSBOOK_ACC_ID_INT); addressbook->address_book_is_read_only = contacts_svc_value_get_int(value, CTS_LIST_ADDRESSBOOK_MODE_INT); } void _contacts_free_query_address_book_struct_member_only(contacts_query_address_book_s* addressbook) { addressbook->address_book_db_id = 0; _contacts_safe_free(addressbook->address_book_name); addressbook->address_book_type = 1; } GSList* _contacts_gslist_next_until_not_deleted(GSList* list) { if(list == NULL) return NULL; GSList* gslist = list; CTSvalue* value = gslist->data; if(value == NULL) return NULL; while( (contacts_svc_value_get_bool(value, CTS_NUM_VAL_DELETE_BOOL) == true) && (gslist != NULL) ) { gslist = g_slist_next(gslist); if(gslist != NULL) { value = gslist->data; /* codes below is for SVACE passed */ if(value == NULL) { gslist = NULL; break; } } } return gslist; }