LibHomeScreen();
~LibHomeScreen();
- LibHomeScreen(const LibHomeScreen &) = delete;
- LibHomeScreen &operator=(const LibHomeScreen &) = delete;
+ LibHomeScreen(const LibHomeScreen &) = delete;
+ LibHomeScreen &operator=(const LibHomeScreen &) = delete;
- using handler_func = std::function<void(const char*)>;
+ using handler_func = std::function<void(const char*)>;
- enum EventType {
- Event_TapShortcut = 1,
- Event_OnScreenMessage
- };
+ enum EventType {
+ Event_TapShortcut = 1,
+ Event_OnScreenMessage
+ };
- static const std::vector<std::string> api_list;
- static const std::vector<std::string> event_list;
+ static const std::vector<std::string> api_list;
+ static const std::vector<std::string> event_list;
/* Method */
- int init(const int port, const std::string& token);
+ int init(const int port, const std::string& token);
- int tapShortcut(const char* application_name);
- int onScreenMessage(const char* display_message);
+ int tapShortcut(const char* application_name);
+ int onScreenMessage(const char* display_message);
- void set_event_handler(enum EventType et, handler_func f);
+ void set_event_handler(enum EventType et, handler_func f);
void registerCallback(
void (*event_cb)(const std::string& event, struct json_object* event_contents),
private:
int initialize_websocket();
- int runEventloop();
-
+
void (*onEvent)(const std::string& event, struct json_object* event_contents);
void (*onReply)(struct json_object* reply);
void (*onHangup)(void);
int mport = 2000;
std::string mtoken = "hs";
- std::map<EventType, handler_func> handlers;
+ std::map<EventType, handler_func> handlers;
public:
/* Don't use/ Internal only */
}
});
- // Run event loop for HomeScreen
- hs->runEventloop();
-
-
/*
* Set SoundManager
*/
smw->subscribe(QString("removedMainConnection"));
smw->subscribe(QString("asyncSetSourceState"));
smw->subscribe(QString("asyncConnect"));
- smw->run_eventloop();
// Set context property for SoundManager
context->setContextProperty("smw", smw);
#include <sys/socket.h>
#include <iostream>
#include <algorithm>
-#include <thread>
#include <errno.h>
#include <cassert>
#include <cctype>
*/
LibHomeScreen::LibHomeScreen()
{
-
}
/**
HMI_DEBUG("libhomescreen","Initialized");
}
- this->runEventloop();
-
return ret;
}
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
*