aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-06-08 12:49:57 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-06-08 12:49:57 +0900
commit5d5a780a405fdb71a85898d8d988f6ee1bf3b3e0 (patch)
tree7a561abb05d31ce7cfc119c3514a64ad17ca44db
parent1e55798ce66d927f649284441202bc6ae1df328b (diff)
parent6a01f1dd20e9438c15ebcd434273a79f404429ab (diff)
Merge branch 'sandbox/knimitz/format_code' into sandbox/knimitz/lock
Change-Id: Ifbd46e0156ab5baf93fbb785f4fdfda963ed2af4 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--src/app.cpp156
-rw-r--r--src/app.hpp2
-rw-r--r--src/applist.cpp127
-rw-r--r--src/applist.hpp19
-rw-r--r--src/request.cpp4
-rw-r--r--src/request.hpp2
-rw-r--r--src/wm-client.cpp67
-rw-r--r--src/wm-client.hpp12
-rw-r--r--src/wm-error.cpp2
-rw-r--r--src/wm-error.h1
10 files changed, 204 insertions, 188 deletions
diff --git a/src/app.cpp b/src/app.cpp
index cedf70c..5bd597c 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -46,7 +46,7 @@ extern "C"
namespace wm
{
-const unsigned TIME_OUT = 10000000UL; /* 10s */
+const unsigned kTimeOut = 10000000UL; /* 10s */
/* DrawingArea name used by "{layout}.{area}" */
const char kNameLayoutNormal[] = "normal";
@@ -68,11 +68,9 @@ const char kKeyHeightPixel[] = "height_pixel";
const char kKeyWidthMm[] = "width_mm";
const char kKeyHeightMm[] = "height_mm";
-static const std::string task_allocate = "allocate";
-static const std::string task_release = "release";
-static sd_event_source *timer_ev_src = nullptr;
+static sd_event_source *g_timer_ev_src = nullptr;
-static AppList app_list;
+static AppList g_app_list;
namespace
{
@@ -122,13 +120,13 @@ processTimerHandler(sd_event_source *s, uint64_t usec, void *userdata)
void App::timerHandler()
{
- unsigned seq = app_list.currentSequenceNumber();
- HMI_SEQ_DEBUG(seq, "Timer expired, remove Request");
- app_list.req_dump();
- app_list.removeRequest(seq);
- app_list.next();
- app_list.req_dump();
- if (app_list.haveRequest())
+ unsigned req_num = g_app_list.currentRequestNumber();
+ HMI_SEQ_DEBUG(req_num, "Timer expired remove Request");
+ g_app_list.reqDump();
+ g_app_list.removeRequest(req_num);
+ g_app_list.next();
+ g_app_list.reqDump();
+ if (g_app_list.haveRequest())
{
this->process_request();
}
@@ -137,16 +135,16 @@ void App::timerHandler()
void App::removeClient(const std::string &appid)
{
HMI_DEBUG("wm", "Remove clinet %s from list", appid.c_str());
- app_list.removeClient(appid);
+ g_app_list.removeClient(appid);
}
bool App::subscribeEventForApp(const std::string &appid, afb_req req, const std::string &evname)
{
- if(app_list.contains(appid) != WMError::SUCCESS){
+ if(!g_app_list.contains(appid)){
HMI_DEBUG("wm", "Client %s is not registered", appid.c_str());
return false;
}
- auto client = app_list.lookUpClient(appid);
+ auto client = g_app_list.lookUpClient(appid);
return client->subscribe(req, evname);
}
@@ -425,12 +423,12 @@ void App::layout_commit()
void App::set_timer()
{
- HMI_SEQ_DEBUG(app_list.currentSequenceNumber(), "Timer set activate");
- if (timer_ev_src == nullptr)
+ HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), "Timer set activate");
+ if (g_timer_ev_src == nullptr)
{
// firsttime set into sd_event
- int ret = sd_event_add_time(afb_daemon_get_event_loop(), &timer_ev_src,
- CLOCK_REALTIME, time(NULL) * (1000000UL) + TIME_OUT, 1, processTimerHandler, this);
+ int ret = sd_event_add_time(afb_daemon_get_event_loop(), &g_timer_ev_src,
+ CLOCK_REALTIME, time(NULL) * (1000000UL) + kTimeOut, 1, processTimerHandler, this);
if (ret < 0)
{
HMI_ERROR("wm", "Could't set timer");
@@ -439,19 +437,19 @@ void App::set_timer()
else
{
// update timer limitation after second time
- sd_event_source_set_time(timer_ev_src, time(NULL) * (1000000UL) + TIME_OUT);
- sd_event_source_set_enabled(timer_ev_src, SD_EVENT_ONESHOT);
+ sd_event_source_set_time(g_timer_ev_src, time(NULL) * (1000000UL) + kTimeOut);
+ sd_event_source_set_enabled(g_timer_ev_src, SD_EVENT_ONESHOT);
}
}
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);
+ unsigned req_num = g_app_list.currentRequestNumber();
+ HMI_SEQ_DEBUG(req_num, "Timer stop");
+ int rc = sd_event_source_set_enabled(g_timer_ev_src, SD_EVENT_OFF);
if (rc < 0)
{
- HMI_SEQ_ERROR(seq, "Timer stop failed");
+ HMI_SEQ_ERROR(req_num, "Timer stop failed");
}
}
@@ -459,7 +457,7 @@ WMError App::lm_release(const struct WMAction &action)
{
//auto const &surface_id = this->lookup_id(drawing_name);
WMError ret = WMError::LAYOUT_CHANGE_FAIL;
- unsigned req_num = app_list.currentSequenceNumber();
+ unsigned req_num = g_app_list.currentRequestNumber();
auto const &surface_id = this->lookup_id(action.role.c_str());
if (!surface_id)
{
@@ -561,8 +559,7 @@ WMError App::lm_layout_change(const struct WMAction &action)
TODO: emit syncDraw with application*/
if (msg)
{
- HMI_SEQ_DEBUG(app_list.currentSequenceNumber(), msg);
- //app_list.removeRequest(req_num);
+ HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), msg);
return WMError::LAYOUT_CHANGE_FAIL;
}
this->lm_layout_change(action.role.c_str());
@@ -575,7 +572,7 @@ WMError App::do_transition(unsigned req_num)
* Check Policy
*/
// get current trigger
- auto trigger = app_list.getRequest(req_num);
+ auto trigger = g_app_list.getRequest(req_num);
bool is_activate = true;
/* get new status from Policy Manager
@@ -583,23 +580,23 @@ WMError App::do_transition(unsigned req_num)
(json_object*?) newLayout = checkPolicy(trigger);
(vector<struct WMAction>&) auto actions = translator.inputActionFromLayout(newLayout, currentLayout)
for(const auto& x : actions){
- app_list.setAciton(req_num, x)
+ g_app_list.setAciton(req_num, x)
}
or
- translator.inputActionFromLayout(newLayout, currentLayout, &app_list, req_num);
+ translator.inputActionFromLayout(newLayout, currentLayout, &g_app_list, req_num);
/* The following error check is not necessary because main.cpp will reject the message form not registered object
} */
HMI_SEQ_NOTICE(req_num, "ATM, Policy manager does't exist, then set WMAction as is");
- if (TASK_RELEASE == trigger.task)
+ if (trigger.task == Task::TASK_RELEASE)
{
is_activate = false;
}
- WMError ret = app_list.setAction(req_num, trigger.appid, trigger.role, trigger.area, is_activate);
- app_list.req_dump();
+ WMError ret = g_app_list.setAction(req_num, trigger.appid, trigger.role, trigger.area, is_activate);
+ g_app_list.reqDump();
if (ret != WMError::SUCCESS)
{
@@ -609,7 +606,7 @@ WMError App::do_transition(unsigned req_num)
// layer manager task
bool sync_draw_happen = false;
- for (const auto &y : app_list.getActions(req_num))
+ for (const auto &y : g_app_list.getActions(req_num))
{
/*
do_task(y);
@@ -626,11 +623,11 @@ WMError App::do_transition(unsigned req_num)
{
HMI_SEQ_ERROR(req_num, "%s: appid: %s, role: %s, area: %s",
errorDescription(ret), y.appid.c_str(), y.role.c_str(), y.area.c_str());
- app_list.removeRequest(req_num);
+ g_app_list.removeRequest(req_num);
break;
// TODO: if transition fails, what should we do?
}
- /* app_list.lookUpClient(y.appid)->emit_syncdraw(y.role, y.area); */
+ /* g_app_list.lookUpClient(y.appid)->emit_syncdraw(y.role, y.area); */
}
else
{
@@ -638,17 +635,17 @@ WMError App::do_transition(unsigned req_num)
if (!ret)
{
HMI_SEQ_ERROR(req_num, "Failed release resource: %s", y.appid.c_str());
- app_list.removeRequest(req_num);
+ g_app_list.removeRequest(req_num);
break;
// TODO: if transition fails, what should we do?
}
- /* app_list.lookUpClient(y.appid)->emit_invisible(y.role, y.area); */
+ /* g_app_list.lookUpClient(y.appid)->emit_invisible(y.role, y.area); */
}
}
if (ret != WMError::SUCCESS)
{
- //this->emit_error(request_seq, 0 /*error_num*/, "error happens"); // test
+ //this->emit_error(req_num, 0 /*error_num*/, "error happens"); // test
}
else if (sync_draw_happen)
{
@@ -656,7 +653,7 @@ WMError App::do_transition(unsigned req_num)
}
else
{
- app_list.removeRequest(req_num); // HACK!!!
+ g_app_list.removeRequest(req_num); // HACK!!!
}
return ret;
}
@@ -762,10 +759,21 @@ void App::lm_layout_change(const char *drawing_name)
std::string str_area_sub = std::string(kNameLayoutSplit) + "." + std::string(kNameAreaSub);
compositor::rect area_rect_main = this->area_info[state.main];
compositor::rect area_rect_sub = this->area_info[*surface_id];
+ // >>> HACK
+ HMI_WARNING("wm", "HACK!!! mediaplayer and hvac is only supported for split");
+ std::string request_role = drawing_name;
+ //std::string request_app = transform(request_role.begin(), request_role.end(), request_role.begin(), tolower); //hvac or mediaplayer
+ std::string hack_appid = "navigation";
+ std::string hack_role = main;
+ std::string hack_area = str_area_main;
+ g_app_list.setAction(g_app_list.currentRequestNumber(), hack_appid, hack_role, hack_area, true);
+ //g_app_list.setEndDrawFinished(g_app_list.currentRequestNumber(), request_role, request_role);
+ //g_app_list.setEndDrawFinished(g_app_list.currentRequestNumber(), hack_appid, hack_role); // This process is illegal
+ // >>> HACK
this->emit_syncdraw(main.c_str(), str_area_main.c_str(),
area_rect_main.x, area_rect_main.y,
area_rect_main.w, area_rect_main.h);
- this->emit_syncdraw(drawing_name, str_area_sub.c_str(),
+ this->emit_syncdraw(request_role.c_str(), str_area_sub.c_str(),
area_rect_sub.x, area_rect_sub.y,
area_rect_sub.w, area_rect_sub.h);
this->enqueue_flushdraw(state.main);
@@ -854,19 +862,19 @@ 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) != WMError::SUCCESS)
+ if (!g_app_list.contains(id))
{
reply("app doesn't request 'requestSurface' yet");
return;
}
- auto client = app_list.lookUpClient(id);
+ auto client = g_app_list.lookUpClient(id);
/*
* Queueing Phase
*/
- unsigned current = app_list.currentSequenceNumber();
- unsigned requested_num = app_list.getSequenceNumber(id);
+ unsigned current = g_app_list.currentRequestNumber();
+ unsigned requested_num = g_app_list.getRequestNumber(id);
if (requested_num != 0)
{
HMI_SEQ_INFO(requested_num, "%s %s %s request is already queued", id.c_str(), role.c_str(), area.c_str());
@@ -875,8 +883,8 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char
}
WMRequest req = WMRequest(id, role, area, Task::TASK_ALLOCATE);
- unsigned new_req = app_list.addAllocateRequest(req);
- app_list.req_dump();
+ unsigned new_req = g_app_list.addAllocateRequest(req);
+ g_app_list.reqDump();
HMI_SEQ_DEBUG(current, "%s start sequence with %s, %s", id.c_str(), role.c_str(), area.c_str());
@@ -911,18 +919,18 @@ void App::api_deactivate_surface(char const *appid, char const *drawing_name, co
std::string role = drawing_name;
std::string area = ""; //drawing_area;
- if (app_list.contains(id) != WMError::SUCCESS)
+ if (!g_app_list.contains(id))
{
reply("app doesn't request 'requestSurface' yet");
return;
}
- auto client = app_list.lookUpClient(id);
+ auto client = g_app_list.lookUpClient(id);
/*
* Queueing Phase
*/
- unsigned current = app_list.currentSequenceNumber();
- unsigned requested_num = app_list.getSequenceNumber(id);
+ unsigned current = g_app_list.currentRequestNumber();
+ unsigned requested_num = g_app_list.getRequestNumber(id);
if (requested_num != 0)
{
HMI_SEQ_INFO(requested_num, "%s %s %s request is already queued", id.c_str(), role.c_str(), area.c_str());
@@ -931,8 +939,8 @@ void App::api_deactivate_surface(char const *appid, char const *drawing_name, co
}
WMRequest req = WMRequest(id, role, area, Task::TASK_RELEASE);
- unsigned new_req = app_list.addAllocateRequest(req);
- app_list.req_dump();
+ unsigned new_req = g_app_list.addAllocateRequest(req);
+ g_app_list.reqDump();
HMI_SEQ_DEBUG(current, "%s start sequence with %s, %s", id.c_str(), role.c_str(), area.c_str());
@@ -995,30 +1003,30 @@ void App::lm_enddraw(const char *drawing_name)
}
}
-void App::do_enddraw(unsigned request_seq)
+void App::do_enddraw(unsigned req_num)
{
// get actions
- auto actions = app_list.getActions(request_seq);
- HMI_SEQ_INFO(request_seq, "do endDraw");
+ auto actions = g_app_list.getActions(req_num);
+ HMI_SEQ_INFO(req_num, "do endDraw");
for (const auto &act : actions)
{
- HMI_SEQ_DEBUG(request_seq, "visible %s", act.role.c_str());
+ HMI_SEQ_DEBUG(req_num, "visible %s", act.role.c_str());
this->lm_enddraw(act.role.c_str());
}
- HMI_SEQ_INFO(request_seq, "emit flushDraw");
+ HMI_SEQ_INFO(req_num, "emit flushDraw");
/* do
{
// emit flush Draw
- //emitFlushDrawToAll(&app_list, request_seq);
+ //emitFlushDrawToAll(&g_app_list, req_num);
// emit status change event
- } while (!app_list.requestFinished());*/
+ } while (!g_app_list.requestFinished());*/
}
void App::process_request()
{
- unsigned req = app_list.currentSequenceNumber();
+ unsigned req = g_app_list.currentRequestNumber();
HMI_SEQ_DEBUG(req, "Do next request");
WMError rc = do_transition(req);
if(rc != WMError::SUCCESS){
@@ -1030,8 +1038,8 @@ void App::api_enddraw(char const *appid, char const *drawing_name)
{
std::string id(appid);
std::string role(drawing_name);
- unsigned current_seq = app_list.currentSequenceNumber();
- bool result = app_list.setEndDrawFinished(current_seq, id, role);
+ unsigned current_req = g_app_list.currentRequestNumber();
+ bool result = g_app_list.setEndDrawFinished(current_req, id, role);
if (!result)
{
@@ -1039,25 +1047,25 @@ void App::api_enddraw(char const *appid, char const *drawing_name)
return;
}
- if (app_list.endDrawFullfilled(current_seq))
+ if (g_app_list.endDrawFullfilled(current_req))
{
// do task for endDraw
//this->stop_timer();
- this->do_enddraw(current_seq);
+ this->do_enddraw(current_req);
this->stop_timer();
- app_list.removeRequest(current_seq);
- HMI_SEQ_INFO(current_seq, "Finish request");
- app_list.next();
- if (app_list.haveRequest())
+ g_app_list.removeRequest(current_req);
+ HMI_SEQ_INFO(current_req, "Finish request");
+ g_app_list.next();
+ if (g_app_list.haveRequest())
{
this->process_request();
}
}
else
{
- HMI_SEQ_INFO(current_seq, "Wait other App call endDraw");
+ HMI_SEQ_INFO(current_req, "Wait other App call endDraw");
return;
}
}
@@ -1138,7 +1146,7 @@ void App::surface_removed(uint32_t surface_id)
{
HMI_DEBUG("wm", "surface_id is %u", surface_id);
- app_list.removeSurface(surface_id);
+ g_app_list.removeSurface(surface_id);
}
void App::emit_activated(char const *label)
@@ -1207,8 +1215,8 @@ result<int> App::api_request_surface(char const *appid, char const *drawing_name
// add client into the db
std::string appid_str(appid);
std::string role(drawing_name);
- //app_list.addClient(appid_str, role);
- app_list.addClient(appid_str, *lid, id, role);
+ //g_app_list.addClient(appid_str, role);
+ g_app_list.addClient(appid_str, *lid, id, role);
return Ok<int>(id);
}
diff --git a/src/app.hpp b/src/app.hpp
index d13fd4d..7ead82e 100644
--- a/src/app.hpp
+++ b/src/app.hpp
@@ -264,7 +264,7 @@ struct App
WMError do_transition(unsigned sequence_number);
- void do_enddraw(unsigned sequence_number);
+ void do_enddraw(unsigned req_num);
void process_request();
void set_timer();
void stop_timer();
diff --git a/src/applist.cpp b/src/applist.cpp
index 6b608d0..9b06c84 100644
--- a/src/applist.cpp
+++ b/src/applist.cpp
@@ -20,7 +20,6 @@
using std::shared_ptr;
using std::string;
-using std::unique_ptr;
using std::vector;
namespace wm
@@ -28,8 +27,8 @@ namespace wm
AppList::AppList()
: req_list(0),
- client_list(0),
- current_seq(1)
+ app2client(0),
+ current_req(1)
{
}
@@ -38,32 +37,32 @@ AppList::~AppList() {}
void AppList::addClient(const string &appid, const string &role)
{
shared_ptr<WMClient> client = std::make_shared<WMClient>(appid, role);
- client_list[appid] = client;
- client_dump();
+ this->app2client[appid] = client;
+ this->clientDump();
}
void AppList::addClient(const std::string &appid, unsigned layer, unsigned surface, const std::string &role)
{
shared_ptr<WMClient> client = std::make_shared<WMClient>(appid, layer, surface, role);
- client_list[appid] = client;
- client_dump();
+ this->app2client[appid] = client;
+ this->clientDump();
}
void AppList::removeClient(const string &appid)
{
- client_list.erase(appid);
+ this->app2client.erase(appid);
}
-WMError AppList::contains(const string &appid)
+bool AppList::contains(const string &appid) const
{
- auto result = client_list.find(appid);
- return (client_list.end() != result) ? WMError::SUCCESS : WMError::NOT_REGISTERED;
+ auto result = this->app2client.find(appid);
+ return (this->app2client.end() != result) ? true : false;
}
void AppList::removeSurface(unsigned surface_id){
// This function may be very slow
bool ret = false;
- for (auto &x : client_list)
+ for (auto &x : this->app2client)
{
ret = x.second->removeSurfaceIfExist(surface_id);
if(ret){
@@ -81,28 +80,28 @@ void AppList::removeSurface(unsigned surface_id){
*/
shared_ptr<WMClient> AppList::lookUpClient(const string &appid)
{
- return client_list.at(appid);
+ return this->app2client.at(appid);
}
-int AppList::countClient()
+int AppList::countClient() const
{
- return client_list.size();
+ return this->app2client.size();
}
-unsigned AppList::currentSequenceNumber()
+unsigned AppList::currentRequestNumber() const
{
- return current_seq;
+ return this->current_req;
}
// Is this function necessary ?
-unsigned AppList::getSequenceNumber(const string &appid)
+unsigned AppList::getRequestNumber(const string &appid) const
{
- for (const auto &x : req_list)
+ for (const auto &x : this->req_list)
{
// Since app will not request twice and more, comparing appid is enough?
if ((x.trigger.appid == appid))
{
- return x.seq_num;
+ return x.req_num;
}
}
return 0;
@@ -110,29 +109,24 @@ unsigned AppList::getSequenceNumber(const string &appid)
unsigned AppList::addAllocateRequest(WMRequest req)
{
- if (req_list.size() == 0)
+ if (this->req_list.size() == 0)
{
- req.seq_num = current_seq;
+ req.req_num = current_req;
}
else
{
- HMI_SEQ_DEBUG(current_seq, "real: %d", req_list.back().seq_num + 1);
- req.seq_num = req_list.back().seq_num + 1;
+ HMI_SEQ_DEBUG(this->current_req, "add: %d", this->req_list.back().req_num + 1);
+ req.req_num = this->req_list.back().req_num + 1;
}
- req_list.push_back(req);
- return req.seq_num; // return 1; if you test time_expire
-}
-
-bool AppList::requestFinished()
-{
- return req_list.empty();
+ this->req_list.push_back(req);
+ return req.req_num; // return 1; if you test time_expire
}
struct WMTrigger AppList::getRequest(unsigned req_num)
{
- for (auto &x : req_list)
+ for (const auto &x : this->req_list)
{
- if (req_num == x.seq_num)
+ if (req_num == x.req_num)
{
return x.trigger;
}
@@ -141,9 +135,9 @@ struct WMTrigger AppList::getRequest(unsigned req_num)
const vector<struct WMAction> &AppList::getActions(unsigned req_num)
{
- for (auto &x : req_list)
+ for (auto &x : this->req_list)
{
- if (req_num == x.seq_num)
+ if (req_num == x.req_num)
{
return x.sync_draw_req;
}
@@ -153,9 +147,9 @@ const vector<struct WMAction> &AppList::getActions(unsigned req_num)
WMError AppList::setAction(unsigned req_num, const struct WMAction &action)
{
WMError result = WMError::FAIL;
- for (auto &x : req_list)
+ for (auto &x : this->req_list)
{
- if (req_num != x.seq_num)
+ if (req_num != x.req_num)
{
continue;
}
@@ -167,16 +161,24 @@ WMError AppList::setAction(unsigned req_num, const struct WMAction &action)
return result;
}
+/**
+ * Note:
+ * This function set action with parameters.
+ * if visible is true, it means app should be visible, so enddraw_finished parameter should be false.
+ * otherwise (visible is false) app should be invisible. Then enddraw_finished param is set to true.
+ * This function doesn't support actions for focus yet.
+ */
WMError AppList::setAction(unsigned req_num, const string &appid, const string &role, const string &area, bool visible)
{
WMError result = WMError::NOT_REGISTERED;
for (auto &x : req_list)
{
- if (req_num != x.seq_num)
+ if (req_num != x.req_num)
{
continue;
}
- WMAction action{appid, role, area, visible, false};
+ bool edraw_f = (visible) ? false : true;
+ WMAction action{appid, role, area, visible, edraw_f};
x.sync_draw_req.push_back(action);
result = WMError::SUCCESS;
@@ -185,16 +187,21 @@ WMError AppList::setAction(unsigned req_num, const string &appid, const string &
return result;
}
+/**
+ * This function checks
+ * * req_num is equal to current request number
+ * * appid and role are equeal to the appid and role stored in action list(sync_draw_req)
+ */
bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const string &role)
{
bool result = false;
for (auto &x : req_list)
{
- if (req_num < x.seq_num)
+ if (req_num < x.req_num)
{
break;
}
- if (req_num == x.seq_num)
+ if (req_num == x.req_num)
{
for (auto &y : x.sync_draw_req)
{
@@ -206,13 +213,13 @@ bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const st
}
}
}
- req_dump();
+ this->reqDump();
return result;
}
/**
* @brief check all actions of the requested sequence is finished
- * @param unsigned sequence_num
+ * @param unsigned request_number
* @return true if all action is set.
*/
bool AppList::endDrawFullfilled(unsigned req_num)
@@ -220,11 +227,11 @@ bool AppList::endDrawFullfilled(unsigned req_num)
bool result = false;
for (const auto &x : req_list)
{
- if (req_num < x.seq_num)
+ if (req_num < x.req_num)
{
break;
}
- if (req_num == x.seq_num)
+ if (req_num == x.req_num)
{
result = true;
for (const auto &y : x.sync_draw_req)
@@ -240,32 +247,32 @@ bool AppList::endDrawFullfilled(unsigned req_num)
return result;
}
-void AppList::removeRequest(unsigned req_seq)
+void AppList::removeRequest(unsigned req_num)
{
- req_list.erase(remove_if(req_list.begin(), req_list.end(),
- [req_seq](WMRequest x) {
- return x.seq_num == req_seq;
- }));
+ this->req_list.erase(remove_if(this->req_list.begin(), this->req_list.end(),
+ [req_num](WMRequest x) {
+ return x.req_num == req_num;
+ }));
}
void AppList::next()
{
- ++this->current_seq;
- if (0 == this->current_seq)
+ ++this->current_req;
+ if (0 == this->current_req)
{
- this->current_seq = 1;
+ this->current_req = 1;
}
}
-bool AppList::haveRequest()
+bool AppList::haveRequest() const
{
- return !req_list.empty();
+ return !this->req_list.empty();
}
-void AppList::client_dump()
+void AppList::clientDump()
{
DUMP("======= client dump =====");
- for (const auto &x : client_list)
+ for (const auto &x : this->app2client)
{
const auto &y = x.second;
y->dumpInfo();
@@ -273,13 +280,13 @@ void AppList::client_dump()
DUMP("======= client dump end=====");
}
-void AppList::req_dump()
+void AppList::reqDump()
{
DUMP("======= req dump =====");
- DUMP("current request : %d", current_seq);
+ DUMP("current request : %d", current_req);
for (const auto &x : req_list)
{
- DUMP("requested with : %d", x.seq_num);
+ DUMP("requested with : %d", x.req_num);
DUMP("Trigger : (APPID :%s, ROLE :%s, AREA :%s, TASK: %d)",
x.trigger.appid.c_str(),
x.trigger.role.c_str(),
diff --git a/src/applist.hpp b/src/applist.hpp
index 97f772b..0f2285b 100644
--- a/src/applist.hpp
+++ b/src/applist.hpp
@@ -41,37 +41,36 @@ class AppList
void addClient(const std::string &appid, const std::string &role);
void addClient(const std::string &appid, unsigned layer, unsigned surface, const std::string &role);
void removeClient(const std::string &appid);
- WMError contains(const std::string &appid);
- int countClient();
+ bool contains(const std::string &appid) const;
+ int countClient() const;
std::shared_ptr<WMClient> lookUpClient(const std::string &appid);
void removeSurface(unsigned surface);
// Request Interface
- unsigned currentSequenceNumber();
- unsigned getSequenceNumber(const std::string &appid);
+ unsigned currentRequestNumber() const;
+ unsigned getRequestNumber(const std::string &appid) const;
unsigned addAllocateRequest(WMRequest req);
/* TODO: consider, which is better WMClient or std::string appid?
if appid is key to manage resources, it is better to select std::string
otherwise WMClient is better, IMO */
- bool requestFinished();
WMError setAction(unsigned req_num, const struct WMAction &action);
WMError setAction(unsigned req_num, const std::string &appid, const std::string &role, const std::string &area, bool visible = true);
bool setEndDrawFinished(unsigned req_num, const std::string &appid, const std::string &role);
bool endDrawFullfilled(unsigned req_num);
void removeRequest(unsigned req_num);
void next();
- bool haveRequest();
+ bool haveRequest() const;
struct WMTrigger getRequest(unsigned req_num);
const std::vector<struct WMAction> &getActions(unsigned req_num);
- void client_dump();
- void req_dump();
+ void clientDump();
+ void reqDump();
private:
std::vector<WMRequest> req_list;
- std::unordered_map<std::string, std::shared_ptr<WMClient>> client_list;
- unsigned current_seq;
+ std::unordered_map<std::string, std::shared_ptr<WMClient>> app2client;
+ unsigned current_req;
};
} // namespace wm
diff --git a/src/request.cpp b/src/request.cpp
index 97b9f49..069f8ff 100644
--- a/src/request.cpp
+++ b/src/request.cpp
@@ -24,7 +24,7 @@ using std::string;
WMRequest::WMRequest() {}
WMRequest::WMRequest(string appid, string role, string area, Task task)
- : seq_num(0),
+ : req_num(0),
trigger{appid, role, area, task},
sync_draw_req(0)
{
@@ -36,7 +36,7 @@ WMRequest::~WMRequest()
WMRequest::WMRequest(const WMRequest &obj)
{
- this->seq_num = obj.seq_num;
+ this->req_num = obj.req_num;
this->trigger = obj.trigger;
this->sync_draw_req = obj.sync_draw_req;
}
diff --git a/src/request.hpp b/src/request.hpp
index 9a97abb..ab1ef95 100644
--- a/src/request.hpp
+++ b/src/request.hpp
@@ -54,7 +54,7 @@ struct WMRequest
virtual ~WMRequest();
WMRequest(const WMRequest &obj);
- unsigned seq_num;
+ unsigned req_num;
struct WMTrigger trigger;
std::vector<struct WMAction> sync_draw_req;
};
diff --git a/src/wm-client.cpp b/src/wm-client.cpp
index 380c841..2542016 100644
--- a/src/wm-client.cpp
+++ b/src/wm-client.cpp
@@ -26,31 +26,30 @@ using std::vector;
namespace wm
{
-const vector<string> wm_events = {
+const vector<string> kWMEvents = {
// Private event for applications
"syncDraw", "flushDraw", "visible", "invisible", "active", "inactive", "error"};
-const vector<string> error_description = {
+const vector<string> kErrorDescription = {
"unknown-error"};
-static const char key_drawing_name[] = "drawing_name";
-static const char key_role[] = "role";
-static const char key_err[] = "error";
-static const char key_err_desc[] = "error_description";
+static const char kKeyDrawingName[] = "drawing_name";
+static const char kKeyrole[] = "role";
+static const char kKeyError[] = "error";
+static const char kKeyErrorDesc[] = "kErrorDescription";
WMClient::WMClient(const string &appid, unsigned layerID, unsigned surfaceID, const string &role)
- : layer(layerID),
- id(appid),
+ : id(appid), layer(layerID),
role2surface(0)
{
role2surface[role] = surfaceID;
- for (auto x : wm_events)
+ for (auto x : kWMEvents)
{
#if GTEST_ENABLED
string ev = x;
#else
afb_event ev = afb_daemon_make_event(x.c_str());
#endif
- event_list[x] = ev;
+ event2list[x] = ev;
}
}
@@ -58,17 +57,17 @@ WMClient::WMClient(const string &appid, const string &role)
: id(appid),
layer(0),
role2surface(0),
- event_list(0)
+ event2list(0)
{
role2surface[role] = INVALID_SURFACE_ID;
- for (auto x : wm_events)
+ for (auto x : kWMEvents)
{
#if GTEST_ENABLED
string ev = x;
#else
afb_event ev = afb_daemon_make_event(x.c_str());
#endif
- event_list[x] = ev;
+ event2list[x] = ev;
}
}
@@ -76,24 +75,24 @@ WMClient::~WMClient()
{
}
-string WMClient::appID()
+string WMClient::appID() const
{
return this->id;
}
-unsigned WMClient::surfaceID(const string &role)
+unsigned WMClient::surfaceID(const string &role) const
{
- if (0 == role2surface.count(role))
+ if (0 == this->role2surface.count(role))
{
HMI_WARNING("wm", "invalid role");
return INVALID_SURFACE_ID;
}
- return role2surface.at(role);
+ return this->role2surface.at(role);
}
-unsigned WMClient::layerID()
+unsigned WMClient::layerID() const
{
- return layer;
+ return this->layer;
}
void WMClient::registerLayer(unsigned layerID)
@@ -104,22 +103,22 @@ void WMClient::registerLayer(unsigned layerID)
bool WMClient::addSurface(const string &role, unsigned surface)
{
HMI_DEBUG("wm", "Add role %s with surface %d", role.c_str(), surface);
- if (0 != role2surface.count(role))
+ if (0 != this->role2surface.count(role))
{
- HMI_NOTICE("wm", "override surfaceID %d with %d", role2surface[role], surface);
+ HMI_NOTICE("wm", "override surfaceID %d with %d", this->role2surface[role], surface);
}
- role2surface[role] = surface;
+ this->role2surface[role] = surface;
return true;
}
bool WMClient::removeSurfaceIfExist(unsigned surfaceID)
{
bool ret = false;
- for (auto &x : role2surface)
+ for (auto &x : this->role2surface)
{
if (surfaceID == x.second)
{
- role2surface.erase(x.first);
+ this->role2surface.erase(x.first);
ret = true;
break;
}
@@ -130,9 +129,9 @@ bool WMClient::removeSurfaceIfExist(unsigned surfaceID)
bool WMClient::removeRole(const string &role)
{
bool ret = false;
- if (role2surface.count(role) != 0)
+ if (this->role2surface.count(role) != 0)
{
- role2surface.erase(role);
+ this->role2surface.erase(role);
ret = true;
}
return ret;
@@ -140,11 +139,11 @@ bool WMClient::removeRole(const string &role)
bool WMClient::subscribe(afb_req req, const string &evname)
{
- if(evname != key_err){
+ if(evname != kKeyError){
HMI_DEBUG("wm", "error is only enabeled for now");
return false;
}
- int ret = afb_req_subscribe(req, event_list[evname]);
+ int ret = afb_req_subscribe(req, this->event2list[evname]);
if (ret)
{
HMI_DEBUG("wm", "Failed to subscribe %s", evname.c_str());
@@ -155,16 +154,16 @@ bool WMClient::subscribe(afb_req req, const string &evname)
void WMClient::emitError(WM_CLIENT_ERROR_EVENT ev)
{
- if (!afb_event_is_valid(this->event_list[key_err])){
+ if (!afb_event_is_valid(this->event2list[kKeyError])){
HMI_ERROR("wm", "event err is not valid");
return;
}
json_object *j = json_object_new_object();
- json_object_object_add(j, key_err, json_object_new_int(ev));
- json_object_object_add(j, key_err_desc, json_object_new_string(error_description[ev].c_str()));
- HMI_DEBUG("wm", "error: %d, description:%s", ev, error_description[ev].c_str());
+ json_object_object_add(j, kKeyError, json_object_new_int(ev));
+ json_object_object_add(j, kKeyErrorDesc, json_object_new_string(kErrorDescription[ev].c_str()));
+ HMI_DEBUG("wm", "error: %d, description:%s", ev, kErrorDescription[ev].c_str());
- int ret = afb_event_push(this->event_list[key_err], j);
+ int ret = afb_event_push(this->event2list[kKeyError], j);
if (ret != 0)
{
HMI_DEBUG("wm", "afb_event_push failed: %m");
@@ -175,7 +174,7 @@ void WMClient::dumpInfo()
{
DUMP("APPID : %s", id.c_str());
DUMP(" LAYER : %d", layer);
- for (const auto &x : role2surface)
+ for (const auto &x : this->role2surface)
{
DUMP(" ROLE : %s , SURFACE : %d", x.first.c_str(), x.second);
}
diff --git a/src/wm-client.hpp b/src/wm-client.hpp
index 4bfb60b..ad9e7b0 100644
--- a/src/wm-client.hpp
+++ b/src/wm-client.hpp
@@ -43,9 +43,9 @@ class WMClient
WMClient(const std::string &appid, const std::string &role);
virtual ~WMClient();
- std::string appID();
- unsigned surfaceID(const std::string &role);
- unsigned layerID();
+ std::string appID() const;
+ unsigned surfaceID(const std::string &role) const;
+ unsigned layerID() const;
void registerLayer(unsigned layerID);
bool addSurface(const std::string& role, unsigned surface);
bool removeSurfaceIfExist(unsigned surfaceID);
@@ -57,14 +57,14 @@ class WMClient
void dumpInfo();
private:
- unsigned layer;
std::string id;
+ unsigned layer;
std::unordered_map<std::string, unsigned> role2surface;
#if GTEST_ENABLED
// This is for unit test. afb_make_event occurs sig11 if call not in afb-binding
- std::unordered_map<std::string, std::string> event_list;
+ std::unordered_map<std::string, std::string> event2list;
#else
- std::unordered_map<std::string, struct afb_event> event_list;
+ std::unordered_map<std::string, struct afb_event> event2list;
#endif
};
} // namespace wm
diff --git a/src/wm-error.cpp b/src/wm-error.cpp
index ab1ea31..4b01922 100644
--- a/src/wm-error.cpp
+++ b/src/wm-error.cpp
@@ -34,6 +34,8 @@ const char *errorDescription(WMError enum_error_number)
return "Request is dropped, due to time out expiring";
case LAYOUT_CHANGE_FAIL:
return "Layout change fails, due to some reasons";
+ case NO_ENTRY:
+ return "No element";
default:
return "Unknown error number. Window manager bug.";
}
diff --git a/src/wm-error.h b/src/wm-error.h
index ce271b3..155d791 100644
--- a/src/wm-error.h
+++ b/src/wm-error.h
@@ -28,6 +28,7 @@ typedef enum WINDOWMANAGER_ERROR
TIMEOUT_EXPIRED,
NOT_REGISTERED,
LAYOUT_CHANGE_FAIL,
+ NO_ENTRY,
UNKNOWN,
ERR_MAX = UNKNOWN
}