diff options
-rw-r--r-- | src/app.cpp | 56 | ||||
-rw-r--r-- | src/app.hpp | 7 | ||||
-rw-r--r-- | src/applist.cpp | 17 | ||||
-rw-r--r-- | src/applist.hpp | 7 | ||||
-rw-r--r-- | src/wm-error.cpp | 6 | ||||
-rw-r--r-- | src/wm-error.h | 7 |
6 files changed, 53 insertions, 47 deletions
diff --git a/src/app.cpp b/src/app.cpp index 08a9371..5bd597c 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -453,21 +453,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 = 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); @@ -475,7 +476,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; @@ -483,7 +484,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. @@ -491,12 +492,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) @@ -546,10 +547,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()); @@ -559,14 +560,13 @@ bool App::lm_layout_change(const struct WMAction &action) if (msg) { 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 @@ -595,10 +595,10 @@ bool App::do_transition(unsigned req_num) { is_activate = false; } - 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; @@ -619,9 +619,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()); g_app_list.removeRequest(req_num); break; // TODO: if transition fails, what should we do? @@ -642,11 +643,11 @@ bool App::do_transition(unsigned req_num) } } - if (!ret) + if (ret != WMError::SUCCESS) { //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(); } @@ -898,11 +899,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() } } @@ -954,11 +955,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() } } @@ -1027,7 +1028,10 @@ void App::process_request() { 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) diff --git a/src/app.hpp b/src/app.hpp index 2ee3560..7ead82e 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 req_num); + WMError do_transition(unsigned sequence_number); void do_enddraw(unsigned req_num); 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 2575849..9b06c84 100644 --- a/src/applist.cpp +++ b/src/applist.cpp @@ -122,11 +122,6 @@ unsigned AppList::addAllocateRequest(WMRequest 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 (const auto &x : this->req_list) @@ -149,9 +144,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 : this->req_list) { if (req_num != x.req_num) @@ -159,7 +154,7 @@ bool AppList::setAction(unsigned req_num, const struct WMAction &action) continue; } x.sync_draw_req.push_back(action); - result = true; + result = WMError::SUCCESS; break; } @@ -173,9 +168,9 @@ bool AppList::setAction(unsigned req_num, const struct WMAction &action) * 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. */ -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.req_num) @@ -186,7 +181,7 @@ bool AppList::setAction(unsigned req_num, const string &appid, const string &rol WMAction action{appid, role, area, visible, edraw_f}; 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 bb80961..0f2285b 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 { @@ -53,9 +53,8 @@ class AppList /* 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() 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); diff --git a/src/wm-error.cpp b/src/wm-error.cpp index 0ced0d7..4b01922 100644 --- a/src/wm-error.cpp +++ b/src/wm-error.cpp @@ -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: @@ -28,8 +28,12 @@ static const char *errorDescription(WMError enum_error_number) 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: diff --git a/src/wm-error.h b/src/wm-error.h index 3413c72..155d791 100644 --- a/src/wm-error.h +++ b/src/wm-error.h @@ -26,12 +26,15 @@ typedef enum WINDOWMANAGER_ERROR 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
\ No newline at end of file |