From 1d45ed97751d447b451d0f629e0ec2a4358cb9ea Mon Sep 17 00:00:00 2001 From: Yuta Doi Date: Fri, 27 Oct 2017 22:57:49 +0900 Subject: Replace 'constexpr' with 'const char*' 'constexpr' causes the warning [-Wwrite-strings]. So replace 'constexpr' with 'const char*'. Change-Id: I03e2c7b53e4db6cb5b804c66cb88ae15e2387eb8 Signed-off-by: Yuta Doi --- src/libwindowmanager.cpp | 8 ++++++-- src/libwindowmanager.h | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/libwindowmanager.cpp b/src/libwindowmanager.cpp index 770d248..84a091f 100644 --- a/src/libwindowmanager.cpp +++ b/src/libwindowmanager.cpp @@ -57,6 +57,10 @@ class LibWindowmanager::Impl { std::string("flushdraw") }; + /* Key for json obejct */ + const char *kKeyDrawingName = "drawing_name"; + const char *kKeyDrawingArea = "drawing_area"; + // This is the LibWindowmanager interface impl int init(int port, char const *token); @@ -229,7 +233,7 @@ int LibWindowmanager::Impl::requestSurface(json_object *object) { TRACE(); const char *tmp_label = json_object_get_string( - json_object_object_get(object, LibWindowmanager::kKeyDrawingName)); + json_object_object_get(object, this->kKeyDrawingName)); // DrawingName in "object" is overwrited in api_call("RequestSurface") // So it is neccesary to copy it. @@ -444,7 +448,7 @@ void LibWindowmanager::Impl::event(char const *et, json_object *object) { auto i = this->handlers.find(oet.second); if (i != this->handlers.end()) { const char *label = json_object_get_string( - json_object_object_get(object, LibWindowmanager::kKeyDrawingName)); + json_object_object_get(object, this->kKeyDrawingName)); if (this->labels.find(label) != this->labels.end()) { i->second(object); diff --git a/src/libwindowmanager.h b/src/libwindowmanager.h index 59c5ca5..83dff5f 100644 --- a/src/libwindowmanager.h +++ b/src/libwindowmanager.h @@ -38,8 +38,8 @@ public: const std::string kStrAreaSub = "sub"; /* Key for json obejct */ - constexpr static char *kKeyDrawingName = "drawing_name"; - constexpr static char *kKeyDrawingArea = "drawing_area"; + const char *kKeyDrawingName = "drawing_name"; + const char *kKeyDrawingArea = "drawing_area"; enum EventType { Event_Active = 0, -- cgit 1.2.3-korg From b10e52f09b7e7c6d2c7272087e2c245adf2e90df Mon Sep 17 00:00:00 2001 From: Yuta Doi Date: Sat, 28 Oct 2017 18:55:48 +0900 Subject: Replace json_object_object_get() with json_object_object_get_ex() json_object_object_get() is deprecated so it causes compile warning. Change-Id: Id43c3e098a58bd9a1a20e9fb55bc194babd6f48d Signed-off-by: Yuta Doi --- src/libwindowmanager.cpp | 52 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/libwindowmanager.cpp b/src/libwindowmanager.cpp index 84a091f..267fecc 100644 --- a/src/libwindowmanager.cpp +++ b/src/libwindowmanager.cpp @@ -138,8 +138,13 @@ void onEvent(void *closure, const char *event, afb_wsj1_msg *msg) { return; } - reinterpret_cast(closure)->event( - event, json_object_object_get(afb_wsj1_msg_object_j(msg), "data")); + json_object *val; + if (json_object_object_get_ex(afb_wsj1_msg_object_j(msg), "data", &val)) { + reinterpret_cast(closure)->event(event, val); + } + else { + fprintf(stderr, "Not found key \"data\"\n"); + } } /* called when wsj1 hangsup */ @@ -158,12 +163,6 @@ constexpr struct afb_wsj1_itf itf = { // XXX: I am not sure this is the right thing to do though... std::recursive_mutex dispatch_mutex; -json_object *drawing_name_json_argument(char const *label) { - json_object *j = json_object_new_object(); - json_object_object_add(j, "drawing_name", json_object_new_string(label)); - return j; -} - } // namespace /** @@ -232,8 +231,15 @@ fail: int LibWindowmanager::Impl::requestSurface(json_object *object) { TRACE(); - const char *tmp_label = json_object_get_string( - json_object_object_get(object, this->kKeyDrawingName)); + 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 { + fprintf(stderr, "Not found key \"%s\"\n", this->kKeyDrawingName); + return -EINVAL; + } // DrawingName in "object" is overwrited in api_call("RequestSurface") // So it is neccesary to copy it. @@ -253,8 +259,16 @@ int LibWindowmanager::Impl::requestSurface(json_object *object) { int rc2 = this->api_call("RequestSurface", object, [&rc](bool ok, json_object *j) { if (ok) { - int id = - json_object_get_int(json_object_object_get(j, "response")); + json_object *val; + int id; + if (json_object_object_get_ex(j, "response", &val)) { + id = json_object_get_int(val); + } + else { + fprintf(stderr, "Not found key \"response\"\n"); + rc = -EINVAL; + return; + } char *buf; asprintf(&buf, "%d", id); printf("setenv(\"QT_IVI_SURFACE_ID\", %s, 1)\n", buf); @@ -332,6 +346,9 @@ void LibWindowmanager::Impl::set_event_handler(enum EventType et, handler_fun fu json_object_object_add(j, "event", json_object_new_int(et)); int ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j, _on_reply_static, this); + if (0 > ret) { + fprintf(stderr, "calling %s/wm_subscribe failed\n", wmAPI); + } // Set event handler if (et >= Event_Active && et <= Event_FlushDraw) { @@ -447,8 +464,15 @@ void LibWindowmanager::Impl::event(char const *et, json_object *object) { auto i = this->handlers.find(oet.second); if (i != this->handlers.end()) { - const char *label = json_object_get_string( - json_object_object_get(object, this->kKeyDrawingName)); + json_object *val; + const char *label; + if (json_object_object_get_ex(object, this->kKeyDrawingName, &val)) { + label = json_object_get_string(val); + } + else { + fprintf(stderr, "Not found key \"%s\"\n", this->kKeyDrawingName); + return; + } if (this->labels.find(label) != this->labels.end()) { i->second(object); -- cgit 1.2.3-korg From b6f0140e194b80fa01b39f20dbff3d436dc2e792 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Thu, 26 Oct 2017 16:21:05 +0900 Subject: Use a version for the library To prevent bitbake package_qa issue, adding version is necessary. So I added a version number of 0.1.0. Bug-AGL : SPEC-1000 Change-Id: Ic7a22fe04cdab3d323ca75f9292a09ec29fd6d07 Signed-off-by: Kazumasa Mitsunari --- CMakeLists.txt | 4 ++-- src/CMakeLists.txt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/CMakeLists.txt b/CMakeLists.txt index e25b271..ba11f5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,8 +19,8 @@ cmake_minimum_required(VERSION 2.8) project(WindowManagerTMC) set(PACKAGE_VERSION_MAJOR 0) -set(PACKAGE_VERSION_MINOR 0) -set(PACKAGE_VERSION_REVISION 1) +set(PACKAGE_VERSION_MINOR 1) +set(PACKAGE_VERSION_REVISION 0) set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_REVISION}") find_package(PkgConfig REQUIRED) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 96cad55..9052d70 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,6 +51,7 @@ set_target_properties(${TARGET_LIBWM} # INTERPROCEDURAL_OPTIMIZATION ON CXX_EXTENSIONS OFF CXX_STANDARD 14 + VERSION ${PACKAGE_VERSION} CXX_STANDARD_REQUIRED ON) if (LINK_LIBCXX) -- cgit 1.2.3-korg