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://www.tizenopensource.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.
26 #include "edit-repeat.h"
27 #include "edit-alarm.h"
30 #include "external-ug.h"
33 static const char *_name = "view/detail";
35 #define CAL_REPEAT_EVERY_2_WEEK (CAL_REPEAT_EVERY_YEAR+1)
36 #define CAL_REPEAT_EVERY_3_DAY (CAL_REPEAT_EVERY_2_WEEK+1)
38 #define ARRAY_SIZE(array) \
39 ((int)(sizeof(array) / sizeof(array[0])))
43 static void __cal_detail_update_view(void *data);
44 static void __cal_detail_edit_button_callback(void *data, Evas_Object *obj, void *ei);
46 enum genlist_item_type{
61 Evas_Object *ly; // self
74 Eina_Bool is_deleted; //When event is deleted, updating view is not needed.
83 }cal_detail_genlist_item_data;
85 static Elm_Genlist_Item_Class itc_seperator, itc_title_loc, itc_4_text, itc_mutilline, itc_parts, itc_linked_cal;
87 static void __cal_detail_delete_layout(void *data, Evas *e, Evas_Object *obj, void *ei)
91 c_retm_if(!data, "Input parameter is null");
93 cal_detail_data *p = data;
96 CALENDAR_SVC_STRUCT_FREE(&(p->cs));
100 CALENDAR_SVC_DEL_EVENT_CHANGED_CALLBACK(__cal_detail_update_view);
104 static cal_struct* __cal_detail_get_event(int idx)
107 cal_struct *cs = NULL;
108 r = CALENDAR_SVC_GET(CAL_STRUCT_SCHEDULE, idx, NULL, &cs);
109 if (r != CAL_SUCCESS || CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_DELETED) ==1)
112 CALENDAR_SVC_STRUCT_FREE(&cs);
113 ERR("CALENDAR_SVC_GET is failed");
120 static void __cal_detail_get_time_text(time_t t, int allday, char *buf, int sz)
125 localtime_r(&t, &tm);
128 time = CAL_UTIL_TIME_FORMAT_6;
130 time = CAL_UTIL_TIME_FORMAT_1;
133 cal_util_get_time_text(buf, sz, CAL_UTIL_DATE_FORMAT_1, NULL, &tm);
135 cal_util_get_time_text(buf, sz, CAL_UTIL_DATE_FORMAT_1, time, &tm);
138 static void __cal_detail_get_start_time(cal_struct *cs, char *buf, int sz, cal_detail_data* p)
147 allday = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_ALL_DAY_EVENT);
148 repeat = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_REPEAT_TERM);
150 if (repeat && !p->ad->is_aul)
153 t = mktime(CALENDAR_SVC_STRUCT_GET_TM(cs, CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_LOCAL));
155 __cal_detail_get_time_text(t, allday, buf, sz);
158 static void __cal_detail_get_end_time(cal_struct *cs, char *buf, int sz, cal_detail_data* p)
167 allday = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_ALL_DAY_EVENT);
168 repeat = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_REPEAT_TERM);
170 if (repeat && !p->ad->is_aul)
173 t = mktime(CALENDAR_SVC_STRUCT_GET_TM(cs, CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_LOCAL));
175 __cal_detail_get_time_text(t, allday, buf, sz);
178 static void __cal_detail_get_alarm(cal_detail_data * p,cal_struct *cs)
180 c_retm_if(!p, "p is null");
181 c_retm_if(!cs, "cs is null");
185 g_list_free(p->alarm_list);
186 p->alarm_list = NULL;
188 int r = CALENDAR_SVC_STRUCT_GET_LIST(cs, CAL_VALUE_LST_ALARM, &al);
189 c_retm_if(r != CAL_SUCCESS, "CALENDAR_SVC_STRUCT_GET_LIST(CAL_VALUE_LST_ALARM) is failed(%d)", r);
191 c_retm_if(!al, "al is null");
194 cal_value *val = al->data;
195 c_retm_if(!val, "val is null");
197 int tick = CALENDAR_SVC_VALUE_GET_INT(val, CAL_VALUE_INT_ALARMS_TICK);
198 cal_sch_remind_tick_unit_t unit = CALENDAR_SVC_VALUE_GET_INT(val, CAL_VALUE_INT_ALARMS_TICK_UNIT);
199 int min = cal_edit_alarm_get_min(tick, unit);
200 p->alarm_list = g_list_append(p->alarm_list,(void *)min);
201 al = g_list_next(al);
204 p->alarm_list = g_list_first(p->alarm_list);
207 static void __cal_detail_get_repeat(cal_struct *cs, char *buf, int sz)
209 c_retm_if(!cs, "cs is null");
215 term = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_REPEAT_TERM);
217 if (term == CAL_REPEAT_EVERY_WEEK) {
218 int interval = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_REPEAT_INTERVAL);
220 term = CAL_REPEAT_EVERY_2_WEEK;
223 if (term == CAL_REPEAT_EVERY_DAY) {
224 int interval = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_REPEAT_INTERVAL);
226 term = CAL_REPEAT_EVERY_3_DAY;
229 cal_edit_repeat_get_repeat_str(term, flag, buf, sz);
232 static void __cal_detail_get_save_to_str(int calid, char *buf, int sz)
234 cal_struct *cs = NULL;
235 const char *str = NULL;
238 r = CALENDAR_SVC_GET(CAL_STRUCT_CALENDAR, calid, NULL, &cs);
239 if (r != CAL_SUCCESS)
241 snprintf(buf, sz, "%s", _("Phone"));
243 CALENDAR_SVC_STRUCT_FREE(&cs);
248 if (calid == DEFAULT_CALENDAR_ID)
249 str = C_("IDS_CLD_OPT_PHONE_CALENDAR");
252 str = CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_TABLE_TXT_NAME);
254 str = C_("IDS_CLD_OPT_PHONE_CALENDAR");
257 snprintf(buf, sz, "%s", str);
259 CALENDAR_SVC_STRUCT_FREE(&cs);
262 static void __cal_detail_get_save_to(cal_struct *cs, char *buf, int sz)
266 idx = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_CALENDAR_ID);
269 snprintf(buf, sz, "%s", C_("IDS_CLD_OPT_PHONE_CALENDAR"));
273 __cal_detail_get_save_to_str(idx, buf, sz);
276 static inline const char* __cal_detail_get_note(cal_struct *cs)
278 c_retvm_if(!cs, NULL, "cs is null");
280 return CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_VALUE_TXT_DESCRIPTION);
283 static void __cal_detail_back_button_callback(void *data, Evas_Object *obj, void *ei)
287 cal_detail_data *p = data;
289 if((NULL != p->ad->ug) && (UG_DETAIL == p->ad->u_type))
291 ug_destroy_me(p->ad->ug);
295 if(p->ad->request_view == CV_DETAIL)
297 if(elm_naviframe_top_item_get(p->ad->nv) != elm_naviframe_bottom_item_get(p->ad->nv))
299 p->ad->request_view = CV_UNKNOWN;
300 p->ad->is_aul = EINA_FALSE;
302 elm_win_lower(p->ad->win);
308 if(p->ad->is_update_view)
309 edje_object_signal_emit(CAL_UTIL_GET_EDJ_DATA(p->parent), "update", "prog");
312 struct appdata * ad = p->ad;
313 c_retm_if(!ad, "ad is null");
315 ad->current_view = CV_UNKNOWN;
318 static void __cal_viewer_back_button_callback(void *data, Evas_Object *obj, void *ei)
325 static void __cal_detail_error_popup_response_event_callback(void *data, Evas_Object *obj, void *ei)
329 c_retm_if(!data, "data is null");
331 Evas_Object *popup = data;
332 struct appdata *ad = evas_object_data_get(popup, "data");
334 c_retm_if(!ad, "ad is null");
335 c_retm_if(!ad->win, "p->ad->win is null");
337 if (!elm_naviframe_top_item_get(ad->nv))
340 elm_win_lower(ad->win);
342 evas_object_del(popup);
345 static void __cal_detail_delete_event(cal_detail_data* p, Eina_Bool is_delete_all)
349 c_retm_if(!p, "p is null");
352 cal_value* value = NULL;
356 if (!is_delete_all) {
357 cal_struct *cs = __cal_detail_get_event(p->cid);
358 c_retm_if(!cs, "cs is null");
361 value = CALENDAR_SVC_VALUE_NEW(CAL_VALUE_LST_EXCEPTION_DATE);
362 CALENDAR_SVC_VALUE_SET_TIME(value,CAL_VALUE_GMT_EXCEPTION_DATE_TIME,CAL_TZ_FLAG_GMT,t);
363 CALENDAR_SVC_STRUCT_GET_LIST(cs,CAL_VALUE_LST_EXCEPTION_DATE,&list);
364 list = g_list_append(list,value);
366 CALENDAR_SVC_STRUCT_SET_LIST(cs,CAL_VALUE_LST_EXCEPTION_DATE,list);
367 r = CALENDAR_SVC_UPDATE(cs);
368 if (r != CAL_SUCCESS)
369 ERR("CALENDAR_SVC_UPDATE is failed %d", r);
371 p->is_deleted = EINA_TRUE;
373 CALENDAR_SVC_STRUCT_FREE(&cs);
376 r = CALENDAR_SVC_DELETE(CAL_STRUCT_SCHEDULE, p->cid);
377 c_retm_if(r!=CAL_SUCCESS, "CALENDAR_SVC_DELETE(CAL_STRUCT_SCHEDULE, %d) is failed(%d)", p->cid, r);
379 p->is_deleted = EINA_TRUE;
382 evas_object_del(p->popup);
384 if ((p->ad->ug) && (UG_DETAIL == p->ad->u_type))
385 ug_destroy_me(p->ad->ug);
387 if (elm_naviframe_top_item_get(p->ad->nv) == elm_naviframe_bottom_item_get(p->ad->nv))
390 elm_naviframe_item_pop(p->ad->nv);
393 struct appdata * ad = p->ad;
394 c_retm_if(!ad, "ad is null");
396 ad->current_view = CV_UNKNOWN;
399 static void __cal_detail_delete_popup_response_event_callback(void *data, Evas_Object *obj, void *event_info)
401 c_retm_if(!data, "data is null");
402 c_retm_if(!obj, "obj is null");
404 Evas_Object *popup = data;
405 Evas_Object *button = obj;
407 cal_detail_data* p = evas_object_data_get(popup, "data");
408 c_retm_if(!p, "p is null");
410 if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_BODY_ONLY_THIS_EVENT")))
411 __cal_detail_delete_event(p, EINA_FALSE);
412 else if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"))
413 || !strcmp(elm_object_text_get(button), S_("IDS_COM_SK_OK")))
414 __cal_detail_delete_event(p, EINA_TRUE);
416 evas_object_del(popup);
420 static void __cal_detail_edit_popup_response_event_callback(void *data, Evas_Object *obj, void *event_info)
422 c_retm_if(!data, "data is null");
423 c_retm_if(!obj, "obj is null");
425 Evas_Object *popup = data;
426 Evas_Object *button = obj;
428 cal_detail_data* p = evas_object_data_get(popup, "data");
429 c_retm_if(!p, "p is null");
431 struct appdata* ad = p->ad;
432 c_retm_if(!ad, "ad is null");
434 if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_BODY_ONLY_THIS_EVENT")))
435 ad->edit_special_one = EINA_TRUE;
436 else if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS")))
437 ad->edit_special_one = EINA_FALSE;
439 evas_object_del(popup);
444 cal_edit_create_view(ad, p->ly);
446 evas_object_del(popup);
450 static void __cal_detail_show_popup(cal_detail_data *p, const char *tit, Eina_Bool is_edit)
452 void (*callback_func)(void *data, Evas_Object *obj, void *ei) = NULL;
455 callback_func = __cal_detail_edit_popup_response_event_callback;
457 callback_func = __cal_detail_delete_popup_response_event_callback;
459 cal_struct *cs = __cal_detail_get_event(p->cid);
460 c_retm_if(!cs, "__cal_detail_get_event(%d) is failed", p->cid);
462 if (CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_REPEAT_TERM)) {
463 p->popup = cal_util_add_popup(p->ad->win, "verticalbuttonstyle", NULL, tit, callback_func, p,
464 C_("IDS_CLD_BODY_ONLY_THIS_EVENT"), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"),
465 S_("IDS_COM_SK_CANCEL"), NULL);
468 p->popup = cal_util_add_popup(p->ad->win, NULL, NULL, tit, callback_func, p,
469 S_("IDS_COM_SK_OK"),S_("IDS_COM_SK_CANCEL"), NULL);
472 c_retm_if(!p->popup, "elm_popup_add(p->ad->win) returned null");
475 static void __cal_detail_delete_button_callback(void *data, Evas_Object *obj, void *ei)
479 Evas_Object *ly = data;
480 cal_detail_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
481 cal_struct *cs = NULL;
487 cs = __cal_detail_get_event(p->cid);
489 __cal_detail_show_popup(p, C_("IDS_CLD_OPT_DELETE_EVENT"), EINA_FALSE);
493 CALENDAR_SVC_STRUCT_FREE(&cs);
496 static void __cal_detail_edit_button_callback(void *data, Evas_Object *obj, void *ei)
500 Evas_Object *ly = data;
501 cal_detail_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
502 cal_struct *cs = NULL;
504 p = CAL_UTIL_GET_PRIV_DATA(ly);
507 cs = __cal_detail_get_event(p->cid);
509 if (0 != CALENDAR_SVC_STRUCT_GET_INT(cs,CAL_VALUE_INT_REPEAT_TERM))
510 __cal_detail_show_popup(p, C_("IDS_CLD_HEADER_EDIT_EVENT"), EINA_TRUE);
512 cal_edit_create_view(p->ad, ly);
515 CALENDAR_SVC_STRUCT_FREE(&cs);
519 static char* __cal_detail_get_title_location_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
521 c_retvm_if(!item_data, NULL, "item_data is null");
525 cal_detail_data *p = item_data->p;
526 c_retvm_if(!p, NULL, "p is null");
528 cal_struct *cs = p->cs;
529 c_retvm_if(!cs, NULL, "cs is null");
531 if (!CAL_STRCMP(part, "elm.text.1"))
533 title = CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_VALUE_TXT_SUMMARY);
535 return strdup(title);
538 if (!CAL_STRCMP(part, "elm.text.2"))
540 loc = CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_VALUE_TXT_LOCATION);
548 static char* __cal_detail_get_save_to_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
550 cal_detail_data *p = item_data->p;
559 if (!CAL_STRCMP(part, "elm.text.1"))
561 return strdup(C_("IDS_ST_BODY_SAVE_TO"));
564 if(!CAL_STRCMP(part, "elm.text.2"))
566 __cal_detail_get_save_to(cs, buf, sizeof(buf));
573 static char* __cal_detail_get_start_time_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
577 cal_detail_data *p = item_data->p;
584 if (!CAL_STRCMP(part, "elm.text.1"))
586 return strdup(S_("IDS_COM_BODY_START"));
589 if(!CAL_STRCMP(part, "elm.text.2"))
591 __cal_detail_get_start_time(cs, buf, sizeof(buf), p);
598 static char* __cal_detail_get_end_time_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
602 cal_detail_data *p = item_data->p;
609 if (!CAL_STRCMP(part, "elm.text.1"))
611 return strdup(S_("IDS_COM_BODY_END"));
614 if(!CAL_STRCMP(part, "elm.text.2"))
616 __cal_detail_get_end_time(cs, buf, sizeof(buf), p);
623 static void __cal_detail_get_alarm_text(cal_detail_genlist_item_data *data, char* buf, int buf_size)
625 c_retm_if(!data, "data is null");
626 cal_edit_alarm_get_alarm_str(data->alarm_value, buf, buf_size);
629 static char* __cal_detail_add_alarm_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
632 char buf[1024] = {0};
633 cal_detail_data *p = item_data->p;
640 if (!CAL_STRCMP(part, "elm.text.1"))
642 return strdup(S_("IDS_COM_BODY_ALARM"));
645 if(!CAL_STRCMP(part, "elm.text.2"))
647 __cal_detail_get_alarm_text(item_data, buf, sizeof(buf));
655 static char* __cal_detail_get_repeat_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
658 char buf[1024] = {0};
659 cal_detail_data *p = item_data->p;
666 if (!CAL_STRCMP(part, "elm.text.1"))
668 return strdup(C_("IDS_CLD_BODY_REPEAT"));
671 if(!CAL_STRCMP(part, "elm.text.2"))
673 __cal_detail_get_repeat(cs, buf, sizeof(buf));
681 static char* __cal_detail_get_note_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
685 cal_detail_data *p = item_data->p;
695 static Evas_Object* __cal_detail_add_note_object(cal_detail_data *p, Evas_Object *parent, const char *text)
697 c_retvm_if(!p, NULL, "p is null");
698 c_retvm_if(!parent, NULL, "parent is null");
699 c_retvm_if(!text, NULL, "text is null");
700 c_retvm_if(!strlen(text), NULL, "strlen(text) is zero");
702 Evas_Object *layout = cal_util_add_edit_field(parent, C_("IDS_COM_BODY_NOTE"), NULL, EINA_FALSE, EINA_FALSE);
703 c_retvm_if(!layout, NULL, "layout is null");
705 Evas_Object *entry = elm_object_part_content_get(layout, "elm.swallow.content");
706 c_retvm_if(!entry, layout, "entry is null");
711 elm_entry_context_menu_disabled_set(entry, EINA_TRUE);
712 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
713 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_EXPAND);
714 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
715 elm_entry_autocapital_type_set(entry, EINA_TRUE);
716 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
718 elm_entry_entry_set(entry, text);
723 static Evas_Object* __cal_detail_add_note_icon(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
725 c_retvm_if(!obj, NULL, "obj is null");
726 c_retvm_if(!part, NULL, "part is null");
727 c_retvm_if(!item_data, NULL, "item_data is null");
729 cal_detail_data *p = item_data->p;
730 Evas_Object *edit_field = NULL;
731 const char *note = NULL;
733 cal_struct *cs = p->cs;
734 c_retvm_if(!cs, NULL, "cs is null");
736 if (!CAL_STRCMP(part, "elm.icon"))
738 note = __cal_detail_get_note(cs);
739 if (!CAL_STRLEN(note))
742 edit_field = __cal_detail_add_note_object(p, obj, elm_entry_utf8_to_markup(note));
748 static Evas_Object *__cal_detail_get_genlist_item_icon(void *data, Evas_Object *obj, const char *part)
750 c_retvm_if(!data, NULL, "data is null");
752 Evas_Object *e_obj = NULL;
754 cal_detail_genlist_item_data *item_data = (cal_detail_genlist_item_data*)data;
755 int type = item_data->type;
760 e_obj = __cal_detail_add_note_icon(obj, part, item_data);
770 static char *__cal_detail_get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
772 c_retvm_if(!data, NULL, "data is null");
774 cal_detail_genlist_item_data *item_data = (cal_detail_genlist_item_data*)data;
775 int type = item_data->type;
779 case _GTYPE_TITLE_LOC:
780 return __cal_detail_get_title_location_text(obj, part, item_data);
783 return __cal_detail_get_start_time_text(obj, part, item_data);
786 return __cal_detail_get_end_time_text(obj, part, item_data);
789 return __cal_detail_add_alarm_text(obj, part, item_data);
792 return __cal_detail_get_repeat_text(obj, part, item_data);
795 return __cal_detail_get_note_text(obj, part, item_data);
797 case _GTYPE_LINKED_CAL:
798 return __cal_detail_get_save_to_text(obj, part, item_data);
807 static void __cal_detail_genlist_item_delete_callback(void *data, Evas_Object *obj)
809 c_retm_if(!data, "data is null");
811 cal_detail_genlist_item_data *item_data = (cal_detail_genlist_item_data*)data;
818 static Eina_Bool __cal_detail_get_genlist_item_state(void *data, Evas_Object *obj, const char *part)
823 static void __cal_detail_genlist_item_select_callback(void *data, Evas_Object *obj, void *event_info)
828 static Elm_Object_Item* __cal_detail_add_genlist_item(Evas_Object *parent, Elm_Genlist_Item_Class *itc, int type, cal_detail_data *p)
830 c_retvm_if(!parent, NULL, "parent is null");
831 c_retvm_if(!itc, NULL, "itc is null");
832 c_retvm_if(!p, NULL, "p is null");
834 cal_detail_genlist_item_data *item_data = calloc(1, sizeof(cal_detail_genlist_item_data));
835 c_retvm_if(!item_data, NULL, "calloc(1, sizeof(cal_detail_genlist_item_data)) is failed");
839 item_data->type = type;
841 item_data->it = elm_genlist_item_append(parent, itc, (void*)(item_data), NULL, ELM_GENLIST_ITEM_NONE, __cal_detail_genlist_item_select_callback, NULL);
842 c_retvm_if(!item_data->it, NULL, "elm_genlist_item_append() is failed");
844 return item_data->it;
847 static Elm_Object_Item* __cal_detail_add_separator(Evas_Object *genlist, cal_detail_data *p)
849 c_retvm_if(!p, NULL, "p is null");
850 c_retvm_if(!genlist, NULL, "genlist is null");
852 Elm_Object_Item *git = __cal_detail_add_genlist_item(genlist, &itc_seperator, 0, p);
853 c_retvm_if(!git, NULL, "__cal_detail_add_genlist_item returned null");
855 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_NONE);
861 static Elm_Object_Item* __cal_detail_add_title_location(Evas_Object *genlist, cal_detail_data *p)
863 __cal_detail_add_separator(genlist, p);
864 return __cal_detail_add_genlist_item(genlist, &itc_title_loc, _GTYPE_TITLE_LOC, p);
867 static Elm_Object_Item* __cal_detail_add_start_time(Evas_Object *genlist, cal_detail_data *p)
869 __cal_detail_add_separator(genlist, p);
870 return __cal_detail_add_genlist_item(genlist, &itc_4_text, _GTYPE_START, p);
873 static void __cal_detail_add_alarm_item(Evas_Object *genlist, Elm_Genlist_Item_Class *itc, int type, cal_detail_data *p, int alarm)
875 c_retm_if(!genlist, "genlist is null");
876 c_retm_if(!itc, "itc is null");
877 c_retm_if(!p, "p is null");
879 cal_detail_genlist_item_data *item_data = calloc(1, sizeof(cal_detail_genlist_item_data));
880 c_retm_if(!item_data, "calloc is failed");
883 item_data->type = type;
884 item_data->alarm_value = alarm;
886 item_data->it = elm_genlist_item_append(genlist, itc, item_data, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
890 ERR("elm_genlist_item_append returned null");
896 static void __cal_detail_add_alarm(Evas_Object *genlist, cal_detail_data *p)
898 c_retm_if(!genlist, "genlist is null");
899 c_retm_if(!p, "p is null");
900 c_retm_if(!p->cs, "p->cs is null");
902 __cal_detail_add_separator(genlist, p);
903 __cal_detail_get_alarm(p, p->cs);
905 if (!p->alarm_list) {
906 __cal_detail_add_alarm_item(genlist, &itc_4_text, _GTYPE_ALARM, p, -1);
908 GList *alarm = p->alarm_list;
912 alarm_min = (int)alarm->data;
913 __cal_detail_add_alarm_item(genlist, &itc_4_text, _GTYPE_ALARM, p, alarm_min);
914 alarm = g_list_next(alarm);
920 static Elm_Object_Item* __cal_detail_add_end_time(Evas_Object *genlist, cal_detail_data *p)
922 __cal_detail_add_separator(genlist, p);
923 return __cal_detail_add_genlist_item(genlist, &itc_4_text, _GTYPE_END, p);
927 static Elm_Object_Item* __cal_detail_add_repeat(Evas_Object *genlist, cal_detail_data *p)
929 __cal_detail_add_separator(genlist, p);
930 return __cal_detail_add_genlist_item(genlist, &itc_4_text, _GTYPE_REPEAT, p);
934 static Elm_Object_Item* __cal_detail_add_note(Evas_Object *genlist, cal_detail_data *p)
936 c_retvm_if(!p, NULL, "p is null");
937 c_retvm_if(!genlist, NULL, "genlist is null");
939 cal_struct *cs = p->cs;
940 c_retvm_if(!cs, NULL, "cs is null");
942 const char *note = __cal_detail_get_note(cs);
943 if (!CAL_STRLEN(note))
946 __cal_detail_add_separator(genlist, p);
948 return __cal_detail_add_genlist_item(genlist, &itc_mutilline, _GTYPE_NOTE, p);
951 static Elm_Object_Item* __cal_detail_add_save_to(Evas_Object *genlist, cal_detail_data *p)
953 __cal_detail_add_separator(genlist, p);
955 return __cal_detail_add_genlist_item(genlist, &itc_linked_cal, _GTYPE_LINKED_CAL, p);
958 static void __cal_detail_show_error_popup(cal_detail_data *p)
962 c_retm_if(!p, "p is null");
963 c_retm_if(!p->ad, "p->ad is null");
964 c_retm_if(!p->ad->win, "p->ad->win is null");
967 evas_object_del(p->popup);
969 p->popup = cal_util_add_popup(p->ad->win, NULL, S_("IDS_COM_POP_WARNING"), C_("IDS_CLD_BODY_NO_EVENTS"),
970 __cal_detail_error_popup_response_event_callback, p->ad, S_("IDS_COM_SK_OK"), NULL);
971 c_retm_if(!p->popup, "cal_util_add_popup(p->ad->win) returned null");
974 static Evas_Object *__cal_detail_create_genlist(cal_detail_data *p)
976 c_retvm_if(!p, NULL, "p is null");
977 c_retvm_if(!p->ad, NULL, "p->ad is null");
979 Evas_Object *genlist;
981 if(p->ad->is_aul && p->ad->ical)
984 p->cs = __cal_detail_get_event(p->ad->cid);
987 __cal_detail_show_error_popup(p);
991 genlist = elm_genlist_add(p->ly);
992 c_retvm_if(!genlist, NULL, "elm_genlist_add(p->ly) returned null");
994 elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_NONE);
996 itc_seperator.item_style = "dialogue/seperator";
997 itc_seperator.func.text_get = NULL;
998 itc_seperator.func.state_get = __cal_detail_get_genlist_item_state;
999 itc_seperator.func.del = __cal_detail_genlist_item_delete_callback;
1002 itc_title_loc.item_style = "dialogue/2text";
1003 itc_title_loc.func.text_get = __cal_detail_get_genlist_item_label;
1004 itc_title_loc.func.del = __cal_detail_genlist_item_delete_callback;
1006 itc_4_text.item_style = "dialogue/2text";
1007 itc_4_text.func.text_get = __cal_detail_get_genlist_item_label;
1008 itc_4_text.func.del = __cal_detail_genlist_item_delete_callback;
1010 itc_mutilline.item_style = "dialogue/1icon";
1011 itc_mutilline.func.text_get = __cal_detail_get_genlist_item_label;
1012 itc_mutilline.func.del = __cal_detail_genlist_item_delete_callback;
1013 itc_mutilline.func.content_get = __cal_detail_get_genlist_item_icon;
1015 itc_parts.item_style = "dialogue/1icon";
1016 itc_parts.func.text_get = __cal_detail_get_genlist_item_label;
1017 itc_parts.func.del = __cal_detail_genlist_item_delete_callback;
1018 itc_parts.func.content_get = __cal_detail_get_genlist_item_icon;
1020 itc_linked_cal.item_style = "dialogue/2text";
1021 itc_linked_cal.func.text_get = __cal_detail_get_genlist_item_label;
1022 itc_linked_cal.func.del = __cal_detail_genlist_item_delete_callback;
1024 __cal_detail_add_title_location(genlist, p);
1025 __cal_detail_add_start_time(genlist, p);
1026 __cal_detail_add_end_time(genlist, p);
1027 __cal_detail_add_alarm(genlist, p);
1028 __cal_detail_add_repeat(genlist, p);
1029 __cal_detail_add_note(genlist, p);
1030 __cal_detail_add_save_to(genlist, p);
1035 static void __cal_detail_update_view(void *data)
1039 c_retm_if(!data, "data is null");
1041 cal_detail_data *p = data;
1046 Evas_Object *genlist;
1047 struct appdata* ad = p->ad;
1048 c_retm_if(!ad, "ad is null");
1050 is_hour24 = ad->is_hour24;
1052 cal_util_delete_evas_object(&p->genlist);
1053 genlist = __cal_detail_create_genlist(p);
1056 elm_object_part_content_set(p->ly, "sw", genlist);
1057 p->genlist = genlist;
1062 static Evas_Object *__cal_detail_create_layout(struct appdata *ad, Evas_Object *parent)
1066 Evas_Object *genlist;
1067 p = calloc(1, sizeof(cal_detail_data));
1072 ly = cal_util_add_layout(parent, "edit");
1078 evas_object_data_set(ly, "priv", p);
1082 p->alarm_list = NULL;
1084 is_hour24 = ad->is_hour24;
1086 elm_layout_theme_set(CAL_UTIL_GET_EDJ_DATA(ly),"layout", "application", "controlbar");
1088 genlist = __cal_detail_create_genlist(p);
1091 evas_object_del(ly);
1096 elm_object_part_content_set(p->ly, "sw", genlist);
1097 p->genlist = genlist;
1099 evas_object_event_callback_add(ly, EVAS_CALLBACK_DEL, __cal_detail_delete_layout, p);
1101 CALENDAR_SVC_ADD_EVENT_CHANGED_CALLBACK(__cal_detail_update_view, p);
1106 static void __cal_detail_save_to_calendar_button_callback(void *data, Evas_Object *obj, void *ei)
1110 c_retm_if(!data, "data is null");
1112 Evas_Object *ly = data;
1115 p = CAL_UTIL_GET_PRIV_DATA(ly);
1116 c_retm_if(!p, "CAL_UTIL_GET_PRIV_DATA(ly) returned null");
1118 cal_edit_create_view(p->ad, p->parent);
1121 void cal_detail_create_view(struct appdata *ad, Evas_Object *parent)
1125 c_retm_if(!ad || !parent, "Input parameter is null");
1127 if (ad->current_view == CV_DETAIL)
1131 Evas_Object *back_button;
1132 Evas_Object *controlbar;
1133 Elm_Object_Item* navi_item;
1135 ly = __cal_detail_create_layout(ad, parent);
1136 c_retm_if(!ly, "__cal_detail_create_layout(ad, parent) is failed");
1138 navi_item = elm_naviframe_item_push(ad->nv, C_("IDS_COM_BODY_DETAILS"), NULL, NULL, ly, NULL);
1141 ERR("elm_naviframe_item_push is failed");
1142 evas_object_del(ly);
1146 controlbar = cal_util_add_controlbar(ad->nv);
1149 ERR("cal_util_add_controlbar(ad->nv) is failed");
1150 elm_naviframe_item_pop(ad->nv);
1154 elm_toolbar_item_append(controlbar, NULL, S_("IDS_COM_SK_EDIT"), __cal_detail_edit_button_callback, ly);
1155 elm_toolbar_item_append(controlbar, NULL, S_("IDS_COM_BODY_DELETE"), __cal_detail_delete_button_callback, ly);
1157 elm_object_item_part_content_set( navi_item, "controlbar", controlbar);
1159 back_button = elm_object_item_part_content_get(navi_item, "prev_btn");
1162 back_button = elm_button_add(ad->nv);
1165 ERR("elm_button_add is failed.");
1168 elm_object_style_set(back_button, "naviframe/back_btn/default");
1169 elm_object_item_part_content_set(navi_item, "prev_btn", back_button);
1171 elm_object_style_set(back_button, "naviframe/back_btn/default");
1172 evas_object_smart_callback_add(back_button, "clicked", __cal_detail_back_button_callback, CAL_UTIL_GET_PRIV_DATA(ly));
1174 ad->current_view = CV_DETAIL;
1179 void cal_viewer_create_view(struct appdata *ad, Evas_Object *parent, char* raw_data)
1183 c_retm_if(!ad || !parent || !raw_data, "Input parameter is null");
1186 Evas_Object *back_button;
1187 Evas_Object *controlbar;
1188 Elm_Object_Item* navi_item;
1190 int r = CALENDAR_SVC_UTIL_CONVERT_VCS_TO_EVENT(raw_data, VCALENDAR_DATA_LEN, &ad->ical);
1191 if (r != CAL_SUCCESS)
1192 ERR("CALENDAR_SVC_UTIL_CONVERT_VCS_TO_EVENT fail. : %d", r);
1194 ly = __cal_detail_create_layout(ad, parent);
1195 c_retm_if(!ly, "__cal_detail_create_layout(ad, parent) is failed");
1197 navi_item = elm_naviframe_item_push(ad->nv, _("VCS Viewer"), NULL, NULL, ly, NULL);
1200 ERR("elm_naviframe_item_push is failed");
1201 evas_object_del(ly);
1205 controlbar = cal_util_add_controlbar(ad->nv);
1208 ERR("cal_util_add_controlbar(ad->nv) is failed");
1209 elm_naviframe_item_pop(ad->nv);
1213 elm_toolbar_item_append(controlbar, NULL, _("Save to Calendar"), __cal_detail_save_to_calendar_button_callback, ly);
1215 elm_object_item_part_content_set(navi_item, "controlbar", controlbar);
1217 back_button = elm_object_item_part_content_get(navi_item, "prev_btn");
1220 back_button = elm_button_add(ad->nv);
1223 ERR("elm_button_add is failed.");
1226 elm_object_style_set(back_button, "naviframe/back_btn/default");
1227 elm_object_item_part_content_set(navi_item, "prev_btn", back_button);
1229 elm_object_style_set(back_button, "naviframe/back_btn/default");
1230 evas_object_smart_callback_add(back_button, "clicked", __cal_viewer_back_button_callback, CAL_UTIL_GET_PRIV_DATA(ly));