diff options
Diffstat (limited to 'src/contacts_company.c')
-rwxr-xr-x | src/contacts_company.c | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/src/contacts_company.c b/src/contacts_company.c new file mode 100755 index 0000000..7bdcd17 --- /dev/null +++ b/src/contacts_company.c @@ -0,0 +1,125 @@ +/* + * 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 <tizen.h> +#include <contacts.h> +#include <contacts-svc.h> +#include <contacts_private.h> +#include <stdlib.h> +#include <string.h> +#include <dlog.h> + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "TIZEN_N_CONTACTS" +#define LOG_MODE (1) + +int contact_company_create(contact_company_h* company) +{ + if(company == 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_COMPANY); + if(ret == NULL) { + LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY); + return CONTACTS_ERROR_OUT_OF_MEMORY; + } + *company = (contact_company_h)ret; + + return CONTACTS_ERROR_NONE; +} + +int contact_company_destroy(contact_company_h company) +{ + if(company == 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*)company) == 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_company_get_detail(contact_company_h company, contact_company_detail_e detail_type, char** data) +{ + if(company == NULL || data == NULL) { + LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER); + return CONTACTS_ERROR_INVALID_PARAMETER; + } + CTSvalue * CTScompany = (CTSvalue *)company; + *data = NULL; + switch(detail_type) + { + case CONTACT_COMPANY_DETAIL_NAME: + *data= _contacts_safe_strdup(contacts_svc_value_get_str(CTScompany, CTS_COMPANY_VAL_NAME_STR)); + break; + case CONTACT_COMPANY_DETAIL_DEPARTMENT: + *data = _contacts_safe_strdup(contacts_svc_value_get_str(CTScompany, CTS_COMPANY_VAL_DEPARTMENT_STR)); + break; + case CONTACT_COMPANY_DETAIL_JOBTITLE: + *data = _contacts_safe_strdup(contacts_svc_value_get_str(CTScompany, CTS_COMPANY_VAL_JOB_TITLE_STR)); + break; + case CONTACT_COMPANY_DETAIL_ASSISTANT: + *data = _contacts_safe_strdup(contacts_svc_value_get_str(CTScompany, CTS_COMPANY_VAL_ASSISTANT_NAME_STR)); + break; + default: + LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER); + return CONTACTS_ERROR_INVALID_PARAMETER; + break; + } + + return CONTACTS_ERROR_NONE; +} + +int contact_company_set_detail(contact_company_h company, contact_company_detail_e detail_type, const char* data) +{ + if(company == NULL || data == NULL) { + LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER); + return CONTACTS_ERROR_INVALID_PARAMETER; + } + CTSvalue * CTScompany = (CTSvalue *)company; + int ret = CTS_ERR_ARG_INVALID; + switch(detail_type) + { + case CONTACT_COMPANY_DETAIL_NAME: + ret= contacts_svc_value_set_str(CTScompany, CTS_COMPANY_VAL_NAME_STR,data); + break; + case CONTACT_COMPANY_DETAIL_DEPARTMENT: + ret=contacts_svc_value_set_str(CTScompany, CTS_COMPANY_VAL_DEPARTMENT_STR,data); + break; + case CONTACT_COMPANY_DETAIL_JOBTITLE: + ret=contacts_svc_value_set_str(CTScompany, CTS_COMPANY_VAL_JOB_TITLE_STR,data); + break; + case CONTACT_COMPANY_DETAIL_ASSISTANT: + ret=contacts_svc_value_set_str(CTScompany, CTS_COMPANY_VAL_ASSISTANT_NAME_STR,data); + break; + } + if(ret == CTS_SUCCESS) { + return CONTACTS_ERROR_NONE; + } + + LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER); + return CONTACTS_ERROR_INVALID_PARAMETER; +} + |