Merge branch 'sandbox/knimitz/format_code' into sandbox/knimitz/lock
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Fri, 8 Jun 2018 03:49:57 +0000 (12:49 +0900)
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Fri, 8 Jun 2018 03:49:57 +0000 (12:49 +0900)
Change-Id: Ifbd46e0156ab5baf93fbb785f4fdfda963ed2af4
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
1  2 
src/app.cpp
src/app.hpp
src/applist.cpp
src/applist.hpp
src/wm-error.cpp
src/wm-error.h

diff --combined src/app.cpp
@@@ -46,7 -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 +68,9 @@@ const char kKeyHeightPixel[] = "height_
  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 +120,13 @@@ processTimerHandler(sd_event_source *s
  
  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();
      }
  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 +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");
      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");
      }
  }
  
 -bool App::lm_release(const struct WMAction &action)
 +WMError App::lm_release(const struct WMAction &action)
  {
      //auto const &surface_id = this->lookup_id(drawing_name);
-     unsigned req_num = app_list.currentSequenceNumber();
 +    WMError ret = WMError::LAYOUT_CHANGE_FAIL;
+     unsigned req_num = g_app_list.currentRequestNumber();
      auto const &surface_id = this->lookup_id(action.role.c_str());
      if (!surface_id)
      {
          HMI_SEQ_ERROR(req_num, "Surface does not exist");
 -        return false;
 +        return ret;
      }
  
      if (*surface_id == this->layers.main_surface)
      {
          HMI_SEQ_ERROR(req_num, "Cannot deactivate main_surface");
 -        return false;
 +        return ret;
      }
  
      auto o_state = *this->layers.get_layout_state(*surface_id);
      if (o_state == nullptr)
      {
          HMI_SEQ_ERROR(req_num, "Could not find layer for surface");
 -        return false;
 +        return ret;
      }
  
      struct LayoutState &state = *o_state;
      if (state.main == -1)
      {
          HMI_SEQ_ERROR(req_num, "No surface active");
 -        return false;
 +        return ret;
      }
  
      // Check against main_surface, main_surface_name is the configuration item.
      {
          HMI_SEQ_DEBUG(req_num, "Refusing to deactivate main_surface %d", *surface_id);
          //reply(nullptr);
 -        return true;
 +        return WMError::SUCCESS;
      }
      if ((state.main == *surface_id) && (state.sub == *surface_id))
      {
          HMI_SEQ_ERROR(req_num, "Surface is not active");
 -        return false;
 +        return ret;
      }
  
      if (state.main == *surface_id)
                  this->enqueue_flushdraw(state.main);
              });
      }
 -    return true;
 +    return WMError::SUCCESS;
  }
  
 -bool App::lm_layout_change(const struct WMAction &action)
 +WMError App::lm_layout_change(const struct WMAction &action)
  {
      const char *msg = this->check_surface_exist(action.role.c_str());
  
      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);
 -        //g_app_list.removeRequest(req_num);
 -        return false;
 +        return WMError::LAYOUT_CHANGE_FAIL;
      }
      this->lm_layout_change(action.role.c_str());
 -    return true;
 +    return WMError::SUCCESS;
  }
  
 -bool App::do_transition(unsigned req_num)
 +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
      (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();
 -    bool ret = g_app_list.setAction(req_num, trigger.appid, trigger.role, trigger.area, is_activate);
++    WMError ret = g_app_list.setAction(req_num, trigger.appid, trigger.role, trigger.area, is_activate);
+     g_app_list.reqDump();
  
 -    if (!ret)
 +    if (ret != WMError::SUCCESS)
      {
          HMI_SEQ_ERROR(req_num, "Failed to set action");
          return ret;
  
      // 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);
          {
              sync_draw_happen = true;
              ret = lm_layout_change(y);
 -            if (!ret)
 +            if (ret != WMError::SUCCESS)
              {
 -                HMI_SEQ_ERROR(req_num, "Failed layout change: %s", y.appid.c_str());
 +                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
          {
              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)
 +    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 (ret && sync_draw_happen)
 +    else if (sync_draw_happen)
      {
          this->set_timer();
      }
      else
      {
-         app_list.removeRequest(req_num); // HACK!!!
+         g_app_list.removeRequest(req_num); // HACK!!!
      }
      return ret;
  }
@@@ -762,10 -758,21 +759,21 @@@ void App::lm_layout_change(const char *
                          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 -861,19 +862,19 @@@ void App::api_activate_surface(char con
      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());
      }
  
      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());
  
      /*
      * Do allocate tasks
      */
 -    bool ret = this->do_transition(new_req);
 +    WMError ret = this->do_transition(new_req);
  
 -    if (!ret)
 +    if (ret != WMError::SUCCESS)
      {
 -        HMI_SEQ_ERROR(new_req, "failed to do_transition");
 +        HMI_SEQ_ERROR(new_req, errorDescription(ret));
          //this->emit_error()
      }
  }
@@@ -911,18 -918,18 +919,18 @@@ void App::api_deactivate_surface(char c
      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());
      }
  
      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());
  
      /*
      * Do allocate tasks
      */
 -    bool ret = this->do_transition(new_req);
 +    WMError ret = this->do_transition(new_req);
  
 -    if (!ret)
 +    if (ret != WMError::SUCCESS)
      {
 -        HMI_SEQ_ERROR(new_req, "failed to do_transition");
 +        HMI_SEQ_ERROR(new_req, errorDescription(ret));
          //this->emit_error()
      }
  }
