21 #include <QJsonDocument> 22 #include <QJsonObject> 23 #include <QQuickWindow> 29 #define SCREEN_AREA "OnScreen" 30 #define SCREEN_NAME "OnScreenApp" 55 mp_wm =
new QLibWindowmanager();
56 mp_wm->init(port, token);
58 mp_hs =
new LibHomeScreen();
59 mp_hs->init(port, token);
62 mp_hs->set_event_handler(LibHomeScreen::Event_OnScreenMessage, [
this](json_object *
object){
63 struct json_object *value;
64 json_object_object_get_ex(
object,
"display_message", &value);
65 const char *display_message = json_object_get_string(value);
67 HMI_DEBUG(
"onscreenapp",
"display_message = %s", display_message);
69 QString data(display_message);
70 QJsonDocument doc = QJsonDocument::fromJson(data.toUtf8());
71 QJsonObject jsonObj(doc.object());
75 if (jsonObj.contains(
"app")) {
76 HMI_DEBUG(
"onscreenapp",
"json parse. app is %s", jsonObj[
"app"].toString());
77 osm.app = jsonObj[
"app"].toString();
80 if (jsonObj.contains(
"message")) {
81 HMI_DEBUG(
"onscreenapp",
"json parse. message is %s", jsonObj[
"message"].toString());
82 osm.message = jsonObj[
"message"].toString();
85 if (jsonObj.contains(
"file")) {
86 HMI_DEBUG(
"onscreenapp",
"json parse. file is %s", jsonObj[
"file"].toString());
87 osm.file = jsonObj[
"file"].toString();
89 if (osm.file.left(1) ==
"/") {
90 osm.file = QUrl::fromLocalFile(osm.file).toString();
94 if (jsonObj.contains(
"mask")) {
95 HMI_DEBUG(
"onscreenapp",
"json parse. mask is %s", jsonObj[
"mask"].toString());
96 osm.mask = jsonObj[
"mask"].toString();
100 for(QVector<ON_SCREEN_MESSAGE>::iterator it = m_vecOSM.begin(); it != m_vecOSM.end(); ++it) {
101 if (it->app == osm.app) {
102 it->message = osm.message;
111 m_vecOSM.append(osm);
114 if (osm.app ==
"Phone") {
115 if (osm.message ==
"incoming call") {
120 else if (osm.message ==
"call rejected") {
124 else if (osm.app ==
"System") {
125 if (osm.message ==
"error") {
130 else if (osm.message ==
"rejected") {
159 HMI_DEBUG(
"onscreenapp",
"!!!!LayoutHandler requestSurface Failed!!!!!");
163 mp_wm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [
this](json_object *
object) {
168 mp_wm->set_event_handler(QLibWindowmanager::Event_Active, [
this](json_object *
object) {
169 struct json_object *value;
170 json_object_object_get_ex(
object,
"drawing_name", &value);
171 const char *name = json_object_get_string(value);
173 HMI_DEBUG(
"onscreenapp",
"Event_Active kKeyDrawingName = %s", name);
176 mp_wm->set_event_handler(QLibWindowmanager::Event_Inactive, [
this](json_object *
object) {
177 struct json_object *value;
178 json_object_object_get_ex(
object,
"drawing_name", &value);
179 const char *name = json_object_get_string(value);
181 HMI_DEBUG(
"onscreenapp",
"Event_Inactive kKeyDrawingName = %s", name);
184 HMI_DEBUG(
"onscreenapp",
"LayoutHander::init() finished.");
198 const char* str = json_object_to_json_string(reply_contents);
199 HMI_DEBUG(
"onscreenapp",
"EventHandler::onReply %s", str);
204 HMI_DEBUG(
"onscreenapp",
"EventHandler::activateSurface()");
205 if (m_isActive ==
false) {
216 HMI_DEBUG(
"onscreenapp",
"EventHandler::deactivateSurface()");
218 for(QVector<ON_SCREEN_MESSAGE>::iterator it = m_vecOSM.begin(); it != m_vecOSM.end(); ++it) {
219 if (it->app == app) {
225 if (m_vecOSM.length() > 0) {
228 if (!osm.
file.isEmpty()) {
242 HMI_DEBUG(
"onscreenapp",
"EventHandler::onScreenReply()");
243 mp_hs->onScreenReply(message.toLatin1());
247 void EventHandler::slotActivateSurface(){
256 void EventHandler::setWindowMask(QString maskfile)
258 HMI_DEBUG(
"onscreenapp",
"EventHandler::setWindowMask()");
259 HMI_DEBUG(
"onscreenapp",
"maskfile = %s", maskfile);
261 QImage img(maskfile);
262 QPixmap mask = QPixmap::fromImage(img);
264 if (mask.hasAlphaChannel()) {
265 HMI_DEBUG(
"onscreenapp",
"input maskfile has alpha.");
266 mp_qw->setMask(mask.mask());
269 HMI_DEBUG(
"onscreenapp",
"!!!! maskfile does not have alpha!!!!");
+
+
#define HMI_DEBUG(prefix, args,...)
+
void deactivateSurface(QString app)
+
+
void init(int port, const char *token)
+
void onRep(struct json_object *reply_contents)
+
void activateSurface(QString app)
+
void setQuickWindow(QQuickWindow *qw)
+
+
+
+
void signalLoader(QVariant url)
+
Q_INVOKABLE void onScreenReply(const QString &message)
+
+
static void onRep_static(struct json_object *reply_contents)
+
void signalSetClearBackgroud()
+
EventHandler(QObject *parent=0)
+
+