From 68462c7180f69f2c9df1e161a0f86a1f52f33360 Mon Sep 17 00:00:00 2001 From: Tadao Tanikawa Date: Tue, 5 Dec 2017 18:28:37 +0900 Subject: Support XDG application To run XDG application on AGL HomeScreen/WindowManager, a new binding API of WindowManager is added. This api is used only by AGL XDG-Launcher and all xdg applications should be packed as wgt compatible to AGL Application framework. Bug-AGL: SPEC-1096 Change-Id: Iea43c65ce03a352773c47e125490990f32dc9695 Signed-off-by: Tadao Tanikawa --- src/libwindowmanager.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ src/libwindowmanager.h | 2 ++ 2 files changed, 53 insertions(+) diff --git a/src/libwindowmanager.cpp b/src/libwindowmanager.cpp index 4a9b951..18cde43 100644 --- a/src/libwindowmanager.cpp +++ b/src/libwindowmanager.cpp @@ -67,6 +67,7 @@ class LibWindowmanager::Impl { // WM API int requestSurface(json_object *object); + int requestSurfaceXDG(json_object *object); int activateSurface(json_object *object); int deactivateSurface(json_object *object); int endDraw(json_object *object); @@ -291,6 +292,52 @@ int LibWindowmanager::Impl::requestSurface(json_object *object) { return rc; } +int LibWindowmanager::Impl::requestSurfaceXDG(json_object *object) { + TRACE(); + HMI_DEBUG("libwm", "called"); + + json_object *val; + const char *tmp_label; + if (json_object_object_get_ex(object, this->kKeyDrawingName, &val)) { + tmp_label = json_object_get_string(val); + } + else { + HMI_DEBUG("libwm", "Not found key \"%s\"", this->kKeyDrawingName); + return -EINVAL; + } + + // DrawingName in "object" is overwrited in api_call("RequestSurface") + // So it is neccesary to copy it. + const char *label = std::string(tmp_label).c_str(); + + if (this->labels.find(label) != this->labels.end()) { + HMI_ERROR("libwm", "Surface label already known!"); + return -EINVAL; + } + + // Store application name first + // because it may not return from setenv + HMI_DEBUG("libwm", "Insert application name: %s\n", label); + this->labels.insert(this->labels.end(), label); + + /* send the request */ + int rc = this->api_call("RequestSurfaceXDG", object, [](bool ok, json_object *j) { + if (!ok) { + HMI_ERROR("libwm", "Could not get surface ID from WM: %s", + j != nullptr ? json_object_to_json_string_ext( + j, JSON_C_TO_STRING_PRETTY) + : "no-info"); + } + }); + + if (rc != 0) { + HMI_ERROR("libwm", "Erase application name: %s", label); + this->labels.erase(label); + } + + return rc; +} + int LibWindowmanager::Impl::activateSurface(json_object *object) { TRACE(); HMI_DEBUG("libwm", "called"); @@ -513,6 +560,10 @@ int LibWindowmanager::requestSurface(json_object *object) { return this->d->requestSurface(object); } +int LibWindowmanager::requestSurfaceXDG(json_object *object) { + return this->d->requestSurfaceXDG(object); +} + int LibWindowmanager::activateSurface(json_object *object) { return this->d->activateSurface(object); } diff --git a/src/libwindowmanager.h b/src/libwindowmanager.h index 83dff5f..ec14617 100644 --- a/src/libwindowmanager.h +++ b/src/libwindowmanager.h @@ -40,6 +40,7 @@ public: /* Key for json obejct */ const char *kKeyDrawingName = "drawing_name"; const char *kKeyDrawingArea = "drawing_area"; + const char *kKeyIviId = "ivi_id"; enum EventType { Event_Active = 0, @@ -56,6 +57,7 @@ public: // WM API int requestSurface(json_object *object); + int requestSurfaceXDG(json_object *object); int activateSurface(json_object *object); int deactivateSurface(json_object *object); int endDraw(json_object *object); -- cgit 1.2.3-korg