[misc] Sync from master branch.
[apps/core/preloaded/calendar.git] / ug / edit / edit-ug.c
index efc3f4f..ba9a560 100755 (executable)
 #include "external-ug.h"
 #include "cld-images.h"
 #include "dialogue.h"
+#include "appcontrol.h"
 
 #define INVALID_TIMEZONE_VALUE (100)
 #define CAL_EDIT_UG_MAX_ATTACHMENT_COUNT 6
 
 typedef struct {
 
+       Elm_Theme *theme;
+
        ui_gadget_h ug;
        cal_appcontrol_item_type item_type;
 
@@ -43,6 +46,7 @@ typedef struct {
        Evas_Object *base_layout;
        Evas_Object *naviframe;
        Evas_Object *window;
+       Evas_Object *conformant;
 
        Evas_Object *parent;
        Evas_Object *popup;
@@ -165,9 +169,6 @@ static int __cal_edit_ug_finish(cal_edit_ug_data *data)
        error = calendar_disconnect();
        c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_disconnect() is failed(%x)", error);
 
-       elm_theme_extension_del(NULL, EDJDIR "/calendar_theme.edj");
-       elm_theme_extension_del(NULL, EDJDIR "/calendar_theme2.edj");
-
        cal_util_disconnect_pattern_generator();
 
        int ret = 0;
@@ -1127,15 +1128,15 @@ static void __cal_edit_ug_title_entry_changed_callback(void *data, Evas_Object *
                __cal_edit_ug_set_record_title(p->event, p->title_str);
 }
 
-static Evas_Object * __cal_edit_ug_title_icon(cal_edit_ug_data* p, Evas_Object *obj)
+static Evas_Object * __cal_edit_ug_title_item(cal_edit_ug_data* p, Evas_Object *obj)
 {
        c_retv_if(!p, NULL);
        c_retv_if(!obj, NULL);
 
-       Evas_Object *ef = cal_util_add_edit_field(obj, S_("IDS_COM_BODY_DETAILS_TITLE"), EINA_FALSE, EINA_TRUE);
+       Evas_Object *ef = cal_util_add_edit_field(obj, NULL, S_("IDS_COM_BODY_DETAILS_TITLE"), EINA_FALSE, EINA_TRUE, EINA_FALSE);
        c_retvm_if(!ef, NULL, "ef is null");
 
-       Evas_Object *entry = elm_object_part_content_get(ef, "elm.swallow.content");
+       Evas_Object *entry = elm_object_part_content_get(ef, "elm.icon.entry");
        c_retvm_if(!entry, ef, "entry is null");
 
        elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
@@ -1150,8 +1151,6 @@ static Evas_Object * __cal_edit_ug_title_icon(cal_edit_ug_data* p, Evas_Object *
        evas_object_smart_callback_add(p->title_entry, "changed", __cal_edit_ug_title_entry_changed_callback, p);
        evas_object_smart_callback_add(p->title_entry, "preedit,changed", __cal_edit_ug_title_entry_changed_callback, p);
 
-       cal_save_cancel_set_input_panel_callback_for_ug(p->save_cancel, p->title_entry);
-
        return ef;
 
 }
@@ -1160,23 +1159,23 @@ static void __cal_edit_ug_update_title_language(Evas_Object *item)
 {
        c_ret_if(!item);
 
-       Evas_Object *edit_field = elm_object_part_content_get(item, "elm.icon");
-       c_ret_if(!edit_field);
+       Evas_Object *entry = elm_object_part_content_get(item, "elm.icon.entry");
+       c_retm_if(!entry, "entry is null");
 
-       elm_object_part_text_set(edit_field, "elm.guidetext", S_("IDS_COM_BODY_DETAILS_TITLE"));
+       elm_object_part_text_set(entry, "elm.guide", S_("IDS_COM_BODY_DETAILS_TITLE"));
 }
 
 static Evas_Object *__cal_edit_ug_add_title(cal_edit_ug_data* p)
 {
        c_retv_if(!p, NULL);
 
-       Evas_Object *item = cal_dialogue_append_item(p->dialogue, "1icon", NULL, NULL);
-       c_retvm_if(!item, NULL, "cal_dialogue_append_item() is failed");
+       Evas_Object *item = __cal_edit_ug_title_item(p, p->dialogue);
+       c_retvm_if(!item, NULL, "__cal_edit_ug_title_item() is failed");
 
-       Evas_Object *editfield = __cal_edit_ug_title_icon(p, item);
-       c_retvm_if(!editfield, NULL, "__cal_edit_ug_title_icon() is failed");
-
-       elm_object_part_content_set(item, "elm.icon", editfield);
+       evas_object_size_hint_weight_set(item, EVAS_HINT_EXPAND, 0.0);
+       evas_object_size_hint_align_set(item, EVAS_HINT_FILL, 0.0);
+       elm_box_pack_end(p->dialogue, item);
+       evas_object_show(item);
 
        return item;
 }
@@ -1211,15 +1210,16 @@ static Evas_Object * __cal_edit_ug_location_icon(cal_edit_ug_data* p, Evas_Objec
 
        Evas_Object *ly = NULL;
 
-       Evas_Object *ef = cal_util_add_edit_field(obj, C_("IDS_COM_BODY_DETAILS_LOCATION"), EINA_FALSE, EINA_TRUE);
+       Evas_Object *ef = cal_util_add_edit_field(obj, NULL, C_("IDS_COM_BODY_DETAILS_LOCATION"), EINA_FALSE, EINA_TRUE, EINA_TRUE);
        ly = ef;
 
-       p->location_entry = elm_object_part_content_get(ef, "elm.swallow.content");
+       p->location_entry = elm_object_part_content_get(ef, "elm.icon.entry");
        c_retv_if(!p->location_entry, ly);
 
        evas_object_smart_callback_add(p->location_entry, "changed", __cal_edit_ug_location_entry_changed_callback, p);
        evas_object_smart_callback_add(p->location_entry, "preedit,changed", __cal_edit_ug_location_entry_changed_callback, p);
-       cal_save_cancel_set_input_panel_callback_for_ug(p->save_cancel, p->location_entry);
+
+       elm_entry_cursor_end_set(p->location_entry);
 
        elm_entry_cnp_mode_set(p->location_entry, ELM_CNP_MODE_PLAINTEXT);
 
@@ -1241,12 +1241,11 @@ static void __cal_edit_ug_update_location_language(Evas_Object *item)
        Evas_Object *edit_field = elm_object_part_content_get(layout, "editfield/sw");
        c_ret_if(!edit_field);
 
-       elm_object_part_text_set(edit_field, "elm.guidetext", C_("IDS_COM_BODY_DETAILS_LOCATION"));
+       Evas_Object *entry = elm_object_part_content_get(edit_field, "elm.icon.entry");
+       c_retm_if(!entry, "entry is null");
 
-       Evas_Object *button = elm_object_part_content_get(layout, "button/sw");
-       c_ret_if(!button);
+       elm_object_part_text_set(entry, "elm.guide", C_("IDS_COM_BODY_DETAILS_LOCATION"));
 
-       elm_object_text_set(button, C_("IDS_LBS_BODY_MAP"));
 }
 
 static Evas_Object *__cal_edit_ug_add_location(cal_edit_ug_data* p)
@@ -1305,15 +1304,15 @@ static void __cal_edit_ug_note_entry_changed_callback(void *data, Evas_Object *o
 }
 
 
-static Evas_Object * __cal_edit_ug_note_icon(cal_edit_ug_data* p, Evas_Object *obj)
+static Evas_Object * __cal_edit_ug_note_item(cal_edit_ug_data* p, Evas_Object *obj)
 {
        c_retv_if(!p, NULL);
        c_retv_if(!obj, NULL);
 
-       Evas_Object *ef = cal_util_add_edit_field(obj, C_("IDS_CLD_BODY_CREATE_DESCRITION"), EINA_FALSE, EINA_TRUE );
+       Evas_Object *ef = cal_util_add_edit_field(obj, NULL, C_("IDS_CLD_BODY_CREATE_DESCRITION"), EINA_FALSE, EINA_TRUE, EINA_FALSE);
 
        if (ef) {
-               Evas_Object *entry = elm_object_part_content_get(ef, "elm.swallow.content");
+               Evas_Object *entry = elm_object_part_content_get(ef, "elm.icon.entry");
                c_retvm_if(!entry, ef, "entry is null");
 
                evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -1350,7 +1349,7 @@ static Evas_Object * __cal_edit_ug_note_icon(cal_edit_ug_data* p, Evas_Object *o
 
                evas_object_smart_callback_add(p->note_entry, "changed", __cal_edit_ug_note_entry_changed_callback, p);
                evas_object_smart_callback_add(p->note_entry, "preedit,changed", __cal_edit_ug_note_entry_changed_callback, p);
-               cal_save_cancel_set_input_panel_callback_for_ug(p->save_cancel, p->note_entry);
+               elm_entry_cursor_end_set(p->note_entry);
 
                return ef;
        }
@@ -1362,24 +1361,24 @@ static void __cal_edit_ug_update_description_language(Evas_Object *item)
 {
        c_ret_if(!item);
 
-       Evas_Object *edit_field = elm_object_part_content_get(item, "elm.icon");
-       c_ret_if(!edit_field);
+       Evas_Object *entry = elm_object_part_content_get(item, "elm.icon.entry");
+       c_retm_if(!entry, "entry is null");
+
+       elm_object_part_text_set(entry, "elm.guide", C_("IDS_CLD_BODY_CREATE_DESCRITION"));
 
-       elm_object_part_text_set(edit_field, "elm.guidetext", C_("IDS_CLD_BODY_CREATE_DESCRITION"));
 }
 
 static Evas_Object *__cal_edit_ug_add_note(cal_edit_ug_data* p)
 {
        c_retv_if(!p, NULL);
 
-       Evas_Object *item = cal_dialogue_append_item(p->dialogue, "1icon",  NULL, NULL);
-       c_retvm_if(!item, NULL, "cal_dialogue_append_item() is failed");
-
-       Evas_Object *editfield = __cal_edit_ug_note_icon(p, item);
-       c_retvm_if(!editfield, NULL, "__cal_edit_ug_location_icon() is failed");
-
+       Evas_Object *item = __cal_edit_ug_note_item(p, p->dialogue);
+       c_retvm_if(!item, NULL, "__cal_edit_ug_note_item() is failed");
 
-       elm_object_part_content_set(item, "elm.icon", editfield);
+       evas_object_size_hint_weight_set(item, EVAS_HINT_EXPAND, 0.0);
+       evas_object_size_hint_align_set(item, EVAS_HINT_FILL, 0.0);
+       elm_box_pack_end(p->dialogue, item);
+       evas_object_show(item);
 
        return item;
 }
@@ -1481,8 +1480,8 @@ static void __cal_edit_ug_end_date_changed_callback(void *data, Evas_Object* obj
 
        Eina_Bool result = __cal_edit_ug_check_date_validity(p);
        if(!result)     {
-               int r = status_message_post(C_("IDS_CLD_POP_END_TIME_SHOULD_BE_SET_AFTER_START_TIME"));
-               c_warn_if(r != STATUS_ERROR_NONE, "status_message_post() is failed(%d)", r);
+               int r = notification_status_message_post(C_("IDS_CLD_POP_END_TIME_SHOULD_BE_SET_AFTER_START_TIME"));
+               c_warn_if(r != NOTIFICATION_ERROR_NONE, "notification_status_message_post() is failed(%d)", r);
        } else
                __cal_edit_ug_set_record_time(p, p->event);
 
@@ -1840,7 +1839,7 @@ static void __cal_edit_ug_alarm_select_callback(Evas_Object *obj, void *data)
        else
                alarm_type = ALARM_TYPE_TODO;
 
-       cal_edit_alarm_create_view(p->naviframe, reminder, alarm_type, __cal_edit_ug_alarm_changed_callback, obj);
+       cal_edit_alarm_create_view(p->window, p->conformant, p->naviframe, reminder, alarm_type, __cal_edit_ug_alarm_changed_callback, obj);
 
 }
 
@@ -2113,7 +2112,7 @@ static void __cal_edit_ug_repeat_select_callback(Evas_Object *obj, void *data)
 
        cal_edit_ug_data* p = data;
 
-       p->repeat_layout = cal_edit_repeat_create_view(p->naviframe, p->repeat_freq, p->repeat_range, &(p->stm), &(p->repeat_until),&(p->repeat_count),
+       p->repeat_layout = cal_edit_repeat_create_view(p->window, p->conformant, p->naviframe, p->repeat_freq, p->repeat_range, &(p->stm), &(p->repeat_until),&(p->repeat_count),
                        (cal_edit_repeat_destroy_callback)__cal_edit_ug_repeat_callback, p);
        c_retm_if(!p->repeat_layout, "p->repeat_layout is null");
 
@@ -2860,8 +2859,8 @@ static void __cal_edit_ug_save_button_callback(void *data, Evas_Object *obj, voi
 
        c_retm_if(record_index < 0, "cal_edit_save() is failed");
 
-       int r = status_message_post(S_("IDS_COM_POP_SAVED"));
-       c_warn_if(r != STATUS_ERROR_NONE, "status_message_post() is failed(%d)", r);
+       int r = notification_status_message_post(S_("IDS_COM_POP_SAVED"));
+       c_warn_if(r != NOTIFICATION_ERROR_NONE, "notification_status_message_post() is failed(%d)", r);
 
        __cal_edit_ug_send_result_to_detail_ug(p, record_index);
 
@@ -2869,6 +2868,47 @@ static void __cal_edit_ug_save_button_callback(void *data, Evas_Object *obj, voi
 
 }
 
+static Eina_Bool __cal_edit_ug_input_panel_is_shown(cal_edit_ug_data *p)
+{
+       c_retv_if(!p, EINA_FALSE);
+
+       Ecore_IMF_Context* ic = NULL;
+       ic = elm_entry_imf_context_get(p->title_entry);
+       c_retvm_if(!ic, EINA_FALSE, "elm_entry_imf_context_get returned null");
+
+       if(ecore_imf_context_input_panel_state_get(ic) == ECORE_IMF_INPUT_PANEL_STATE_SHOW)     {
+               ecore_imf_context_input_panel_hide(ic);
+               return EINA_TRUE;
+       }
+
+       ic = elm_entry_imf_context_get(p->note_entry);
+       c_retvm_if(!ic, EINA_FALSE, "elm_entry_imf_context_get returned null");
+
+       if(ecore_imf_context_input_panel_state_get(ic) == ECORE_IMF_INPUT_PANEL_STATE_SHOW)     {
+               ecore_imf_context_input_panel_hide(ic);
+               return EINA_TRUE;
+       }
+
+       ic = elm_entry_imf_context_get(p->location_entry);
+       c_retvm_if(!ic, EINA_FALSE, "elm_entry_imf_context_get returned null");
+
+       if(ecore_imf_context_input_panel_state_get(ic) == ECORE_IMF_INPUT_PANEL_STATE_SHOW)     {
+               ecore_imf_context_input_panel_hide(ic);
+               return EINA_TRUE;
+       }
+
+       if(p->multibuttonentry){
+               ic = elm_entry_imf_context_get(elm_multibuttonentry_entry_get(p->multibuttonentry));
+               c_retvm_if(!ic, EINA_FALSE, "elm_entry_imf_context_get returned null");
+
+               if(ecore_imf_context_input_panel_state_get(ic) == ECORE_IMF_INPUT_PANEL_STATE_SHOW)     {
+                       ecore_imf_context_input_panel_hide(ic);
+                       return EINA_TRUE;
+               }
+       }
+
+       return EINA_FALSE;
+}
 
 static void __cal_edit_ug_back_button_callback(void *user_data, Evas_Object *obj, void *ei)
 {
@@ -2880,7 +2920,8 @@ static void __cal_edit_ug_back_button_callback(void *user_data, Evas_Object *obj
 
        c_ret_if(!data->ug);
 
-       ug_destroy_me(data->ug);
+       if(!__cal_edit_ug_input_panel_is_shown(data))
+               ug_destroy_me(data->ug);
 }
 
 static void __cal_edit_ug_show_multi_alarms (cal_edit_ug_data *p)
@@ -3237,7 +3278,7 @@ static void __cal_edit_ug_add_toolbar(cal_edit_ug_data *data, Evas_Object *scrol
 
        __cal_edit_ug_update_naviframe_language(data);
 
-       data->save_cancel = cal_save_cancel_create(data->naviframe, NULL, __cal_edit_ug_save_button_callback, __cal_edit_ug_back_button_callback, data);
+       data->save_cancel = cal_save_cancel_create(data->window, data->conformant, data->naviframe, __cal_edit_ug_save_button_callback, __cal_edit_ug_back_button_callback, data);
 
 }
 
@@ -3341,129 +3382,159 @@ static calendar_record_h inline __cal_edit_ug_get_origin_record(const calendar_r
        return _calendar_get_record_with_index(index);
 }
 
-static void *__cal_edit_ug_create_callback(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv)
+static void __cal_edit_ug_get_appcontrol_input_data(service_h service, cal_edit_ug_data *data)
 {
        CAL_FN_START;
 
-       c_retv_if(!ug, NULL);
-       c_retv_if(!service, NULL);
-       c_retv_if(!priv, NULL);
-       c_retv_if(mode != UG_MODE_FULLVIEW, NULL);
+       int r = 0;
+       char *index = 0;
+       char *item_type = NULL;
 
-       cal_edit_ug_data *data = priv;
+       r = service_get_extra_data(service, CAL_APPCONTROL_ITEM_TYPE, &item_type);
+       c_ret_if(r != SERVICE_ERROR_NONE);
 
-       data->ug = ug;
+       if (CAL_STRCMP(CAL_APPCONTROL_ITEM_TYPE_EVENT, item_type)
+               && CAL_STRCMP(CAL_APPCONTROL_ITEM_TYPE_TODO, item_type)) {
+               ERR("Invaild input : %s, %s", CAL_APPCONTROL_ITEM_TYPE, item_type);
 
-       int cid = 0;
-       char *item_type = NULL;
-       char *index = NULL;
-       char *path = NULL;
-       calendar_error_e error = CALENDAR_ERROR_NONE;
+               CAL_FREE(item_type);
+
+               return;
+       }
 
-       int r = service_get_extra_data(service, "index", &index);
+       CAL_FREE(item_type);
 
-       if (r == SERVICE_ERROR_NONE)
-               cid = atoi(index);
+       r = service_get_extra_data(service, CAL_APPCONTROL_ITEM_ID, &index);
+       if (r != SERVICE_ERROR_NONE) {
+               ERR("service_get_extra_data(%s) is failed(%x)", "eventId", r);
 
-       r = service_get_extra_data(service, CAL_APPCONTROL_ITEM_TYPE, &item_type);
+               CAL_FREE(index);
+
+               return;
+       }
+
+       data->is_edit_mode = EINA_TRUE;
+       data->record = _calendar_get_record_with_index(atoi(index));
+
+       if (_calendar_is_task_record(data->record))
+               data->item_type == ITEM_TYPE_TODO;
+       else
+               data->item_type == ITEM_TYPE_EVENT;
+}
+
+static void __cal_edit_ug_get_appcontrol_input_data_old(service_h service, cal_edit_ug_data *data)
+{
+       CAL_FN_START;
+
+       int r = 0;
+
+       char *item_type = NULL;
+
+       r = service_get_extra_data(service, "itemType", &item_type);
        if (r == SERVICE_ERROR_NONE) {
 
-               if (!CAL_STRCMP(item_type, CAL_APPCONTROL_ITEM_TYPE_EVENT)) {
+               if (!CAL_STRCMP(item_type, "event")) {
                        data->item_type = ITEM_TYPE_EVENT;
                        data->is_edit_mode = EINA_TRUE;
 
-                       r = service_get_extra_data(service, CAL_APPCONTROL_EVENT_ID, &index);
+                       char *index = NULL;
+
+                       r = service_get_extra_data(service, "eventId", &index);
                        if (r != SERVICE_ERROR_NONE) {
-                               ERR("service_get_extra_data(%s) is failed(%x)", CAL_APPCONTROL_EVENT_ID, r);
+                               ERR("service_get_extra_data(%s) is failed(%x)", "eventId", r);
 
                                CAL_FREE(index);
 
-                               ug_destroy_me(ug);
-
-                               return NULL;
+                               return;
                        }
 
-                       cid = atoi(index);
-                       calendar_record_h record = _calendar_get_record_with_index(cid);
+                       calendar_record_h record = _calendar_get_record_with_index(atoi(index));
                        c_retv_if(!record, NULL);
 
-                       calendar_record_destroy(record, true);
+                       CAL_FREE(index);
+
+                       data->record = record;
 
-               } else if (!CAL_STRCMP(item_type, CAL_APPCONTROL_ITEM_TYPE_TODO)) {
+               } else if (!CAL_STRCMP(item_type, "todo")) {
 
                        data->item_type = ITEM_TYPE_TODO;
                        data->is_edit_mode = EINA_TRUE;
 
-                       r = service_get_extra_data(service, CAL_APPCONTROL_TODO_ID, &index);
+                       char *index = NULL;
+
+                       r = service_get_extra_data(service, "todoId", &index);
                        if (r != SERVICE_ERROR_NONE) {
-                               ERR("service_get_extra_data(%s) is failed(%x)", CAL_APPCONTROL_TODO_ID, r);
+                               ERR("service_get_extra_data(%s) is failed(%x)", "todoId", r);
 
                                CAL_FREE(index);
 
-                               ug_destroy_me(ug);
-
-                               return NULL;
+                               return;
                        }
 
-                       cid = atoi(index);
-                       calendar_record_h record = _calendar_get_record_with_index(cid);
+                       calendar_record_h record = _calendar_get_record_with_index(atoi(index));
                        c_retv_if(!record, NULL);
 
-                       calendar_record_destroy(record, true);
+                       CAL_FREE(index);
 
-               }
-               else if (!CAL_STRCMP(item_type, CAL_APPCONTROL_ITEM_TYPE_VCS)) {
+                       data->record = record;
+
+               } else if (!CAL_STRCMP(item_type, "vcs")) {
 
                        data->item_type = ITEM_TYPE_VCS;
 
-                       r = service_get_extra_data(service, CAL_APPCONTROL_VCS_PATH, &path);
+                       char *path = NULL;
+
+                       r = service_get_extra_data(service, "path", &path);
                        if (r != SERVICE_ERROR_NONE) {
-                               ERR("service_get_extra_data(%s) is failed(%x)", CAL_APPCONTROL_VCS_PATH, r);
+                               ERR("service_get_extra_data(%s) is failed(%x)", "path", r);
 
                                CAL_FREE(path);
 
-                               ug_destroy_me(ug);
-
-                               return NULL;
+                               return;
                        }
 
                        FILE * file = fopen(path, "r");
                        if (!file) {
                                ERR("fopen(%s) is failed.", path);
 
-                               ug_destroy_me(ug);
+                               CAL_FREE(path);
 
-                               return NULL;
+                               return;
                        }
 
-                       struct stat st;
+                       struct stat st = {0};
                        if (stat(path, &st) != 0) {
                                ERR("Getting file information Error!");
                                fclose(file);
                                CAL_FREE(path);
-                               ug_destroy_me(ug);
 
-                               return NULL;
+                               return;
                        }
 
+                       CAL_FREE(path);
+
                        int size = st.st_size;
                        char *raw_data = calloc(size + 1, sizeof(char));
                        if(!raw_data){
                                ERR("raw_data is NULL!");
                                fclose(file);
                                free(raw_data);
-                               CAL_FREE(path);
-                               ug_destroy_me(ug);
 
-                               return NULL;
+                               return;
                        }
 
                        r = fread(raw_data, 1, size, file);
                        fclose( file );
-                       c_retv_if(r < 0, NULL);
+                       if (r < 0) {
+                               ERR("fread() is failed(%d)", errno);
+
+                               return;
+                       }
 
                        calendar_list_h list = NULL;
 
+                       calendar_error_e error = CALENDAR_ERROR_NONE;
+
                        error = calendar_vcalendar_parse_to_calendar(raw_data, &list);
                        c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_vcalendar_parse_to_calendar() is failed(%x)", error);
 
@@ -3482,84 +3553,114 @@ static void *__cal_edit_ug_create_callback(ui_gadget_h ug, enum ug_mode mode, se
                }
        }
 
-       if (!data->record) {
-               if (0 < cid) {
-                       data->is_edit_mode = EINA_TRUE;
-                       data->record = _calendar_get_record_with_index(cid);
-               }
-               else {
-                       data->is_edit_mode = EINA_FALSE;
-                       char *record_address = NULL;
-
-                       r = service_get_extra_data(service, "record", &record_address);
-                       if(record_address){
-                               data->record = (calendar_record_h)strtoul(record_address, NULL, 16);
-                               c_warn_if(!data->record, "strtol(%s, NULL, 16) is failed", record_address);
-                       }
-                       else    {
-                               char *note_str = NULL;
-                               r = service_get_extra_data(service, "note", &note_str);
+       CAL_FREE(item_type);
+}
 
-                               if(note_str){
-                                       calendar_record_h record = NULL;
-                                       calendar_error_e error = CALENDAR_ERROR_NONE;
-                                       error = calendar_record_create(_calendar_event._uri, &record);
-                                       c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_create() is failed(%x)", error);
+static void __cal_edit_ug_get_ug_input_data(service_h service, cal_edit_ug_data *data)
+{
+       CAL_FN_START;
 
-                                       data->record = record;
-                                       __cal_edit_ug_set_record_note(data->record, note_str);
+       int r = 0;
 
-                                       time_t now = time(NULL);
-                                       localtime_r(&now, &data->base_time);
+       char *index = NULL;
 
-                                       CAL_FREE(note_str);
-                               }
-                       }
+       r = service_get_extra_data(service, "index", &index);
+       if (r == SERVICE_ERROR_NONE) {
+               data->record = _calendar_get_record_with_index(atoi(index));
+               data->is_edit_mode = EINA_TRUE;
+       }
 
-                       int index = _calendar_get_record_index(data->record);
-                       if(index>0)     {
-                               data->is_edit_mode = EINA_TRUE;
-                       }
-                       _calendar_record_type record_type = _calendar_get_record_type(data->record);
-                       ERR("record_type=%d", record_type);
+       char *record_address = NULL;
 
-                       if (record_type != _CALENDAR_RECORD_TYPE_EVENT && record_type != _CALENDAR_RECORD_TYPE_TODO &&  record_type != _CALENDAR_RECORD_TYPE_SEARCH_TODO_CALENDAR) {
-                               data->instance = data->record;
-                               data->record = __cal_edit_ug_get_origin_record(data->instance);
-                       }
+       r = service_get_extra_data(service, "record", &record_address);
+       if (CAL_STRLEN(record_address)) {
+               data->record = (calendar_record_h)strtoul(record_address, NULL, 16);
+
+               if (0 < _calendar_get_record_index(data->record))
+                       data->is_edit_mode = EINA_TRUE;
+
+               _calendar_record_type record_type = _calendar_get_record_type(data->record);
+
+               if (record_type != _CALENDAR_RECORD_TYPE_EVENT && record_type != _CALENDAR_RECORD_TYPE_TODO &&  record_type != _CALENDAR_RECORD_TYPE_SEARCH_TODO_CALENDAR) {
+                       data->instance = data->record;
 
-                       if(record_address)
-                               CAL_FREE(record_address);
+                       data->record = __cal_edit_ug_get_origin_record(data->instance);
                }
 
                if (_calendar_is_task_record(data->record))
                        data->item_type = ITEM_TYPE_TODO;
                else
                        data->item_type = ITEM_TYPE_EVENT;
+       } else {
+               calendar_error_e error = CALENDAR_ERROR_NONE;
+
+               error = calendar_record_create(_calendar_event._uri, &data->record);
+               c_retm_if(error != CALENDAR_ERROR_NONE, "calendar_record_create() is failed(%x)", error);
+
+               data->is_edit_mode = EINA_FALSE;
+
+               data->item_type = ITEM_TYPE_EVENT;
        }
 
+       CAL_FREE(record_address);
 
        //base_time
        char *base_time = NULL;
+
        r = service_get_extra_data(service, "base_time", &base_time);
        c_warn_if(SERVICE_ERROR_NONE != r,"service_get_extra_data is failed(%d).", r);
 
-       if(base_time){
+       if (base_time) {
                long long int lli_time = strtoll(base_time, NULL, 10);
                cal_util_convert_lli_to_tm(NULL, lli_time, &data->base_time);
-               CAL_FREE(base_time);
-       }
 
-       if (error != CALENDAR_ERROR_NONE || data->item_type == ITEM_TYPE_UNKNOWN) {
-               ERR("ERROR!! Invaild parameter!!");
-               ug_destroy_me(ug);
+               free(base_time);
+       } else {
+               struct tm t = {0};
+               struct tm* returned_tm = NULL;
+               time_t now = 0;
+
+               now = time(NULL);
+
+               returned_tm = gmtime_r(&now, &t);
+               if (!returned_tm)
+                       ERR("localtime_r is failed.");
+               else
+                       CAL_MEMCPY(&data->base_time, &t, struct tm);
        }
+}
 
-       CAL_FREE(item_type);
+static void *__cal_edit_ug_create_callback(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv)
+{
+       CAL_FN_START;
+
+       c_retv_if(!ug, NULL);
+       c_retv_if(!service, NULL);
+       c_retv_if(!priv, NULL);
+       c_retv_if(mode != UG_MODE_FULLVIEW, NULL);
+
+       cal_edit_ug_data *data = priv;
+
+       data->ug = ug;
 
-       CAL_FREE(index);
+       char *operation = NULL;
 
-       CAL_FREE(path);
+       int r = service_get_operation(service, &operation);
+       c_retv_if(r != SERVICE_ERROR_NONE, NULL);
+
+       if (!CAL_STRCMP(operation, CAL_APPCONTROL_SOCAIL_EDIT))
+               __cal_edit_ug_get_appcontrol_input_data(service, data);
+       else if (!CAL_STRCMP(operation, SERVICE_OPERATION_EDIT))
+               __cal_edit_ug_get_appcontrol_input_data_old(service, data);
+       else
+               __cal_edit_ug_get_ug_input_data(service, data);
+
+       CAL_FREE(operation);
+
+       if (!data->record) {
+               ERR("ERROR!! Invaild parameter!!");
+               ug_destroy_me(ug);
+       }
 
        Evas_Object *parent = ug_get_parent_layout(ug);
        c_retv_if(!parent, NULL);
@@ -3567,8 +3668,23 @@ static void *__cal_edit_ug_create_callback(ui_gadget_h ug, enum ug_mode mode, se
        data->window = ug_get_window();
        c_retv_if(!data->window, NULL);
 
-       elm_theme_extension_add(NULL, "/usr/apps/"CALENDAR_PACKAGE"/res/edje/theme.edj");
-       elm_theme_extension_add(NULL, "/usr/apps/"CALENDAR_PACKAGE"/res/edje/theme2.edj");
+       data->conformant = ug_get_conformant();
+       if (!data->conformant) {
+               data->conformant = elm_conformant_add(data->window);
+               c_retv_if(!data->conformant, NULL);
+
+               evas_object_size_hint_weight_set(data->conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               elm_win_resize_object_add(data->window, data->conformant);
+               evas_object_show(data->conformant);
+       }
+
+       data->theme = elm_theme_new();
+       c_retv_if(!data->theme, NULL);
+
+       elm_theme_ref_set(data->theme, NULL);
+
+       elm_theme_extension_add(data->theme, "/usr/apps/"CALENDAR_PACKAGE"/res/edje/theme.edj");
+       elm_theme_extension_add(data->theme, "/usr/apps/"CALENDAR_PACKAGE"/res/edje/theme2.edj");
 
        Evas_Object *base = __cal_edit_ug_create_layout(parent, data);
        c_retv_if(!base, NULL);
@@ -3583,6 +3699,9 @@ static void __cal_edit_ug_destroy_callback(ui_gadget_h ug, service_h service, vo
 
        cal_edit_ug_data *data = priv;
 
+       if (data->save_cancel)
+               cal_save_cancel_destroy(data->save_cancel);
+
        cal_util_delete_evas_object(&data->base_layout);
 
        if (data->timezone_city)
@@ -3608,9 +3727,6 @@ static void __cal_edit_ug_destroy_callback(ui_gadget_h ug, service_h service, vo
        CAL_FREE(data->address);
        CAL_FREE(data->note_str);
 
-       if (data->save_cancel)
-               cal_save_cancel_destroy(data->save_cancel);
-
        if (data->tabbar)
                evas_object_del(data->tabbar);
 
@@ -3623,6 +3739,11 @@ static void __cal_edit_ug_destroy_callback(ui_gadget_h ug, service_h service, vo
        if (data->instance)
                calendar_record_destroy(data->instance, true);
 
+       elm_theme_extension_del(data->theme, "/usr/apps/"CALENDAR_PACKAGE"/res/edje/theme.edj");
+       elm_theme_extension_del(data->theme, "/usr/apps/"CALENDAR_PACKAGE"/res/edje/theme2.edj");
+
+       elm_theme_free(data->theme);
+
 }
 
 static void __cal_edit_ug_key_callback(ui_gadget_h ug, enum ug_key_event evt, service_h data, void *priv)