From d22ffadbe9fcb13144264e71da300bdf56724906 Mon Sep 17 00:00:00 2001 From: Tadao Tanikawa Date: Fri, 24 Aug 2018 04:42:40 +0000 Subject: Revert "Use appid between homescreen-service and apps" This reverts commit 58d5aa69c638b5e6d59f858516385e01fe248031. Bug-AGL: SPEC-1685 Change-Id: I166edba9dcc41a7f2e5d9c7a9a6bd75216a27be8 Signed-off-by: Tadao Tanikawa --- include/libhomescreen.hpp | 3 +-- sample/simple-egl/src/simple-egl.cpp | 16 +++++++++++----- src/libhomescreen.cpp | 36 ++++++++++-------------------------- 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/include/libhomescreen.hpp b/include/libhomescreen.hpp index ea35d1e..4a92059 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_id); + int tapShortcut(const char* application_name); int onScreenMessage(const char* display_message); int onScreenReply(const char* reply_message); @@ -77,7 +77,6 @@ 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 f56cf4d..be694d7 100644 --- a/sample/simple-egl/src/simple-egl.cpp +++ b/sample/simple-egl/src/simple-egl.cpp @@ -579,11 +579,17 @@ init_hs(LibHomeScreen* hs){ } hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [](json_object *object){ - 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); + 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); + } }); return 0; diff --git a/src/libhomescreen.cpp b/src/libhomescreen.cpp index c621a80..0462d4d 100644 --- a/src/libhomescreen.cpp +++ b/src/libhomescreen.cpp @@ -115,7 +115,6 @@ LibHomeScreen::~LibHomeScreen() int LibHomeScreen::init(const int port, const string& token) { int ret = 0; - if(port > 0 && token.size() > 0) { mport = port; @@ -135,16 +134,6 @@ 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; } @@ -214,12 +203,12 @@ END: * When HomeScreen shortcut area is tapped, sending a event * * #### Parameters - * - application_id [in] : Tapped application id + * - application_name [in] : Tapped application name (label) * * #### Return * - Returns 0 on success or -1 in case of error. */ -int LibHomeScreen::tapShortcut(const char* application_id) +int LibHomeScreen::tapShortcut(const char* application_name) { if(!sp_websock) { @@ -227,8 +216,8 @@ int LibHomeScreen::tapShortcut(const char* application_id) } struct json_object* j_obj = json_object_new_object(); - struct json_object* val = json_object_new_string(application_id); - json_object_object_add(j_obj, "application_id", val); + 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); } @@ -457,12 +446,14 @@ 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_id":"hoge"},"jtype":"afb-event"} +* msg is like {"event":"homescreen\/tap_shortcut","data":{"application_name":"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; } @@ -485,16 +476,9 @@ void LibHomeScreen::on_event(void *closure, const char *event, struct afb_wsj1_m } if (strcasecmp(event_only, LibHomeScreen::event_list[0].c_str()) == 0) { - 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); - } + 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) { -- cgit 1.2.3-korg