aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>2018-08-06 12:00:28 +0900
committerScott Murray <scott.murray@konsulko.com>2018-08-16 13:45:13 -0400
commit58d5aa69c638b5e6d59f858516385e01fe248031 (patch)
tree3f4861d711cd4f0ef0a1406912dc7fbbf374cc6d
parentba66f5506b4abdaf61ff5caa51dadc3d397fe5a0 (diff)
Use appid between homescreen-service and appsflounder_5.99.3flounder/5.99.35.99.3
Use appid between hss and apps, and check event destination in libhomescreen. So these is no need compare code when recived Event_TapShortcut Event. [Patch Sets 2] Make a copy of the string returned by getenv. BUG-AGL: SPEC-1645 Change-Id: I042015ee92c4c142418b1ac15d51a9408e219757 Signed-off-by: zheng_wenlong <wenlong_zheng@nexty-ele.com> Signed-off-by: Scott Murray <scott.murray@konsulko.com>
-rw-r--r--include/libhomescreen.hpp3
-rw-r--r--sample/simple-egl/src/simple-egl.cpp16
-rw-r--r--src/libhomescreen.cpp36
3 files changed, 33 insertions, 22 deletions
diff --git a/include/libhomescreen.hpp b/include/libhomescreen.hpp
index 4a92059..ea35d1e 100644
--- a/include/libhomescreen.hpp
+++ b/include/libhomescreen.hpp
@@ -51,7 +51,7 @@ public:
/* Method */
int init(const int port, const std::string& token);
- int tapShortcut(const char* application_name);
+ int tapShortcut(const char* application_id);
int onScreenMessage(const char* display_message);
int onScreenReply(const char* reply_message);
@@ -77,6 +77,7 @@ private:
struct afb_wsj1* sp_websock;
struct afb_wsj1_itf minterface;
sd_event* mploop;
+ std::string mapp_id;
std::string muri;
int mport = 2000;
diff --git a/sample/simple-egl/src/simple-egl.cpp b/sample/simple-egl/src/simple-egl.cpp
index be694d7..f56cf4d 100644
--- a/sample/simple-egl/src/simple-egl.cpp
+++ b/sample/simple-egl/src/simple-egl.cpp
@@ -579,17 +579,11 @@ init_hs(LibHomeScreen* hs){
}
hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [](json_object *object){
- const char *application_name = json_object_get_string(
- json_object_object_get(object, "application_name"));
- HMI_DEBUG("simple-egl","Event_TapShortcut application_name = %s ", application_name);
- if(strcmp(application_name, app_name.c_str()) == 0)
- {
- HMI_DEBUG("simple-egl","try to activesurface %s ", app_name.c_str());
- json_object *obj = json_object_new_object();
- json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(app_name.c_str()));
- json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string("normal.full"));
- wm->activateSurface(obj);
- }
+ HMI_DEBUG("simple-egl","try to activesurface %s ", app_name.c_str());
+ json_object *obj = json_object_new_object();
+ json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(app_name.c_str()));
+ json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string("normal.full"));
+ wm->activateSurface(obj);
});
return 0;
diff --git a/src/libhomescreen.cpp b/src/libhomescreen.cpp
index 0462d4d..c621a80 100644
--- a/src/libhomescreen.cpp
+++ b/src/libhomescreen.cpp
@@ -115,6 +115,7 @@ LibHomeScreen::~LibHomeScreen()
int LibHomeScreen::init(const int port, const string& token)
{
int ret = 0;
+
if(port > 0 && token.size() > 0)
{
mport = port;
@@ -134,6 +135,16 @@ int LibHomeScreen::init(const int port, const string& token)
HMI_DEBUG("libhomescreen","Initialized");
}
+ mapp_id = std::getenv("AFM_ID");
+ if(mapp_id.size()) {
+ mapp_id.erase(mapp_id.find('@'));
+ HMI_DEBUG("libhomescreen","My application id is: %s.", mapp_id);
+ }
+ else
+ {
+ HMI_ERROR("libhomescreen","Failed to get my application id");
+ }
+
return ret;
}
@@ -203,12 +214,12 @@ END:
* When HomeScreen shortcut area is tapped, sending a event
*
* #### Parameters
- * - application_name [in] : Tapped application name (label)
+ * - application_id [in] : Tapped application id
*
* #### Return
* - Returns 0 on success or -1 in case of error.
*/
-int LibHomeScreen::tapShortcut(const char* application_name)
+int LibHomeScreen::tapShortcut(const char* application_id)
{
if(!sp_websock)
{
@@ -216,8 +227,8 @@ int LibHomeScreen::tapShortcut(const char* application_name)
}
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);
+ struct json_object* val = json_object_new_string(application_id);
+ json_object_object_add(j_obj, "application_id", val);
return this->call("tap_shortcut", j_obj);
}
@@ -446,14 +457,12 @@ void LibHomeScreen::on_call(void *closure, const char *api, const char *verb, st
/*
* event is like "homescreen/tap_shortcut"
-* msg is like {"event":"homescreen\/tap_shortcut","data":{"application_name":"hoge"},"jtype":"afb-event"}
+* msg is like {"event":"homescreen\/tap_shortcut","data":{"application_id":"hoge"},"jtype":"afb-event"}
* so you can get
event name : struct json_object obj = json_object_object_get(msg,"event")
*/
void LibHomeScreen::on_event(void *closure, const char *event, struct afb_wsj1_msg *msg)
{
- HMI_DEBUG("libhomescreen","event: (%s) msg: (%s).", event, afb_wsj1_msg_object_s(msg));
-
if (strstr(event, API) == NULL) {
return;
}
@@ -476,9 +485,16 @@ void LibHomeScreen::on_event(void *closure, const char *event, struct afb_wsj1_m
}
if (strcasecmp(event_only, LibHomeScreen::event_list[0].c_str()) == 0) {
- auto i = this->handlers.find(Event_TapShortcut);
- if ( i != this->handlers.end() ) {
- i->second(json_data);
+ struct json_object *j_id;
+ json_object_object_get_ex(json_data, "application_id", &j_id);
+ const char* app_id = json_object_get_string(j_id);
+
+ if(!strcasecmp(app_id, mapp_id.c_str())) {
+ HMI_DEBUG("libhomescreen","send Event_TapShortcut to: (%s).", mapp_id.c_str());
+ auto i = this->handlers.find(Event_TapShortcut);
+ if ( i != this->handlers.end() ) {
+ i->second(json_data);
+ }
}
}
else if (strcasecmp(event_only, LibHomeScreen::event_list[1].c_str()) == 0) {