add als2019 source code
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>
Mon, 20 May 2019 07:02:58 +0000 (16:02 +0900)
committerzheng_wenlong <wenlong_zheng@nexty-ele.com>
Mon, 20 May 2019 07:02:58 +0000 (16:02 +0900)
include/libhomescreen.hpp
src/libhomescreen.cpp

index e51e01c..0361fa4 100644 (file)
@@ -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:
index ad18ca4..9c50c86 100644 (file)
@@ -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);
+        }
+    }
 }
 
 /**