Revert "Use appid between homescreen-service and apps"
[src/libhomescreen.git] / src / libhomescreen.cpp
index c621a80..0462d4d 100644 (file)
@@ -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) {