aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-06-01 00:26:03 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-06-01 00:26:03 +0900
commit358f8b12f6d858473b0bfbd6ed9b191cd94f7b02 (patch)
tree6fefe8a555472e5637d6c24f960fa4b847c62f1a
parent59edf2c3a8d4b246f5b06b163a307cfef0a57b25 (diff)
Add subscribe function in app.cpp to control from main.cpp
Change-Id: I69ef05d99dffcdbc7ffccb019821011c5bef9d46 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--src/app.cpp75
-rw-r--r--src/app.hpp1
2 files changed, 53 insertions, 23 deletions
diff --git a/src/app.cpp b/src/app.cpp
index c862680..b6160d2 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -134,11 +134,22 @@ void App::timerHandler()
}
}
-void App::removeClient(const std::string &appid){
+void App::removeClient(const std::string &appid)
+{
HMI_DEBUG("wm", "Remove clinet %s from list", appid.c_str());
app_list.removeClient(appid);
}
+bool App::subscribeEventForApp(const std::string &appid, afb_req req, const std::string &evname)
+{
+ if(!app_list.contains(appid)){
+ HMI_DEBUG("wm", "Client %s is not registered", appid.c_str());
+ return false;
+ }
+ auto client = app_list.lookUpClient(appid);
+ return client->subscribe(req, evname);
+}
+
/**
* App Impl
*/
@@ -412,7 +423,8 @@ void App::layout_commit()
this->display->flush();
}
-void App::set_timer(){
+void App::set_timer()
+{
HMI_SEQ_DEBUG(app_list.currentSequenceNumber(), "Timer set activate");
if (timer_ev_src == nullptr)
{
@@ -432,11 +444,13 @@ void App::set_timer(){
}
}
-void App::stop_timer(){
+void App::stop_timer()
+{
unsigned seq = app_list.currentSequenceNumber();
HMI_SEQ_DEBUG(seq, "Timer stop");
int rc = sd_event_source_set_enabled(timer_ev_src, SD_EVENT_OFF);
- if(rc < 0){
+ if (rc < 0)
+ {
HMI_SEQ_ERROR(seq, "Timer stop failed");
}
}
@@ -586,7 +600,8 @@ bool App::do_transition(unsigned req_num)
bool ret = app_list.setAction(req_num, trigger.appid, trigger.role, trigger.area, is_activate);
app_list.req_dump();
- if(!ret){
+ if (!ret)
+ {
HMI_SEQ_ERROR(req_num, "Failed to set action");
return ret;
}
@@ -598,7 +613,7 @@ bool App::do_transition(unsigned req_num)
/*
do_task(y);
*/
- /* TODO
+ /* TODO
but current we can't do do_task,
so divide the processing into lm_layout_change and lm_release
*/
@@ -606,7 +621,8 @@ bool App::do_transition(unsigned req_num)
{
sync_draw_happen = true;
ret = lm_layout_change(y);
- if(!ret){
+ if (!ret)
+ {
HMI_SEQ_ERROR(req_num, "Failed layout change: %s", y.appid.c_str());
app_list.removeRequest(req_num);
break;
@@ -614,7 +630,8 @@ bool App::do_transition(unsigned req_num)
}
/* app_list.lookUpClient(y.appid)->emit_syncdraw(y.role, y.area); */
}
- else{
+ else
+ {
ret = lm_release(y);
if (!ret)
{
@@ -627,19 +644,22 @@ bool App::do_transition(unsigned req_num)
}
}
- if(!ret){
+ if (!ret)
+ {
//this->emit_error(request_seq, 0 /*error_num*/, "error happens"); // test
}
- else if (ret && sync_draw_happen){
+ else if (ret && sync_draw_happen)
+ {
this->set_timer();
}
- else{
+ else
+ {
app_list.removeRequest(req_num); // HACK!!!
}
return ret;
}
-void App::lm_layout_change(const char* drawing_name)
+void App::lm_layout_change(const char *drawing_name)
{
auto const &surface_id = this->lookup_id(drawing_name);
auto layer_id = this->layers.get_layer_id(*surface_id);
@@ -784,7 +804,7 @@ void App::lm_layout_change(const char* drawing_name)
}
}
-const char* App::check_surface_exist(const char* drawing_name)
+const char *App::check_surface_exist(const char *drawing_name)
{
auto const &surface_id = this->lookup_id(drawing_name);
if (!surface_id)
@@ -832,13 +852,18 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char
std::string role = drawing_name;
std::string area = drawing_area;
- if(!app_list.contains(id)){
+ if (!app_list.contains(id))
+ {
reply("app doesn't request 'requestSurface' yet");
return;
}
auto client = app_list.lookUpClient(id);
+ // test
+ HMI_DEBUG("wm", "test");
+ client->emitError(WM_CLIENT_ERROR_EVENT::UNKNOWN_ERROR);
+
/*
* Queueing Phase
*/
@@ -870,7 +895,8 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char
*/
bool ret = this->do_transition(new_req);
- if(!ret){
+ if (!ret)
+ {
HMI_SEQ_ERROR(new_req, "failed to do_transition");
//this->emit_error()
}
@@ -885,9 +911,10 @@ void App::api_deactivate_surface(char const *appid, char const *drawing_name, co
*/
std::string id = appid;
std::string role = drawing_name;
- std::string area = ""; //drawing_area;
+ std::string area = ""; //drawing_area;
- if(!app_list.contains(id)){
+ if (!app_list.contains(id))
+ {
reply("app doesn't request 'requestSurface' yet");
return;
}
@@ -954,7 +981,8 @@ void App::check_flushdraw(int surface_id)
}
}
-void App::lm_enddraw(const char* drawing_name){
+void App::lm_enddraw(const char *drawing_name)
+{
HMI_DEBUG("wm", "end draw %s", drawing_name);
for (unsigned i = 0, iend = this->pending_end_draw.size(); i < iend; i++)
{
@@ -975,13 +1003,14 @@ void App::do_enddraw(unsigned request_seq)
auto actions = app_list.getActions(request_seq);
HMI_SEQ_INFO(request_seq, "do endDraw");
- for(const auto& act : actions){
+ for (const auto &act : actions)
+ {
HMI_SEQ_DEBUG(request_seq, "visible %s", act.role.c_str());
this->lm_enddraw(act.role.c_str());
}
HMI_SEQ_INFO(request_seq, "emit flushDraw");
-/* do
+ /* do
{
// emit flush Draw
//emitFlushDrawToAll(&app_list, request_seq);
@@ -1097,11 +1126,11 @@ void App::surface_created(uint32_t surface_id)
this->lookup_name(surface_id).value_or("unknown-name").c_str());
}*/
- // search pid from surfaceID
+ // search pid from surfaceID
- // pick up appid from pid from application manager
+ // pick up appid from pid from application manager
- // check appid then add it to the client
+ // check appid then add it to the client
}
void App::surface_removed(uint32_t surface_id)
diff --git a/src/app.hpp b/src/app.hpp
index 7782e04..4d079c1 100644
--- a/src/app.hpp
+++ b/src/app.hpp
@@ -233,6 +233,7 @@ struct App
//static int processTimerHandler(sd_event_source *s, uint64_t usec, void *userdata);
void timerHandler();
void removeClient(const std::string &appid);
+ bool subscribeEventForApp(const std::string &appid, afb_req req, const std::string &evname);
private:
optional<int> lookup_id(char const *name);