Some events were emitted in a function before it replies.
This patch changes
* The function checks parameter then reply error if it is incorrect.
* After checking parameters, the function continues to process.
The exeption is the syncronous functions such as requestSurface.
Change-Id: I168eba3e2b70d53615a4221bcbbba6bc6096c1db
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
this->display->flush();
}
this->display->flush();
}
-char const *App::api_activate_surface(char const *drawing_name, char const *drawing_area) {
+void App::api_activate_surface(char const *drawing_name, char const *drawing_area, const reply_func &reply) {
ST();
auto const &surface_id = this->lookup_id(drawing_name);
if (!surface_id) {
ST();
auto const &surface_id = this->lookup_id(drawing_name);
if (!surface_id) {
- return "Surface does not exist";
+ reply("Surface does not exist");
+ return;
}
if (!this->controller->surface_exists(*surface_id)) {
}
if (!this->controller->surface_exists(*surface_id)) {
- return "Surface does not exist in controller!";
+ reply("Surface does not exist in controller!");
+ return;
}
auto layer_id = this->layers.get_layer_id(*surface_id);
if (!layer_id) {
}
auto layer_id = this->layers.get_layer_id(*surface_id);
if (!layer_id) {
- return "Surface is not on any layer!";
+ reply("Surface is not on any layer!");
+ return;
}
auto o_state = *this->layers.get_layout_state(*surface_id);
if (o_state == nullptr) {
}
auto o_state = *this->layers.get_layout_state(*surface_id);
if (o_state == nullptr) {
- return "Could not find layer for surface";
+ reply("Could not find layer for surface");
+ return;
+ HMI_DEBUG("wm", "surface %d is detected", *surface_id);
+ reply(nullptr);
+
struct LayoutState &state = *o_state;
// disable layers that are above our current layer
struct LayoutState &state = *o_state;
// disable layers that are above our current layer
-
- // no error
- return nullptr;
-char const *App::api_deactivate_surface(char const *drawing_name) {
+void App::api_deactivate_surface(char const *drawing_name, const reply_func &reply) {
ST();
auto const &surface_id = this->lookup_id(drawing_name);
if (!surface_id) {
ST();
auto const &surface_id = this->lookup_id(drawing_name);
if (!surface_id) {
- return "Surface does not exist";
- }
+ reply ("Surface does not exist");
+ return;
+ }
if (*surface_id == this->layers.main_surface) {
if (*surface_id == this->layers.main_surface) {
- return "Cannot deactivate main_surface";
+ reply("Cannot deactivate main_surface");
+ return;
}
auto o_state = *this->layers.get_layout_state(*surface_id);
if (o_state == nullptr) {
}
auto o_state = *this->layers.get_layout_state(*surface_id);
if (o_state == nullptr) {
- return "Could not find layer for surface";
+ reply("Could not find layer for surface");
+ return;
}
struct LayoutState &state = *o_state;
if (state.main == -1) {
}
struct LayoutState &state = *o_state;
if (state.main == -1) {
- return "No surface active";
+ reply("No surface active");
+ return;
}
// Check against main_surface, main_surface_name is the configuration item.
if (*surface_id == this->layers.main_surface) {
HMI_DEBUG("wm", "Refusing to deactivate main_surface %d", *surface_id);
}
// Check against main_surface, main_surface_name is the configuration item.
if (*surface_id == this->layers.main_surface) {
HMI_DEBUG("wm", "Refusing to deactivate main_surface %d", *surface_id);
+ reply(nullptr);
+ return;
+ if((state.main == *surface_id) && (state.sub == *surface_id)){
+ reply("Surface is not active");
+ return;
+ }
+ reply(nullptr);
if (state.main == *surface_id) {
if (state.sub != -1) {
if (state.main == *surface_id) {
if (state.sub != -1) {
area_rect.x, area_rect.y, area_rect.w, area_rect.h);
this->enqueue_flushdraw(state.main);
});
area_rect.x, area_rect.y, area_rect.w, area_rect.h);
this->enqueue_flushdraw(state.main);
});
- } else {
- return "Surface is not active";
}
void App::enqueue_flushdraw(int surface_id) {
}
void App::enqueue_flushdraw(int surface_id) {
-char const *App::api_enddraw(char const *drawing_name) {
+void App::api_enddraw(char const *drawing_name) {
for (unsigned i = 0, iend = this->pending_end_draw.size(); i < iend; i++) {
auto n = this->lookup_name(this->pending_end_draw[i]);
if (n && *n == drawing_name) {
for (unsigned i = 0, iend = this->pending_end_draw.size(); i < iend; i++) {
auto n = this->lookup_name(this->pending_end_draw[i]);
if (n && *n == drawing_name) {
this->pending_end_draw.resize(iend - 1);
this->activate(this->pending_end_draw[i]);
this->emit_flushdraw(drawing_name);
this->pending_end_draw.resize(iend - 1);
this->activate(this->pending_end_draw[i]);
this->emit_flushdraw(drawing_name);
- return "No EndDraw pending for surface";
}
void App::api_ping() { this->dispatch_pending_events(); }
}
void App::api_ping() { this->dispatch_pending_events(); }
} else {
auto drawing_name = this->lookup_name(surface_id);
if (drawing_name) {
} else {
auto drawing_name = this->lookup_name(surface_id);
if (drawing_name) {
- this->api_deactivate_surface(drawing_name->c_str());
+ this->api_deactivate_surface(drawing_name->c_str(), [](const char*){});
void App::deactivate_main_surface() {
this->layers.main_surface = -1;
void App::deactivate_main_surface() {
this->layers.main_surface = -1;
- this->api_deactivate_surface(this->layers.main_surface_name.c_str());
+ this->api_deactivate_surface(this->layers.main_surface_name.c_str(), [](const char*){});
}
bool App::can_split(struct LayoutState const &state, int new_id) {
}
bool App::can_split(struct LayoutState const &state, int new_id) {
struct App {
typedef std::unordered_map<uint32_t, struct compositor::rect> rect_map;
struct App {
typedef std::unordered_map<uint32_t, struct compositor::rect> rect_map;
+ typedef std::function<void(const char* err_msg)> reply_func;
enum EventType {
Event_Val_Min = 0,
enum EventType {
Event_Val_Min = 0,
result<int> api_request_surface(char const *drawing_name);
char const *api_request_surface(char const *drawing_name, char const *ivi_id);
result<int> api_request_surface(char const *drawing_name);
char const *api_request_surface(char const *drawing_name, char const *ivi_id);
- char const *api_activate_surface(char const *drawing_name, char const *drawing_area);
- char const *api_deactivate_surface(char const *drawing_name);
- char const *api_enddraw(char const *drawing_name);
+ void api_activate_surface(char const *drawing_name, char const *drawing_area, const reply_func &reply);
+ void api_deactivate_surface(char const *drawing_name, const reply_func &reply);
+ void api_enddraw(char const *drawing_name);
result<json_object *> api_get_display_info();
result<json_object *> api_get_area_info(char const *drawing_name);
result<json_object *> api_get_display_info();
result<json_object *> api_get_area_info(char const *drawing_name);
- char const *api_subscribe(afb_req *req, char const *event_name);
void api_ping();
void send_event(char const *evname, char const *label);
void send_event(char const *evname, char const *label, char const *area, int x, int y, int w, int h);
void api_ping();
void send_event(char const *evname, char const *label);
void send_event(char const *evname, char const *label, char const *area, int x, int y, int w, int h);
- auto ret = g_afb_instance->app.api_activate_surface(a_drawing_name, a_drawing_area);
- if (ret != nullptr) {
- afb_req_fail(req, "failed", ret);
- return;
- }
+ g_afb_instance->app.api_activate_surface(a_drawing_name, a_drawing_area,
+ [&req](const char* errmsg){
+ if (errmsg != nullptr) {
+ HMI_ERROR("wm", errmsg);
+ afb_req_fail(req, "failed", errmsg);
+ return;
+ }
+ afb_req_success(req, NULL, "success");
+ });
- afb_req_success(req, NULL, "success");
} catch (std::exception &e) {
} catch (std::exception &e) {
- afb_req_fail_f(req, "failed", "Uncaught exception while calling activatesurface: %s", e.what());
+ HMI_WARNING("wm", "failed", "Uncaught exception while calling activatesurface: %s", e.what());
- auto ret = g_afb_instance->app.api_deactivate_surface(a_drawing_name);
- if (ret != nullptr) {
- afb_req_fail(req, "failed", ret);
- return;
- }
+ g_afb_instance->app.api_deactivate_surface(a_drawing_name,
+ [&req](const char* errmsg){
+ if (errmsg != nullptr) {
+ HMI_ERROR("wm", errmsg);
+ afb_req_fail(req, "failed", errmsg);
+ return;
+ }
+ afb_req_success(req, NULL, "success");
+ });
- afb_req_success(req, NULL, "success");
} catch (std::exception &e) {
} catch (std::exception &e) {
- afb_req_fail_f(req, "failed", "Uncaught exception while calling deactivatesurface: %s", e.what());
+ HMI_WARNING("wm", "Uncaught exception while calling deactivatesurface: %s", e.what());
afb_req_fail(req, "failed", "Need char const* argument drawing_name");
return;
}
afb_req_fail(req, "failed", "Need char const* argument drawing_name");
return;
}
+ afb_req_success(req, NULL, "success");
- auto ret = g_afb_instance->app.api_enddraw(a_drawing_name);
- if (ret != nullptr) {
- afb_req_fail(req, "failed", ret);
- return;
- }
+ g_afb_instance->app.api_enddraw(a_drawing_name);
- afb_req_success(req, NULL, "success");
} catch (std::exception &e) {
} catch (std::exception &e) {
- afb_req_fail_f(req, "failed", "Uncaught exception while calling enddraw: %s", e.what());
+ HMI_WARNING("wm", "failed", "Uncaught exception while calling enddraw: %s", e.what());