aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>2018-10-30 14:29:15 +0900
committerzheng_wenlong <wenlong_zheng@nexty-ele.com>2018-10-30 14:29:15 +0900
commitb98e130e1dbedf7064678a1da4ebfaa0544c99d2 (patch)
treec9fb9513a23144e2edaefc5f54006efac55746cd
parent8bf11a8668902565b0e9a23e320777f5fb611848 (diff)
add source for ces2019
-rw-r--r--include/libhomescreen.hpp8
-rw-r--r--src/libhomescreen.cpp136
2 files changed, 134 insertions, 10 deletions
diff --git a/include/libhomescreen.hpp b/include/libhomescreen.hpp
index 4a92059..f07e62f 100644
--- a/include/libhomescreen.hpp
+++ b/include/libhomescreen.hpp
@@ -40,9 +40,12 @@ public:
using handler_func = std::function<void(json_object*)>;
enum EventType {
+ Event_ShowWindow = 1,
Event_TapShortcut = 1,
Event_OnScreenMessage,
- Event_OnScreenReply
+ Event_OnScreenReply,
+ Event_AllocateRestriction,
+ Event_ReleaseRestriction
};
static const std::vector<std::string> api_list;
@@ -66,6 +69,9 @@ public:
int call(const char* verb, struct json_object* arg);
int subscribe(const std::string& event_name);
int unsubscribe(const std::string& event_name);
+ int allocateRestriction(const char* area);
+ int releaseRestriction(const char* area);
+ int showWindow(const char* id, json_object* json);
private:
int initialize_websocket();
diff --git a/src/libhomescreen.cpp b/src/libhomescreen.cpp
index c3e76ba..9689863 100644
--- a/src/libhomescreen.cpp
+++ b/src/libhomescreen.cpp
@@ -36,17 +36,23 @@ static const char API[] = "homescreen";
const std::vector<std::string> LibHomeScreen::api_list {
std::string("ping"), // debug do not use
- std::string("tap_shortcut"), // HomeScreen Application only
+// std::string("tap_shortcut"), // HomeScreen Application only
std::string("on_screen_message"),
std::string("on_screen_reply"),
std::string("subscribe"),
- std::string("unsubscribe")
+ std::string("unsubscribe"),
+ std::string("showWindow"),
+ std::string("allocateRestriction"),
+ std::string("releaseRestriction")
};
const std::vector<std::string> LibHomeScreen::event_list {
- std::string("tap_shortcut"),
+// std::string("tap_shortcut"),
+ std::string("showWindow"),
std::string("on_screen_message"),
std::string("on_screen_reply"),
+ std::string("allocateRestriction"),
+ std::string("releaseRestriction"),
std::string("none")
};
@@ -215,10 +221,11 @@ int LibHomeScreen::tapShortcut(const char* application_name)
return -1;
}
- struct json_object* j_obj = json_object_new_object();
- struct json_object* val = json_object_new_string(application_name);
- json_object_object_add(j_obj, "application_name", val);
- return this->call("tap_shortcut", j_obj);
+ struct json_object* obj = json_object_new_object();
+ struct json_object* val = json_object_new_string("normal");
+ json_object_object_add(obj, "area", val);
+
+ return showWindow(application_name, obj);
}
/**
@@ -287,9 +294,13 @@ int LibHomeScreen::onScreenReply(const char* reply_message)
*/
void LibHomeScreen::set_event_handler(enum EventType et, handler_func f)
{
- if (et >= 1 && et <= 3) {
+ if (et >= 1 && et <= 5) {
switch (et) {
- case Event_TapShortcut:
+/* case Event_TapShortcut:
+ this->subscribe(LibHomeScreen::event_list[0]);
+ break;
+*/
+ case Event_ShowWindow:
this->subscribe(LibHomeScreen::event_list[0]);
break;
case Event_OnScreenMessage:
@@ -298,6 +309,12 @@ void LibHomeScreen::set_event_handler(enum EventType et, handler_func f)
case Event_OnScreenReply:
this->subscribe(LibHomeScreen::event_list[2]);
break;
+ case Event_AllocateRestriction:
+ this->subscribe(LibHomeScreen::event_list[3]);
+ break;
+ case Event_ReleaseRestriction:
+ this->subscribe(LibHomeScreen::event_list[4]);
+ break;
}
this->handlers[et] = std::move(f);
@@ -429,6 +446,107 @@ int LibHomeScreen::unsubscribe(const string& event_name)
return ret;
}
+/**
+ * Sending show window event
+ *
+ * Call HomeScreen Service's showWindow verb to request display id's screen.
+ *
+ * #### Parameters
+ * - id [in] : This argument should be specified to the application's id.
+ * - json [in] : This argument should be specified to the json parameters.
+ *
+ * #### Return
+ * - Returns 0 on success or -1 in case of error.
+ *
+ */
+int LibHomeScreen::showWindow(const char* application_name, json_object* json)
+{
+ if(!sp_websock)
+ {
+ return -1;
+ }
+
+ struct json_object* j_obj = json_object_new_object();
+ struct json_object* val = json_object_new_string(application_name);
+ json_object_object_add(j_obj, "application_name", val);
+ // j_json = json;
+ if (json == nullptr) {
+ struct json_object* j_json = json_object_new_object();
+ struct json_object* value = json_object_new_string("normal");
+ json_object_object_add(j_json, "area", value);
+ json_object_object_add(j_obj, "parameter", j_json);
+ }
+ else {
+ json_object_object_add(j_obj, "parameter", json);
+ }
+
+
+ return this->call("showWindow", j_obj);
+}
+
+/**
+ * Sending allocate restriction event
+ *
+ * Call HomeScreen Service's requestRestriction verb to request restriction screen.
+ *
+ * #### Parameters
+ * - area [in] : restriction display area id.
+ *
+ * #### Return
+ * - Returns 0 on success or -1 in case of error.
+ *
+ */
+int LibHomeScreen::allocateRestriction(const char* area)
+{
+ if(!sp_websock)
+ {
+ return -1;
+ }
+
+ struct json_object* j_obj = json_object_new_object();
+ struct json_object* a_obj = json_object_new_object();
+
+ struct json_object* val = json_object_new_string(area);
+
+ json_object_object_add(j_obj, "area", val);
+
+ json_object_object_add(a_obj, "args", j_obj);
+
+ return this->call("allocateRestriction", a_obj);
+}
+
+/**
+ * Sending release restriction event
+ *
+ * Call HomeScreen Service's releaseRestriction verb to release restriction screen.
+ *
+ * #### Parameters
+ * - area [in] : restriction display area id.
+ *
+ * #### Return
+ * - Returns 0 on success or -1 in case of error.
+ *
+ */
+int LibHomeScreen::releaseRestriction(const char* area)
+{
+ if(!sp_websock)
+ {
+ return -1;
+ }
+
+ struct json_object* j_obj = json_object_new_object();
+ struct json_object* a_obj = json_object_new_object();
+
+ struct json_object* val = json_object_new_string(area);
+
+ json_object_object_add(j_obj, "area", val);
+
+ json_object_object_add(a_obj, "args", j_obj);
+
+ return this->call("releaseRestriction", a_obj);
+}
+
+
/************* Callback Function *************/
void LibHomeScreen::on_hangup(void *closure, struct afb_wsj1 *wsj)