Modify function argument from char to json
[src/libhomescreen.git] / src / libhomescreen.cpp
index 90ecec2..2f3ef44 100644 (file)
@@ -18,7 +18,6 @@
 #include <sys/socket.h>
 #include <iostream>
 #include <algorithm>
-#include <thread>
 #include <errno.h>
 #include <cassert>
 #include <cctype>
@@ -80,7 +79,6 @@ static void _on_reply_static(void *closure, struct afb_wsj1_msg *msg)
  */
 LibHomeScreen::LibHomeScreen()
 {
-
 }
 
 /**
@@ -134,8 +132,6 @@ int LibHomeScreen::init(const int port, const string& token)
                HMI_DEBUG("libhomescreen","Initialized");
        }
 
-       this->runEventloop();
-
        return ret;
 }
 
@@ -199,47 +195,6 @@ END:
        return -1;
 }
 
-static void *event_loop_run(void *args)
-{
-       struct sd_event* loop = (struct sd_event*)(args);
-       HMI_DEBUG("libhomescreen","start eventloop");
-       for(;;)
-               sd_event_run(loop, 30000000);
-}
-
-/**
- * This function start receiving the reply/event message from home screen
- *
- * #### Parameters
- * Nothing
- *
- * #### Return
- * - Returns thread_id on success or -1 in case of error.
- *
- * #### Note
- *
- */
-int LibHomeScreen::runEventloop()
-{
-       if(mploop && sp_websock)
-       {
-               pthread_t thread_id;
-           int ret = pthread_create(&thread_id, NULL, event_loop_run, mploop);
-               if(ret != 0)
-               {
-                       HMI_ERROR("libhomescreen","Cannot run eventloop due to error:%d", errno);
-                       return -1;
-               }
-               else
-                       return thread_id;
-       }
-       else
-       {
-               HMI_ERROR("libhomescreen","Connecting is not established yet");
-               return -1;
-       }
-}
-
 /**
  * Sending ShortCut Icon tapped event
  *
@@ -486,25 +441,15 @@ 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);
-
-               struct json_object *json_application_name = json_object_object_get(json_data, "application_name");
-               const char* application_name = json_object_get_string(json_application_name);
-
                if ( i != this->handlers.end() ) {
-                       i->second(application_name);
+                       i->second(json_data);
                }
        }
        else if (strcasecmp(event_only, LibHomeScreen::event_list[1].c_str()) == 0) {
-
                auto i = this->handlers.find(Event_OnScreenMessage);
-
-               struct json_object *json_display_message = json_object_object_get(json_data, "display_message");
-               const char* display_message = json_object_get_string(json_display_message);
-
                if ( i != this->handlers.end() ) {
-                       i->second(display_message);
+                       i->second(json_data);
                }
-
        }
 
        json_object_put(ev_contents);