From 381755e4686a08e766316aaf40e8fdfa202d48d4 Mon Sep 17 00:00:00 2001 From: zheng_wenlong Date: Fri, 29 Sep 2017 21:00:25 +0900 Subject: Add homescreen-2017 Add new homescreen-2017 with agl-service-windowmanaeger-2017 and agl-service-homescreen-2017. About this information see JIRA SPEC-871. [PatchSet2] Use aglwgt make package. Delete homescreensimulator and sampleapptimedate beacuse not use them. Change-Id: I402134d0386e76b2127ca95b9b0b48c1721b4086 Signed-off-by: zheng_wenlong --- homescreen/src/homescreenhandler.cpp | 79 ++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 homescreen/src/homescreenhandler.cpp (limited to 'homescreen/src/homescreenhandler.cpp') diff --git a/homescreen/src/homescreenhandler.cpp b/homescreen/src/homescreenhandler.cpp new file mode 100644 index 0000000..2a69034 --- /dev/null +++ b/homescreen/src/homescreenhandler.cpp @@ -0,0 +1,79 @@ +#include "homescreenhandler.h" +#include + +void* HomescreenHandler::myThis = 0; + +HomescreenHandler::HomescreenHandler(QObject *parent) : + QObject(parent), + mp_hs(NULL) +{ + +} + +HomescreenHandler::~HomescreenHandler() +{ + if (mp_hs != NULL) { + delete mp_hs; + } +} + +void HomescreenHandler::init(int port, const char *token) +{ + mp_hs = new LibHomeScreen(); + mp_hs->init(port, token); + + myThis = this; + +// mp_hs->registerCallback(HomescreenHandler::onEv_static, HomescreenHandler::onRep_static); +// mp_hs->subscribe(LibHomeScreen::event_list[0]); +// mp_hs->subscribe(LibHomeScreen::event_list[1]); + + mp_hs->registerCallback(nullptr, HomescreenHandler::onRep_static); + + mp_hs->set_event_handler(LibHomeScreen::Event_OnScreenMessage, [this](const char* display_message){ + qDebug("set_event_handler Event_OnScreenMessage display_message = %s", display_message); + }); + + mp_hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [this](const char* application_name){ + if(strcmp(application_name, "Home") == 0){ + emit this->homeButton(); + } + }); + +} + +void HomescreenHandler::tapShortcut(QString application_name) +{ + qDebug("tapShortcut %s", qPrintable(application_name)); + mp_hs->tapShortcut(application_name.toStdString().c_str()); +} + +void HomescreenHandler::onRep_static(struct json_object* reply_contents) +{ + static_cast(HomescreenHandler::myThis)->onRep(reply_contents); +} + +void HomescreenHandler::onEv_static(const string& event, struct json_object* event_contents) +{ + static_cast(HomescreenHandler::myThis)->onEv(event, event_contents); +} + +void HomescreenHandler::onRep(struct json_object* reply_contents) +{ + const char* str = json_object_to_json_string(reply_contents); + qDebug("HomeScreen onReply %s", str); +} + +void HomescreenHandler::onEv(const string& event, struct json_object* event_contents) +{ + const char* str = json_object_to_json_string(event_contents); + qDebug("HomeScreen onEv %s, contents: %s", event.c_str(), str); + + if (event.compare("homescreen/on_screen_message") == 0) { + struct json_object *json_data = json_object_object_get(event_contents, "data"); + struct json_object *json_display_message = json_object_object_get(json_data, "display_message"); + const char* display_message = json_object_get_string(json_display_message); + + qDebug("display_message = %s", display_message); + } +} -- cgit 1.2.3-korg