onscreenapp: Initial clean-up in code
[apps/onscreenapp.git] / app / eventhandler.h
1 /*
2  * Copyright (c) 2019 TOYOTA MOTOR CORPORATION
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 #ifndef HOMESCREENHANDLER_H
18 #define HOMESCREENHANDLER_H
19
20 #include <QObject>
21 #include <string>
22 #include <QVariant>
23 #include <QPair>
24 #include "hmi-debug.h"
25
26 #define APP_ID "onscreenapp"
27
28 class QQmlApplicationEngine;
29
30 class EventHandler : public QObject
31 {
32     Q_OBJECT
33 public:
34     explicit EventHandler(QObject *parent = 0);
35     ~EventHandler();
36
37     EventHandler(const EventHandler&) = delete;
38     EventHandler& operator=(const EventHandler&) = delete;
39
40     void init(int port, const char* token);
41
42     static void* myThis;
43
44     Q_INVOKABLE void deactivateWindow();
45     Q_INVOKABLE void onScreenReply(const QString &ons_title, const QString &btn_name);
46
47 signals:
48     void updateModel(QVariant data);
49     void showOnScreen();
50     void hideOnScreen();
51
52 private:
53     enum {
54         HIDING = 0,
55         SHOWING,
56         SWAPPING
57     };
58
59     int getDisplayStatus() {return m_dsp_sts;}
60     void setDisplayStatus(int sts) {m_dsp_sts = sts;}
61     void activateWindow(const char *role, const char *area = "normal.full");
62
63     QPair<QString, QString> m_req, m_dsp;
64     int m_dsp_sts = HIDING;
65 };
66 #endif // HOMESCREENHANDLER_H