summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Simon Moeller <jsmoeller@linuxfoundation.org>2017-11-02 17:01:36 +0000
committerGerrit Code Review <gerrit@automotivelinux.org>2017-11-02 17:01:36 +0000
commit2d89ec62b5118a4a5b5834b636184271c53b2312 (patch)
tree859fd0732782dea2376a78ffb1f7442e30f85f1c
parent52b760024986f635b78d77573311072936d16e4e (diff)
parentb6f0140e194b80fa01b39f20dbff3d436dc2e792 (diff)
Merge changes from topics '11553', '(detached'eel_4.99.2eel/4.99.24.99.2
* changes: Use a version for the library Replace json_object_object_get() with json_object_object_get_ex() Replace 'constexpr' with 'const char*'
-rw-r--r--CMakeLists.txt4
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/libwindowmanager.cpp56
-rw-r--r--src/libwindowmanager.h4
4 files changed, 47 insertions, 18 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d1c9a96..ad24ccb 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)
diff --git a/src/libwindowmanager.cpp b/src/libwindowmanager.cpp
index 770d248..267fecc 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);
@@ -134,8 +138,13 @@ void onEvent(void *closure, const char *event, afb_wsj1_msg *msg) {
return;
}
- reinterpret_cast<LibWindowmanager::Impl *>(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<LibWindowmanager::Impl *>(closure)->event(event, val);
+ }
+ else {
+ fprintf(stderr, "Not found key \"data\"\n");
+ }
}
/* called when wsj1 hangsup */
@@ -154,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
/**
@@ -228,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, LibWindowmanager::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.
@@ -249,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);
@@ -328,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) {
@@ -443,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, LibWindowmanager::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);
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,