X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fmain.cpp;h=5990e9971617442459146b50604f4081121ba7a5;hb=741a9924776e40293b91eff00ec91d5a72f5da7f;hp=0447f86722d85214d9c78d96a3a74bd84766c881;hpb=c1d85371b1eb693128cf9553c356ea77e609d9a3;p=apps%2Fagl-service-windowmanager.git diff --git a/src/main.cpp b/src/main.cpp index 0447f86..5990e99 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -189,13 +189,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("wm", errmsg); - return; - } - }); + [](const char *) {}); g_afb_instance->wmgr.removeClient(ctxt->name); delete ctxt; @@ -308,6 +302,54 @@ void windowmanager_requestsurfacexdg(afb_req req) noexcept } } +void windowmanager_setrole(afb_req req) noexcept +{ + std::lock_guard guard(binding_m); + if (g_afb_instance == nullptr) + { + afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?"); + return; + } + try + { + unsigned pid = 0; + char const *appid = afb_req_get_application_id(req); + json_object *jreq = afb_req_json(req); + + json_object *j_role = nullptr; + if (!json_object_object_get_ex(jreq, "role", &j_role)) + { + afb_req_fail(req, "failed", "Need char const* argument role"); + return; + } + char const *a_role = json_object_get_string(j_role); + + json_object *j_pid = nullptr; + if (json_object_object_get_ex(jreq, "pid", &j_pid)) + { + HMI_DEBUG("wm", "PID is set"); + char const *a_pid = json_object_get_string(j_pid); + pid = std::stol(a_pid); + } + + auto ret = g_afb_instance->wmgr.api_set_role(appid, a_role, pid); + if (!ret) + { + afb_req_fail(req, "failed", "Couldn't register"); + return; + } + + createSecurityContext(req, appid, a_role); + + afb_req_success(req, NULL, "success"); + } + catch (std::exception &e) + { + afb_req_fail_f(req, "failed", "Uncaught exception while calling requestsurfacexdg: %s", e.what()); + return; + } +} + void windowmanager_activatewindow(afb_req req) noexcept { std::lock_guard guard(binding_m); @@ -716,6 +758,7 @@ void windowmanager_debug_terminate(afb_req req) noexcept const struct afb_verb_v2 windowmanager_verbs[] = { {"requestsurface", windowmanager_requestsurface, nullptr, nullptr, AFB_SESSION_NONE}, {"requestsurfacexdg", windowmanager_requestsurfacexdg, nullptr, nullptr, AFB_SESSION_NONE}, + {"setrole", windowmanager_setrole, nullptr, nullptr, AFB_SESSION_NONE}, {"activatewindow", windowmanager_activatewindow, nullptr, nullptr, AFB_SESSION_NONE}, {"deactivatewindow", windowmanager_deactivatewindow, nullptr, nullptr, AFB_SESSION_NONE}, {"enddraw", windowmanager_enddraw, nullptr, nullptr, AFB_SESSION_NONE},