summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Simon Moeller <jsmoeller@linuxfoundation.org>2018-11-30 21:07:10 +0000
committerGerrit Code Review <gerrit@automotivelinux.org>2018-11-30 21:07:10 +0000
commit2b1bf85afe0a8b24f75386f7c24df85f9b785bd3 (patch)
tree8b727b720dd475deb8fbd52ec0cae83613b156ec
parentd1188744973931f66a83968310175369cd85c231 (diff)
parentd9dc8ef258ed2ddeeca83775eee945dbfdae59c5 (diff)
Merge "Migrates bindings v3"guppy_6.99.2guppy/6.99.26.99.2
-rw-r--r--policy_manager/policy_manager.cpp6
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/applist.cpp4
-rw-r--r--src/main.cpp68
-rw-r--r--src/util.cpp4
-rw-r--r--src/window_manager.cpp15
-rw-r--r--src/window_manager.hpp4
-rw-r--r--src/wm_client.cpp8
-rw-r--r--src/wm_client.hpp7
9 files changed, 71 insertions, 49 deletions
diff --git a/policy_manager/policy_manager.cpp b/policy_manager/policy_manager.cpp
index 999bc87..67f7179 100644
--- a/policy_manager/policy_manager.cpp
+++ b/policy_manager/policy_manager.cpp
@@ -26,7 +26,7 @@
extern "C"
{
-#define AFB_BINDING_VERSION 2
+#define AFB_BINDING_VERSION 3
#include <afb/afb-binding.h>
#include <systemd/sd-event.h>
#include "stm.h"
@@ -693,7 +693,7 @@ int PolicyManager::setStateTransitionProcessToSystemd(int event_id, uint64_t del
if (0 == delay_ms)
{
- int ret = sd_event_add_defer(afb_daemon_get_event_loop(), &event_source,
+ int ret = sd_event_add_defer(afb_api_get_event_loop(afbBindingV3root), &event_source,
&pm::transitionStateWrapper, new int(event_id));
if (0 > ret)
{
@@ -711,7 +711,7 @@ int PolicyManager::setStateTransitionProcessToSystemd(int event_id, uint64_t del
uint64_t usec = (time_spec.tv_sec * 1000000) + (time_spec.tv_nsec / 1000) + (delay_ms * 1000);
// Set timer
- int ret = sd_event_add_time(afb_daemon_get_event_loop(), &event_source,
+ int ret = sd_event_add_time(afb_api_get_event_loop(afbBindingV3root), &event_source,
CLOCK_BOOTTIME, usec, 1,
&pm::timerEventWrapper, new int(event_id));
if (0 > ret)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d2b16ae..fc19a18 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -56,7 +56,7 @@ target_link_libraries(${TARGETS_WM}
target_compile_definitions(${TARGETS_WM}
PRIVATE
- AFB_BINDING_VERSION=2
+ AFB_BINDING_VERSION=3
# We do not want source location of messages
AFB_BINDING_PRAGMA_NO_VERBOSE_DETAILS
WINMAN_VERSION_STRING="${PACKAGE_VERSION}"
@@ -70,7 +70,7 @@ endif()
target_compile_options(${TARGETS_WM}
PRIVATE
- -Wall -Wextra -Wno-unused-parameter -Wno-comment)
+ -Wall -Wextra -Wno-unused-parameter -Wno-comment -Wno-missing-field-initializers)
set_target_properties(${TARGETS_WM}
PROPERTIES
diff --git a/src/applist.cpp b/src/applist.cpp
index 17b47e3..67980f1 100644
--- a/src/applist.cpp
+++ b/src/applist.cpp
@@ -310,6 +310,10 @@ const vector<struct WMAction> &AppList::getActions(unsigned req_num, bool* found
}
}
HMI_SEQ_ERROR(req_num, "Couldn't get action with the request : %d", req_num);
+ {
+ static vector<struct WMAction> empty;
+ return empty;
+ }
}
/**
diff --git a/src/main.cpp b/src/main.cpp
index 29d25fb..333df70 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -56,7 +56,7 @@ int afb_instance::init()
return this->wmgr.init();
}
-int _binding_init()
+static int _binding_init()
{
HMI_NOTICE("WinMan ver. %s", WINMAN_VERSION_STRING);
@@ -78,7 +78,7 @@ error:
return -1;
}
-int binding_init() noexcept
+static int binding_init (afb_api_t api) noexcept
{
try
{
@@ -110,7 +110,7 @@ static void cbRemoveClientCtxt(void *data)
delete ctxt;
}
-static void createSecurityContext(afb_req req, const char* appid, const char* role)
+static void createSecurityContext(afb_req_t req, const char* appid, const char* role)
{
WMClientCtxt *ctxt = (WMClientCtxt *)afb_req_context_get(req);
if (!ctxt)
@@ -123,7 +123,7 @@ static void createSecurityContext(afb_req req, const char* appid, const char* ro
}
}
-void windowmanager_requestsurface(afb_req req) noexcept
+void windowmanager_requestsurface(afb_req_t req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
if (g_afb_instance == nullptr)
@@ -169,7 +169,7 @@ void windowmanager_requestsurface(afb_req req) noexcept
}
}
-void windowmanager_requestsurfacexdg(afb_req req) noexcept
+void windowmanager_requestsurfacexdg(afb_req_t req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
if (g_afb_instance == nullptr)
@@ -222,7 +222,7 @@ void windowmanager_requestsurfacexdg(afb_req req) noexcept
}
}
-void windowmanager_activatewindow(afb_req req) noexcept
+void windowmanager_activatewindow(afb_req_t req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
if (g_afb_instance == nullptr)
@@ -272,7 +272,7 @@ void windowmanager_activatewindow(afb_req req) noexcept
}
}
-void windowmanager_deactivatewindow(afb_req req) noexcept
+void windowmanager_deactivatewindow(afb_req_t req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
if (g_afb_instance == nullptr)
@@ -315,7 +315,7 @@ void windowmanager_deactivatewindow(afb_req req) noexcept
}
}
-void windowmanager_enddraw(afb_req req) noexcept
+void windowmanager_enddraw(afb_req_t req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
if (g_afb_instance == nullptr)
@@ -349,7 +349,7 @@ void windowmanager_enddraw(afb_req req) noexcept
}
}
-void windowmanager_getdisplayinfo_thunk(afb_req req) noexcept
+void windowmanager_getdisplayinfo_thunk(afb_req_t req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
if (g_afb_instance == nullptr)
@@ -376,7 +376,7 @@ void windowmanager_getdisplayinfo_thunk(afb_req req) noexcept
}
}
-void windowmanager_getareainfo_thunk(afb_req req) noexcept
+void windowmanager_getareainfo_thunk(afb_req_t req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
if (g_afb_instance == nullptr)
@@ -413,7 +413,7 @@ void windowmanager_getareainfo_thunk(afb_req req) noexcept
}
}
-void windowmanager_wm_subscribe(afb_req req) noexcept
+void windowmanager_wm_subscribe(afb_req_t req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
if (g_afb_instance == nullptr)
@@ -448,7 +448,7 @@ void windowmanager_wm_subscribe(afb_req req) noexcept
}
}
-void windowmanager_ping(afb_req req) noexcept
+void windowmanager_ping(afb_req_t req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
@@ -463,7 +463,7 @@ void windowmanager_ping(afb_req req) noexcept
}
}
-void windowmanager_debug_terminate(afb_req req) noexcept
+void windowmanager_debug_terminate(afb_req_t req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
if (g_afb_instance == nullptr)
@@ -490,18 +490,30 @@ void windowmanager_debug_terminate(afb_req req) noexcept
}
}
-const struct afb_verb_v2 windowmanager_verbs[] = {
- {"requestSurface", windowmanager_requestsurface, nullptr, nullptr, AFB_SESSION_NONE},
- {"requestSurfaceXDG", windowmanager_requestsurfacexdg, nullptr, nullptr, AFB_SESSION_NONE},
- {"activateWindow", windowmanager_activatewindow, nullptr, nullptr, AFB_SESSION_NONE},
- {"deactivateWindow", windowmanager_deactivatewindow, nullptr, nullptr, AFB_SESSION_NONE},
- {"endDraw", windowmanager_enddraw, nullptr, nullptr, AFB_SESSION_NONE},
- {"getDisplayInfo", windowmanager_getdisplayinfo_thunk, nullptr, nullptr, AFB_SESSION_NONE},
- {"getAreaInfo", windowmanager_getareainfo_thunk, nullptr, nullptr, AFB_SESSION_NONE},
- {"wm_subscribe", windowmanager_wm_subscribe, nullptr, nullptr, AFB_SESSION_NONE},
- {"ping", windowmanager_ping, nullptr, nullptr, AFB_SESSION_NONE},
- {"debug_terminate", windowmanager_debug_terminate, nullptr, nullptr, AFB_SESSION_NONE},
- {}};
-
-extern "C" const struct afb_binding_v2 afbBindingV2 = {
- "windowmanager", nullptr, nullptr, windowmanager_verbs, nullptr, binding_init, nullptr, 0};
+const afb_verb_t windowmanager_verbs[] = {
+ { .verb = "requestSurface", .callback = windowmanager_requestsurface },
+ { .verb = "requestSurfaceXDG", .callback = windowmanager_requestsurfacexdg },
+ { .verb = "activateWindow", .callback = windowmanager_activatewindow },
+ { .verb = "deactivateWindow", .callback = windowmanager_deactivatewindow },
+ { .verb = "endDraw", .callback = windowmanager_enddraw },
+ { .verb = "getDisplayInfo", .callback = windowmanager_getdisplayinfo_thunk },
+ { .verb = "getAreaInfo", .callback = windowmanager_getareainfo_thunk },
+ { .verb = "wm_subscribe", .callback = windowmanager_wm_subscribe },
+ { .verb = "ping", .callback = windowmanager_ping },
+ { .verb = "debug_terminate", .callback = windowmanager_debug_terminate },
+ {} };
+
+extern "C" const afb_binding_t afbBindingExport = {
+ .api = "windowmanager",
+ .specification = "windowmanager",
+ .info = "windowmanager",
+ .verbs = windowmanager_verbs,
+ .preinit = nullptr,
+ .init = binding_init,
+ .onevent = nullptr,
+ .userdata = nullptr,
+ .provide_class = nullptr,
+ .require_class = nullptr,
+ .require_api = nullptr,
+ .noconcurrency = 0
+};
diff --git a/src/util.cpp b/src/util.cpp
index 37977f2..eb6425d 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -29,7 +29,7 @@ void rectangle::fit(unsigned long to_width, unsigned long to_height)
{
// fit rect within (to_width x to_height)
- if (to_width <= width()) {
+ if (to_width <= (unsigned long)width()) {
// scale to fit with
set_bottom(top() + (static_cast<long>(to_width) * height() / width()) - 1);
set_right(left() + to_width - 1);
@@ -139,4 +139,4 @@ void _DUMP(enum LOG_LEVEL level, const char *log, ...)
fprintf(stderr, "%s \n", message);
va_end(args);
free(message);
-} \ No newline at end of file
+}
diff --git a/src/window_manager.cpp b/src/window_manager.cpp
index cc6f410..cd7d2e5 100644
--- a/src/window_manager.cpp
+++ b/src/window_manager.cpp
@@ -136,7 +136,7 @@ int WindowManager::init()
// Make afb event
for (int i = Event_Val_Min; i <= Event_Val_Max; i++)
{
- map_afb_event[kListEventName[i]] = afb_daemon_make_event(kListEventName[i].c_str());
+ map_afb_event[kListEventName[i]] = afb_api_make_event(afbBindingV3root, kListEventName[i].c_str());
}
const struct rect css_bg = this->lc->getAreaSize("fullscreen");
@@ -378,9 +378,9 @@ void WindowManager::api_enddraw(char const *appid, char const *drawing_name)
}
}
-int WindowManager::api_subscribe(afb_req req, int event_id)
+int WindowManager::api_subscribe(afb_req_t req, int event_id)
{
- struct afb_event event = this->map_afb_event[kListEventName[event_id]];
+ afb_event_t event = this->map_afb_event[kListEventName[event_id]];
return afb_req_subscribe(req, event);
}
@@ -839,6 +839,13 @@ void WindowManager::emitScreenUpdated(unsigned req_num)
HMI_SEQ_DEBUG(req_num, "emit screen updated");
bool found = false;
auto actions = g_app_list.getActions(req_num, &found);
+ if (!found)
+ {
+ HMI_SEQ_ERROR(req_num,
+ "Window Manager bug :%s : Action is not set",
+ errorDescription(WMError::NO_ENTRY));
+ return;
+ }
// create json object
json_object *j = json_object_new_object();
@@ -874,7 +881,7 @@ void WindowManager::setTimer()
if (g_timer_ev_src == nullptr)
{
// firsttime set into sd_event
- int ret = sd_event_add_time(afb_daemon_get_event_loop(), &g_timer_ev_src,
+ int ret = sd_event_add_time(afb_api_get_event_loop(afbBindingV3root), &g_timer_ev_src,
CLOCK_BOOTTIME, (uint64_t)(ts.tv_sec + kTimeOut) * 1000000ULL, 1, processTimerHandler, this);
if (ret < 0)
{
diff --git a/src/window_manager.hpp b/src/window_manager.hpp
index 8bfdb0f..30deb4b 100644
--- a/src/window_manager.hpp
+++ b/src/window_manager.hpp
@@ -176,7 +176,7 @@ class WindowManager
void api_activate_window(char const *appid, char const *role, char const *drawing_area, const reply_func &reply);
void api_deactivate_window(char const *appid, char const *role, const reply_func &reply);
void api_enddraw(char const *appid, char const *role);
- int api_subscribe(afb_req req, int event_id);
+ int api_subscribe(afb_req_t req, int event_id);
result<json_object *> api_get_display_info();
result<json_object *> api_get_area_info(char const *role);
void send_event(const std::string& evname, const std::string& role);
@@ -218,7 +218,7 @@ class WindowManager
void processNextRequest();
private:
- std::map<std::string, struct afb_event> map_afb_event;
+ std::map<std::string, afb_event_t> map_afb_event;
std::unordered_map<std::string, struct rect> area2size;
std::shared_ptr<LayerControl> lc;
PMWrapper pmw;
diff --git a/src/wm_client.cpp b/src/wm_client.cpp
index 7a93c7c..e7cb552 100644
--- a/src/wm_client.cpp
+++ b/src/wm_client.cpp
@@ -48,7 +48,7 @@ WMClient::WMClient(const string &appid, unsigned layer, unsigned surface, const
#if GTEST_ENABLED
string ev = x;
#else
- afb_event ev = afb_daemon_make_event(x.c_str());
+ afb_event_t ev = afb_api_make_event(afbBindingV3root, x.c_str());
#endif
evname2list[x] = ev;
}
@@ -66,7 +66,7 @@ WMClient::WMClient(const string &appid, const string &role)
#if GTEST_ENABLED
string ev = x;
#else
- afb_event ev = afb_daemon_make_event(x.c_str());
+ afb_event_t ev = afb_api_make_event(afbBindingV3root, x.c_str());
#endif
evname2list[x] = ev;
}
@@ -85,7 +85,7 @@ WMClient::WMClient(const string &appid, unsigned layer, const string &role)
#if GTEST_ENABLED
string ev = x;
#else
- afb_event ev = afb_daemon_make_event(x.c_str());
+ afb_event_t ev = afb_api_make_event(afbBindingV3root, x.c_str());
#endif
evname2list[x] = ev;
}
@@ -144,7 +144,7 @@ bool WMClient::removeSurfaceIfExist(unsigned surface)
#if GTEST_ENABLED
-bool WMClient::subscribe(afb_req req, const string &evname)
+bool WMClient::subscribe(afb_req_t req, const string &evname)
{
if(evname != kKeyError){
HMI_DEBUG("error is only enabeled for now");
diff --git a/src/wm_client.hpp b/src/wm_client.hpp
index 7e92ed5..623d34f 100644
--- a/src/wm_client.hpp
+++ b/src/wm_client.hpp
@@ -24,7 +24,6 @@
extern "C"
{
-#define AFB_BINDING_VERSION 2
#include <afb/afb-binding.h>
}
@@ -56,7 +55,7 @@ class WMClient
bool removeSurfaceIfExist(unsigned surface);
#if GTEST_ENABLED
- bool subscribe(afb_req req, const std::string &event_name);
+ bool subscribe(afb_req_t req, const std::string &event_name);
void emitError(WM_CLIENT_ERROR_EVENT ev);
#endif
@@ -74,9 +73,9 @@ class WMClient
// This is for unit test. afb_make_event occurs sig11 if call not in afb-binding
std::unordered_map<std::string, std::string> event2list;
#else
- std::unordered_map<std::string, struct afb_event> evname2list;
+ std::unordered_map<std::string, afb_event_t> evname2list;
#endif
};
} // namespace wm
-#endif \ No newline at end of file
+#endif