Add tapShortcut event for launcher application
[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 <libhomescreen.hpp>
22 #include <functional>
23 #include <QVariant>
24
25 class QLibHomeScreen : public QObject
26 {
27     Q_OBJECT
28 public:
29     explicit QLibHomeScreen(QObject *parent = 0);
30     ~QLibHomeScreen();
31
32     QLibHomeScreen(const QLibHomeScreen &) = delete;
33     QLibHomeScreen &operator=(const QLibHomeScreen &) = delete;
34
35     enum QEventType {
36        Event_TapShortcut = LibHomeScreen::Event_TapShortcut,
37        Event_OnScreenReply = LibHomeScreen::Event_OnScreenReply
38     };
39     using handler_fun = std::function<void(json_object *object)>;
40
41     void init(int port, const QString &token);
42     void set_event_handler(enum QEventType et, handler_fun f);
43     Q_INVOKABLE int onScreenMessage(const QString &message);
44     Q_INVOKABLE int subscribe(const QString &eventName);
45     Q_INVOKABLE int unsubscribe(const QString &eventName);
46     Q_INVOKABLE void tapShortcut(QString application_name);
47
48 signals:
49
50 private:
51     LibHomeScreen *mp_hs;
52 };
53
54 #endif // QLIBHOMESCREEN_H