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.
24 #include "ug-settings.h"
25 #include "external-ug.h"
26 #include "cld-images.h"
28 #define PROGRESS_BAR_TIMER_INTERVAL 0.1
39 }focus_in_month_view_type;
42 ITEM_LOCK_TIMEZONE_ON_OFF = 0,
43 ITEM_LOCK_TIMEZONE_GUIDE_TEXT,
45 ITEM_FIRST_DAY_OF_WEEK,
50 ITEM_WEEK_NUMBER_ON_OFF,
51 ITEM_COMPLETED_TO_DO_ON_OFF,
52 ITEM_IMPORT_CALENDARS,
53 ITEM_EXPORT_CALENDARS,
61 Elm_Object_Item *item;
72 SETTING_EXPORT_CALENDAR,
73 SETTING_IMPORT_CALENDAR
76 static Elm_Genlist_Item_Class itc_seperator = {
77 .item_style = "dialogue/separator/21/with_line",
78 .func.text_get = NULL,
79 .func.content_get = NULL,
80 .func.state_get = NULL,
84 static char *__cal_setting_ug_get_genlist_item_label(void *data, Evas_Object *obj, const char *part);
85 static Evas_Object *__cal_setting_ug_get_genlist_item_icon(void *data, Evas_Object *obj, const char *part);
86 static char *__cal_setting_get_import_genlist_item_label(void *data, Evas_Object *obj, const char *part);
87 static Evas_Object* __cal_setting_get_import_genlist_icon(void *item_data, Evas_Object *obj, const char *part);
88 static void __cal_setting_gl_insert_genlist_item(struct ug_data *ugd, Evas_Object *genlist, Elm_Object_Item *item_after, int index);
89 static void __cal_setting_complete_todo_on_off_changed_callback(void *data, Evas_Object *obj, void *event_info);
90 static void __cal_setting_week_number_on_off_changed_callback(void *data, Evas_Object *obj, void *event_info);
92 extern void cal_setting_export_create_view(struct ug_data *data);
94 static Elm_Genlist_Item_Class itc_2text_1icon_2 = {
95 .item_style = "dialogue/2text.1icon.2",
96 .func.text_get = __cal_setting_get_import_genlist_item_label,
97 .func.content_get = __cal_setting_get_import_genlist_icon,
100 static Elm_Genlist_Item_Class itc_lock_tz = {
101 .item_style = "dialogue/1text.1icon",
102 .func.text_get = __cal_setting_ug_get_genlist_item_label,
103 .func.content_get = __cal_setting_ug_get_genlist_item_icon,
104 .func.state_get = NULL,
108 static Elm_Genlist_Item_Class itc_import = {
109 .item_style = "dialogue/1text",
110 .func.text_get = __cal_setting_ug_get_genlist_item_label,
111 .func.content_get = NULL,
112 .func.state_get = NULL,
116 static Elm_Genlist_Item_Class itc_tz = {
117 .item_style = "dialogue/2text.3",
118 .func.text_get = __cal_setting_ug_get_genlist_item_label,
119 .func.content_get = NULL,
120 .func.state_get = NULL,
124 static Elm_Genlist_Item_Class itc = {
125 .item_style = "dialogue/2text.3/expandable",
126 .func.text_get = __cal_setting_ug_get_genlist_item_label,
127 .func.content_get = NULL,
128 .func.state_get = NULL,
132 static Elm_Genlist_Item_Class itc_radio = {
133 .item_style = "dialogue/1text.1icon.2/expandable2",
134 .func.text_get = __cal_setting_ug_get_genlist_item_label,
135 .func.content_get = __cal_setting_ug_get_genlist_item_icon,
136 .func.state_get = NULL,
140 static Elm_Genlist_Item_Class itc_lock_tz_guide = {
141 .item_style = "multiline/1text",
142 .func.text_get = __cal_setting_ug_get_genlist_item_label,
143 .func.content_get = NULL,
144 .func.state_get = NULL,
148 static char *__cal_setting_get_import_genlist_item_label(void *data, Evas_Object *obj, const char *part)
150 c_retv_if(!data, NULL);
151 c_retv_if(!part, NULL);
153 calendar_record_h calendar_book = data;
156 char* description = NULL;
158 calendar_error_e error = CALENDAR_ERROR_NONE;
160 if (!CAL_STRCMP(part,"elm.text.1")) {
162 cid = _calendar_get_calendar_index(calendar_book);
163 if (cid == DEFAULT_EVENT_CALENDAR_BOOK_ID)
164 return strdup(C_("IDS_CLD_BODY_MY_CALENDAR"));
165 else if (cid == DEFAULT_TODO_CALENDAR_BOOK_ID)
166 return strdup(C_("IDS_TASK_BODY_MY_TASK"));
167 else if (cid == DEFAULT_BIRTHDAY_CALENDAR_BOOK_ID)
168 return strdup(C_("IDS_CLD_MBODY_CONTACTS_BIRTHDAY"));
170 error = calendar_record_get_str(calendar_book, _calendar_book.name, &name);
171 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_str() is faile(%x)", error);
173 if (CAL_STRLEN(name))
178 return strdup(C_("IDS_CLD_BODY_NO_TITLE"));
180 } else if (!CAL_STRCMP(part,"elm.text.2")) {
182 error = calendar_record_get_int(calendar_book, _calendar_book.account_id, &cid);
183 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is faile(%x)", error);
185 if (cid == _CALENDAR_LOCAL_ACCOUNT_ID)
186 return strdup(C_("IDS_CLD_POP_MY_PHONE"));
188 error = calendar_record_get_str(calendar_book, _calendar_book.description, &description);
189 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_str() is faile(%x)", error);
191 if (CAL_STRLEN(description))
194 CAL_FREE(description);
196 return strdup(S_("IDS_COM_POP_NO_ACCOUNTS"));
199 return strdup(C_("IDS_CLD_BODY_NO_TITLE"));
202 static Evas_Object* __cal_setting_get_import_genlist_icon(void *item_data, Evas_Object *obj, const char *part)
204 c_retvm_if(!item_data, NULL, "item_data is null");
205 c_retvm_if(!obj, NULL, "obj is null");
207 Evas_Object *icon = NULL;
208 char* icon_path = NULL;
209 calendar_record_h calendar_book = item_data;
210 Eina_Bool r = EINA_FALSE;
214 calendar_error_e error = CALENDAR_ERROR_NONE;
216 error = calendar_record_get_int(calendar_book, _calendar_book.id, &cid);
217 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is faile(%x)", error);
219 error = calendar_record_get_int(calendar_book, _calendar_book.account_id, &aid);
220 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is faile(%x)", error);
222 if (!CAL_STRCMP(part, "elm.icon")) {
223 icon = elm_icon_add(obj);
226 ERR("elm_icon_add fail");
230 if ( aid == _CALENDAR_LOCAL_ACCOUNT_ID) {
231 r = elm_icon_file_set(icon, CAL_IMAGES_EDJ, CAL_IMAGES_PHONE);
233 icon_path = cal_account_svc_get_account_icon_path(aid);
235 r = elm_icon_file_set(icon, icon_path, NULL);
242 evas_object_del(icon);
245 evas_object_show(icon);
252 static char *__cal_setting_ug_get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
254 c_retvm_if(!data, NULL, "data is null");
255 c_retvm_if(!obj, NULL, "part is null");
257 Item_data *item_data = data;
258 item_type type = item_data->index;
263 localtime_r(&t, &tm);
267 if (!CAL_STRCMP(part, "elm.text.1")) {
268 return strdup(C_("IDS_CLD_BODY_TIME_ZONE"));
269 } else if (!CAL_STRCMP(part, "elm.text.2")) {
270 return g_strdup_printf("%s, %s", S_(item_data->ugd->city), item_data->ugd->time_zone);
274 case ITEM_LOCK_TIMEZONE_ON_OFF:
275 if (!CAL_STRCMP(part, "elm.text"))
276 return strdup(C_("IDS_CLD_MBODY_LOCK_TIME_ZONE"));
279 case ITEM_LOCK_TIMEZONE_GUIDE_TEXT:
280 return strdup(C_("IDS_CLD_BODY_LOCK_TIME_ZONE_DESCRIPTION_MSG"));
283 case ITEM_FIRST_DAY_OF_WEEK:
284 if (!CAL_STRCMP(part, "elm.text.1")) {
285 return strdup(C_("IDS_CLD_BODY_FIRST_DAY_OF_WEEK"));
286 } else if (!CAL_STRCMP(part, "elm.text.2")) {
287 if (FIRST_DAY_LOCALE_DEFAULT == item_data->ugd->first_day_of_week) {
288 return strdup(C_("IDS_CLD_BODY_LOCALE_DEFAULT"));
289 } else if (FIRST_DAY_SUNDAY == item_data->ugd->first_day_of_week) {
290 return strdup(C_("IDS_ST_BODY_SUNDAY"));
291 } else if (FIRST_DAY_MONDAY == item_data->ugd->first_day_of_week) {
292 return strdup(C_("IDS_ST_BODY_MONDAY"));
293 } else if (FIRST_DAY_SATURDAY == item_data->ugd->first_day_of_week) {
294 return strdup(S_("IDS_COM_BODY_SATURDAY"));
299 case ITEM_WEEK_NUMBER_ON_OFF:
300 if (!CAL_STRCMP(part, "elm.text"))
301 return strdup(C_("IDS_CLD_BODY_SHOW_WEEK_NUMBER"));
304 case ITEM_COMPLETED_TO_DO_ON_OFF:
305 if (!CAL_STRCMP(part, "elm.text"))
306 return strdup(C_("IDS_CLD_BODY_SHOW_COMPLETED_TASKS"));
309 case ITEM_LOCALE_DEFAULT:
310 return strdup(C_("IDS_CLD_BODY_LOCALE_DEFAULT"));
313 return strdup(C_("IDS_ST_BODY_SUNDAY"));
316 return strdup(C_("IDS_ST_BODY_MONDAY"));
319 return strdup(S_("IDS_COM_BODY_SATURDAY"));
321 case ITEM_IMPORT_CALENDARS:
322 if (!CAL_STRCMP(part, "elm.text"))
323 return strdup(C_("IDS_CLD_BODY_IMPORT_EVENTS_TASKS_ABB"));
326 case ITEM_EXPORT_CALENDARS:
327 if (!CAL_STRCMP(part, "elm.text"))
328 return strdup(C_("IDS_CLD_BODY_EXPORT_EVENTS_TASKS_ABB"));
337 static void __cal_setting_ug_radio_changed_callback(void *data, Evas_Object *obj, void *event_info)
339 c_retm_if(!data, "data is null");
340 c_retm_if(!obj, "part is null");
343 Eina_List *realized_list;
345 Item_data *item_data = data;
346 item_type type = item_data->index;
350 case ITEM_LOCALE_DEFAULT:
351 item_data->ugd->first_day_of_week = FIRST_DAY_LOCALE_DEFAULT;
352 ret = vconf_set_int(CAL_VCONFKEY_FIRST_DAY_OF_WEEK, item_data->ugd->first_day_of_week);
353 c_retm_if(ret != 0,"vconf_set_int(CAL_VCONFKEY_FIRST_DAY_OF_WEEK, 0) is failed(%d)", ret);
356 item_data->ugd->first_day_of_week = FIRST_DAY_SUNDAY;
357 ret = vconf_set_int(CAL_VCONFKEY_FIRST_DAY_OF_WEEK, item_data->ugd->first_day_of_week);
358 c_retm_if(ret != 0,"vconf_set_int(CAL_VCONFKEY_FIRST_DAY_OF_WEEK, 0) is failed(%d)", ret);
361 item_data->ugd->first_day_of_week = FIRST_DAY_MONDAY;
362 ret = vconf_set_int(CAL_VCONFKEY_FIRST_DAY_OF_WEEK, item_data->ugd->first_day_of_week);
363 c_retm_if(ret != 0,"vconf_set_int(CAL_VCONFKEY_FIRST_DAY_OF_WEEK, 1) is failed(%d)", ret);
366 item_data->ugd->first_day_of_week = FIRST_DAY_SATURDAY;
367 ret = vconf_set_int(CAL_VCONFKEY_FIRST_DAY_OF_WEEK, item_data->ugd->first_day_of_week);
368 c_retm_if(ret != 0,"vconf_set_int(CAL_VCONFKEY_FIRST_DAY_OF_WEEK, 1) is failed(%d)", ret);
375 elm_genlist_item_selected_set(item_data->item,0);
377 realized_list = elm_genlist_realized_items_get(item_data->ugd->genlist);
378 EINA_LIST_FOREACH(realized_list, l, it)
380 item_data = elm_object_item_data_get(it);
384 if ( type == ITEM_FIRST_DAY_OF_WEEK ||
385 type == ITEM_LOCALE_DEFAULT ||
386 type == ITEM_SUNDAY ||
387 type == ITEM_MONDAY ||
388 type == ITEM_SATURDAY) {
389 if ( item_data->index == ITEM_FIRST_DAY_OF_WEEK ||
390 item_data->index == ITEM_LOCALE_DEFAULT ||
391 item_data->index == ITEM_SUNDAY ||
392 item_data->index == ITEM_MONDAY ||
393 item_data->index == ITEM_SATURDAY)
394 elm_genlist_item_update(it);
399 static void __cal_setting_ug_lock_time_zone_check_changed_callback(void *data, Evas_Object *obj, void *event_info)
401 c_retm_if(!data, "data is NULL");
402 c_retm_if(!obj, "obj is NULL");
404 Item_data *item_data = data;
406 c_retm_if(!item_data->ugd, "item_data->ugd is NULL");
407 c_retm_if(!item_data->ugd->genlist, "item_data->ugd->genlist is NULL");
408 c_retm_if(!item_data->ugd->item_time_zone_on_off, "item_data->ugd->item_time_zone_on_off is NULL");
412 if (item_data->ugd->item_time_zone) {
413 elm_object_item_del(item_data->ugd->item_time_zone);
414 item_data->ugd->item_time_zone = NULL;
417 if (item_data->ugd->item_time_zone_guide) {
418 elm_object_item_del(item_data->ugd->item_time_zone_guide);
419 item_data->ugd->item_time_zone_guide = NULL;
422 if(elm_check_state_get(item_data->check)) {
423 item_data->ugd->is_on = 1;
425 ret = vconf_set_int(CAL_VCONFKEY_LOCK_TIMEZONE_ON_OFF,item_data->ugd->is_on);
426 c_retm_if(ret != 0,"vconf_set_int(CAL_VCONFKEY_LOCK_TIMEZONE_ON_OFF, 0) is failed(%d)", ret);
428 __cal_setting_gl_insert_genlist_item(item_data->ugd, item_data->ugd->genlist, item_data->ugd->item_time_zone_on_off, ITEM_TIMEZONE);
430 item_data->ugd->is_on = 0;
432 ret = vconf_set_int(CAL_VCONFKEY_LOCK_TIMEZONE_ON_OFF,item_data->ugd->is_on);
433 c_retm_if(ret != 0,"vconf_set_int(CAL_VCONFKEY_LOCK_TIMEZONE_ON_OFF, 0) is failed(%d)", ret);
435 __cal_setting_gl_insert_genlist_item(item_data->ugd, item_data->ugd->genlist, item_data->ugd->item_time_zone_on_off, ITEM_LOCK_TIMEZONE_GUIDE_TEXT);
439 static void __cal_setting_ug_lock_time_zone_check_select_callback(void *data, Evas_Object *obj, void *event_info)
441 c_retm_if(!data, "data is NULL");
442 c_retm_if(!obj, "obj is NULL");
444 Item_data *item_data = data;
446 elm_check_state_set(item_data->check, !elm_check_state_get(item_data->check));
448 __cal_setting_ug_lock_time_zone_check_changed_callback(data, elm_object_item_widget_get(item_data->item), event_info);
450 elm_genlist_item_selected_set(item_data->item,0);
453 static void __cal_setting_ug_show_week_num_check_select_callback(void *data, Evas_Object *obj, void *event_info)
455 c_retm_if(!data, "data is NULL");
456 c_retm_if(!obj, "obj is NULL");
458 Item_data *item_data = data;
460 elm_check_state_set(item_data->check, !elm_check_state_get(item_data->check));
462 __cal_setting_week_number_on_off_changed_callback(data, elm_object_item_widget_get(item_data->item), event_info);
464 elm_genlist_item_selected_set(item_data->item,0);
467 static void __cal_setting_ug_show_complete_task_check_select_callback(void *data, Evas_Object *obj, void *event_info)
469 c_retm_if(!data, "data is NULL");
470 c_retm_if(!obj, "obj is NULL");
472 Item_data *item_data = data;
474 elm_check_state_set(item_data->check, !elm_check_state_get(item_data->check));
476 __cal_setting_complete_todo_on_off_changed_callback(data, elm_object_item_widget_get(item_data->item), event_info);
478 elm_genlist_item_selected_set(item_data->item,0);
481 static void __cal_setting_genlist_item_select_callback(void *data, Evas_Object *obj, void *event_info)
483 c_retm_if(!data, "data is NULL");
484 c_retm_if(!obj, "obj is NULL");
486 Item_data *item_data = data;
487 elm_genlist_item_selected_set(item_data->item,0);
488 if(0 == elm_genlist_item_expanded_get(item_data->item)) {
489 elm_genlist_item_expanded_set(item_data->item, 1);
491 elm_genlist_item_expanded_set(item_data->item, 0);
495 static void __cal_setting_get_filename(char *fullpath, char *dest, int size_dest)
497 c_retm_if(!fullpath, "fullpath is NULL");
498 c_retm_if(!dest, "dest is NULL");
501 index = strrchr(fullpath, '/');
502 snprintf(dest, size_dest, "%s", index + 1);
505 static void * __cal_setting_import_calendars(void* data)
507 c_retvm_if(!data, NULL, "parameter(data) is NULL");
509 struct ug_data *ugd = data;
511 cal_progress_info *p_info = ugd->p_info;
512 c_retvm_if(!p_info, NULL, "p_info is NULL");
514 char *vcalendar_stream = NULL;
516 struct stat st = {0};
518 FILE * file = fopen(ugd->path, "r");
520 free(vcalendar_stream);
521 ERR("Failed to open file!");
522 p_info->completed = true;
527 if(stat(ugd->path, &st) != 0) {
528 ERR("stat(ugd->path, &st) is fail!");
529 p_info->completed = true;
535 vcalendar_stream = calloc(size + 1, sizeof(char));
536 if (!vcalendar_stream) {
537 ERR("vcalendar_stream is null");
538 p_info->completed = true;
543 ret = fread(vcalendar_stream, 1, size, file);
545 free(vcalendar_stream);
546 ERR("Failed to read file!");
547 p_info->completed = true;
556 calendar_error_e error = CALENDAR_ERROR_NONE;
558 calendar_list_h list = NULL;
560 error = calendar_vcalendar_parse_to_calendar(vcalendar_stream, &list);
561 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_vcalendar_parse_to_calendar() is failed(%x)", error);
563 CAL_FREE(vcalendar_stream);
565 error = calendar_db_insert_records(list, NULL, NULL);
566 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_db_insert_records() is failed(%x)", error);
568 error = calendar_list_destroy(list, true);
569 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_list_destroy() is failed(%x)", error);
571 p_info->completed = true;
577 static void __cal_setting_process_end(struct ug_data *ugd )
579 c_retm_if(!ugd, "parameter(ugd) is NULL");
581 cal_progress_info *p_info = ugd->p_info;
582 c_retm_if(!p_info, "p_info is NULL");
588 static Eina_Bool __cal_setting_backup_import_timer_cb(void *data)
590 c_retvm_if(!data, ECORE_CALLBACK_CANCEL, "parameter(data) is NULL");
592 struct ug_data *ugd = data;
593 cal_progress_info *p_info;
595 p_info = ugd->p_info;
596 c_retvm_if(NULL == p_info , ECORE_CALLBACK_CANCEL, "p_info is NULL");
599 if (!p_info->completed) {
601 if (!p_info->alive) {
602 p_info->result = FALSE;
603 p_info->completed = true;
604 return ECORE_CALLBACK_RENEW;
607 return ECORE_CALLBACK_RENEW;
611 pthread_join(p_info->thread, NULL);
613 if (p_info->result) {
614 if (SETTING_IMPORT_CALENDAR== ugd->setting_mode) {
615 message = C_("IDS_CLD_POP_IMPORTED");
617 message = C_("IDS_CLD_POP_EXPORTED");
620 message = S_("IDS_COM_POP_FAILED");
623 evas_object_del(ugd->popup);
625 __cal_setting_process_end(ugd);
627 cal_util_show_small_information(ugd->layout, message, 1.0);
629 return ECORE_CALLBACK_CANCEL;
633 static void __cal_setting_progress_popup_hide_cb(void *data, Evas_Object *obj, void *event_info)
635 c_retm_if(!data, "data is null");
636 c_retm_if(!obj, "obj is null");
638 Evas_Object *popup = data;
640 if (!strcmp(elm_object_text_get(obj), S_("IDS_COM_SK_CANCEL"))) {
641 bool *is_alive = evas_object_data_get(popup, "data");
645 evas_object_del(popup);
648 Evas_Object* __cal_setting_progressbar_popup(Evas_Object *parent, cal_progress_info *p_info)
650 c_retvm_if(!parent, NULL, "parent is null");
651 c_retvm_if(!p_info, NULL, "p_info is null");
656 Evas_Object *progressbar;
658 popup = cal_util_add_popup(parent, NULL, NULL, NULL,
659 __cal_setting_progress_popup_hide_cb, &p_info->alive, S_("IDS_COM_SK_CANCEL"), NULL);
660 c_retvm_if(!popup, NULL, "cal_util_add_popup() return NULL");
662 layout = cal_util_add_layout(popup, "popup_center_text_progressview");
664 p_info->layout = layout;
666 title = elm_label_add(layout);
667 c_retvm_if(NULL == title, NULL, "elm_label_add() return NULL");
669 elm_object_style_set(title, "popup_description/default");
670 elm_label_line_wrap_set(title, EINA_TRUE);
671 evas_object_size_hint_weight_set(title, EVAS_HINT_EXPAND, 0.0);
672 evas_object_size_hint_align_set(title, EVAS_HINT_FILL, EVAS_HINT_FILL);
673 evas_object_show(title);
674 p_info->label = title;
676 progressbar = elm_progressbar_add(layout);
677 c_retvm_if(NULL == progressbar, NULL, "elm_progressbar_add() return NULL");
679 p_info->progressbar= progressbar;
681 elm_object_part_content_set(layout, "elm.swallow.content", title);
682 elm_object_part_content_set(layout, "elm.swallow.end", progressbar);
683 evas_object_size_hint_align_set(progressbar, 0.5, 0.5);
684 evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
685 elm_progressbar_pulse(progressbar, EINA_TRUE);
687 evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
688 evas_object_show(progressbar);
689 elm_object_content_set(popup, layout);
694 static void __cal_setting_import_calendar_ug_result(ui_gadget_h ug, service_h result, void *data)
696 c_retm_if(!ug, "parameter(ug) is NULL");
697 c_retm_if(!data, "parameter(data) is NULL");
698 c_retm_if(!result, "parameter(result) is NULL");
704 struct ug_data *ugd = data;
705 cal_progress_info *p_info;
706 char title[CAL_TEXT_MAX_LEN];
707 char filepath[CAL_TEXT_SHORT_LEN];
709 ret = service_get_extra_data(result, "result", &val);
710 c_ret_if(ret != SERVICE_ERROR_NONE);
716 ugd->path = strdup((char *)val);
717 c_retm_if(NULL == ugd->path, "strdup() return NULL");
721 p_info = calloc(1, sizeof(cal_progress_info));
722 c_retm_if(!p_info, "calloc() return NULL");
724 ugd->p_info = p_info;
726 p_info->alive = true;
727 p_info->result = TRUE;
728 p_info->completed = false;
729 __cal_setting_get_filename(ugd->path, filepath, sizeof(filepath));
731 snprintf(title, sizeof(title), "%s<br>%s", C_("IDS_CLD_POP_IMPORTING_ING"), filepath);
733 ret = pthread_create(&p_info->thread, NULL, __cal_setting_import_calendars, ugd);
735 ERR("Thread creation failed(%d)", ret);
741 p_info->timer = ecore_timer_add(0.1, __cal_setting_backup_import_timer_cb, ugd);
742 if (NULL == p_info->timer) {
743 ERR("ecore_timer_ada() return NULL");
745 p_info->alive = false;
746 pthread_join(p_info->thread, NULL);
754 ugd->popup = __cal_setting_progressbar_popup(ugd->naviframe, p_info);
755 elm_object_text_set(p_info->label, title);
757 evas_object_smart_callback_add(ugd->popup, "response", __cal_setting_progress_popup_hide_cb, &p_info->alive);
761 static void __cal_setting_import_calendar_myfile_ug(struct ug_data *ugd)
763 c_retm_if(!ugd, "ugd is null");
765 struct ug_cbs cbs = {0};
766 cbs.result_cb = __cal_setting_import_calendar_ug_result;
769 cal_launch_ug_with_var(ugd->ug, CAL_MYFILES_UG, &cbs, "path", "/opt/usr/media/Backup/Calendar", "select_type", "IMPORT", "file_type", "vcs", NULL);
772 static inline void __cal_setting_progress_fail(cal_progress_info *p_info)
774 c_retm_if(!p_info, "parameter(p_info) is NULL");
776 p_info->completed = true;
777 p_info->result = false;
782 static void * __cal_setting_export_calendars(void *data)
784 c_retvm_if(!data, NULL, "parameter(data) is NULL");
786 Eina_Bool ret = EINA_TRUE;
789 calendar_record_h calendar_book;
790 struct ug_data *ugd = data;
791 cal_progress_info *p_info = ugd->p_info;
792 char *vcs_data = NULL;
794 fd = open(ugd->path, O_WRONLY|O_CREAT|O_TRUNC, 0644);
796 ERR("open(%s) Failed(%d)", ugd->path, errno);
797 __cal_setting_progress_fail(p_info);
801 if (ugd->checked_calendar_list == NULL) {
802 c_warn_if(1, "ugd->calendar_list is NULL");
810 calendar_error_e error = CALENDAR_ERROR_NONE;
812 calendar_filter_h filter = NULL;
814 error = calendar_filter_create(_calendar_event._uri, &filter);
815 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_create() is failed(%x)", error);
817 EINA_LIST_FOREACH(ugd->checked_calendar_list, cursor, calendar_book) {
819 error = calendar_record_get_int(calendar_book, _calendar_book.id, &cid);
820 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
822 error = calendar_filter_add_int(filter, _calendar_event.calendar_book_id, CALENDAR_MATCH_EQUAL, cid);
823 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_int() is failed(%x)", error);
825 if (eina_list_next(cursor)) {
826 error = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_OR);
827 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_add_operator() is failed(%x)", error);
832 calendar_query_h query = NULL;
834 error = calendar_query_create(_calendar_event._uri, &query);
835 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_create() is failed(%x)", error);
837 error = calendar_query_set_filter(query, filter);
838 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_add_filter() is failed(%x)", error);
840 calendar_list_h list = NULL;
842 error = calendar_db_get_records_with_query(query, 0, 0, &list);
843 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_db_get_records_with_query() is failed(%x)", error);
845 error = calendar_vcalendar_make_from_records(list, &vcs_data);
846 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_vcalendar_make_from_records() is failed(%x)", error);
848 error = calendar_list_destroy(list, true);
849 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_list_destroy() is failed(%x)", error);
851 error = calendar_query_destroy(query);
852 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_query_destroy() is failed(%x)", error);
854 error = calendar_filter_destroy(filter);
855 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_filter_destroy() is failed(%x)", error);
858 r = write(fd, vcs_data, strlen(vcs_data));
860 ERR("write() is failed.");
862 cal_util_update_media_db(ugd->path);
864 p_info->completed = true;
865 p_info->result = true;
868 __cal_setting_progress_fail(p_info);
875 ERR("fsync() failed(%d)", r);
876 __cal_setting_progress_fail(p_info);
880 if (!p_info->result) {
881 ret = unlink(ugd->path);
883 ERR("unlink(%s) failed(%d)", ugd->path, ret);
884 __cal_setting_progress_fail(p_info);
893 static void __cal_setting_export_myfile_ug_result(ui_gadget_h ug, service_h result, void *data)
895 c_retm_if(!ug, "parameter(ug) is NULL");
896 c_retm_if(!data, "parameter(data) is NULL");
897 c_retm_if(!result, "parameter(result) is NULL");
901 char path[CAL_TEXT_MAX_LEN];
902 char title[CAL_TEXT_MAX_LEN];
903 char filepath[CAL_TEXT_SHORT_LEN];
904 cal_progress_info *p_info;
905 struct ug_data *ugd = data;
907 elm_naviframe_item_pop(ugd->naviframe);
909 c_retm_if(ugd->p_info, "thread is running");
913 ret = service_get_extra_data(result, "result", &val);
914 c_ret_if(ret != SERVICE_ERROR_NONE);
916 p_info = calloc(1, sizeof(cal_progress_info));
917 c_retm_if(NULL == p_info, "calloc() return NULL");
919 ugd->p_info = p_info;
922 snprintf(path, sizeof(path), "%s/calendars.vcs", (char *)val);
926 ugd->path = strdup(path);
928 p_info->alive = true;
929 p_info->result = TRUE;
930 __cal_setting_get_filename(ugd->path, filepath, sizeof(filepath));
931 snprintf(title, sizeof(title), "%s<br>%s", C_("IDS_CLD_POP_EXPORTING_ING"), filepath);
933 ret = pthread_create(&p_info->thread, NULL, __cal_setting_export_calendars, ugd );
935 ERR("Thread creation failed(%d)", ret);
941 p_info->timer = ecore_timer_add(PROGRESS_BAR_TIMER_INTERVAL, __cal_setting_backup_import_timer_cb, ugd);
942 if (NULL == p_info->timer) {
943 ERR("ecore_timer_ada() return NULL");
944 p_info->alive = false;
945 pthread_join(p_info->thread, NULL);
951 ugd->popup = __cal_setting_progressbar_popup(ugd->naviframe, p_info);
952 elm_object_text_set(p_info->label, title);
955 void cal_setting_export_calendar_myfile_ug(struct ug_data *ugd)
958 c_retm_if(!ugd, "ugd is null");
960 struct ug_cbs cbs = {0};
961 cbs.result_cb = __cal_setting_export_myfile_ug_result;
964 cal_launch_ug_with_var(ugd->ug, CAL_MYFILES_UG, &cbs, "path", "/opt/usr/media/Backup/Calendar", "select_type", "EXPORT", "file_type", "FOLDER", NULL);
967 static void __cal_setting_show_export_view(Item_data *item_data)
971 c_retm_if(!item_data, "item_data is null");
973 struct ug_data *ugd = item_data->ugd;
974 c_retm_if(!ugd, "ugd is null");
976 cal_setting_export_create_view(ugd);
979 static void __cal_setting_genlist_item_import_export_select_callback(void *data, Evas_Object *obj, void *event_info)
981 c_retm_if(!data, "data is null");
983 Item_data *item_data = data;
984 elm_genlist_item_selected_set(item_data->item,0);
985 item_type type = item_data->index;
987 case ITEM_IMPORT_CALENDARS:
989 item_data->ugd->setting_mode = SETTING_IMPORT_CALENDAR;
991 __cal_setting_import_calendar_myfile_ug(item_data->ugd);
993 case ITEM_EXPORT_CALENDARS:
995 item_data->ugd->setting_mode = SETTING_EXPORT_CALENDAR;
997 __cal_setting_show_export_view(item_data);
1004 static void __cal_setting_complete_todo_on_off_changed_callback(void *data, Evas_Object *obj, void *event_info)
1006 c_retm_if(!data, "data is null");
1008 Item_data *item_data = data;
1010 if (elm_check_state_get(item_data->check)) {
1011 item_data->ugd->is_complete_todo = 1;
1012 ret = vconf_set_int(CAL_VCONFKEY_COMPLETE_TODO_ON_OFF,item_data->ugd->is_complete_todo);
1013 c_retm_if(ret != 0,"vconf_set_int(CAL_VCONFKEY_COMPLETE_TODO_ON_OFF, 0) is failed(%d)", ret);
1015 item_data->ugd->is_complete_todo = 0;
1016 ret = vconf_set_int(CAL_VCONFKEY_COMPLETE_TODO_ON_OFF,item_data->ugd->is_complete_todo);
1017 c_retm_if(ret != 0,"vconf_set_int(CAL_VCONFKEY_COMPLETE_TODO_ON_OFF, 0) is failed(%d)", ret);
1021 static void __cal_setting_week_number_on_off_changed_callback(void *data, Evas_Object *obj, void *event_info)
1023 c_retm_if(!data, "data is null");
1025 Item_data *item_data = data;
1028 c_retm_if(!item_data->check, "item_data->check is null");
1030 if (elm_check_state_get(item_data->check)) {
1031 item_data->ugd->is_display_weeknumber= 1;
1032 ret = vconf_set_int(CAL_VCONFKEY_WEEK_NMUBER_ON_OFF ,item_data->ugd->is_display_weeknumber);
1033 c_retm_if(ret != 0,"vconf_set_int(CAL_VCONFKEY_WEEK_NMUBER_ON_OFF, 0) is failed(%d)", ret);
1035 item_data->ugd->is_display_weeknumber= 0;
1036 ret = vconf_set_int(CAL_VCONFKEY_WEEK_NMUBER_ON_OFF,item_data->ugd->is_display_weeknumber);
1037 c_retm_if(ret != 0,"vconf_set_int(CAL_VCONFKEY_WEEK_NMUBER_ON_OFF, 0) is failed(%d)", ret);
1041 static Evas_Object *__cal_setting_ug_get_genlist_item_icon(void *data, Evas_Object *obj, const char *part)
1043 c_retvm_if(!data, NULL, "data is null");
1044 c_retvm_if(!obj, NULL, "obj is null");
1046 Evas_Object *eo_begin = NULL;
1047 Item_data *item_data = data;
1048 item_type type = item_data->index;
1050 if (!CAL_STRCMP(part, "elm.icon")) {
1051 eo_begin = elm_radio_add(obj);
1053 case ITEM_LOCK_TIMEZONE_ON_OFF:
1054 eo_begin = elm_check_add(obj);
1055 elm_check_state_set(eo_begin, item_data->ugd->is_on);
1056 elm_object_style_set(eo_begin, "on&off");
1057 evas_object_propagate_events_set(eo_begin, EINA_FALSE);
1058 item_data->check = eo_begin;
1059 evas_object_smart_callback_add(eo_begin, "changed", __cal_setting_ug_lock_time_zone_check_changed_callback, item_data);
1061 case ITEM_LOCALE_DEFAULT:
1062 if (FIRST_DAY_LOCALE_DEFAULT == item_data->ugd->first_day_of_week) {
1063 elm_radio_state_value_set(eo_begin, 0);
1065 elm_radio_state_value_set(eo_begin, -1);
1069 if (FIRST_DAY_SUNDAY == item_data->ugd->first_day_of_week) {
1070 elm_radio_state_value_set(eo_begin, 0);
1072 elm_radio_state_value_set(eo_begin, -1);
1076 if (FIRST_DAY_MONDAY == item_data->ugd->first_day_of_week) {
1077 elm_radio_state_value_set(eo_begin, 0);
1079 elm_radio_state_value_set(eo_begin, -1);
1083 if (FIRST_DAY_SATURDAY == item_data->ugd->first_day_of_week) {
1084 elm_radio_state_value_set(eo_begin, 0);
1086 elm_radio_state_value_set(eo_begin, -1);
1089 case ITEM_WEEK_NUMBER_ON_OFF:
1090 eo_begin = elm_check_add(obj);
1091 c_retvm_if(!eo_begin , NULL, "eo_begin is null");
1093 elm_check_state_set(eo_begin, item_data->ugd->is_display_weeknumber);
1094 elm_object_style_set(eo_begin, "on&off");
1095 evas_object_propagate_events_set(eo_begin, EINA_FALSE);
1096 item_data->check = eo_begin;
1097 evas_object_smart_callback_add(eo_begin, "changed", __cal_setting_week_number_on_off_changed_callback, item_data);
1099 case ITEM_COMPLETED_TO_DO_ON_OFF:
1100 eo_begin = elm_check_add(obj);
1101 elm_check_state_set(eo_begin, item_data->ugd->is_complete_todo);
1102 elm_object_style_set(eo_begin, "on&off");
1103 evas_object_propagate_events_set(eo_begin, EINA_FALSE);
1104 item_data->check = eo_begin;
1105 evas_object_smart_callback_add(eo_begin, "changed", __cal_setting_complete_todo_on_off_changed_callback, item_data);
1110 elm_radio_group_add(eo_begin, item_data->rgd);
1112 item_data->check = eo_begin;
1117 static void __cal_setting_ug_time_zone_ug_destroy_callback(ui_gadget_h ug, void *priv)
1120 c_retm_if(!priv, "priv is null");
1122 Item_data *item_data = priv;
1123 elm_genlist_item_selected_set(item_data->item,0);
1128 static void __cal_setting_ug_time_zone_ug_result_callback(ui_gadget_h ug, service_h result, void *priv)
1132 c_retm_if(!priv, "priv is null");
1134 Item_data *item_data = priv;
1138 int ret = service_get_extra_data(result, "city", &city);
1139 c_ret_if(ret != SERVICE_ERROR_NONE);
1141 char *timezone = NULL;
1143 ret = service_get_extra_data(result, "timezone", &timezone);
1144 c_ret_if(ret != SERVICE_ERROR_NONE);
1146 char *tzpath = NULL;
1148 ret = service_get_extra_data(result, "tzpath", &tzpath);
1149 c_ret_if(ret != SERVICE_ERROR_NONE);
1151 if (item_data->ugd->city)
1152 free(item_data->ugd->city);
1154 item_data->ugd->city = strdup(city);
1155 c_retm_if(!item_data->ugd->city, "item_data->ugd->city is null");
1157 item_data->ugd->time_zone = g_strdup_printf("GMT%s", timezone);
1158 c_retm_if(!item_data->ugd->time_zone, "item_data->ugd->time_zone is null");
1160 elm_genlist_item_update(item_data->item);
1162 ret = vconf_set_str(CAL_VCONFKEY_LOCK_TIMEZONE_PATH, tzpath);
1163 c_warn_if(ret, "vconf_set_str(CAL_VCONFKEY_LOCK_TIMEZONE_PATH, tzpath) is failed");
1165 ret = vconf_set_str(CAL_VCONFKEY_LOCK_TIMEZONE_CITY, city);
1166 c_warn_if(ret, "vconf_set_str(CAL_VCONFKEY_LOCK_TIMEZONE_CITY, tzpath) is failed");
1168 ret = vconf_set_str(CAL_VCONFKEY_LOCK_TIMEZONE_OFFSET, timezone);
1169 c_warn_if(ret, "vconf_set_str(CAL_VCONFKEY_LOCK_TIMEZONE_OFFSET, tzpath) is failed");
1176 static void __cal_setting_ug_time_zone_ug_layout_callback(ui_gadget_h ug, enum ug_mode mode, void *priv)
1179 c_retm_if(!ug, "ug is null");
1183 base = ug_get_layout(ug);
1190 case UG_MODE_FULLVIEW:
1191 evas_object_show(base);
1194 DBG("Unsupported ug layout");
1199 static void __cal_setting_ug_create_time_zone_ug(void *data, Evas_Object *obj, void *event_info)
1201 c_retm_if(!data, "data is null");
1203 Item_data *item_data = data;
1207 memset(&uc, 0, sizeof(struct ug_cbs));
1208 uc.destroy_cb = __cal_setting_ug_time_zone_ug_destroy_callback;
1209 uc.layout_cb = __cal_setting_ug_time_zone_ug_layout_callback;
1210 uc.result_cb = __cal_setting_ug_time_zone_ug_result_callback;
1211 uc.priv = item_data;
1213 ug_create(NULL, "worldclock-efl", UG_MODE_FULLVIEW, NULL, &uc);
1217 static Elm_Object_Item *__cal_setting_ug_add_genlist_item(struct ug_data *ugd, Evas_Object *genlist,Eina_Bool is_seperator,int index)
1219 c_retvm_if(!ugd, NULL, "ugd is null");
1220 c_retvm_if(!genlist, NULL, "genlist is null");
1222 Elm_Object_Item *item = NULL;
1223 Item_data *item_data = NULL;
1226 item = elm_genlist_item_append(genlist, &itc_seperator, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1227 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1229 item_data = calloc(1, sizeof(Item_data));
1230 c_retvm_if(!item_data, NULL, "item_data is null");
1232 item_data->ugd = ugd;
1235 case ITEM_LOCK_TIMEZONE_ON_OFF:
1236 item_data->index = index;
1237 item_data->item = elm_genlist_item_append(genlist, &itc_lock_tz, item_data, NULL, ELM_GENLIST_ITEM_NONE, __cal_setting_ug_lock_time_zone_check_select_callback, item_data);
1238 ugd->item_time_zone_on_off = item_data->item;
1240 case ITEM_LOCK_TIMEZONE_GUIDE_TEXT:
1242 item_data->index = index;
1243 item_data->item = elm_genlist_item_append(genlist, &itc_lock_tz_guide, item_data, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1244 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1245 ugd->item_time_zone_guide = item_data->item;
1253 item_data->index = index;
1254 item_data->item = elm_genlist_item_append(genlist, &itc_tz, item_data, NULL, ELM_GENLIST_ITEM_NONE, __cal_setting_ug_create_time_zone_ug, item_data);
1255 ugd->item_time_zone = item_data->item;
1261 case ITEM_FIRST_DAY_OF_WEEK:
1262 item_data->index = index;
1263 item_data->item = elm_genlist_item_append(genlist, &itc, item_data, NULL, ELM_GENLIST_ITEM_TREE, __cal_setting_genlist_item_select_callback, item_data);
1264 ugd->rgd_first_day = elm_radio_add((Evas_Object *)(item_data->item));
1265 elm_radio_state_value_set(ugd->rgd_first_day, -1);
1270 case ITEM_LOCALE_DEFAULT:
1271 item_data->index = index;
1272 item_data->item = elm_genlist_item_append(genlist, &itc_radio, item_data, ugd->item_first_day_of_week, ELM_GENLIST_ITEM_NONE, __cal_setting_ug_radio_changed_callback, item_data);
1273 item_data->rgd = ugd->rgd_first_day;
1275 case ITEM_WEEK_NUMBER_ON_OFF:
1276 item_data->index = index;
1277 item_data->item = elm_genlist_item_append(genlist, &itc_lock_tz, item_data, NULL, ELM_GENLIST_ITEM_NONE, __cal_setting_ug_show_week_num_check_select_callback, item_data);
1279 case ITEM_COMPLETED_TO_DO_ON_OFF:
1280 item_data->index = index;
1281 item_data->item = elm_genlist_item_append(genlist, &itc_lock_tz, item_data, NULL, ELM_GENLIST_ITEM_NONE, __cal_setting_ug_show_complete_task_check_select_callback, item_data);
1283 case ITEM_IMPORT_CALENDARS:
1284 case ITEM_EXPORT_CALENDARS:
1285 item_data->index = index;
1286 item_data->item = elm_genlist_item_append(genlist, &itc_import, item_data, NULL, ELM_GENLIST_ITEM_NONE, __cal_setting_genlist_item_import_export_select_callback, item_data);
1294 item = item_data->item;
1301 static void __cal_setting_ug_genlist_item_expand_callback(void *data, Evas_Object *obj, void *event_info)
1303 c_retm_if(!data, "data is null");
1304 c_retm_if(!event_info, "event_info is null");
1306 struct ug_data *ugd = data;
1307 Elm_Object_Item *it = event_info;
1308 Evas_Object *gl = elm_object_item_widget_get(it);
1310 if (it == ugd->item_first_day_of_week) {
1312 __cal_setting_ug_add_genlist_item(ugd, gl, EINA_FALSE, ITEM_LOCALE_DEFAULT);
1313 __cal_setting_ug_add_genlist_item(ugd, gl, EINA_FALSE, ITEM_SATURDAY);
1314 __cal_setting_ug_add_genlist_item(ugd, gl, EINA_FALSE, ITEM_SUNDAY);
1315 __cal_setting_ug_add_genlist_item(ugd, gl, EINA_FALSE, ITEM_MONDAY);
1319 static void __cal_setting_ug_genlist_item_contract_callback(void *data, Evas_Object *obj, void *event_info)
1321 c_retm_if(!event_info, "event_info is null");
1323 Elm_Object_Item *item = event_info;
1324 elm_genlist_item_subitems_clear(item);
1327 Evas_Object* cal_setting_ug_create_view(Evas_Object *navi, struct ug_data *ugd)
1329 c_retv_if(!navi, NULL);
1330 c_retv_if(!ugd, NULL);
1332 Evas_Object *layout = cal_util_add_layout(navi, "selectioninfo");
1333 c_retv_if(!layout, NULL);
1335 Evas_Object *genlist = elm_genlist_add(layout);
1336 c_retvm_if(!genlist, NULL, "genlist is null");
1338 elm_genlist_clear(genlist);
1339 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1341 ugd->genlist = genlist;
1343 __cal_setting_ug_add_genlist_item(ugd,genlist,EINA_TRUE, 0);
1344 __cal_setting_ug_add_genlist_item(ugd,genlist,EINA_FALSE,ITEM_LOCK_TIMEZONE_ON_OFF);
1345 __cal_setting_ug_add_genlist_item(ugd,genlist,EINA_FALSE,ITEM_LOCK_TIMEZONE_GUIDE_TEXT);
1346 __cal_setting_ug_add_genlist_item(ugd,genlist,EINA_FALSE,ITEM_TIMEZONE);
1348 __cal_setting_ug_add_genlist_item(ugd,genlist,EINA_TRUE,0);
1349 ugd->item_first_day_of_week = __cal_setting_ug_add_genlist_item(ugd,genlist,EINA_FALSE,ITEM_FIRST_DAY_OF_WEEK);
1351 __cal_setting_ug_add_genlist_item(ugd, genlist, EINA_TRUE, 0);
1352 __cal_setting_ug_add_genlist_item(ugd,genlist, EINA_FALSE, ITEM_WEEK_NUMBER_ON_OFF);
1354 __cal_setting_ug_add_genlist_item(ugd, genlist, EINA_TRUE, 0);
1355 __cal_setting_ug_add_genlist_item(ugd,genlist, EINA_FALSE, ITEM_COMPLETED_TO_DO_ON_OFF);
1357 __cal_setting_ug_add_genlist_item(ugd,genlist,EINA_TRUE, 0);
1358 __cal_setting_ug_add_genlist_item(ugd,genlist,EINA_FALSE,ITEM_IMPORT_CALENDARS);
1359 __cal_setting_ug_add_genlist_item(ugd,genlist,EINA_FALSE,ITEM_EXPORT_CALENDARS);
1361 __cal_setting_ug_add_genlist_item(ugd, genlist, EINA_TRUE, 0);
1363 evas_object_smart_callback_add(genlist, "expanded", __cal_setting_ug_genlist_item_expand_callback, ugd);
1364 evas_object_smart_callback_add(genlist, "contracted", __cal_setting_ug_genlist_item_contract_callback, ugd);
1366 elm_object_part_content_set(layout, "gen.swallow.contents", genlist);
1371 static void __cal_setting_gl_insert_genlist_item(struct ug_data *ugd, Evas_Object *genlist, Elm_Object_Item *item_after, int index)
1373 c_retm_if(!ugd, "ugd is NULL");
1374 c_retm_if(!genlist, "genlist is NULL");
1375 c_retm_if(!item_after, "item_after is NULL");
1377 Item_data *item_data = calloc(1, sizeof(Item_data));
1378 c_retm_if(!item_data, "item_data is NULL");
1380 item_data->ugd = ugd;
1385 item_data->index = index;
1386 item_data->item = elm_genlist_item_insert_after(genlist, &itc_tz, item_data, NULL, item_after, ELM_GENLIST_ITEM_NONE, __cal_setting_ug_create_time_zone_ug, item_data);
1387 ugd->item_time_zone = item_data->item;
1392 case ITEM_LOCK_TIMEZONE_GUIDE_TEXT:
1394 item_data->index = index;
1395 item_data->item = elm_genlist_item_insert_after(genlist, &itc_lock_tz_guide, item_data, NULL, item_after, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1396 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1397 ugd->item_time_zone_guide = item_data->item;