External: Fix bugs that decryption doesn't work properly by ui-app
[platform/core/security/ode.git] / tools / apps / ode / src / ode-app-confirm.c
index ffc5494..d921a30 100755 (executable)
@@ -17,6 +17,7 @@
  */
 
 #include "ode-app.h"
+#include "ode-password.h"
 #include <ode/external-encryption.h>
 #include <ode/internal-encryption.h>
 
@@ -28,8 +29,10 @@ char *confirm_button_text[] = {
 extern char *encrypt_header_text[];
 static int sdcard_option_selected = 0;
 static int device_full_encryption_state = 0;
+popup_data_s popup_data; /* for temporary */
 
 #define sdcard_option_num 2
+
 static void _confirm_next_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
 {
        int ret = 0;
@@ -39,37 +42,38 @@ static void _confirm_next_btn_clicked_cb(void *data, Evas_Object *obj, void *eve
        switch (ad->view_type) {
        case ENCRYPT_DEVICE:
                dlog_print(DLOG_DEBUG, LOG_TAG, "encrypt device confirm");
-               ret = ode_internal_encryption_encrypt("tizen", 0);
-               if (ret != 0) {
-                       dlog_print(DLOG_DEBUG, LOG_TAG, "internal encryption failed");
-               }
-               ui_app_exit();
+               if (device_full_encryption_state == 0)
+                       ad->device_info.device_option = 0;
+               else
+                       ad->device_info.device_option = 1;
+               popup_data.parent = ad->base;
+               popup_data.popup = NULL;
+               popup_data.mode = INTERNAL_ENCRYPT_PASSWORD;
+               popup_data.callback_data = ad;
+               create_confirm_password_popup(&popup_data);
                break;
        case DECRYPT_DEVICE:
                dlog_print(DLOG_DEBUG, LOG_TAG, "decrypt device confirm");
-               ret = ode_internal_encryption_decrypt("tizen");
-               if (ret != 0) {
-                       dlog_print(DLOG_DEBUG, LOG_TAG, "internal decryption failed");
-               }
-               ui_app_exit();
+               popup_data.parent = ad->base;
+               popup_data.popup = NULL;
+               popup_data.mode = INTERNAL_DECRYPT_PASSWORD;
+               create_confirm_password_popup(&popup_data);
                break;
        case ENCRYPT_SD_CARD:
                dlog_print(DLOG_DEBUG, LOG_TAG, "encrypt sd card confrim");
-               create_base_window();
-               create_progress_view("Encrypting", "External");
                ret = ode_external_encryption_encrypt(ad->entry_data, 0);
                if (ret != 0) {
                        dlog_print(DLOG_DEBUG, LOG_TAG, "external encryption failed");
                }
+               create_base_window();
+               create_progress_view("Encrypting", "External");
                break;
        case DECRYPT_SD_CARD:
                dlog_print(DLOG_DEBUG, LOG_TAG, "decrypt sd card confrim");
-               create_base_window();
-               create_progress_view("Decrypting", "External");
-               ret = ode_external_encryption_decrypt(ad->entry_data);
-               if (ret != 0) {
-                       dlog_print(DLOG_DEBUG, LOG_TAG, "external decryption failed");
-               }
+               popup_data.parent = ad->base;
+               popup_data.popup = NULL;
+               popup_data.mode = EXTERNAL_DECRYPT_PASSWORD;
+               create_confirm_password_popup(&popup_data);
                break;
        }
 }
@@ -149,7 +153,7 @@ static char *sd_confirm_multiline_text_get(void *data, Evas_Object *obj, const c
                }
        };
 
-       char **text = genlist_text[(int)data];
+       char **text = genlist_text[(intptr_t)data];
 
        if (!strcmp(part, "elm.text"))
                return strdup(__(text[0]));
@@ -160,8 +164,8 @@ static char *sd_confirm_multiline_text_get(void *data, Evas_Object *obj, const c
 
 void radio_changed_cb(void *data, Evas_Object *obj, void *event_info)
 {
-       dlog_print(DLOG_INFO, LOG_TAG, "The value has changed %d\n", (int)data);
-       sdcard_option_selected = (int)data;
+       dlog_print(DLOG_INFO, LOG_TAG, "The value has changed %d\n", (intptr_t)data);
+       sdcard_option_selected = (intptr_t)data;
 
        dlog_print(DLOG_INFO, LOG_TAG, "sdcard_option_selected is  %d\n", sdcard_option_selected);
 }
@@ -169,7 +173,7 @@ void radio_changed_cb(void *data, Evas_Object *obj, void *event_info)
 static Evas_Object *sd_confirm_content_get(void *data, Evas_Object *obj, const char *part)
 {
        static Evas_Object *group = NULL;
-       int idx = (int)data;
+       int idx = (intptr_t)data;
 
        if (!strcmp(part, "elm.swallow.end")) {
                if (idx == 0) {
@@ -320,7 +324,7 @@ void ode_confirm_encrypt_sd_card_create_view(appdata_s *ad)
        itc = ode_create_genlist_item_class("multiline", sd_confirm_multiline_text_get, sd_confirm_content_get);
 
        for (index = 0; index < sdcard_option_num; index++) {
-               item = elm_genlist_item_append(genlist, itc, (void *)index, NULL, ELM_GENLIST_ITEM_NONE , NULL, NULL);
+               item = elm_genlist_item_append(genlist, itc, (void*)(intptr_t)index, NULL, ELM_GENLIST_ITEM_NONE , NULL, NULL);
                elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_NONE);
        }