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.
26 #include <ui-gadget-module.h>
27 #include <appcore-efl.h>
31 #include "edit-alarm.h"
32 #include "edit-repeat.h"
36 #define INVALID_TIMEZONE_VALUE (100)
41 Evas_Object *ly; // self
43 Evas_Object *nv; // navigatino bar
47 Evas_Object *e_title; // entry title
48 Evas_Object *entry_loc; // entry location
49 Evas_Object *l_start; // layout start
50 Evas_Object *l_end; // layout end
51 Evas_Object *l_alarm; // layout alarm
52 Evas_Object *l_repeat; // layout repeat
53 Evas_Object *l_saveto; // layout save event to
54 Evas_Object *e_note; // entry note
55 Elm_Object_Item *timezone_item; // timezone item
57 struct tm stm; // start
63 Eina_Bool is_selected_timezone;
66 char * timezone_offset;
68 int repeat_occurrences;
69 struct tm repeat_end_date_time;
72 Evas_Object *ly_alarm;
74 cal_repeat_term_t repeat; // repeat off, daily, ...
75 int repeat_end_date_num;
76 int repeat_week; // for weekly
77 Evas_Object *ly_repeat;
82 Evas_Object *ly_saveto;
88 Evas_Object *c_allday;
94 struct ui_gadget *ug_worldclock;
98 Eina_List *calendar_list; //For save to
100 Elm_Object_Item *alarm_first_it;
101 Elm_Object_Item *alarm_last_it;
102 Evas_Object *add_button;
106 enum cal_edit_alarm_value {
107 CAL_EDIT_ALARM_OFF = -1,
108 CAL_EDIT_ALARM_ON_TIME,
111 enum genlist_item_type{
136 static Elm_Object_Item* it; // To update
137 static Elm_Genlist_Item_Class itc_seperator, itc_1icon, itc_1text_1icon, itc_2text_1btn, itc_2text, itc_2text_1icon_2, itc_2text_1icon_4, itc_2text_2icon_4;
138 static Elm_Object_Item* __cal_edit_add_genlist_item(Evas_Object *genlist, Elm_Genlist_Item_Class *itc, int type, cal_edit_data *p);
139 static Elm_Object_Item* __cal_edit_add_genlist_alarm_item(Evas_Object *genlist, Elm_Genlist_Item_Class *itc, int type, cal_edit_data *p, int alarm);
140 static void __cal_edit_genlist_item_select_callback(void *data, Evas_Object *obj, void *event_info);
143 static void __cal_edit_delete_layout(void *data, Evas *e, Evas_Object *obj, void *ei)
147 c_retm_if(!data, "data is null");
149 cal_edit_data *p = data;
151 struct appdata* ad = p->ad;
152 c_retm_if(!ad, "ad is null");
158 ecore_idler_del(p->idler);
162 if (p->timezone_city)
163 free(p->timezone_city);
164 if (p->timezone_path)
165 free(p->timezone_path);
166 if (p->timezone_offset)
167 free(p->timezone_offset);
169 if (p->calendar_list) {
170 EINA_LIST_FOREACH(p->calendar_list, list, cs) {
172 CALENDAR_SVC_STRUCT_FREE(&cs);
174 eina_list_free(p->calendar_list);
177 if (ad->edit_special_one)
178 ad->edit_special_one = EINA_FALSE;
183 static void __cal_edit_cancel_button_callback(void *data, Evas_Object *obj, void *ei)
185 elm_naviframe_item_pop(data);
188 static inline void __cal_edit_set_time_text(cal_edit_data *p)
190 const char* date = NULL;
191 const char* time = NULL;
193 date = CAL_UTIL_DATE_FORMAT_1;
197 if (p->ad->is_hour24)
198 time = CAL_UTIL_TIME_FORMAT_6;
200 time = CAL_UTIL_TIME_FORMAT_1;
203 cal_util_set_time_text(CAL_UTIL_GET_EDJ_DATA(p->l_start), "text", date, time, &p->stm);
204 cal_util_set_time_text(CAL_UTIL_GET_EDJ_DATA(p->l_end), "text", date, time, &p->etm);
207 static inline void __cal_edit_set_repeat_text(cal_edit_data *p)
209 char buf[1024] = {0};
211 cal_edit_repeat_get_repeat_str(p->repeat, p->repeat_week, buf, sizeof(buf));
212 edje_object_part_text_set(CAL_UTIL_GET_EDJ_DATA(p->l_repeat), "text", buf);
215 static void __cal_edit_change_wday(cal_edit_data *p)
221 for (i = 0; i < 7; i++) {
222 if ( ((p->repeat_week >> i) & 1) &&
223 (wday > CAL_UTIL_GET_WDAY(i - p->stm.tm_wday))) {
224 wday = CAL_UTIL_GET_WDAY(i - p->stm.tm_wday);
228 wday = CAL_UTIL_GET_WDAY(wday);
230 cal_util_update_tm_day(&p->stm, wday);
231 cal_util_update_tm_day(&p->etm, wday);
232 __cal_edit_set_time_text(p);
235 static inline cal_edit_data* __cal_edit_check_layout(Evas_Object *sc)
239 p = CAL_UTIL_GET_PRIV_DATA(sc);
246 static inline void __cal_edit_fill_entry(char **str, cal_struct *cs, const char *field)
248 c_retm_if(!str, "str is null");
249 c_retm_if(!cs, "cs is null");
253 *str = CALENDAR_SVC_STRUCT_GET_STR(cs, field);
256 *str = elm_entry_utf8_to_markup((*str));
259 static inline void __cal_edit_fill_title(cal_edit_data *p, cal_struct *cs)
261 __cal_edit_fill_entry(&(p->stitle), cs, CAL_VALUE_TXT_SUMMARY);
265 static inline void __cal_edit_fill_location(cal_edit_data *p, cal_struct *cs)
267 __cal_edit_fill_entry(&(p->slocation), cs, CAL_VALUE_TXT_LOCATION);
270 static void __cal_edit_fill_note(cal_edit_data *p, cal_struct *cs)
272 c_retm_if(!p, "p is null");
273 c_retm_if(!cs, "cs is null");
275 char *str = CALENDAR_SVC_STRUCT_GET_STR(cs,CAL_VALUE_TXT_DESCRIPTION);
277 p->snote = strdup(str);
280 static void __cal_edit_fill_time(cal_edit_data *p, cal_struct *cs)
282 c_retm_if(!p, "p is null");
283 c_retm_if(!cs, "cs is null");
285 time_t st = mktime(CALENDAR_SVC_STRUCT_GET_TM(cs, CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_LOCAL));
286 time_t et = mktime(CALENDAR_SVC_STRUCT_GET_TM(cs, CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_LOCAL));
288 p->allday = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_ALL_DAY_EVENT);
290 localtime_r(&st, &p->stm);
291 localtime_r(&et, &p->etm);
293 if (CALENDAR_SVC_STRUCT_GET_INT(cs,CAL_VALUE_INT_REPEAT_TERM)) {
296 localtime_r(&st, &p->stm);
297 localtime_r(&et, &p->etm);
300 p->timezone_city = CAL_STRDUP(CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_VALUE_TXT_TZ_CITY_NAME));
301 c_warn_if(!p->timezone_city, "p->timezone_city is null");
303 p->timezone_path = CAL_STRDUP(CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_VALUE_TXT_TZ_NAME));
304 c_warn_if(!p->timezone_path, "p->timezone_path is null");
306 p->timezone = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_TIMEZONE);
308 if (!p->timezone_city || !p->timezone_path) {
309 cal_util_get_timezone_info(&p->timezone_path, &p->timezone_city, &p->timezone_offset);
310 if (p->timezone_offset) {
311 char *text = strstr(p->timezone_offset, "T");
312 p->timezone = atoi(text+2);
317 static void __cal_edit_fill_alarm(cal_edit_data *p, cal_struct *cs)
319 c_retm_if(!p, "p is null");
320 c_retm_if(!cs, "cs is null");
322 if (p->list_alm_min) {
323 g_list_free(p->list_alm_min);
324 p->list_alm_min = NULL;
329 int r = CALENDAR_SVC_STRUCT_GET_LIST(cs, CAL_VALUE_LST_ALARM, &al);
330 c_retm_if(r!=CAL_SUCCESS, "CALENDAR_SVC_STRUCT_GET_LIST(CAL_VALUE_LST_ALARM) is failed(%d)", r);
340 cal_value *val = al->data;
341 c_retm_if(!val, "val is null");
345 int tick = CALENDAR_SVC_VALUE_GET_INT(val, CAL_VALUE_INT_ALARMS_TICK);
346 cal_sch_remind_tick_unit_t unit = CALENDAR_SVC_VALUE_GET_INT(val, CAL_VALUE_INT_ALARMS_TICK_UNIT);
348 int min = cal_edit_alarm_get_min(tick, unit);
349 p->list_alm_min = g_list_append(p->list_alm_min,(void *)min);
351 al = g_list_next(al);
354 p->list_alm_min = g_list_first(p->list_alm_min);
357 static void __cal_edit_fill_repeat(cal_edit_data *p, cal_struct *cs)
359 c_retm_if(!p, "p is null");
360 c_retm_if(!cs, "cs is null");
363 cal_repeat_term_t term = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_REPEAT_TERM);
364 if (term == CAL_REPEAT_EVERY_WEEK) {
365 char *sflag = CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_VALUE_TXT_WEEK_FLAG);
366 flag = cal_util_get_week_flag(sflag);
370 p->repeat_week = flag;
372 struct tm *tm_tm = CALENDAR_SVC_STRUCT_GET_TM(cs, CAL_VALUE_GMT_REPEAT_END_DATE, CAL_TZ_FLAG_LOCAL);
373 CAL_MEMCPY(&(p->repeat_end_date_time),tm_tm, struct tm);
376 p->repeat_occurrences = CALENDAR_SVC_STRUCT_GET_INT(cs,"repeat_occurrences");
378 if (CAL_REPEAT_NONE != p->repeat) {
379 if (0 == p->repeat_occurrences)
380 p->repeat_end_date_num = 2;
382 p->repeat_end_date_num = 1;
387 static void __cal_edit_fill_save_to(cal_edit_data *p, cal_struct *cs)
392 calid = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_CALENDAR_ID);
394 calid = DEFAULT_CALENDAR_ID;
396 acct_id = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_ACCOUNT_ID);
397 if(acct_id < ALL_VISIBILITY_ACCOUNT)
398 acct_id = LOCAL_ACCOUNT_ID;
404 static void __cal_edit_fill_vcs_information(cal_edit_data *p)
407 struct appdata* ad = p->ad;
410 cal_struct* cs = p->ad->ical;
412 __cal_edit_fill_title(p, cs);
413 __cal_edit_fill_location(p, cs);
414 __cal_edit_fill_time(p, cs);
415 __cal_edit_fill_alarm(p, cs);
416 __cal_edit_fill_repeat(p, cs);
417 __cal_edit_fill_save_to(p, cs);
418 __cal_edit_fill_note(p, cs);
424 static void __cal_edit_fill_detail_information(cal_edit_data *p, int cid)
432 r = CALENDAR_SVC_GET(CAL_STRUCT_SCHEDULE, p->event_id, NULL, &cs);
433 if (r != CAL_SUCCESS)
436 CALENDAR_SVC_STRUCT_FREE(&cs);
441 __cal_edit_fill_title(p, cs);
442 __cal_edit_fill_location(p, cs);
443 __cal_edit_fill_time(p, cs);
444 __cal_edit_fill_alarm(p, cs);
445 __cal_edit_fill_repeat(p, cs);
446 __cal_edit_fill_save_to(p, cs);
447 __cal_edit_fill_note(p, cs);
449 p->accid = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_ACCOUNT_ID);
451 CALENDAR_SVC_STRUCT_FREE(&cs);
456 static inline cal_struct* __cal_edit_get_cs(int cid)
461 cs = CALENDAR_SVC_STRUCT_NEW(CAL_STRUCT_SCHEDULE);
466 r = CALENDAR_SVC_GET(CAL_STRUCT_SCHEDULE, cid, NULL, &cs);
467 if (r != CAL_SUCCESS)
470 CALENDAR_SVC_STRUCT_FREE(&cs);
479 static inline void __cal_edit_fill_cs_title(cal_edit_data *p, cal_struct *cs)
482 CALENDAR_SVC_STRUCT_SET_STR(cs, CAL_VALUE_TXT_SUMMARY, p->stitle);
484 CALENDAR_SVC_STRUCT_SET_STR(cs, CAL_VALUE_TXT_SUMMARY, C_("IDS_CLD_BODY_NO_TITLE"));
487 static inline void __cal_edit_fill_cs_location(cal_edit_data *p, cal_struct *cs)
490 CALENDAR_SVC_STRUCT_SET_STR(cs, CAL_VALUE_TXT_LOCATION, p->slocation);
492 CALENDAR_SVC_STRUCT_SET_STR(cs, CAL_VALUE_TXT_LOCATION, "");
495 static inline void __cal_edit_fill_cs_note(cal_edit_data *p, cal_struct *cs)
498 CALENDAR_SVC_STRUCT_SET_STR(cs, CAL_VALUE_TXT_DESCRIPTION, p->snote);
500 CALENDAR_SVC_STRUCT_SET_STR(cs, CAL_VALUE_TXT_DESCRIPTION, "");
503 static void __cal_edit_fill_cs_time(cal_edit_data *p, cal_struct *cs)
518 memcpy(&stm,&p->stm,sizeof(struct tm));
519 memcpy(&etm,&p->etm,sizeof(struct tm));
521 else if (p->is_selected_timezone) {
522 char *local_tz_path = NULL;
524 local_tz_path = vconf_get_str(CAL_VCONFKEY_LOCK_TIMEZONE_PATH);
525 if (!local_tz_path) {
526 local_tz_path = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
527 if (!local_tz_path) {
528 ERR("vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID) is failed");
529 local_tz_path = "Asia/Seoul";
533 CALENDAR_SVC_UTIL_CONVERT_DB_TIME(&p->stm,local_tz_path, &stm,p->timezone_path);
534 CALENDAR_SVC_UTIL_CONVERT_DB_TIME(&p->etm,local_tz_path, &etm,p->timezone_path);
537 memcpy(&stm,&p->stm,sizeof(struct tm));
538 memcpy(&etm,&p->etm,sizeof(struct tm));
541 if (p->timezone_path)
542 CALENDAR_SVC_STRUCT_SET_STR(cs,CAL_VALUE_TXT_TZ_NAME,p->timezone_path);
543 if (p->timezone_city)
544 CALENDAR_SVC_STRUCT_SET_STR(cs,CAL_VALUE_TXT_TZ_CITY_NAME,p->timezone_city);
546 CALENDAR_SVC_STRUCT_SET_INT(cs,CAL_VALUE_INT_TIMEZONE,p->timezone);
548 CALENDAR_SVC_STRUCT_SET_INT(cs, CAL_VALUE_INT_ALL_DAY_EVENT, p->allday);
550 CALENDAR_SVC_STRUCT_SET_TM(cs, CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_LOCAL, &stm);
551 CALENDAR_SVC_STRUCT_SET_TM(cs, CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_LOCAL, &etm);
555 static int __cal_edit_g_list_compare(const void* data1, const void* data2)
557 return (int)data1 - (int)data2;
560 static int __cal_edit_g_list_compare_with_data(const void* data1, const void* data2, void* user_data)
562 return (int)data1 - (int)data2;
565 static void __cal_edit_fill_cs_alarm(cal_edit_data *p, cal_struct *cs)
567 c_retm_if(!p, "p is null");
568 c_retm_if(!cs, "cs is null");
571 cal_sch_remind_tick_unit_t unit;
572 GList *al = NULL, *temp = NULL;
576 Elm_Object_Item *it = p->alarm_first_it;
577 while (it && (count++ <= p->alarm_count)) {
579 Item_Data *item_data = elm_object_item_data_get(it);
580 c_retm_if(!item_data, "item_data is null");
582 if (g_list_find_custom(temp, (const void*)item_data->alarm_value, __cal_edit_g_list_compare))
585 temp = g_list_insert_sorted_with_data(temp, (void*)item_data->alarm_value, __cal_edit_g_list_compare_with_data, NULL);
587 cal_edit_alarm_get_tick(item_data->alarm_value, &tick, &unit);
590 cal_value *val = CALENDAR_SVC_VALUE_NEW(CAL_VALUE_LST_ALARM);
591 c_retm_if(!val, "calendar_svc_value_new is failed");
593 CALENDAR_SVC_VALUE_SET_INT(val, CAL_VALUE_INT_ALARMS_TICK, tick);
594 CALENDAR_SVC_VALUE_SET_INT(val, CAL_VALUE_INT_ALARMS_TICK_UNIT, unit);
595 al = g_list_append(al, val);
598 if (count-1 == p->alarm_count)
599 p->alarm_last_it = it;
601 it = elm_genlist_item_next_get(it);
604 CALENDAR_SVC_STRUCT_SET_LIST(cs, CAL_VALUE_LST_ALARM, al);
607 static inline void __cal_edit_get_week_string(int week, char *week_s)
609 c_retm_if(!week_s,"week_s is null");
613 memset(week_s, 0, 7);
616 for (i = 0; i < 7; i++) {
624 static void __cal_edit_fill_cs_repeat(cal_edit_data *p, cal_struct *cs)
629 case CAL_REPEAT_EVERY_WEEK:
630 __cal_edit_get_week_string(p->repeat_week, sflag);
631 CALENDAR_SVC_STRUCT_SET_STR(cs, CAL_VALUE_TXT_WEEK_FLAG, sflag);
632 case CAL_REPEAT_EVERY_DAY:
633 case CAL_REPEAT_EVERY_MONTH:
634 case CAL_REPEAT_EVERY_YEAR:
635 CALENDAR_SVC_STRUCT_SET_TIME(cs, CAL_VALUE_GMT_REPEAT_END_DATE, CAL_TZ_FLAG_LOCAL, cal_util_get_max_time());
636 CALENDAR_SVC_STRUCT_SET_INT(cs, CAL_VALUE_INT_REPEAT_INTERVAL, 1);
642 CALENDAR_SVC_STRUCT_SET_INT(cs, CAL_VALUE_INT_REPEAT_TERM, p->repeat);
644 if (CAL_REPEAT_NONE != p->repeat)
646 p->repeat_end_date_time.tm_hour = p->stm.tm_hour;
647 p->repeat_end_date_time.tm_min = p->stm.tm_min;
648 p->repeat_end_date_time.tm_sec = p->stm.tm_sec;
650 if (1 == p->repeat_end_date_num)
651 CALENDAR_SVC_STRUCT_SET_INT(cs, CAL_VALUE_INT_REPEAT_OCCURRENCES, p->repeat_occurrences);
652 else if (2 == p->repeat_end_date_num)
653 CALENDAR_SVC_STRUCT_SET_TM(cs,CAL_VALUE_GMT_REPEAT_END_DATE,CAL_TZ_FLAG_LOCAL,&p->repeat_end_date_time);
657 static void __cal_edit_fill_cs_save_to(cal_edit_data *p, cal_struct *cs)
659 CALENDAR_SVC_STRUCT_SET_INT(cs, CAL_VALUE_INT_CALENDAR_ID, p->calid);
661 if (p->accid == ALL_ACCOUNT_ID)
662 CALENDAR_SVC_STRUCT_SET_INT(cs, CAL_VALUE_INT_ACCOUNT_ID, LOCAL_ACCOUNT_ID);
664 CALENDAR_SVC_STRUCT_SET_INT(cs, CAL_VALUE_INT_ACCOUNT_ID, p->accid);
667 static inline void __cal_edit_mark_deleted(GList *al)
675 CALENDAR_SVC_VALUE_SET_INT(val, CAL_VALUE_INT_DETAIL_DELETE, 1);
680 Eina_Bool cal_edit_check_email_vailidity(const char* email)
682 c_retvm_if(!email, EINA_FALSE, "email is null");
684 const char* temp = strchr(email, '@');
685 c_retvm_if(!temp, EINA_FALSE, "%s is invalid address", email);
686 c_retvm_if(*(temp+1) == '.', EINA_FALSE, "%s is invalid address", email);
688 temp = strchr(temp, '.');
689 c_retvm_if(!temp, EINA_FALSE, "%s is invalid address", email);
690 c_retvm_if(strlen(temp) <= 1, EINA_FALSE, "%s is invalid address", email);
695 static inline void __cal_edit_fill_cs(cal_edit_data *p, cal_struct *cs)
697 __cal_edit_fill_cs_title(p, cs);
698 __cal_edit_fill_cs_location(p, cs);
699 __cal_edit_fill_cs_time(p, cs);
700 __cal_edit_fill_cs_alarm(p, cs);
701 __cal_edit_fill_cs_repeat(p, cs);
702 __cal_edit_fill_cs_note(p, cs);
703 __cal_edit_fill_cs_save_to(p, cs);
706 static void __cal_edit_reponse_event_callback(void *data, Evas_Object *obj, void *ei)
708 c_retm_if(!data, "data is null");
710 Evas_Object *popup = data;
711 evas_object_del(popup);
714 static int __cal_edit_get_date(Evas_Object *df, struct tm *res)
721 localtime_r(&t, &tm); // to fill hidden field
723 elm_datetime_value_get(df, &tm);
734 static void __cal_edit_title_entry_changed_callback(void *data, Evas_Object *obj, void *event_info)
737 Item_Data *item_data = (Item_Data *)data;
738 cal_edit_data *p = item_data->p;
743 str = elm_entry_entry_get(p->e_title);
744 if (!str || str[0] == '\0')
747 p->stitle = elm_entry_markup_to_utf8(str);
751 static Evas_Object * __cal_edit_add_title_icon(Evas_Object *obj, const char *part, Item_Data *item_data)
753 c_retvm_if(!obj, NULL, "obj is null");
754 c_retvm_if(!part, NULL, "part is null");
755 c_retvm_if(!item_data, NULL, "item_data is null");
757 cal_edit_data *p = item_data->p;
758 c_retvm_if(!p, NULL, "p is null");
760 if (!CAL_STRCMP(part, "elm.icon")) {
761 Evas_Object *ef = cal_util_add_edit_field(obj, C_("IDS_COM_BODY_DETAILS_TITLE"), C_("IDS_CLD_BODY_TAP_TO_ENTER_TITLE"), EINA_TRUE, EINA_TRUE);
762 c_retvm_if(!ef, NULL, "ef is null");
764 Evas_Object *entry = elm_object_part_content_get(ef, "elm.swallow.content");
765 c_retvm_if(!entry, ef, "entry is null");
769 elm_entry_entry_set(p->e_title, p->stitle);
771 evas_object_smart_callback_add(p->e_title, "changed", __cal_edit_title_entry_changed_callback, item_data);
779 static inline int _edit_safe_strcmp(char *s1, char *s2)
781 if (NULL == s1 || NULL == s2)
784 return strcmp(s1, s2);
787 static void _edit_location_entry_changed_cb(void *data, Evas_Object *obj, void *event_info)
790 Item_Data *item_data = (Item_Data *)data;
791 cal_edit_data *p = item_data->p;
793 str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
795 if (!_edit_safe_strcmp(str, p->slocation)) {
809 static Evas_Object * __cal_edit_add_location_icon(Evas_Object *obj, const char *part, Item_Data *item_data)
811 Evas_Object *ly = NULL;
815 if (!CAL_STRCMP(part, "elm.icon"))
817 ly = cal_util_add_layout(obj, "dialoguegroup/location");
821 ef = cal_util_add_edit_field(ly, C_("IDS_COM_BODY_DETAILS_LOCATION"), C_("IDS_CLD_BODY_TAP_TO_ENTER_LOCATION"), EINA_TRUE, EINA_TRUE);
828 elm_object_part_content_set(ly, "editfield/sw", ef);
830 en = elm_object_part_content_get(ef, "elm.swallow.content");
832 if (item_data->p->slocation)
833 elm_entry_entry_set(en, item_data->p->slocation);
835 evas_object_smart_callback_add(en, "changed", _edit_location_entry_changed_cb, item_data);
836 elm_entry_cnp_mode_set(en, ELM_CNP_MODE_PLAINTEXT);
842 static Evas_Object* __cal_edit_add_date_field(Evas_Object *dg, cal_edit_data *p, struct tm *tm)
844 c_retvm_if(!dg, NULL, "dg is null");
845 c_retvm_if(!p, NULL, "p is null");
846 c_retvm_if(!tm, NULL, "tm is null");
848 struct appdata* ad = p->ad;
849 c_retvm_if(!ad, NULL, "ad is null");
851 Evas_Object *layout = cal_util_add_datetime(dg, NULL, tm);
852 c_retvm_if(!layout, NULL, "layout is null");
854 Evas_Object *dt = elm_object_part_content_get(layout, "elm.icon");
857 evas_object_del(layout);
863 elm_datetime_field_visible_set(dt, ELM_DATETIME_HOUR, EINA_TRUE);
864 elm_datetime_field_visible_set(dt, ELM_DATETIME_MINUTE, EINA_TRUE);
868 elm_datetime_format_set(dt, "%b %d , %Y %H : %M");
869 elm_datetime_field_visible_set(dt, ELM_DATETIME_AMPM, EINA_FALSE);
873 elm_datetime_format_set(dt, "%b %d , %Y %I : %M %p");
874 elm_datetime_field_visible_set(dt, ELM_DATETIME_AMPM, EINA_TRUE);
879 elm_datetime_field_visible_set(dt, ELM_DATETIME_HOUR, EINA_FALSE);
880 elm_datetime_field_visible_set(dt, ELM_DATETIME_MINUTE, EINA_FALSE);
881 elm_datetime_field_visible_set(dt, ELM_DATETIME_AMPM, EINA_FALSE);
884 elm_datetime_field_limit_set(dt, ELM_DATETIME_YEAR, 70, 137);
889 static void __cal_edit_start_date_changed_callback(void *data, Evas_Object *obj, void *ei)
891 c_retm_if(!data, "data is null");
892 cal_edit_data *p = data;
894 c_retm_if(!p->sdt, "p->sdt is null");
895 c_retm_if(!p->edt, "p->edt is null");
899 __cal_edit_get_date(p->sdt, &(p->stm));
900 __cal_edit_get_date(p->edt, &(p->etm));
902 elm_datetime_value_get(p->sdt, &tm);
904 cal_util_update_tm_hour(&tm, 1);
906 elm_datetime_value_set(p->edt, &tm);
908 __cal_edit_get_date(p->sdt, &(p->stm));
909 __cal_edit_get_date(p->edt, &(p->etm));
913 static Evas_Object * __cal_edit_add_start_date_icon(Evas_Object *obj, const char *part, Item_Data *item_data)
915 Evas_Object *icon_obj = NULL;
916 if (!CAL_STRCMP(part, "elm.icon"))
918 cal_edit_data *p = item_data->p;
919 icon_obj = __cal_edit_add_date_field(obj, p, &p->stm);
920 elm_object_part_text_set(icon_obj, "elm.text", S_("IDS_COM_BODY_START"));
922 p->sdt = elm_object_part_content_get(icon_obj, "elm.icon");
923 c_warn_if(!p->sdt, "p->sdt is null");
925 evas_object_smart_callback_add(p->sdt, "changed", __cal_edit_start_date_changed_callback, p);
931 static void __cal_edit_end_date_changed_callback(void *data, Evas_Object *obj, void *ei)
935 cal_edit_data *p = data;
937 __cal_edit_get_date(p->edt, &(p->etm));
940 static Evas_Object * __cal_edit_add_end_date_icon(Evas_Object *obj, const char *part, Item_Data *item_data)
942 Evas_Object *icon_obj = NULL;
943 if (!CAL_STRCMP(part, "elm.icon"))
945 cal_edit_data *p = item_data->p;
946 icon_obj = __cal_edit_add_date_field(obj, p, &p->etm);
947 elm_object_part_text_set(icon_obj, "elm.text", S_("IDS_COM_BODY_END"));
949 p->edt = elm_object_part_content_get(icon_obj, "elm.icon");
950 c_warn_if(!p->edt, "p->edt is null");
952 evas_object_smart_callback_add(p->edt,"changed", __cal_edit_end_date_changed_callback, p);
957 static void __cal_edit_all_day_changed_callback(void *data, Evas_Object *obj, void *ei)
960 cal_edit_data *p = data;
964 p->allday = elm_check_state_get(obj);
967 elm_datetime_field_visible_set(p->sdt, ELM_DATETIME_HOUR, EINA_TRUE);
968 elm_datetime_field_visible_set(p->edt, ELM_DATETIME_HOUR, EINA_TRUE);
969 elm_datetime_field_visible_set(p->sdt, ELM_DATETIME_MINUTE, EINA_TRUE);
970 elm_datetime_field_visible_set(p->edt, ELM_DATETIME_MINUTE, EINA_TRUE);
972 if (!p->ad->is_hour24) {
973 elm_datetime_field_visible_set(p->sdt, ELM_DATETIME_AMPM, EINA_TRUE);
974 elm_datetime_field_visible_set(p->edt, ELM_DATETIME_AMPM, EINA_TRUE);
979 elm_datetime_field_visible_set(p->sdt, ELM_DATETIME_HOUR, EINA_FALSE);
980 elm_datetime_field_visible_set(p->edt, ELM_DATETIME_HOUR, EINA_FALSE);
981 elm_datetime_field_visible_set(p->sdt, ELM_DATETIME_MINUTE, EINA_FALSE);
982 elm_datetime_field_visible_set(p->edt, ELM_DATETIME_MINUTE, EINA_FALSE);
983 elm_datetime_field_visible_set(p->sdt, ELM_DATETIME_AMPM, EINA_FALSE);
984 elm_datetime_field_visible_set(p->edt, ELM_DATETIME_AMPM, EINA_FALSE);
988 static Evas_Object * __cal_edit_add_all_day_icon(Evas_Object *obj, const char *part, Item_Data *item_data)
991 CAL_ASSERT(item_data);
993 if (!CAL_STRCMP(part, "elm.icon"))
995 cal_edit_data *p = item_data->p;
998 rd = elm_check_add(obj);
999 elm_check_state_set(rd, p->allday);
1000 elm_object_style_set(rd, "on&off");
1002 evas_object_smart_callback_add(rd, "changed", __cal_edit_all_day_changed_callback, p);
1003 elm_check_state_set(p->c_allday, p->allday);
1004 evas_object_propagate_events_set(rd, EINA_FALSE);
1012 static void __cal_edit_note_entry_changed_callback(void *data, Evas_Object *obj, void *event_info)
1014 c_retm_if(!data, "data is null");
1016 Item_Data *item_data = data;
1017 cal_edit_data *p = item_data->p;
1018 c_retm_if(!p, "p is null");
1020 const char *str = elm_entry_markup_to_utf8(elm_entry_entry_get(p->e_note));
1022 if (!CAL_STRLEN(str))
1029 static Evas_Object * __cal_edit_add_note_icon(Evas_Object *obj, const char *part, Item_Data *item_data)
1031 c_retvm_if(!obj , NULL, "obj is null");
1032 c_retvm_if(!part , NULL, "part is null");
1033 c_retvm_if(!item_data , NULL, "item_data is null");
1035 cal_edit_data *p = item_data->p;
1036 c_retvm_if(!p , NULL, "p is null");
1038 if (!CAL_STRCMP(part, "elm.icon")) {
1039 Evas_Object *ef = cal_util_add_edit_field(obj, C_("IDS_COM_BODY_NOTE"), C_("IDS_CLD_BODY_TAP_TO_ENTER_NOTE"), EINA_FALSE, EINA_TRUE );
1041 Evas_Object *entry = elm_object_part_content_get(ef, "elm.swallow.content");
1042 c_retvm_if(!entry, ef, "entry is null");
1044 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1045 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_EXPAND);
1046 elm_entry_autocapital_type_set(entry, EINA_TRUE);
1047 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
1052 elm_entry_entry_set(p->e_note, elm_entry_utf8_to_markup(p->snote));
1054 evas_object_smart_callback_add(p->e_note, "changed", __cal_edit_note_entry_changed_callback, item_data);
1062 static void __cal_edit_set_default_information(cal_edit_data *p)
1067 localtime_r(&now, &p->stm);
1069 localtime_r(&now, &p->etm);
1073 p->repeat = CAL_REPEAT_NONE;
1076 p->calid = DEFAULT_CALENDAR_ID;
1077 p->accid = ALL_ACCOUNT_ID;
1079 p->repeat_occurrences = 10;
1081 cal_util_get_timezone_info(&p->timezone_path, &p->timezone_city, &p->timezone_offset);
1082 if (p->timezone_offset) {
1083 char *text = strstr(p->timezone_offset, "T");
1084 p->timezone = atoi(text+2);
1089 static Evas_Object* __cal_edit_add_save_to_icon(void *item_data, Evas_Object *obj, const char *part)
1093 ERR("item_data is null");
1097 Evas_Object *icon = NULL;
1098 char* default_icon_path = "/opt/apps/org.tizen.efl-calendar/res/icons/all_calendar.png";
1099 char* icon_path = NULL;
1100 cal_struct* cs = (cal_struct*)item_data;
1101 Eina_Bool r = EINA_FALSE;
1105 cid = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_TABLE_INT_INDEX);
1106 aid = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_TABLE_INT_ACCOUNT_ID);
1108 if (!CAL_STRCMP(part, "elm.icon"))
1110 icon = elm_icon_add(obj);
1114 ERR("elm_icon_add fail");
1118 if ( cid == DEFAULT_CALENDAR_ID) {
1119 r = elm_icon_file_set(icon, default_icon_path, NULL);
1120 c_warn_if(!r, "elm_icon_file_set(%s) is failed", default_icon_path);
1123 icon_path = cal_account_svc_get_account_icon_path(aid);
1125 r = elm_icon_file_set(icon, icon_path, NULL);
1126 c_warn_if(!r, "elm_icon_file_set(%s) is failed", default_icon_path);
1130 r = elm_icon_file_set(icon, default_icon_path, NULL);
1131 c_warn_if(!r, "elm_icon_file_set(%s) is failed", default_icon_path);
1138 evas_object_del(icon);
1142 evas_object_show(icon);
1148 static Evas_Object *__cal_edit_get_genlist_item_icon(void *data, Evas_Object *obj, const char *part)
1150 Evas_Object *e_obj = NULL;
1151 Item_Data *item_data = (Item_Data*)data;
1153 switch ( item_data->type)
1156 e_obj = __cal_edit_add_title_icon(obj, part, item_data);
1159 e_obj = __cal_edit_add_location_icon(obj, part, item_data);
1162 e_obj = __cal_edit_add_start_date_icon(obj, part, item_data);
1165 e_obj = __cal_edit_add_end_date_icon(obj, part, item_data);
1168 e_obj = __cal_edit_add_all_day_icon(obj, part, item_data);
1171 e_obj = __cal_edit_add_note_icon(obj, part, item_data);
1180 static char* __cal_edit_add_start_text(Evas_Object *obj, const char *part, Item_Data *item_data)
1182 if (!CAL_STRCMP(part, "elm.text.1"))
1184 return strdup(S_("IDS_COM_BODY_START"));
1190 static char* __cal_edit_add_end_text(Evas_Object *obj, const char *part, Item_Data *item_data)
1192 if (!CAL_STRCMP(part, "elm.text.1"))
1194 return strdup(S_("IDS_COM_BODY_END"));
1200 static void __cal_edit_get_alarm_text(Item_Data *data, char* buf, int buf_size)
1202 c_retm_if(!data, "data is null");
1203 cal_edit_alarm_get_alarm_str(data->alarm_value, buf, buf_size);
1206 static Eina_Bool __cal_edit_check_alarm_time_passed(cal_edit_data *p, cal_struct *cs)
1209 time_t current_time = time(NULL);
1212 Item_Data *item_data = NULL;
1213 Elm_Object_Item *it;
1214 c_retvm_if(!p, EINA_FALSE, "p is null");
1215 c_retvm_if(!p->genlist, EINA_FALSE, "genlist is null");
1219 start_tm.tm_hour = 0;
1220 start_tm.tm_min = 0;
1221 start_tm.tm_sec = 0;
1226 it = p->alarm_first_it;
1227 while (it && (count++ <= p->alarm_count)) {
1229 item_data = elm_object_item_data_get(it);
1230 c_retvm_if(!item_data, EINA_FALSE, "item_data is null");
1232 cal_edit_alarm_get_alarm_str(item_data->alarm_value, buf, sizeof(buf));
1233 if (!strcmp(buf, S_("IDS_COM_BODY_OFF"))) {
1234 it = elm_genlist_item_next_get(it);
1238 alarm = mktime(&start_tm)-item_data->alarm_value*60;
1239 if (alarm < current_time)
1242 it = elm_genlist_item_next_get(it);
1248 static void __cal_edit_show_result_popup(cal_edit_data *p,int result)
1254 case CAL_ERR_EVENT_START_DATE:
1255 cal_util_add_popup(p->win, S_("IDS_COM_POP_WARNING"), "Start date is invalid!",
1256 __cal_edit_reponse_event_callback, NULL, NULL);
1258 case CAL_ERR_EVENT_END_DATE:
1259 cal_util_add_popup(p->win, S_("IDS_COM_POP_WARNING"), "End date is invalid!",
1260 __cal_edit_reponse_event_callback, NULL, NULL);
1262 case CAL_ERR_EVENT_REPEAT_END_DATE:
1263 cal_util_add_popup(p->win, S_("IDS_COM_POP_WARNING"), "Repeat end date is invalid!",
1264 __cal_edit_reponse_event_callback, NULL, NULL);
1266 case CAL_ERR_EVENT_DURATION:
1267 cal_util_add_popup(p->win, S_("IDS_COM_POP_WARNING"), "Event duration is invalid!",
1268 __cal_edit_reponse_event_callback, NULL, NULL);
1270 case CAL_ERR_EVENT_REPEAT_DURATION_TOO_SHORT:
1271 cal_util_add_popup(p->win, S_("IDS_COM_POP_WARNING"), "Event duration is longer than repeat duration!",
1272 __cal_edit_reponse_event_callback, NULL, NULL);
1274 case CAL_ERR_DB_LOCK:
1275 cal_util_add_popup(p->win, S_("IDS_COM_POP_WARNING"), "Sync in progress, try later.",
1276 __cal_edit_reponse_event_callback, NULL, NULL);
1279 snprintf(buf,100,"not saved(internal error-%d)!",result);
1280 cal_util_add_popup(p->win, S_("IDS_COM_POP_WARNING"), buf,
1281 __cal_edit_reponse_event_callback, NULL, NULL);
1286 int __cal_edit_save(cal_edit_data *p)
1292 cal_struct *cs_temp;
1294 cs = __cal_edit_get_cs(p->event_id);
1298 cs_temp = __cal_edit_get_cs(p->event_id);
1302 CALENDAR_SVC_STRUCT_FREE(&cs);
1307 if (__cal_edit_check_alarm_time_passed(p,cs) && p->repeat == CAL_REPEAT_NONE)
1309 cal_util_add_popup(p->win, S_("IDS_COM_POP_WARNING"), "Alarm time already passed!",
1310 __cal_edit_reponse_event_callback, NULL, NULL);
1313 CALENDAR_SVC_STRUCT_FREE(&cs);
1316 CALENDAR_SVC_STRUCT_FREE(&cs_temp);
1321 __cal_edit_fill_cs(p, cs);
1325 if (p->ad->edit_special_one)
1328 cal_value* value = NULL;
1331 CALENDAR_SVC_STRUCT_SET_INT(cs,"original_event_id",CALENDAR_SVC_STRUCT_GET_INT(cs,"index"));
1332 CALENDAR_SVC_STRUCT_SET_INT(cs,CAL_VALUE_INT_REPEAT_TERM,0);
1333 p->ad->cid = CALENDAR_SVC_INSERT(cs);
1336 value = CALENDAR_SVC_VALUE_NEW(CAL_VALUE_LST_EXCEPTION_DATE);
1337 CALENDAR_SVC_VALUE_SET_TIME(value,CAL_VALUE_GMT_EXCEPTION_DATE_TIME,CAL_TZ_FLAG_GMT,t);
1338 CALENDAR_SVC_VALUE_SET_INT(value, CAL_VALUE_INT_EXCEPTION_DATE_ID, p->ad->cid);
1339 CALENDAR_SVC_STRUCT_GET_LIST(cs_temp,CAL_VALUE_LST_EXCEPTION_DATE,&list);
1340 list = g_list_append(list,value);
1341 CALENDAR_SVC_STRUCT_SET_LIST(cs_temp,CAL_VALUE_LST_EXCEPTION_DATE,list);
1343 CALENDAR_SVC_STRUCT_SET_INT(cs_temp,CAL_VALUE_INT_ACCOUNT_ID,p->accid);
1345 CALENDAR_SVC_UPDATE(cs_temp);
1349 r = CALENDAR_SVC_UPDATE(cs);
1350 if (r != CAL_SUCCESS)
1352 __cal_edit_show_result_popup(p,r);
1355 CALENDAR_SVC_STRUCT_FREE(&cs);
1358 CALENDAR_SVC_STRUCT_FREE(&cs_temp);
1367 r = CALENDAR_SVC_INSERT(cs);
1370 __cal_edit_show_result_popup(p,r);
1373 CALENDAR_SVC_STRUCT_FREE(&cs);
1376 CALENDAR_SVC_STRUCT_FREE(&cs_temp);
1382 CALENDAR_SVC_STRUCT_FREE(&cs);
1383 CALENDAR_SVC_STRUCT_FREE(&cs_temp);
1388 static void __cal_edit_save_button_callback(void *data, Evas_Object *obj, void *ei)
1392 c_retm_if(!data, "data is null");
1394 Evas_Object *ly = data;
1395 Elm_Object_Item* navi_item = NULL;
1397 cal_edit_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
1398 c_retm_if(!p, "p is null");
1400 r = __cal_edit_save(p);
1401 c_retm_if(r, "cal_edit_save() is failed");
1403 if ((NULL != p->ad->ug) && (UG_EDIT == p->ad->u_type))
1405 ug_destroy_me(p->ad->ug);
1408 else if (p->ad->request_view == CV_EDIT)
1410 if (elm_naviframe_top_item_get(p->ad->nv) != elm_naviframe_bottom_item_get(p->ad->nv))
1412 p->ad->request_view = CV_UNKNOWN;
1413 elm_win_lower(p->ad->win);
1419 elm_naviframe_prev_btn_auto_pushed_set(p->ad->nv, EINA_TRUE);
1420 elm_naviframe_item_pop(p->ad->nv);
1421 navi_item = elm_naviframe_top_item_get(p->ad->nv);
1424 static char* __cal_edit_add_allday_text(Evas_Object *obj, const char *part, Item_Data *item_data)
1426 if (!CAL_STRCMP(part, "elm.text"))
1428 return strdup(C_("IDS_COM_BODY_ALL_DAY"));
1434 static char* __cal_edit_add_timezone_text(Evas_Object *obj, const char *part, Item_Data *item_data)
1436 CAL_ASSERT(item_data);
1438 cal_edit_data *p = item_data->p;
1440 if (!CAL_STRCMP(part, "elm.text.1"))
1441 return strdup(C_("IDS_CLD_BODY_TIME_ZONE"));
1443 if (!CAL_STRCMP(part, "elm.text.2")) {
1444 if (!p->timezone_offset) {
1445 ERR("p->timezone_offset is null");
1449 return g_strdup_printf("%s, %s", C_(p->timezone_city), p->timezone_offset);
1455 static char* __cal_edit_add_alarm_text(Evas_Object *obj, const char *part, Item_Data *item_data)
1457 CAL_ASSERT(item_data);
1459 cal_edit_data *p = item_data->p;
1464 if (!CAL_STRCMP(part, "elm.text.1"))
1466 return strdup(S_("IDS_COM_BODY_ALARM"));
1468 if (!CAL_STRCMP(part, "elm.text.2"))
1470 __cal_edit_get_alarm_text(item_data, buf, sizeof(buf));
1476 static void __cal_edit_get_repeat_text(cal_edit_data *p, char* buf, int buf_size)
1478 cal_edit_repeat_get_repeat_str(p->repeat, p->repeat_week, buf, buf_size);
1481 static char* __cal_edit_add_repeat_text(Evas_Object *obj, const char *part, Item_Data *item_data)
1483 char buf[1024] = {0};
1484 CAL_ASSERT(item_data);
1486 cal_edit_data *p = item_data->p;
1489 if (!CAL_STRCMP(part, "elm.text.1"))
1491 return strdup(C_("IDS_CLD_BODY_REPEAT"));
1493 if (!CAL_STRCMP(part, "elm.text.2"))
1495 __cal_edit_get_repeat_text(p, buf, sizeof(buf));
1501 static void __cal_edit_get_save_to_str(int calid, char *buf, int sz)
1503 cal_struct *cs = NULL;
1507 r = CALENDAR_SVC_GET(CAL_STRUCT_CALENDAR, calid, NULL, &cs);
1508 if (r != CAL_SUCCESS)
1510 snprintf(buf, sz, "%s", _("Phone"));
1512 CALENDAR_SVC_STRUCT_FREE(&cs);
1517 if (calid == DEFAULT_CALENDAR_ID)
1518 str = C_("IDS_CLD_OPT_PHONE_CALENDAR");
1521 str = CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_TABLE_TXT_NAME);
1523 str = C_("IDS_CLD_OPT_PHONE_CALENDAR");
1526 snprintf(buf, sz, "%s", str);
1528 CALENDAR_SVC_STRUCT_FREE(&cs);
1531 static char* __cal_edit_add_save_to_text(Evas_Object *obj, const char *part, Item_Data *item_data)
1536 CAL_ASSERT(item_data);
1538 cal_edit_data *p = item_data->p;
1541 if (!CAL_STRCMP(part, "elm.text.1"))
1543 return strdup(C_("IDS_ST_BODY_SAVE_TO"));
1546 if (!CAL_STRCMP(part, "elm.text.2"))
1548 if ( p->calid == DEFAULT_CALENDAR_ID)
1549 return strdup(C_("IDS_CLD_OPT_PHONE_CALENDAR"));
1552 __cal_edit_get_save_to_str(p->calid, buf, sizeof(buf));
1559 static char* __cal_edit_add_note_text(Evas_Object *obj, const char *part, Item_Data *item_data)
1561 cal_edit_data *p = item_data->p;
1562 if (!CAL_STRCMP(part, "elm.text.1"))
1564 return strdup(S_("IDS_COM_BODY_NOTE"));
1567 if (!CAL_STRCMP(part, "elm.text.2") && p->snote)
1569 return strdup(p->snote);
1575 static char *__cal_edit_get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
1577 Item_Data *item_data = (Item_Data*)data;
1578 int type = (int)item_data->type;
1587 return __cal_edit_add_start_text(obj, part, item_data);
1589 return __cal_edit_add_end_text(obj, part, item_data);
1591 return __cal_edit_add_allday_text(obj, part, item_data);
1592 case _GTYPE_TIME_ZONE:
1593 return __cal_edit_add_timezone_text(obj, part, item_data);
1595 return __cal_edit_add_alarm_text(obj, part, item_data);
1597 return __cal_edit_add_repeat_text(obj, part, item_data);
1598 case _GTYPE_LINKED_CAL:
1599 return __cal_edit_add_save_to_text(obj, part, item_data);
1601 return __cal_edit_add_note_text(obj, part, item_data);
1609 static void __cal_edit_genlist_item_delete(void *data, Evas_Object *obj)
1611 Item_Data *item_data = (Item_Data*)data;
1617 static Eina_Bool __cal_edit_get_genlist_item_state(void *data, Evas_Object *obj, const char *part)
1623 static void __cal_edit_alarm_callback(void *data, Evas_Object *obj, void *ei)
1625 c_retm_if(!data, "data is null");
1627 Item_Data * item_data = data;
1629 cal_edit_data *p = item_data->p;
1630 c_retm_if(!p, "p is null");
1632 item_data->alarm_value = cal_edit_alarm_get_alarm(p->ly_alarm);
1635 elm_genlist_item_update(item_data->it);
1637 elm_naviframe_item_pop(p->nv);
1640 static void __cal_edit_repeat_callback(void *data, Evas_Object *obj, void *ei)
1642 cal_edit_data *p = data;
1644 p->repeat = cal_edit_repeat_get_repeat(p->ly_repeat, &p->repeat_week, &(p->repeat_end_date_num), &(p->repeat_end_date_time),&(p->repeat_occurrences));
1646 if(CAL_REPEAT_NONE != p->repeat)
1648 if (p->repeat == CAL_REPEAT_EVERY_WEEK)
1649 __cal_edit_change_wday(p);
1651 if(1 != p->repeat_end_date_num)
1653 if(timegm(&(p->repeat_end_date_time)) <= timegm(&p->stm))
1655 cal_util_add_popup(p->win, S_("IDS_COM_POP_WARNING"), "Repeat end time is invalid!",
1656 __cal_edit_reponse_event_callback, NULL, NULL);
1662 DBG("p->repeat_occurrences is %d\n",p->repeat_occurrences);
1663 if(p->repeat_occurrences == 0)
1665 cal_util_add_popup(p->win, S_("IDS_COM_POP_WARNING"), "Repeat occurrence is invalid!",
1666 __cal_edit_reponse_event_callback, NULL, NULL);
1672 struct tm *tm = localtime(&now);
1676 CAL_MEMCPY(&p->repeat_end_date_time, tm, struct tm);
1679 __cal_edit_set_repeat_text(p);
1684 elm_genlist_item_update(it);
1688 elm_naviframe_item_pop(p->nv);
1692 static void __cal_edit_repeat_select_callback(Item_Data *item_data)
1694 cal_edit_data *p = item_data->p;
1695 Evas_Object *btn_save;
1696 Evas_Object *btn_cancel;
1697 Elm_Object_Item* navi_item;
1700 p->nv = elm_naviframe_add(p->genlist);
1702 p->ly_repeat = cal_edit_repeat_create_view(p->parent, p->ad, p->repeat, p->repeat_end_date_num, &(p->stm), &(p->repeat_end_date_time),&(p->repeat_occurrences), (int*)&(p->allday), p->repeat_week);
1703 CAL_ASSERT(p->ly_repeat);
1707 navi_item = elm_naviframe_item_push(p->nv, C_("IDS_CLD_BODY_REPEAT"), NULL, NULL, p->ly_repeat, NULL);
1709 btn_save = elm_button_add(p->nv);
1710 cal_util_set_controlbar_button(btn_save, S_("IDS_COM_OPT_SAVE"), "naviframe/title/default", __cal_edit_repeat_callback, p);
1711 elm_object_item_part_content_set(navi_item, "title_right_btn", btn_save);
1713 btn_cancel = elm_button_add(p->nv);
1714 cal_util_set_controlbar_button(btn_cancel,S_("IDS_COM_SK_CANCEL"),
1715 "naviframe/title/default", __cal_edit_cancel_button_callback, p->nv);
1716 elm_object_item_part_content_set(navi_item, "title_left_btn", btn_cancel);
1720 static void __cal_edit_ug_destroy_callback(struct ui_gadget *ug, void *priv)
1724 cal_edit_data* p = (cal_edit_data*) priv;
1726 if (p->ug_worldclock) {
1727 ug_destroy(p->ug_worldclock);
1728 p->ug_worldclock= NULL;
1731 Elm_Object_Item* navi_item = elm_naviframe_top_item_get(p->nv);
1732 Evas_Object *back_btn = elm_object_item_part_content_get(navi_item, "prev_btn");
1733 if (back_btn != NULL) {
1734 elm_object_style_set(back_btn, "naviframe/back_btn/default"); /* take into effect */
1738 static void __cal_edit_ug_result_callback(struct ui_gadget *ug, bundle *result, void *priv)
1742 c_retm_if(!priv, "priv is null");
1743 c_retm_if(!result, "result is null");
1745 cal_edit_data *p = priv;
1747 const char* city = bundle_get_val(result, "city");
1748 c_retm_if(!city, "city is null");
1750 const char* timezone = bundle_get_val(result, "timezone");
1751 c_retm_if(!timezone, "timezone is null");
1753 const char* tzpath = bundle_get_val(result, "tzpath");
1754 c_retm_if(!tzpath, "tzpath is null");
1757 p->timezone = atoi(timezone);
1759 if (p->timezone_city)
1760 free(p->timezone_city);
1762 p->timezone_city = strdup(C_(city));
1764 if (p->timezone_path)
1765 free(p->timezone_path);
1767 p->timezone_path= strdup(tzpath);
1769 if (p->timezone_offset)
1770 free(p->timezone_offset);
1772 p->timezone_offset= g_strdup_printf("GMT%s",timezone);
1774 p->is_selected_timezone = EINA_TRUE;
1776 elm_genlist_item_update(p->timezone_item);
1779 static void __cal_edit_ug_layout_callback(struct ui_gadget *ug, enum ug_mode mode, void *priv)
1783 c_retm_if(!ug, "ug is null");
1785 Evas_Object *base = ug_get_layout(ug);
1793 case UG_MODE_FULLVIEW:
1794 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
1796 elm_win_resize_object_add(ug_get_window(), base);
1797 evas_object_show(base);
1800 DBG("Unsupported ug layout");
1806 static void __cal_edit_timezone_select_callback(Item_Data *item_data)
1808 c_retm_if(!item_data, "item_data is null");
1810 cal_edit_data *p = item_data->p;
1812 struct ui_gadget *ug;
1813 memset(&uc, 0, sizeof(struct ug_cbs));
1814 uc.destroy_cb = __cal_edit_ug_destroy_callback;
1815 uc.layout_cb = __cal_edit_ug_layout_callback;
1816 uc.result_cb = __cal_edit_ug_result_callback;
1819 ug = ug_create(NULL, "worldclock-efl", UG_MODE_FULLVIEW, NULL, &uc);
1820 p->ug_worldclock = ug;
1823 static void __cal_edit_alarm_select_callback(Item_Data *item_data)
1825 c_retm_if(!item_data, "item_data is null");
1827 Evas_Object *btn_save;
1828 Evas_Object *btn_cancel;
1829 Elm_Object_Item* navi_item;
1830 cal_edit_data *p = item_data->p;
1832 c_retm_if(!p, "p is null");
1833 c_retm_if(!p->nv, "p->nv is null");
1835 p->ly_alarm = cal_edit_alarm_create_view(p->win, item_data->alarm_value, p->ad);
1836 c_retm_if(!p->ly_alarm, "p->ly_alarm is null");
1840 navi_item = elm_naviframe_item_push(p->nv, S_("IDS_COM_BODY_ALARM"), NULL, NULL, p->ly_alarm, NULL);
1842 btn_save = elm_button_add(p->nv);
1843 cal_util_set_controlbar_button(btn_save,S_("IDS_COM_OPT_SAVE"), "naviframe/title/default", __cal_edit_alarm_callback, item_data);
1844 elm_object_item_part_content_set(navi_item, "title_right_btn", btn_save);
1846 btn_cancel = elm_button_add(p->nv);
1847 cal_util_set_controlbar_button(btn_cancel,S_("IDS_COM_SK_CANCEL"), "naviframe/title/default", __cal_edit_cancel_button_callback, p->nv);
1848 elm_object_item_part_content_set(navi_item, "title_left_btn", btn_cancel);
1851 static void __cal_edit_save_to_popup_list_sel(void *data, Evas_Object *obj, void *event_info)
1853 c_retm_if(!data, "data is null");
1854 c_retm_if(!obj, "obj is null");
1856 cal_struct* cs = data;
1858 cal_edit_data *p = CAL_UTIL_GET_PRIV_DATA(obj);
1859 c_retm_if(!p, "p is null");
1861 Elm_Object_Item *item = elm_genlist_selected_item_get(obj);
1862 c_retm_if(!item, "elm_genlist_selected_item_get() returned null");
1864 elm_genlist_item_selected_set(item, EINA_FALSE);
1868 p->calid = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_TABLE_INT_INDEX);
1869 p->accid = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_TABLE_INT_ACCOUNT_ID);
1873 p->calid = DEFAULT_CALENDAR_ID;
1874 p->accid = LOCAL_ACCOUNT_ID;
1877 elm_genlist_item_update(it);
1879 evas_object_del(p->popup);
1883 static void __cal_edit_save_to_popup_hide_cb(void *data, Evas_Object *obj, void *event_info)
1885 c_retm_if(!data, "data is null");
1886 c_retm_if(!obj, "obj is null");
1888 Evas_Object *popup = data;
1890 cal_edit_data *p = evas_object_data_get(popup, "data");
1892 evas_object_del(popup);
1894 c_retm_if(!p, "p is null");
1899 static Evas_Object* __cal_edit_create_save_to_popup(Item_Data *item_data)
1901 c_retvm_if(!item_data, NULL, "item_data is null");
1903 Evas_Object *popup = NULL;
1904 Evas_Object *genlist = NULL;
1905 cal_edit_data *p = item_data->p;
1906 c_retvm_if(!p, NULL, "p is null");
1911 if (!p->calendar_list)
1913 p->calendar_list = CALENDAR_SVC_GET_CALENDARS(p->accid);
1914 c_retvm_if(!p->calendar_list, NULL, "p->calendar_list is null");
1917 popup = cal_util_add_popup(p->ad->win, C_("IDS_ST_BODY_SAVE_TO"), NULL,
1918 __cal_edit_save_to_popup_hide_cb, p, S_("IDS_COM_BODY_CLOSE"), NULL);
1919 c_retvm_if(!popup, NULL, "popup is null");
1920 elm_object_style_set(popup, "liststyle");
1922 genlist = elm_genlist_add(popup);
1924 ERR("elm_genlist_add(popup) returned null");
1925 evas_object_del(popup);
1929 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1930 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1931 evas_object_data_set(genlist, "priv", p);
1933 EINA_LIST_FOREACH(p->calendar_list, l, cs)
1936 elm_genlist_item_append(genlist, &itc_2text_1icon_2, cs, NULL, ELM_GENLIST_ITEM_NONE, __cal_edit_save_to_popup_list_sel, cs);
1939 elm_object_content_set(popup, genlist);
1940 evas_object_show(genlist);
1945 static void __cal_edit_show_save_to_popup(Item_Data *item_data)
1947 c_retm_if(!item_data, "item_data is null");
1950 c_retm_if(!it, "selected item is null");
1952 cal_edit_data *p = item_data->p;
1953 c_retm_if(!p, "p is null");
1955 Evas_Object *popup = __cal_edit_create_save_to_popup(item_data);
1956 c_retm_if(!popup, "popup is NULL");
1961 static void __cal_edit_genlist_item_select_callback(void *data, Evas_Object *obj, void *event_info)
1963 c_retm_if(!obj, "obj is null");
1965 Elm_Object_Item *it = elm_genlist_selected_item_get(obj);
1966 c_retm_if(!it, "elm_genlist_selected_item_get() returned null");
1968 Item_Data *item_data = (Item_Data *)elm_object_item_data_get(it);
1969 c_retm_if(!it, "elm_object_item_data_get() returned null");
1971 int type = item_data->type;
1973 cal_edit_data *p = item_data->p;
1974 c_retm_if(!p, "p is null");
1983 elm_object_focus_set(p->sdt, EINA_TRUE);
1986 elm_object_focus_set(p->edt, EINA_TRUE);
1989 elm_check_state_set(p->c_allday, !elm_check_state_get(p->c_allday));
1990 __cal_edit_all_day_changed_callback(p, p->c_allday, event_info);
1992 case _GTYPE_TIME_ZONE:
1993 __cal_edit_timezone_select_callback(item_data);
1996 __cal_edit_alarm_select_callback(item_data);
1999 __cal_edit_repeat_select_callback(item_data);
2003 case _GTYPE_LINKED_CAL:
2004 __cal_edit_show_save_to_popup(item_data);
2010 elm_genlist_item_selected_set(it, EINA_FALSE);
2015 static char *__cal_edit_get_genlist_save_to_item_label(void *data, Evas_Object *obj, const char *part)
2017 c_retvm_if(!data, NULL, "data is null");
2018 c_retvm_if(!part, NULL, "part is null");
2020 cal_struct *cs = (cal_struct*)data;
2025 if (!CAL_STRCMP(part,"elm.text.1")) {
2027 return strdup(C_("IDS_CLD_OPT_PHONE_CALENDAR"));
2029 cid = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_TABLE_INT_INDEX);
2030 if (cid == DEFAULT_CALENDAR_ID)
2031 return strdup(C_("IDS_CLD_OPT_PHONE_CALENDAR"));
2033 name = CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_TABLE_TXT_NAME);
2035 return strdup(name);
2037 return strdup(C_("IDS_CLD_BODY_NO_TITLE"));
2039 else if (!CAL_STRCMP(part,"elm.text.2")) {
2041 return strdup(S_("IDS_COM_POP_NO_ACCOUNTS"));
2043 cid = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_TABLE_INT_INDEX);
2044 if (cid == DEFAULT_CALENDAR_ID)
2045 return strdup(C_("IDS_EMAIL_BODY_DEFAULT_ACCOUNT"));
2047 description = CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_TABLE_TXT_DESCRIPTION);
2049 return strdup(description);
2051 return strdup(S_("IDS_COM_POP_NO_ACCOUNTS"));
2054 return strdup(C_("IDS_CLD_BODY_NO_TITLE"));
2057 static Elm_Object_Item* __cal_edit_add_genlist_item(Evas_Object *genlist, Elm_Genlist_Item_Class *itc, int type, cal_edit_data *p)
2059 c_retvm_if(!genlist, NULL, "genlist is null");
2060 c_retvm_if(!itc, NULL, "itc is null");
2061 c_retvm_if(!p, NULL, "p is null");
2063 Item_Data *item_data = calloc(1, sizeof(Item_Data));
2064 c_retvm_if(!item_data, NULL, "calloc is failed");
2067 item_data->type = type;
2069 item_data->it = elm_genlist_item_append(genlist, itc, item_data, NULL, ELM_GENLIST_ITEM_NONE, __cal_edit_genlist_item_select_callback, NULL);
2072 ERR("elm_genlist_item_append returned null");
2077 if ( type == _GTYPE_START || type == _GTYPE_END )
2078 elm_genlist_item_select_mode_set( item_data->it, ELM_OBJECT_SELECT_MODE_NONE );
2080 return item_data->it;
2083 static Elm_Object_Item* __cal_edit_add_genlist_alarm_item(Evas_Object *genlist, Elm_Genlist_Item_Class *itc, int type, cal_edit_data *p, int alarm)
2085 c_retvm_if(!genlist, NULL, "genlist is null");
2086 c_retvm_if(!itc, NULL, "itc is null");
2087 c_retvm_if(!p, NULL, "p is null");
2089 Item_Data *item_data = calloc(1, sizeof(Item_Data));
2090 c_retvm_if(!item_data, NULL, "calloc is failed");
2093 item_data->type = type;
2094 item_data->alarm_value = alarm;
2096 if (!p->alarm_first_it) {
2097 item_data->it = elm_genlist_item_append(genlist, &itc_2text, item_data, NULL, ELM_GENLIST_ITEM_NONE, __cal_edit_genlist_item_select_callback, NULL);
2098 p->alarm_first_it = p->alarm_last_it = item_data->it;
2100 item_data->it = elm_genlist_item_insert_after(genlist, itc, item_data, NULL,p->alarm_last_it, ELM_GENLIST_ITEM_NONE, __cal_edit_genlist_item_select_callback, NULL);
2101 p->alarm_last_it = item_data->it;
2106 ERR("elm_genlist_item_append returned null");
2111 return item_data->it;
2115 static Elm_Object_Item* __cal_edit_add_separator(Evas_Object *genlist, cal_edit_data *p)
2117 c_retvm_if(!genlist, NULL, "genlist is null");
2118 c_retvm_if(!p, NULL, "p is null");
2120 Elm_Object_Item *git = __cal_edit_add_genlist_item(genlist, &itc_seperator, 0, p);
2121 c_retvm_if(!git, NULL, "__cal_edit_add_genlist_item returned null");
2123 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_NONE);
2128 static Elm_Object_Item* __cal_edit_set_title(Evas_Object *genlist, cal_edit_data *p)
2130 __cal_edit_add_separator(genlist, p);
2132 return __cal_edit_add_genlist_item(genlist, &itc_1icon, _GTYPE_TITLE, p);
2135 static Elm_Object_Item* __cal_edit_set_location(Evas_Object *genlist, cal_edit_data *p)
2137 return __cal_edit_add_genlist_item(genlist, &itc_1icon, _GTYPE_LOC, p);
2140 static Elm_Object_Item* __cal_edit_set_start_date(Evas_Object *genlist, cal_edit_data *p)
2142 __cal_edit_add_separator(genlist, p);
2144 return __cal_edit_add_genlist_item(genlist, &itc_1icon, _GTYPE_START, p);
2147 static Elm_Object_Item* __cal_edit_set_end_date(Evas_Object *genlist, cal_edit_data *p)
2149 return __cal_edit_add_genlist_item(genlist, &itc_1icon, _GTYPE_END, p);
2152 static Elm_Object_Item* __cal_edit_set_all_day(Evas_Object *genlist, cal_edit_data *p)
2154 return __cal_edit_add_genlist_item(genlist, &itc_1text_1icon, _GTYPE_ALLDAY, p);
2157 static Elm_Object_Item* __cal_edit_set_time_zone(Evas_Object *genlist, cal_edit_data *p)
2159 __cal_edit_add_separator(genlist, p);
2161 return __cal_edit_add_genlist_item(genlist, &itc_2text, _GTYPE_TIME_ZONE, p);
2164 static void __cal_edit_set_alarm(Evas_Object *genlist, cal_edit_data *p)
2166 __cal_edit_add_separator(genlist, p);
2168 GList *temp = p->list_alm_min;
2171 p->alarm_first_it = p->alarm_last_it =
2172 __cal_edit_add_genlist_alarm_item(genlist, &itc_2text_1btn, _GTYPE_ALARM, p,
2173 (p->event_id?CAL_EDIT_ALARM_OFF:CAL_EDIT_ALARM_ON_TIME));
2176 __cal_edit_add_genlist_alarm_item(genlist, &itc_2text_1btn, _GTYPE_ALARM, p, (int)temp->data);
2178 temp = g_list_next(temp);
2183 static Elm_Object_Item* __cal_edit_set_repeat(Evas_Object *genlist, cal_edit_data *p)
2185 __cal_edit_add_separator(genlist, p);
2187 return __cal_edit_add_genlist_item(genlist, &itc_2text, _GTYPE_REPEAT, p);
2190 static Elm_Object_Item* __cal_edit_set_note(Evas_Object *genlist, cal_edit_data *p)
2192 __cal_edit_add_separator(genlist, p);
2194 return __cal_edit_add_genlist_item(genlist, &itc_1icon, _GTYPE_NOTE, p);
2197 static Elm_Object_Item* __cal_edit_set_save_to(Evas_Object *genlist, cal_edit_data *p)
2199 __cal_edit_add_separator(genlist, p);
2201 return __cal_edit_add_genlist_item(genlist, &itc_2text, _GTYPE_LINKED_CAL, p);
2205 static void __cal_edit_set_edit(cal_edit_data *p)
2211 p->stm.tm_year = p->ad->base_tm.tm_year;
2212 p->stm.tm_mon = p->ad->base_tm.tm_mon;
2213 p->stm.tm_mday = p->ad->base_tm.tm_mday;
2215 if (-1 != p->ad->base_hour)
2217 p->stm.tm_hour = p->ad->base_hour;
2223 cal_util_update_tm_hour(&p->stm,1);
2225 p->stm.tm_min = p->stm.tm_sec = 0;
2227 t = mktime(&p->stm);
2228 t += 60 * 60; // add 1 hour
2229 localtime_r(&t, &p->etm);
2231 p->allday = EINA_FALSE;
2234 static Eina_Bool __cal_edit_append_widget_idler(void* data)
2236 c_retvm_if(!data, ECORE_CALLBACK_CANCEL, "data is null");
2238 cal_edit_data *p = (cal_edit_data *)data;
2239 Evas_Object *genlist = p->genlist;
2241 __cal_edit_set_note(genlist, p);
2243 __cal_edit_set_save_to(genlist, p);
2247 return ECORE_CALLBACK_CANCEL;
2250 static Evas_Object* __cal_edit_create_genlist(cal_edit_data* p)
2252 Elm_Object_Item* item = NULL;
2253 Evas_Object *genlist = elm_genlist_add(p->ly);
2254 c_retvm_if(!genlist, NULL, "elm_genlist_add() is failed");
2256 evas_object_data_set(genlist, "priv", p);
2259 elm_object_theme_set(genlist, p->ad->theme);
2261 itc_seperator.item_style = "dialogue/separator/21/with_line";
2262 itc_seperator.func.text_get = NULL;
2263 itc_seperator.func.state_get = __cal_edit_get_genlist_item_state;
2264 itc_seperator.func.del = __cal_edit_genlist_item_delete;
2266 itc_1icon.item_style = "dialogue/1icon";
2267 itc_1icon.func.text_get = __cal_edit_get_genlist_item_label;
2268 itc_1icon.func.del = __cal_edit_genlist_item_delete;
2269 itc_1icon.func.content_get = __cal_edit_get_genlist_item_icon;
2271 itc_1text_1icon.item_style = "dialogue/1text.1icon";
2272 itc_1text_1icon.func.text_get = __cal_edit_get_genlist_item_label;
2273 itc_1text_1icon.func.del = __cal_edit_genlist_item_delete;
2274 itc_1text_1icon.func.content_get = __cal_edit_get_genlist_item_icon;
2276 itc_2text.item_style = "dialogue/2text.3";
2277 itc_2text.func.text_get = __cal_edit_get_genlist_item_label;
2278 itc_2text.func.del = __cal_edit_genlist_item_delete;
2279 itc_2text.func.content_get = __cal_edit_get_genlist_item_icon;
2280 itc_2text.func.state_get = NULL;
2282 itc_2text_1btn.item_style = "dialogue/2text.1icon.6";
2283 itc_2text_1btn.func.text_get = __cal_edit_get_genlist_item_label;
2284 itc_2text_1btn.func.content_get = __cal_edit_get_genlist_item_icon;
2285 itc_2text_1btn.func.state_get = NULL;
2286 itc_2text_1btn.func.del = __cal_edit_genlist_item_delete;
2287 itc_2text_1btn.decorate_item_style = "dialogue/edit/contact";
2289 itc_2text_1icon_4.item_style = "dialogue/2text.1icon.4";
2290 itc_2text_1icon_4.func.text_get = __cal_edit_get_genlist_item_label;
2291 itc_2text_1icon_4.func.del = __cal_edit_genlist_item_delete;
2292 itc_2text_1icon_4.func.content_get = __cal_edit_get_genlist_item_icon;
2294 itc_2text_1icon_2.item_style = "dialogue/2text.1icon.2";
2295 itc_2text_1icon_2.func.text_get = __cal_edit_get_genlist_save_to_item_label;
2296 itc_2text_1icon_2.func.content_get = __cal_edit_add_save_to_icon;
2298 itc_2text_2icon_4.item_style = "dialogue/2text.2icon.4";
2299 itc_2text_2icon_4.func.text_get = __cal_edit_get_genlist_item_label;
2300 itc_2text_2icon_4.func.del = __cal_edit_genlist_item_delete;
2301 itc_2text_2icon_4.func.content_get = __cal_edit_get_genlist_item_icon;
2303 __cal_edit_set_title(genlist, p);
2304 __cal_edit_set_location(genlist, p);
2305 __cal_edit_set_start_date(genlist, p);
2306 __cal_edit_set_end_date(genlist, p);
2307 __cal_edit_set_all_day(genlist, p);
2309 p->timezone_item = __cal_edit_set_time_zone(genlist, p);
2311 __cal_edit_set_alarm(genlist, p);
2313 item = __cal_edit_set_repeat(genlist, p);
2314 if (p->ad->edit_special_one)
2315 elm_object_item_disabled_set(item, EINA_TRUE);
2317 evas_object_show(genlist);
2322 static void __cal_edit_layout_rendering_callback(void *data, Evas *e, void *event_info)
2326 c_retm_if(!data, "data is null");
2328 cal_edit_data* p = data;
2330 evas_event_callback_del(e, EVAS_CALLBACK_RENDER_FLUSH_POST, __cal_edit_layout_rendering_callback);
2336 p->idler = ecore_idler_add(__cal_edit_append_widget_idler,p);
2341 static Evas_Object *__cal_edit_create_layout(struct appdata *ad, Evas_Object *parent)
2343 c_retvm_if(!ad, NULL, "ad is null");
2344 c_retvm_if(!parent, NULL, "parent is null");
2350 cal_edit_data *p = calloc(1, sizeof(cal_edit_data));
2351 c_retvm_if(!p, NULL, "calloc(1, sizeof(cal_edit_data)) returned null");
2356 p->snote = ad->strnote;
2357 p->is_selected_timezone = EINA_FALSE;
2360 p->alarm_last_it = NULL;
2361 p->alarm_first_it = NULL;
2362 p->list_alm_min = NULL;
2363 p->add_button = NULL;
2364 time_t t = time(NULL);
2365 localtime_r(&t,&tm);
2367 CAL_MEMCPY(&p->repeat_end_date_time, &tm, struct tm);
2369 ly = cal_util_add_layout(ad->nv, "edit");
2372 ERR("cal_util_add_layout return null");
2377 e = evas_object_evas_get(ly);
2380 p->event_id = ad->cid;
2381 evas_object_data_set(ly, "priv", p);
2383 if (ad->is_aul && ad->ical)
2384 __cal_edit_fill_vcs_information(p);
2387 __cal_edit_fill_detail_information(p, p->event_id);
2389 __cal_edit_set_default_information(p);
2390 __cal_edit_set_edit(p);
2394 p->genlist = __cal_edit_create_genlist(p);
2397 evas_object_del(ly);
2402 cf = elm_conformant_add(ad->win);
2405 ERR("elm_conformant_add(ad->win) is failed");
2406 evas_object_del(ly);
2411 evas_object_size_hint_weight_set(cf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2412 evas_object_show(cf);
2413 elm_object_content_set(cf, p->genlist);
2414 elm_object_style_set(cf, "internal_layout");
2415 elm_object_part_content_set(ly, "sw", cf);
2417 evas_object_event_callback_add(ly, EVAS_CALLBACK_DEL, __cal_edit_delete_layout, p);
2418 evas_event_callback_add(e, EVAS_CALLBACK_RENDER_FLUSH_POST, __cal_edit_layout_rendering_callback, p);
2423 static void __cal_edit_back_button_callback(void *data, Evas_Object *obj, void *ei)
2427 c_retm_if(!data, "data is null");
2429 cal_edit_data *p = data;
2430 Elm_Object_Item* navi_item = NULL;
2432 if ((NULL != p->ad->ug) && (UG_EDIT == p->ad->u_type))
2434 ug_destroy_me(p->ad->ug);
2438 if (p->ad->request_view == CV_EDIT)
2440 if (elm_naviframe_top_item_get(p->ad->nv) != elm_naviframe_bottom_item_get(p->ad->nv))
2442 p->ad->request_view = CV_UNKNOWN;
2443 elm_win_lower(p->ad->win);
2449 elm_naviframe_prev_btn_auto_pushed_set(p->ad->nv, EINA_TRUE);
2450 elm_naviframe_item_pop(p->ad->nv);
2451 navi_item = elm_naviframe_top_item_get(p->ad->nv);
2453 if (p->ad->is_update_view)
2454 edje_object_signal_emit(CAL_UTIL_GET_EDJ_DATA(p->parent), "update", "prog");
2458 static void __cal_edit_add_controlbar( struct appdata *ad, Evas_Object *ly)
2460 c_retm_if(!ad, "ad is null");
2461 c_retm_if(!ly, "ly is null");
2463 Elm_Object_Item* navi_item;
2465 Evas_Object *btn_save;
2466 Evas_Object *btn_cancel;
2469 title = S_("IDS_COM_SK_EDIT");
2471 title = S_("IDS_COM_SK_NEW");
2473 elm_naviframe_prev_btn_auto_pushed_set(ad->nv, EINA_FALSE);
2475 navi_item = elm_naviframe_item_push(ad->nv, title, NULL, NULL, ly, NULL);
2476 c_retm_if(!navi_item, "elm_naviframe_item_push returned null");
2478 btn_save = elm_button_add(ad->nv);
2479 c_retm_if(!btn_save, "elm_button_add(ad->nv) returned null");
2480 cal_util_set_controlbar_button(btn_save, S_("IDS_COM_OPT_SAVE"), "naviframe/title/default", __cal_edit_save_button_callback, ly);
2481 elm_object_item_part_content_set(navi_item, "title_right_btn", btn_save);
2483 btn_cancel = elm_button_add(ad->nv);
2484 c_retm_if(!btn_cancel, "elm_button_add(ad->nv) returned null");
2485 cal_util_set_controlbar_button(btn_cancel, S_("IDS_COM_SK_CANCEL"), "naviframe/title/default", __cal_edit_back_button_callback, CAL_UTIL_GET_PRIV_DATA(ly));
2486 elm_object_item_part_content_set(navi_item, "title_left_btn", btn_cancel);
2489 void cal_edit_create_view(struct appdata *ad, Evas_Object *parent)
2493 c_retm_if(!ad, "ad is null");
2494 c_retm_if(!parent, "parent is null");
2496 Evas_Object *ly = __cal_edit_create_layout(ad, parent);
2497 c_retm_if(!ly, "__cal_edit_create_layout(ad, parent) returned null");
2499 __cal_edit_add_controlbar(ad, ly);