/* * 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 #include #ifdef LOG_TAG #undef LOG_TAG #endif #define LOG_TAG "TIZEN_N_CONTACTS" #define LOG_MODE (1) int contact_nickname_create(contact_nickname_h* nickname) { if(nickname == NULL) { LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER); return CONTACTS_ERROR_INVALID_PARAMETER; } CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_NICKNAME); if(ret == NULL) { LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY); return CONTACTS_ERROR_OUT_OF_MEMORY; } *nickname = (contact_nickname_h)ret; return CONTACTS_ERROR_NONE; } int contact_nickname_destroy(contact_nickname_h nickname) { if(nickname == NULL) { LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER); return CONTACTS_ERROR_INVALID_PARAMETER; } if(contacts_svc_value_free((CTSvalue*)nickname) == CTS_SUCCESS) { return CONTACTS_ERROR_NONE; } LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER); return CONTACTS_ERROR_INVALID_PARAMETER; } int contact_nickname_get_nickname(contact_nickname_h nickname, char** data) { if(nickname == NULL || data == NULL) { LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER); return CONTACTS_ERROR_INVALID_PARAMETER; } *data = NULL; *data = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)nickname, CTS_NICKNAME_VAL_NAME_STR)); return CONTACTS_ERROR_NONE; } int contact_nickname_set_nickname(contact_nickname_h nickname, const char* data) { if(nickname == NULL || data == NULL) { LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER); return CONTACTS_ERROR_INVALID_PARAMETER; } if(contacts_svc_value_set_str((CTSvalue*)nickname, CTS_NICKNAME_VAL_NAME_STR, data) == CTS_SUCCESS) { return CONTACTS_ERROR_NONE; } LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER); return CONTACTS_ERROR_INVALID_PARAMETER; } int contact_nickname_iterator_next(contact_nickname_iterator_h* nickname_iterator, contact_nickname_h* nickname) { if(nickname_iterator == NULL || nickname == NULL) { LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER); return CONTACTS_ERROR_INVALID_PARAMETER; } *nickname = NULL; GSList* gslist = (GSList*)*nickname_iterator; gslist = _contacts_gslist_next_until_not_deleted(gslist); if(gslist != NULL) { *nickname = (contact_nickname_h)(gslist)->data; gslist = g_slist_next(gslist); *nickname_iterator = (contact_nickname_iterator_h)gslist; return CONTACTS_ERROR_NONE; } *nickname_iterator = NULL; return CONTACTS_ERROR_ITERATOR_END; } bool contact_nickname_iterator_has_next(contact_nickname_iterator_h nickname_iterator) { if(nickname_iterator == NULL) { return false; } GSList* gslist = (GSList*)nickname_iterator; CTSvalue* value = (CTSvalue*)gslist->data; if(value == NULL) { return false; } gslist = _contacts_gslist_next_until_not_deleted(gslist); if(gslist == NULL) { return false; } return true; }