External: Fix bugs that decryption doesn't work properly by ui-app 96/114696/1
authorSungbae Yoo <sungbae.yoo@samsung.com>
Tue, 14 Feb 2017 11:33:32 +0000 (20:33 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Tue, 14 Feb 2017 11:40:27 +0000 (20:40 +0900)
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Change-Id: I23fed938dd87afb6363723dc54eb35cb53dd960a

server/engine/encryption/ecryptfs-engine.cpp
tools/apps/ode/include/ode-password.h
tools/apps/ode/src/ode-app-confirm.c
tools/apps/ode/src/password/confirm-popup.c
tools/apps/ode/src/password/password.c

index 9eaef01..b7d2161 100644 (file)
@@ -37,7 +37,7 @@
 #define MEDIA_EXCLUSION_LIST "temp_video/Camera/DCIM:mp3|mpga|m4a|mp4|wav|amr|awb|wma|ogg|oga|aac|mka|flac|3gp|3ga|mid|midi|xmf|rtttl|rtx|ota|smf|spm|imy|mpeg|m4v|3gp|3gpp|3g2|3gpp2|wmv|asf|mkv|webm|ts|avi|jpg|jpeg|gif|png|bmp|wbmp|divx|flv|ac3|mov|tiff|f4v|mpeg3|voice"
 
 #define CIPHER_MODE "aes"
-#define ENCRYPTION_TMP_DIR ".ecryptfs_encrypted"
+#define ENCRYPTION_TMP_DIR ".ecryptfs_temp"
 
 
 #define ECRYPTFS_VERSION_MAJOR 0x00
@@ -353,8 +353,8 @@ void EcryptfsEngine::encrypt(const data &key, unsigned int options)
                if (tempDir.exists()) {
                        tempDir.remove(true);
                }
-
                tempDir.makeDirectory();
+
                if (!(options & OPTION_ONLY_NEW_FILE)) {
                        copyInPlace(destination, destination, tempDir.getPath(),
                                        [](const std::string &file) {
@@ -365,6 +365,8 @@ void EcryptfsEngine::encrypt(const data &key, unsigned int options)
                                                this->progress.update(current * 100 / totalSize);
                                        });
                }
+
+               tempDir.remove(true);
        } catch (runtime::Exception &e) {
                try {
                        ecryptfsUmount(destination);
@@ -390,6 +392,9 @@ void EcryptfsEngine::decrypt(const data &key, unsigned int options)
            runtime::File tempDir(source + "/" ENCRYPTION_TMP_DIR);
                runtime::File tempMountpoint(tempDir.getPath() + "/mount");
 
+               if (tempDir.exists()) {
+                       tempDir.remove(true);
+               }
                tempDir.makeDirectory();
 
                tempMountpoint.makeDirectory();
index 7cf9b37..26599e7 100755 (executable)
@@ -36,6 +36,7 @@ enum {
        INSERT_SD_CARD,
        INTERNAL_ENCRYPT_PASSWORD,
        INTERNAL_DECRYPT_PASSWORD,
+       EXTERNAL_DECRYPT_PASSWORD,
 };
 
 typedef struct {
index f53ce26..d921a30 100755 (executable)
@@ -61,21 +61,19 @@ static void _confirm_next_btn_clicked_cb(void *data, Evas_Object *obj, void *eve
                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;
        }
 }
index a40a362..3ed8537 100755 (executable)
@@ -121,7 +121,7 @@ static void confirm_password_popup_confirm_cb(void *data, Evas_Object *obj, void
        popup_data_s *popup_data = (popup_data_s *)data;
 
        /* for temporary start */
-       if (popup_data->mode == INTERNAL_ENCRYPT_PASSWORD || popup_data->mode == INTERNAL_DECRYPT_PASSWORD) {
+       if (popup_data->mode == INTERNAL_ENCRYPT_PASSWORD || popup_data->mode == INTERNAL_DECRYPT_PASSWORD || popup_data->mode == EXTERNAL_DECRYPT_PASSWORD) {
                snprintf(popup_data->entry_data, PATH_MAX, "%s", elm_entry_entry_get(confirm_entry));
                evas_object_del(popup_data->popup);
                password_result_callback(popup_data, "success");
index 38f19db..4ab13cb 100755 (executable)
@@ -128,6 +128,15 @@ void password_result_callback(popup_data_s *data, const char *result)
                        return;
                }
                break;
+       case EXTERNAL_DECRYPT_PASSWORD:
+               ret = ode_external_encryption_decrypt(data->entry_data);
+               if (ret != 0) {
+                       dlog_print(DLOG_DEBUG, LOG_TAG, "failed to decrypt internal storage");
+                       return;
+               }
+               create_base_window();
+        create_progress_view("Decrypting", "External");
+               break;
        /* for temporary end */
        default:
                break;