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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
/*
* 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>
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;
}
|