fix issues
[src/libqthomescreen.git] / src / qlibhomescreen.h
1 /*
2  * Copyright (c) 2017 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 QLIBHOMESCREEN_H
18 #define QLIBHOMESCREEN_H
19
20 #include <QObject>
21 #include <QQuickWindow>
22 #include <libhomescreen.hpp>
23 #include <functional>
24 #include <QVariant>
25
26 class QLibHomeScreen : public QObject
27 {
28     Q_OBJECT
29 public:
30     explicit QLibHomeScreen(QObject *parent = 0);
31     ~QLibHomeScreen();
32
33     QLibHomeScreen(const QLibHomeScreen &) = delete;
34     QLibHomeScreen &operator=(const QLibHomeScreen &) = delete;
35
36     enum QEventType {
37        Event_TapShortcut = LibHomeScreen::Event_TapShortcut,
38        Event_ShowWindow = LibHomeScreen::Event_ShowWindow,
39        Event_OnScreenMessage = LibHomeScreen::Event_OnScreenMessage,
40        Event_OnScreenReply = LibHomeScreen::Event_OnScreenReply,
41        Event_HideWindow = LibHomeScreen::Event_HideWindow,
42        Event_ReplyShowWindow = LibHomeScreen::Event_ReplyShowWindow,
43        Event_ShowNotification = LibHomeScreen::Event_ShowNotification,
44        Event_ShowInformation = LibHomeScreen::Event_ShowInformation,
45        Event_AppListChanged = LibHomeScreen::Event_AppListChanged,
46        Event_RegisterShortcut = LibHomeScreen::Event_RegisterShortcut,
47        Event_UpdateShortcut = LibHomeScreen::Event_UpdateShortcut,
48        Event_SetDestination = LibHomeScreen::Event_SetDestination,
49        Event_CancelDestination = LibHomeScreen::Event_CancelDestination,
50        Event_StartNavigation = LibHomeScreen::Event_StartNavigation,
51        Event_StopNavigation = LibHomeScreen::Event_StopNavigation
52     };
53     using handler_fun = std::function<void(json_object *object)>;
54
55     void init(int port, const QString &token);
56     void set_event_handler(enum QEventType et, handler_fun f);
57     void showWindow(QString application_id, json_object* area);
58     void replyShowWindow(QString application_id, json_object* reply);
59     Q_INVOKABLE void showInformation(QString info);
60     Q_INVOKABLE void showNotification(QString icon, QString text);
61
62     Q_INVOKABLE int onScreenMessage(const QString &message);
63     Q_INVOKABLE int subscribe(const QString &eventName);
64     Q_INVOKABLE int unsubscribe(const QString &eventName);
65     Q_INVOKABLE void tapShortcut(QString application_id);
66     Q_INVOKABLE void showWindow(QString application_id, QString area);
67     Q_INVOKABLE void hideWindow(QString application_id);
68     Q_INVOKABLE void replyShowWindow(QString application_id, QString reply);
69     Q_INVOKABLE void getRunnables(void);
70     Q_INVOKABLE int registerShortcut(QString shortcut_id, QString shortcut_name, QString position);
71     Q_INVOKABLE int updateShortcut(QString application_id, QString shortcut_id, QString shortcut_name);
72     int updateShortcut(QString application_id, struct json_object* obj);
73     void registerCallback(
74         void (*event_cb)(const std::string& event, struct json_object* event_contents),
75         void (*reply_cb)(struct json_object* reply_contents),
76         void (*hangup_cb)(void) = nullptr);
77     void setQuickWindow(QQuickWindow *qw);
78
79 signals:
80
81 public slots:
82     void slotPublishSubscription(void);
83
84 private:
85     LibHomeScreen *mp_hs;
86     QQuickWindow *mp_window;
87     QMetaObject::Connection m_loading;
88 };
89
90 #endif // QLIBHOMESCREEN_H