#include <vconf.h>
#include <widget_model.h>
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <dpl/utils/wrt_global_settings.h>
#include <common/application_data.h>
#include <common/application_launcher.h>
const char PROTOCOL_HANDLER_ASK_MSG[] = "Add protocol?";
const char PROTOCOL_HANDLER_ASK_TITLE[] = "Add protocol";
+const char PROTOCOL_HANDLER_ASK_REMEMBER[] = "Remember dicision";
const char CONTENT_HANDLER_ASK_MSG[] = "Add content?";
const char CONTENT_HANDLER_ASK_TITLE[] = "Add content";
+const char CONTENT_HANDLER_AKS_REMEMBER[] = "Remember dicision";
}
ViewLogic::ViewLogic():
"text/xml"
};
+/**
+ * Saves user's response from popup to custom handler. Saves Yes/No and remember
+ * state.
+ * @param response
+ * @param customHandler
+ */
+void saveUserResponse(Wrt::Popup::PopupResponse response,
+ CustomHandlerDB::CustomHandlerPtr customHandler)
+{
+ switch (response) {
+ case Wrt::Popup::YES_DO_REMEMBER:
+ LogDebug("User allowed, remember");
+ customHandler->user_decision = static_cast<CustomHandlerDB::HandlerState>
+ (CustomHandlerDB::Agreed | CustomHandlerDB::DecisionSaved);
+ break;
+ case Wrt::Popup::YES_DONT_REMEMBER:
+ LogDebug("User allowed, don't remember");
+ customHandler->user_decision = CustomHandlerDB::Agreed;
+ break;
+ case Wrt::Popup::NO_DO_REMEMBER:
+ LogDebug("User didn't allow, remember");
+ customHandler->user_decision = static_cast<CustomHandlerDB::HandlerState>
+ (CustomHandlerDB::Declined | CustomHandlerDB::DecisionSaved);
+ break;
+ case Wrt::Popup::NO_DONT_REMEMBER:
+ LogDebug("User didn't allow, don't remember");
+ customHandler->user_decision = CustomHandlerDB::Declined;
+ break;
+ }
+}
+
//TODO registration, checking if registered and unregistration can be done in
//common functions for both types of handlers. Only white and black lists
//have to be separated
LogDebug("Protocol already registered - nothing to do");
} else {
LogDebug("Protocol handler not found");
- if (Wrt::Popup::PopupInvoker().askYesNo(PROTOCOL_HANDLER_ASK_TITLE, PROTOCOL_HANDLER_ASK_MSG)) {
- LogDebug("User allowed");
- customHandler->user_decision = CustomHandlerDB::Agreed;
- } else {
- LogDebug("User didn't allow");
- customHandler->user_decision = CustomHandlerDB::Declined;
- }
- //TODO merge to one popup
- LogDebug("Protocol handler not found");
- if (Wrt::Popup::PopupInvoker().askYesNo("REMEMBER", "Want to remember? ")) {
- LogDebug("User allowed");
- customHandler->user_decision =
- static_cast<CustomHandlerDB::HandlerState>
- (customHandler->user_decision | CustomHandlerDB::DecisionSaved);
- } else {
- LogDebug("User didn't allow");
- }
+ Wrt::Popup::PopupResponse response =
+ GlobalSettings::PopupsTestModeEnabled() ? Wrt::Popup::YES_DO_REMEMBER :
+ Wrt::Popup::PopupInvoker().askYesNoCheckbox(
+ PROTOCOL_HANDLER_ASK_TITLE,
+ PROTOCOL_HANDLER_ASK_MSG,
+ PROTOCOL_HANDLER_ASK_REMEMBER);
+ saveUserResponse(response, customHandler);
if (customHandler->user_decision == CustomHandlerDB::Declined)
return;
handlersDao.registerProtocolHandler(*(customHandler.get()));
LogDebug("Protocol already registered - nothing to do");
} else {
LogDebug("Protocol handler not found");
- if (Wrt::Popup::PopupInvoker().askYesNo(PROTOCOL_HANDLER_ASK_TITLE, PROTOCOL_HANDLER_ASK_MSG)) {
- LogDebug("User allowed");
- customHandler->user_decision = CustomHandlerDB::Agreed;
- } else {
- LogDebug("User didn't allow");
- customHandler->user_decision = CustomHandlerDB::Declined;
- }
- //TODO merge to one popup
- LogDebug("Protocol handler not found");
- if (Wrt::Popup::PopupInvoker().askYesNo("REMEMBER", "Want to remember? ")) {
- LogDebug("User allowed");
- customHandler->user_decision =
- static_cast<CustomHandlerDB::HandlerState>
- (customHandler->user_decision | CustomHandlerDB::DecisionSaved);
- } else {
- LogDebug("User didn't allow");
- }
+ Wrt::Popup::PopupResponse response =
+ GlobalSettings::PopupsTestModeEnabled() ? Wrt::Popup::YES_DO_REMEMBER :
+ Wrt::Popup::PopupInvoker().askYesNoCheckbox(
+ CONTENT_HANDLER_ASK_TITLE,
+ CONTENT_HANDLER_ASK_MSG,
+ CONTENT_HANDLER_AKS_REMEMBER);
+ saveUserResponse(response, customHandler);
if (customHandler->user_decision == CustomHandlerDB::Declined)
return;
handlersDao.registerContentHandler(*(customHandler.get()));