diff options
author | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2018-08-09 19:57:05 +0900 |
---|---|---|
committer | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2018-08-09 20:01:41 +0900 |
commit | cc24ba7c7aea5a1a64c8847738bca113b3e2c5a1 (patch) | |
tree | 3ce6f9142e637d797a2ac89050abb55117374727 | |
parent | e0ec2034617e118426536646fe84977b7c70929e (diff) |
Extract constant variables from class
Change-Id: If1a3e18dd6467622165437ba4c975ddea188b0e5
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r-- | src/libwindowmanager.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/libwindowmanager.cpp b/src/libwindowmanager.cpp index 395c580..198c728 100644 --- a/src/libwindowmanager.cpp +++ b/src/libwindowmanager.cpp @@ -32,6 +32,14 @@ extern "C" { #define UNUSED(x) (void)(x) +namespace { + /* Key for json obejct */ + static const char g_kKeyDrawingName[] = "drawing_name"; + static const char g_kKeyDrawingArea[] = "drawing_area"; + static const char g_kKeyDrawingRect[] = "drawing_rect"; + static const char g_kKeyResponse[] = "response"; +} + /** * @class LibWindowmanager::Impl */ @@ -86,10 +94,6 @@ private: std::string("screenUpdated"), std::string("error") }; - /* Key for json obejct */ - const char *kKeyDrawingName = "drawing_name"; - const char *kKeyDrawingArea = "drawing_area"; - const char *kKeyDrawingRect = "drawing_rect"; struct Screen _screen; visible_handler _on_visible; @@ -245,11 +249,11 @@ int LibWindowmanager::Impl::requestSurface(json_object *object) { json_object *val; const char *tmp_label; - if (json_object_object_get_ex(object, this->kKeyDrawingName, &val)) { + if (json_object_object_get_ex(object, g_kKeyDrawingName, &val)) { tmp_label = json_object_get_string(val); } else { - HMI_DEBUG("libwm", "Not found key \"%s\"", this->kKeyDrawingName); + HMI_DEBUG("libwm", "Not found key \"%s\"", g_kKeyDrawingName); return -EINVAL; } @@ -273,7 +277,7 @@ int LibWindowmanager::Impl::requestSurface(json_object *object) { this->api_call("RequestSurface", object, [&rc](bool ok, json_object *j) { if (ok) { json_object *val; - if (json_object_object_get_ex(j, "response", &val)) { + if (json_object_object_get_ex(j, g_kKeyResponse, &val)) { rc = json_object_get_int(val); } else { @@ -302,11 +306,11 @@ int LibWindowmanager::Impl::requestSurfaceXDG(json_object *object) { json_object *val; const char *tmp_label; - if (json_object_object_get_ex(object, this->kKeyDrawingName, &val)) { + if (json_object_object_get_ex(object, g_kKeyDrawingName, &val)) { tmp_label = json_object_get_string(val); } else { - HMI_DEBUG("libwm", "Not found key \"%s\"", this->kKeyDrawingName); + HMI_DEBUG("libwm", "Not found key \"%s\"", g_kKeyDrawingName); return -EINVAL; } @@ -404,7 +408,7 @@ int LibWindowmanager::Impl::getDisplayInfo(json_object *object) { [&rc, &w_px, &h_px, &w_mm, &h_mm, &scale](bool ok, json_object *j) { if (ok) { json_object *val; - if (json_object_object_get_ex(j, "response", &val)) { + if (json_object_object_get_ex(j, g_kKeyResponse, &val)) { HMI_DEBUG("libwm", "responce:%s", json_object_get_string(val)); json_object *j_w_px = nullptr; @@ -507,7 +511,7 @@ int LibWindowmanager::Impl::getAreaInfo(json_object *in_obj, json_object *out_ob if (ok) { json_object *val; HMI_DEBUG("libwm", "j:%s", json_object_get_string(j)); - if (json_object_object_get_ex(j, "response", &val)) { + if (json_object_object_get_ex(j, g_kKeyResponse, &val)) { json_object *j_x = nullptr; if (!json_object_object_get_ex(val, "x", &j_x)) { HMI_DEBUG("libwm", "Not found key \"x\""); @@ -778,7 +782,7 @@ void LibWindowmanager::Impl::event(char const *et, json_object *object) { json_object *j_val; std::string role = ""; bool emit = false; - if(json_object_object_get_ex(object, this->kKeyDrawingName, &j_val)) { + if(json_object_object_get_ex(object, g_kKeyDrawingName, &j_val)) { role = json_object_get_string(j_val); } if (this->labels.find(role) != this->labels.end()){ @@ -806,10 +810,10 @@ void LibWindowmanager::Impl::event(char const *et, json_object *object) { } case Event_SyncDraw : if(_on_sync_draw && emit) { - json_object_object_get_ex(object, this->kKeyDrawingArea, &j_val); + json_object_object_get_ex(object, g_kKeyDrawingArea, &j_val); const char* area = json_object_get_string(j_val); json_object *j_rect; - json_object_object_get_ex(object, this->kKeyDrawingRect, &j_rect); + json_object_object_get_ex(object, g_kKeyDrawingRect, &j_rect); json_object_object_get_ex(j_rect, "x", &j_val); int x = json_object_get_int(j_val); json_object_object_get_ex(j_rect, "y", &j_val); @@ -849,7 +853,7 @@ void LibWindowmanager::Impl::event(char const *et, json_object *object) { if (i != this->handlers.end()) { json_object *val; const char *label; - if (json_object_object_get_ex(object, this->kKeyDrawingName, &val)) { + if (json_object_object_get_ex(object, g_kKeyDrawingName, &val)) { label = json_object_get_string(val); } else { @@ -876,7 +880,7 @@ int LibWindowmanager::Impl::runEventLoop() { int ret = pthread_create(&thread_id, NULL, event_loop_run, this->loop); if(ret != 0) { - printf("Cannot run eventloop due to error:%d", errno); + HMI_ERROR("libwm", "Cannot run eventloop due to error:%d", errno); return -1; } else @@ -884,7 +888,7 @@ int LibWindowmanager::Impl::runEventLoop() { } else { - printf("Connecting is not established yet"); + HMI_ERROR("libwm", "Connecting is not established yet"); return -1; } } |