diff options
author | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2018-09-18 16:18:19 +0900 |
---|---|---|
committer | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2018-09-18 16:18:19 +0900 |
commit | 494d3a09bdbc74c9005db421122cc60acb733443 (patch) | |
tree | 901f46c08b01d7eb6cb214b09c04c5dc769deb61 /src | |
parent | b7957f3fc1e5f5ce0525d62c67da64457ef1d9e0 (diff) |
On the way to adding attach service surface
Change-Id: Ief7fe7ecbe2022b9b6b70e4f3df1c2e7a074075a
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 41 | ||||
-rw-r--r-- | src/window_manager.cpp | 15 | ||||
-rw-r--r-- | src/window_manager.hpp | 1 |
3 files changed, 57 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index d5adfd5..5141def 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -507,6 +507,46 @@ void windowmanager_set_render_order(afb_req req) noexcept } } +void windowmanager_attach_app(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; + } + + char* appid = afb_req_get_application_id(req); + if(appid) + { + json_object *jreq = afb_req_json(req); + json_object *j_dest, *j_id; // Do not free this. binder frees jreq, then free j_ro + if (json_object_object_get_ex(jreq, "destination", &j_dest) && + json_object_object_get_ex(jreq, "service_surface", &j_id)) + { + const char* dest_app = json_object_get_string(j_dest); + const char* service = json_object_get_string(j_id); + + std::string uuid = g_afb_instance->wmgr.api_client_attach_service_surface(appid, dest_app, service); + if (uuid.empty()) + { + afb_req_fail(req, "failed", nullptr); + } + else + { + json_object *resp = json_object_new_object(); + json_object_object_add(resp, "uuid", json_object_new_string(uuid.c_str())); + afb_req_success(req, resp, nullptr); + } + } + free(appid); + } + else + { + afb_req_fail(req, "failed", nullptr); + } +} + void windowmanager_wm_subscribe(afb_req req) noexcept { std::lock_guard<std::mutex> guard(binding_m); @@ -706,6 +746,7 @@ const struct afb_verb_v2 windowmanager_verbs[] = { {"getDisplayInfo", windowmanager_getdisplayinfo_thunk, nullptr, nullptr, AFB_SESSION_NONE}, {"getAreaInfo", windowmanager_getareainfo_thunk, nullptr, nullptr, AFB_SESSION_NONE}, {"setRenderOrder", windowmanager_set_render_order, nullptr, nullptr, AFB_SESSION_NONE}, + {"attachApp", windowmanager_attach_app, nullptr, nullptr, AFB_SESSION_NONE}, {"wm_subscribe", windowmanager_wm_subscribe, nullptr, nullptr, AFB_SESSION_NONE}, {"list_drawing_names", windowmanager_list_drawing_names, nullptr, nullptr, AFB_SESSION_NONE}, {"ping", windowmanager_ping, nullptr, nullptr, AFB_SESSION_NONE}, diff --git a/src/window_manager.cpp b/src/window_manager.cpp index 60470b4..0eeebcd 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -514,6 +514,21 @@ bool WindowManager::api_client_set_render_order(char const* appid, const vector< return ret; } +string api_client_attach_service_surface(const char* appid, const char* dest, const char* service_surface) +{ + string uuid = "", s_dest; + s_dest = dest; + // uuid = generate_uuid_randam()); + auto client = g_app_list.lookUpClient(s_dest); + if(!client) + { + HMI_ERROR("Failed to look up destination [%s]", dest); + return uuid; + } + //string uuid = client->attachServiceSurface(appid); +} + + result<json_object *> WindowManager::api_get_display_info() { Screen screen = this->lc->getScreenInfo(); diff --git a/src/window_manager.hpp b/src/window_manager.hpp index 96dbfe6..7bd0802 100644 --- a/src/window_manager.hpp +++ b/src/window_manager.hpp @@ -178,6 +178,7 @@ class WindowManager void api_deactivate_surface(char const *appid, char const *role, const reply_func &reply); void api_enddraw(char const *appid, char const *role); bool api_client_set_render_order(const char *appid, const std::vector<std::string> &render_order); + std::string api_client_attach_service_surface(const char* appid, const char* dest, const char* service_surface); result<json_object *> api_get_display_info(); result<json_object *> api_get_area_info(char const *role); void send_event(char const *evname, char const *label); |