diff options
-rw-r--r-- | src/app.cpp | 61 | ||||
-rw-r--r-- | src/app.hpp | 7 | ||||
-rw-r--r-- | src/applist.cpp | 16 | ||||
-rw-r--r-- | src/applist.hpp | 8 |
4 files changed, 49 insertions, 43 deletions
diff --git a/src/app.cpp b/src/app.cpp index 9dfe21a..cedf70c 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -142,7 +142,7 @@ void App::removeClient(const std::string &appid) bool App::subscribeEventForApp(const std::string &appid, afb_req req, const std::string &evname) { - if(!app_list.contains(appid)){ + if(app_list.contains(appid) != WMError::SUCCESS){ HMI_DEBUG("wm", "Client %s is not registered", appid.c_str()); return false; } @@ -455,21 +455,22 @@ void App::stop_timer() } } -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); + WMError ret = WMError::LAYOUT_CHANGE_FAIL; unsigned req_num = app_list.currentSequenceNumber(); 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); @@ -477,7 +478,7 @@ bool App::lm_release(const struct WMAction &action) if (o_state == nullptr) { HMI_SEQ_ERROR(req_num, "Could not find layer for surface"); - return false; + return ret; } struct LayoutState &state = *o_state; @@ -485,7 +486,7 @@ bool App::lm_release(const struct WMAction &action) 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. @@ -493,12 +494,12 @@ bool App::lm_release(const struct WMAction &action) { 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) @@ -548,10 +549,10 @@ bool App::lm_release(const struct WMAction &action) 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()); @@ -562,13 +563,13 @@ bool App::lm_layout_change(const struct WMAction &action) { HMI_SEQ_DEBUG(app_list.currentSequenceNumber(), msg); //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 @@ -597,10 +598,10 @@ bool App::do_transition(unsigned req_num) { is_activate = false; } - bool ret = app_list.setAction(req_num, trigger.appid, trigger.role, trigger.area, is_activate); + WMError ret = app_list.setAction(req_num, trigger.appid, trigger.role, trigger.area, is_activate); app_list.req_dump(); - if (!ret) + if (ret != WMError::SUCCESS) { HMI_SEQ_ERROR(req_num, "Failed to set action"); return ret; @@ -621,9 +622,10 @@ bool App::do_transition(unsigned req_num) { 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); break; // TODO: if transition fails, what should we do? @@ -644,11 +646,11 @@ bool App::do_transition(unsigned req_num) } } - if (!ret) + if (ret != WMError::SUCCESS) { //this->emit_error(request_seq, 0 /*error_num*/, "error happens"); // test } - else if (ret && sync_draw_happen) + else if (sync_draw_happen) { this->set_timer(); } @@ -852,7 +854,7 @@ 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) != WMError::SUCCESS) { reply("app doesn't request 'requestSurface' yet"); return; @@ -889,11 +891,11 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char /* * 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() } } @@ -909,7 +911,7 @@ 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)) + if (app_list.contains(id) != WMError::SUCCESS) { reply("app doesn't request 'requestSurface' yet"); return; @@ -945,11 +947,11 @@ void App::api_deactivate_surface(char const *appid, char const *drawing_name, co /* * 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() } } @@ -1018,7 +1020,10 @@ void App::process_request() { unsigned req = app_list.currentSequenceNumber(); 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) diff --git a/src/app.hpp b/src/app.hpp index 25a72cb..d13fd4d 100644 --- a/src/app.hpp +++ b/src/app.hpp @@ -33,6 +33,7 @@ #include "wayland_ivi_wm.hpp" #include "hmi-debug.h" #include "request.hpp" +#include "wm-error.h" namespace wl { @@ -261,7 +262,7 @@ struct App void emit_invisible(char const *label); void emit_visible(char const *label); - bool do_transition(unsigned sequence_number); + WMError do_transition(unsigned sequence_number); void do_enddraw(unsigned sequence_number); void process_request(); @@ -281,8 +282,8 @@ struct App // 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 --git a/src/applist.cpp b/src/applist.cpp index 8c13f5f..6b608d0 100644 --- a/src/applist.cpp +++ b/src/applist.cpp @@ -54,10 +54,10 @@ void AppList::removeClient(const string &appid) client_list.erase(appid); } -bool AppList::contains(const string &appid) +WMError AppList::contains(const string &appid) { auto result = client_list.find(appid); - return (client_list.end() != result) ? true : false; + return (client_list.end() != result) ? WMError::SUCCESS : WMError::NOT_REGISTERED; } void AppList::removeSurface(unsigned surface_id){ @@ -150,9 +150,9 @@ const vector<struct WMAction> &AppList::getActions(unsigned req_num) } } -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) { if (req_num != x.seq_num) @@ -160,16 +160,16 @@ bool AppList::setAction(unsigned req_num, const struct WMAction &action) 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) +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) @@ -179,7 +179,7 @@ bool AppList::setAction(unsigned req_num, const string &appid, const string &rol WMAction action{appid, role, area, visible, false}; x.sync_draw_req.push_back(action); - result = true; + result = WMError::SUCCESS; break; } return result; diff --git a/src/applist.hpp b/src/applist.hpp index 241f153..97f772b 100644 --- a/src/applist.hpp +++ b/src/applist.hpp @@ -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,7 +41,7 @@ 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); - bool contains(const std::string &appid); + WMError contains(const std::string &appid); int countClient(); std::shared_ptr<WMClient> lookUpClient(const std::string &appid); void removeSurface(unsigned surface); @@ -54,8 +54,8 @@ class AppList if appid is key to manage resources, it is better to select std::string otherwise WMClient is better, IMO */ bool requestFinished(); - 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); |