3 * Copyright 2012 Samsung Electronics Co., Ltd
5 * Licensed under the Flora License, Version 1.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include <ui-gadget-module.h>
25 #include "external-ug.h"
26 #include "detail-common.h"
27 #include "detail-attendee.h"
33 Evas_Object *base_layout;
34 Evas_Object *naviframe;
36 Evas_Object *dialogue;
38 Elm_Object_Item *navi_item;
40 calendar_record_h instance;
41 calendar_record_h record;
43 Ecore_Event_Handler *mouse_down_event_handler;
44 Evas_Coord mouse_down_x;
45 Evas_Coord mouse_down_y;
51 Evas_Object *reminder;
52 Evas_Object *recurrence;
54 Evas_Object *attendee;
55 Evas_Object *show_me_as;
62 static int __cal_detail_ug_initialize(cal_detail_ug_data *data)
66 calendar_error_e error = CALENDAR_ERROR_NONE;
68 error = calendar_connect();
69 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_connect() is failed(%x)", error);
71 _calendar_init_hash();
73 const char *path = bindtextdomain(CALENDAR, LOCALEDIR);
74 c_warn_if(!path, "bindtextdomain(%s, %s) is failed.", CALENDAR, LOCALEDIR);
76 cal_util_connect_pattern_generator();
81 static void __cal_detail_ug_finish()
85 calendar_error_e error = CALENDAR_ERROR_NONE;
87 error = calendar_disconnect();
88 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_disconnect() is failed(%x)", error);
90 elm_theme_extension_del(NULL, EDJDIR "/calendar_theme.edj");
92 cal_util_disconnect_pattern_generator();
95 static void __cal_detail_ug_back_button_callback(void *user_data, Evas_Object *obj, void *ei)
101 cal_detail_ug_data *data = user_data;
105 ug_destroy_me(data->ug);
108 static Evas_Object * __cal_detail_ug_add_back_button(cal_detail_ug_data *data)
112 Evas_Object *back_button = elm_button_add(data->naviframe);
113 c_retv_if(!back_button, NULL);
115 evas_object_smart_callback_add(back_button, "clicked", __cal_detail_ug_back_button_callback, data);
117 elm_object_style_set(back_button, "naviframe/end_btn/default");
122 static void __cal_detail_ug_update_title_language(Evas_Object *item, calendar_record_h record)
126 char *summary = _calendar_get_summary(record);
128 elm_object_part_text_set(item, "elm.text.1", summary);
133 static Evas_Object * __cal_detail_ug_add_title(Evas_Object *box, calendar_record_h record)
137 c_retv_if(!box, NULL);
138 c_retv_if(!record, NULL);
140 Evas_Object *item = cal_dialogue_append_item(box, "2text", NULL, NULL);
142 __cal_detail_ug_update_title_language(item, record);
144 char *location = _calendar_get_location(record);
146 elm_object_part_text_set(item, "elm.text.2", location);
153 static void __cal_detail_ug_update_from_language(Evas_Object *item)
157 elm_object_part_text_set(item, "elm.text.1", C_("IDS_CLD_BODY_FROM"));
160 static void __cal_detail_ug_update_from_region(Evas_Object *item, calendar_record_h record)
164 const char *time_format = NULL;
166 if (!_calendar_is_allday_record(record)) {
168 time_format = CAL_UTIL_TIME_FORMAT_6;
170 time_format = CAL_UTIL_TIME_FORMAT_1;
173 calendar_time_s time = {0};
175 _calendar_get_start_time(record, &time);
177 char *from_time = _calendar_get_time_str(&time, CAL_UTIL_DATE_FORMAT_1, time_format);
179 elm_object_part_text_set(item, "elm.text.2", from_time);
184 static Evas_Object * __cal_detail_ug_add_start_time(Evas_Object *box, calendar_record_h record)
188 c_retv_if(!box, NULL);
189 c_retv_if(!record, NULL);
191 Evas_Object *item = cal_dialogue_append_item(box, "2text", NULL, NULL);
193 __cal_detail_ug_update_from_language(item);
195 __cal_detail_ug_update_from_region(item, record);
200 static void __cal_detail_ug_update_to_language(Evas_Object *item)
204 elm_object_part_text_set(item, "elm.text.1", C_("IDS_CLD_BODY_TO"));
207 static void __cal_detail_ug_update_to_region(Evas_Object *item, calendar_record_h record)
211 const char *time_format = NULL;
213 if (!_calendar_is_allday_record(record)) {
215 time_format = CAL_UTIL_TIME_FORMAT_6;
217 time_format = CAL_UTIL_TIME_FORMAT_1;
220 calendar_time_s time = {0};
222 _calendar_get_end_time(record, &time);
224 char *to_time = _calendar_get_time_str(&time, CAL_UTIL_DATE_FORMAT_1, time_format);
226 elm_object_part_text_set(item, "elm.text.2", to_time);
231 static Evas_Object * __cal_detail_ug_add_end_time(Evas_Object *box, calendar_record_h record)
235 c_retv_if(!box, NULL);
236 c_retv_if(!record, NULL);
238 Evas_Object *item = cal_dialogue_append_item(box, "2text", NULL, NULL);
240 __cal_detail_ug_update_to_language(item);
242 __cal_detail_ug_update_to_region(item, record);
247 static void __cal_detail_ug_update_due_language(Evas_Object *item)
251 elm_object_part_text_set(item, "elm.text.1", C_("IDS_CLD_BODY_DUE_DATE"));
254 static void __cal_detail_ug_update_due_region(Evas_Object *item, calendar_record_h record)
258 const char *time_format = NULL;
260 if (!_calendar_is_allday_record(record)) {
262 time_format = CAL_UTIL_TIME_FORMAT_6;
264 time_format = CAL_UTIL_TIME_FORMAT_1;
267 calendar_time_s due_time = {0};
269 _calendar_get_end_time(record, &due_time);
271 if (due_time.time.utime == CALENDAR_TODO_NO_DUE_DATE) {
272 elm_object_part_text_set(item, "elm.text.1", C_("IDS_CLD_BODY_NO_DUE_DATE_M_NOUN"));
276 char *due_time_text = _calendar_get_time_str(&due_time, CAL_UTIL_DATE_FORMAT_1, time_format);
278 elm_object_part_text_set(item, "elm.text.2", due_time_text);
284 static Evas_Object * __cal_detail_ug_add_due_time(Evas_Object *box, calendar_record_h record)
288 c_retv_if(!box, NULL);
289 c_retv_if(!record, NULL);
291 Evas_Object *item = cal_dialogue_append_item(box, "2text", NULL, NULL);
293 __cal_detail_ug_update_due_language(item);
295 __cal_detail_ug_update_due_region(item, record);
300 static char * __cal_detail_ug_get_recurrence_text(calendar_record_h record)
304 c_retv_if(!record, NULL);
306 calendar_error_e error = CALENDAR_ERROR_NONE;
310 error = calendar_record_get_int(record, _calendar_event.freq, &freq);
311 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
315 error = calendar_record_get_int(record, _calendar_event.interval, &interval);
316 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
318 if (freq == CALENDAR_RECURRENCE_WEEKLY) {
320 freq = CAL_REPEAT_EVERY_2_WEEK;
322 } else if (freq == CALENDAR_RECURRENCE_DAILY) {
324 freq = CAL_REPEAT_EVERY_3_DAY;
329 _calendar_get_recurrence_frequency_str(freq, buf, sizeof(buf));
334 static GList * __cal_detail_ug_get_reminder_list(calendar_record_h record)
338 c_retv_if(!record, NULL);
340 GList *reminder_list = NULL;
342 int reminder_count = 0;
343 calendar_error_e error = CALENDAR_ERROR_NONE;
345 if (_calendar_is_task_record(record))
346 error = calendar_record_get_child_record_count(record, _calendar_todo.calendar_alarm, (unsigned int *)&reminder_count);
348 error = calendar_record_get_child_record_count(record, _calendar_event.calendar_alarm, (unsigned int *)&reminder_count);
350 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_count() is failed(%x)", error);
353 for (i = 0; i < reminder_count; i++) {
354 calendar_record_h calendar_alarm = NULL;
356 if (_calendar_is_task_record(record))
357 error = calendar_record_get_child_record_at_p(record, _calendar_todo.calendar_alarm, i, &calendar_alarm);
359 error = calendar_record_get_child_record_at_p(record, _calendar_event.calendar_alarm, i, &calendar_alarm);
361 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_at_p() is failed(%x)", error);
363 Cal_Reminder* reminder = cal_reminder_create(calendar_alarm);
364 reminder_list = g_list_append(reminder_list, (void *)reminder);
368 reminder_list = g_list_first(reminder_list);
370 return reminder_list;
373 static void __cal_detail_ug_update_reminder_language(Evas_Object *item, calendar_record_h record)
377 elm_object_part_text_set(item, "elm.text.1", C_("IDS_CLD_BODY_REMINDER"));
379 GList *reminder_list = __cal_detail_ug_get_reminder_list(record);
382 char reminder_text[50] = {0};
384 cal_reminder_get_string(reminder_list->data, reminder_text, sizeof(reminder_text));
386 elm_object_part_text_set(item, "elm.text.2", reminder_text);
388 g_list_free(reminder_list);
390 elm_object_part_text_set(item, "elm.text.2", S_("IDS_COM_BODY_OFF"));
393 static Evas_Object * __cal_detail_ug_add_reminder(Evas_Object *box, calendar_record_h record)
397 c_retv_if(!box, NULL);
398 c_retv_if(!record, NULL);
400 Evas_Object *item = cal_dialogue_append_item(box, "2text", NULL, NULL);
402 __cal_detail_ug_update_reminder_language(item, record);
407 static void __cal_detail_ug_update_recurrence_language(Evas_Object *item, calendar_record_h record)
411 char *recurrence = __cal_detail_ug_get_recurrence_text(record);
413 elm_object_part_text_set(item, "elm.text.1", C_("IDS_CLD_BODY_REPEAT"));
414 elm_object_part_text_set(item, "elm.text.2", recurrence);
419 static Evas_Object * __cal_detail_ug_add_recurrence(Evas_Object *box, calendar_record_h record)
423 c_retv_if(!box, NULL);
424 c_retv_if(!record, NULL);
426 Evas_Object *item = cal_dialogue_append_item(box, "2text", NULL, NULL);
428 __cal_detail_ug_update_recurrence_language(item, record);
433 static inline char* __cal_detail_get_note_text(calendar_record_h record)
435 c_retv_if(!record, NULL);
439 calendar_error_e error = CALENDAR_ERROR_NONE;
441 if (_calendar_is_task_record(record))
442 error = calendar_record_get_str_p(record, _calendar_todo.description, ¬e);
444 error = calendar_record_get_str_p(record, _calendar_event.description, ¬e);
446 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_str() is failed(%x)", error);
451 static Evas_Object * __cal_detail_ug_add_note(Evas_Object *box, calendar_record_h record)
455 c_retv_if(!box, NULL);
456 c_retv_if(!record, NULL);
458 char *note = __cal_detail_get_note_text(record);
460 if (!CAL_STRLEN(note))
463 Evas_Object *item = cal_dialogue_append_item(box, "1icon", NULL, NULL);
465 Evas_Object *edit_field = cal_util_add_edit_field(item, NULL, EINA_FALSE, EINA_FALSE);
467 ERR("cal_util_add_edit_field() is failed.");
469 evas_object_del(item);
474 Evas_Object *entry = elm_object_part_content_get(edit_field, "elm.swallow.content");
476 ERR("cal_util_add_edit_field() is failed.");
478 evas_object_del(item);
483 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
484 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_EXPAND);
485 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
486 elm_entry_autocapital_type_set(entry, EINA_TRUE);
488 elm_entry_entry_set(entry, note);
490 elm_object_part_content_set(item, "elm.icon", edit_field);
495 static inline void __cal_detail_append_multibutton_entry_item(Evas_Object *mbe, calendar_record_h record)
497 cal_participant *part = calloc(1, sizeof(cal_participant));
502 calendar_error_e error = CALENDAR_ERROR_NONE;
503 error = calendar_record_get_str(record, _calendar_attendee.name, &name);
504 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_str() is failed(%x)", error);
505 if (!CAL_STRLEN(name)) {
506 ERR("Attendee name is NULL!!");
507 name = S_("IDS_COM_BODY_UNKNOWN");
510 part->name = CAL_STRDUP(name);
513 error = calendar_record_get_str(record, _calendar_attendee.email, &email);
514 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_str() is failed(%x)", error);
516 if (CAL_STRLEN(email))
517 part->email = strdup(email);
519 ERR("Attendee email is mandatory data!! There is no email for %s.", part->name);
521 error = calendar_record_get_int(record, _calendar_attendee.person_id, &part->person_id);
522 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
524 error = calendar_record_get_int(record, _calendar_attendee.status, &part->status);
525 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
527 error = calendar_record_get_int(record, _calendar_attendee.role, &part->role);
528 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
530 error = calendar_record_get_int(record, _calendar_attendee.rsvp, &part->response);
531 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
533 elm_multibuttonentry_item_append(mbe, name, NULL, part);
536 static inline void __cal_detail_set_multibutton_entry_item(Evas_Object *multibutton_entry, calendar_record_h record)
538 c_ret_if(!multibutton_entry);
541 int attendee_count = 0;
543 calendar_error_e error = CALENDAR_ERROR_NONE;
545 error = calendar_record_get_child_record_count(record, _calendar_event.calendar_attendee, (unsigned int *)&attendee_count);
546 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_count() is failed(%x)", error);
550 for (i = 0; i < attendee_count; i++) {
551 calendar_record_h calendar_attendee = NULL;
553 error = calendar_record_get_child_record_at_p(record, _calendar_event.calendar_attendee, i, &calendar_attendee);
554 if (error != CALENDAR_ERROR_NONE) {
555 ERR("calendar_record_get_child_record_at_p() is failed(%x)", error);
559 __cal_detail_append_multibutton_entry_item(multibutton_entry, calendar_attendee);
563 static void __cal_detail_popup_hide_callback(void *data, Evas_Object *obj, void *ei)
565 evas_object_del(obj);
568 static void __cal_detail_show_ctx_popup(cal_detail_ug_data *data, cal_participant *part)
573 Evas_Object *ctx_popup = elm_ctxpopup_add(data->naviframe);
574 c_ret_if(!ctx_popup);
576 int person_id = part->person_id;
577 char *name = part->name;
580 cal_detail_common_get_person_default_number(person_id, &part->number);
582 char *number = part->number;
584 evas_object_smart_callback_add(ctx_popup, "dismissed", __cal_detail_popup_hide_callback, data);
586 if (CAL_STRLEN(number)) {
587 elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BODY_VOICE_CALL"), NULL, cal_detail_common_ctx_callback_for_voice_call, number);
589 elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BODY_MESSAGE"), NULL, cal_detail_common_ctx_callback_for_message, number);
592 if (CAL_STRLEN(part->email)) {
593 elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BODY_EMAIL"), NULL, cal_detail_common_ctx_callback_for_email, part->email);
597 evas_object_smart_callback_add(ctx_popup, "dismissed", __cal_detail_popup_hide_callback, NULL);
599 elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BODY_EMAIL"), NULL, cal_detail_common_ctx_callback_for_email, name);
600 elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_OPT_ADD_TO_CONTACTS"), NULL, cal_detail_common_ctx_callback_for_contact, name);
603 evas_object_data_set(ctx_popup, "record", data->record);
604 evas_object_move(ctx_popup, data->mouse_down_x, data->mouse_down_y);
605 evas_object_show(ctx_popup);
608 static void __cal_detail_multibuttonentry_item_selected_callback(void *user_data, Evas_Object *obj, void *ei)
611 c_ret_if(!user_data);
613 Elm_Object_Item *it = ei;
614 cal_detail_ug_data *data = user_data;
616 cal_participant *part = elm_object_item_data_get(it);
619 __cal_detail_show_ctx_popup(data, part);
622 static void __cal_detail_multibuttonentry_item_deleted_callback(void *data, Evas_Object *obj, void *ei)
626 Elm_Object_Item *item = ei;
628 cal_participant *part = elm_object_item_data_get(item);
631 CAL_FREE(part->name);
636 static void __cal_detail_multibuttonentry_unfocused_callback(void *data, Evas_Object *obj, void *ei)
640 elm_multibuttonentry_item_selected_set(elm_multibuttonentry_selected_item_get(obj), EINA_FALSE);
643 static Eina_Bool __cal_detail_mouse_down_callback(void *user_data, int type, void *event)
645 c_retv_if(!user_data, ECORE_CALLBACK_RENEW);
646 c_retv_if(!event, ECORE_CALLBACK_RENEW);
648 cal_detail_ug_data *data = user_data;
650 Ecore_Event_Mouse_Button *ev= event;
653 data->mouse_down_x = ev->x;
654 data->mouse_down_y = ev->y;
656 return ECORE_CALLBACK_RENEW;
659 static Evas_Object * __cal_detail_add_multibutton_entry(Evas_Object *item, cal_detail_ug_data *data)
661 c_retv_if(!item, NULL);
662 c_retv_if(!data, NULL);
664 Evas_Object *multibutton_entry = elm_multibuttonentry_add(item);
665 c_retv_if(!multibutton_entry, NULL);
667 evas_object_size_hint_weight_set(multibutton_entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
668 evas_object_size_hint_align_set(multibutton_entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
670 evas_object_smart_callback_add(multibutton_entry, "item,selected", __cal_detail_multibuttonentry_item_selected_callback, data);
671 evas_object_smart_callback_add(multibutton_entry, "item,deleted", __cal_detail_multibuttonentry_item_deleted_callback, NULL);
672 evas_object_smart_callback_add(multibutton_entry, "unfocused", __cal_detail_multibuttonentry_unfocused_callback, NULL);
674 Evas_Object *entry = elm_multibuttonentry_entry_get(multibutton_entry);
676 elm_entry_editable_set(entry, EINA_FALSE);
678 evas_object_show(multibutton_entry);
680 if (!data->mouse_down_event_handler)
681 data->mouse_down_event_handler = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, __cal_detail_mouse_down_callback, data);
683 return multibutton_entry;
686 static void __cal_detail_attendee_status_button_callback(void *user_data, Evas_Object *obj, void *event_info)
690 c_ret_if(!user_data);
692 cal_detail_ug_data *data = user_data;
694 cal_detail_attendee_create_view(data->naviframe, data->record);
697 static Evas_Object * __cal_detail_ug_add_attendee(Evas_Object *box, calendar_record_h record, cal_detail_ug_data *data)
701 c_retv_if(!box, NULL);
702 c_retv_if(!record, NULL);
703 c_retv_if(!data, NULL);
705 int attendee_count = 0;
707 calendar_error_e error = CALENDAR_ERROR_NONE;
709 error = calendar_record_get_child_record_count(record, _calendar_event.calendar_attendee, (unsigned int *)&attendee_count);
710 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_count() is failed(%x)", error);
715 Evas_Object *item = cal_dialogue_append_item(box, "1icon", NULL, NULL);
717 Evas_Object *multibutton_entry = __cal_detail_add_multibutton_entry(item, data);
719 __cal_detail_set_multibutton_entry_item(multibutton_entry, record);
721 elm_object_part_content_set(item, "elm.icon", multibutton_entry);
723 Evas_Object *attendee_status_button = elm_button_add(item);
724 c_retv_if(!attendee_status_button, item);
726 cal_util_set_controlbar_button(attendee_status_button, NULL, "reveal/extended", __cal_detail_attendee_status_button_callback, data);
728 elm_object_part_content_set(item, "elm.icon.2", attendee_status_button);
733 static void __cal_detail_get_save_to_text(int calendar_book_id, char *buf, int sz)
736 calendar_error_e error = CALENDAR_ERROR_NONE;
737 calendar_record_h calendar = NULL;
739 error = calendar_db_get_record(_calendar_book._uri, calendar_book_id, &calendar);
740 c_ret_if(error != CALENDAR_ERROR_NONE);
742 if (calendar_book_id == DEFAULT_EVENT_CALENDAR_BOOK_ID)
743 str = C_("IDS_CLD_BODY_MY_CALENDAR");
744 else if (calendar_book_id == DEFAULT_TODO_CALENDAR_BOOK_ID)
745 str = C_("IDS_TASK_BODY_MY_TASK");
747 error = calendar_record_get_str_p(calendar, _calendar_book.name, &str);
748 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_str() is failed(%x)", error);
751 snprintf(buf, sz, "%s", str);
753 error = calendar_record_destroy(calendar, true);
754 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_destroy() is failed(%x)", error);
757 static void __cal_detail_ug_update_saveto_language(Evas_Object *item, calendar_record_h record)
761 elm_object_part_text_set(item, "elm.text.1", C_("IDS_ST_BODY_SAVE_TO"));
763 char calendar_name[128] = {0};
765 __cal_detail_get_save_to_text(_calendar_get_calendar_index(record), calendar_name, sizeof(calendar_name));
767 elm_object_part_text_set(item, "elm.text.2", calendar_name);
770 static Evas_Object * __cal_detail_ug_add_save_to(Evas_Object *box, calendar_record_h record)
774 c_retv_if(!box, NULL);
775 c_retv_if(!record, NULL);
777 Evas_Object *item = cal_dialogue_append_item(box, "2text", NULL, NULL);
779 __cal_detail_ug_update_saveto_language(item, record);
784 static void __cal_detail_ug_add_dialogue_item(cal_detail_ug_data *data)
788 Evas_Object *dialogue = data->dialogue;
790 calendar_record_h record = data->record;
792 calendar_record_h instance = data->instance;
794 Evas_Object *box = cal_dialogue_get_box(dialogue);
796 data->title = __cal_detail_ug_add_title(box, record);
801 if (!_calendar_is_task_record(instance)) {
802 data->from = __cal_detail_ug_add_start_time(box, instance);
804 data->to = __cal_detail_ug_add_end_time(box, instance);
806 data->due = __cal_detail_ug_add_due_time(box, instance);
808 data->reminder = __cal_detail_ug_add_reminder(box, record);
810 if (!_calendar_is_task_record(record))
811 data->recurrence = __cal_detail_ug_add_recurrence(box, record);
813 data->note = __cal_detail_ug_add_note(box, record);
815 if (_calendar_is_eas_record(record)) {
816 if (!_calendar_is_task_record(record))
817 data->attendee = __cal_detail_ug_add_attendee(box, record, data);
821 data->save_to = __cal_detail_ug_add_save_to(box, record);
824 static Evas_Object * __cal_detail_ug_create_dialogue(cal_detail_ug_data *data)
828 c_retv_if(!data, NULL);
830 Evas_Object *parent = data->naviframe;
832 Evas_Object *dialogue = cal_dialogue_create(parent);
834 data->dialogue = dialogue;
836 __cal_detail_ug_add_dialogue_item(data);
841 static void inline __cal_detail_ug_clone_record(const calendar_record_h source_record, calendar_record_h *target_record)
845 c_ret_if(!source_record);
846 c_ret_if(!target_record);
848 calendar_error_e error = CALENDAR_ERROR_NONE;
850 error = calendar_record_clone(source_record, target_record);
851 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_clone() is failed(%x)", error);
854 static inline void __cal_detail_ug_update_record(calendar_record_h *record)
856 calendar_error_e error = CALENDAR_ERROR_NONE;
858 int record_index = _calendar_get_record_index(*record);
859 c_ret_if(record_index < 0);
861 error = calendar_record_destroy(*record, true);
862 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_destroy() is failed(%x)", error);
864 *record = _calendar_get_record_with_index(record_index);
867 static void __cal_detail_update_view(const char* view_uri, void* user_data)
871 c_ret_if(!user_data);
873 cal_detail_ug_data *data = user_data;
875 __cal_detail_ug_update_record(&data->record);
877 Evas_Object *dialogue = data->dialogue;
879 cal_dialogue_delete_all_items(dialogue);
881 __cal_detail_ug_add_dialogue_item(data);
884 static void __cal_detail_remove_db_changed_callback(cal_detail_ug_data *data)
890 calendar_error_e error = CALENDAR_ERROR_NONE;
892 error = calendar_db_remove_changed_cb(_calendar_event._uri, __cal_detail_update_view, data);
893 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_db_remove_changed_cb() is failed(%x)", error);
895 error = calendar_db_remove_changed_cb(_calendar_todo._uri, __cal_detail_update_view, data);
896 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_db_remove_changed_cb() is failed(%x)", error);
899 static void __cal_detail_add_db_changed_callback(cal_detail_ug_data *data)
905 calendar_error_e error = CALENDAR_ERROR_NONE;
907 error = calendar_db_add_changed_cb(_calendar_event._uri, __cal_detail_update_view, data);
908 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_db_remove_changed_cb() is failed(%x)", error);
910 error = calendar_db_add_changed_cb(_calendar_todo._uri, __cal_detail_update_view, data);
911 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_db_remove_changed_cb() is failed(%x)", error);
914 static void __cal_detail_ug_edit_ug_result_callback(ui_gadget_h ug, service_h result, void *priv)
921 int record_index = 0;
922 long long int base_time = 0;
926 int ret = service_get_extra_data(result, "record_index", &value);
927 c_warn_if(ret != SERVICE_ERROR_NONE, "service_get_extra_data() is failed(%x)", ret);
929 if (CAL_STRLEN(value))
930 record_index = atoi(value);
934 ret = service_get_extra_data(result, "base_time", &value);
935 c_warn_if(ret != SERVICE_ERROR_NONE, "service_get_extra_data() is failed(%x)", ret);
937 base_time = strtoll(value, NULL, 10);
941 cal_detail_ug_data *data = priv;
943 calendar_error_e error = calendar_record_destroy(data->record, true);
944 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_destroy() is failed(%x)", error);
946 data->record = _calendar_get_record_with_index(record_index);
948 if (data->instance) {
949 error = calendar_record_destroy(data->instance, true);
950 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_destroy() is failed(%x)", error);
952 data->instance = NULL;
955 if(!_calendar_is_task_record(data->record))
957 struct tm tm_start = {0};
959 cal_util_convert_lli_to_tm(NULL, base_time, &tm_start);
961 struct tm tm_end = tm_start;
963 cal_util_update_tm_day(&tm_end, 1);
965 data->instance = _calendar_get_instance_from_record(data->record, &tm_start, &tm_end);
966 c_ret_if(!data->instance);
969 Evas_Object *dialogue = data->dialogue;
971 cal_dialogue_delete_all_items(dialogue);
973 __cal_detail_ug_add_dialogue_item(data);
975 __cal_detail_add_db_changed_callback(data);
978 static void __cal_detail_ug_edit_ug_destroy_callback(ui_gadget_h ug, void *priv)
984 cal_detail_ug_data *data = priv;
986 Evas_Object *edit_button = elm_object_item_part_content_get(data->navi_item, "toolbar_button1");
987 if(elm_object_disabled_get(edit_button))
988 elm_object_disabled_set(edit_button, EINA_FALSE);
993 static void __cal_detail_launch_edit_ug(cal_detail_ug_data *data, calendar_record_h record)
997 calendar_record_h cloned_record = NULL;
999 __cal_detail_ug_clone_record(record, &cloned_record);
1001 char record_address[16] = {0};
1003 snprintf(record_address, sizeof(record_address), "%p", (void *)cloned_record);
1005 struct ug_cbs cbs = {0};
1007 cbs.result_cb = __cal_detail_ug_edit_ug_result_callback;
1008 cbs.destroy_cb = __cal_detail_ug_edit_ug_destroy_callback;
1011 cal_launch_ug_with_var(data->ug, "calendar-edit-efl", &cbs, "record", record_address, NULL);
1013 __cal_detail_remove_db_changed_callback(data);
1016 static void __cal_detail_event_edit_popup_response_callback(void *user_data, Evas_Object *obj, void *event_info)
1018 c_ret_if(!user_data);
1021 Evas_Object *popup = user_data;
1022 Evas_Object *button = obj;
1024 cal_detail_ug_data *data = evas_object_data_get(popup, "data");
1026 if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_BODY_ONLY_THIS_EVENT")))
1027 __cal_detail_launch_edit_ug(data, data->instance);
1028 else if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"))
1029 || !strcmp(elm_object_text_get(button), S_("IDS_COM_SK_OK")))
1030 __cal_detail_launch_edit_ug(data, data->record);
1032 evas_object_del(popup);
1035 static void __cal_detail_edit_button_callback(void *user_data, Evas_Object *obj, void *ei)
1039 c_ret_if(!user_data);
1041 cal_detail_ug_data *data = user_data;
1043 calendar_record_h record = data->record;
1045 if (_calendar_is_recurrent_record(record)) {
1046 cal_util_add_popup(data->window, "verticalbuttonstyle", NULL, C_("IDS_CLD_HEADER_EDIT_EVENT"), __cal_detail_event_edit_popup_response_callback, data,
1047 C_("IDS_CLD_BODY_ONLY_THIS_EVENT"), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"),
1048 S_("IDS_COM_SK_CANCEL"), NULL);
1050 __cal_detail_launch_edit_ug(data, record);
1051 elm_object_disabled_set(obj, EINA_TRUE);
1055 static void __cal_detail_save_button_callback(void *user_data, Evas_Object *obj, void *ei)
1059 c_ret_if(!user_data);
1061 cal_detail_ug_data *data = user_data;
1063 calendar_record_h record = data->record;
1065 calendar_error_e error = CALENDAR_ERROR_NONE;
1067 error = calendar_db_insert_record(record, NULL);
1068 if (error != CALENDAR_ERROR_NONE) {
1069 ERR("calendar_db_insert_record() is failed(%x)", error);
1073 static void __cal_detail_delete_event(cal_detail_ug_data *data, Eina_Bool is_delete_all)
1079 calendar_record_h record = data->record;
1082 _calendar_delete_recurrence_instance(data->instance);
1084 _calendar_delete_record(record);
1086 ug_destroy_me(data->ug);
1089 static void __cal_detail_delete_popup_response_event_callback(void *user_data, Evas_Object *obj, void *event_info)
1091 c_ret_if(!user_data);
1094 Evas_Object *popup = user_data;
1095 Evas_Object *button = obj;
1097 cal_detail_ug_data *data = evas_object_data_get(popup, "data");
1100 if (NULL != strstr(elm_object_text_get(button), S_("IDS_COM_BODY_DELETE")))
1101 __cal_detail_delete_event(data, EINA_TRUE);
1102 else if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_BODY_ONLY_THIS_EVENT")))
1103 __cal_detail_delete_event(data, EINA_FALSE);
1104 else if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS")))
1105 __cal_detail_delete_event(data, EINA_TRUE);
1107 evas_object_del(popup);
1110 static inline void __cal_detail_show_task_delete_popup(cal_detail_ug_data *data, calendar_record_h record)
1114 cal_util_add_popup(data->window, NULL, NULL, S_("IDS_COM_POP_DELETE_Q"), __cal_detail_delete_popup_response_event_callback, data,
1115 S_("IDS_COM_BODY_DELETE"), S_("IDS_COM_SK_CANCEL"), NULL);
1118 static inline void __cal_detail_show_event_delete_popup(cal_detail_ug_data *data, calendar_record_h record)
1122 if (_calendar_is_recurrent_record(record)) {
1123 cal_util_add_popup(data->window, "verticalbuttonstyle", NULL, C_("IDS_CLD_OPT_DELETE_EVENT"), __cal_detail_delete_popup_response_event_callback, data,
1124 C_("IDS_CLD_BODY_ONLY_THIS_EVENT"), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"),S_("IDS_COM_SK_CANCEL"), NULL);
1127 cal_util_add_popup(data->window, NULL, NULL, S_("IDS_COM_POP_DELETE_Q"), __cal_detail_delete_popup_response_event_callback, data,
1128 S_("IDS_COM_BODY_DELETE"), S_("IDS_COM_SK_CANCEL"), NULL);
1132 static void __cal_detail_delete_button_callback(void *user_data, Evas_Object *obj, void *ei)
1136 c_ret_if(!user_data);
1139 cal_detail_ug_data *data = user_data;
1141 Evas_Object *ctx_popup = obj;
1143 calendar_record_h record = data->record;
1146 evas_object_del(ctx_popup);
1148 if (_calendar_is_task_record(record))
1149 __cal_detail_show_task_delete_popup(data, record);
1151 __cal_detail_show_event_delete_popup(data, record);
1154 static void __cal_detail_share_popup_hide_callback(void *data, Evas_Object *obj, void *event_info)
1158 Evas_Object *popup = data;
1160 evas_object_del(popup);
1163 static void __cal_detail_via_message_callback(void *user_data, Evas_Object *obj, void *ei)
1165 c_ret_if(!user_data);
1168 cal_detail_ug_data *data = user_data;
1170 _calendar_export_record_to_vcs(data->record, CAL_MESSAGE_VCS);
1172 cal_launch_ug_with_var(data->ug, CAL_MESSAGE_COMPOSER_UG, NULL, "ATTACHFILE", CAL_MESSAGE_VCS, NULL);
1174 evas_object_del(obj);
1177 static void __cal_detail_via_email_callback(void *user_data, Evas_Object *obj, void *ei)
1179 c_ret_if(!user_data);
1182 cal_detail_ug_data *data = user_data;
1184 _calendar_export_record_to_vcs(data->record, CAL_EMAIL_VCS);
1186 cal_launch_ug_with_var(data->ug, CAL_EMAIL_COMPOSER_UG, (struct ug_cbs *)data, "RUN_TYPE", "5", "ATTACHMENT", CAL_EMAIL_VCS, NULL);
1188 evas_object_del(obj);
1191 static void __cal_detail_via_bluetooth_callback(void *user_data, Evas_Object *obj, void *ei)
1193 c_ret_if(!user_data);
1196 cal_detail_ug_data *data = user_data;
1198 _calendar_export_record_to_vcs(data->record, CAL_BLUETOOTH_VCS);
1200 cal_launch_ug_with_var(data->ug, CAL_BLUETOOTH_UG, NULL, "launch-type", "send", "filecount", "1", "files", CAL_BLUETOOTH_VCS, NULL);
1202 evas_object_del(obj);
1205 static void __cal_detail_share_button_callback(void *user_data, Evas_Object *obj, void *ei)
1207 c_ret_if(!user_data);
1210 cal_detail_ug_data *data = user_data;
1212 Evas_Object *ctx_popup = obj;
1214 evas_object_del(ctx_popup);
1216 Evas_Object *popup = cal_util_add_popup(data->window, NULL, S_("IDS_COM_BUTTON_SHARE"), NULL, __cal_detail_share_popup_hide_callback, data, S_("IDS_COM_BODY_CLOSE"), NULL);
1219 evas_object_data_set(popup, "priv", data);
1221 Elm_Object_Item *popup_item = elm_popup_item_append(popup, S_("IDS_COM_BODY_MESSAGE"), NULL, __cal_detail_via_message_callback, data);
1222 c_ret_if(!popup_item);
1224 popup_item = elm_popup_item_append(popup, S_("IDS_COM_BODY_EMAIL"), NULL, __cal_detail_via_email_callback, data);
1225 c_ret_if(!popup_item);
1227 popup_item = elm_popup_item_append(popup, S_("IDS_COM_BODY_BLUETOOTH"), NULL, __cal_detail_via_bluetooth_callback, data);
1228 c_ret_if(!popup_item);
1231 static void __cal_detail_more_button_callback(void *user_data, Evas_Object *obj, void *event_info)
1233 c_ret_if(!user_data);
1236 cal_detail_ug_data *data = user_data;
1238 Evas_Object *ctx_popup = elm_ctxpopup_add(data->naviframe);
1239 c_ret_if(!ctx_popup);
1241 elm_ctxpopup_direction_priority_set(ctx_popup, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP);
1243 Elm_Object_Item *item = NULL;
1245 item = elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BODY_DELETE"), NULL, __cal_detail_delete_button_callback, data);
1248 item = elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BUTTON_SHARE"), NULL, __cal_detail_share_button_callback, data);
1251 Evas_Coord_Rectangle r = {0};
1253 cal_util_get_geometry(&r, obj);
1255 evas_object_move(ctx_popup, r.x + r.w/2, r.y + r.h/2);
1257 evas_object_show(ctx_popup);
1260 static Evas_Object *__cal_detail_ug_create_layout(Evas_Object *parent, cal_detail_ug_data *data)
1264 c_retv_if(!parent, NULL);
1265 c_retv_if(!data, NULL);
1267 Evas_Object *base_layout = cal_util_add_layout(parent, NULL);
1268 c_retv_if(!base_layout, NULL);
1270 Evas_Object *naviframe = elm_naviframe_add(base_layout);
1272 ERR("elm_naviframe_add() is failed");
1274 evas_object_del(base_layout);
1279 evas_object_show(naviframe);
1281 Evas_Object *bg = cal_util_add_bg(base_layout, EINA_FALSE);
1283 ERR("cal_util_add_bg() is failed");
1285 evas_object_del(base_layout);
1290 data->base_layout = base_layout;
1291 data->naviframe = naviframe;
1293 cal_util_initialize_timezone();
1295 Evas_Object *dialogue = __cal_detail_ug_create_dialogue(data);
1297 Evas_Object *back_button = __cal_detail_ug_add_back_button(data);
1299 Elm_Object_Item *item = NULL;
1301 if (_calendar_is_task_record(data->record))
1302 item = elm_naviframe_item_push(naviframe, C_("IDS_CLD_BODY_TASK_DETAILS"), back_button, NULL, dialogue, NULL);
1304 item = elm_naviframe_item_push(naviframe, C_("IDS_CLD_BODY_EVENT_DETAILS"), back_button, NULL, dialogue, NULL);
1305 c_warn_if(!item, "elm_naviframe_item_push() is failed");
1306 data->navi_item = item;
1308 cal_util_add_toolbar_button(naviframe, "toolbar_button1", S_("IDS_COM_BODY_EDIT"), __cal_detail_edit_button_callback, data);
1310 if (0 < _calendar_get_record_index(data->record)) {
1312 Evas_Object *more_button = cal_util_add_toolbar_button(naviframe, "toolbar_more_btn", NULL, __cal_detail_more_button_callback, data);
1313 elm_object_style_set(more_button, "naviframe/more/default");
1315 cal_util_add_toolbar_button(naviframe, "toolbar_button1", S_("IDS_COM_OPT_SAVE"), __cal_detail_save_button_callback, data);
1318 elm_object_part_content_set(base_layout, "elm.swallow.content", naviframe);
1319 elm_object_part_content_set(base_layout, "elm.swallow.bg", bg);
1325 static calendar_record_h inline __cal_detail_ug_get_origin_record(const calendar_record_h instance)
1329 c_retv_if(!instance, NULL);
1331 int index = _calendar_get_record_index(instance);
1333 return _calendar_get_record_with_index(index);
1336 static void *__cal_detail_ug_create_callback(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv)
1340 c_retv_if(!ug, NULL);
1341 c_retv_if(!service, NULL);
1342 c_retv_if(!priv, NULL);
1343 c_retv_if(mode != UG_MODE_FULLVIEW, NULL);
1345 cal_detail_ug_data *data = priv;
1350 char *item_type = NULL;
1353 calendar_error_e error = CALENDAR_ERROR_NONE;
1355 int r = service_get_extra_data(service, "index", &index);
1356 if (r == SERVICE_ERROR_NONE)
1359 r = service_get_extra_data(service, CAL_APPCONTROL_ITEM_TYPE, &item_type);
1360 if (r == SERVICE_ERROR_NONE) {
1362 if (!CAL_STRCMP(item_type, CAL_APPCONTROL_ITEM_TYPE_EVENT)) {
1364 r = service_get_extra_data(service, CAL_APPCONTROL_EVENT_ID, &index);
1365 if (r != SERVICE_ERROR_NONE) {
1366 ERR("service_get_extra_data(%s) is failed(%x)", CAL_APPCONTROL_EVENT_ID, r);
1376 calendar_record_h record = _calendar_get_record_with_index(cid);
1377 c_retv_if(!record, NULL);
1379 calendar_record_destroy(record, true);
1381 } else if (!CAL_STRCMP(item_type, CAL_APPCONTROL_ITEM_TYPE_TODO)) {
1383 r = service_get_extra_data(service, CAL_APPCONTROL_TODO_ID, &index);
1384 if (r != SERVICE_ERROR_NONE) {
1385 ERR("service_get_extra_data(%s) is failed(%x)", CAL_APPCONTROL_TODO_ID, r);
1395 calendar_record_h record = _calendar_get_record_with_index(cid);
1396 c_retv_if(!record, NULL);
1398 calendar_record_destroy(record, true);
1400 } else if (!CAL_STRCMP(item_type, CAL_APPCONTROL_ITEM_TYPE_VCS)) {
1402 r = service_get_extra_data(service, CAL_APPCONTROL_VCS_PATH, &path);
1403 if (r != SERVICE_ERROR_NONE) {
1404 ERR("service_get_extra_data(%s) is failed(%x)", CAL_APPCONTROL_VCS_PATH, r);
1413 FILE * file = fopen(path, "r");
1415 ERR("fopen(%s) is failed.", path);
1423 r = stat(path, &st);
1424 c_warn_if(r == -1, "stat(%s) is failed(%d)", path, errno);
1426 int size = st.st_size;
1427 char *raw_data = calloc(size + 1, sizeof(char));
1429 ERR("calloc is failed.");
1438 r = fread(raw_data, 1, size, file);
1440 c_retv_if(r < 0, NULL);
1442 calendar_list_h list = NULL;
1444 error = calendar_vcalendar_parse_to_calendar(raw_data, &list);
1445 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_vcalendar_parse_to_calendar() is failed(%x)", error);
1448 calendar_record_h record = NULL;
1449 error = calendar_list_get_current_record_p(list, &record);
1450 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_list_get_current_record_p() is failed(%x)", error);
1452 error = calendar_record_clone(record, &data->record);
1453 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_clone() is failed(%x)", error);
1455 error = calendar_list_destroy(list, true);
1462 if (!data->record) {
1464 data->record = _calendar_get_record_with_index(cid);
1466 char *record_address = NULL;
1468 r = service_get_extra_data(service, "record", &record_address);
1469 if (r != SERVICE_ERROR_NONE) {
1470 ERR("service_get_extra_data(record) is failed(%x)", r);
1472 data->record = (calendar_record_h)strtoul(record_address, NULL, 16);
1473 c_warn_if(!data->record, "strtol(%s, NULL, 16) is failed", record_address);
1476 _calendar_record_type record_type = _calendar_get_record_type(data->record);
1478 if (record_type != _CALENDAR_RECORD_TYPE_EVENT && record_type != _CALENDAR_RECORD_TYPE_TODO) {
1479 data->instance = data->record;
1480 data->record = __cal_detail_ug_get_origin_record(data->instance);
1483 CAL_FREE(record_address);
1488 CAL_FREE(item_type);
1494 Evas_Object *parent = ug_get_parent_layout(ug);
1495 c_retv_if(!parent, NULL);
1497 data->window = ug_get_window();
1498 c_retv_if(!data->window, NULL);
1500 elm_theme_extension_add(NULL, "/usr/apps/"CALENDAR_PACKAGE"/res/edje/theme.edj");
1502 Evas_Object *base = __cal_detail_ug_create_layout(parent, data);
1503 c_retv_if(!base, NULL);
1505 __cal_detail_add_db_changed_callback(data);
1510 static void __cal_detail_ug_destroy_callback(ui_gadget_h ug, service_h service, void *priv)
1516 cal_detail_ug_data *data = priv;
1518 __cal_detail_remove_db_changed_callback(data);
1520 if (data->mouse_down_event_handler)
1521 ecore_event_handler_del(data->mouse_down_event_handler);
1523 cal_util_delete_evas_object(&data->base_layout);
1526 static void __cal_detail_ug_key_callback(ui_gadget_h ug, enum ug_key_event evt, service_h data, void *priv)
1531 case UG_KEY_EVENT_END:
1539 static void __cal_detail_ug_update_button_language(Evas_Object *naviframe, calendar_record_h record)
1541 c_ret_if(!naviframe);
1543 Elm_Object_Item *item = elm_naviframe_top_item_get(naviframe);
1546 Evas_Object *button = elm_object_item_part_content_get(item, "toolbar_button1");
1549 elm_object_text_set(button, S_("IDS_COM_BODY_EDIT"));
1551 if (_calendar_get_record_index(record) <= 0)
1552 elm_object_text_set(button, S_("IDS_COM_OPT_SAVE"));
1555 static void __cal_detail_ug_update_language(cal_detail_ug_data *data)
1558 c_ret_if(!data->record);
1562 calendar_record_h record = data->record;
1564 __cal_detail_ug_update_title_language(data->title, record);
1566 Eina_Bool is_task_record = _calendar_is_task_record(record);
1568 if (!is_task_record) {
1570 __cal_detail_ug_update_from_language(data->from);
1572 __cal_detail_ug_update_to_language(data->to);
1575 __cal_detail_ug_update_due_language(data->due);
1577 __cal_detail_ug_update_reminder_language(data->reminder, record);
1579 if (!is_task_record)
1580 __cal_detail_ug_update_recurrence_language(data->recurrence, record);
1582 __cal_detail_ug_update_saveto_language(data->save_to, record);
1586 static void __cal_detail_ug_update_region(cal_detail_ug_data *data)
1589 c_ret_if(!data->record);
1591 calendar_record_h record = data->record;
1593 if (!_calendar_is_task_record(data->record)) {
1595 __cal_detail_ug_update_from_region(data->from, record);
1597 __cal_detail_ug_update_to_region(data->to, record);
1600 __cal_detail_ug_update_due_region(data->to, record);
1603 static void __cal_detail_ug_event_callback(ui_gadget_h ug, enum ug_event event, service_h service, void *priv)
1609 case UG_EVENT_LANG_CHANGE:
1610 __cal_detail_ug_update_language((cal_detail_ug_data *)priv);
1612 case UG_EVENT_REGION_CHANGE:
1613 __cal_detail_ug_update_region((cal_detail_ug_data *)priv);
1616 case UG_EVENT_ROTATE_PORTRAIT:
1617 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
1619 case UG_EVENT_ROTATE_LANDSCAPE:
1620 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
1628 API int UG_MODULE_INIT(struct ug_module_ops *ops)
1632 c_retv_if(!ops, -1);
1634 cal_detail_ug_data *data = calloc(1, sizeof(cal_detail_ug_data));
1636 ops->create = __cal_detail_ug_create_callback;
1637 ops->destroy = __cal_detail_ug_destroy_callback;
1638 ops->key_event = __cal_detail_ug_key_callback;
1639 ops->event = __cal_detail_ug_event_callback;
1641 ops->opt = UG_OPT_INDICATOR_PORTRAIT_ONLY;
1643 const char *path = bindtextdomain(CALENDAR, LOCALEDIR);
1644 c_warn_if(!path, "bindtextdomain(%s, %s) is failed.", CALENDAR, LOCALEDIR);
1646 __cal_detail_ug_initialize(data);
1651 API void UG_MODULE_EXIT(struct ug_module_ops *ops)
1657 __cal_detail_ug_finish();
1659 cal_detail_ug_data *data = ops->priv;