aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.cpp117
1 files changed, 71 insertions, 46 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 0447f86..e6cccb5 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -236,18 +236,26 @@ void windowmanager_requestsurface(afb_req req) noexcept
return;
}
- const char *appid = afb_req_get_application_id(req);
- auto ret = g_afb_instance->wmgr.api_request_surface(
- appid, a_drawing_name);
- if (ret.is_err())
+ char *appid = afb_req_get_application_id(req);
+ if(appid)
{
- afb_req_fail(req, "failed", ret.unwrap_err());
- return;
+ auto ret = g_afb_instance->wmgr.api_request_surface(
+ appid, a_drawing_name);
+ if (ret.is_err())
+ {
+ afb_req_fail(req, "failed", ret.unwrap_err());
+ }
+ else
+ {
+ createSecurityContext(req, appid, a_drawing_name);
+ afb_req_success(req, json_object_new_int(ret.unwrap()), "success");
+ }
+ free(appid);
+ }
+ else
+ {
+ afb_req_fail(req, "failed", nullptr);
}
-
- createSecurityContext(req, appid, a_drawing_name);
-
- afb_req_success(req, json_object_new_int(ret.unwrap()), "success");
}
catch (std::exception &e)
{
@@ -287,19 +295,23 @@ void windowmanager_requestsurfacexdg(afb_req req) noexcept
return;
}
char const *a_ivi_id = json_object_get_string(j_ivi_id);
- char const *appid = afb_req_get_application_id(req);
- auto ret = g_afb_instance->wmgr.api_request_surface(
- appid, a_drawing_name, a_ivi_id);
-
- if (ret != nullptr)
+ char *appid = afb_req_get_application_id(req);
+ if(appid)
{
- afb_req_fail(req, "failed", ret);
- return;
- }
-
- createSecurityContext(req, appid, a_drawing_name);
+ auto ret = g_afb_instance->wmgr.api_request_surface(
+ appid, a_drawing_name, a_ivi_id);
- afb_req_success(req, NULL, "success");
+ if (ret != nullptr)
+ {
+ afb_req_fail(req, "failed", ret);
+ }
+ else
+ {
+ createSecurityContext(req, appid, a_drawing_name);
+ afb_req_success(req, NULL, "success");
+ }
+ free(appid);
+ }
}
catch (std::exception &e)
{
@@ -336,18 +348,22 @@ void windowmanager_activatewindow(afb_req req) noexcept
return;
}
- g_afb_instance->wmgr.api_activate_surface(
- afb_req_get_application_id(req),
- a_drawing_name, a_drawing_area,
- [&req](const char *errmsg) {
- if (errmsg != nullptr)
- {
- HMI_ERROR("wm", errmsg);
- afb_req_fail(req, "failed", errmsg);
- return;
- }
- afb_req_success(req, NULL, "success");
- });
+ char* appid = afb_req_get_application_id(req);
+ if(appid)
+ {
+ g_afb_instance->wmgr.api_activate_surface(
+ appid, a_drawing_name, a_drawing_area,
+ [&req](const char *errmsg) {
+ if (errmsg != nullptr)
+ {
+ HMI_ERROR("wm", errmsg);
+ afb_req_fail(req, "failed", errmsg);
+ return;
+ }
+ afb_req_success(req, NULL, "success");
+ });
+ free(appid);
+ }
}
catch (std::exception &e)
{
@@ -378,17 +394,22 @@ void windowmanager_deactivatewindow(afb_req req) noexcept
return;
}
- g_afb_instance->wmgr.api_deactivate_surface(
- afb_req_get_application_id(req), a_drawing_name,
- [&req](const char *errmsg) {
- if (errmsg != nullptr)
- {
- HMI_ERROR("wm", errmsg);
- afb_req_fail(req, "failed", errmsg);
- return;
- }
- afb_req_success(req, NULL, "success");
- });
+ char* appid = afb_req_get_application_id(req);
+ if(appid)
+ {
+ g_afb_instance->wmgr.api_deactivate_surface(
+ appid, a_drawing_name,
+ [&req](const char *errmsg) {
+ if (errmsg != nullptr)
+ {
+ HMI_ERROR("wm", errmsg);
+ afb_req_fail(req, "failed", errmsg);
+ return;
+ }
+ afb_req_success(req, NULL, "success");
+ });
+ free(appid);
+ }
}
catch (std::exception &e)
{
@@ -420,8 +441,12 @@ void windowmanager_enddraw(afb_req req) noexcept
}
afb_req_success(req, NULL, "success");
- g_afb_instance->wmgr.api_enddraw(
- afb_req_get_application_id(req), a_drawing_name);
+ char* appid = afb_req_get_application_id(req);
+ if(appid)
+ {
+ g_afb_instance->wmgr.api_enddraw(appid, a_drawing_name);
+ free(appid);
+ }
}
catch (std::exception &e)
{