@@@ -995,43 -1002,40 +1003,43 @@@ void App::lm_enddraw(const char *drawin
      }
  }
  
- 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");
 -    do_transition(req);
 +    WMError rc = do_transition(req);
 +    if(rc != WMError::SUCCESS){
 +        HMI_SEQ_ERROR(req, errorDescription(rc));
 +    }
  }
  
  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)
      {
          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 -1142,7 +1146,7 @@@ void App::surface_removed(uint32_t surf
  {
      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 -1211,8 +1215,8 @@@ result<int> App::api_request_surface(ch
          // 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 --combined src/app.hpp
@@@ -33,7 -33,6 +33,7 @@@
  #include "wayland_ivi_wm.hpp"
  #include "hmi-debug.h"
  #include "request.hpp"
 +#include "wm-error.h"
  
  namespace wl
  {
@@@ -262,9 -261,9 +262,9 @@@ struct Ap
      void emit_invisible(char const *label);
      void emit_visible(char const *label);
  
 -    bool do_transition(unsigned req_num);
 +    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();
      // The following function is temporary.
      // Then will be removed when layermanager is finished
      void lm_layout_change(const char *drawing_name);
 -    bool lm_layout_change(const struct WMAction &action);
 -    bool lm_release(const struct WMAction &action);
 +    WMError lm_layout_change(const struct WMAction &action);
 +    WMError lm_release(const struct WMAction &action);
      void lm_enddraw(const char *drawing_name);
  };
  
diff --combined src/applist.cpp
@@@ -20,7 -20,6 +20,6 @@@
  
  using std::shared_ptr;
  using std::string;
- using std::unique_ptr;
  using std::vector;
  
  namespace wm
@@@ -28,8 -27,8 +27,8 @@@
  
  AppList::AppList()
      : req_list(0),
-       client_list(0),
-       current_seq(1)
+       app2client(0),
+       current_req(1)
  {
  }
  
@@@ -38,32 -37,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){
   */
  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;
  
  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
  }
  
 -bool AppList::requestFinished() const
 -{
 -    return this->req_list.empty();
 -}
 -
  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;
          }
  
  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;
          }
      }
  }
  
 -bool AppList::setAction(unsigned req_num, const struct WMAction &action)
 +WMError AppList::setAction(unsigned req_num, const struct WMAction &action)
  {
 -    bool result = false;
 +    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;
          }
          x.sync_draw_req.push_back(action);
 -        result = true;
 +        result = WMError::SUCCESS;
          break;
      }
  
      return result;
  }
  
 -bool AppList::setAction(unsigned req_num, const string &appid, const string &role, const string &area, bool visible)
+ /**
+  * 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)
  {
 -    bool result = false;
 +    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 = true;
 +        result = WMError::SUCCESS;
          break;
      }
      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)
              {
              }
          }
      }
-     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)
      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)
      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();
      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 --combined src/applist.hpp
@@@ -20,9 -20,9 +20,9 @@@
  #include <string>
  #include <map>
  #include <memory>
 -//#include <experimental/optional>
  #include "wm-client.hpp"
  #include "request.hpp"
 +#include "wm-error.h"
  
  namespace wm
  {
@@@ -41,37 -41,37 +41,36 @@@ class AppLis
      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();
 -    bool requestFinished() const;
 -    bool setAction(unsigned req_num, const struct WMAction &action);
 -    bool setAction(unsigned req_num, const std::string &appid, const std::string &role, const std::string &area, bool visible = true);
 +    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 --combined src/wm-error.cpp
@@@ -17,7 -17,7 +17,7 @@@
  
  namespace wm {
  
 -static const char *errorDescription(WMError enum_error_number)
 +const char *errorDescription(WMError enum_error_number)
  {
      switch (enum_error_number){
          case SUCCESS:
              return "Request is rejected, due to the policy rejection of the request.";
          case REQ_DROPPED:
              return "Request is dropped, because the high priority request is done";
 +        case NOT_REGISTERED:
 +            return "Not registered";
          case TIMEOUT_EXPIRED:
              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 --combined src/wm-error.h
@@@ -26,14 -26,12 +26,15 @@@ typedef enum WINDOWMANAGER_ERRO
      REQ_REJECTED,
      REQ_DROPPED,
      TIMEOUT_EXPIRED,
 +    NOT_REGISTERED,
 +    LAYOUT_CHANGE_FAIL,
+     NO_ENTRY,
      UNKNOWN,
      ERR_MAX = UNKNOWN
 -} WMError;
 +}
 +WMError;
  
 -static const char *errorDescription(WMError enum_error_number);
 +const char *errorDescription(WMError enum_error_number);
  
  }
  #endif // WINDOW_MANAGER_ERROR