summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYuta Doi <yuta-d@witz-inc.co.jp>2017-10-28 18:55:48 +0900
committerYuta Doi <yuta-d@witz-inc.co.jp>2017-11-02 00:46:10 +0000
commitb10e52f09b7e7c6d2c7272087e2c245adf2e90df (patch)
treefaa47853315d2a7c9e3c257dbd5a83250ac8fa34 /src
parent1d45ed97751d447b451d0f629e0ec2a4358cb9ea (diff)
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 <yuta-d@witz-inc.co.jp>
Diffstat (limited to 'src')
-rw-r--r--src/libwindowmanager.cpp52
1 files changed, 38 insertions, 14 deletions
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<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 */
@@ -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);