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
135
136
137
138
139
140
141
|
/*
* 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 <stdlib.h>
#include <contacts_private.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_messenger_create(contact_messenger_h* messenger)
{
CONTACTS_NULL_ARG_CHECK(messenger);
CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_MESSENGER);
if(ret == NULL) {
LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
return CONTACTS_ERROR_OUT_OF_MEMORY;
}
*messenger = (contact_messenger_h)ret;
return CONTACTS_ERROR_NONE;
}
int contact_messenger_destroy(contact_messenger_h messenger)
{
CONTACTS_NULL_ARG_CHECK(messenger);
if(contacts_svc_value_free((CTSvalue*)messenger) == 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_messenger_get_id(contact_messenger_h messenger, char** id)
{
CONTACTS_NULL_ARG_CHECK(messenger);
CONTACTS_NULL_ARG_CHECK(id);
*id = NULL;
*id = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)messenger, CTS_MESSENGER_VAL_IM_ID_STR));
return CONTACTS_ERROR_NONE;
}
int contact_messenger_set_id(contact_messenger_h messenger, const char* id)
{
CONTACTS_NULL_ARG_CHECK(messenger);
CONTACTS_NULL_ARG_CHECK(id);
if(contacts_svc_value_set_str((CTSvalue*)messenger, CTS_MESSENGER_VAL_IM_ID_STR, id) == 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_messenger_get_type(contact_messenger_h messenger, contact_messenger_type_e *type)
{
CONTACTS_NULL_ARG_CHECK(messenger);
CONTACTS_NULL_ARG_CHECK(type);
*type = contacts_svc_value_get_int((CTSvalue*)messenger, CTS_MESSENGER_VAL_TYPE_INT);
return CONTACTS_ERROR_NONE;
}
int contact_messenger_set_type(contact_messenger_h messenger, contact_messenger_type_e type)
{
CONTACTS_NULL_ARG_CHECK(messenger);
if(contacts_svc_value_set_int((CTSvalue*)messenger, CTS_MESSENGER_VAL_TYPE_INT, type) == 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_messenger_iterator_next(contact_messenger_iterator_h* messenger_iterator, contact_messenger_h* messenger)
{
CONTACTS_NULL_ARG_CHECK(messenger_iterator);
CONTACTS_NULL_ARG_CHECK(messenger);
*messenger = NULL;
GSList* gslist = (GSList*)*messenger_iterator;
gslist = _contacts_gslist_next_until_not_deleted(gslist);
if(gslist != NULL)
{
*messenger = (contact_messenger_h)(gslist)->data;
gslist = g_slist_next(gslist);
*messenger_iterator = (contact_messenger_iterator_h)gslist;
return CONTACTS_ERROR_NONE;
}
*messenger_iterator = NULL;
return CONTACTS_ERROR_ITERATOR_END;
}
bool contact_messenger_iterator_has_next(contact_messenger_iterator_h messenger_iterator)
{
if(messenger_iterator == NULL) {
return false;
}
GSList* gslist = (GSList*)messenger_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;
}
|