./rework/interface/external/encrypt-sdcard.cpp
./rework/interface/external/decrypt-sdcard.cpp
./rework/interface/external/insert-sdcard.cpp
- ./rework/interface/external/password-sdcard.cpp)
+ ./rework/interface/external/password-sdcard.cpp
+ ./rework/interface/external/retry-sdcard.cpp)
SET(EXTERNAL_LOCKTYPE_SRC
./rework/interface/external-locktype/password.cpp
void PasswordSDCard::retryCrypto(const std::string &data)
{
- /* TBD : Retry Encrypt/Decrypt */
+ Vconf cryptoType(VCONFKEY_SDE_CRYPTO_TYPE);
+ Vconf cryptoState(VCONFKEY_SDE_CRYPTO_STATE);
+
+ std::string type(cryptoType.getString());
+ passwordConfirm.dispose();
+
+ if (!type.compare("encrypt")) {
+ Vconf option(VCONFKEY_SDE_ENCRYPT_NEWFILE);
+ cryptoState.setString("unencrypted");
+ encryption.encrypt(data, option.getBool());
+ progress.reset(new ExternalEncryptProgress(window));
+ } else if (!type.compare("decrypt")) {
+ cryptoState.setString("encrypted");
+ encryption.decrypt(data);
+ progress.reset(new ExternalDecryptProgress(window));
+ }
+
+ if (progress) {
+ setFullContent(progress.get());
+ progress->start();
+ }
}
void PasswordSDCard::onResultCallback(int result, const std::string &data)
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "retry-sdcard.h"
+
+RetryPopup::RetryPopup(Widget *parent)
+ : MobileDefaultPopup(parent),
+ appControl("org.tizen.ode")
+{
+}
+
+RetryPopup::~RetryPopup()
+{
+}
+
+void RetryPopup::setPartContent(const std::string &title, const std::string &content)
+{
+ setTitleText(dgetText(title));
+ setContentText(dgetText(content));
+ setButton(dgetText("IDS_ST_BUTTON_CANCEL"),
+ [this](void *) {
+ dispose();
+ },
+ dgetText("IDS_ST_BUTTON_RETRY"),
+ [this](void *) {
+ onRetry.emit();
+ });
+}
+
+ExternalRetryEncrypt::ExternalRetryEncrypt(Widget *parent)
+ : RetryPopup(parent)
+{
+ setPartContent("IDS_ST_HEADER_FAILED_TO_ENCRYPT_SD_CARD", "IDS_ST_POP_AN_ERROR_HAS_OCCURRED_TO_USE_THE_SD_CARD_THE_ENCRYPTION_PROCESS_MUST_BE_COMPLETED_TAP_RETRY_TO_TRY_AGAIN");
+ onRetry.connect(this, &ExternalRetryEncrypt::retry);
+}
+
+ExternalRetryEncrypt::~ExternalRetryEncrypt()
+{
+}
+
+void ExternalRetryEncrypt::retry()
+{
+ dispose();
+ notification.dispose();
+ appControl.setData("viewtype", "SD_CARD_PASSWORD");
+ appControl.launch();
+}
+
+void ExternalRetryEncrypt::createNotification()
+{
+ appControl.setData("viewtype", "SD_CARD_PASSWORD");
+ notification.setTitle(dgetText("IDS_ST_MBODY_SD_CARD_ENCRYPTION_ERROR"));
+ notification.setContent(dgetText("IDS_ST_SBODY_TAP_HERE_TO_TRY_AGAIN"));
+ notification.setAppControl(appControl);
+ notification.post();
+}
+
+ExternalRetryEncryptStorageFull::ExternalRetryEncryptStorageFull(Widget *parent)
+ : RetryPopup(parent)
+{
+ std::string text;
+ Vconf storageSize(VCONFKEY_ENCRYPT_NEEDED_SIZE);
+ int size = storageSize.getInt();
+
+ text.append(dgetText("IDS_ST_POP_YOUR_SD_CARD_DOESNT_HAVE_ENOUGH_SPACE"));
+ text.append(formatString("IDS_ST_POP_APPROXIMATELY_P1SS_P2SS_IS_NEEDED", (double)size));
+ text.append(dgetText("IDS_ST_POP_GO_TO_SETTINGS_STORAGE_AND_RAM_STORAGE_DETAILS_THEN_DELETE_SOME_FILES_AND_TRY_AGAIN"));
+ setPartContent("IDS_ST_HEADER_FAILED_TO_ENCRYPT_SD_CARD", text);
+ onRetry.connect(this, &ExternalRetryEncryptStorageFull::retry);
+}
+
+ExternalRetryEncryptStorageFull::~ExternalRetryEncryptStorageFull()
+{
+}
+
+void ExternalRetryEncryptStorageFull::retry()
+{
+ /* TBD */
+}
+
+void ExternalRetryEncryptStorageFull::createNotification()
+{
+ appControl.setData("viewtype", "ENCRYPT_SD_CARD");
+ notification.setTitle(dgetText("IDS_ST_MBODY_SD_CARD_ENCRYPTION_ERROR"));
+ notification.setContent(dgetText("IDS_ST_SBODY_DELETE_SOME_FILES_THEN_TRY_AGAIN"));
+ notification.setAppControl(appControl);
+ notification.post();
+}
+
+ExternalRetryDecrypt::ExternalRetryDecrypt(Widget *parent)
+ : RetryPopup(parent)
+{
+ setPartContent("IDS_ST_HEADER_FAILED_TO_DECRYPT_SD_CARD", "IDS_ST_POP_AN_ERROR_HAS_OCCURRED_TO_USE_THE_SD_CARD_THE_DECRYPTION_PROCESS_MUST_BE_COMPLETED_TAP_RETRY_TO_TRY_AGAIN");
+ onRetry.connect(this, &ExternalRetryDecrypt::retry);
+}
+
+ExternalRetryDecrypt::~ExternalRetryDecrypt()
+{
+}
+
+void ExternalRetryDecrypt::retry()
+{
+ dispose();
+ notification.dispose();
+ appControl.setData("veiwtype", "SD_CARD_PASSWORD");
+ appControl.launch();
+}
+
+void ExternalRetryDecrypt::createNotification()
+{
+ appControl.setData("viewtype", "SD_CARD_PASSWORD");
+ notification.setTitle(dgetText("IDS_ST_MBODY_SD_CARD_DECRYPTION_ERROR"));
+ notification.setContent(dgetText("IDS_ST_SBODY_TAP_HERE_TO_TRY_AGAIN"));
+ notification.setAppControl(appControl);
+ notification.post();
+}
+
+ExternalRetryDecryptStorageFull::ExternalRetryDecryptStorageFull(Widget *parent)
+ : RetryPopup(parent)
+{
+ std::string text;
+ Vconf storageSize(VCONFKEY_ENCRYPT_NEEDED_SIZE);
+ int size = storageSize.getInt();
+
+ text.append(dgetText("IDS_ST_POP_YOUR_SD_CARD_DOESNT_HAVE_ENOUGH_SPACE"));
+ text.append(formatString("IDS_ST_POP_APPROXIMATELY_P1SS_P2SS_IS_NEEDED", (double)size));
+ text.append(dgetText("IDS_ST_POP_GO_TO_SETTINGS_STORAGE_AND_RAM_STORAGE_DETAILS_THEN_DELETE_SOME_FILES_AND_TRY_AGAIN"));
+ setPartContent("IDS_ST_HEADER_FAILED_TO_DECRYPT_SD_CARD", text);
+ onRetry.connect(this, &ExternalRetryDecryptStorageFull::retry);
+}
+
+ExternalRetryDecryptStorageFull::~ExternalRetryDecryptStorageFull()
+{
+}
+
+void ExternalRetryDecryptStorageFull::retry()
+{
+ /* [TBD] retry decryption here */
+}
+
+void ExternalRetryDecryptStorageFull::createNotification()
+{
+ appControl.setData("viewtype", "DECRYPT_SD_CARD");
+ notification.setTitle(dgetText("IDS_ST_MBODY_SD_CARD_DECRYPTION_ERROR"));
+ notification.setContent(dgetText("IDS_ST_SBODY_DELETE_SOME_FILES_THEN_TRY_AGAIN"));
+ notification.setAppControl(appControl);
+ notification.post();
+}
+
+ExternalRetry::ExternalRetry()
+ : popup(nullptr), vconf(VCONFKEY_SDE_CRYPTO_TYPE)
+{
+ window->setConfig(Window::Config::SetAlpha);
+}
+
+ExternalRetry::~ExternalRetry()
+{
+}
+
+void ExternalRetry::create()
+{
+ std::string type(vconf.getString());
+ if (!type.compare("encrypt")) {
+ popup.reset(new ExternalRetryEncrypt(window));
+ } else if(!type.compare("decrypt")) {
+ popup.reset(new ExternalRetryDecrypt(window));
+ }
+ popup->show();
+ popup->createNotification();
+}
+
+void ExternalRetry::dispose()
+{
+ ::ui_app_exit();
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __ODE_EXTERNAL_RETRY_POPUP_H__
+#define __ODE_EXTERNAL_RETRY_POPUP_H__
+
+#include "../interface.h"
+#include "../tools/vconf.h"
+#include "../../widgets/popup.h"
+#include "../../widgets/notification.h"
+#include "../../widgets/appcontrol.h"
+#include "../../widgets/signal.h"
+#include "../../language.h"
+
+class RetryPopup : public MobileDefaultPopup {
+public:
+ RetryPopup(Widget *parent);
+ virtual ~RetryPopup();
+
+ virtual void setPartContent(const std::string &title, const std::string &content);
+ virtual void createNotification() = 0;
+ virtual void retry() = 0;
+
+ Signal<> onRetry;
+ AppControl appControl;
+ Notification notification;
+};
+
+class ExternalRetryEncrypt : public RetryPopup {
+public:
+ ExternalRetryEncrypt(Widget *parent);
+ ~ExternalRetryEncrypt();
+
+ void createNotification();
+ void retry();
+};
+
+class ExternalRetryEncryptStorageFull : public RetryPopup {
+public:
+ ExternalRetryEncryptStorageFull(Widget *parent);
+ ~ExternalRetryEncryptStorageFull();
+
+ void createNotification();
+ void retry();
+};
+
+class ExternalRetryDecrypt : public RetryPopup {
+public:
+ ExternalRetryDecrypt(Widget *parent);
+ ~ExternalRetryDecrypt();
+
+ void createNotification();
+ void retry();
+};
+
+class ExternalRetryDecryptStorageFull : public RetryPopup {
+public:
+ ExternalRetryDecryptStorageFull(Widget *parent);
+ ~ExternalRetryDecryptStorageFull();
+
+ void createNotification();
+ void retry();
+};
+
+class ExternalRetry : public ODEInterface {
+public:
+ ExternalRetry();
+ ~ExternalRetry();
+
+ void create();
+ void dispose();
+
+private:
+ std::unique_ptr<RetryPopup> popup;
+ Vconf vconf;
+};
+#endif
}
ExternalEncryptProgress::ExternalEncryptProgress(Widget *parent)
- : ProgressPage(parent, "external,encryption,progress", VCONFKEY_SDE_ENCRYPT_PROGRESS)
+ : ProgressPage(parent, "external,encryption,progress", VCONFKEY_SDE_ENCRYPT_PROGRESS),
+ cryptoState(VCONFKEY_SDE_CRYPTO_STATE),
+ retryPopup(parent)
{
+ Vconf cryptoType(VCONFKEY_SDE_CRYPTO_TYPE);
+ cryptoType.setString("encrypt");
+
std::string text;
titleText.reset(new TextBlock(this, titleStyle, dgetText("IDS_ST_BODY_ENCRYPTING_SD_CARD_ING")));
setContent("message_title", titleText.get());
text.append(dgetText("IDS_ST_BODY_THE_SD_CARD_CANT_BE_USED_UNTIL_IT_HAS_BEEN_ENCRYPTED"));
contentText.reset(new TextBlock(this, contentStyle, text));
setContent("message_content", contentText.get());
+
+ cryptoState.addChangedCallback();
+ cryptoState.onKeyChanged.connect(this, &ExternalEncryptProgress::cryptoStateChangedCallback);
}
ExternalEncryptProgress::~ExternalEncryptProgress()
{
+ cryptoState.removeChangedCallback();
+}
+
+void ExternalEncryptProgress::cryptoStateChangedCallback()
+{
+ std::string state(cryptoState.getString());
+ if (!state.compare("error_partially_encrypted")) {
+ retryPopup.show();
+ retryPopup.createNotification();
+ }
}
ExternalDecryptProgress::ExternalDecryptProgress(Widget *parent)
- : ProgressPage(parent, "external,decryption,progress", VCONFKEY_SDE_ENCRYPT_PROGRESS)
+ : ProgressPage(parent, "external,decryption,progress", VCONFKEY_SDE_ENCRYPT_PROGRESS),
+ cryptoState(VCONFKEY_SDE_CRYPTO_STATE),
+ retryPopup(parent)
{
+ Vconf cryptoType(VCONFKEY_SDE_CRYPTO_TYPE);
+ cryptoType.setString("decrypt");
+
std::string text;
titleText.reset(new TextBlock(this, titleStyle, dgetText("IDS_ST_BODY_DECRYPTING_SD_CARD_ING")));
setContent("message_title", titleText.get());
text.append(dgetText("IDS_ST_BODY_THE_SD_CARD_CANT_BE_USED_UNTIL_IT_HAS_BEEN_DECRYPTED"));
contentText.reset(new TextBlock(this, contentStyle, text));
setContent("message_content", contentText.get());
+
+ cryptoState.addChangedCallback();
+ cryptoState.onKeyChanged.connect(this, &ExternalDecryptProgress::cryptoStateChangedCallback);
}
ExternalDecryptProgress::~ExternalDecryptProgress()
{
+ cryptoState.removeChangedCallback();
+}
+
+void ExternalDecryptProgress::cryptoStateChangedCallback()
+{
+ std::string state(cryptoState.getString());
+ if (!state.compare("error_partially_encrypted")) {
+ retryPopup.show();
+ retryPopup.createNotification();
+ }
}
InternalEncryptProgress::InternalEncryptProgress(Widget *parent)
#include "interface.h"
#include "tools/vconf.h"
+#include "external/retry-sdcard.h"
#include "../language.h"
#include "../widgets/layout.h"
#include "../widgets/timer.h"
public:
ExternalEncryptProgress(Widget *parent);
~ExternalEncryptProgress();
+
+ void cryptoStateChangedCallback();
+
+ Vconf cryptoState;
+ ExternalRetryEncrypt retryPopup;
};
class ExternalDecryptProgress : public ProgressPage {
public:
ExternalDecryptProgress(Widget *parent);
~ExternalDecryptProgress();
+
+ void cryptoStateChangedCallback();
+
+ Vconf cryptoState;
+ ExternalRetryDecrypt retryPopup;
};
class InternalEncryptProgress : public ProgressPage {