1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
/*
* 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_name_create(contact_name_h* name)
{
if(name == 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_NAME);
if(ret == NULL) {
LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
return CONTACTS_ERROR_OUT_OF_MEMORY;
}
*name = (contact_name_h)ret;
return CONTACTS_ERROR_NONE;
}
int contact_name_destroy(contact_name_h name)
{
if(name == 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*)name) == 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_name_get_detail(contact_name_h name, contact_name_detail_e detail_type, char** data)
{
if(name == NULL || data == NULL) {
LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
return CONTACTS_ERROR_INVALID_PARAMETER;
}
*data = NULL;
switch(detail_type)
{
case CONTACT_NAME_DETAIL_DISPLAY:
*data = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)name, CTS_NAME_VAL_DISPLAY_STR));
break;
case CONTACT_NAME_DETAIL_FIRST:
*data = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)name, CTS_NAME_VAL_FIRST_STR));
break;
case CONTACT_NAME_DETAIL_LAST:
*data = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)name, CTS_NAME_VAL_LAST_STR));
break;
case CONTACT_NAME_DETAIL_MIDDLE:
*data = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)name, CTS_NAME_VAL_ADDITION_STR));
break;
case CONTACT_NAME_DETAIL_SUFFIX:
*data = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)name, CTS_NAME_VAL_SUFFIX_STR));
break;
case CONTACT_NAME_DETAIL_TITLE:
*data = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)name, CTS_NAME_VAL_PREFIX_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_name_set_detail(contact_name_h name, contact_name_detail_e detail_type, const char* data)
{
if(name == NULL || data == NULL) {
LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
return CONTACTS_ERROR_INVALID_PARAMETER;
}
int ret = CTS_ERR_ARG_INVALID;
switch(detail_type)
{
case CONTACT_NAME_DETAIL_DISPLAY:
ret = contacts_svc_value_set_str((CTSvalue*)name, CTS_NAME_VAL_DISPLAY_STR, data);
break;
case CONTACT_NAME_DETAIL_FIRST:
ret = contacts_svc_value_set_str((CTSvalue*)name, CTS_NAME_VAL_FIRST_STR, data);
break;
case CONTACT_NAME_DETAIL_LAST:
ret = contacts_svc_value_set_str((CTSvalue*)name, CTS_NAME_VAL_LAST_STR, data);
break;
case CONTACT_NAME_DETAIL_MIDDLE:
ret = contacts_svc_value_set_str((CTSvalue*)name, CTS_NAME_VAL_ADDITION_STR, data);
break;
case CONTACT_NAME_DETAIL_SUFFIX:
ret = contacts_svc_value_set_str((CTSvalue*)name, CTS_NAME_VAL_SUFFIX_STR, data);
break;
case CONTACT_NAME_DETAIL_TITLE:
ret = contacts_svc_value_set_str((CTSvalue*)name, CTS_NAME_VAL_PREFIX_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;
}
|