3 Copyright (c) 2000-2012 Samsung Electronics Co., Ltd All Rights Reserved
5 This file is part of org.tizen.efl-calendar
6 Written by Taeho Kang <taeho84.kang@samsung.com>
8 PROPRIETARY/CONFIDENTIAL
10 This software is the confidential and proprietary information of
11 SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
12 disclose such Confidential Information and shall use it only in
13 accordance with the terms of the license agreement you entered
14 into with SAMSUNG ELECTRONICS.
16 SAMSUNG make no representations or warranties about the suitability
17 of the software, either express or implied, including but not limited
18 to the implied warranties of merchantability, fitness for a particular
19 purpose, or non-infringement. SAMSUNG shall not be liable for any
20 damages suffered by licensee as a result of using, modifying or
21 distributing this software or its derivatives.
30 #include "edit-repeat.h"
31 #include "edit-alarm.h"
34 #include "external-ug.h"
37 static const char *_name = "view/detail";
39 #define CAL_REPEAT_EVERY_2_WEEK (CAL_REPEAT_EVERY_YEAR+1)
40 #define CAL_REPEAT_EVERY_3_DAY (CAL_REPEAT_EVERY_2_WEEK+1)
42 #define ARRAY_SIZE(array) \
43 ((int)(sizeof(array) / sizeof(array[0])))
47 static void __cal_detail_update_view(void *data);
48 static void __cal_detail_edit_button_callback(void *data, Evas_Object *obj, void *ei);
50 enum genlist_item_type{
65 Evas_Object *ly; // self
78 Eina_Bool is_deleted; //When event is deleted, updating view is not needed.
87 }cal_detail_genlist_item_data;
89 static Elm_Genlist_Item_Class itc_seperator, itc_title_loc, itc_4_text, itc_mutilline, itc_parts, itc_linked_cal;
91 static void __cal_detail_delete_layout(void *data, Evas *e, Evas_Object *obj, void *ei)
95 c_retm_if(!data, "Input parameter is null");
97 cal_detail_data *p = data;
100 CALENDAR_SVC_STRUCT_FREE(&(p->cs));
104 CALENDAR_SVC_DEL_EVENT_CHANGED_CALLBACK(__cal_detail_update_view);
108 static cal_struct* __cal_detail_get_event(int idx)
111 cal_struct *cs = NULL;
112 r = CALENDAR_SVC_GET(CAL_STRUCT_SCHEDULE, idx, NULL, &cs);
113 if (r != CAL_SUCCESS || CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_DELETED) ==1)
116 CALENDAR_SVC_STRUCT_FREE(&cs);
117 ERR("CALENDAR_SVC_GET is failed");
124 static void __cal_detail_get_time_text(time_t t, int allday, char *buf, int sz)
129 localtime_r(&t, &tm);
132 time = CAL_UTIL_TIME_FORMAT_6;
134 time = CAL_UTIL_TIME_FORMAT_1;
137 cal_util_get_time_text(buf, sz, CAL_UTIL_DATE_FORMAT_1, NULL, &tm);
139 cal_util_get_time_text(buf, sz, CAL_UTIL_DATE_FORMAT_1, time, &tm);
142 static void __cal_detail_get_start_time(cal_struct *cs, char *buf, int sz, cal_detail_data* p)
151 allday = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_ALL_DAY_EVENT);
152 repeat = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_REPEAT_TERM);
154 if (repeat && !p->ad->is_aul)
157 t = mktime(CALENDAR_SVC_STRUCT_GET_TM(cs, CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_LOCAL));
159 __cal_detail_get_time_text(t, allday, buf, sz);
162 static void __cal_detail_get_end_time(cal_struct *cs, char *buf, int sz, cal_detail_data* p)
171 allday = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_ALL_DAY_EVENT);
172 repeat = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_REPEAT_TERM);
174 if (repeat && !p->ad->is_aul)
177 t = mktime(CALENDAR_SVC_STRUCT_GET_TM(cs, CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_LOCAL));
179 __cal_detail_get_time_text(t, allday, buf, sz);
182 static void __cal_detail_get_alarm(cal_detail_data * p,cal_struct *cs)
184 c_retm_if(!p, "p is null");
185 c_retm_if(!cs, "cs is null");
189 g_list_free(p->alarm_list);
190 p->alarm_list = NULL;
192 int r = CALENDAR_SVC_STRUCT_GET_LIST(cs, CAL_VALUE_LST_ALARM, &al);
193 c_retm_if(r != CAL_SUCCESS, "CALENDAR_SVC_STRUCT_GET_LIST(CAL_VALUE_LST_ALARM) is failed(%d)", r);
195 c_retm_if(!al, "al is null");
198 cal_value *val = al->data;
199 c_retm_if(!val, "val is null");
201 int tick = CALENDAR_SVC_VALUE_GET_INT(val, CAL_VALUE_INT_ALARMS_TICK);
202 cal_sch_remind_tick_unit_t unit = CALENDAR_SVC_VALUE_GET_INT(val, CAL_VALUE_INT_ALARMS_TICK_UNIT);
203 int min = cal_edit_alarm_get_min(tick, unit);
204 p->alarm_list = g_list_append(p->alarm_list,(void *)min);
205 al = g_list_next(al);
208 p->alarm_list = g_list_first(p->alarm_list);
211 static void __cal_detail_get_repeat(cal_struct *cs, char *buf, int sz)
213 c_retm_if(!cs, "cs is null");
219 term = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_REPEAT_TERM);
221 if (term == CAL_REPEAT_EVERY_WEEK) {
222 int interval = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_REPEAT_INTERVAL);
224 term = CAL_REPEAT_EVERY_2_WEEK;
227 if (term == CAL_REPEAT_EVERY_DAY) {
228 int interval = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_REPEAT_INTERVAL);
230 term = CAL_REPEAT_EVERY_3_DAY;
233 cal_edit_repeat_get_repeat_str(term, flag, buf, sz);
236 static void __cal_detail_get_save_to_str(int calid, char *buf, int sz)
238 cal_struct *cs = NULL;
239 const char *str = NULL;
242 r = CALENDAR_SVC_GET(CAL_STRUCT_CALENDAR, calid, NULL, &cs);
243 if (r != CAL_SUCCESS)
245 snprintf(buf, sz, "%s", _("Phone"));
247 CALENDAR_SVC_STRUCT_FREE(&cs);
252 if (calid == DEFAULT_CALENDAR_ID)
253 str = C_("IDS_CLD_OPT_PHONE_CALENDAR");
256 str = CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_TABLE_TXT_NAME);
258 str = C_("IDS_CLD_OPT_PHONE_CALENDAR");
261 snprintf(buf, sz, "%s", str);
263 CALENDAR_SVC_STRUCT_FREE(&cs);
266 static void __cal_detail_get_save_to(cal_struct *cs, char *buf, int sz)
270 idx = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_CALENDAR_ID);
273 snprintf(buf, sz, "%s", C_("IDS_CLD_OPT_PHONE_CALENDAR"));
277 __cal_detail_get_save_to_str(idx, buf, sz);
280 static inline const char* __cal_detail_get_note(cal_struct *cs)
282 c_retvm_if(!cs, NULL, "cs is null");
284 return CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_VALUE_TXT_DESCRIPTION);
287 static void __cal_detail_back_button_callback(void *data, Evas_Object *obj, void *ei)
291 cal_detail_data *p = data;
293 if((NULL != p->ad->ug) && (UG_DETAIL == p->ad->u_type))
295 ug_destroy_me(p->ad->ug);
299 if(p->ad->request_view == CV_DETAIL)
301 if(elm_naviframe_top_item_get(p->ad->nv) != elm_naviframe_bottom_item_get(p->ad->nv))
303 p->ad->request_view = CV_UNKNOWN;
304 p->ad->is_aul = EINA_FALSE;
306 elm_win_lower(p->ad->win);
312 if(p->ad->is_update_view)
313 edje_object_signal_emit(CAL_UTIL_GET_EDJ_DATA(p->parent), "update", "prog");
316 struct appdata * ad = p->ad;
317 c_retm_if(!ad, "ad is null");
319 ad->current_view = CV_UNKNOWN;
322 static void __cal_viewer_back_button_callback(void *data, Evas_Object *obj, void *ei)
329 static void __cal_detail_error_popup_response_event_callback(void *data, Evas_Object *obj, void *ei)
333 c_retm_if(!data, "data is null");
335 Evas_Object *popup = data;
336 struct appdata *ad = evas_object_data_get(popup, "data");
338 c_retm_if(!ad, "ad is null");
339 c_retm_if(!ad->win, "p->ad->win is null");
341 if (!elm_naviframe_top_item_get(ad->nv))
344 elm_win_lower(ad->win);
346 evas_object_del(popup);
349 static void __cal_detail_delete_event(cal_detail_data* p, Eina_Bool is_delete_all)
353 c_retm_if(!p, "p is null");
356 cal_value* value = NULL;
360 if (!is_delete_all) {
361 cal_struct *cs = __cal_detail_get_event(p->cid);
362 c_retm_if(!cs, "cs is null");
365 value = CALENDAR_SVC_VALUE_NEW(CAL_VALUE_LST_EXCEPTION_DATE);
366 CALENDAR_SVC_VALUE_SET_TIME(value,CAL_VALUE_GMT_EXCEPTION_DATE_TIME,CAL_TZ_FLAG_GMT,t);
367 CALENDAR_SVC_STRUCT_GET_LIST(cs,CAL_VALUE_LST_EXCEPTION_DATE,&list);
368 list = g_list_append(list,value);
370 CALENDAR_SVC_STRUCT_SET_LIST(cs,CAL_VALUE_LST_EXCEPTION_DATE,list);
371 r = CALENDAR_SVC_UPDATE(cs);
372 if (r != CAL_SUCCESS)
373 ERR("CALENDAR_SVC_UPDATE is failed %d", r);
375 p->is_deleted = EINA_TRUE;
377 CALENDAR_SVC_STRUCT_FREE(&cs);
380 r = CALENDAR_SVC_DELETE(CAL_STRUCT_SCHEDULE, p->cid);
381 c_retm_if(r!=CAL_SUCCESS, "CALENDAR_SVC_DELETE(CAL_STRUCT_SCHEDULE, %d) is failed(%d)", p->cid, r);
383 p->is_deleted = EINA_TRUE;
386 evas_object_del(p->popup);
388 if ((p->ad->ug) && (UG_DETAIL == p->ad->u_type))
389 ug_destroy_me(p->ad->ug);
391 if (elm_naviframe_top_item_get(p->ad->nv) == elm_naviframe_bottom_item_get(p->ad->nv))
394 elm_naviframe_item_pop(p->ad->nv);
397 struct appdata * ad = p->ad;
398 c_retm_if(!ad, "ad is null");
400 ad->current_view = CV_UNKNOWN;
403 static void __cal_detail_delete_popup_response_event_callback(void *data, Evas_Object *obj, void *event_info)
405 c_retm_if(!data, "data is null");
406 c_retm_if(!obj, "obj is null");
408 Evas_Object *popup = data;
409 Evas_Object *button = obj;
411 cal_detail_data* p = evas_object_data_get(popup, "data");
412 c_retm_if(!p, "p is null");
414 if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_BODY_ONLY_THIS_EVENT")))
415 __cal_detail_delete_event(p, EINA_FALSE);
416 else if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"))
417 || !strcmp(elm_object_text_get(button), S_("IDS_COM_SK_OK")))
418 __cal_detail_delete_event(p, EINA_TRUE);
420 evas_object_del(popup);
424 static void __cal_detail_edit_popup_response_event_callback(void *data, Evas_Object *obj, void *event_info)
426 c_retm_if(!data, "data is null");
427 c_retm_if(!obj, "obj is null");
429 Evas_Object *popup = data;
430 Evas_Object *button = obj;
432 cal_detail_data* p = evas_object_data_get(popup, "data");
433 c_retm_if(!p, "p is null");
435 struct appdata* ad = p->ad;
436 c_retm_if(!ad, "ad is null");
438 if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_BODY_ONLY_THIS_EVENT")))
439 ad->edit_special_one = EINA_TRUE;
440 else if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS")))
441 ad->edit_special_one = EINA_FALSE;
443 evas_object_del(popup);
448 cal_edit_create_view(ad, p->ly);
450 evas_object_del(popup);
454 static void __cal_detail_show_popup(cal_detail_data *p, const char *tit, Eina_Bool is_edit)
456 void (*callback_func)(void *data, Evas_Object *obj, void *ei) = NULL;
459 callback_func = __cal_detail_edit_popup_response_event_callback;
461 callback_func = __cal_detail_delete_popup_response_event_callback;
463 cal_struct *cs = __cal_detail_get_event(p->cid);
464 c_retm_if(!cs, "__cal_detail_get_event(%d) is failed", p->cid);
466 if (CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_REPEAT_TERM)) {
467 p->popup = cal_util_add_popup(p->ad->win, "verticalbuttonstyle", NULL, tit, callback_func, p,
468 C_("IDS_CLD_BODY_ONLY_THIS_EVENT"), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"),
469 S_("IDS_COM_SK_CANCEL"), NULL);
472 p->popup = cal_util_add_popup(p->ad->win, NULL, NULL, tit, callback_func, p,
473 S_("IDS_COM_SK_OK"),S_("IDS_COM_SK_CANCEL"), NULL);
476 c_retm_if(!p->popup, "elm_popup_add(p->ad->win) returned null");
479 static void __cal_detail_delete_button_callback(void *data, Evas_Object *obj, void *ei)
483 Evas_Object *ly = data;
484 cal_detail_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
485 cal_struct *cs = NULL;
491 cs = __cal_detail_get_event(p->cid);
493 __cal_detail_show_popup(p, C_("IDS_CLD_OPT_DELETE_EVENT"), EINA_FALSE);
497 CALENDAR_SVC_STRUCT_FREE(&cs);
500 static void __cal_detail_edit_button_callback(void *data, Evas_Object *obj, void *ei)
504 Evas_Object *ly = data;
505 cal_detail_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
506 cal_struct *cs = NULL;
508 p = CAL_UTIL_GET_PRIV_DATA(ly);
511 cs = __cal_detail_get_event(p->cid);
513 if (0 != CALENDAR_SVC_STRUCT_GET_INT(cs,CAL_VALUE_INT_REPEAT_TERM))
514 __cal_detail_show_popup(p, C_("IDS_CLD_HEADER_EDIT_EVENT"), EINA_TRUE);
516 cal_edit_create_view(p->ad, ly);
519 CALENDAR_SVC_STRUCT_FREE(&cs);
523 static char* __cal_detail_get_title_location_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
525 c_retvm_if(!item_data, NULL, "item_data is null");
529 cal_detail_data *p = item_data->p;
530 c_retvm_if(!p, NULL, "p is null");
532 cal_struct *cs = p->cs;
533 c_retvm_if(!cs, NULL, "cs is null");
535 if (!CAL_STRCMP(part, "elm.text.1"))
537 title = CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_VALUE_TXT_SUMMARY);
539 return strdup(title);
542 if (!CAL_STRCMP(part, "elm.text.2"))
544 loc = CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_VALUE_TXT_LOCATION);
552 static char* __cal_detail_get_save_to_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
554 cal_detail_data *p = item_data->p;
563 if (!CAL_STRCMP(part, "elm.text.1"))
565 return strdup(C_("IDS_ST_BODY_SAVE_TO"));
568 if(!CAL_STRCMP(part, "elm.text.2"))
570 __cal_detail_get_save_to(cs, buf, sizeof(buf));
577 static char* __cal_detail_get_start_time_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
581 cal_detail_data *p = item_data->p;
588 if (!CAL_STRCMP(part, "elm.text.1"))
590 return strdup(S_("IDS_COM_BODY_START"));
593 if(!CAL_STRCMP(part, "elm.text.2"))
595 __cal_detail_get_start_time(cs, buf, sizeof(buf), p);
602 static char* __cal_detail_get_end_time_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
606 cal_detail_data *p = item_data->p;
613 if (!CAL_STRCMP(part, "elm.text.1"))
615 return strdup(S_("IDS_COM_BODY_END"));
618 if(!CAL_STRCMP(part, "elm.text.2"))
620 __cal_detail_get_end_time(cs, buf, sizeof(buf), p);
627 static void __cal_detail_get_alarm_text(cal_detail_genlist_item_data *data, char* buf, int buf_size)
629 c_retm_if(!data, "data is null");
630 cal_edit_alarm_get_alarm_str(data->alarm_value, buf, buf_size);
633 static char* __cal_detail_add_alarm_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
636 char buf[1024] = {0};
637 cal_detail_data *p = item_data->p;
644 if (!CAL_STRCMP(part, "elm.text.1"))
646 return strdup(S_("IDS_COM_BODY_ALARM"));
649 if(!CAL_STRCMP(part, "elm.text.2"))
651 __cal_detail_get_alarm_text(item_data, buf, sizeof(buf));
659 static char* __cal_detail_get_repeat_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
662 char buf[1024] = {0};
663 cal_detail_data *p = item_data->p;
670 if (!CAL_STRCMP(part, "elm.text.1"))
672 return strdup(C_("IDS_CLD_BODY_REPEAT"));
675 if(!CAL_STRCMP(part, "elm.text.2"))
677 __cal_detail_get_repeat(cs, buf, sizeof(buf));
685 static char* __cal_detail_get_note_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
689 cal_detail_data *p = item_data->p;
699 static Evas_Object* __cal_detail_add_note_object(cal_detail_data *p, Evas_Object *parent, const char *text)
701 c_retvm_if(!p, NULL, "p is null");
702 c_retvm_if(!parent, NULL, "parent is null");
703 c_retvm_if(!text, NULL, "text is null");
704 c_retvm_if(!strlen(text), NULL, "strlen(text) is zero");
706 Evas_Object *layout = cal_util_add_edit_field(parent, C_("IDS_COM_BODY_NOTE"), NULL, EINA_FALSE, EINA_FALSE);
707 c_retvm_if(!layout, NULL, "layout is null");
709 Evas_Object *entry = elm_object_part_content_get(layout, "elm.swallow.content");
710 c_retvm_if(!entry, layout, "entry is null");
715 elm_entry_context_menu_disabled_set(entry, EINA_TRUE);
716 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
717 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_EXPAND);
718 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
719 elm_entry_autocapital_type_set(entry, EINA_TRUE);
720 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
722 elm_entry_entry_set(entry, text);
727 static Evas_Object* __cal_detail_add_note_icon(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
729 c_retvm_if(!obj, NULL, "obj is null");
730 c_retvm_if(!part, NULL, "part is null");
731 c_retvm_if(!item_data, NULL, "item_data is null");
733 cal_detail_data *p = item_data->p;
734 Evas_Object *edit_field = NULL;
735 const char *note = NULL;
737 cal_struct *cs = p->cs;
738 c_retvm_if(!cs, NULL, "cs is null");
740 if (!CAL_STRCMP(part, "elm.icon"))
742 note = __cal_detail_get_note(cs);
743 if (!CAL_STRLEN(note))
746 edit_field = __cal_detail_add_note_object(p, obj, elm_entry_utf8_to_markup(note));
752 static Evas_Object *__cal_detail_get_genlist_item_icon(void *data, Evas_Object *obj, const char *part)
754 c_retvm_if(!data, NULL, "data is null");
756 Evas_Object *e_obj = NULL;
758 cal_detail_genlist_item_data *item_data = (cal_detail_genlist_item_data*)data;
759 int type = item_data->type;
764 e_obj = __cal_detail_add_note_icon(obj, part, item_data);
774 static char *__cal_detail_get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
776 c_retvm_if(!data, NULL, "data is null");
778 cal_detail_genlist_item_data *item_data = (cal_detail_genlist_item_data*)data;
779 int type = item_data->type;
783 case _GTYPE_TITLE_LOC:
784 return __cal_detail_get_title_location_text(obj, part, item_data);
787 return __cal_detail_get_start_time_text(obj, part, item_data);
790 return __cal_detail_get_end_time_text(obj, part, item_data);
793 return __cal_detail_add_alarm_text(obj, part, item_data);
796 return __cal_detail_get_repeat_text(obj, part, item_data);
799 return __cal_detail_get_note_text(obj, part, item_data);
801 case _GTYPE_LINKED_CAL:
802 return __cal_detail_get_save_to_text(obj, part, item_data);
811 static void __cal_detail_genlist_item_delete_callback(void *data, Evas_Object *obj)
813 c_retm_if(!data, "data is null");
815 cal_detail_genlist_item_data *item_data = (cal_detail_genlist_item_data*)data;
822 static Eina_Bool __cal_detail_get_genlist_item_state(void *data, Evas_Object *obj, const char *part)
827 static void __cal_detail_genlist_item_select_callback(void *data, Evas_Object *obj, void *event_info)
832 static Elm_Object_Item* __cal_detail_add_genlist_item(Evas_Object *parent, Elm_Genlist_Item_Class *itc, int type, cal_detail_data *p)
834 c_retvm_if(!parent, NULL, "parent is null");
835 c_retvm_if(!itc, NULL, "itc is null");
836 c_retvm_if(!p, NULL, "p is null");
838 cal_detail_genlist_item_data *item_data = calloc(1, sizeof(cal_detail_genlist_item_data));
839 c_retvm_if(!item_data, NULL, "calloc(1, sizeof(cal_detail_genlist_item_data)) is failed");
843 item_data->type = type;
845 item_data->it = elm_genlist_item_append(parent, itc, (void*)(item_data), NULL, ELM_GENLIST_ITEM_NONE, __cal_detail_genlist_item_select_callback, NULL);
846 c_retvm_if(!item_data->it, NULL, "elm_genlist_item_append() is failed");
848 return item_data->it;
851 static Elm_Object_Item* __cal_detail_add_separator(Evas_Object *genlist, cal_detail_data *p)
853 c_retvm_if(!p, NULL, "p is null");
854 c_retvm_if(!genlist, NULL, "genlist is null");
856 Elm_Object_Item *git = __cal_detail_add_genlist_item(genlist, &itc_seperator, 0, p);
857 c_retvm_if(!git, NULL, "__cal_detail_add_genlist_item returned null");
859 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_NONE);
865 static Elm_Object_Item* __cal_detail_add_title_location(Evas_Object *genlist, cal_detail_data *p)
867 __cal_detail_add_separator(genlist, p);
868 return __cal_detail_add_genlist_item(genlist, &itc_title_loc, _GTYPE_TITLE_LOC, p);
871 static Elm_Object_Item* __cal_detail_add_start_time(Evas_Object *genlist, cal_detail_data *p)
873 __cal_detail_add_separator(genlist, p);
874 return __cal_detail_add_genlist_item(genlist, &itc_4_text, _GTYPE_START, p);
877 static void __cal_detail_add_alarm_item(Evas_Object *genlist, Elm_Genlist_Item_Class *itc, int type, cal_detail_data *p, int alarm)
879 c_retm_if(!genlist, "genlist is null");
880 c_retm_if(!itc, "itc is null");
881 c_retm_if(!p, "p is null");
883 cal_detail_genlist_item_data *item_data = calloc(1, sizeof(cal_detail_genlist_item_data));
884 c_retm_if(!item_data, "calloc is failed");
887 item_data->type = type;
888 item_data->alarm_value = alarm;
890 item_data->it = elm_genlist_item_append(genlist, itc, item_data, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
894 ERR("elm_genlist_item_append returned null");
900 static void __cal_detail_add_alarm(Evas_Object *genlist, cal_detail_data *p)
902 c_retm_if(!genlist, "genlist is null");
903 c_retm_if(!p, "p is null");
904 c_retm_if(!p->cs, "p->cs is null");
906 __cal_detail_add_separator(genlist, p);
907 __cal_detail_get_alarm(p, p->cs);
909 if (!p->alarm_list) {
910 __cal_detail_add_alarm_item(genlist, &itc_4_text, _GTYPE_ALARM, p, -1);
912 GList *alarm = p->alarm_list;
916 alarm_min = (int)alarm->data;
917 __cal_detail_add_alarm_item(genlist, &itc_4_text, _GTYPE_ALARM, p, alarm_min);
918 alarm = g_list_next(alarm);
924 static Elm_Object_Item* __cal_detail_add_end_time(Evas_Object *genlist, cal_detail_data *p)
926 __cal_detail_add_separator(genlist, p);
927 return __cal_detail_add_genlist_item(genlist, &itc_4_text, _GTYPE_END, p);
931 static Elm_Object_Item* __cal_detail_add_repeat(Evas_Object *genlist, cal_detail_data *p)
933 __cal_detail_add_separator(genlist, p);
934 return __cal_detail_add_genlist_item(genlist, &itc_4_text, _GTYPE_REPEAT, p);
938 static Elm_Object_Item* __cal_detail_add_note(Evas_Object *genlist, cal_detail_data *p)
940 c_retvm_if(!p, NULL, "p is null");
941 c_retvm_if(!genlist, NULL, "genlist is null");
943 cal_struct *cs = p->cs;
944 c_retvm_if(!cs, NULL, "cs is null");
946 const char *note = __cal_detail_get_note(cs);
947 if (!CAL_STRLEN(note))
950 __cal_detail_add_separator(genlist, p);
952 return __cal_detail_add_genlist_item(genlist, &itc_mutilline, _GTYPE_NOTE, p);
955 static Elm_Object_Item* __cal_detail_add_save_to(Evas_Object *genlist, cal_detail_data *p)
957 __cal_detail_add_separator(genlist, p);
959 return __cal_detail_add_genlist_item(genlist, &itc_linked_cal, _GTYPE_LINKED_CAL, p);
962 static void __cal_detail_show_error_popup(cal_detail_data *p)
966 c_retm_if(!p, "p is null");
967 c_retm_if(!p->ad, "p->ad is null");
968 c_retm_if(!p->ad->win, "p->ad->win is null");
971 evas_object_del(p->popup);
973 p->popup = cal_util_add_popup(p->ad->win, NULL, S_("IDS_COM_POP_WARNING"), C_("IDS_CLD_BODY_NO_EVENTS"),
974 __cal_detail_error_popup_response_event_callback, p->ad, S_("IDS_COM_SK_OK"), NULL);
975 c_retm_if(!p->popup, "cal_util_add_popup(p->ad->win) returned null");
978 static Evas_Object *__cal_detail_create_genlist(cal_detail_data *p)
980 c_retvm_if(!p, NULL, "p is null");
981 c_retvm_if(!p->ad, NULL, "p->ad is null");
983 Evas_Object *genlist;
985 if(p->ad->is_aul && p->ad->ical)
988 p->cs = __cal_detail_get_event(p->ad->cid);
991 __cal_detail_show_error_popup(p);
995 genlist = elm_genlist_add(p->ly);
996 c_retvm_if(!genlist, NULL, "elm_genlist_add(p->ly) returned null");
998 elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_NONE);
1000 itc_seperator.item_style = "dialogue/seperator";
1001 itc_seperator.func.text_get = NULL;
1002 itc_seperator.func.state_get = __cal_detail_get_genlist_item_state;
1003 itc_seperator.func.del = __cal_detail_genlist_item_delete_callback;
1006 itc_title_loc.item_style = "dialogue/2text";
1007 itc_title_loc.func.text_get = __cal_detail_get_genlist_item_label;
1008 itc_title_loc.func.del = __cal_detail_genlist_item_delete_callback;
1010 itc_4_text.item_style = "dialogue/2text";
1011 itc_4_text.func.text_get = __cal_detail_get_genlist_item_label;
1012 itc_4_text.func.del = __cal_detail_genlist_item_delete_callback;
1014 itc_mutilline.item_style = "dialogue/1icon";
1015 itc_mutilline.func.text_get = __cal_detail_get_genlist_item_label;
1016 itc_mutilline.func.del = __cal_detail_genlist_item_delete_callback;
1017 itc_mutilline.func.content_get = __cal_detail_get_genlist_item_icon;
1019 itc_parts.item_style = "dialogue/1icon";
1020 itc_parts.func.text_get = __cal_detail_get_genlist_item_label;
1021 itc_parts.func.del = __cal_detail_genlist_item_delete_callback;
1022 itc_parts.func.content_get = __cal_detail_get_genlist_item_icon;
1024 itc_linked_cal.item_style = "dialogue/2text";
1025 itc_linked_cal.func.text_get = __cal_detail_get_genlist_item_label;
1026 itc_linked_cal.func.del = __cal_detail_genlist_item_delete_callback;
1028 __cal_detail_add_title_location(genlist, p);
1029 __cal_detail_add_start_time(genlist, p);
1030 __cal_detail_add_end_time(genlist, p);
1031 __cal_detail_add_alarm(genlist, p);
1032 __cal_detail_add_repeat(genlist, p);
1033 __cal_detail_add_note(genlist, p);
1034 __cal_detail_add_save_to(genlist, p);
1039 static void __cal_detail_update_view(void *data)
1043 c_retm_if(!data, "data is null");
1045 cal_detail_data *p = data;
1050 Evas_Object *genlist;
1051 struct appdata* ad = p->ad;
1052 c_retm_if(!ad, "ad is null");
1054 is_hour24 = ad->is_hour24;
1056 cal_util_delete_evas_object(&p->genlist);
1057 genlist = __cal_detail_create_genlist(p);
1060 elm_object_part_content_set(p->ly, "sw", genlist);
1061 p->genlist = genlist;
1066 static Evas_Object *__cal_detail_create_layout(struct appdata *ad, Evas_Object *parent)
1070 Evas_Object *genlist;
1071 p = calloc(1, sizeof(cal_detail_data));
1076 ly = cal_util_add_layout(parent, "edit");
1082 evas_object_data_set(ly, "priv", p);
1086 p->alarm_list = NULL;
1088 is_hour24 = ad->is_hour24;
1090 elm_layout_theme_set(CAL_UTIL_GET_EDJ_DATA(ly),"layout", "application", "controlbar");
1092 genlist = __cal_detail_create_genlist(p);
1095 evas_object_del(ly);
1100 elm_object_part_content_set(p->ly, "sw", genlist);
1101 p->genlist = genlist;
1103 evas_object_event_callback_add(ly, EVAS_CALLBACK_DEL, __cal_detail_delete_layout, p);
1105 CALENDAR_SVC_ADD_EVENT_CHANGED_CALLBACK(__cal_detail_update_view, p);
1110 static void __cal_detail_save_to_calendar_button_callback(void *data, Evas_Object *obj, void *ei)
1114 c_retm_if(!data, "data is null");
1116 Evas_Object *ly = data;
1119 p = CAL_UTIL_GET_PRIV_DATA(ly);
1120 c_retm_if(!p, "CAL_UTIL_GET_PRIV_DATA(ly) returned null");
1122 cal_edit_create_view(p->ad, p->parent);
1125 void cal_detail_create_view(struct appdata *ad, Evas_Object *parent)
1129 c_retm_if(!ad || !parent, "Input parameter is null");
1131 if (ad->current_view == CV_DETAIL)
1135 Evas_Object *back_button;
1136 Evas_Object *controlbar;
1137 Elm_Object_Item* navi_item;
1139 ly = __cal_detail_create_layout(ad, parent);
1140 c_retm_if(!ly, "__cal_detail_create_layout(ad, parent) is failed");
1142 navi_item = elm_naviframe_item_push(ad->nv, C_("IDS_COM_BODY_DETAILS"), NULL, NULL, ly, NULL);
1145 ERR("elm_naviframe_item_push is failed");
1146 evas_object_del(ly);
1150 controlbar = cal_util_add_controlbar(ad->nv);
1153 ERR("cal_util_add_controlbar(ad->nv) is failed");
1154 elm_naviframe_item_pop(ad->nv);
1158 elm_toolbar_item_append(controlbar, NULL, S_("IDS_COM_SK_EDIT"), __cal_detail_edit_button_callback, ly);
1159 elm_toolbar_item_append(controlbar, NULL, S_("IDS_COM_BODY_DELETE"), __cal_detail_delete_button_callback, ly);
1161 elm_object_item_part_content_set( navi_item, "controlbar", controlbar);
1163 back_button = elm_object_item_part_content_get(navi_item, "prev_btn");
1166 back_button = elm_button_add(ad->nv);
1169 ERR("elm_button_add is failed.");
1172 elm_object_style_set(back_button, "naviframe/back_btn/default");
1173 elm_object_item_part_content_set(navi_item, "prev_btn", back_button);
1175 elm_object_style_set(back_button, "naviframe/back_btn/default");
1176 evas_object_smart_callback_add(back_button, "clicked", __cal_detail_back_button_callback, CAL_UTIL_GET_PRIV_DATA(ly));
1178 ad->current_view = CV_DETAIL;
1183 void cal_viewer_create_view(struct appdata *ad, Evas_Object *parent, char* raw_data)
1187 c_retm_if(!ad || !parent || !raw_data, "Input parameter is null");
1190 Evas_Object *back_button;
1191 Evas_Object *controlbar;
1192 Elm_Object_Item* navi_item;
1194 int r = CALENDAR_SVC_UTIL_CONVERT_VCS_TO_EVENT(raw_data, VCALENDAR_DATA_LEN, &ad->ical);
1195 if (r != CAL_SUCCESS)
1196 ERR("CALENDAR_SVC_UTIL_CONVERT_VCS_TO_EVENT fail. : %d", r);
1198 ly = __cal_detail_create_layout(ad, parent);
1199 c_retm_if(!ly, "__cal_detail_create_layout(ad, parent) is failed");
1201 navi_item = elm_naviframe_item_push(ad->nv, _("VCS Viewer"), NULL, NULL, ly, NULL);
1204 ERR("elm_naviframe_item_push is failed");
1205 evas_object_del(ly);
1209 controlbar = cal_util_add_controlbar(ad->nv);
1212 ERR("cal_util_add_controlbar(ad->nv) is failed");
1213 elm_naviframe_item_pop(ad->nv);
1217 elm_toolbar_item_append(controlbar, NULL, _("Save to Calendar"), __cal_detail_save_to_calendar_button_callback, ly);
1219 elm_object_item_part_content_set(navi_item, "controlbar", controlbar);
1221 back_button = elm_object_item_part_content_get(navi_item, "prev_btn");
1224 back_button = elm_button_add(ad->nv);
1227 ERR("elm_button_add is failed.");
1230 elm_object_style_set(back_button, "naviframe/back_btn/default");
1231 elm_object_item_part_content_set(navi_item, "prev_btn", back_button);
1233 elm_object_style_set(back_button, "naviframe/back_btn/default");
1234 evas_object_smart_callback_add(back_button, "clicked", __cal_viewer_back_button_callback, CAL_UTIL_GET_PRIV_DATA(ly));