--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co.
+ *
+ * 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
+ */
+/**
+ * @file src/agent/notification-daemon/ui/Answerable.h
+ * @author Zofia Abramowska <z.abramowska@samsung.com>
+ * @brief Implementation Answerable button pressed events classes
+ */
+#pragma once
+
+#include "PopupCheck.h"
+#include "Popup.h"
+
+#include <types/NotificationResponse.h>
+
+namespace AskUser {
+namespace Notification {
+
+class IAnswerable {
+public:
+ enum class Button {
+ ALLOW,
+ DENY
+ };
+ typedef std::function<void(int, NResponseType)> AnswerHandler;
+
+ IAnswerable(AnswerHandler handler) : m_handler(handler) {}
+ virtual void process(enum Button) const = 0;
+ virtual ~IAnswerable() {}
+protected:
+ AnswerHandler m_handler;
+};
+
+class AnswerablePopupCheck : public IAnswerable {
+public:
+ AnswerablePopupCheck(PopupCheck *popup, AnswerHandler handler)
+ : IAnswerable(handler), m_popup(popup) {}
+ virtual void process(enum Button button) const {
+ NResponseType answer;
+ switch (button) {
+ case IAnswerable::Button::ALLOW:
+ if (m_popup->getCheckboxState())
+ answer = NResponseType::AllowAlways;
+ else
+ answer = NResponseType::Allow;
+ break;
+ case IAnswerable::Button::DENY:
+ if (m_popup->getCheckboxState())
+ answer = NResponseType::DenyAlways;
+ else
+ answer = NResponseType::Deny;
+ break;
+ default:
+ answer = NResponseType::Error;
+ }
+ m_handler(m_popup->getId(), answer);
+ }
+private:
+ PopupCheck *m_popup;
+};
+
+class AnswerablePopupLaunch : public IAnswerable {
+public:
+ AnswerablePopupLaunch(Popup *popup, AnswerHandler handler)
+ : IAnswerable(handler), m_popup(popup) {}
+ virtual void process(enum Button button) const {
+ NResponseType answer;
+ switch (button) {
+ case IAnswerable::Button::ALLOW:
+ answer = NResponseType::AllowAlways;
+ break;
+ case IAnswerable::Button::DENY:
+ answer = NResponseType::DenyAlways;
+ break;
+ default:
+ answer = NResponseType::Error;
+ }
+ m_handler(m_popup->getId(), answer);
+ }
+private:
+ Popup *m_popup;
+};
+
+} // namespace AskUser
+} // namespace Notification