[misc] Sycn with master branch.
[apps/core/preloaded/calendar.git] / src / list-base.c
1 /*
2   *
3   *  Copyright 2012  Samsung Electronics Co., Ltd
4   *
5   *  Licensed under the Flora License, Version 1.1 (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
8   *
9   *       http://floralicense.org/license/
10   *
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.
16   */
17
18 #include "cld.h"
19 #include "list-base.h"
20 #include "external-ug.h"
21 #include "view.h"
22 #include "detail-view.h"
23 #include "cld-images.h"
24 #include "edit-view.h"
25
26 typedef struct {
27         struct appdata *ad;
28         Evas_Object *parent;
29         Evas_Object *genlist;
30         calendar_record_h selected_record;
31         Evas_Object *popup;
32         Ecore_Idler *popup_idler;
33         const char *searchtext;
34         Elm_Object_Item *sweep_it;
35         cal_list_callback select_item_callback;
36         void* select_item_callback_data;
37         int item_count;
38 } cal_list_base_s;
39
40 _calendar_book_color calendar_color;
41
42 static Evas_Object *__cal_list_get_genlist_loadmore_item_icon(void *data, Evas_Object *obj, const char *part)
43 {
44         c_retv_if(!data, NULL);
45
46         cal_list_base_s *p = data;
47
48         Evas_Object *progressbar = elm_progressbar_add(p->parent);
49         c_retv_if(!progressbar, NULL);
50
51         elm_object_style_set(progressbar, "list_process");
52         evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.5);
53         evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
54         evas_object_show(progressbar);
55         elm_progressbar_pulse(progressbar, EINA_TRUE);
56         return progressbar;
57 }
58
59 static char* __cal_list_base_share_genlist_item_label(void *data, Evas_Object *obj, const char *part)
60 {
61         c_retvm_if(!data || !obj || !part, NULL, "data is null");
62
63         char *name = (char *)data;
64
65         if (!CAL_STRCMP(part, "elm.text")) {
66                 return strdup(name);
67         }
68
69         return NULL;
70 }
71
72 static char* __cal_list_get_genlist_header_item_label(void *data, Evas_Object *obj, const char *part)
73 {
74         c_retvm_if(!data, NULL, "data is null.");
75
76         char buf[128];
77         cal_list_genlist_item_data *item_data = data;
78         const struct tm *tm = item_data->tm;
79
80         if (!CAL_STRCMP(part, "elm.text")) {
81
82                 if (item_data->todo_group_type == CAL_TASK_NO_DUE_DATE) {
83                         return strdup(C_("IDS_CLD_BODY_NO_DUE_DATE_M_NOUN"));
84                 } else if (item_data->todo_group_type == CAL_TASK_DUE_TODAY) {
85                         return strdup(C_("IDS_CLD_HEADER_DUE_TODAY"));
86                 } else if (item_data->todo_group_type == CAL_TASK_DUE_WITHIN_A_WEEK) {
87                         return strdup("Due within a week");
88                 } else if (item_data->todo_group_type == CAL_TASK_DUE_IN_OVER_ONE_WEEK) {
89                         return strdup(C_("IDS_CLD_HEADER_DUE_IN_OVER_1_WEEK"));
90                 } else if (item_data->todo_group_type == CAL_TASK_OVER_DUE) {
91                         return strdup(C_("IDS_TASK_DROP_OVERDUE"));
92                 }
93
94                 if (!tm) {
95                         return strdup(C_("IDS_CLD_BODY_REPEATING_EVENT"));
96                 } else {
97
98                         cal_util_get_time_text(buf, sizeof(buf), CAL_UTIL_DATE_FORMAT_1, NULL, tm);
99
100                         return strdup(buf);
101                 }
102         }
103
104         return NULL;
105 }
106
107 static char* __cal_list_get_genlist_custom_group_header_item_label(void *data, Evas_Object *obj, const char *part)
108 {
109         c_retvm_if(!data, NULL, "data is null.");
110
111         char buf[128];
112         cal_list_genlist_item_data *item_data = data;
113         const struct tm *tm = item_data->tm;
114
115         if (!CAL_STRCMP(part, "elm.text")) {
116                 if (!tm)
117                         return strdup("ERROR!!!");
118                 cal_util_get_time_text(buf, sizeof(buf), CAL_UTIL_DATE_FORMAT_1, NULL, tm);
119                 return strdup(buf);
120         }
121         return strdup("ERROR!!!");
122 }
123
124 static inline void __get_tm(const calendar_time_s* caltime, struct tm* tm_time)
125 {
126         switch (caltime->type) {
127         case CALENDAR_TIME_UTIME:
128                 cal_util_convert_lli_to_tm(NULL, caltime->time.utime, tm_time);
129                 break;
130         case CALENDAR_TIME_LOCALTIME:
131                 tm_time->tm_year = caltime->time.date.year - 1900;
132                 tm_time->tm_mon = caltime->time.date.month - 1;
133                 tm_time->tm_mday = caltime->time.date.mday;
134                 break;
135         default:
136                 // error
137                 break;
138         }
139 }
140
141 static char* __cal_list_get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
142 {
143         c_retv_if(!data, NULL);
144         c_retv_if(!obj, NULL);
145         c_retv_if(!part, NULL);
146
147         cal_list_genlist_item_data *item_data = data;
148
149         cal_list_base_s *p = CAL_UTIL_GET_PRIV_DATA(obj);
150         c_retv_if(!p, NULL);
151
152         char *str = NULL;
153
154         calendar_record_h record = item_data->record;
155         c_retv_if(!record, NULL);
156
157         if (!CAL_STRCMP(part, "elm.text.1")) {
158                 str = _calendar_get_summary(record);
159
160                 if (p->searchtext) {
161                         char *text = cal_util_get_search_color_text(p->searchtext, str);
162                         if(CAL_STRLEN(text))    {
163                                 free(str);
164                                 return text;
165                         }
166                         else
167                                 return str;
168                 }
169
170                 return str;
171         } else if (!CAL_STRCMP(part, "elm.text.2")) {
172
173                 return _calendar_get_location(record);
174
175         } else if (!CAL_STRCMP(part, "elm.text.3")) {
176
177                 return _calendar_get_time_str_for_genlist(record);
178
179         } else if (!CAL_STRCMP(part, "elm.slide.text.1")) {
180
181                 return _calendar_get_summary(record);
182         }
183
184         return NULL;
185 }
186
187 static char* __cal_list_get_genlist_task_item_label(void *data, Evas_Object *obj, const char *part)
188 {
189         c_retv_if(!data, NULL);
190         c_retv_if(!obj, NULL);
191         c_retv_if(!part, NULL);
192
193         cal_list_genlist_item_data *item_data = data;
194
195         cal_list_base_s *p = CAL_UTIL_GET_PRIV_DATA(obj);
196         c_retv_if(!p, NULL);
197
198         calendar_record_h record = item_data->record;
199         c_retv_if(!record, NULL);
200
201         int todo_status;
202         calendar_record_get_int(record, _calendar_todo.todo_status, &todo_status);
203         bool is_done = (todo_status == CALENDAR_TODO_STATUS_COMPLETED);
204
205         if ((CAL_STRCMP(part, "elm.text.1") == 0 && !is_done) ||
206                 (CAL_STRCMP(part, "elm.textblock.1") == 0 && is_done)) {
207
208                 char* text = _calendar_get_summary(record);
209                 c_retv_if(text == NULL, NULL);
210
211                 if (p->searchtext) {
212                         char* text2 = cal_util_get_search_color_text(p->searchtext, text);
213                         if(CAL_STRLEN(text2))   {
214                                 free(text);
215                                 text = text2;
216                         }
217                 }
218
219                 if (is_done) {
220                         char* text3 = calloc(strlen(text) + 100, 1);
221                         if(text3 == NULL){
222                                 free(text);
223                                 c_retv_if(text3 == NULL, NULL);
224                         }
225                         sprintf(text3, "<strikethrough=on strikethrough_color=#D1D1D1>%s</strikethrough>", text);
226                         free(text);
227                         text = text3;
228                 }
229
230
231                 return text;
232
233         } else if (!CAL_STRCMP(part, "elm.textblock.2")) {
234                 if (!is_done)
235                         return NULL;
236
237                 return _calendar_get_location(record);
238         } else if (!CAL_STRCMP(part, "elm.text.3")) {
239                 if (is_done)
240                         return NULL;
241
242                 calendar_time_s due_time;
243                 calendar_record_get_caltime(record, _calendar_todo.due_time, &due_time);
244                 // TODO:mapi
245 //              if (due_time == -1) {
246 //                      return strdup("No due date");
247 //              }
248
249                 return _calendar_get_time_str_for_genlist(record);
250         } else if (!CAL_STRCMP(part, "elm.textblock.3")) {
251                 if (!is_done)
252                         return NULL;
253
254                 calendar_time_s due_time;
255                 calendar_record_get_caltime(record, _calendar_todo.due_time, &due_time);
256                 // TODO:mapi
257 //              if (due_time == -1) {
258 //                      return strdup("No due date");
259 //              }
260
261                 return _calendar_get_time_str_for_genlist(record);
262         }
263
264         return NULL;
265 }
266
267 static void __cal_list_base_set_genlist_item_sweep_off(Elm_Object_Item *it)
268 {
269         c_retm_if(!it, "it is null");
270         elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE);
271         elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_ALWAYS);
272 }
273
274 static Eina_Bool __cal_list_popup_idler_callback(void *data)
275 {
276         c_retv_if(!data, ECORE_CALLBACK_CANCEL);
277
278         cal_list_base_s *p = data;
279
280         if (p->popup) {
281                 evas_object_del(p->popup);
282                 p->popup = NULL;
283         }
284
285         p->popup_idler = NULL;
286
287         return ECORE_CALLBACK_CANCEL;
288 }
289
290 static inline void __cal_list_base_delete_popup(cal_list_base_s *p)
291 {
292         c_retm_if(!p || !p->popup, "param is null");
293
294         if (p->popup_idler) {
295                 ecore_idler_del(p->popup_idler);
296                 p->popup_idler = NULL;
297         }
298
299         p->popup_idler = ecore_idler_add(__cal_list_popup_idler_callback, p);
300         c_ret_if(!p->popup_idler);
301 }
302
303 static void __cal_list_base_show_popup(cal_list_base_s *p, const char *tit, Eina_Bool is_edit);
304
305 void __cal_list_edit_button_callback(void *data, Evas_Object *obj, void *ei)
306 {
307         cal_list_genlist_item_data *item_data = data;
308         c_retm_if(!item_data, "item_data is NULL.");
309
310         cal_list_base_s* p = CAL_UTIL_GET_PRIV_DATA(obj);
311         c_retm_if(!p, "p is NULL.");
312
313         calendar_record_h record = item_data->record;
314         c_retm_if(!record, "record is NULL.");
315
316         p->ad->cid = _calendar_get_record_index(record);
317         p->selected_record = record;
318
319         if (_calendar_is_task_record(record)) {
320
321                 calendar_record_h origin_record = NULL;
322                 int index = _calendar_get_record_index(record);
323                 origin_record = _calendar_get_record_with_index(index);
324
325                 cal_edit_create_view(p->ad, origin_record, NULL, NULL);
326                 calendar_record_destroy(origin_record, true);
327
328                 __cal_list_base_set_genlist_item_sweep_off(p->sweep_it);
329
330         } else {
331
332                 if (_calendar_is_recurrent_record(record)) {
333                         __cal_list_base_show_popup(p,C_("IDS_CLD_HEADER_EDIT_EVENT"), EINA_TRUE);
334                 } else {
335                         calendar_record_h origin_record = NULL;
336                         int index = _calendar_get_record_index(record);
337                         origin_record = _calendar_get_record_with_index(index);
338
339                         cal_edit_create_view(p->ad, origin_record, NULL, NULL);
340                         calendar_record_destroy(origin_record, true);
341
342                         __cal_list_base_set_genlist_item_sweep_off(p->sweep_it);
343                 }
344
345         }
346 }
347
348 static void __cal_list_delete_norepeat_popup_response_event_callback(void *data, Evas_Object *obj, void *event_info)
349 {
350         c_retm_if(!data, "data is null");
351         c_retm_if(!obj, "obj is null");
352
353         Evas_Object *popup = data;
354         Evas_Object *button = obj;
355
356         cal_list_base_s* p = evas_object_data_get(popup, "data");
357
358         c_retm_if(!p, "p is null");
359         c_retm_if(!p->ad, "p->ad is null");
360         c_retm_if(!p->popup, "p->popup is null");
361
362         if (NULL != strstr(elm_object_text_get(button), S_("IDS_COM_BODY_DELETE"))) {
363                 _calendar_delete_record_with_index(p->ad->cid);
364
365                 int r = notification_status_message_post(S_("IDS_COM_POP_DELETED"));
366                 c_warn_if(r != NOTIFICATION_ERROR_NONE, "notification_status_message_post() is failed(%d)", r);
367         }
368
369         evas_object_del(p->popup);
370         p->popup = NULL;
371 }
372
373 static void __cal_list_edit_popup_response_event_callback(void *data, Evas_Object *obj, void *event_info)
374 {
375         c_retm_if(!data, "data is null");
376         c_retm_if(!obj, "obj is null");
377
378         Evas_Object *popup = data;
379         Evas_Object *button = obj;
380         cal_list_base_s* p = evas_object_data_get(popup, "data");
381         c_retm_if(!p, "p is null");
382
383         struct appdata* ad = p->ad;
384         c_retm_if(!ad, "ad is null");
385
386         if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_BODY_ONLY_THIS_EVENT"))) {
387                 cal_edit_create_view(p->ad, p->selected_record, NULL, NULL);
388                 __cal_list_base_set_genlist_item_sweep_off(p->sweep_it);
389         }else if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"))) {
390                 calendar_record_h origin_record = NULL;
391                 int index = _calendar_get_record_index(p->selected_record);
392                 origin_record = _calendar_get_record_with_index(index);
393
394                 cal_edit_create_view(p->ad, origin_record, NULL, NULL);
395                 __cal_list_base_set_genlist_item_sweep_off(p->sweep_it);
396                 calendar_record_destroy(origin_record, true);
397         }
398
399         evas_object_del(popup);
400         p->popup = NULL;
401 }
402
403 static void __cal_list_delete_event(cal_list_base_s* p, Eina_Bool is_delete_all)
404 {
405         c_ret_if(!p);
406
407         struct appdata* ad = p->ad;
408         c_ret_if(!ad);
409
410         if (!is_delete_all)
411                 _calendar_delete_recurrence_instance(p->selected_record);
412         else
413                 _calendar_delete_record_with_index(ad->cid);
414
415         int r = notification_status_message_post(S_("IDS_COM_POP_DELETED"));
416         c_warn_if(r != NOTIFICATION_ERROR_NONE, "notification_status_message_post() is failed(%d)", r);
417 }
418
419 static void __cal_list_delete_popup_response_event_callback(void *data, Evas_Object *obj, void *event_info)
420 {
421         c_retm_if(!data, "data is null");
422         c_retm_if(!obj, "obj is null");
423
424         Evas_Object *popup = data;
425         Evas_Object *button = obj;
426
427         cal_list_base_s* p = evas_object_data_get(popup, "data");
428         c_retm_if(!p, "p is null");
429
430         if (!strcmp(elm_object_text_get(button), S_("IDS_COM_BODY_DELETE"))) {
431                 __cal_list_delete_event(p, EINA_FALSE);
432         } else if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_BODY_ONLY_THIS_EVENT"))) {
433                 __cal_list_delete_event(p, EINA_FALSE);
434         } else if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"))) {
435                 __cal_list_delete_event(p, EINA_TRUE);
436         }
437
438         evas_object_del(popup);
439         p->popup = NULL;
440 }
441
442 static void __cal_list_base_show_popup(cal_list_base_s *p, const char *tit, Eina_Bool is_edit)
443 {
444         c_retm_if(!p, "p is NULL.");
445
446         void (*callback_func)(void *data, Evas_Object *obj, void *ei) = NULL;
447
448         if (is_edit) {
449                 callback_func = __cal_list_edit_popup_response_event_callback;
450
451         } else {
452                 callback_func = __cal_list_delete_popup_response_event_callback;
453         }
454
455         p->popup = cal_util_add_popup(p->ad->win, "verticalbuttonstyle", NULL, tit,
456                         callback_func, p, C_("IDS_CLD_BODY_ONLY_THIS_EVENT"),
457                         C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"), S_("IDS_COM_SK_CANCEL"), NULL);
458
459         c_retm_if(!p->popup, "cal_util_add_popup(p->ad->win) returned null");
460
461         evas_object_data_set(p->popup, "priv", p);
462 }
463
464 void __cal_list_delete_button_callback(void *data, Evas_Object *obj, void *ei)
465 {
466         cal_list_genlist_item_data *item_data = data;
467         c_retm_if(!item_data, "item_data is NULL.");
468
469         cal_list_base_s* p = CAL_UTIL_GET_PRIV_DATA(obj);
470         c_retm_if(!p, "p is NULL.");
471
472         calendar_record_h record = item_data->record;
473         c_retm_if(!record, "record is NULL.");
474
475         p->ad->cid = _calendar_get_record_index(record);
476         p->selected_record = record;
477
478         c_ret_if(p->ad->cid == 0);
479
480         if (_calendar_is_task_record(record)) {
481                 p->popup = cal_util_add_popup(p->ad->win, NULL, NULL, S_("IDS_COM_POP_DELETE_Q"), __cal_list_delete_norepeat_popup_response_event_callback, p,
482                         S_("IDS_COM_BODY_DELETE"),S_("IDS_COM_SK_CANCEL"), NULL);
483         } else {
484                 if (_calendar_is_recurrent_record(record)) {
485                         __cal_list_base_show_popup(p, C_("IDS_CLD_OPT_DELETE_EVENT"), EINA_FALSE);
486                 } else {
487                         p->popup = cal_util_add_popup(p->ad->win, NULL, NULL, S_("IDS_COM_POP_DELETE_Q"), __cal_list_delete_norepeat_popup_response_event_callback, p,
488                                 S_("IDS_COM_BODY_DELETE"),S_("IDS_COM_SK_CANCEL"), NULL);
489                 }
490         }
491 }
492
493 static void __cal_list_base_share_popup_response_callback(void *data, Evas_Object *obj, void *ei)
494 {
495         c_retm_if(!data, "data is null");
496         c_retm_if(!obj, "obj is null");
497
498         Evas_Object *popup = data;
499
500         cal_list_base_s* p = evas_object_data_get(popup, "data");
501         c_retm_if(!p, "p is null");
502
503         evas_object_del(popup);
504         p->popup = NULL;
505
506 }
507
508 static void __cal_list_genlist_item_check_changed_callback(void *data, Evas_Object *obj, void *event_info)
509 {
510         c_ret_if(!data);
511         c_ret_if(!obj);
512
513         cal_list_genlist_item_data *item_data = data;
514
515         cal_list_base_s* p = CAL_UTIL_GET_PRIV_DATA(obj);
516         c_ret_if(!p);
517
518         item_data->checked = elm_check_state_get(obj);
519
520         calendar_record_h record = item_data->record;
521         c_ret_if(!record);
522
523         calendar_error_e error = CALENDAR_ERROR_NONE;
524         calendar_record_h todo_original_record = NULL;
525         int todo_id = _calendar_get_record_index(record);
526         error = calendar_db_get_record(_calendar_todo._uri, todo_id, &todo_original_record);
527         c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_db_get_record(%d) is failed(%x)", todo_id, error);
528
529         if (item_data->checked) {
530                 error = calendar_record_set_int(todo_original_record, _calendar_todo.todo_status, CALENDAR_TODO_STATUS_COMPLETED);
531                 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_set_int() is failed(%x)", error);
532
533                 error = calendar_record_set_int(record, _calendar_todo_calendar_book.todo_status, CALENDAR_TODO_STATUS_COMPLETED);
534                 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_set_int() is failed(%x)", error);
535         }
536         else {
537                 error = calendar_record_set_int(todo_original_record, _calendar_todo.todo_status, CALENDAR_TODO_STATUS_IN_PROCESS);
538                 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_set_int() is failed(%x)", error);
539
540                 error = calendar_record_set_int(record, _calendar_todo_calendar_book.todo_status, CALENDAR_TODO_STATUS_IN_PROCESS);
541                 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_set_int() is failed(%x)", error);
542         }
543
544         cal_main_remove_db_changed_callback(p->ad);
545
546         error = calendar_db_update_record(todo_original_record);
547         c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_db_update_record() is failed(%x)", error);
548
549         cal_main_add_db_changed_callback(p->ad);
550
551         elm_genlist_item_update(item_data->it);
552
553         // TBD: UX not so good if task item is removed from list immediately.
554         if (!p->ad->is_display_complete_todo && item_data->checked)
555                 elm_object_item_del(item_data->it);
556 }
557
558 void __cal_list_base_send_button_callback(void *data, Evas_Object *obj, void *ei);
559
560 static Evas_Object* __get_action_button(Evas_Object* obj, const char *part, cal_list_base_s *p, cal_list_genlist_item_data *item_data)
561 {
562         Evas_Object *button = elm_button_add(obj);
563         c_retvm_if(!button, NULL, "button is NULL");
564
565         evas_object_data_set(button, "priv", p);
566         Eina_Bool button_disabled_set = EINA_FALSE;
567
568         if (!CAL_STRCMP(part, "elm.slide.swallow.1")) {
569
570                 elm_object_style_set(button, "text_only/sweep");
571                 elm_object_text_set(button, S_("IDS_COM_SK_EDIT"));
572                 evas_object_smart_callback_add(button, "clicked", __cal_list_edit_button_callback, item_data);
573                 evas_object_propagate_events_set(button, EINA_FALSE);
574                 if(button_disabled_set)
575                         elm_object_disabled_set(button, EINA_TRUE);
576
577         } else if (!CAL_STRCMP(part, "elm.slide.swallow.2")) {
578
579                 elm_object_style_set(button, "text_only/sweep");
580                 elm_object_text_set(button, S_("IDS_COM_BUTTON_SHARE"));
581                 evas_object_smart_callback_add(button, "clicked", __cal_list_base_send_button_callback, item_data);
582                 evas_object_propagate_events_set(button, EINA_FALSE);
583
584         } else if (!CAL_STRCMP(part, "elm.slide.swallow.3")) {
585
586                 elm_object_style_set(button, "sweep/delete");
587                 elm_object_text_set(button, S_("IDS_COM_BODY_DELETE"));
588                 evas_object_smart_callback_add(button, "clicked", __cal_list_delete_button_callback, item_data);
589                 evas_object_propagate_events_set(button, EINA_FALSE);
590                 if(button_disabled_set)
591                         elm_object_disabled_set(button, EINA_TRUE);
592
593         }
594
595         return button;
596 }
597
598 static Evas_Object *__cal_list_get_genlist_item_icon(void *data, Evas_Object *obj, const char *part)
599 {
600         c_retv_if(!data, NULL);
601
602         cal_list_base_s *p = CAL_UTIL_GET_PRIV_DATA(obj);
603         c_retv_if(!p, NULL);
604
605         cal_list_genlist_item_data *item_data = data;
606
607         Evas_Object *icon = NULL;
608
609         calendar_record_h record = item_data->record;
610
611         if (!CAL_STRCMP(part, "elm.swallow.colorbar")) {
612
613                 _calendar_get_calendar_color(record, &calendar_color);
614
615                 icon = evas_object_rectangle_add(evas_object_evas_get(obj));
616                 evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
617                 evas_object_color_set(icon, calendar_color.red, calendar_color.green, calendar_color.blue, calendar_color.alpha);
618
619                 return icon;
620
621         } else if (CAL_STRCMP(part, "elm.slide.swallow.1") == 0 ||
622                            CAL_STRCMP(part, "elm.slide.swallow.2") == 0 ||
623                            CAL_STRCMP(part, "elm.slide.swallow.3") == 0) {
624
625                 return __get_action_button(obj, part, p, item_data);
626
627         } else if (!CAL_STRCMP(part, "elm.edit.icon.1") ) {
628                 icon = elm_check_add(obj);
629                 c_retvm_if(!icon, NULL, "elm_check_add returned null");
630
631                 int todo_status;
632                 calendar_record_get_int(record, _calendar_todo.todo_status, &todo_status);
633
634                 if (CALENDAR_TODO_STATUS_COMPLETED == todo_status)
635                         item_data->checked = EINA_TRUE;
636                 else if (CALENDAR_TODO_STATUS_IN_PROCESS == todo_status)
637                         item_data->checked = EINA_FALSE;
638
639                 elm_check_state_pointer_set(icon, &item_data->checked);
640                 evas_object_smart_callback_add(icon, "changed", __cal_list_genlist_item_check_changed_callback, item_data);
641                 evas_object_propagate_events_set(icon, EINA_FALSE);
642                 evas_object_data_set(icon, "priv", p);
643
644                 return icon;
645         } else if (!CAL_STRCMP(part, "elm.icon.1")) {
646                 if (!_calendar_has_reminder(record))
647                         return NULL;
648
649                 icon = elm_icon_add(obj);
650                 c_retv_if(!icon, NULL);
651
652                 int r = elm_icon_file_set(icon, CAL_IMAGES_EDJ, CAL_IMAGES_ALARM);
653                 c_retv_if(!r, NULL);
654
655                 return icon;
656         } else if (!CAL_STRCMP(part, "elm.icon.2")) {
657                 if (!_calendar_is_recurrent_record(record))
658                         return NULL;
659
660                 icon = elm_icon_add(obj);
661                 c_retv_if(!icon, NULL);
662
663                 int r = elm_icon_file_set(icon, CAL_IMAGES_EDJ, CAL_IMAGES_REPEAT);
664                 c_retv_if(!r, NULL);
665
666                 return icon;
667         } else if (!CAL_STRCMP(part, "elm.icon.3")) {
668                 if (!_calendar_is_facebook_record(record))
669                         return NULL;
670
671                 icon = elm_icon_add(obj);
672                 c_retv_if(!icon, NULL);
673
674                 int r = elm_icon_file_set(icon, CAL_IMAGES_EDJ, CAL_IMAGES_FACEBOOK);
675                 c_retv_if(!r, NULL);
676
677                 return icon;
678         } else {
679                 DBG("The part %s is unattended for!!!", part);
680         }
681
682         return NULL;
683 }
684
685 static Evas_Object *__cal_list_get_genlist_task_item_icon(void *data, Evas_Object *obj, const char *part)
686 {
687         c_retv_if(!data, NULL);
688
689         cal_list_base_s *p = CAL_UTIL_GET_PRIV_DATA(obj);
690         c_retv_if(!p, NULL);
691
692         cal_list_genlist_item_data *item_data = data;
693
694         Evas_Object *icon = NULL;
695
696         calendar_record_h record = item_data->record;
697         c_retv_if(!_calendar_is_task_record(record), NULL);
698
699         if (!CAL_STRCMP(part, "elm.swallow.colorbar"))
700         {
701                 icon = evas_object_rectangle_add(evas_object_evas_get(obj));
702                 evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
703
704                 _calendar_get_calendar_color(record, &calendar_color);
705
706                 evas_object_color_set(icon, calendar_color.red, calendar_color.green, calendar_color.blue, calendar_color.alpha);
707
708                 return icon;
709         } else if (CAL_STRCMP(part, "elm.slide.swallow.1") == 0 ||
710                            CAL_STRCMP(part, "elm.slide.swallow.2") == 0 ||
711                            CAL_STRCMP(part, "elm.slide.swallow.3") == 0) {
712
713                 return __get_action_button(obj, part, p, item_data);
714
715         } else if (!CAL_STRCMP(part, "elm.edit.icon")) {
716                 Evas_Object *check = elm_check_add(obj);
717                 c_retvm_if(!check, NULL, "elm_check_add returned null");
718
719                 item_data->checked = EINA_FALSE;
720
721                 calendar_error_e error = CALENDAR_ERROR_NONE;
722
723                 calendar_todo_status_e todo_status = 0;
724
725                 error = calendar_record_get_int(record, _calendar_todo.todo_status, (int *)&todo_status);
726                 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
727
728                 if (CALENDAR_TODO_STATUS_COMPLETED == todo_status) {
729                         item_data->checked = EINA_TRUE;
730                 } else if (CALENDAR_TODO_STATUS_IN_PROCESS == todo_status) {
731                         item_data->checked = EINA_FALSE;
732                 }
733
734                 elm_check_state_pointer_set(check, &item_data->checked);
735                 evas_object_smart_callback_add(check, "changed", __cal_list_genlist_item_check_changed_callback, item_data);
736                 evas_object_propagate_events_set(check, EINA_FALSE);
737                 evas_object_data_set(check, "priv", p);
738                 return check;
739         }  else if (!CAL_STRCMP(part, "elm.icon.2")) {
740                 calendar_error_e error = CALENDAR_ERROR_NONE;
741
742                 calendar_todo_priority_e priority = CALENDAR_TODO_PRIORITY_NONE;
743
744                 error = calendar_record_get_int(record, _calendar_todo.priority, (int *)&priority);
745                 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
746
747                 if (priority == CALENDAR_TODO_PRIORITY_HIGH) {
748                         icon = elm_icon_add(obj);
749                         c_retvm_if(!icon, NULL, "elm_icon_add returned null");
750                         int r = elm_icon_file_set(icon, CAL_IMAGES_EDJ, CAL_IMAGES_PRIORITY);
751                         c_retv_if(!r, NULL);
752                 } else if (priority == CALENDAR_TODO_PRIORITY_LOW) {
753                         icon = elm_icon_add(obj);
754                         c_retvm_if(!icon, NULL, "elm_icon_add returned null");
755                         int r = elm_icon_file_set(icon, CAL_IMAGES_EDJ, CAL_IMAGES_PRIORITY_LOW);
756                         c_retv_if(!r, NULL);
757                 }
758
759                 return icon;
760         }  else if (!CAL_STRCMP(part, "elm.icon.1")) {
761                 if (!_calendar_has_reminder(record))
762                         return NULL;
763
764                 icon = elm_icon_add(obj);
765                 c_retv_if(!icon, NULL);
766
767                 int r = elm_icon_file_set(icon, CAL_IMAGES_EDJ, CAL_IMAGES_ALARM);
768                 c_retv_if(!r, NULL);
769
770                 return icon;
771         }  else {
772                 DBG("The part %s is unattended for!!!", part);
773         }
774
775         return NULL;
776 }
777
778 // TODO: Create new type for header item data
779 static void __cal_list_delete_genlist_header_item(void *data, Evas_Object *obj)
780 {
781         CAL_FN_START;
782
783         c_retm_if(!data, "data is null.");
784
785         cal_list_genlist_item_data *item_data = data;
786
787         free(item_data->tm);
788         free(item_data);
789 }
790
791 static void __cal_list_delete_genlist_item(void *data, Evas_Object *obj)
792 {
793         c_retm_if(!data, "data is null.");
794         cal_list_genlist_item_data *item_data = data;
795         free(item_data);
796 }
797
798 Elm_Genlist_Item_Class cal_list_itc_h = {
799         .item_style = "grouptitle",
800         .func.text_get = __cal_list_get_genlist_header_item_label,
801         .func.del = __cal_list_delete_genlist_header_item,
802 };
803
804 Elm_Genlist_Item_Class cal_list_today_group_itc_h = {
805         .item_style = "today_grouptitle",
806         .func.text_get = __cal_list_get_genlist_custom_group_header_item_label,
807         .func.del = __cal_list_delete_genlist_header_item,
808 };
809
810 Elm_Genlist_Item_Class cal_list_normal_itc = {
811         .item_style = "4text.1icon.3.calendar.search",
812         .func.text_get = __cal_list_get_genlist_item_label,
813         .func.del = __cal_list_delete_genlist_item,
814         .func.content_get = __cal_list_get_genlist_item_icon,
815         .decorate_item_style = "mode/slide3",
816 };
817
818 Elm_Genlist_Item_Class cal_task_itc = {
819         .item_style = "3text.4icon.calendar.check",
820         .func.text_get = __cal_list_get_genlist_task_item_label,
821         .func.del = __cal_list_delete_genlist_item,
822         .func.content_get = __cal_list_get_genlist_task_item_icon,
823         .decorate_item_style = "mode/slide3",
824 };
825
826 Elm_Genlist_Item_Class itc_1text = {
827         .item_style = "1text",
828         .func.content_get = NULL,
829         .func.text_get = __cal_list_base_share_genlist_item_label,
830 };
831
832 Elm_Genlist_Item_Class itc_1icon = {
833         .item_style = "1icon.custom",
834         .func.content_get = NULL,
835         .func.text_get = NULL,
836         .func.content_get = __cal_list_get_genlist_loadmore_item_icon,
837 };
838
839 static void __cal_list_via_message_callback(void *data, Evas_Object *obj, void *ei)
840 {
841         c_retm_if(!data, "data is null");
842         c_retm_if(!obj, "obj is null");
843
844         cal_list_base_s *p = data;
845         c_retm_if(!p->ad, "p->ad is null");
846
847         c_ret_if(!p->selected_record);
848
849         calendar_record_h record = _calendar_get_record_with_index(_calendar_get_record_index(p->selected_record));
850         c_ret_if(!record);
851
852         _calendar_export_record_to_vcs(record, CAL_MESSAGE_VCS);
853
854         p->ad->ug = cal_launch_ug_with_var(NULL, CAL_MESSAGE_COMPOSER_UG, NULL, "ATTACHFILE", CAL_MESSAGE_VCS, NULL);
855
856         __cal_list_base_set_genlist_item_sweep_off(p->sweep_it);
857
858         __cal_list_base_delete_popup(p);
859 }
860
861 static void __cal_list_via_email_callback(void *data, Evas_Object *obj, void *ei)
862 {
863         c_retm_if(!data, "data is null");
864         c_retm_if(!obj, "obj is null");
865
866         cal_list_base_s *p = data;
867         c_retm_if(!p->ad, "p->ad is null");
868
869         c_ret_if(!p->selected_record);
870
871         calendar_record_h record = _calendar_get_record_with_index(_calendar_get_record_index(p->selected_record));
872         c_ret_if(!record);
873
874         _calendar_export_record_to_vcs(record, CAL_EMAIL_VCS);
875
876         p->ad->ug = cal_launch_ug_with_var(NULL, CAL_EMAIL_COMPOSER_UG, (struct ug_cbs *)p->ad, "RUN_TYPE", "5", "ATTACHFILE", CAL_EMAIL_VCS, NULL);
877
878         __cal_list_base_set_genlist_item_sweep_off(p->sweep_it);
879
880         __cal_list_base_delete_popup(p);
881 }
882
883 static void __cal_list_via_bluetooth_callback(void *data, Evas_Object *obj, void *ei)
884 {
885         c_retm_if(!data, "data is null");
886         c_retm_if(!obj, "obj is null");
887
888         cal_list_base_s *p = data;
889         c_retm_if(!p->ad, "p->ad is null");
890
891         c_ret_if(!p->selected_record);
892
893         calendar_record_h record = _calendar_get_record_with_index(_calendar_get_record_index(p->selected_record));
894         c_ret_if(!record);
895
896         _calendar_export_record_to_vcs(record, CAL_BLUETOOTH_VCS);
897
898         p->ad->ug = cal_launch_ug_with_var(NULL, CAL_BLUETOOTH_UG, NULL, "launch-type", "send", "filecount", "1", "files", CAL_BLUETOOTH_VCS, NULL);
899
900         __cal_list_base_set_genlist_item_sweep_off(p->sweep_it);
901
902         __cal_list_base_delete_popup(p);
903 }
904
905 void __cal_list_base_send_button_callback(void *data, Evas_Object *obj, void *ei)
906 {
907         cal_list_genlist_item_data *item_data = data;
908         c_retm_if(!item_data, "item_data is NULL.");
909
910         cal_list_base_s* p = CAL_UTIL_GET_PRIV_DATA(obj);
911         c_retm_if(!p, "p is NULL.");
912
913         calendar_record_h record = item_data->record;
914         c_retm_if(!record, "record is NULL.");
915
916         p->ad->cid = _calendar_get_record_index(record);
917         p->selected_record = record;
918
919         p->popup = cal_util_add_popup(p->ad->win, "menustyle", S_("IDS_COM_BUTTON_SHARE"), NULL,
920                                 __cal_list_base_share_popup_response_callback, p,
921                                 S_("IDS_COM_BODY_CLOSE"),  NULL);
922
923         c_retm_if(!p->popup, "cal_util_add_popup returned null");
924         evas_object_data_set(p->popup, "data", p);
925
926         Evas_Object *genlist = elm_genlist_add(p->popup);
927         c_retm_if(!genlist, "elm_genlist_add returned null");
928
929         elm_genlist_item_append(genlist, &itc_1text, S_("IDS_COM_BODY_EMAIL"), NULL, ELM_GENLIST_ITEM_NONE, __cal_list_via_email_callback, p);
930         elm_genlist_item_append(genlist, &itc_1text, S_("IDS_COM_BODY_MESSAGE"), NULL, ELM_GENLIST_ITEM_NONE, __cal_list_via_message_callback, p);
931         elm_genlist_item_append(genlist, &itc_1text, S_("IDS_COM_BODY_BLUETOOTH"), NULL, ELM_GENLIST_ITEM_NONE, __cal_list_via_bluetooth_callback, p);
932
933         elm_object_content_set(p->popup, genlist);
934         evas_object_show(p->popup);
935 }
936
937 Elm_Object_Item* cal_list_base_append_genlist_group_item(Evas_Object *genlist,
938                 const Elm_Genlist_Item_Class *itc, const struct tm *tm, cal_task_group_item_type type)
939 {
940         CAL_FN_START;
941
942         c_retv_if(!genlist, NULL);
943
944         cal_list_base_s* p = CAL_UTIL_GET_PRIV_DATA(genlist);
945         c_retvm_if(!p, NULL, "p is null.");
946
947         struct tm *t = NULL;
948
949         if (tm) {
950                 t = calloc(1, sizeof(struct tm));
951
952                 *t = *tm;
953         } else {
954                 t = NULL;
955         }
956
957         cal_list_genlist_item_data *item_data = calloc(1, sizeof(cal_list_genlist_item_data));
958
959         item_data->tm = t;
960         item_data->todo_group_type = type;
961
962         item_data->it = elm_genlist_item_append(genlist, itc, item_data, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
963         if (item_data->it == NULL) {
964                 ERR("elm_genlist_item_append failed!");
965
966                 free(item_data);
967                 CAL_FREE(t);
968
969                 return NULL;
970         }
971
972         elm_genlist_item_select_mode_set(item_data->it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
973
974         return item_data->it;
975 }
976
977 Elm_Object_Item* cal_list_base_prepend_genlist_group_item(Evas_Object *genlist,
978                 const Elm_Genlist_Item_Class *itc, const struct tm *tm)
979 {
980         CAL_FN_START;
981
982         c_retv_if(!genlist, NULL);
983
984         struct tm *t = calloc(1, sizeof(struct tm));
985
986         *t = *tm;
987
988         cal_list_genlist_item_data *item_data = calloc(1, sizeof(cal_list_genlist_item_data));
989
990         item_data->tm = t;
991
992         item_data->it = elm_genlist_item_prepend(genlist, itc, item_data, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
993         if (item_data->it == NULL) {
994                 ERR("elm_genlist_item_prepend failed!");
995                 free(item_data);
996                 return NULL;
997         }
998
999         elm_genlist_item_select_mode_set(item_data->it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1000
1001         return item_data->it;
1002 }
1003
1004 static void __cal_list_genlist_item_select_callback(void *data, Evas_Object *obj, void *event_info)
1005 {
1006         CAL_FN_START;
1007
1008         c_ret_if(!data);
1009         c_ret_if(!obj);
1010
1011         calendar_record_h record = data;
1012
1013         Elm_Object_Item *it = elm_genlist_selected_item_get(obj);
1014         c_ret_if(!it);
1015
1016         elm_genlist_item_selected_set(it, EINA_FALSE);
1017
1018         cal_list_base_s* p = CAL_UTIL_GET_PRIV_DATA(obj);
1019         c_retm_if(!p, "priv is null.");
1020
1021         p->ad->cid = _calendar_get_record_index(record);
1022
1023         if (p->select_item_callback != NULL) {
1024                 p->select_item_callback(p->select_item_callback_data);
1025         } else {
1026                 cal_detail_create_view(p->ad, record, NULL, NULL);
1027         }
1028 }
1029
1030 static Elm_Object_Item* __cal_list_append_genlist_item(Evas_Object *genlist,
1031                 const Elm_Genlist_Item_Class *itc, calendar_record_h record, Elm_Object_Item *parent)
1032 {
1033         CAL_FN_START;
1034
1035         cal_list_base_s* p = CAL_UTIL_GET_PRIV_DATA(genlist);
1036         c_retv_if(!p, NULL);
1037
1038         cal_list_genlist_item_data *item_data = calloc(1, sizeof(cal_list_genlist_item_data));
1039
1040         item_data->record = record;
1041
1042         item_data->it = elm_genlist_item_append(genlist, itc, item_data, parent, ELM_GENLIST_ITEM_NONE, __cal_list_genlist_item_select_callback, record);
1043         if (!item_data->it) {
1044                 ERR("item_data->it is null");
1045
1046                 free(item_data);
1047
1048                 return NULL;
1049         }
1050
1051         return item_data->it;
1052 }
1053
1054 static Elm_Object_Item* __cal_list_prepend_genlist_item(Evas_Object *genlist,
1055                 const Elm_Genlist_Item_Class *itc, calendar_record_h record, Elm_Object_Item *parent)
1056 {
1057         CAL_FN_START;
1058
1059         cal_list_genlist_item_data *item_data = calloc(1, sizeof(cal_list_genlist_item_data));
1060
1061         item_data->record = record;
1062
1063         item_data->it = elm_genlist_item_prepend(genlist, itc, item_data, parent, ELM_GENLIST_ITEM_NONE,  __cal_list_genlist_item_select_callback, record);
1064         c_retv_if(!item_data->it, NULL);
1065
1066         return item_data->it;
1067 }
1068
1069 static void __cal_list_gl_mode_right(void *data, Evas_Object *obj, void *event_info)
1070 {
1071         c_retm_if(!event_info, "event_info is null");
1072         c_retm_if(!obj, "obj is null");
1073
1074         Elm_Object_Item *it = event_info;
1075
1076         elm_genlist_item_decorate_mode_set(it, "slide", EINA_TRUE);
1077
1078         cal_list_base_s* p = CAL_UTIL_GET_PRIV_DATA(obj);
1079         c_retm_if(!p, "p is null");
1080
1081         if (p->sweep_it && it != p->sweep_it)
1082                 elm_genlist_item_decorate_mode_set(p->sweep_it, "slide", EINA_FALSE);
1083
1084         p->sweep_it = it;
1085 }
1086
1087 static void __cal_list_gl_mode_left(void *data, Evas_Object *obj, void *event_info)
1088 {
1089         c_retm_if(!event_info, "event_info is null");
1090         Elm_Object_Item *it = event_info;
1091
1092         elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE);
1093 }
1094
1095 static void __cal_list_gl_mode_cancel(void *data, Evas_Object *obj, void *event_info)
1096 {
1097         c_retm_if(!obj, "obj is null");
1098
1099         Elm_Object_Item *it = (Elm_Object_Item *)elm_genlist_decorated_item_get(obj);
1100         c_ret_if(!it);
1101
1102         elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE);
1103 }
1104
1105 Evas_Object* cal_list_base_get_genlist_p(cal_list_base_h list)
1106 {
1107         cal_list_base_s* p = (cal_list_base_s*)list;
1108         c_retv_if(!p, NULL);
1109         return p->genlist;
1110 }
1111
1112 static void __cal_list_base_text_refresh_callback(void *data)
1113 {
1114         CAL_FN_START;
1115
1116         c_retm_if(!data, "data is null");
1117         cal_list_base_s *p = data;
1118
1119         cal_main_update_title_text(p->ad);
1120         elm_object_text_set(p->ad->new_event_button, S_("IDS_COM_BODY_CREATE"));
1121
1122         elm_genlist_realized_items_update(p->genlist);
1123
1124 }
1125
1126 void cal_list_base_clear(cal_list_base_h list)
1127 {
1128         CAL_FN_START;
1129
1130         cal_list_base_s* p = (cal_list_base_s*)list;
1131         c_ret_if(!p);
1132
1133         elm_genlist_clear(p->genlist);
1134         p->item_count = 0;
1135 }
1136
1137 void cal_list_base_delete(cal_list_base_h list)
1138 {
1139         CAL_FN_START;
1140
1141         cal_list_base_s* p = (cal_list_base_s*)list;
1142         c_ret_if(!p);
1143
1144         if (!p->genlist)
1145                 return;
1146
1147         elm_object_part_content_unset(p->parent, "sw");
1148
1149         evas_object_del(p->genlist);
1150
1151         if (p->popup_idler) {
1152                 ecore_idler_del(p->popup_idler);
1153                 p->popup_idler = NULL;
1154         }
1155
1156         if (p->popup) {
1157                 evas_object_del(p->popup);
1158                 p->popup = NULL;
1159         }
1160
1161         p->genlist = NULL;
1162
1163         cal_lang_manager_remove_callback(__cal_list_base_text_refresh_callback, p);
1164 }
1165
1166 cal_list_base_h cal_list_base_create(
1167                                 struct appdata *ad, Evas_Object* parent, const char* part_name, bool enable_sweep_menu,
1168                                 cal_list_callback select_item_callback, void* select_item_callback_data)
1169 {
1170         CAL_FN_START;
1171
1172         c_retv_if(ad == NULL, NULL);
1173         c_retv_if(parent == NULL, NULL);
1174
1175         cal_list_base_s* p = (cal_list_base_s*)calloc(1, sizeof(cal_list_base_s));
1176         c_retv_if(p == NULL, NULL);
1177
1178         Evas_Object *genlist = elm_genlist_add(parent);
1179         if (genlist == NULL) {
1180                 c_warn_if(1, "elm_genlist_add failed");
1181                 free(p);
1182                 return NULL;
1183         }
1184
1185         p->ad = ad;
1186         p->parent = parent;
1187         p->select_item_callback = select_item_callback;
1188         p->select_item_callback_data = select_item_callback_data;
1189
1190         evas_object_data_set(genlist, "priv", p);
1191
1192         if (enable_sweep_menu) {
1193                 evas_object_smart_callback_add(genlist, "drag,start,right", __cal_list_gl_mode_right, NULL);
1194                 evas_object_smart_callback_add(genlist, "drag,start,left", __cal_list_gl_mode_left, NULL);
1195                 evas_object_smart_callback_add(genlist, "drag,start,up", __cal_list_gl_mode_cancel, NULL);
1196                 evas_object_smart_callback_add(genlist, "drag,start,down", __cal_list_gl_mode_cancel, NULL);
1197         }
1198
1199         elm_object_part_content_set(parent, part_name, genlist);
1200
1201         p->genlist = genlist;
1202
1203         cal_lang_manager_add_callback(__cal_list_base_text_refresh_callback, p);
1204
1205         return p;
1206 }
1207
1208 void cal_list_base_delete_popup(cal_list_base_h list)
1209 {
1210         cal_list_base_s* p = (cal_list_base_s*)list;
1211         c_ret_if(!p);
1212
1213         if (p->popup) {
1214                 evas_object_del(p->popup);
1215                 p->popup = NULL;
1216         }
1217 }
1218
1219 void cal_list_base_delete_popup_idler(cal_list_base_h list)
1220 {
1221         cal_list_base_s* p = (cal_list_base_s*)list;
1222         c_ret_if(!p);
1223
1224         if (p->popup_idler) {
1225                 ecore_idler_del(p->popup_idler);
1226                 p->popup_idler = NULL;
1227         }
1228 }
1229
1230 void cal_list_base_add_item(cal_list_base_h list, calendar_record_h record, bool prepend)
1231 {
1232         cal_list_base_s* p = (cal_list_base_s*)list;
1233         c_ret_if(!p);
1234         c_ret_if(!record);
1235
1236         if (prepend) {
1237                 Elm_Object_Item* it = elm_genlist_first_item_get(p->genlist);
1238                 if (_calendar_is_task_record(record))
1239                         __cal_list_prepend_genlist_item(p->genlist, &cal_task_itc, record, NULL);
1240                 else
1241                         __cal_list_prepend_genlist_item(p->genlist, &cal_list_normal_itc, record, NULL);
1242         } else {
1243                 if (_calendar_is_task_record(record))
1244                         __cal_list_append_genlist_item(p->genlist, &cal_task_itc, record, NULL);
1245                 else
1246                         __cal_list_append_genlist_item(p->genlist, &cal_list_normal_itc, record, NULL);
1247         }
1248
1249         p->item_count++;
1250 }
1251
1252 void cal_list_base_add_item_after(cal_list_base_h list, calendar_record_h record, Elm_Object_Item* after)
1253 {
1254         cal_list_base_s* p = (cal_list_base_s*)list;
1255         c_ret_if(!p);
1256         c_ret_if(!record);
1257
1258         cal_list_genlist_item_data *item_data = calloc(1, sizeof(cal_list_genlist_item_data));
1259         item_data->record = record;
1260
1261         if (_calendar_is_task_record(record))
1262                 item_data->it = elm_genlist_item_insert_after(p->genlist, &cal_task_itc, item_data, NULL, after, ELM_GENLIST_ITEM_NONE, __cal_list_genlist_item_select_callback, record);
1263         else
1264                 item_data->it = elm_genlist_item_insert_after(p->genlist, &cal_list_normal_itc, item_data, NULL, after, ELM_GENLIST_ITEM_NONE, __cal_list_genlist_item_select_callback, record);
1265
1266         if (!item_data->it) {
1267                 ERR("item_data->it is null");
1268                 free(item_data);
1269         }
1270 }
1271
1272 int cal_list_base_get_item_count(cal_list_base_h list)
1273 {
1274         const cal_list_base_s* p = (cal_list_base_s*)list;
1275         return p->item_count;
1276 }
1277
1278 void cal_list_base_set_search_text(cal_list_base_h list, const  char *search_text)
1279 {
1280         cal_list_base_s* p = (cal_list_base_s*)list;
1281         c_ret_if(!p);
1282
1283         p->searchtext = search_text;
1284
1285 }