Add notification daemon
[platform/core/security/askuser.git] / src / agent / notification-daemon / GuiRunner.h
1 /*
2  *  Copyright (c) 2016 Samsung Electronics Co.
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License
15  */
16 /**
17  * @file        src/notification-daemon/GuiRunner.h
18  * @author      Oskar Ĺšwitalski <o.switalski@samsung.com>
19  * @brief       Declaration of GuiRunner class
20  */
21
22 #pragma once
23
24 #include <Elementary.h>
25 #include <functional>
26 #include <string>
27
28 #include <types/NotificationResponse.h>
29 #include <log/alog.h>
30
31 namespace AskUser {
32
33 namespace Notification {
34
35 typedef std::function<bool()> DropHandler;
36
37 struct PopupData {
38     NResponseType type;
39     Evas_Object *win;
40 };
41
42 struct drop {
43     DropHandler handle;
44     PopupData *popup;
45 };
46
47 class GuiRunner {
48 public:
49     GuiRunner();
50
51     NResponseType popupRun(const std::string &app, const std::string &perm);
52
53     void setDropHandler(DropHandler dropHandler);
54     void stop();
55
56     std::string getErrorMsg() { return m_errorMsg; }
57
58 private:
59     PopupData *m_popupData;
60     DropHandler m_dropHandler;
61
62     Evas_Object *m_win;
63     Evas_Object *m_popup;
64     Evas_Object *m_box;
65     Evas_Object *m_content;
66     Evas_Object *m_allowButton;
67     Evas_Object *m_neverButton;
68     Evas_Object *m_denyButton;
69     Ecore_Timer *m_timer;
70
71     bool m_running = false;
72     bool m_initialized = false;
73
74     std::string m_errorMsg;
75
76     void initialize();
77 };
78
79 } /* namespace Notification */
80
81 } /* namespace AskUser */