3 * Copyright 2012 Samsung Electronics Co., Ltd
5 * Licensed under the Flora License, Version 1.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.tizenopensource.org/license
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
23 #include "edit-repeat.h"
24 #include "edit-alarm.h"
28 #include "external-ug.h"
30 static const char *_name = "view/detail";
31 #define CAL_REPEAT_EVERY_2_WEEK (CALS_FREQ_SECONDLY+1)
32 #define CAL_REPEAT_EVERY_3_DAY (CAL_REPEAT_EVERY_2_WEEK+1)
34 #define ARRAY_SIZE(array) \
35 ((int)(sizeof(array) / sizeof(array[0])))
37 #define APP_CALL "org.tizen.call"
38 #define APP_VTCALL "org.tizen.vtmain"
39 #define APP_CONTACT_S "org.tizen.contacts-shortcut"
41 static char messagebody[2048] = {0};
45 static void __cal_detail_autolink_send_email_selected_callback(void *data, Evas_Object *obj, void *event_info);
46 static void __cal_detail_autolink_add_to_contact_selected_callback(void *data, Evas_Object *obj, void *event_info);
47 static void __cal_detail_voice_call_selected_callback(void *data, Evas_Object *obj, void *event_info);
48 static void __cal_detail_autolink_send_message_selected_callback(void *data, Evas_Object *obj, void *event_info);
49 static void __cal_detail_autolink_video_call_selected_callback(void *data, Evas_Object *obj, void *event_info);
50 static void __cal_detail_autolink_phone_add_to_contact_selected_callback(void *data, Evas_Object *obj, void *event_info);
51 static void __cal_detail_update_view(void *data);
52 static void __cal_detail_edit_button_callback(void *data, Evas_Object *obj, void *ei);
53 static void __cal_detail_update_view_todo(void *data);
55 struct anchor_popup_item_t {
57 void (*response) (void *data, Evas_Object *obj, void *event_info);
60 static struct anchor_popup_item_t g_email_list[] = {
61 {"Send email", __cal_detail_autolink_send_email_selected_callback},
62 {"Add to contact", __cal_detail_autolink_add_to_contact_selected_callback},
65 static struct anchor_popup_item_t g_phone_list[] = {
66 {"Voice call", __cal_detail_voice_call_selected_callback},
67 {"Send message", __cal_detail_autolink_send_message_selected_callback},
68 {"Video call", __cal_detail_autolink_video_call_selected_callback},
69 {"Add to contact", __cal_detail_autolink_phone_add_to_contact_selected_callback},
72 enum genlist_item_type{
74 _GTYPE_START_AND_END_TIME,
76 _GTYPE_REMINDER_AND_REPEAT,
92 struct autolink_data_t {
94 Elm_Genlist_Item_Class itc;
104 Evas_Object *ly; // self
108 Evas_Object *genlist;
114 Ecore_Event_Handler *evt; // button down event
121 Eina_Bool is_deleted; //When event is deleted, updating view is not needed.
124 Eina_Bool is_todo_mode;
133 }cal_detail_genlist_item_data;
135 static Elm_Genlist_Item_Class itc_seperator, itc_2text, itc_4text, itc_mutilline, itc_parts, itc_linked_cal;
137 static void __cal_detail_autolink_send_email_selected_callback(void *data, Evas_Object *obj, void *event_info)
139 struct autolink_data_t *ald = (struct autolink_data_t *)data;
141 cal_launch_ug_with_var(EMAIL_COMPOSER_UG, NULL, "RUN_TYPE", "5", "TO", ald->info, NULL);
143 evas_object_del(ald->popup);
147 static void __cal_detail_autolink_add_to_contact_selected_callback(void *data, Evas_Object *obj,
150 struct autolink_data_t *ald = (struct autolink_data_t *)data;
153 snprintf(buf, sizeof(buf), "%d", 22);
155 cal_launch_ug_with_var(CONTACT_UG, NULL, "type", buf, "ct_email", ald->info, NULL);
157 evas_object_del(ald->popup);
161 static void __cal_detail_autolink_send_message_selected_callback(void *data, Evas_Object *obj, void *event_info)
163 struct autolink_data_t *ald = (struct autolink_data_t *)data;
165 cal_launch_ug_with_var(MESSAGE_COMPOSER_UG, NULL, "TO", ald->info, NULL);
167 evas_object_del(ald->popup);
171 static void __cal_detail_voice_call_selected_callback(void *data, Evas_Object *obj, void *event_info)
173 struct autolink_data_t *ald = (struct autolink_data_t *)data;
176 char telnum[255]={0,};
178 appsvc_set_operation(b, APPSVC_OPERATION_CALL);
179 snprintf(telnum, sizeof(telnum), "tel:%s", ald->info);
180 appsvc_set_uri(b, telnum);
181 appsvc_add_data(b, "ctindex", "-1");
182 appsvc_run_service(b, 0, NULL, NULL);
186 evas_object_del(ald->popup);
190 static void __cal_detail_autolink_video_call_selected_callback(void *data, Evas_Object *obj, void *event_info)
192 struct autolink_data_t *ald = (struct autolink_data_t *)data;
194 bundle *bd = bundle_create();
195 bundle_add(bd, "KEY_CALL_TYPE", "mo");
196 bundle_add(bd, "KEY_CALL_HANDLE", "1");
197 bundle_add(bd, "KEY_CALLING_PARTY_NUMBER", ald->info);
198 bundle_add(bd, "KEY_CLI_CAUSE", "-1");
199 bundle_add(bd, "KEY_FORWARDED", "-1");
201 aul_launch_app("org.tizen.vtmain", bd);
205 evas_object_del(ald->popup);
209 static void __cal_detail_autolink_phone_add_to_contact_selected_callback(void *data, Evas_Object *obj, void *event_info)
211 c_retm_if(!data, "data is null");
213 struct autolink_data_t *ald = data;
216 snprintf(buf, sizeof(buf), "%d", 21);
218 cal_launch_ug_with_var(CONTACT_UG, NULL, "type", buf, "ct_num", ald->info, NULL);
220 evas_object_del(ald->popup);
224 static void __cal_detail_delete_layout(void *data, Evas *e, Evas_Object *obj, void *ei)
228 c_retm_if(!data, "Input parameter is null");
230 cal_detail_data *p = data;
233 ecore_event_handler_del(p->evt);
235 if (p->cs && NULL == p->ad->ical)
236 CALENDAR_SVC_STRUCT_FREE(&(p->cs));
238 if (!p->is_todo_mode)
239 CALENDAR_SVC_DEL_EVENT_CHANGED_CALLBACK(__cal_detail_update_view);
241 CALENDAR_SVC_DEL_EVENT_CHANGED_CALLBACK(__cal_detail_update_view_todo);
246 static cal_struct* __cal_detail_get_event(cal_detail_data *p, int idx)
248 c_retvm_if(!p, NULL, "p parameter is null");
249 c_retvm_if(idx < 0, NULL, "idx is invalied(%d)", idx);
252 cal_struct *cs = NULL;
254 if (!p->is_todo_mode)
255 r = CALENDAR_SVC_GET(CAL_STRUCT_SCHEDULE, idx, NULL, &cs);
257 r = CALENDAR_SVC_GET(CAL_STRUCT_TODO, idx, NULL, &cs);
259 c_retvm_if(r != CAL_SUCCESS, NULL, "CALENDAR_SVC_GET(%d) is failed(%d)", idx, r);
264 static void __cal_detail_get_time_text(struct tm *tm, Eina_Bool is_allday, char *buf, int sz)
269 time = CAL_UTIL_TIME_FORMAT_6;
271 time = CAL_UTIL_TIME_FORMAT_1;
274 cal_util_get_time_text(buf, sz, CAL_UTIL_DATE_FORMAT_1, NULL, tm);
276 cal_util_get_time_text(buf, sz, CAL_UTIL_DATE_FORMAT_1, time, tm);
279 static void __cal_detail_get_start_time(cal_struct *cs, char *buf, int sz, cal_detail_data* p)
284 __cal_detail_get_time_text(&p->ad->tm_start, CALENDAR_SVC_IS_ALLDAY_EVENT(cs), buf, sz);
287 static void __cal_detail_get_end_time(cal_struct *cs, char *buf, int sz, cal_detail_data* p)
292 __cal_detail_get_time_text(&p->ad->tm_end, CALENDAR_SVC_IS_ALLDAY_EVENT(cs), buf, sz);
295 static void __cal_detail_get_alarm(cal_detail_data * p,cal_struct *cs)
297 c_retm_if(!p, "p is null");
298 c_retm_if(!cs, "cs is null");
302 g_list_free(p->alarm_list);
303 p->alarm_list = NULL;
305 int r = CALENDAR_SVC_STRUCT_GET_LIST(cs, CAL_VALUE_LST_ALARM, &al);
306 c_retm_if(r != CAL_SUCCESS, "CALENDAR_SVC_STRUCT_GET_LIST(CAL_VALUE_LST_ALARM) is failed(%d)", r);
308 c_retm_if(!al, "al is null");
311 cal_value *val = al->data;
312 c_retm_if(!val, "val is null");
314 int tick = CALENDAR_SVC_VALUE_GET_INT(val, CAL_VALUE_INT_ALARMS_TICK);
315 cal_sch_remind_tick_unit_t unit = CALENDAR_SVC_VALUE_GET_INT(val, CAL_VALUE_INT_ALARMS_TICK_UNIT);
316 int min = cal_edit_alarm_get_min(tick, unit);
317 p->alarm_list = g_list_append(p->alarm_list,(void *)min);
318 al = g_list_next(al);
321 p->alarm_list = g_list_first(p->alarm_list);
324 static void __cal_detail_get_repeat(cal_struct *cs, char *buf, int size)
328 cal_struct *original_cs = NULL;
330 int original_event_id = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_ORIGINAL_EVENT_ID);
331 if (0 < original_event_id) {
332 int r = CALENDAR_SVC_GET(CAL_STRUCT_SCHEDULE, original_event_id, NULL, &original_cs);
333 c_retm_if(r != CAL_SUCCESS, "CALENDAR_SVC_GET(%d) is failed(%d)", original_event_id, r);
339 int freq = CALENDAR_SVC_STRUCT_GET_INT(original_cs, CALS_VALUE_INT_RRULE_FREQ);
341 if (freq == CALS_FREQ_WEEKLY) {
343 int interval = CALENDAR_SVC_STRUCT_GET_INT(original_cs, CALS_VALUE_INT_RRULE_INTERVAL);
345 freq = CAL_REPEAT_EVERY_2_WEEK;
347 } else if (freq == CALS_FREQ_DAILY) {
349 int interval = CALENDAR_SVC_STRUCT_GET_INT(original_cs, CALS_VALUE_INT_RRULE_INTERVAL);
351 freq = CAL_REPEAT_EVERY_3_DAY;
354 _cal_edit_repeat_get_freq_str(freq, buf, size);
356 if (original_cs != cs)
357 CALENDAR_SVC_STRUCT_FREE(&original_cs);
360 static void __cal_detail_get_save_to_str(int calid, char *buf, int sz)
362 cal_struct *cs = NULL;
363 const char *str = NULL;
366 r = CALENDAR_SVC_GET(CAL_STRUCT_CALENDAR, calid, NULL, &cs);
367 if (r != CAL_SUCCESS)
369 snprintf(buf, sz, "%s", _("Phone"));
371 CALENDAR_SVC_STRUCT_FREE(&cs);
376 if (calid == DEFAULT_CALENDAR_ID)
377 str = C_("IDS_CLD_OPT_PHONE_CALENDAR");
380 str = CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_TABLE_TXT_NAME);
382 str = C_("IDS_CLD_OPT_PHONE_CALENDAR");
385 snprintf(buf, sz, "%s", str);
387 CALENDAR_SVC_STRUCT_FREE(&cs);
390 static void __cal_detail_get_save_to(cal_struct *cs, char *buf, int sz)
394 idx = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_CALENDAR_ID);
397 snprintf(buf, sz, "%s", C_("IDS_CLD_OPT_PHONE_CALENDAR"));
401 __cal_detail_get_save_to_str(idx, buf, sz);
404 static void __cal_detail_popup_hide_callback(void *data, Evas_Object *obj, void *ei)
406 c_retm_if(!data, "data is null");
408 cal_detail_data* p = data;
412 evas_object_del(obj);
416 static inline const char* __cal_detail_get_note(cal_struct *cs)
418 c_retvm_if(!cs, NULL, "cs is null");
420 return CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_VALUE_TXT_DESCRIPTION);
423 static void __cal_detail_via_message_callback(void *data, Evas_Object *obj, void *ei)
425 c_retm_if(!data, "data is null");
426 c_retm_if(!obj, "obj is null");
428 cal_detail_data *p = data;
429 c_retm_if(!p->cs, "p->cs is null");
431 int r = cal_util_create_vcs_file_from_cs(p->cs, MESSAGE_VCS);
432 if (CAL_SUCCESS != r) {
433 ERR("send via message failed: save vcs %d", r);
437 cal_launch_ug_with_var(MESSAGE_COMPOSER_UG, NULL, "ATTACHFILE", MESSAGE_VCS, NULL);
439 evas_object_del(obj);
443 static void __cal_detail_via_email_callback(void *data, Evas_Object *obj, void *ei)
445 c_retm_if(!data, "data is null");
446 c_retm_if(!obj, "obj is null");
448 cal_detail_data *p = data;
449 c_retm_if(!p->cs, "p->cs is null");
451 int r = cal_util_create_vcs_file_from_cs(p->cs, EMAIL_VCS);
452 if (CAL_SUCCESS != r) {
453 ERR("send via email failed: save vcs %d", r);
457 cal_launch_ug_with_var(EMAIL_COMPOSER_UG, NULL, "RUN_TYPE", "5", "ATTACHMENT", EMAIL_VCS, NULL);
459 evas_object_del(obj);
463 static void __cal_detail_via_bluetooth_callback(void *data, Evas_Object *obj, void *ei)
465 c_retm_if(!data, "data is null");
466 c_retm_if(!obj, "obj is null");
468 cal_detail_data *p = data;
469 c_retm_if(!p->cs, "p->cs is null");
471 int r = cal_util_create_vcs_file_from_cs(p->cs, BLUETOOTH_VCS);
472 if (CAL_SUCCESS != r) {
473 ERR("send via bluetooth failed: save cvs %d", r);
477 cal_launch_ug_with_var(BLUETOOTH_UG, NULL, "launch-type", "send", "filecount", "1", "files", BLUETOOTH_VCS, NULL);
479 evas_object_del(obj);
483 static void __cal_detail_send_button_callback(void *data, Evas_Object *obj, void *ei)
485 c_retm_if(!data, "data is null");
486 c_retm_if(!obj, "obj is null");
488 Evas_Object *ly = data;
490 cal_detail_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
491 c_retm_if(!p, "CAL_UTIL_GET_PRIV_DATA(ly) is failed");
493 Evas_Object *ctx = p->ctx;
496 evas_object_del(ctx);
498 p->ctx = elm_ctxpopup_add(p->ad->nv);
499 c_retm_if(!p->ctx, "elm_ctxpopup_add(p->ad->nv) returned null");
503 evas_object_smart_callback_add(ctx, "dismissed", __cal_detail_popup_hide_callback, p);
504 elm_ctxpopup_item_append(ctx, S_("IDS_COM_BODY_MESSAGE"), NULL, __cal_detail_via_message_callback, p);
505 elm_ctxpopup_item_append(ctx, S_("IDS_COM_BODY_EMAIL"), NULL, __cal_detail_via_email_callback, p);
506 elm_ctxpopup_item_append(ctx, S_("IDS_COM_BODY_BLUETOOTH"), NULL, __cal_detail_via_bluetooth_callback, p);
509 evas_object_geometry_get(p->ad->cbar, &x, &y, &w, &h);
510 evas_object_move(ctx, w / 2, y + h / 5);
511 evas_object_show(ctx);
514 static void __cal_detail_back_button_callback(void *data, Evas_Object *obj, void *ei)
518 cal_detail_data *p = data;
520 if((NULL != p->ad->ug) && (UG_DETAIL == p->ad->u_type))
522 ug_destroy_me(p->ad->ug);
526 if(p->ad->request_view == CV_DETAIL)
528 if(elm_naviframe_top_item_get(p->ad->nv) != elm_naviframe_bottom_item_get(p->ad->nv))
530 p->ad->request_view = CV_UNKNOWN;
531 p->ad->is_aul = EINA_FALSE;
533 elm_win_lower(p->ad->win);
539 if(p->ad->is_update_view)
540 edje_object_signal_emit(CAL_UTIL_GET_EDJ_DATA(p->parent), "update", "prog");
543 struct appdata * ad = p->ad;
544 c_retm_if(!ad, "ad is null");
546 ad->current_view = CV_UNKNOWN;
549 static void __cal_detail_viewer_back_button_callback(void *data, Evas_Object *obj, void *ei)
553 struct appdata *ad = data;
554 c_retm_if(!ad, "ad is NULL");
555 c_retm_if(!ad->nv, "ad->nv is NULL");
557 elm_naviframe_item_pop(ad->nv);
560 static void __cal_detail_error_popup_response_event_callback(void *data, Evas_Object *obj, void *ei)
564 c_retm_if(!data, "data is null");
566 Evas_Object *popup = data;
567 struct appdata *ad = evas_object_data_get(popup, "data");
569 c_retm_if(!ad, "ad is null");
570 c_retm_if(!ad->win, "p->ad->win is null");
572 if (!elm_naviframe_top_item_get(ad->nv))
575 elm_win_lower(ad->win);
577 evas_object_del(popup);
580 static void __cal_detail_delete_event(cal_detail_data* p, Eina_Bool is_delete_all)
584 c_retm_if(!p, "p is null");
588 if (!is_delete_all) {
590 long long int lli_time;
591 cal_util_convert_tm_to_lli(NULL, &p->ad->tm_start, &lli_time);
593 r = calendar_svc_event_delete_normal_instance(p->cid, lli_time);
594 if (r != CAL_SUCCESS)
595 ERR("calendar_svc_event_delete_normal_instance() is failed(%d)", r);
597 p->is_deleted = EINA_TRUE;
601 if (!p->is_todo_mode)
602 r = CALENDAR_SVC_DELETE(CAL_STRUCT_SCHEDULE, p->cid);
604 r = CALENDAR_SVC_DELETE(CAL_STRUCT_TODO, p->cid);
606 c_retm_if(r != CAL_SUCCESS, "CALENDAR_SVC_DELETE(CAL_STRUCT_SCHEDULE, %d) is failed(%d)", p->cid, r);
608 p->is_deleted = EINA_TRUE;
611 evas_object_del(p->popup);
613 if ((p->ad->ug) && (UG_DETAIL == p->ad->u_type))
614 ug_destroy_me(p->ad->ug);
617 if (elm_naviframe_top_item_get(p->ad->nv) == elm_naviframe_bottom_item_get(p->ad->nv))
620 elm_naviframe_item_pop(p->ad->nv);
623 struct appdata * ad = p->ad;
624 c_retm_if(!ad, "ad is null");
626 ad->current_view = CV_UNKNOWN;
629 static void __cal_detail_delete_popup_response_event_callback(void *data, Evas_Object *obj, void *event_info)
631 c_retm_if(!data, "data is null");
632 c_retm_if(!obj, "obj is null");
634 Evas_Object *popup = data;
635 Evas_Object *button = obj;
637 cal_detail_data* p = evas_object_data_get(popup, "data");
638 c_retm_if(!p, "p is null");
640 if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_BODY_ONLY_THIS_EVENT")))
641 __cal_detail_delete_event(p, EINA_FALSE);
642 else if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"))
643 || !strcmp(elm_object_text_get(button), S_("IDS_COM_SK_OK")))
644 __cal_detail_delete_event(p, EINA_TRUE);
646 evas_object_del(popup);
650 static void __cal_detail_event_edit_popup_response_callback(void *data, Evas_Object *obj, void *event_info)
652 c_retm_if(!data, "data is null");
653 c_retm_if(!obj, "obj is null");
655 Evas_Object *popup = data;
656 Evas_Object *button = obj;
658 cal_detail_data* p = evas_object_data_get(popup, "data");
659 c_retm_if(!p, "p is null");
661 struct appdata* ad = p->ad;
662 c_retm_if(!ad, "ad is null");
664 if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_BODY_ONLY_THIS_EVENT")))
665 ad->edit_special_one = EINA_TRUE;
666 else if (!strcmp(elm_object_text_get(button), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"))
667 || !strcmp(elm_object_text_get(button), S_("IDS_COM_SK_OK")))
668 ad->edit_special_one = EINA_FALSE;
670 evas_object_del(popup);
675 cal_edit_create_view(ad, p->ly);
677 evas_object_del(popup);
681 static inline void __cal_detail_show_event_edit_popup(cal_detail_data *p, cal_struct *cs)
685 if (CALENDAR_SVC_STRUCT_GET_INT(cs, CALS_VALUE_INT_RRULE_ID)) {
686 p->popup = cal_util_add_popup(p->ad->win, "verticalbuttonstyle", NULL, C_("IDS_CLD_HEADER_EDIT_EVENT"), __cal_detail_event_edit_popup_response_callback, p,
687 C_("IDS_CLD_BODY_ONLY_THIS_EVENT"), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"),
688 S_("IDS_COM_SK_CANCEL"), NULL);
691 p->popup = cal_util_add_popup(p->ad->win, NULL, NULL, C_("IDS_CLD_HEADER_EDIT_EVENT"), __cal_detail_event_edit_popup_response_callback, p,
692 S_("IDS_COM_SK_OK"),S_("IDS_COM_SK_CANCEL"), NULL);
696 static inline void __cal_detail_show_event_delete_popup(cal_detail_data *p, cal_struct *cs)
700 if (CALENDAR_SVC_STRUCT_GET_INT(cs, CALS_VALUE_INT_RRULE_ID)) {
701 p->popup = cal_util_add_popup(p->ad->win, "verticalbuttonstyle", NULL, C_("IDS_CLD_OPT_DELETE_EVENT"), __cal_detail_delete_popup_response_event_callback, p,
702 C_("IDS_CLD_BODY_ONLY_THIS_EVENT"), C_("IDS_CLD_POP_ALL_REPETITIVE_EVENTS"),
703 S_("IDS_COM_SK_CANCEL"), NULL);
706 p->popup = cal_util_add_popup(p->ad->win, NULL, NULL, C_("IDS_CLD_OPT_DELETE_EVENT"), __cal_detail_delete_popup_response_event_callback, p,
707 S_("IDS_COM_SK_OK"),S_("IDS_COM_SK_CANCEL"), NULL);
711 static void __cal_detail_task_edit_popup_response_callback(void *data, Evas_Object *obj, void *event_info)
713 c_retm_if(!data, "data is null");
714 c_retm_if(!obj, "obj is null");
716 Evas_Object *popup = data;
717 Evas_Object *button = obj;
719 cal_detail_data* p = evas_object_data_get(popup, "data");
720 c_retm_if(!p, "p is null");
722 struct appdata* ad = p->ad;
723 c_retm_if(!ad, "ad is null");
725 if (!strcmp(elm_object_text_get(button), S_("IDS_COM_SK_OK")))
726 cal_edit_create_view_todo(ad, p->ly);
728 evas_object_del(popup);
732 static inline void __cal_detail_show_task_edit_popup(cal_detail_data *p, cal_struct *cs)
736 p->popup = cal_util_add_popup(p->ad->win, NULL, NULL, C_("IDS_TASK_HEADER_EDIT_TASK"), __cal_detail_task_edit_popup_response_callback, p,
737 S_("IDS_COM_SK_OK"),S_("IDS_COM_SK_CANCEL"), NULL);
740 static inline void __cal_detail_show_task_delete_popup(cal_detail_data *p, cal_struct *cs)
744 p->popup = cal_util_add_popup(p->ad->win, NULL, NULL, C_("IDS_CLD_OPT_DELETE_TASK"), __cal_detail_delete_popup_response_event_callback, p,
745 S_("IDS_COM_SK_OK"),S_("IDS_COM_SK_CANCEL"), NULL);
748 static void __cal_detail_delete_button_callback(void *data, Evas_Object *obj, void *ei)
754 Evas_Object *ly = data;
756 cal_detail_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
759 cal_struct *cs = __cal_detail_get_event(p, p->cid);
762 /*CAL_STRUCT_TYPE_TODO == 2*/
763 if (CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_TYPE) == 2)
764 __cal_detail_show_task_delete_popup(p, cs);
766 __cal_detail_show_event_delete_popup(p, cs);
768 CALENDAR_SVC_STRUCT_FREE(&cs);
771 static Eina_Bool __cal_detail_mouse_button_down_callback(void *data, int type, void *event)
773 Ecore_Event_Mouse_Button *ev = event;
774 cal_detail_data *p = data;
779 return ECORE_CALLBACK_RENEW;
782 static void __cal_detail_edit_button_callback(void *data, Evas_Object *obj, void *ei)
788 Evas_Object *ly = data;
790 cal_detail_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
793 cal_struct *cs = __cal_detail_get_event(p, p->cid);
796 /*CAL_STRUCT_TYPE_TODO == 2*/
797 if (CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_TYPE) == 2)
798 __cal_detail_show_task_edit_popup(p, cs);
800 __cal_detail_show_event_edit_popup(p, cs);
802 CALENDAR_SVC_STRUCT_FREE(&cs);
805 static char* __cal_detail_get_title_location_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
807 c_retvm_if(!item_data, NULL, "item_data is null");
811 cal_detail_data *p = item_data->p;
812 c_retvm_if(!p, NULL, "p is null");
814 cal_struct *cs = p->cs;
815 c_retvm_if(!cs, NULL, "cs is null");
817 if (!CAL_STRCMP(part, "elm.text.1"))
819 title = CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_VALUE_TXT_SUMMARY);
820 if (title && title[0] != '\0')
821 return strdup(title);
823 return strdup(C_("IDS_CLD_BODY_NO_TITLE"));
826 if (!CAL_STRCMP(part, "elm.text.2"))
828 loc = CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_VALUE_TXT_LOCATION);
829 if (loc && loc[0] != '\0')
832 return strdup(C_("IDS_CLD_BODY_NO_LOCATION_SELECTED"));
838 static char* __cal_detail_get_save_to_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
840 cal_detail_data *p = item_data->p;
849 if (!CAL_STRCMP(part, "elm.text.1"))
851 return strdup(C_("IDS_ST_BODY_SAVE_TO"));
854 if(!CAL_STRCMP(part, "elm.text.2"))
856 __cal_detail_get_save_to(cs, buf, sizeof(buf));
863 static char* __cal_detail_get_start_time_and_end_time_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
865 c_retv_if(!item_data, NULL);
867 cal_detail_data *p = item_data->p;
870 cal_struct *cs = p->cs;
871 c_retv_if(!cs, NULL);
873 if (CAL_STRCMP(part, "elm.text.1") == 0) {
876 return strdup(C_("IDS_CLD_BODY_DUE_DATE"));
878 return strdup(S_("IDS_COM_BODY_START"));
881 if (CAL_STRCMP(part, "elm.text.3") == 0) {
884 return strdup(C_("IDS_CLD_BODY_DUE_DATE"));
886 return strdup(S_("IDS_COM_BODY_END"));
891 if (CAL_STRCMP(part, "elm.text.2") == 0) {
893 __cal_detail_get_start_time(cs, buf, sizeof(buf), p);
898 if (CAL_STRCMP(part, "elm.text.4") == 0) {
900 __cal_detail_get_end_time(cs, buf, sizeof(buf), p);
908 static char* __cal_detail_get_due_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
910 c_retv_if(!item_data, NULL);
912 cal_detail_data *p = item_data->p;
915 cal_struct *cs = p->cs;
916 c_retv_if(!cs, NULL);
918 if (!CAL_STRCMP(part, "elm.text.1")) {
921 return strdup(C_("IDS_CLD_BODY_DUE_DATE"));
923 return strdup(S_("IDS_COM_BODY_END"));
928 if (!CAL_STRCMP(part, "elm.text.2")) {
930 __cal_detail_get_end_time(cs, buf, sizeof(buf), p);
938 static void __cal_detail_get_alarm_text(cal_detail_genlist_item_data *data, char* buf, int buf_size)
940 c_retm_if(!data, "data is null");
941 cal_edit_alarm_get_alarm_str(data->alarm_value, buf, buf_size);
944 static char* __cal_detail_add_reminder_and_repeat_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
947 char buf[1024] = {0};
948 cal_detail_data *p = item_data->p;
955 if (!CAL_STRCMP(part, "elm.text.1"))
957 return strdup(C_("IDS_CLD_BODY_REMINDER"));
960 if(!CAL_STRCMP(part, "elm.text.2"))
962 __cal_detail_get_alarm_text(item_data, buf, sizeof(buf));
966 if (!CAL_STRCMP(part, "elm.text.3"))
968 return strdup(C_("IDS_CLD_BODY_REPEAT"));
971 if(!CAL_STRCMP(part, "elm.text.4"))
973 __cal_detail_get_repeat(cs, buf, sizeof(buf));
981 static Eina_Bool __cal_detail_check_autolink_delimiter(char ch)
983 if (isdigit(ch) || isalpha(ch))
988 char undeli[] = "@-_.+"; /* The char in the string is not a delimiter */
991 for (i = 0; i < sizeof(undeli) / sizeof(undeli[0]); ++i)
1001 static int __cal_detail_check_autolink_phone_number(const char *word)
1003 const int min_phone_num_len = 3;
1004 const int max_phone_num_len = 15;
1006 int num_counter = 0;
1013 while (isdigit(word[i]) || word[i] == '-')
1015 if (isdigit(word[i]))
1018 if (num_counter > max_phone_num_len)
1023 else if (i == 0 || word[i - 1] == '-')
1025 /* The first char is '-' or two consecutive '-' */
1031 /* Make sure that the last char is digit */
1032 while (!isdigit(word[i]))
1037 if (num_counter < min_phone_num_len)
1047 static enum anchor_t __cal_detail_get_autolink_anchor_type(const char *word)
1052 if (NULL != strstr(word, EMAIL_LINK_FLAG))
1054 return ANCHOR_EMAIL_LINK;
1058 if (strchr(word, '@') != NULL)
1060 return ANCHOR_EMAIL;
1064 char *url_prefix[] = { "http://", "HTTP://", "www.", "WWW." };
1065 for (i = 0; i < sizeof(url_prefix) / sizeof(url_prefix[0]); ++i)
1067 if (g_str_has_prefix(word, url_prefix[i]))
1074 if (__cal_detail_check_autolink_phone_number(word))
1076 return ANCHOR_PHONE;
1082 static void __cal_detail_process_autolink_anchor_word(GString *anchor)
1087 GString *word = g_string_new(anchor->str);
1088 g_string_assign(anchor, ""); /* clear */
1089 char *snote_display = NULL;
1090 char *email_link = NULL;
1092 switch (__cal_detail_get_autolink_anchor_type(word->str))
1095 g_string_append(anchor, "<color=#72b1f2FF>");
1096 g_string_append_printf(anchor,
1097 "<a href=email|%s underline=on underline_color=#72b1f2FF>",
1099 g_string_append(anchor, word->str);
1100 g_string_append(anchor, "</a></color>");
1104 g_string_append(anchor, "<color=#72b1f2FF>");
1105 g_string_append_printf(anchor,
1106 "<a href=url|%s underline=on underline_color=#72b1f2FF>",
1108 g_string_append(anchor, word->str);
1109 g_string_append(anchor, "</a></color>");
1113 len = __cal_detail_check_autolink_phone_number(word->str);
1114 char num[32] = { 0 };
1115 snprintf(num, len + 1, "%s", word->str);
1117 g_string_append(anchor, "<color=#72b1f2FF>");
1118 g_string_append_printf(anchor,
1119 "<a href=phone_num|%s underline=on underline_color=#72b1f2FF>",
1121 g_string_append(anchor, num);
1122 g_string_append(anchor, "</a></color>");
1123 g_string_append(anchor, word->str + len);
1125 case ANCHOR_EMAIL_LINK:
1127 email_link = strstr(word->str, EMAIL_LINK_FLAG);
1128 int nsize = email_link - word->str + 1;
1129 CAL_CALLOC(snote_display, nsize, char);
1130 if(NULL != snote_display)
1132 strncpy(snote_display, word->str, nsize-1);
1134 g_string_append(anchor, "<color=#72b1f2FF>");
1135 g_string_append_printf(anchor,
1136 "<a href=email_link|%s underline=on underline_color=#72b1f2FF>",
1137 email_link+strlen(EMAIL_LINK_FLAG));
1139 g_string_append(anchor, snote_display);
1140 g_string_append(anchor, "</a></color>");
1141 free(snote_display);
1144 g_string_append(anchor, word->str);
1149 static GString *__cal_detail_add_autolink_anchor(const char *content)
1151 c_retvm_if(!content, NULL, "Input parameter is null");
1153 const char *p = content;
1155 GString *text = g_string_new("");
1156 GString *buf = g_string_new("");
1158 while (*p != '\0') {
1159 g_string_assign(buf, ""); /* reset buffer */
1161 if(NULL != strstr(p, EMAIL_LINK_FLAG))
1164 g_string_append_len(buf, p, CAL_STRLEN(content));
1165 __cal_detail_process_autolink_anchor_word(buf);
1166 g_string_append(text, buf->str);
1169 else if (__cal_detail_check_autolink_delimiter(p[0]))
1171 g_string_append_c(text, p[0]);
1174 else if (p[0] == '<')
1176 gt = strchr(p, '>'); /* search tag end */
1177 CAL_ASSERT(gt); /* assert '<' and '>' are matched */
1178 g_string_append_len(text, p, gt - p + 1);
1184 while (p[i] != '\0')
1186 if (__cal_detail_check_autolink_delimiter(p[i]) || p[i] == '<')
1193 g_string_append_len(buf, p, i);
1196 __cal_detail_process_autolink_anchor_word(buf);
1197 g_string_append(text, buf->str);
1201 g_string_free(buf, TRUE);
1206 static char* __cal_detail_get_note_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
1210 cal_detail_data *p = item_data->p;
1220 static void __cal_detail_autolink_popup_response_callback(void *data, Evas_Object *obj, void *event_info)
1222 c_retm_if(!data, "data is null");
1223 c_retm_if(!obj, "obj is null");
1225 struct autolink_data_t *ald = data;
1230 evas_object_del(obj);
1233 void __cal_detail_show_autolink_popup(struct autolink_data_t *ald, cal_detail_data* p)
1235 c_retm_if(!ald, "ald is null");
1236 c_retm_if(!p, "p is null");
1238 struct anchor_popup_item_t *list = NULL;
1242 Elm_Object_Item *item = NULL;
1247 list = g_email_list;
1248 count = ARRAY_SIZE(g_email_list);
1251 list = g_phone_list;
1252 count = ARRAY_SIZE(g_phone_list);
1258 ctx = elm_ctxpopup_add(p->ly);
1259 c_retm_if(!ctx, "elm_ctxpopup_add is failed");
1261 evas_object_smart_callback_add(ctx, "dismissed", __cal_detail_autolink_popup_response_callback, ald);
1263 for (i = 0; i < count; ++i)
1265 item = elm_ctxpopup_item_append(ctx, list[i].label, NULL, list[i].response, ald);
1268 ERR("elm_ctxpopup_item_append returned null");
1269 evas_object_del(ctx);
1273 evas_object_move(ctx, p->x, p->y);
1274 evas_object_show(ctx);
1277 static char *__cal_detail_get_autolink_anchor_type_str(enum anchor_t type)
1286 case ANCHOR_EMAIL_LINK:
1287 return "email_link";
1293 static enum anchor_t __cal_detail_parse_autolink_anchor_type(char *s)
1296 for (i = NOT_ANCHOR + 1; i < NOT_ANCHOR + 5; ++i)
1298 if (CAL_STRCMP(s, __cal_detail_get_autolink_anchor_type_str(i)) == 0)
1300 return (enum anchor_t)i;
1307 static void __cal_detail_autolink_email_link_clicked(char *info)
1309 c_retm_if(!info, "Input parameter is null");
1311 char *account_id= NULL;
1312 char *email_id= NULL;
1313 char *src_box= NULL;
1317 req = bundle_create();
1318 c_retm_if(!req, "bundle_create is failed");
1320 char livemagazine[30] = { 0, };
1321 snprintf(livemagazine, sizeof(livemagazine), "%d", 0);
1322 char internal[30] = { 0, };
1323 snprintf(internal, sizeof(internal), "%d", 1);
1325 temp = strchr(info, '_');
1329 bundle_add(req, "ACCOUNT_ID", account_id);
1336 temp = strchr(email_id, '_');
1340 bundle_add(req, "MAIL_ID", email_id);
1347 bundle_add(req, "MAILBOX", src_box);
1351 bundle_add(req, "RUN_TYPE", "7");
1352 ret = aul_launch_app("org.tizen.email", req);
1353 c_warn_if(!ret, "aul_launch_app(org.tizen.email) is failed(%d)", ret);
1358 static void __cal_detail_autolink_anchor_clicked_callback(void *data, Evas_Object *obj, void *event_info)
1360 c_retm_if(!data, "data is null");
1362 struct autolink_data_t *s_ald = NULL;
1363 cal_detail_data* p = data;
1364 char buf[128] = { 0 };
1366 Elm_Entry_Anchor_Info *ei = (Elm_Entry_Anchor_Info *)event_info;
1368 char *temp = strchr(ei->name, ' ');
1371 ERR("strchr(ei->name, ' ') is failed");
1375 CAL_STRNCPY(buf, ei->name, temp - ei->name);
1377 temp = strchr(buf, '|');
1380 ERR("strchr(buf '|') is failed");
1384 s_ald = calloc(1, sizeof(struct autolink_data_t));
1385 c_retm_if(!s_ald, "calloc(1, struct autolink_data_t) is failed");
1387 s_ald->info = calloc(128, sizeof(char));
1390 ERR("calloc(128, char) is failed");
1396 CAL_STRNCPY(s_ald->info, temp + 1, 128);
1398 s_ald->type = __cal_detail_parse_autolink_anchor_type(buf);
1400 switch (s_ald->type)
1404 __cal_detail_show_autolink_popup(s_ald, p);
1407 aul_open_content(s_ald->info); /* launch browser */
1409 case ANCHOR_EMAIL_LINK:
1410 __cal_detail_autolink_email_link_clicked(s_ald->info);
1420 static Evas_Object* __cal_detail_add_note_object(cal_detail_data *p, Evas_Object *parent, const char *text)
1422 c_retvm_if(!p, NULL, "p is null");
1423 c_retvm_if(!parent, NULL, "parent is null");
1424 c_retvm_if(!text, NULL, "text is null");
1425 c_retvm_if(!strlen(text), NULL, "strlen(text) is zero");
1427 Evas_Object *layout = cal_util_add_edit_field(parent, S_("IDS_COM_BODY_NOTE"), NULL, EINA_FALSE, EINA_FALSE);
1428 c_retvm_if(!layout, NULL, "layout is null");
1430 Evas_Object *entry = elm_object_part_content_get(layout, "elm.swallow.content");
1431 c_retvm_if(!entry, layout, "entry is null");
1436 evas_object_smart_callback_add(entry, "anchor,clicked", __cal_detail_autolink_anchor_clicked_callback, p);
1437 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1438 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_EXPAND);
1439 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
1440 elm_entry_autocapital_type_set(entry, EINA_TRUE);
1442 elm_entry_entry_set(entry, text);
1447 static Evas_Object* __cal_detail_add_note_icon(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
1449 c_retvm_if(!obj, NULL, "obj is null");
1450 c_retvm_if(!part, NULL, "part is null");
1451 c_retvm_if(!item_data, NULL, "item_data is null");
1453 cal_detail_data *p = item_data->p;
1454 Evas_Object *edit_field = NULL;
1455 const char *note = NULL;
1456 GString *text = NULL;
1457 cal_struct *cs = p->cs;
1458 c_retvm_if(!cs, NULL, "cs is null");
1460 if (!CAL_STRCMP(part, "elm.icon"))
1462 note = __cal_detail_get_note(cs);
1463 if (!CAL_STRLEN(note))
1466 text = __cal_detail_add_autolink_anchor(elm_entry_utf8_to_markup(note));
1467 g_string_prepend(text, "<font_size=35>");
1468 edit_field = __cal_detail_add_note_object(p, obj, text->str);
1474 static Evas_Object *__cal_detail_get_genlist_item_icon(void *data, Evas_Object *obj, const char *part)
1476 c_retvm_if(!data, NULL, "data is null");
1478 Evas_Object *e_obj = NULL;
1480 cal_detail_genlist_item_data *item_data = (cal_detail_genlist_item_data*)data;
1481 int type = item_data->type;
1487 e_obj = __cal_detail_add_note_icon(obj, part, item_data);
1496 static char* __cal_detail_get_priority_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
1498 cal_detail_data *p = item_data->p;
1501 c_retvm_if(!cs, NULL, "cs is null");
1503 if (!CAL_STRCMP(part, "elm.text.1"))
1504 return strdup(C_("IDS_CLD_BODY_PRIORITY"));
1506 if (!CAL_STRCMP(part, "elm.text.2")) {
1507 switch (p->priority) {
1508 case EVENT_PRIORITY_LOW:
1509 return strdup(S_("IDS_COM_BODY_LOW"));
1510 case EVENT_PRIORITY_NORMAL:
1511 return strdup(C_("IDS_IDLE_BODY_NORMAL"));
1512 case EVENT_PRIORITY_HIGH:
1513 return strdup(S_("IDS_COM_OPT_HIGH_M_QUALITY"));
1522 static char *__cal_detail_get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
1524 c_retvm_if(!data, NULL, "data is null");
1526 cal_detail_genlist_item_data *item_data = (cal_detail_genlist_item_data*)data;
1527 int type = item_data->type;
1531 case _GTYPE_TITLE_LOC:
1532 return __cal_detail_get_title_location_text(obj, part, item_data);
1533 case _GTYPE_START_AND_END_TIME:
1534 return __cal_detail_get_start_time_and_end_time_text(obj, part, item_data);
1536 return __cal_detail_get_due_text(obj, part, item_data);
1537 case _GTYPE_REMINDER_AND_REPEAT:
1538 return __cal_detail_add_reminder_and_repeat_text(obj, part, item_data);
1540 return __cal_detail_get_note_text(obj, part, item_data);
1542 case _GTYPE_LINKED_CAL:
1543 return __cal_detail_get_save_to_text(obj, part, item_data);
1544 case _GTYPE_PRIORITY:
1545 return __cal_detail_get_priority_text(obj, part, item_data);
1551 static void __cal_detail_genlist_item_delete_callback(void *data, Evas_Object *obj)
1553 c_retm_if(!data, "data is null");
1555 cal_detail_genlist_item_data *item_data = (cal_detail_genlist_item_data*)data;
1562 static Eina_Bool __cal_detail_get_genlist_item_state(void *data, Evas_Object *obj, const char *part)
1567 static void __cal_detail_genlist_item_select_callback(void *data, Evas_Object *obj, void *event_info)
1572 static Elm_Object_Item* __cal_detail_add_genlist_item(Evas_Object *parent, Elm_Genlist_Item_Class *itc, int type, cal_detail_data *p)
1574 c_retvm_if(!parent, NULL, "parent is null");
1575 c_retvm_if(!itc, NULL, "itc is null");
1576 c_retvm_if(!p, NULL, "p is null");
1578 cal_detail_genlist_item_data *item_data = calloc(1, sizeof(cal_detail_genlist_item_data));
1579 c_retvm_if(!item_data, NULL, "calloc(1, sizeof(cal_detail_genlist_item_data)) is failed");
1583 item_data->type = type;
1585 item_data->it = elm_genlist_item_append(parent, itc, (void*)(item_data), NULL, ELM_GENLIST_ITEM_NONE, __cal_detail_genlist_item_select_callback, NULL);
1586 c_retvm_if(!item_data->it, NULL, "elm_genlist_item_append() is failed");
1588 return item_data->it;
1591 static Elm_Object_Item* __cal_detail_add_separator(Evas_Object *genlist, cal_detail_data *p)
1593 c_retvm_if(!p, NULL, "p is null");
1594 c_retvm_if(!genlist, NULL, "genlist is null");
1596 if (p->is_todo_mode)
1599 Elm_Object_Item *git = __cal_detail_add_genlist_item(genlist, &itc_seperator, 0, p);
1600 c_retvm_if(!git, NULL, "__cal_detail_add_genlist_item returned null");
1602 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1608 static Elm_Object_Item* __cal_detail_add_title_location(Evas_Object *genlist, cal_detail_data *p)
1610 __cal_detail_add_separator(genlist, p);
1611 return __cal_detail_add_genlist_item(genlist, &itc_2text, _GTYPE_TITLE_LOC, p);
1614 static Elm_Object_Item* __cal_detail_add_start_and_end_time(Evas_Object *genlist, cal_detail_data *p)
1616 // __cal_detail_add_separator(genlist, p);
1617 return __cal_detail_add_genlist_item(genlist, &itc_4text, _GTYPE_START_AND_END_TIME, p);
1620 static Elm_Object_Item* __cal_detail_add_due(Evas_Object *genlist, cal_detail_data *p)
1622 // __cal_detail_add_separator(genlist, p);
1623 return __cal_detail_add_genlist_item(genlist, &itc_2text, _GTYPE_DUE, p);
1626 static void __cal_detail_add_reminder_and_repeat_item(Evas_Object *genlist, Elm_Genlist_Item_Class *itc, int type, cal_detail_data *p, int alarm)
1628 c_retm_if(!genlist, "genlist is null");
1629 c_retm_if(!itc, "itc is null");
1630 c_retm_if(!p, "p is null");
1632 cal_detail_genlist_item_data *item_data = calloc(1, sizeof(cal_detail_genlist_item_data));
1633 c_retm_if(!item_data, "calloc is failed");
1636 item_data->type = type;
1637 item_data->alarm_value = alarm;
1639 item_data->it = elm_genlist_item_append(genlist, itc, item_data, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1643 ERR("elm_genlist_item_append returned null");
1649 static void __cal_detail_add_reminder_and_repeat(Evas_Object *genlist, cal_detail_data *p)
1651 c_retm_if(!genlist, "genlist is null");
1652 c_retm_if(!p, "p is null");
1653 c_retm_if(!p->cs, "p->cs is null");
1655 // __cal_detail_add_separator(genlist, p);
1656 __cal_detail_get_alarm(p, p->cs);
1658 if (!p->alarm_list) {
1659 __cal_detail_add_reminder_and_repeat_item(genlist, &itc_4text, _GTYPE_REMINDER_AND_REPEAT, p, -1);
1661 GList *alarm = p->alarm_list;
1665 alarm_min = (int)alarm->data;
1666 __cal_detail_add_reminder_and_repeat_item(genlist, &itc_4text, _GTYPE_REMINDER_AND_REPEAT, p, alarm_min);
1667 alarm = g_list_next(alarm);
1673 static Elm_Object_Item* __cal_detail_add_note(Evas_Object *genlist, cal_detail_data *p)
1675 c_retvm_if(!p, NULL, "p is null");
1676 c_retvm_if(!genlist, NULL, "genlist is null");
1678 cal_struct *cs = p->cs;
1679 c_retvm_if(!cs, NULL, "cs is null");
1681 const char *note = __cal_detail_get_note(cs);
1682 if (!CAL_STRLEN(note))
1685 // __cal_detail_add_separator(genlist, p);
1687 return __cal_detail_add_genlist_item(genlist, &itc_mutilline, _GTYPE_NOTE, p);
1690 static Elm_Object_Item* __cal_detail_add_save_to(Evas_Object *genlist, cal_detail_data *p)
1692 // __cal_detail_add_separator(genlist, p);
1694 return __cal_detail_add_genlist_item(genlist, &itc_linked_cal, _GTYPE_LINKED_CAL, p);
1697 static void __cal_detail_show_error_popup(cal_detail_data *p)
1701 c_retm_if(!p, "p is null");
1702 c_retm_if(!p->ad, "p->ad is null");
1703 c_retm_if(!p->ad->win, "p->ad->win is null");
1706 evas_object_del(p->popup);
1708 p->popup = cal_util_add_popup(p->ad->win, NULL, S_("IDS_COM_POP_WARNING"), C_("IDS_CLD_BODY_NO_EVENTS"),
1709 __cal_detail_error_popup_response_event_callback, p->ad, S_("IDS_COM_SK_OK"), NULL);
1710 c_retm_if(!p->popup, "cal_util_add_popup(p->ad->win) returned null");
1713 static Evas_Object *__cal_detail_create_genlist(cal_detail_data *p)
1715 c_retvm_if(!p, NULL, "p is null");
1716 c_retvm_if(!p->ad, NULL, "p->ad is null");
1718 Evas_Object *genlist;
1721 p->cs = p->ad->ical;
1724 CALENDAR_SVC_STRUCT_FREE(&p->cs);
1726 p->cs = __cal_detail_get_event(p, p->ad->cid);
1729 cal_main_set_cs(p->ad, p->cs);
1732 __cal_detail_show_error_popup(p);
1736 genlist = elm_genlist_add(p->ly);
1737 c_retvm_if(!genlist, NULL, "elm_genlist_add(p->ly) returned null");
1739 elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_NONE);
1741 itc_seperator.item_style = "dialogue/seperator";
1742 itc_seperator.func.text_get = NULL;
1743 itc_seperator.func.state_get = __cal_detail_get_genlist_item_state;
1744 itc_seperator.func.del = __cal_detail_genlist_item_delete_callback;
1746 itc_2text.item_style = "dialogue/2text";
1747 itc_2text.func.text_get = __cal_detail_get_genlist_item_label;
1748 itc_2text.func.del = __cal_detail_genlist_item_delete_callback;
1750 itc_4text.item_style = "dialogue/4text";
1751 itc_4text.func.text_get = __cal_detail_get_genlist_item_label;
1752 itc_4text.func.del = __cal_detail_genlist_item_delete_callback;
1754 itc_mutilline.item_style = "dialogue/1icon";
1755 itc_mutilline.func.text_get = __cal_detail_get_genlist_item_label;
1756 itc_mutilline.func.del = __cal_detail_genlist_item_delete_callback;
1757 itc_mutilline.func.content_get = __cal_detail_get_genlist_item_icon;
1759 itc_parts.item_style = "dialogue/1icon.fill";
1760 itc_parts.func.text_get = __cal_detail_get_genlist_item_label;
1761 itc_parts.func.del = __cal_detail_genlist_item_delete_callback;
1762 itc_parts.func.content_get = __cal_detail_get_genlist_item_icon;
1764 itc_linked_cal.item_style = "dialogue/2text";
1765 itc_linked_cal.func.text_get = __cal_detail_get_genlist_item_label;
1766 itc_linked_cal.func.del = __cal_detail_genlist_item_delete_callback;
1768 __cal_detail_add_title_location(genlist, p);
1769 __cal_detail_add_start_and_end_time(genlist, p);
1770 __cal_detail_add_reminder_and_repeat(genlist, p);
1771 __cal_detail_add_note(genlist, p);
1773 __cal_detail_add_save_to(genlist, p);
1778 static void __cal_detail_update_view(void *data)
1782 c_retm_if(!data, "data is null");
1784 cal_detail_data *p = data;
1789 Evas_Object *genlist;
1790 struct appdata* ad = p->ad;
1791 c_retm_if(!ad, "ad is null");
1793 is_hour24 = ad->is_hour24;
1795 cal_util_delete_evas_object(&p->genlist);
1796 genlist = __cal_detail_create_genlist(p);
1799 elm_object_part_content_set(p->ly, "sw", genlist);
1800 p->genlist = genlist;
1805 static Evas_Object *__cal_detail_create_layout(struct appdata *ad, Evas_Object *parent)
1809 Evas_Object *genlist;
1810 p = calloc(1, sizeof(cal_detail_data));
1815 ly = cal_util_add_layout(parent, "edit");
1821 evas_object_data_set(ly, "priv", p);
1825 p->alarm_list = NULL;
1826 p->is_todo_mode = EINA_FALSE;
1828 is_hour24 = ad->is_hour24;
1830 genlist = __cal_detail_create_genlist(p);
1833 evas_object_del(ly);
1838 elm_object_part_content_set(p->ly, "sw", genlist);
1839 p->genlist = genlist;
1841 p->evt = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, __cal_detail_mouse_button_down_callback, p);
1843 evas_object_event_callback_add(ly, EVAS_CALLBACK_DEL, __cal_detail_delete_layout, p);
1845 CALENDAR_SVC_ADD_EVENT_CHANGED_CALLBACK(__cal_detail_update_view, p);
1850 static void __cal_detail_save_to_calendar_button_callback(void *data, Evas_Object *obj, void *ei)
1854 struct appdata *ad = data;
1855 c_retm_if(!ad || !ad->nv, "ad or ad->nv is null");
1857 int r = CALENDAR_SVC_INSERT(ad->ical);
1858 if (CAL_SUCCESS != r)
1859 ERR("Calendar service delete failed: %d", r);
1863 void cal_detail_create_view(struct appdata *ad, Evas_Object *parent)
1867 c_retm_if(!ad || !parent, "Input parameter is null");
1869 if (ad->current_view == CV_DETAIL)
1873 Evas_Object *back_button;
1874 Evas_Object *controlbar;
1875 Elm_Object_Item* navi_item;
1877 ly = __cal_detail_create_layout(ad, parent);
1878 c_retm_if(!ly, "__cal_detail_create_layout(ad, parent) is failed");
1880 navi_item = elm_naviframe_item_push(ad->nv, C_("IDS_CLD_BODY_EVENT_DETAILS"), NULL, NULL, ly, NULL);
1883 ERR("elm_naviframe_item_push is failed");
1884 evas_object_del(ly);
1888 controlbar = cal_util_add_controlbar(ad->nv);
1891 ERR("cal_util_add_controlbar(ad->nv) is failed");
1892 elm_naviframe_item_pop(ad->nv);
1896 elm_toolbar_item_append(controlbar, CAL_CBAR_ICON_EDIT, NULL, __cal_detail_edit_button_callback, ly);
1898 if (ad->item_type == ITEM_TYPE_UNKNOWN) {
1899 elm_toolbar_item_append(controlbar, CAL_CBAR_ICON_SHARE, NULL, __cal_detail_send_button_callback, ly);
1900 elm_toolbar_item_append(controlbar, CAL_CBAR_ICON_DELETE, NULL, __cal_detail_delete_button_callback, ly);
1903 elm_object_item_part_content_set( navi_item, "controlbar", controlbar);
1905 back_button = elm_object_item_part_content_get(navi_item, "prev_btn");
1908 back_button = elm_button_add(ad->nv);
1911 ERR("elm_button_add is failed.");
1914 elm_object_style_set(back_button, "naviframe/back_btn/default");
1915 elm_object_item_part_content_set(navi_item, "prev_btn", back_button);
1917 elm_object_style_set(back_button, "naviframe/back_btn/default");
1918 evas_object_smart_callback_add(back_button, "clicked", __cal_detail_back_button_callback, CAL_UTIL_GET_PRIV_DATA(ly));
1920 ad->current_view = CV_DETAIL;
1925 void cal_detail_create_viewer(struct appdata *ad, Evas_Object *parent, cal_struct *cs)
1929 c_retm_if(!ad || !parent || !cs, "Input parameter is null");
1932 Evas_Object *back_button;
1933 Elm_Object_Item* navi_item;
1936 ly = __cal_detail_create_layout(ad, parent);
1937 c_retm_if(!ly, "__cal_detail_create_layout(ad, parent) is failed");
1939 navi_item = elm_naviframe_item_push(ad->nv, _("VCS Viewer"), NULL, NULL, ly, NULL);
1941 ERR("elm_naviframe_item_push is failed");
1942 evas_object_del(ly);
1946 Evas_Object *controlbar = cal_util_add_controlbar(ad->nv);
1948 ERR("cal_util_add_controlbar(ad->nv) is failed");
1949 elm_naviframe_item_pop(ad->nv);
1953 elm_toolbar_item_append(controlbar, NULL, S_("IDS_COM_OPT_SAVE"), __cal_detail_save_to_calendar_button_callback, ad);
1954 elm_object_item_part_content_set(navi_item, "controlbar", controlbar);
1956 back_button = elm_button_add(ad->nv);
1957 c_retm_if(!back_button, "elm_button_add is failed.");
1959 elm_object_style_set(back_button, "naviframe/back_btn/default");
1960 elm_object_item_part_content_set(navi_item, "prev_btn", back_button);
1962 evas_object_smart_callback_add(back_button, "clicked", __cal_detail_viewer_back_button_callback, ad);
1965 static int __cal_detail_get_priority(cal_struct *cs)
1967 c_retvm_if(!cs, 0, "cs is null");
1969 return CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_PRIORITY);
1972 static void __cal_detail_add_priority(Evas_Object *genlist, cal_detail_data *p)
1974 c_retm_if(!genlist, "genlist is null");
1975 c_retm_if(!p, "p is null");
1976 c_retm_if(!p->cs, "p->cs is null");
1978 p->priority = __cal_detail_get_priority(p->cs);
1980 __cal_detail_add_genlist_item(genlist, &itc_4text, _GTYPE_PRIORITY, p);
1985 static Evas_Object *__cal_detail_create_genlist_todo(cal_detail_data *p)
1987 c_retvm_if(!p, NULL, "p is null");
1988 c_retvm_if(!p->ad, NULL, "p->ad is null");
1990 Evas_Object *genlist;
1992 if(p->ad->is_aul && p->ad->ical)
1993 p->cs = p->ad->ical;
1995 p->cs = __cal_detail_get_event(p, p->ad->cid);
1998 __cal_detail_show_error_popup(p);
2000 genlist = elm_genlist_add(p->ly);
2001 c_retvm_if(!genlist, NULL, "elm_genlist_add(p->ly) returned null");
2003 if (NULL != p->ad->theme)
2005 elm_object_theme_set(genlist, p->ad->theme);
2008 elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_NONE);
2010 itc_seperator.item_style = "dialogue/seperator";
2011 itc_seperator.func.text_get = NULL;
2012 itc_seperator.func.state_get = __cal_detail_get_genlist_item_state;
2013 itc_seperator.func.del = __cal_detail_genlist_item_delete_callback;
2015 itc_2text.item_style = "dialogue/2text";
2016 itc_2text.func.text_get = __cal_detail_get_genlist_item_label;
2017 itc_2text.func.del = __cal_detail_genlist_item_delete_callback;
2019 itc_4text.item_style = "dialogue/2text";
2020 itc_4text.func.text_get = __cal_detail_get_genlist_item_label;
2021 itc_4text.func.del = __cal_detail_genlist_item_delete_callback;
2023 itc_mutilline.item_style = "dialogue/1icon";
2024 itc_mutilline.func.text_get = __cal_detail_get_genlist_item_label;
2025 itc_mutilline.func.del = __cal_detail_genlist_item_delete_callback;
2026 itc_mutilline.func.content_get = __cal_detail_get_genlist_item_icon;
2028 Elm_Object_Item *git = __cal_detail_add_genlist_item(genlist, &itc_seperator, 0, p);
2029 c_retvm_if(!git, NULL, "__cal_detail_add_genlist_item returned null");
2030 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
2032 __cal_detail_add_title_location(genlist, p);
2033 __cal_detail_add_due(genlist, p);
2034 __cal_detail_add_priority(genlist, p);
2035 __cal_detail_add_reminder_and_repeat(genlist, p);
2036 __cal_detail_add_note(genlist, p);
2041 static Evas_Object *__cal_detail_create_layout_todo(struct appdata *ad, Evas_Object *parent)
2045 Evas_Object *genlist;
2046 p = calloc(1, sizeof(cal_detail_data));
2051 ly = cal_util_add_layout(parent, "edit");
2057 evas_object_data_set(ly, "priv", p);
2061 p->alarm_list = NULL;
2062 p->is_todo_mode = EINA_TRUE;
2064 is_hour24 = ad->is_hour24;
2066 genlist = __cal_detail_create_genlist_todo(p);
2069 evas_object_del(ly);
2074 elm_object_part_content_set(p->ly, "sw", genlist);
2075 p->genlist = genlist;
2077 p->evt = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, __cal_detail_mouse_button_down_callback, p);
2079 evas_object_event_callback_add(ly, EVAS_CALLBACK_DEL, __cal_detail_delete_layout, p);
2081 CALENDAR_SVC_ADD_EVENT_CHANGED_CALLBACK(__cal_detail_update_view_todo, p);
2086 void cal_detail_create_view_todo(struct appdata *ad, Evas_Object *parent)
2090 c_retm_if(!ad || !parent, "Input parameter is null");
2093 Evas_Object *back_button;
2094 Evas_Object *controlbar;
2095 Elm_Object_Item* navi_item;
2097 ly = __cal_detail_create_layout_todo(ad, parent);
2098 c_retm_if(!ly, "__cal_detail_create_layout(ad, parent) is failed");
2100 navi_item = elm_naviframe_item_push(ad->nv, C_("IDS_CLD_BODY_TASK_DETAILS"), NULL, NULL, ly, NULL);
2103 ERR("elm_naviframe_item_push is failed");
2104 evas_object_del(ly);
2108 controlbar = cal_util_add_controlbar(ad->nv);
2111 ERR("cal_util_add_controlbar(ad->nv) is failed");
2112 elm_naviframe_item_pop(ad->nv);
2116 elm_toolbar_item_append(controlbar, CAL_CBAR_ICON_EDIT, NULL, __cal_detail_edit_button_callback, ly);
2117 elm_toolbar_item_append(controlbar, CAL_CBAR_ICON_SHARE, NULL, __cal_detail_send_button_callback, ly);
2118 elm_toolbar_item_append(controlbar, CAL_CBAR_ICON_DELETE, NULL, __cal_detail_delete_button_callback, ly);
2120 elm_object_item_part_content_set( navi_item, "controlbar", controlbar);
2122 back_button = elm_object_item_part_content_get(navi_item, "prev_btn");
2125 back_button = elm_button_add(ad->nv);
2128 ERR("elm_button_add is failed.");
2131 elm_object_style_set(back_button, "naviframe/back_btn/default");
2132 elm_object_item_part_content_set(navi_item, "prev_btn", back_button);
2134 elm_object_style_set(back_button, "naviframe/back_btn/default");
2135 evas_object_smart_callback_add(back_button, "clicked", __cal_detail_back_button_callback, CAL_UTIL_GET_PRIV_DATA(ly));
2138 static void __cal_detail_update_view_todo(void *data)
2142 c_retm_if(!data, "data is null");
2144 cal_detail_data *p = data;
2149 Evas_Object *genlist;
2150 struct appdata* ad = p->ad;
2151 c_retm_if(!ad, "ad is null");
2153 is_hour24 = ad->is_hour24;
2155 cal_util_delete_evas_object(&p->genlist);
2156 genlist = __cal_detail_create_genlist_todo(p);
2159 elm_object_part_content_set(p->ly, "sw", genlist);
2160 p->genlist = genlist;