use appid instead of appname in "tap_shortcut" 35/17735/1
authorwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>
Tue, 6 Nov 2018 02:17:27 +0000 (10:17 +0800)
committerwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>
Tue, 6 Nov 2018 02:17:27 +0000 (10:17 +0800)
Now In homescreen-service used application_id to identify
different application, so use appid instead of appname
in "tap_shortcut" parameter.

Bug-AGL: SPEC-1764

Change-Id: I46af214cf25108ca0c2983a54547ab1f64f9ab59
Signed-off-by: wang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>
include/libhomescreen.hpp
sample/simple-egl/src/simple-egl.cpp
sample/template/main.cpp
src/libhomescreen.cpp

index 4a92059..54662d4 100644 (file)
@@ -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);
 
index 799729b..4271a66 100644 (file)
@@ -570,14 +570,8 @@ 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());
-                       wm->activateWindow(main_role);
-               }
+               HMI_DEBUG("simple-egl","try to activesurface %s ", app_name.c_str());
+               wm->activateWindow(main_role);
        });
 
        return 0;
index 831df41..fef270b 100644 (file)
@@ -146,16 +146,12 @@ int main(int argc, char *argv[])
 
         // Set event handler
         hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [wm](json_object *object) {
-            const char *appname = json_object_get_string(
-                           json_object_object_get(object, "application_name"));
-            if(myname == appname) {
-                qDebug("Surface %s got tapShortcut\n", appname);
-                // Application should call LibWindowmanager::endDraw() in TapShortcut handler
-                               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);
-            }
+            qDebug("Surface %s got tapShortcut\n", myname.c_str());
+            // Application should call LibWindowmanager::endDraw() in TapShortcut handler
+            json_object *obj = json_object_new_object();
+            json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(myname.c_str()));
+            json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string("normal.full"));
+            wm->activateSurface(obj);
         });
 
         /*
index c3e76ba..29ba7ef 100644 (file)
@@ -203,12 +203,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 (label)
  *
  * #### 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 +216,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);
 }
 
@@ -445,8 +445,8 @@ 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"}
+* event is like "homescreen/hvac"
+* msg is like {"event":"homescreen\/hvac","data":{"type":"tap_shortcut"},"jtype":"afb-event"}
 * so you can get
        event name : struct json_object obj = json_object_object_get(msg,"event")
 */