aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-07-31 11:42:52 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-07-31 11:42:52 +0900
commitf35e79a450b49bd62a529d74980f332c62aa4c6b (patch)
tree48dce85b64d974bb38eee51121f57d1342201c3a /src/main.cpp
parentc558f5f94338b1b95a99d6ef9c91731bd2d4cebf (diff)
Forgot to merge
Call api_set_role from main.cpp Change-Id: I7e27dd09e8023e9e44982df5554820134696fb35 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index b5659e2..4c3d07c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -318,6 +318,54 @@ void windowmanager_requestsurfacexdg(afb_req req) noexcept
}
}
+void windowmanager_setrole(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> 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<std::mutex> guard(binding_m);
@@ -726,6 +774,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},