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"
28 #include "appcontrol.h"
34 Evas_Object *base_layout;
35 Evas_Object *naviframe;
37 Evas_Object *dialogue;
39 Elm_Object_Item *navi_item;
41 calendar_record_h instance;
42 calendar_record_h record;
44 Ecore_Event_Handler *mouse_down_event_handler;
45 Evas_Coord mouse_down_x;
46 Evas_Coord mouse_down_y;
52 Evas_Object *reminder;
53 Evas_Object *recurrence;
55 Evas_Object *attendee;
56 Evas_Object *show_me_as;
62 #define CAL_URI_FILE_FORMAT "file://"
64 static int __cal_detail_ug_initialize(cal_detail_ug_data *data)
68 calendar_error_e error = CALENDAR_ERROR_NONE;
70 error = calendar_connect();
71 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_connect() is failed(%x)", error);
73 _calendar_init_hash();
75 const char *path = bindtextdomain(CALENDAR, LOCALEDIR);
76 c_warn_if(!path, "bindtextdomain(%s, %s) is failed.", CALENDAR, LOCALEDIR);
78 cal_util_connect_pattern_generator();
83 static void __cal_detail_ug_finish()
87 calendar_error_e error = CALENDAR_ERROR_NONE;
89 error = calendar_disconnect();
90 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_disconnect() is failed(%x)", error);
92 elm_theme_extension_del(NULL, EDJDIR "/calendar_theme.edj");
94 cal_util_disconnect_pattern_generator();
97 static void __cal_detail_ug_back_button_callback(void *user_data, Evas_Object *obj, void *ei)
101 c_ret_if(!user_data);
103 cal_detail_ug_data *data = user_data;
107 ug_destroy_me(data->ug);
110 static Evas_Object * __cal_detail_ug_add_back_button(cal_detail_ug_data *data)
114 Evas_Object *back_button = elm_button_add(data->naviframe);
115 c_retv_if(!back_button, NULL);
117 evas_object_smart_callback_add(back_button, "clicked", __cal_detail_ug_back_button_callback, data);
119 elm_object_style_set(back_button, "naviframe/end_btn/default");
124 static void __cal_detail_ug_update_title_language(Evas_Object *item, calendar_record_h record)
128 char *summary = _calendar_get_summary(record);
130 elm_object_part_text_set(item, "elm.text.1", summary);
135 static Evas_Object * __cal_detail_ug_add_title(Evas_Object *box, calendar_record_h record)
139 c_retv_if(!box, NULL);
140 c_retv_if(!record, NULL);
142 Evas_Object *item = cal_dialogue_append_item(box, "2text", NULL, NULL);
144 __cal_detail_ug_update_title_language(item, record);
146 char *location = _calendar_get_location(record);
148 elm_object_part_text_set(item, "elm.text.2", location);
155 static void __cal_detail_ug_update_from_language(Evas_Object *item)
159 elm_object_part_text_set(item, "elm.text.1", C_("IDS_CLD_BODY_FROM"));
162 static void __cal_detail_ug_update_from_region(Evas_Object *item, calendar_record_h record)
166 const char *time_format = NULL;
168 if (!_calendar_is_allday_record(record)) {
170 time_format = CAL_UTIL_TIME_FORMAT_6;
172 time_format = CAL_UTIL_TIME_FORMAT_1;
175 calendar_time_s time = {0};
177 _calendar_get_start_time(record, &time);
179 char *from_time = _calendar_get_time_str(&time, CAL_UTIL_DATE_FORMAT_1, time_format);
181 elm_object_part_text_set(item, "elm.text.2", from_time);
186 static Evas_Object * __cal_detail_ug_add_start_time(Evas_Object *box, calendar_record_h record)
190 c_retv_if(!box, NULL);
191 c_retv_if(!record, NULL);
193 Evas_Object *item = cal_dialogue_append_item(box, "2text", NULL, NULL);
195 __cal_detail_ug_update_from_language(item);
197 __cal_detail_ug_update_from_region(item, record);
202 static void __cal_detail_ug_update_to_language(Evas_Object *item)
206 elm_object_part_text_set(item, "elm.text.1", C_("IDS_CLD_BODY_TO"));
209 static void __cal_detail_ug_update_to_region(Evas_Object *item, calendar_record_h record)
213 const char *time_format = NULL;
215 if (!_calendar_is_allday_record(record)) {
217 time_format = CAL_UTIL_TIME_FORMAT_6;
219 time_format = CAL_UTIL_TIME_FORMAT_1;
222 calendar_time_s time = {0};
224 _calendar_get_end_time(record, &time);
226 char *to_time = _calendar_get_time_str(&time, CAL_UTIL_DATE_FORMAT_1, time_format);
228 elm_object_part_text_set(item, "elm.text.2", to_time);
233 static Evas_Object * __cal_detail_ug_add_end_time(Evas_Object *box, calendar_record_h record)
237 c_retv_if(!box, NULL);
238 c_retv_if(!record, NULL);
240 Evas_Object *item = cal_dialogue_append_item(box, "2text", NULL, NULL);
242 __cal_detail_ug_update_to_language(item);
244 __cal_detail_ug_update_to_region(item, record);
249 static void __cal_detail_ug_update_due_language(Evas_Object *item)
253 elm_object_part_text_set(item, "elm.text.1", C_("IDS_CLD_BODY_DUE_DATE"));
256 static void __cal_detail_ug_update_due_region(Evas_Object *item, calendar_record_h record)
260 const char *time_format = NULL;
262 if (!_calendar_is_allday_record(record)) {
264 time_format = CAL_UTIL_TIME_FORMAT_6;
266 time_format = CAL_UTIL_TIME_FORMAT_1;
269 calendar_time_s due_time = {0};
271 _calendar_get_end_time(record, &due_time);
273 if (due_time.time.utime == CALENDAR_TODO_NO_DUE_DATE) {
274 elm_object_part_text_set(item, "elm.text.1", C_("IDS_CLD_BODY_NO_DUE_DATE_M_NOUN"));
278 char *due_time_text = _calendar_get_time_str(&due_time, CAL_UTIL_DATE_FORMAT_1, time_format);
280 elm_object_part_text_set(item, "elm.text.2", due_time_text);
286 static Evas_Object * __cal_detail_ug_add_due_time(Evas_Object *box, calendar_record_h record)
290 c_retv_if(!box, NULL);
291 c_retv_if(!record, NULL);
293 Evas_Object *item = cal_dialogue_append_item(box, "2text", NULL, NULL);
295 __cal_detail_ug_update_due_language(item);
297 __cal_detail_ug_update_due_region(item, record);
302 static char * __cal_detail_ug_get_recurrence_text(calendar_record_h record)
306 c_retv_if(!record, NULL);
308 calendar_error_e error = CALENDAR_ERROR_NONE;
312 error = calendar_record_get_int(record, _calendar_event.freq, &freq);
313 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
317 error = calendar_record_get_int(record, _calendar_event.interval, &interval);
318 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
320 if (freq == CALENDAR_RECURRENCE_WEEKLY) {
322 freq = CAL_REPEAT_EVERY_2_WEEK;
324 } else if (freq == CALENDAR_RECURRENCE_DAILY) {
326 freq = CAL_REPEAT_EVERY_3_DAY;
331 _calendar_get_recurrence_frequency_str(freq, buf, sizeof(buf));
336 static GList * __cal_detail_ug_get_reminder_list(calendar_record_h record)
340 c_retv_if(!record, NULL);
342 GList *reminder_list = NULL;
344 int reminder_count = 0;
345 calendar_error_e error = CALENDAR_ERROR_NONE;
347 if (_calendar_is_task_record(record))
348 error = calendar_record_get_child_record_count(record, _calendar_todo.calendar_alarm, (unsigned int *)&reminder_count);
350 error = calendar_record_get_child_record_count(record, _calendar_event.calendar_alarm, (unsigned int *)&reminder_count);
352 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_count() is failed(%x)", error);
355 for (i = 0; i < reminder_count; i++) {
356 calendar_record_h calendar_alarm = NULL;
358 if (_calendar_is_task_record(record))
359 error = calendar_record_get_child_record_at_p(record, _calendar_todo.calendar_alarm, i, &calendar_alarm);
361 error = calendar_record_get_child_record_at_p(record, _calendar_event.calendar_alarm, i, &calendar_alarm);
363 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_at_p() is failed(%x)", error);
365 Cal_Reminder* reminder = cal_reminder_create(calendar_alarm);
366 reminder_list = g_list_append(reminder_list, (void *)reminder);
370 reminder_list = g_list_first(reminder_list);
372 return reminder_list;
375 static void __cal_detail_ug_update_reminder_language(Evas_Object *item, calendar_record_h record)
379 elm_object_part_text_set(item, "elm.text.1", C_("IDS_CLD_BODY_REMINDER"));
381 GList *reminder_list = __cal_detail_ug_get_reminder_list(record);
384 char reminder_text[50] = {0};
386 cal_reminder_get_string(reminder_list->data, reminder_text, sizeof(reminder_text));
388 elm_object_part_text_set(item, "elm.text.2", reminder_text);
390 g_list_free(reminder_list);
392 elm_object_part_text_set(item, "elm.text.2", S_("IDS_COM_BODY_OFF"));
395 static Evas_Object * __cal_detail_ug_add_reminder(Evas_Object *box, calendar_record_h record)
399 c_retv_if(!box, NULL);
400 c_retv_if(!record, NULL);
402 Evas_Object *item = cal_dialogue_append_item(box, "2text", NULL, NULL);
404 __cal_detail_ug_update_reminder_language(item, record);
409 static void __cal_detail_ug_update_recurrence_language(Evas_Object *item, calendar_record_h record)
413 char *recurrence = __cal_detail_ug_get_recurrence_text(record);
415 elm_object_part_text_set(item, "elm.text.1", C_("IDS_CLD_BODY_REPEAT"));
416 elm_object_part_text_set(item, "elm.text.2", recurrence);
421 static Evas_Object * __cal_detail_ug_add_recurrence(Evas_Object *box, calendar_record_h record)
425 c_retv_if(!box, NULL);
426 c_retv_if(!record, NULL);
428 Evas_Object *item = cal_dialogue_append_item(box, "2text", NULL, NULL);
430 __cal_detail_ug_update_recurrence_language(item, record);
435 static inline char* __cal_detail_get_note_text(calendar_record_h record)
437 c_retv_if(!record, NULL);
441 calendar_error_e error = CALENDAR_ERROR_NONE;
443 if (_calendar_is_task_record(record))
444 error = calendar_record_get_str_p(record, _calendar_todo.description, ¬e);
446 error = calendar_record_get_str_p(record, _calendar_event.description, ¬e);
448 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_str() is failed(%x)", error);
453 static Evas_Object * __cal_detail_ug_add_note(Evas_Object *box, calendar_record_h record)
457 c_retv_if(!box, NULL);
458 c_retv_if(!record, NULL);
460 char *note = __cal_detail_get_note_text(record);
462 if (!CAL_STRLEN(note))
465 Evas_Object *item = cal_dialogue_append_item(box, "1icon", NULL, NULL);
467 Evas_Object *edit_field = cal_util_add_edit_field(item, NULL, NULL, EINA_FALSE, EINA_FALSE, EINA_TRUE);
470 ERR("cal_util_add_edit_field() is failed.");
472 evas_object_del(item);
477 Evas_Object *entry = elm_object_part_content_get(edit_field, "elm.swallow.content");
479 ERR("cal_util_add_edit_field() is failed.");
481 evas_object_del(item);
486 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
487 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_EXPAND);
488 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
489 elm_entry_autocapital_type_set(entry, EINA_TRUE);
491 elm_entry_entry_set(entry, note);
493 elm_object_part_content_set(item, "elm.icon", edit_field);
498 static inline void __cal_detail_append_multibutton_entry_item(Evas_Object *mbe, calendar_record_h record)
500 cal_participant *part = calloc(1, sizeof(cal_participant));
505 calendar_error_e error = CALENDAR_ERROR_NONE;
506 error = calendar_record_get_str(record, _calendar_attendee.name, &name);
507 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_str() is failed(%x)", error);
508 if (!CAL_STRLEN(name)) {
509 ERR("Attendee name is NULL!!");
510 name = S_("IDS_COM_BODY_UNKNOWN");
513 part->name = CAL_STRDUP(name);
516 error = calendar_record_get_str(record, _calendar_attendee.email, &email);
517 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_str() is failed(%x)", error);
519 if (CAL_STRLEN(email))
520 part->email = strdup(email);
522 ERR("Attendee email is mandatory data!! There is no email for %s.", part->name);
524 error = calendar_record_get_int(record, _calendar_attendee.person_id, &part->person_id);
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.status, &part->status);
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.role, &part->role);
531 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
533 error = calendar_record_get_int(record, _calendar_attendee.rsvp, &part->response);
534 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
536 elm_multibuttonentry_item_append(mbe, name, NULL, part);
539 static inline void __cal_detail_set_multibutton_entry_item(Evas_Object *multibutton_entry, calendar_record_h record)
541 c_ret_if(!multibutton_entry);
544 int attendee_count = 0;
546 calendar_error_e error = CALENDAR_ERROR_NONE;
548 error = calendar_record_get_child_record_count(record, _calendar_event.calendar_attendee, (unsigned int *)&attendee_count);
549 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_count() is failed(%x)", error);
553 for (i = 0; i < attendee_count; i++) {
554 calendar_record_h calendar_attendee = NULL;
556 error = calendar_record_get_child_record_at_p(record, _calendar_event.calendar_attendee, i, &calendar_attendee);
557 if (error != CALENDAR_ERROR_NONE) {
558 ERR("calendar_record_get_child_record_at_p() is failed(%x)", error);
562 __cal_detail_append_multibutton_entry_item(multibutton_entry, calendar_attendee);
566 static void __cal_detail_popup_hide_callback(void *data, Evas_Object *obj, void *ei)
568 evas_object_del(obj);
571 static void __cal_detail_show_ctx_popup(cal_detail_ug_data *data, cal_participant *part)
576 Evas_Object *ctx_popup = elm_ctxpopup_add(data->naviframe);
577 c_ret_if(!ctx_popup);
579 int person_id = part->person_id;
580 char *name = part->name;
583 cal_detail_common_get_person_default_number(person_id, &part->number);
585 char *number = part->number;
587 evas_object_smart_callback_add(ctx_popup, "dismissed", __cal_detail_popup_hide_callback, data);
589 if (CAL_STRLEN(number)) {
590 elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BODY_VOICE_CALL"), NULL, cal_detail_common_ctx_callback_for_voice_call, number);
592 elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BODY_MESSAGE"), NULL, cal_detail_common_ctx_callback_for_message, number);
595 if (CAL_STRLEN(part->email)) {
596 elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BODY_EMAIL"), NULL, cal_detail_common_ctx_callback_for_email, part->email);
600 evas_object_smart_callback_add(ctx_popup, "dismissed", __cal_detail_popup_hide_callback, NULL);
602 elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BODY_EMAIL"), NULL, cal_detail_common_ctx_callback_for_email, name);
603 elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_OPT_ADD_TO_CONTACTS"), NULL, cal_detail_common_ctx_callback_for_contact, name);
606 evas_object_data_set(ctx_popup, "record", data->record);
607 evas_object_move(ctx_popup, data->mouse_down_x, data->mouse_down_y);
608 evas_object_show(ctx_popup);
611 static void __cal_detail_multibuttonentry_item_selected_callback(void *user_data, Evas_Object *obj, void *ei)
614 c_ret_if(!user_data);
616 Elm_Object_Item *it = ei;
617 cal_detail_ug_data *data = user_data;
619 cal_participant *part = elm_object_item_data_get(it);
622 __cal_detail_show_ctx_popup(data, part);
625 static void __cal_detail_multibuttonentry_item_deleted_callback(void *data, Evas_Object *obj, void *ei)
629 Elm_Object_Item *item = ei;
631 cal_participant *part = elm_object_item_data_get(item);
634 CAL_FREE(part->name);
639 static void __cal_detail_multibuttonentry_unfocused_callback(void *data, Evas_Object *obj, void *ei)
643 elm_multibuttonentry_item_selected_set(elm_multibuttonentry_selected_item_get(obj), EINA_FALSE);
646 static Eina_Bool __cal_detail_mouse_down_callback(void *user_data, int type, void *event)
648 c_retv_if(!user_data, ECORE_CALLBACK_RENEW);
649 c_retv_if(!event, ECORE_CALLBACK_RENEW);
651 cal_detail_ug_data *data = user_data;
653 Ecore_Event_Mouse_Button *ev= event;
656 data->mouse_down_x = ev->x;
657 data->mouse_down_y = ev->y;
659 return ECORE_CALLBACK_RENEW;
662 static Evas_Object * __cal_detail_add_multibutton_entry(Evas_Object *item, cal_detail_ug_data *data)
664 c_retv_if(!item, NULL);
665 c_retv_if(!data, NULL);
667 Evas_Object *multibutton_entry = elm_multibuttonentry_add(item);
668 c_retv_if(!multibutton_entry, NULL);
670 evas_object_size_hint_weight_set(multibutton_entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
671 evas_object_size_hint_align_set(multibutton_entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
673 evas_object_smart_callback_add(multibutton_entry, "item,selected", __cal_detail_multibuttonentry_item_selected_callback, data);
674 evas_object_smart_callback_add(multibutton_entry, "item,deleted", __cal_detail_multibuttonentry_item_deleted_callback, NULL);
675 evas_object_smart_callback_add(multibutton_entry, "unfocused", __cal_detail_multibuttonentry_unfocused_callback, NULL);
677 Evas_Object *entry = elm_multibuttonentry_entry_get(multibutton_entry);
679 elm_entry_editable_set(entry, EINA_FALSE);
681 evas_object_show(multibutton_entry);
683 if (!data->mouse_down_event_handler)
684 data->mouse_down_event_handler = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, __cal_detail_mouse_down_callback, data);
686 return multibutton_entry;
689 static void __cal_detail_attendee_status_button_callback(void *user_data, Evas_Object *obj, void *event_info)
693 c_ret_if(!user_data);
695 cal_detail_ug_data *data = user_data;
697 cal_detail_attendee_create_view(data->naviframe, data->record);
700 static Evas_Object * __cal_detail_ug_add_attendee(Evas_Object *box, calendar_record_h record, cal_detail_ug_data *data)
704 c_retv_if(!box, NULL);
705 c_retv_if(!record, NULL);
706 c_retv_if(!data, NULL);
708 int attendee_count = 0;
710 calendar_error_e error = CALENDAR_ERROR_NONE;
712 error = calendar_record_get_child_record_count(record, _calendar_event.calendar_attendee, (unsigned int *)&attendee_count);
713 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_count() is failed(%x)", error);
718 Evas_Object *item = cal_dialogue_append_item(box, "1icon", NULL, NULL);
720 Evas_Object *multibutton_entry = __cal_detail_add_multibutton_entry(item, data);
722 __cal_detail_set_multibutton_entry_item(multibutton_entry, record);
724 elm_object_part_content_set(item, "elm.icon", multibutton_entry);
726 Evas_Object *attendee_status_button = elm_button_add(item);
727 c_retv_if(!attendee_status_button, item);
729 cal_util_set_controlbar_button(attendee_status_button, NULL, "reveal/extended", __cal_detail_attendee_status_button_callback, data);
731 elm_object_part_content_set(item, "elm.icon.2", attendee_status_button);
736 static void __cal_detail_get_save_to_text(int calendar_book_id, char *buf, int sz)
739 calendar_error_e error = CALENDAR_ERROR_NONE;
740 calendar_record_h calendar = NULL;
742 error = calendar_db_get_record(_calendar_book._uri, calendar_book_id, &calendar);
743 c_ret_if(error != CALENDAR_ERROR_NONE);
745 if (calendar_book_id == DEFAULT_EVENT_CALENDAR_BOOK_ID)
746 str = C_("IDS_CLD_BODY_MY_CALENDAR");
747 else if (calendar_book_id == DEFAULT_TODO_CALENDAR_BOOK_ID)
748 str = C_("IDS_TASK_BODY_MY_TASK");
750 error = calendar_record_get_str_p(calendar, _calendar_book.name, &str);
751 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_str() is failed(%x)", error);
754 snprintf(buf, sz, "%s", str);
756 error = calendar_record_destroy(calendar, true);
757 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_destroy() is failed(%x)", error);
760 static void __cal_detail_ug_update_saveto_language(Evas_Object *item, calendar_record_h record)
764 elm_object_part_text_set(item, "elm.text.1", C_("IDS_ST_BODY_SAVE_TO"));
766 char calendar_name[128] = {0};
768 __cal_detail_get_save_to_text(_calendar_get_calendar_index(record), calendar_name, sizeof(calendar_name));
770 elm_object_part_text_set(item, "elm.text.2", calendar_name);
773 static Evas_Object * __cal_detail_ug_add_save_to(Evas_Object *box, calendar_record_h record)
777 c_retv_if(!box, NULL);
778 c_retv_if(!record, NULL);
780 Evas_Object *item = cal_dialogue_append_item(box, "2text", NULL, NULL);
782 __cal_detail_ug_update_saveto_language(item, record);
787 static void __cal_detail_ug_add_dialogue_item(cal_detail_ug_data *data)
791 Evas_Object *dialogue = data->dialogue;
793 calendar_record_h record = data->record;
795 calendar_record_h instance = data->instance;
797 Evas_Object *box = cal_dialogue_get_box(dialogue);
799 data->title = __cal_detail_ug_add_title(box, record);
804 if (!_calendar_is_task_record(instance)) {
805 data->from = __cal_detail_ug_add_start_time(box, instance);
807 data->to = __cal_detail_ug_add_end_time(box, instance);
809 data->due = __cal_detail_ug_add_due_time(box, instance);
811 data->reminder = __cal_detail_ug_add_reminder(box, record);
813 if (!_calendar_is_task_record(record))
814 data->recurrence = __cal_detail_ug_add_recurrence(box, record);
816 data->note = __cal_detail_ug_add_note(box, record);
818 if (_calendar_is_eas_record(record)) {
819 if (!_calendar_is_task_record(record))
820 data->attendee = __cal_detail_ug_add_attendee(box, record, data);
824 data->save_to = __cal_detail_ug_add_save_to(box, record);
827 static Evas_Object * __cal_detail_ug_create_dialogue(cal_detail_ug_data *data)
831 c_retv_if(!data, NULL);
833 Evas_Object *parent = data->naviframe;
835 Evas_Object *dialogue = cal_dialogue_create(parent);
837 data->dialogue = dialogue;
839 __cal_detail_ug_add_dialogue_item(data);
844 static void inline __cal_detail_ug_clone_record(const calendar_record_h source_record, calendar_record_h *target_record)
848 c_ret_if(!source_record);
849 c_ret_if(!target_record);
851 calendar_error_e error = CALENDAR_ERROR_NONE;
853 error = calendar_record_clone(source_record, target_record);
854 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_clone() is failed(%x)", error);
857 static inline void __cal_detail_ug_update_record(calendar_record_h *record)
859 calendar_error_e error = CALENDAR_ERROR_NONE;
861 int record_index = _calendar_get_record_index(*record);
862 c_ret_if(record_index < 0);
864 error = calendar_record_destroy(*record, true);
865 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_destroy() is failed(%x)", error);
867 *record = _calendar_get_record_with_index(record_index);
870 static void __cal_detail_update_view(const char* view_uri, void* user_data)
874 c_ret_if(!user_data);
876 cal_detail_ug_data *data = user_data;
878 __cal_detail_ug_update_record(&data->record);
880 Evas_Object *dialogue = data->dialogue;
882 cal_dialogue_delete_all_items(dialogue);
884 __cal_detail_ug_add_dialogue_item(data);
887 static void __cal_detail_remove_db_changed_callback(cal_detail_ug_data *data)
893 calendar_error_e error = CALENDAR_ERROR_NONE;
895 error = calendar_db_remove_changed_cb(_calendar_event._uri, __cal_detail_update_view, data);
896 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_db_remove_changed_cb() is failed(%x)", error);
898 error = calendar_db_remove_changed_cb(_calendar_todo._uri, __cal_detail_update_view, data);
899 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_db_remove_changed_cb() is failed(%x)", error);
902 static void __cal_detail_add_db_changed_callback(cal_detail_ug_data *data)
908 calendar_error_e error = CALENDAR_ERROR_NONE;
910 error = calendar_db_add_changed_cb(_calendar_event._uri, __cal_detail_update_view, data);
911 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_db_remove_changed_cb() is failed(%x)", error);
913 error = calendar_db_add_changed_cb(_calendar_todo._uri, __cal_detail_update_view, data);
914 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_db_remove_changed_cb() is failed(%x)", error);
917 static void __cal_detail_ug_edit_ug_result_callback(ui_gadget_h ug, service_h result, void *priv)
924 int record_index = 0;
925 long long int base_time = 0;
929 int ret = service_get_extra_data(result, "record_index", &value);
930 c_warn_if(ret != SERVICE_ERROR_NONE, "service_get_extra_data() is failed(%x)", ret);
932 if (CAL_STRLEN(value))
933 record_index = atoi(value);
937 ret = service_get_extra_data(result, "base_time", &value);
938 c_warn_if(ret != SERVICE_ERROR_NONE, "service_get_extra_data() is failed(%x)", ret);
940 base_time = strtoll(value, NULL, 10);
944 cal_detail_ug_data *data = priv;
946 calendar_error_e error = calendar_record_destroy(data->record, true);
947 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_destroy() is failed(%x)", error);
949 data->record = _calendar_get_record_with_index(record_index);
951 if (data->instance) {
952 error = calendar_record_destroy(data->instance, true);
953 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_destroy() is failed(%x)", error);
955 data->instance = NULL;
958 if(!_calendar_is_task_record(data->record))
960 struct tm tm_start = {0};
962 cal_util_convert_lli_to_tm(NULL, base_time, &tm_start);
964 struct tm tm_end = tm_start;
966 cal_util_update_tm_day(&tm_end, 1);
968 data->instance = _calendar_get_instance_from_record(data->record, &tm_start, &tm_end);
969 c_ret_if(!data->instance);
972 Evas_Object *dialogue = data->dialogue;
974 cal_dialogue_delete_all_items(dialogue);
976 __cal_detail_ug_add_dialogue_item(data);
978 __cal_detail_add_db_changed_callback(data);
981 static void __cal_detail_ug_edit_ug_destroy_callback(ui_gadget_h ug, void *priv)
987 cal_detail_ug_data *data = priv;
989 Evas_Object *edit_button = elm_object_item_part_content_get(data->navi_item, "toolbar_button1");
990 if(elm_object_disabled_get(edit_button))
991 elm_object_disabled_set(edit_button, EINA_FALSE);
996 static void __cal_detail_launch_edit_ug(cal_detail_ug_data *data, calendar_record_h record)
1000 calendar_record_h cloned_record = NULL;
1002 __cal_detail_ug_clone_record(record, &cloned_record);
1004 char record_address[16] = {0};
1006 snprintf(record_address, sizeof(record_address), "%p", (void *)cloned_record);
1008 struct ug_cbs cbs = {0};
1010 cbs.result_cb = __cal_detail_ug_edit_ug_result_callback;
1011 cbs.destroy_cb = __cal_detail_ug_edit_ug_destroy_callback;
1014 cal_launch_ug_with_var(data->ug, "calendar-edit-efl", &cbs, "record", record_address, NULL);
1016 __cal_detail_remove_db_changed_callback(data);
1019 static void __cal_detail_event_edit_popup_response_callback(void *user_data, Evas_Object *obj, void *event_info)
1021 c_ret_if(!user_data);
1024 Evas_Object *popup = user_data;
1025 Evas_Object *button = obj;
1027 cal_detail_ug_data *data = evas_object_data_get(popup, "data");
1029 if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_BODY_ONLY_THIS_EVENT")))
1030 __cal_detail_launch_edit_ug(data, data->instance);
1031 else if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"))
1032 || !strcmp(elm_object_text_get(button), S_("IDS_COM_SK_OK")))
1033 __cal_detail_launch_edit_ug(data, data->record);
1035 evas_object_del(popup);
1038 static void __cal_detail_edit_button_callback(void *user_data, Evas_Object *obj, void *ei)
1042 c_ret_if(!user_data);
1044 cal_detail_ug_data *data = user_data;
1046 calendar_record_h record = data->record;
1048 if (_calendar_is_recurrent_record(record)) {
1049 cal_util_add_popup(data->window, "verticalbuttonstyle", NULL, C_("IDS_CLD_HEADER_EDIT_EVENT"), __cal_detail_event_edit_popup_response_callback, data,
1050 C_("IDS_CLD_BODY_ONLY_THIS_EVENT"), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"),
1051 S_("IDS_COM_SK_CANCEL"), NULL);
1053 __cal_detail_launch_edit_ug(data, record);
1054 elm_object_disabled_set(obj, EINA_TRUE);
1058 static void __cal_detail_save_button_callback(void *user_data, Evas_Object *obj, void *ei)
1062 c_ret_if(!user_data);
1064 cal_detail_ug_data *data = user_data;
1066 calendar_record_h record = data->record;
1068 calendar_error_e error = CALENDAR_ERROR_NONE;
1070 error = calendar_db_insert_record(record, NULL);
1071 if (error != CALENDAR_ERROR_NONE) {
1072 ERR("calendar_db_insert_record() is failed(%x)", error);
1074 int r = notification_status_message_post(S_("IDS_COM_POP_SAVED"));
1075 c_warn_if(r != NOTIFICATION_ERROR_NONE, "notification_status_message_post() is failed(%d)", r);
1079 static void __cal_detail_delete_event(cal_detail_ug_data *data, Eina_Bool is_delete_all)
1085 calendar_record_h record = data->record;
1088 _calendar_delete_recurrence_instance(data->instance);
1090 _calendar_delete_record(record);
1092 int r = notification_status_message_post(S_("IDS_COM_POP_DELETED"));
1093 c_warn_if(r != NOTIFICATION_ERROR_NONE, "notification_status_message_post() is failed(%d)", r);
1095 ug_destroy_me(data->ug);
1098 static void __cal_detail_delete_popup_response_event_callback(void *user_data, Evas_Object *obj, void *event_info)
1100 c_ret_if(!user_data);
1103 Evas_Object *popup = user_data;
1104 Evas_Object *button = obj;
1106 cal_detail_ug_data *data = evas_object_data_get(popup, "data");
1109 if (NULL != strstr(elm_object_text_get(button), S_("IDS_COM_BODY_DELETE")))
1110 __cal_detail_delete_event(data, EINA_TRUE);
1111 else if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_BODY_ONLY_THIS_EVENT")))
1112 __cal_detail_delete_event(data, EINA_FALSE);
1113 else if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS")))
1114 __cal_detail_delete_event(data, EINA_TRUE);
1116 evas_object_del(popup);
1119 static inline void __cal_detail_show_task_delete_popup(cal_detail_ug_data *data, calendar_record_h record)
1123 cal_util_add_popup(data->window, NULL, NULL, S_("IDS_COM_POP_DELETE_Q"), __cal_detail_delete_popup_response_event_callback, data,
1124 S_("IDS_COM_BODY_DELETE"), S_("IDS_COM_SK_CANCEL"), NULL);
1127 static inline void __cal_detail_show_event_delete_popup(cal_detail_ug_data *data, calendar_record_h record)
1131 if (_calendar_is_recurrent_record(record)) {
1132 cal_util_add_popup(data->window, "verticalbuttonstyle", NULL, C_("IDS_CLD_OPT_DELETE_EVENT"), __cal_detail_delete_popup_response_event_callback, data,
1133 C_("IDS_CLD_BODY_ONLY_THIS_EVENT"), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"),S_("IDS_COM_SK_CANCEL"), NULL);
1136 cal_util_add_popup(data->window, NULL, NULL, S_("IDS_COM_POP_DELETE_Q"), __cal_detail_delete_popup_response_event_callback, data,
1137 S_("IDS_COM_BODY_DELETE"), S_("IDS_COM_SK_CANCEL"), NULL);
1141 static void __cal_detail_delete_button_callback(void *user_data, Evas_Object *obj, void *ei)
1145 c_ret_if(!user_data);
1148 cal_detail_ug_data *data = user_data;
1150 Evas_Object *ctx_popup = obj;
1152 calendar_record_h record = data->record;
1155 evas_object_del(ctx_popup);
1157 if (_calendar_is_task_record(record))
1158 __cal_detail_show_task_delete_popup(data, record);
1160 __cal_detail_show_event_delete_popup(data, record);
1163 static void __cal_detail_share_popup_hide_callback(void *data, Evas_Object *obj, void *event_info)
1167 Evas_Object *popup = data;
1169 evas_object_del(popup);
1172 static void __cal_detail_via_message_callback(void *user_data, Evas_Object *obj, void *ei)
1174 c_ret_if(!user_data);
1177 cal_detail_ug_data *data = user_data;
1179 _calendar_export_record_to_vcs(data->record, CAL_MESSAGE_VCS);
1181 cal_launch_ug_with_var(data->ug, CAL_MESSAGE_COMPOSER_UG, NULL, "ATTACHFILE", CAL_MESSAGE_VCS, NULL);
1183 evas_object_del(obj);
1186 static void __cal_detail_via_email_callback(void *user_data, Evas_Object *obj, void *ei)
1188 c_ret_if(!user_data);
1191 cal_detail_ug_data *data = user_data;
1193 _calendar_export_record_to_vcs(data->record, CAL_EMAIL_VCS);
1195 cal_launch_ug_with_var(data->ug, CAL_EMAIL_COMPOSER_UG, (struct ug_cbs *)data, "RUN_TYPE", "5", "ATTACHMENT", CAL_EMAIL_VCS, NULL);
1197 evas_object_del(obj);
1200 static void __cal_detail_via_bluetooth_callback(void *user_data, Evas_Object *obj, void *ei)
1202 c_ret_if(!user_data);
1205 cal_detail_ug_data *data = user_data;
1207 _calendar_export_record_to_vcs(data->record, CAL_BLUETOOTH_VCS);
1209 cal_launch_ug_with_var(data->ug, CAL_BLUETOOTH_UG, NULL, "launch-type", "send", "filecount", "1", "files", CAL_BLUETOOTH_VCS, NULL);
1211 evas_object_del(obj);
1214 static void __cal_detail_share_button_callback(void *user_data, Evas_Object *obj, void *ei)
1216 c_ret_if(!user_data);
1219 cal_detail_ug_data *data = user_data;
1221 Evas_Object *ctx_popup = obj;
1223 evas_object_del(ctx_popup);
1225 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);
1228 evas_object_data_set(popup, "priv", data);
1230 Elm_Object_Item *popup_item = elm_popup_item_append(popup, S_("IDS_COM_BODY_MESSAGE"), NULL, __cal_detail_via_message_callback, data);
1231 c_ret_if(!popup_item);
1233 popup_item = elm_popup_item_append(popup, S_("IDS_COM_BODY_EMAIL"), NULL, __cal_detail_via_email_callback, data);
1234 c_ret_if(!popup_item);
1236 popup_item = elm_popup_item_append(popup, S_("IDS_COM_BODY_BLUETOOTH"), NULL, __cal_detail_via_bluetooth_callback, data);
1237 c_ret_if(!popup_item);
1240 static void __cal_detail_more_button_callback(void *user_data, Evas_Object *obj, void *event_info)
1242 c_ret_if(!user_data);
1245 cal_detail_ug_data *data = user_data;
1247 Evas_Object *ctx_popup = elm_ctxpopup_add(data->naviframe);
1248 c_ret_if(!ctx_popup);
1250 elm_ctxpopup_direction_priority_set(ctx_popup, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP);
1252 Elm_Object_Item *item = NULL;
1254 item = elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BODY_DELETE"), NULL, __cal_detail_delete_button_callback, data);
1257 item = elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BUTTON_SHARE"), NULL, __cal_detail_share_button_callback, data);
1260 Evas_Coord_Rectangle r = {0};
1262 cal_util_get_geometry(&r, obj);
1264 evas_object_move(ctx_popup, r.x + r.w/2, r.y + r.h/2);
1266 evas_object_show(ctx_popup);
1269 static Evas_Object *__cal_detail_ug_create_layout(Evas_Object *parent, cal_detail_ug_data *data)
1273 c_retv_if(!parent, NULL);
1274 c_retv_if(!data, NULL);
1276 Evas_Object *base_layout = cal_util_add_layout(parent, NULL);
1277 c_retv_if(!base_layout, NULL);
1279 Evas_Object *naviframe = elm_naviframe_add(base_layout);
1281 ERR("elm_naviframe_add() is failed");
1283 evas_object_del(base_layout);
1288 evas_object_show(naviframe);
1290 Evas_Object *bg = cal_util_add_bg(base_layout, EINA_FALSE);
1292 ERR("cal_util_add_bg() is failed");
1294 evas_object_del(base_layout);
1299 data->base_layout = base_layout;
1300 data->naviframe = naviframe;
1302 cal_util_initialize_timezone();
1304 Evas_Object *dialogue = __cal_detail_ug_create_dialogue(data);
1306 Evas_Object *back_button = __cal_detail_ug_add_back_button(data);
1308 Elm_Object_Item *item = NULL;
1310 if (_calendar_is_task_record(data->record))
1311 item = elm_naviframe_item_push(naviframe, C_("IDS_CLD_BODY_TASK_DETAILS"), back_button, NULL, dialogue, NULL);
1313 item = elm_naviframe_item_push(naviframe, C_("IDS_CLD_BODY_EVENT_DETAILS"), back_button, NULL, dialogue, NULL);
1314 c_warn_if(!item, "elm_naviframe_item_push() is failed");
1315 data->navi_item = item;
1317 cal_util_add_toolbar_button(naviframe, "toolbar_button1", S_("IDS_COM_BODY_EDIT"), __cal_detail_edit_button_callback, data);
1319 if (0 < _calendar_get_record_index(data->record)) {
1321 Evas_Object *more_button = cal_util_add_toolbar_button(naviframe, "toolbar_more_btn", NULL, __cal_detail_more_button_callback, data);
1322 elm_object_style_set(more_button, "naviframe/more/default");
1324 cal_util_add_toolbar_button(naviframe, "toolbar_button1", S_("IDS_COM_OPT_SAVE"), __cal_detail_save_button_callback, data);
1327 elm_object_part_content_set(base_layout, "elm.swallow.content", naviframe);
1328 elm_object_part_content_set(base_layout, "elm.swallow.bg", bg);
1334 static calendar_record_h inline __cal_detail_ug_get_origin_record(const calendar_record_h instance)
1338 c_retv_if(!instance, NULL);
1340 int index = _calendar_get_record_index(instance);
1342 return _calendar_get_record_with_index(index);
1345 static void __cal_detail_ug_get_appcontrol_input_data(service_h service, cal_detail_ug_data *data)
1351 char *item_type = NULL;
1353 r = service_get_extra_data(service, CAL_APPCONTROL_ITEM_TYPE, &item_type);
1354 c_ret_if(r != SERVICE_ERROR_NONE);
1356 if (CAL_STRCMP(CAL_APPCONTROL_ITEM_TYPE_EVENT, item_type)
1357 && CAL_STRCMP(CAL_APPCONTROL_ITEM_TYPE_TODO, item_type)) {
1358 ERR("Invaild input : %s, %s", CAL_APPCONTROL_ITEM_TYPE, item_type);
1360 CAL_FREE(item_type);
1365 CAL_FREE(item_type);
1367 r = service_get_extra_data(service, CAL_APPCONTROL_ITEM_ID, &index);
1368 if (r != SERVICE_ERROR_NONE) {
1369 ERR("service_get_extra_data(%s) is failed(%x)", "eventId", r);
1376 data->record = _calendar_get_record_with_index(atoi(index));
1379 static void __cal_detail_ug_get_record_from_vcs(char *vcs, cal_detail_ug_data *data)
1386 FILE * file = fopen(vcs, "r");
1388 ERR("fopen(%s) is failed.", vcs);
1395 c_warn_if(r == -1, "stat(%s) is failed(%d)", vcs, errno);
1397 int size = st.st_size;
1398 char *raw_data = calloc(size + 1, sizeof(char));
1400 ERR("calloc is failed.");
1407 r = fread(raw_data, 1, size, file);
1410 ERR("fread() is failed(%d)", errno);
1412 calendar_list_h list = NULL;
1414 calendar_error_e error = CALENDAR_ERROR_NONE;
1416 error = calendar_vcalendar_parse_to_calendar(raw_data, &list);
1417 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_vcalendar_parse_to_calendar() is failed(%x)", error);
1419 error = calendar_list_first(list);
1420 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_list_first() is failed(%x)", error);
1422 calendar_record_h record = NULL;
1424 error = calendar_list_get_current_record_p(list, &record);
1425 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_list_get_current_record_p() is failed(%x)", error);
1429 error = calendar_list_get_current_record_p(list, &record);
1430 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_list_get_current_record_p() is failed(%x)", error);
1432 if (_calendar_is_event_or_task(record)) {
1434 error = calendar_record_clone(record, &data->record);
1435 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_clone() is failed(%x)", error);
1440 error = calendar_list_next(list);
1444 error = calendar_list_get_current_record_p(list, &record);
1445 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_list_get_current_record_p() is failed(%x)", error);
1448 error = calendar_list_destroy(list, true);
1453 static char * __cal_detail_ug_filter_uri_format(const char *uri)
1455 if (!strstr(uri, CAL_URI_FILE_FORMAT))
1458 return strdup(uri+strlen(CAL_URI_FILE_FORMAT));
1461 /* Only vcs will be supported. */
1462 static void __cal_detail_ug_get_appcontrol_input_data_old(service_h service, cal_detail_ug_data *data)
1472 r = service_get_uri(service, &uri);
1473 if (r == SERVICE_ERROR_NONE && CAL_STRLEN(uri)) {
1475 char * filtered_uri = __cal_detail_ug_filter_uri_format(uri);
1479 __cal_detail_ug_get_record_from_vcs(filtered_uri, data);
1486 r = service_get_extra_data(service, "index", &index);
1487 if (r == SERVICE_ERROR_NONE) {
1488 calendar_record_h record = _calendar_get_record_with_index(atoi(index));
1489 if (r != SERVICE_ERROR_NONE) {
1491 ERR("_calendar_get_record_with_index(%d) is failed", cid);
1500 data->record = record;
1505 char *item_type = NULL;
1507 r = service_get_extra_data(service, "itemType", &item_type);
1508 if (r == SERVICE_ERROR_NONE) {
1510 if (!CAL_STRCMP(item_type, "event")) {
1512 r = service_get_extra_data(service, "eventId", &index);
1513 if (r != SERVICE_ERROR_NONE) {
1514 ERR("service_get_extra_data(%s) is failed(%x)", "eventid", r);
1521 calendar_record_h record = _calendar_get_record_with_index(atoi(index));
1522 if (r != SERVICE_ERROR_NONE) {
1524 ERR("_calendar_get_record_with_index(%d) is failed", cid);
1533 data->record = record;
1535 } else if (!CAL_STRCMP(item_type, "todo")) {
1537 r = service_get_extra_data(service, "todoId", &index);
1538 if (r != SERVICE_ERROR_NONE) {
1539 ERR("service_get_extra_data(%s) is failed(%x)", "todoId", r);
1546 calendar_record_h record = _calendar_get_record_with_index(atoi(index));
1547 if (r != SERVICE_ERROR_NONE) {
1549 ERR("_calendar_get_record_with_index(%d) is failed", cid);
1558 data->record = record;
1560 } else if (!CAL_STRCMP(item_type, "vcs")) {
1564 r = service_get_extra_data(service, "path", &vcs);
1565 if (r != SERVICE_ERROR_NONE) {
1566 ERR("service_get_extra_data(%s) is failed(%x)", "path", r);
1573 __cal_detail_ug_get_record_from_vcs(vcs, data);
1579 CAL_FREE(item_type);
1582 static void *__cal_detail_ug_create_callback(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv)
1586 c_retv_if(!ug, NULL);
1587 c_retv_if(!service, NULL);
1588 c_retv_if(!priv, NULL);
1589 c_retv_if(mode != UG_MODE_FULLVIEW, NULL);
1591 cal_detail_ug_data *data = priv;
1596 char *item_type = NULL;
1599 calendar_error_e error = CALENDAR_ERROR_NONE;
1603 char *operation = NULL;
1605 r = service_get_operation(service, &operation);
1606 c_retv_if(r != SERVICE_ERROR_NONE, NULL);
1608 if (!CAL_STRCMP(operation, CAL_APPCONTROL_SOCAIL_VIEW))
1609 __cal_detail_ug_get_appcontrol_input_data(service, data);
1611 __cal_detail_ug_get_appcontrol_input_data_old(service, data);
1613 CAL_FREE(operation);
1615 if (!data->record) {
1616 char *record_address = NULL;
1618 r = service_get_extra_data(service, "record", &record_address);
1619 if (r != SERVICE_ERROR_NONE) {
1620 ERR("service_get_extra_data(record) is failed(%x)", r);
1624 data->record = (calendar_record_h)strtoul(record_address, NULL, 16);
1625 c_warn_if(!data->record, "strtol(%s, NULL, 16) is failed", record_address);
1628 _calendar_record_type record_type = _calendar_get_record_type(data->record);
1630 if (record_type != _CALENDAR_RECORD_TYPE_EVENT && record_type != _CALENDAR_RECORD_TYPE_TODO) {
1631 data->instance = data->record;
1632 data->record = __cal_detail_ug_get_origin_record(data->instance);
1635 CAL_FREE(record_address);
1638 Evas_Object *parent = ug_get_parent_layout(ug);
1639 c_retv_if(!parent, NULL);
1641 data->window = ug_get_window();
1642 c_retv_if(!data->window, NULL);
1644 elm_theme_extension_add(NULL, "/usr/apps/"CALENDAR_PACKAGE"/res/edje/theme.edj");
1646 Evas_Object *base = __cal_detail_ug_create_layout(parent, data);
1647 c_retv_if(!base, NULL);
1649 __cal_detail_add_db_changed_callback(data);
1654 static void __cal_detail_ug_destroy_callback(ui_gadget_h ug, service_h service, void *priv)
1660 cal_detail_ug_data *data = priv;
1662 __cal_detail_remove_db_changed_callback(data);
1664 if (data->mouse_down_event_handler)
1665 ecore_event_handler_del(data->mouse_down_event_handler);
1667 cal_util_delete_evas_object(&data->base_layout);
1670 static void __cal_detail_ug_key_callback(ui_gadget_h ug, enum ug_key_event evt, service_h data, void *priv)
1675 case UG_KEY_EVENT_END:
1683 static void __cal_detail_ug_update_button_language(Evas_Object *naviframe, calendar_record_h record)
1685 c_ret_if(!naviframe);
1687 Elm_Object_Item *item = elm_naviframe_top_item_get(naviframe);
1690 Evas_Object *button = elm_object_item_part_content_get(item, "toolbar_button1");
1693 elm_object_text_set(button, S_("IDS_COM_BODY_EDIT"));
1695 if (_calendar_get_record_index(record) <= 0)
1696 elm_object_text_set(button, S_("IDS_COM_OPT_SAVE"));
1699 static void __cal_detail_ug_update_language(cal_detail_ug_data *data)
1702 c_ret_if(!data->record);
1706 calendar_record_h record = data->record;
1708 __cal_detail_ug_update_title_language(data->title, record);
1710 Eina_Bool is_task_record = _calendar_is_task_record(record);
1712 if (!is_task_record) {
1714 __cal_detail_ug_update_from_language(data->from);
1716 __cal_detail_ug_update_to_language(data->to);
1719 __cal_detail_ug_update_due_language(data->due);
1721 __cal_detail_ug_update_reminder_language(data->reminder, record);
1723 if (!is_task_record)
1724 __cal_detail_ug_update_recurrence_language(data->recurrence, record);
1726 __cal_detail_ug_update_saveto_language(data->save_to, record);
1730 static void __cal_detail_ug_update_region(cal_detail_ug_data *data)
1733 c_ret_if(!data->record);
1735 calendar_record_h record = data->record;
1737 if (!_calendar_is_task_record(data->record)) {
1739 __cal_detail_ug_update_from_region(data->from, record);
1741 __cal_detail_ug_update_to_region(data->to, record);
1744 __cal_detail_ug_update_due_region(data->to, record);
1747 static void __cal_detail_ug_event_callback(ui_gadget_h ug, enum ug_event event, service_h service, void *priv)
1753 case UG_EVENT_LANG_CHANGE:
1754 __cal_detail_ug_update_language((cal_detail_ug_data *)priv);
1756 case UG_EVENT_REGION_CHANGE:
1757 __cal_detail_ug_update_region((cal_detail_ug_data *)priv);
1760 case UG_EVENT_ROTATE_PORTRAIT:
1761 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
1763 case UG_EVENT_ROTATE_LANDSCAPE:
1764 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
1772 API int UG_MODULE_INIT(struct ug_module_ops *ops)
1776 c_retv_if(!ops, -1);
1778 cal_detail_ug_data *data = calloc(1, sizeof(cal_detail_ug_data));
1780 ops->create = __cal_detail_ug_create_callback;
1781 ops->destroy = __cal_detail_ug_destroy_callback;
1782 ops->key_event = __cal_detail_ug_key_callback;
1783 ops->event = __cal_detail_ug_event_callback;
1785 ops->opt = UG_OPT_INDICATOR_PORTRAIT_ONLY;
1787 const char *path = bindtextdomain(CALENDAR, LOCALEDIR);
1788 c_warn_if(!path, "bindtextdomain(%s, %s) is failed.", CALENDAR, LOCALEDIR);
1790 __cal_detail_ug_initialize(data);
1795 API void UG_MODULE_EXIT(struct ug_module_ops *ops)
1801 __cal_detail_ug_finish();
1803 cal_detail_ug_data *data = ops->priv;