#include "insert-sdcard.h"
InsertSDCardInterface::InsertSDCardInterface()
- : popup(nullptr), appControl("org.tizen.ode")
+ : popup(nullptr), appControl("org.tizen.ode"), notification(NOTIFICATION_TYPE_NOTI)
{
window->setConfig(Window::Config::SetAlpha);
}
/* SD Card Encrypted Notification */
appControl.setData("viewtype", "SD_CARD_PASSWORD");
notification.setTitle(dgetText("IDS_ST_MBODY_SD_CARD_ENCRYPTED"));
- notification.setContent(dgetText("IDS_ST_SBODY_TAP_HERE_TO_ENTER_PW_FOR_SD_CARD_ABB"));
+ notification.setContentText(dgetText("IDS_ST_SBODY_TAP_HERE_TO_ENTER_PW_FOR_SD_CARD_ABB"));
notification.setAppControl(appControl);
notification.post();
}
PasswordSDCard::PasswordSDCard()
: baseLayout(new Layout(window)),
passwordConfirm(baseLayout),
+ notification(NOTIFICATION_TYPE_NOTI),
progress(nullptr)
{
window->setContent(baseLayout);
encryption.mount(data);
appControl.setData("viewtype", "DECRYPT_SD_CARD");
notification.setTitle(dgetText("IDS_ST_MBODY_DECRYPT_SD_CARD"));
- notification.setContent(dgetText("IDS_ST_SBODY_SD_CARD_ENCRYPTED_M_STATUS"));
+ notification.setContentText(dgetText("IDS_ST_SBODY_SD_CARD_ENCRYPTED_M_STATUS"));
notification.setAppControl(appControl);
notification.post();
} else {
appControl.setData("viewtype", "ENCRYPT_SD_CARD");
notification.setTitle(dgetText("IDS_ST_MBODY_ENCRYPT_SD_CARD_ABB"));
- notification.setContent(dgetText("IDS_ST_SBODY_TAP_HERE_TO_ENTER_PW_FOR_SD_CARD_ABB"));
+ notification.setContentText(dgetText("IDS_ST_SBODY_TAP_HERE_TO_ENTER_PW_FOR_SD_CARD_ABB"));
notification.setAppControl(appControl);
notification.post();
}
RetryPopup::RetryPopup(Widget *parent)
: MobileDefaultPopup(parent),
- appControl("org.tizen.ode")
+ appControl("org.tizen.ode"),
+ notification(NOTIFICATION_TYPE_NOTI)
{
}
{
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.setContentText(dgetText("IDS_ST_SBODY_TAP_HERE_TO_TRY_AGAIN"));
notification.setAppControl(appControl);
notification.post();
}
{
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.setContentText(dgetText("IDS_ST_SBODY_DELETE_SOME_FILES_THEN_TRY_AGAIN"));
notification.setAppControl(appControl);
notification.post();
}
{
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.setContentText(dgetText("IDS_ST_SBODY_TAP_HERE_TO_TRY_AGAIN"));
+
notification.setAppControl(appControl);
notification.post();
}
{
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.setContentText(dgetText("IDS_ST_SBODY_DELETE_SOME_FILES_THEN_TRY_AGAIN"));
notification.setAppControl(appControl);
notification.post();
}
: Layout{parent, "/usr/apps/org.tizen.ode/res/org.tizen.ode.edj", group},
vconf(key),
progressbar(this, Progressbar::Config::SetPulse),
+ notification(nullptr),
+ doneNotification(nullptr),
titleStyle("DEFAULT='font=Tizen:style=Regular font_size=40 color=#ffffff wrap=mixed align=center'"),
- contentStyle("DEFAULT='font=Tizen:style=Regular font_size=32 color=#ffffff wrap=mixed align=center'")
+ contentStyle("DEFAULT='font=Tizen:style=Regular font_size=32 color=#ffffff wrap=mixed align=center'"),
+ current(0.0)
{
- progressbar.setValue(0.0);
+ progressbar.setValue(current);
setContent("progressbar", &progressbar);
}
void ProgressPage::start()
{
+ createPartContent();
+ createNotification();
+
timer.add(0.1);
timer.onTimer = [this]() {
return setProgress();
int percentage = 0;
percentage = ::atoi(stringValue.c_str());
- progressbar.setValue(percentage/100.0);
+ current = percentage/100.0;
+
+ progressbar.setValue(current);
stringValue.append("%");
setText("progress_percentage", stringValue);
+ if (notification != nullptr && notification->getProgress() != current) {
+ notification->setProgress(percentage/100.0);
+ notification->update();
+ }
+
if (percentage == 100) {
timer.dispose();
+ if (notification)
+ notification->dispose();
+ if (doneNotification)
+ doneNotification->post();
::ui_app_exit();
return ECORE_CALLBACK_DONE;
}
{
Vconf cryptoType(VCONFKEY_SDE_CRYPTO_TYPE);
cryptoType.setString("encrypt");
+ cryptoState.addChangedCallback();
+ cryptoState.onKeyChanged.connect(this, &ExternalEncryptProgress::cryptoStateChangedCallback);
+}
+
+ExternalEncryptProgress::~ExternalEncryptProgress()
+{
+ cryptoState.removeChangedCallback();
+}
+void ExternalEncryptProgress::createPartContent()
+{
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()
+void ExternalEncryptProgress::createNotification()
{
- cryptoState.removeChangedCallback();
+ notification.reset(new Notification(NOTIFICATION_TYPE_ONGOING));
+ notification->setTitle(dgetText("IDS_ST_MBODY_ENCRYPTING_SD_CARD_ING"));
+ notification->setContentText(dgetText("IDS_ST_BODY_PDP_M_PERCENT"));
+ notification->setLayout(NOTIFICATION_LY_ONGOING_PROGRESS);
+ notification->post();
+
+ doneNotification.reset(new Notification(NOTIFICATION_TYPE_NOTI));
+ doneNotification->setTitle(dgetText("IDS_ST_MBODY_SD_CARD_ENCRYPTED"));
+ doneNotification->setLayout(NOTIFICATION_LY_NOTI_EVENT_SINGLE);
}
void ExternalEncryptProgress::cryptoStateChangedCallback()
{
Vconf cryptoType(VCONFKEY_SDE_CRYPTO_TYPE);
cryptoType.setString("decrypt");
+ cryptoState.addChangedCallback();
+ cryptoState.onKeyChanged.connect(this, &ExternalDecryptProgress::cryptoStateChangedCallback);
+}
+
+ExternalDecryptProgress::~ExternalDecryptProgress()
+{
+ cryptoState.removeChangedCallback();
+}
+void ExternalDecryptProgress::createPartContent()
+{
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()
+void ExternalDecryptProgress::createNotification()
{
- cryptoState.removeChangedCallback();
+ notification.reset(new Notification(NOTIFICATION_TYPE_ONGOING));
+ notification->setTitle(dgetText("IDS_ST_MBODY_DECRYPTING_SD_CARD_ING"));
+ notification->setContentText(dgetText("IDS_ST_BODY_PDP_M_PERCENT"));
+ notification->setLayout(NOTIFICATION_LY_ONGOING_PROGRESS);
+ notification->post();
+
+ doneNotification.reset(new Notification(NOTIFICATION_TYPE_NOTI));
+ doneNotification->setTitle(dgetText("IDS_ST_MBODY_SD_CARD_DECRYPTED"));
+ doneNotification->setLayout(NOTIFICATION_LY_NOTI_EVENT_SINGLE);
}
void ExternalDecryptProgress::cryptoStateChangedCallback()
InternalEncryptProgress::InternalEncryptProgress(Widget *parent)
: ProgressPage(parent, "internal,encryption,progress", VCONFKEY_ODE_ENCRYPT_PROGRESS)
{
+}
+
+InternalEncryptProgress::~InternalEncryptProgress()
+{
+}
+
+void InternalEncryptProgress::createPartContent()
+{
std::string text;
titleText.reset(new TextBlock(this, titleStyle, dgetText("IDS_ST_NPBODY_ENCRYPTING_DEVICE_ING")));
setContent("message_title", titleText.get());
setContent("message_content", contentText.get());
}
-InternalEncryptProgress::~InternalEncryptProgress()
+void InternalEncryptProgress::createNotification()
{
}
InternalDecryptProgress::InternalDecryptProgress(Widget *parent)
: ProgressPage(parent, "internal,decryption,progress", VCONFKEY_ODE_ENCRYPT_PROGRESS)
{
+}
+
+InternalDecryptProgress::~InternalDecryptProgress()
+{
+}
+
+void InternalDecryptProgress::createPartContent()
+{
titleText.reset(new TextBlock(this, titleStyle, dgetText("IDS_ST_BODY_DECRYPTING_DEVICE_ING")));
setContent("message_title", titleText.get());
contentText.reset(new TextBlock(this, contentStyle, dgetText("IDS_ST_BODY_PLEASE_WAIT_NONCE_THE_DEVICE_IS_DECRYPTED_IT_WILL_RESTART")));
setContent("message_content", contentText.get());
}
-InternalDecryptProgress::~InternalDecryptProgress()
+void InternalDecryptProgress::createNotification()
{
}
#include "../widgets/timer.h"
#include "../widgets/progressbar.h"
#include "../widgets/textblock.h"
+#include "../widgets/notification.h"
class ProgressPage : public Layout {
public:
ProgressPage(Widget *parent, const std::string &group, const std::string &key);
- ~ProgressPage();
+ virtual ~ProgressPage();
void start();
bool setProgress();
-
+protected:
+ virtual void createPartContent() = 0;
+ virtual void createNotification() = 0;
+protected:
Vconf vconf;
Progressbar progressbar;
Timer timer;
-
+ std::unique_ptr<Notification> notification;
+ std::unique_ptr<Notification> doneNotification;
std::unique_ptr<TextBlock> titleText;
std::unique_ptr<TextBlock> contentText;
std::string titleStyle;
std::string contentStyle;
+ double current;
};
class ExternalEncryptProgress : public ProgressPage {
ExternalEncryptProgress(Widget *parent);
~ExternalEncryptProgress();
+ void createPartContent();
+ void createNotification();
void cryptoStateChangedCallback();
Vconf cryptoState;
ExternalDecryptProgress(Widget *parent);
~ExternalDecryptProgress();
+ void createPartContent();
+ void createNotification();
void cryptoStateChangedCallback();
Vconf cryptoState;
public:
InternalEncryptProgress(Widget *parent);
~InternalEncryptProgress();
+
+ void createPartContent();
+ void createNotification();
};
class InternalDecryptProgress : public ProgressPage {
public:
InternalDecryptProgress(Widget *parent);
~InternalDecryptProgress();
+
+ void createPartContent();
+ void createNotification();
};
#endif
#include "notification.h"
-Notification::Notification()
+Notification::Notification(notification_type_e type)
{
- notification = ::notification_create(NOTIFICATION_TYPE_NOTI);
+ notification = ::notification_create(type);
}
Notification::~Notification()
title.c_str(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
}
-void Notification::setContent(const std::string &content)
+void Notification::setContentText(const std::string &content)
{
::notification_set_text(notification, NOTIFICATION_TEXT_TYPE_CONTENT,
content.c_str(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
}
+void Notification::setProgress(double value)
+{
+ ::notification_set_progress(notification, value);
+}
+
+double Notification::getProgress()
+{
+ double value = 0.0;
+ ::notification_get_progress(notification, &value);
+ return value;
+}
+
+void Notification::setLayout(notification_ly_type_e type)
+{
+ ::notification_set_layout(notification, type);
+}
+
void Notification::setImage(const std::string &path)
{
::notification_set_image(notification, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, path.c_str());
::notification_set_launch_option(notification, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, appControl);
}
+void Notification::update()
+{
+ ::notification_update(notification);
+}
+
void Notification::post()
{
::notification_post(notification);
class Notification {
public:
- Notification();
+ Notification(notification_type_e type);
~Notification();
void setTitle(const std::string &title);
- void setContent(const std::string &content);
+ void setContentText(const std::string &content);
+ void setProgress(double value);
+ double getProgress();
+ void setLayout(notification_ly_type_e type);
void setImage(const std::string &path);
void setAppControl(AppControl &appcontrol);
+
+ void update();
void post();
void dispose();
private: