diff options
author | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2019-05-20 16:02:58 +0900 |
---|---|---|
committer | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2019-05-20 16:02:58 +0900 |
commit | fbf27649e8b43a716d45c676acdee83292db7bbb (patch) | |
tree | 5464a4417a2e2947789e598fdbeba414ddf186f2 | |
parent | 44290c49e08fe52d6e3ed80720473577131090f4 (diff) |
add als2019 source code
-rw-r--r-- | include/libhomescreen.hpp | 2 | ||||
-rw-r--r-- | src/libhomescreen.cpp | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/include/libhomescreen.hpp b/include/libhomescreen.hpp index e51e01c..0361fa4 100644 --- a/include/libhomescreen.hpp +++ b/include/libhomescreen.hpp @@ -51,6 +51,7 @@ public: Event_ShowNotification, Event_ShowInformation, Event_AppListChanged, + Event_RegisterShortcut, Event_Max }; @@ -82,6 +83,7 @@ public: int showNotification(json_object* json); int showInformation(json_object* json); int getRunnables(void); + int registerShortcut(json_object* json); private: diff --git a/src/libhomescreen.cpp b/src/libhomescreen.cpp index ad18ca4..9c50c86 100644 --- a/src/libhomescreen.cpp +++ b/src/libhomescreen.cpp @@ -49,7 +49,8 @@ const std::vector<std::string> LibHomeScreen::api_list { std::string("replyShowWindow"), std::string("showNotification"), std::string("showInformation"), - std::string("getRunnables") + std::string("getRunnables"), + std::string("registerShortcut") }; const std::vector<std::string> LibHomeScreen::event_list { @@ -62,6 +63,7 @@ const std::vector<std::string> LibHomeScreen::event_list { std::string("showNotification"), std::string("showInformation"), std::string("application-list-changed"), + std::string("registerShortcut"), std::string("none") }; @@ -332,6 +334,9 @@ void LibHomeScreen::set_event_handler(enum EventType et, handler_func f) case Event_AppListChanged: this->subscribe(LibHomeScreen::event_list[7]); break; + case Event_RegisterShortcut: + this->subscribe(LibHomeScreen::event_list[8]); + break; } this->handlers[et] = std::move(f); @@ -620,6 +625,27 @@ int LibHomeScreen::getRunnables(void) return this->call("getRunnables", nullptr); } +/** + * register shortcut to homescreen + * + * Call HomeScreen Service's registerShortcut verb to regitster shortcut. + * + * #### Parameters + * - json [in] : This argument should be specified to the json parameters. + * + * #### Return + * - Returns 0 on success or -1 in case of error. + * + */ +int LibHomeScreen::registerShortcut(json_object* json) +{ + if(!sp_websock) + { + return -1; + } + + return this->call("registerShortcut", json); +} /************* Callback Function *************/ @@ -721,6 +747,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[8].c_str()) == 0) { + auto i = this->handlers.find(Event_RegisterShortcut); + if ( i != this->handlers.end() ) { + i->second(json_data); + } + } } /** |