2 * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "qlibhomescreen.h"
18 #include <QJsonDocument>
19 #include <QJsonObject>
22 #define _POPUPREPLY "on_screen_reply"
23 #define _REQ_POPUP_MESSAGE "on_screen_message"
24 #define _TAPSHORTCUT "tap_shortcut"
25 #define _KEY_DATA "data"
26 #define _KEY_APPLICATION_DATA "application_name"
27 #define _KEY_REPLY_MESSAGE "reply_message"
28 #define _KEY_REQUEST_MESSAGE "display_message"
30 static QLibHomeScreen* myThis;
32 // Note: qlibhomescreen will be integrated to libqtappfw
34 QLibHomeScreen::QLibHomeScreen(QObject *parent) :
41 QLibHomeScreen::~QLibHomeScreen()
48 void QLibHomeScreen::init(int port, const QString &token)
50 string ctoken = token.toStdString();
51 mp_hs = new LibHomeScreen();
52 mp_hs->init(port, ctoken.c_str());
57 int QLibHomeScreen::onScreenMessage(const QString &message)
59 string str = message.toStdString();
60 return mp_hs->onScreenMessage(str.c_str());
63 int QLibHomeScreen::subscribe(const QString &evetName)
65 string str = evetName.toStdString();
66 return mp_hs->subscribe(str);
69 int QLibHomeScreen::unsubscribe(const QString &evetName)
71 string str = evetName.toStdString();
72 return mp_hs->unsubscribe(str);
75 void QLibHomeScreen::set_event_handler(enum QEventType et, handler_fun f)
77 LibHomeScreen::EventType hs_et = (LibHomeScreen::EventType)et;
78 return this->mp_hs->set_event_handler(hs_et, std::move(f));