X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fmain.cpp;fp=src%2Fmain.cpp;h=d9f0302c976af2f2d48bb594fd2c4f91cde71de4;hb=9fabd6550e183283363b61f71092477342a357d1;hp=72cc8daf5dd919b80c7b24d701c604d327510e02;hpb=7526846697e4485bca995f01a130f5e34a40b690;p=apps%2Fagl-service-windowmanager.git diff --git a/src/main.cpp b/src/main.cpp index 72cc8da..d9f0302 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -183,13 +183,7 @@ static void cbRemoveClientCtxt(void *data) // so notify it by deactivate request. g_afb_instance->wmgr.api_deactivate_surface( ctxt->name.c_str(), ctxt->role.c_str(), - [](const char *errmsg) { - if (errmsg != nullptr) - { - HMI_ERROR(errmsg); - return; - } - }); + [](const char *) {}); g_afb_instance->wmgr.removeClient(ctxt->name); delete ctxt; @@ -227,18 +221,26 @@ void windowmanager_requestsurface(afb_req req) noexcept return; } - const char *appid = afb_req_get_application_id(req); - auto ret = g_afb_instance->wmgr.api_request_surface( - appid, a_drawing_name); - if (ret.is_err()) + char *appid = afb_req_get_application_id(req); + if(appid) { - afb_req_fail(req, "failed", ret.unwrap_err()); - return; + auto ret = g_afb_instance->wmgr.api_request_surface( + appid, a_drawing_name); + if (ret.is_err()) + { + afb_req_fail(req, "failed", ret.unwrap_err()); + } + else + { + createSecurityContext(req, appid, a_drawing_name); + afb_req_success(req, json_object_new_int(ret.unwrap()), "success"); + } + free(appid); + } + else + { + afb_req_fail(req, "failed", nullptr); } - - createSecurityContext(req, appid, a_drawing_name); - - afb_req_success(req, json_object_new_int(ret.unwrap()), "success"); } catch (std::exception &e) { @@ -275,19 +277,23 @@ void windowmanager_requestsurfacexdg(afb_req req) noexcept return; } char const *a_ivi_id = json_object_get_string(j_ivi_id); - char const *appid = afb_req_get_application_id(req); - auto ret = g_afb_instance->wmgr.api_request_surface( - appid, a_drawing_name, a_ivi_id); - - if (ret != nullptr) + char *appid = afb_req_get_application_id(req); + if(appid) { - afb_req_fail(req, "failed", ret); - return; - } + auto ret = g_afb_instance->wmgr.api_request_surface( + appid, a_drawing_name, a_ivi_id); - createSecurityContext(req, appid, a_drawing_name); - - afb_req_success(req, NULL, "success"); + if (ret != nullptr) + { + afb_req_fail(req, "failed", ret); + } + else + { + createSecurityContext(req, appid, a_drawing_name); + afb_req_success(req, NULL, "success"); + } + free(appid); + } } catch (std::exception &e) { @@ -321,18 +327,22 @@ void windowmanager_activatewindow(afb_req req) noexcept return; } - g_afb_instance->wmgr.api_activate_surface( - afb_req_get_application_id(req), - a_drawing_name, a_drawing_area, - [&req](const char *errmsg) { - if (errmsg != nullptr) - { - HMI_ERROR(errmsg); - afb_req_fail(req, "failed", errmsg); - return; - } - afb_req_success(req, NULL, "success"); - }); + char* appid = afb_req_get_application_id(req); + if(appid) + { + g_afb_instance->wmgr.api_activate_surface( + appid, a_drawing_name, a_drawing_area, + [&req](const char *errmsg) { + if (errmsg != nullptr) + { + HMI_ERROR(errmsg); + afb_req_fail(req, "failed", errmsg); + return; + } + afb_req_success(req, NULL, "success"); + }); + free(appid); + } } catch (std::exception &e) { @@ -360,17 +370,22 @@ void windowmanager_deactivatewindow(afb_req req) noexcept return; } - g_afb_instance->wmgr.api_deactivate_surface( - afb_req_get_application_id(req), a_drawing_name, - [&req](const char *errmsg) { - if (errmsg != nullptr) - { - HMI_ERROR(errmsg); - afb_req_fail(req, "failed", errmsg); - return; - } - afb_req_success(req, NULL, "success"); - }); + char* appid = afb_req_get_application_id(req); + if(appid) + { + g_afb_instance->wmgr.api_deactivate_surface( + appid, a_drawing_name, + [&req](const char *errmsg) { + if (errmsg != nullptr) + { + HMI_ERROR(errmsg); + afb_req_fail(req, "failed", errmsg); + return; + } + afb_req_success(req, NULL, "success"); + }); + free(appid); + } } catch (std::exception &e) { @@ -399,8 +414,12 @@ void windowmanager_enddraw(afb_req req) noexcept } afb_req_success(req, NULL, "success"); - g_afb_instance->wmgr.api_enddraw( - afb_req_get_application_id(req), a_drawing_name); + char* appid = afb_req_get_application_id(req); + if(appid) + { + g_afb_instance->wmgr.api_enddraw(appid, a_drawing_name); + free(appid); + } } catch (std::exception &e) {