From e5d2527df6b684b38f57e35db970f4b8210f81a4 Mon Sep 17 00:00:00 2001 From: wang_zhiqiang Date: Mon, 21 Jan 2019 18:07:29 +0800 Subject: add applistchanged event & delete area defination Change-Id: I3c58712a2e4f080cc75387f94d3d91bb3cba6629 --- include/libhomescreen.hpp | 16 +++++----------- src/libhomescreen.cpp | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/include/libhomescreen.hpp b/include/libhomescreen.hpp index 0fed49f..b9f5e75 100644 --- a/include/libhomescreen.hpp +++ b/include/libhomescreen.hpp @@ -40,6 +40,7 @@ public: using handler_func = std::function; enum EventType { + Event_Min, Event_ShowWindow = 1, Event_TapShortcut = 1, Event_OnScreenMessage, @@ -47,19 +48,11 @@ public: Event_HideWindow, Event_ReplyShowWindow, Event_ShowNotification, - Event_ShowInformation + Event_ShowInformation, + Event_AppListChanged, + Event_Max }; - /* Key for json obejct */ - const char *_keyParameter = "parameter"; - const char *_keyArea = "area"; - - /* display area */ - const char *_areaNormal = "normal"; - const char *_areaFullScreen = "fullscreen"; - const char *_areaSplitMain = "split.main"; - const char *_areaSplitSub = "split.sub"; - static const std::vector api_list; static const std::vector event_list; @@ -87,6 +80,7 @@ public: int replyShowWindow(const char* application_id, json_object* json); int showNotification(json_object* json); int showInformation(json_object* json); + int getRunnables(void); private: diff --git a/src/libhomescreen.cpp b/src/libhomescreen.cpp index 84e3472..b54e373 100644 --- a/src/libhomescreen.cpp +++ b/src/libhomescreen.cpp @@ -46,7 +46,8 @@ const std::vector LibHomeScreen::api_list { std::string("hideWindow"), std::string("replyShowWindow"), std::string("showNotification"), - std::string("showInformation") + std::string("showInformation"), + std::string("getRunnables") }; const std::vector LibHomeScreen::event_list { @@ -58,6 +59,7 @@ const std::vector LibHomeScreen::event_list { std::string("replyShowWindow"), std::string("showNotification"), std::string("showInformation"), + std::string("application-list-changed"), std::string("none") }; @@ -294,7 +296,7 @@ int LibHomeScreen::onScreenReply(const char* reply_message) */ void LibHomeScreen::set_event_handler(enum EventType et, handler_func f) { - if (et >= 1 && et <= 7) { + if (et > Event_Min && et < Event_Max) { switch (et) { case Event_ShowWindow: this->subscribe(LibHomeScreen::event_list[0]); @@ -317,6 +319,9 @@ void LibHomeScreen::set_event_handler(enum EventType et, handler_func f) case Event_ShowInformation: this->subscribe(LibHomeScreen::event_list[6]); break; + case Event_AppListChanged: + this->subscribe(LibHomeScreen::event_list[7]); + break; } this->handlers[et] = std::move(f); @@ -588,6 +593,23 @@ int LibHomeScreen::showInformation(json_object* json) return this->call("showInformation", json); } +/** + * get runnables list + * + * Call HomeScreen Service's getRunnables verb to get runnalbes list. + * + * #### Parameters + * - Nothing + * + * #### Return + * - Returns 0 on success or -1 in case of error. + * + */ +int LibHomeScreen::getRunnables(void) +{ + return this->call("getRunnables", nullptr); +} + /************* Callback Function *************/ @@ -683,6 +705,12 @@ void LibHomeScreen::on_event(void *closure, const char *event, struct afb_wsj1_m i->second(json_data); } } + else if (strcasecmp(event_type, LibHomeScreen::event_list[7].c_str()) == 0) { + auto i = this->handlers.find(Event_AppListChanged); + if ( i != this->handlers.end() ) { + i->second(json_data); + } + } } /** -- cgit 1.2.3-korg