3 * Copyright 2012 Samsung Electronics Co., Ltd
5 * Licensed under the Flora License, Version 1.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 void __cal_query_get_caltime_day(const struct tm* date, bool all_day, calendar_time_s* caltime)
23 caltime->type = CALENDAR_TIME_LOCALTIME;
24 caltime->time.date.year = date->tm_year + 1900;
25 caltime->time.date.month = date->tm_mon + 1;
26 caltime->time.date.mday = date->tm_mday;
28 long long int lli_start = 0;
29 cal_util_convert_tm_to_lli(NULL, date, &lli_start);
30 caltime->type = CALENDAR_TIME_UTIME;
31 caltime->time.utime = lli_start;
35 void __cal_query_add_int_equal_condition(calendar_filter_h filter, unsigned int property_id, int value)
37 calendar_error_e error = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
38 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
40 error = calendar_filter_add_int(filter, property_id, CALENDAR_MATCH_EQUAL, value);
41 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
44 void __cal_query_set_date_range_condition(calendar_filter_h filter,
45 unsigned int time_property_id, const struct tm* date,
46 int direction, bool all_day)
48 calendar_time_s caltime_start = {0};
49 __cal_query_get_caltime_day(date, all_day, &caltime_start);
51 calendar_error_e error = CALENDAR_ERROR_NONE;
54 error = calendar_filter_add_caltime(
55 filter, time_property_id, CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, caltime_start);
57 error = calendar_filter_add_caltime(
58 filter, time_property_id, CALENDAR_MATCH_LESS_THAN, caltime_start);
60 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_caltime() is failed(%x)", error);
63 calendar_query_h cal_query_create_list_more_normal_query(
64 unsigned int time_property_id, const struct tm* start, int direction)
66 c_retv_if(start == NULL, NULL);
68 calendar_query_h query = NULL;
70 calendar_error_e error =
71 calendar_query_create(_calendar_instance_normal_calendar_book._uri, &query);
72 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_create() is failed(%x)", error);
74 calendar_filter_h filter;
76 error = calendar_filter_create(_calendar_instance_normal_calendar_book._uri, &filter);
77 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_create() is failed(%x)", error);
79 __cal_query_set_date_range_condition(filter, time_property_id, start, direction, false);
81 __cal_query_add_int_equal_condition(filter,
82 _calendar_instance_normal_calendar_book.calendar_book_visibility, 1);
84 error = calendar_query_set_filter(query, filter);
85 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_add_filter() is failed(%x)", error);
87 error = calendar_query_set_sort(query, time_property_id, direction > 0);
88 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_set_sort() is failed(%x)", error);
90 error = calendar_filter_destroy(filter);
91 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_destroy() is failed(%x)", error);
96 calendar_query_h cal_query_create_list_more_allday_query(
97 unsigned int time_property_id, const struct tm* start, int direction)
99 c_retv_if(start == NULL, NULL);
101 calendar_query_h query = NULL;
103 calendar_error_e error =
104 calendar_query_create(_calendar_instance_allday_calendar_book._uri, &query);
105 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_create() is failed(%x)", error);
107 calendar_filter_h filter;
109 error = calendar_filter_create(_calendar_instance_allday_calendar_book._uri, &filter);
110 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_create() is failed(%x)", error);
112 __cal_query_set_date_range_condition(filter, time_property_id, start, direction, true);
114 __cal_query_add_int_equal_condition(filter,
115 _calendar_instance_allday_calendar_book.calendar_book_visibility, 1);
117 error = calendar_query_set_filter(query, filter);
118 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_add_filter() is failed(%x)", error);
120 error = calendar_query_set_sort(query, time_property_id, direction > 0);
121 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_set_sort() is failed(%x)", error);
123 error = calendar_filter_destroy(filter);
124 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_destroy() is failed(%x)", error);
129 calendar_filter_h cal_query_create_not_completed_task_filter()
131 calendar_filter_h filter;
133 calendar_error_e error = calendar_filter_create(_calendar_todo_calendar_book._uri, &filter);
134 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_create() is failed(%x)", error);
136 error = calendar_filter_add_int(filter, _calendar_todo_calendar_book.todo_status,
137 CALENDAR_MATCH_EQUAL, CALENDAR_TODO_STATUS_NONE);
138 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
140 error = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_OR);
141 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
143 error = calendar_filter_add_int(filter, _calendar_todo_calendar_book.todo_status,
144 CALENDAR_MATCH_EQUAL, CALENDAR_TODO_STATUS_NEEDS_ACTION);
145 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
147 error = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_OR);
148 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
150 error = calendar_filter_add_int(filter, _calendar_todo_calendar_book.todo_status,
151 CALENDAR_MATCH_EQUAL, CALENDAR_TODO_STATUS_IN_PROCESS);
152 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
154 error = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
155 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
160 calendar_query_h cal_query_create_list_more_task_query(
161 const struct tm* start, int direction, bool include_completed)
163 c_retv_if(start == NULL, NULL);
165 calendar_query_h query = NULL;
167 calendar_error_e error = calendar_query_create(_calendar_todo_calendar_book._uri, &query);
168 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_create() is failed(%x)", error);
170 calendar_filter_h filter = NULL;
172 calendar_filter_h not_competed_filter = NULL;
174 error = calendar_filter_create(_calendar_todo_calendar_book._uri, &filter);
175 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_create() is failed(%x)", error);
177 __cal_query_set_date_range_condition(filter,
178 _calendar_todo_calendar_book.due_time, start, direction, false);
180 __cal_query_add_int_equal_condition(filter,
181 _calendar_todo_calendar_book.calendar_book_visibility, 1);
183 if (!include_completed) {
184 not_competed_filter = cal_query_create_not_completed_task_filter();
186 error = calendar_filter_add_filter(filter, not_competed_filter);
187 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_filter() is failed(%x)", error);
189 // todo: filter handle destroy!
192 error = calendar_query_set_filter(query, filter);
193 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_add_filter() is failed(%x)", error);
195 error = calendar_query_set_sort(query, _calendar_todo_calendar_book.due_time, direction > 0);
196 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_set_sort() is failed(%x)", error);
198 if (not_competed_filter) {
199 error = calendar_filter_destroy(not_competed_filter);
200 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_destroy() is failed(%x)", error);
203 error = calendar_filter_destroy(filter);
204 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_destroy() is failed(%x)", error);
209 calendar_query_h cal_query_create_list_range_query(const char* view_uri,
210 unsigned int start_time_property_id, unsigned int end_time_property_id,
211 const struct tm* start, const struct tm* end, bool all_day)
213 c_retv_if(start == NULL, NULL);
214 c_retv_if(end == NULL, NULL);
216 calendar_query_h query = NULL;
218 calendar_error_e error = calendar_query_create(view_uri, &query);
219 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_create() is failed(%x)", error);
221 calendar_time_s caltime_start = {0};
222 __cal_query_get_caltime_day(start, all_day, &caltime_start);
224 calendar_time_s caltime_end = {0};
225 __cal_query_get_caltime_day(end, all_day, &caltime_end);
227 calendar_filter_h filter;
229 error = calendar_filter_create(view_uri, &filter);
230 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_create() is failed(%x)", error);
232 error = calendar_filter_add_caltime(
233 filter, end_time_property_id, CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, caltime_start);
234 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_caltime() is failed(%x)", error);
236 error = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
237 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
239 error = calendar_filter_add_caltime(
240 filter, start_time_property_id, CALENDAR_MATCH_LESS_THAN_OR_EQUAL, caltime_end);
241 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_caltime() is failed(%x)", error);
243 error = calendar_query_set_filter(query, filter);
244 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_add_filter() is failed(%x)", error);
246 error = calendar_query_set_sort(query, start_time_property_id, true);
247 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_set_sort() is failed(%x)", error);
249 error = calendar_filter_destroy(filter);
250 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_destroy() is failed(%x)", error);
255 calendar_query_h cal_query_create_due_date_task_list_query(struct tm *start, struct tm *end, Eina_Bool is_show_completed_task, _calendar_task_sort_type sort_type)
257 c_retv_if(!start, NULL);
258 c_retv_if(!end, NULL);
259 c_retv_if(sort_type <= _CALENDAR_TASK_SORT_TYPE_NONE, NULL);
260 c_retv_if(_CALENDAR_TASK_SORT_TYPE_MAX <= sort_type, NULL);
262 calendar_query_h query = NULL;
264 calendar_error_e error = CALENDAR_ERROR_NONE;
266 error = calendar_query_create(_calendar_todo_calendar_book._uri, &query);
267 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_create() is failed(%x)", error);
269 calendar_time_s caltime_start = {0};
270 calendar_time_s caltime_end = {0};
272 long long int lli_start = 0;
273 long long int lli_end = 0;
275 cal_util_convert_tm_to_lli(NULL, start, &lli_start);
276 cal_util_convert_tm_to_lli(NULL, end, &lli_end);
278 caltime_start.type = CALENDAR_TIME_UTIME;
279 caltime_start.time.utime = lli_start;
281 caltime_end.type = CALENDAR_TIME_UTIME;
282 caltime_end.time.utime = lli_end;
284 calendar_filter_h filter = NULL;
285 calendar_filter_h status_filter = NULL;
287 error = calendar_filter_create(_calendar_todo_calendar_book._uri, &filter);
288 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_create() is failed(%x)", error);
290 error = calendar_filter_add_caltime(filter, _calendar_todo_calendar_book.due_time, CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, caltime_start);
291 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_caltime() is failed(%x)", error);
293 error = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
294 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
296 error = calendar_filter_add_caltime(filter, _calendar_todo_calendar_book.due_time,CALENDAR_MATCH_LESS_THAN_OR_EQUAL, caltime_end);
297 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_caltime() is failed(%x)", error);
299 error = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
300 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
302 error = calendar_filter_add_int(filter, _calendar_todo_calendar_book.is_deleted, CALENDAR_MATCH_EQUAL, 0);
303 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
305 error = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
306 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
308 error = calendar_filter_add_int(filter, _calendar_todo_calendar_book.calendar_book_visibility, CALENDAR_MATCH_EQUAL, 1);
309 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
311 if (!is_show_completed_task) {
313 error = calendar_filter_create(_calendar_todo_calendar_book._uri, &status_filter);
314 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_create() is failed(%x)", error);
316 error = calendar_filter_add_int(status_filter, _calendar_todo_calendar_book.todo_status, CALENDAR_MATCH_EQUAL, CALENDAR_TODO_STATUS_NONE);
317 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
319 error = calendar_filter_add_operator(status_filter, CALENDAR_FILTER_OPERATOR_OR);
320 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
322 error = calendar_filter_add_int(status_filter, _calendar_todo_calendar_book.todo_status, CALENDAR_MATCH_EQUAL, CALENDAR_TODO_STATUS_NEEDS_ACTION);
323 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
325 error = calendar_filter_add_operator(status_filter, CALENDAR_FILTER_OPERATOR_OR);
326 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
328 error = calendar_filter_add_int(status_filter, _calendar_todo_calendar_book.todo_status, CALENDAR_MATCH_EQUAL, CALENDAR_TODO_STATUS_IN_PROCESS);
329 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
331 error = calendar_filter_add_operator(status_filter, CALENDAR_FILTER_OPERATOR_OR);
332 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
334 error = calendar_filter_add_int(status_filter, _calendar_todo_calendar_book.todo_status, CALENDAR_MATCH_EQUAL, CALENDAR_TODO_STATUS_CANCELED);
335 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
337 error = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
338 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
340 error = calendar_filter_add_filter(filter, status_filter);
341 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_filter() is failed(%x)", error);
344 error = calendar_query_set_filter(query, filter);
345 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_set_filter() is failed(%x)", error);
348 case _CALENDAR_TASK_SORT_TYPE_DUEDATE_ASC:
349 error = calendar_query_set_sort(query, _calendar_todo_calendar_book.due_time, true);
351 case _CALENDAR_TASK_SORT_TYPE_DUEDATE_DES:
352 error = calendar_query_set_sort(query, _calendar_todo_calendar_book.due_time, false);
354 case _CALENDAR_TASK_SORT_TYPE_PRIORITY_ASC:
355 error = calendar_query_set_sort(query, _calendar_todo_calendar_book.priority, true);
357 case _CALENDAR_TASK_SORT_TYPE_PRIORITY_DES:
358 error = calendar_query_set_sort(query, _calendar_todo_calendar_book.priority, false);
360 case _CALENDAR_TASK_SORT_TYPE_STATUS_ASC:
361 error = calendar_query_set_sort(query, _calendar_todo_calendar_book.todo_status, true);
363 case _CALENDAR_TASK_SORT_TYPE_STATUS_DES:
364 error = calendar_query_set_sort(query, _calendar_todo_calendar_book.todo_status, false);
368 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_set_sort() is failed(%x)", error);
371 error = calendar_filter_destroy(status_filter);
372 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_destroy() is failed(%x)", error);
375 error = calendar_filter_destroy(filter);
376 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_destroy() is failed(%x)", error);
381 calendar_query_h cal_query_create_all_task_list_query(struct tm *start, struct tm *end, Eina_Bool is_show_completed_task, _calendar_task_sort_type sort_type)
383 c_retv_if(!start, NULL);
384 c_retv_if(!end, NULL);
385 c_retv_if(sort_type <= _CALENDAR_TASK_SORT_TYPE_NONE, NULL);
386 c_retv_if(_CALENDAR_TASK_SORT_TYPE_MAX <= sort_type, NULL);
388 calendar_query_h query = NULL;
390 calendar_error_e error = CALENDAR_ERROR_NONE;
392 error = calendar_query_create(_calendar_todo_calendar_book._uri, &query);
393 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_create() is failed(%x)", error);
395 calendar_time_s caltime_start = {0};
396 calendar_time_s caltime_end = {0};
398 long long int lli_start = 0;
399 long long int lli_end = 0;
401 cal_util_convert_tm_to_lli(NULL, start, &lli_start);
402 cal_util_convert_tm_to_lli(NULL, end, &lli_end);
404 caltime_start.type = CALENDAR_TIME_UTIME;
405 caltime_start.time.utime = lli_start;
407 caltime_end.type = CALENDAR_TIME_UTIME;
408 caltime_end.time.utime = lli_end;
410 calendar_filter_h filter = NULL;
411 calendar_filter_h status_filter = NULL;
413 error = calendar_filter_create(_calendar_todo_calendar_book._uri, &filter);
414 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_create() is failed(%x)", error);
416 error = calendar_filter_add_int(filter, _calendar_todo_calendar_book.is_deleted, CALENDAR_MATCH_EQUAL, 0);
417 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
419 error = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
420 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
422 error = calendar_filter_add_int(filter, _calendar_todo_calendar_book.calendar_book_visibility, CALENDAR_MATCH_EQUAL, 1);
423 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
425 if (!is_show_completed_task) {
427 error = calendar_filter_create(_calendar_todo_calendar_book._uri, &status_filter);
428 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_create() is failed(%x)", error);
430 error = calendar_filter_add_int(status_filter, _calendar_todo_calendar_book.todo_status, CALENDAR_MATCH_EQUAL, CALENDAR_TODO_STATUS_NONE);
431 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
433 error = calendar_filter_add_operator(status_filter, CALENDAR_FILTER_OPERATOR_OR);
434 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
436 error = calendar_filter_add_int(status_filter, _calendar_todo_calendar_book.todo_status, CALENDAR_MATCH_EQUAL, CALENDAR_TODO_STATUS_NEEDS_ACTION);
437 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
439 error = calendar_filter_add_operator(status_filter, CALENDAR_FILTER_OPERATOR_OR);
440 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
442 error = calendar_filter_add_int(status_filter, _calendar_todo_calendar_book.todo_status, CALENDAR_MATCH_EQUAL, CALENDAR_TODO_STATUS_IN_PROCESS);
443 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
445 error = calendar_filter_add_operator(status_filter, CALENDAR_FILTER_OPERATOR_OR);
446 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
448 error = calendar_filter_add_int(status_filter, _calendar_todo_calendar_book.todo_status, CALENDAR_MATCH_EQUAL, CALENDAR_TODO_STATUS_CANCELED);
449 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
451 error = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
452 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
454 error = calendar_filter_add_filter(filter, status_filter);
455 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_filter() is failed(%x)", error);
458 error = calendar_query_set_filter(query, filter);
459 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_set_filter() is failed(%x)", error);
462 case _CALENDAR_TASK_SORT_TYPE_DUEDATE_ASC:
463 error = calendar_query_set_sort(query, _calendar_todo_calendar_book.due_time, true);
465 case _CALENDAR_TASK_SORT_TYPE_DUEDATE_DES:
466 error = calendar_query_set_sort(query, _calendar_todo_calendar_book.due_time, false);
468 case _CALENDAR_TASK_SORT_TYPE_PRIORITY_ASC:
469 error = calendar_query_set_sort(query, _calendar_todo_calendar_book.priority, true);
471 case _CALENDAR_TASK_SORT_TYPE_PRIORITY_DES:
472 error = calendar_query_set_sort(query, _calendar_todo_calendar_book.priority, false);
474 case _CALENDAR_TASK_SORT_TYPE_STATUS_ASC:
475 error = calendar_query_set_sort(query, _calendar_todo_calendar_book.todo_status, true);
477 case _CALENDAR_TASK_SORT_TYPE_STATUS_DES:
478 error = calendar_query_set_sort(query, _calendar_todo_calendar_book.todo_status, false);
482 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_set_sort() is failed(%x)", error);
485 error = calendar_filter_destroy(status_filter);
486 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_destroy() is failed(%x)", error);
489 error = calendar_filter_destroy(filter);
490 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_destroy() is failed(%x)", error);
497 calendar_query_h cal_query_create_task_search_query(const char* keyword)
499 c_retv_if(!CAL_STRLEN(keyword), NULL);
501 calendar_query_h query = NULL;
503 calendar_error_e error = CALENDAR_ERROR_NONE;
505 calendar_filter_h visibility_filter = NULL;
507 error = calendar_filter_create(_calendar_todo_calendar_book._uri, &visibility_filter);
508 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_create() is failed(%x)", error);
510 error = calendar_filter_add_int(visibility_filter, _calendar_todo_calendar_book.calendar_book_visibility, CALENDAR_MATCH_EQUAL, 1);
511 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
513 calendar_filter_h filter = NULL;
515 error = calendar_query_create(_calendar_todo_calendar_book._uri, &query);
516 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_create() is failed(%x)", error);
518 error = calendar_filter_create(_calendar_todo_calendar_book._uri, &filter);
519 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_create() is failed(%x)", error);
521 error = calendar_filter_add_str(filter, _calendar_todo_calendar_book.summary, CALENDAR_MATCH_CONTAINS, keyword);
522 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_str() is failed(%x)", error);
524 error = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_OR);
525 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
527 error = calendar_filter_add_str(filter, _calendar_todo_calendar_book.location, CALENDAR_MATCH_CONTAINS, keyword);
528 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_str() is failed(%x)", error);
530 error = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_OR);
531 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
533 error = calendar_filter_add_str(filter, _calendar_todo_calendar_book.description, CALENDAR_MATCH_CONTAINS, keyword);
534 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_str() is failed(%x)", error);
536 error = calendar_filter_add_operator(visibility_filter, CALENDAR_FILTER_OPERATOR_AND);
537 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
539 error = calendar_filter_add_filter(visibility_filter, filter);
540 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_filter() is failed(%x)", error);
542 error = calendar_query_set_filter(query, filter);
543 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_set_filter() is failed(%x)", error);
545 error = calendar_filter_destroy(visibility_filter);
546 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_destroy() is failed(%x)", error);
548 error = calendar_filter_destroy(filter);
549 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_destroy() is failed(%x)", error);
554 void cal_do_for_each_record_in_list(calendar_list_h list, cal_for_each_record_callback cb, void* data)
556 calendar_record_h record = NULL;
557 calendar_error_e error = calendar_list_get_current_record_p(list, &record);
558 while (error == CALENDAR_ERROR_NONE) {
561 error = calendar_list_next(list);
562 c_ret_if(error != CALENDAR_ERROR_NONE);
564 error = calendar_list_get_current_record_p(list, &record);
568 calendar_query_h cal_query_create_all_event_list_query(void)
570 calendar_query_h query = NULL;
572 calendar_error_e error = CALENDAR_ERROR_NONE;
574 error = calendar_query_create(_calendar_event_calendar_book._uri, &query);
575 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_create() is failed(%x)", error);
577 calendar_filter_h filter = NULL;
579 error = calendar_filter_create(_calendar_event_calendar_book._uri, &filter);
580 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_create() is failed(%x)", error);
582 error = calendar_filter_add_int(filter, _calendar_event_calendar_book.is_deleted, CALENDAR_MATCH_EQUAL, 0);
583 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
585 error = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
586 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
588 error = calendar_filter_add_int(filter, _calendar_event_calendar_book.calendar_book_visibility, CALENDAR_MATCH_EQUAL, 1);
589 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
591 error = calendar_query_set_filter(query, filter);
592 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_set_filter() is failed(%x)", error);
594 error = calendar_filter_destroy(filter);
595 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_destroy() is failed(%x)", error);