summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/hmi-debug.h117
-rw-r--r--policy_manager/CMakeLists.txt1
-rw-r--r--policy_manager/policy_manager.cpp186
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/applist.cpp16
-rw-r--r--src/applist.hpp2
-rw-r--r--src/json_helper.cpp20
-rw-r--r--src/json_helper.hpp8
-rw-r--r--src/main.cpp215
-rw-r--r--src/pm_wrapper.cpp41
-rw-r--r--src/request.hpp6
-rw-r--r--src/util.cpp89
-rw-r--r--src/util.hpp97
-rw-r--r--src/wayland_ivi_wm.cpp76
-rw-r--r--src/window_manager.cpp208
-rw-r--r--src/window_manager.hpp18
-rw-r--r--src/wm_client.cpp18
-rw-r--r--src/wm_layer.cpp (renamed from src/layers.cpp)42
-rw-r--r--src/wm_layer.hpp (renamed from src/layers.hpp)6
19 files changed, 518 insertions, 650 deletions
diff --git a/include/hmi-debug.h b/include/hmi-debug.h
deleted file mode 100644
index 697ac80..0000000
--- a/include/hmi-debug.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __HMI_DEBUG_H__
-#define __HMI_DEBUG_H__
-
-#include <time.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <stdlib.h>
-
-enum LOG_LEVEL{
- LOG_LEVEL_NONE = 0,
- LOG_LEVEL_ERROR,
- LOG_LEVEL_WARNING,
- LOG_LEVEL_NOTICE,
- LOG_LEVEL_INFO,
- LOG_LEVEL_DEBUG,
- LOG_LEVEL_MAX = LOG_LEVEL_DEBUG
-};
-
-#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
-
-#define HMI_ERROR(prefix, args,...) _HMI_LOG(LOG_LEVEL_ERROR, __FILENAME__, __FUNCTION__, __LINE__, prefix, args, ##__VA_ARGS__)
-#define HMI_WARNING(prefix, args,...) _HMI_LOG(LOG_LEVEL_WARNING, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
-#define HMI_NOTICE(prefix, args,...) _HMI_LOG(LOG_LEVEL_NOTICE, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
-#define HMI_INFO(prefix, args,...) _HMI_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
-#define HMI_DEBUG(prefix, args,...) _HMI_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
-
-#define HMI_SEQ_ERROR(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_ERROR, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__)
-#define HMI_SEQ_WARNING(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_WARNING, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__)
-#define HMI_SEQ_NOTICE(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_NOTICE, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__)
-#define HMI_SEQ_INFO(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__)
-#define HMI_SEQ_DEBUG(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__)
-
-#define DUMP(args, ...) _DUMP(LOG_LEVEL_DEBUG, args, ##__VA_ARGS__)
-
-static char ERROR_FLAG[6][20] = {"NONE", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"};
-
-static void _HMI_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, const char* prefix, const char* log, ...)
-{
- const int log_level = (getenv("USE_HMI_DEBUG") == NULL)?LOG_LEVEL_ERROR:atoi(getenv("USE_HMI_DEBUG"));
- if(log_level < level)
- {
- return;
- }
-
- char *message;
- struct timespec tp;
- unsigned int time;
-
- clock_gettime(CLOCK_REALTIME, &tp);
- time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
-
- va_list args;
- va_start(args, log);
- if (log == NULL || vasprintf(&message, log, args) < 0)
- message = NULL;
- fprintf(stderr, "[%10.3f] [%s %s] [%s, %s(), Line:%d] >>> %s \n", time / 1000.0, prefix, ERROR_FLAG[level], file, func, line, message);
- va_end(args);
- free(message);
-}
-
-static void _HMI_SEQ_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, unsigned seq_num, const char* log, ...){
- const int log_level = (getenv("USE_HMI_DEBUG") == NULL) ? LOG_LEVEL_ERROR:atoi(getenv("USE_HMI_DEBUG"));
- if(log_level < level)
- {
- return;
- }
-
- char *message;
- struct timespec tp;
- unsigned int time;
-
- clock_gettime(CLOCK_REALTIME, &tp);
- time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
-
- va_list args;
- va_start(args, log);
- if (log == NULL || vasprintf(&message, log, args) < 0)
- message = NULL;
- fprintf(stderr, "[%10.3f] [wm %s] [%s, %s(), Line:%d] >>> req %d: %s \n", time / 1000.0, ERROR_FLAG[level], file, func, line, seq_num, message);
- va_end(args);
- free(message);
-}
-
-static void _DUMP(enum LOG_LEVEL level, const char *log, ...)
-{
- const int log_level = (getenv("USE_HMI_DEBUG") == NULL) ? LOG_LEVEL_ERROR : atoi(getenv("USE_HMI_DEBUG"));
- if (log_level < level)
- {
- return;
- }
- char *message;
- va_list args;
- va_start(args, log);
- if (log == NULL || vasprintf(&message, log, args) < 0)
- message = NULL;
- fprintf(stderr, "%s \n", message);
- va_end(args);
- free(message);
-}
-#endif //__HMI_DEBUG_H__ \ No newline at end of file
diff --git a/policy_manager/CMakeLists.txt b/policy_manager/CMakeLists.txt
index 584d311..3ec4c39 100644
--- a/policy_manager/CMakeLists.txt
+++ b/policy_manager/CMakeLists.txt
@@ -45,6 +45,7 @@ add_library(${TARGETS_PM}
SHARED
policy_manager.cpp
stm/stm.c
+ ../src/util.cpp
)
target_include_directories(${TARGETS_PM}
diff --git a/policy_manager/policy_manager.cpp b/policy_manager/policy_manager.cpp
index c7bb007..999bc87 100644
--- a/policy_manager/policy_manager.cpp
+++ b/policy_manager/policy_manager.cpp
@@ -22,7 +22,7 @@
#include <algorithm>
#include <json-c/json.h>
#include "policy_manager.hpp"
-#include "hmi-debug.h"
+#include "util.hpp"
extern "C"
{
@@ -68,19 +68,19 @@ int PolicyManager::initialize()
// Create convert map
for (int i = StmEvtNoMin; i <= StmEvtNoMax; i++)
{
- HMI_DEBUG("wm:pm", "event name:%s no:%d", kStmEventName[i], i);
+ HMI_DEBUG("event name:%s no:%d", kStmEventName[i], i);
this->eventname2no[kStmEventName[i]] = i;
}
for (int i = StmCtgNoMin; i <= StmCtgNoMax; i++)
{
- HMI_DEBUG("wm:pm", "category name:%s no:%d", kStmCategoryName[i], i);
+ HMI_DEBUG("category name:%s no:%d", kStmCategoryName[i], i);
this->categoryname2no[kStmCategoryName[i]] = i;
}
for (int i = StmAreaNoMin; i <= StmAreaNoMax; i++)
{
- HMI_DEBUG("wm:pm", "area name:%s no:%d", kStmAreaName[i], i);
+ HMI_DEBUG("area name:%s no:%d", kStmAreaName[i], i);
this->areaname2no[kStmAreaName[i]] = i;
}
@@ -88,7 +88,7 @@ int PolicyManager::initialize()
ret = this->loadRoleDb();
if (0 > ret)
{
- HMI_ERROR("wm:pm", "Load roles.db Error!!");
+ HMI_ERROR("Load roles.db Error!!");
return ret;
}
@@ -96,7 +96,7 @@ int PolicyManager::initialize()
ret = this->loadStateDb();
if (0 > ret)
{
- HMI_ERROR("wm:pm", "Load states.db Error!!");
+ HMI_ERROR("Load states.db Error!!");
return ret;
}
@@ -123,7 +123,7 @@ int PolicyManager::setInputEventData(json_object *json_in)
// Check arguments
if (nullptr == json_in)
{
- HMI_ERROR("wm:pm", "Argument is NULL!!");
+ HMI_ERROR("Argument is NULL!!");
return -1;
}
@@ -137,17 +137,17 @@ int PolicyManager::setInputEventData(json_object *json_in)
if (this->eventname2no.end() != itr)
{
event_no = this->eventname2no[event];
- HMI_DEBUG("wm:pm", "event(%s:%d)", event, event_no);
+ HMI_DEBUG("event(%s:%d)", event, event_no);
}
else
{
- HMI_ERROR("wm:pm", "Invalid event name!!");
+ HMI_ERROR("Invalid event name!!");
return -1;
}
}
else
{
- HMI_ERROR("wm:pm", "Event is not set!!");
+ HMI_ERROR("Event is not set!!");
return -1;
}
@@ -157,7 +157,7 @@ int PolicyManager::setInputEventData(json_object *json_in)
int category_no = StmCtgNoNone;
if (nullptr != role)
{
- HMI_DEBUG("wm:pm", "role(%s)", role);
+ HMI_DEBUG("role(%s)", role);
// Convert role to category
auto itr = this->role2category.find(role);
@@ -170,7 +170,7 @@ int PolicyManager::setInputEventData(json_object *json_in)
itr = this->role2category.find("fallback");
if (this->role2category.end() != itr)
{
- HMI_DEBUG("wm:pm", "Role:%s is not registered in roles.db, fallback as normal app", role);
+ HMI_DEBUG("Role:%s is not registered in roles.db, fallback as normal app", role);
category = this->role2category["fallback"];
}
}
@@ -179,7 +179,7 @@ int PolicyManager::setInputEventData(json_object *json_in)
{
// Convert name to number
category_no = categoryname2no[category];
- HMI_DEBUG("wm:pm", "category(%s:%d)", category.c_str(), category_no);
+ HMI_DEBUG("category(%s:%d)", category.c_str(), category_no);
}
}
if (StmCtgNoNone == category_no)
@@ -205,7 +205,7 @@ int PolicyManager::setInputEventData(json_object *json_in)
area = this->category2areas[category].front().c_str();
area_no = this->areaname2no[area];
}
- HMI_DEBUG("wm:pm", "area(%s:%d)", area, area_no);
+ HMI_DEBUG("area(%s:%d)", area, area_no);
}
// Set event info to the queue
@@ -237,17 +237,17 @@ int PolicyManager::executeStateTransition()
void PolicyManager::undoState()
{
- HMI_DEBUG("wm:pm", "Undo State !!!");
+ HMI_DEBUG("Undo State !!!");
// Undo state of STM
stmUndoState();
- HMI_DEBUG("wm:pm", ">>>>>>>>>> BEFORE UNDO");
+ HMI_DEBUG(">>>>>>>>>> BEFORE UNDO");
this->dumpLayerState(this->crr_layers);
this->crr_layers = this->prv_layers;
- HMI_DEBUG("wm:pm", ">>>>>>>>>> AFTER UNDO");
+ HMI_DEBUG(">>>>>>>>>> AFTER UNDO");
this->dumpLayerState(this->crr_layers);
}
@@ -282,7 +282,7 @@ void PolicyManager::addStateToJson(const char *name, bool changed,
{
if ((nullptr == name) || (nullptr == json_out))
{
- HMI_ERROR("wm:pm", "Invalid argument!!!");
+ HMI_ERROR("Invalid argument!!!");
return;
}
@@ -296,7 +296,7 @@ void PolicyManager::addStateToJson(const char *layer_name, bool changed,
{
if ((nullptr == layer_name) || (nullptr == json_out))
{
- HMI_ERROR("wm:pm", "Invalid argument!!!");
+ HMI_ERROR("Invalid argument!!!");
return;
}
@@ -325,7 +325,7 @@ void PolicyManager::updateLayer(int event_id, StmState crr_state)
for (int layer_no = StmLayerNoMin;
layer_no <= StmLayerNoMax; layer_no++)
{
- HMI_DEBUG("wm:pm", ">>> LAYER:%s CHANGED:%d LAYOUT:%s",
+ HMI_DEBUG(">>> LAYER:%s CHANGED:%d LAYOUT:%s",
kStmLayerName[layer_no], crr_state.layer[layer_no].changed,
kStmLayoutName[crr_state.layer[layer_no].state]);
}
@@ -343,7 +343,7 @@ void PolicyManager::updateLayer(int event_id, StmState crr_state)
int changed = crr_state.layer[layer_no].changed;
if (changed)
{
- HMI_DEBUG("wm:pm", ">>>>>>>>>> Update layout of layer:%s", layer_name);
+ HMI_DEBUG(">>>>>>>>>> Update layout of layer:%s", layer_name);
// Get current layout name of this layer
int crr_layout_state_no = crr_state.layer[layer_no].state;
@@ -363,10 +363,10 @@ void PolicyManager::updateLayer(int event_id, StmState crr_state)
// Erase role for the event_id from list
this->req_role_list.erase(event_id);
- HMI_DEBUG("wm:pm", ">>>>>>>>>> DUMP LAYERS (BEFORE)");
+ HMI_DEBUG(">>>>>>>>>> DUMP LAYERS (BEFORE)");
this->dumpLayerState(this->prv_layers);
- HMI_DEBUG("wm:pm", ">>>>>>>>>> DUMP LAYERS (AFTER)");
+ HMI_DEBUG(">>>>>>>>>> DUMP LAYERS (AFTER)");
this->dumpLayerState(this->crr_layers);
this->dumpInvisibleRoleHistory();
@@ -405,17 +405,17 @@ int PolicyManager::updateLayout(int event_id, int layer_no,
crr_layout_state = prv_layout_state;
changed = 1;
- HMI_DEBUG("wm:pm", "-- layout name previous:%s current:%s",
+ HMI_DEBUG("-- layout name previous:%s current:%s",
prv_layout_name.c_str(), crr_layout_name.c_str());
if (prv_layout_name == crr_layout_name)
{
- HMI_DEBUG("wm:pm", "---- Previous layout is same with current");
+ HMI_DEBUG("---- Previous layout is same with current");
}
else
{
// If previous layout is NOT same with current,
// current areas is set with default value
- HMI_DEBUG("wm:pm", "---- Previous layout is NOT same with current");
+ HMI_DEBUG("---- Previous layout is NOT same with current");
crr_layout_state.name = this->default_layouts[crr_layout_name].name;
crr_layout_state.category_num = this->default_layouts[crr_layout_name].category_num;
crr_layout_state.area_list = this->default_layouts[crr_layout_name].area_list;
@@ -434,7 +434,7 @@ int PolicyManager::updateLayout(int event_id, int layer_no,
// }
// const char *ctg = kStmCategoryName[ctg_no];
- HMI_DEBUG("wm:pm", "-- Create candidate list for ctg:%s", ctg.c_str());
+ HMI_DEBUG("-- Create candidate list for ctg:%s", ctg.c_str());
AreaList tmp_cand_list;
int candidate_num = 0;
@@ -447,7 +447,7 @@ int PolicyManager::updateLayout(int event_id, int layer_no,
std::string used_role = "";
if ((ctg == req_ctg) && ("activate" == req_evt))
{
- HMI_DEBUG("wm:pm", "---- Requested event is activate");
+ HMI_DEBUG("---- Requested event is activate");
for (AreaState &as : crr_layout_state.area_list)
{
if (as.category == req_ctg)
@@ -459,7 +459,7 @@ int PolicyManager::updateLayout(int event_id, int layer_no,
as.role = req_role;
used_role = req_role;
blank_num--;
- HMI_DEBUG("wm:pm", "------ Update current layout: area:%s category:%s role:%s",
+ HMI_DEBUG("------ Update current layout: area:%s category:%s role:%s",
as.name.c_str(), as.category.c_str(), as.role.c_str());
break;
}
@@ -476,7 +476,7 @@ int PolicyManager::updateLayout(int event_id, int layer_no,
// If there is the category
// which is same with new category and not used for updating yet,
// push it to list
- HMI_DEBUG("wm:pm", "---- Push previous(category:%s role:%s) to candidate list",
+ HMI_DEBUG("---- Push previous(category:%s role:%s) to candidate list",
area_state.category.c_str(), area_state.role.c_str());
tmp_cand_list.push_back(area_state);
candidate_num++;
@@ -488,7 +488,7 @@ int PolicyManager::updateLayout(int event_id, int layer_no,
// so push requested role to candidate list
if (request_for_this_layer && ("" == used_role))
{
- HMI_DEBUG("wm:pm", "---- Push request(area:%s category:%s role:%s) to candidate list",
+ HMI_DEBUG("---- Push request(area:%s category:%s role:%s) to candidate list",
req_area.c_str(), req_ctg.c_str(), req_role.c_str());
AreaState area_state;
area_state.name = req_area;
@@ -498,7 +498,7 @@ int PolicyManager::updateLayout(int event_id, int layer_no,
candidate_num++;
}
- HMI_DEBUG("wm:pm", "---- blank_num:%d candidate_num:%d", blank_num, candidate_num);
+ HMI_DEBUG("---- blank_num:%d candidate_num:%d", blank_num, candidate_num);
// Compare number of candidate/blank,
// And remove role in order of the oldest as necessary
@@ -514,10 +514,10 @@ int PolicyManager::updateLayout(int event_id, int layer_no,
area_state.role = this->popInvisibleRoleHistory(ctg);
if ("" == area_state.role)
{
- HMI_ERROR("wm:pm", "There is no role in history stack!!");
+ HMI_ERROR("There is no role in history stack!!");
}
tmp_cand_list.push_back(area_state);
- HMI_DEBUG("wm:pm", "------ Add role:%s to candidate list",
+ HMI_DEBUG("------ Add role:%s to candidate list",
area_state.role.c_str());
candidate_num++;
}
@@ -528,7 +528,7 @@ int PolicyManager::updateLayout(int event_id, int layer_no,
while (candidate_num != blank_num)
{
std::string removed_role = tmp_cand_list.begin()->role;
- HMI_DEBUG("wm:pm", "------ Remove the oldest role:%s from candidate list",
+ HMI_DEBUG("------ Remove the oldest role:%s from candidate list",
removed_role.c_str());
tmp_cand_list.erase(tmp_cand_list.begin());
candidate_num--;
@@ -555,14 +555,14 @@ int PolicyManager::updateLayout(int event_id, int layer_no,
}
// Update areas
- HMI_DEBUG("wm:pm", "-- Update areas by using candidate list");
+ HMI_DEBUG("-- Update areas by using candidate list");
for (AreaState &as : crr_layout_state.area_list)
{
- HMI_DEBUG("wm:pm", "---- Check area:%s category:%s role:%s",
+ HMI_DEBUG("---- Check area:%s category:%s role:%s",
as.name.c_str(), as.category.c_str(), as.role.c_str());
if ("" == as.role)
{
- HMI_DEBUG("wm:pm", "------ Update this area with role:%s",
+ HMI_DEBUG("------ Update this area with role:%s",
cand_list[as.category].begin()->role.c_str());
as.role = cand_list[as.category].begin()->role;
cand_list[as.category].erase(cand_list[as.category].begin());
@@ -610,7 +610,7 @@ void PolicyManager::createOutputInformation(StmState crr_state, json_object **js
int PolicyManager::transitionState(sd_event_source *source, void *data)
{
- HMI_DEBUG("wm:pm", ">>>>>>>>>> START STATE TRANSITION");
+ HMI_DEBUG(">>>>>>>>>> START STATE TRANSITION");
int event_id = *((int *)data);
@@ -618,7 +618,7 @@ int PolicyManager::transitionState(sd_event_source *source, void *data)
event_no = STM_GET_EVENT_FROM_ID(event_id);
category_no = STM_GET_CATEGORY_FROM_ID(event_id);
area_no = STM_GET_AREA_FROM_ID(event_id);
- HMI_DEBUG("wm:pm", ">>>>>>>>>> EVENT:%s CATEGORY:%s AREA:%s",
+ HMI_DEBUG(">>>>>>>>>> EVENT:%s CATEGORY:%s AREA:%s",
kStmEventName[event_no],
kStmCategoryName[category_no],
kStmAreaName[area_no]);
@@ -628,7 +628,7 @@ int PolicyManager::transitionState(sd_event_source *source, void *data)
int ret = stmTransitionState(event_id, &crr_state);
if (0 > ret)
{
- HMI_ERROR("wm:pm", "Failed transition state");
+ HMI_ERROR("Failed transition state");
if (nullptr != this->callback.onError)
{
json_object *json_out = json_object_new_object();
@@ -674,13 +674,13 @@ int PolicyManager::transitionState(sd_event_source *source, void *data)
this->event_source_list.erase(event_id);
}
- HMI_DEBUG("wm:pm", ">>>>>>>>>> FINISH STATE TRANSITION");
+ HMI_DEBUG(">>>>>>>>>> FINISH STATE TRANSITION");
return 0;
}
int PolicyManager::timerEvent(sd_event_source *source, uint64_t usec, void *data)
{
- HMI_DEBUG("wm:pm", "Call");
+ HMI_DEBUG("Call");
int ret = this->transitionState(source, data);
return ret;
@@ -733,11 +733,11 @@ int PolicyManager::loadRoleDb()
// Get afm application installed dir
char const *afm_app_install_dir = getenv("AFM_APP_INSTALL_DIR");
- HMI_DEBUG("wm:pm", "afm_app_install_dir:%s", afm_app_install_dir);
+ HMI_DEBUG("afm_app_install_dir:%s", afm_app_install_dir);
if (!afm_app_install_dir)
{
- HMI_ERROR("wm:pm", "AFM_APP_INSTALL_DIR is not defined");
+ HMI_ERROR("AFM_APP_INSTALL_DIR is not defined");
}
else
{
@@ -749,21 +749,21 @@ int PolicyManager::loadRoleDb()
int ret = this->inputJsonFilie(file_name.c_str(), &json_obj);
if (0 > ret)
{
- HMI_ERROR("wm:pm", "Could not open roles.db, so use default role information");
+ HMI_ERROR("Could not open roles.db, so use default role information");
json_obj = json_tokener_parse(kDefaultRoleDb);
}
- HMI_DEBUG("wm:pm", "json_obj dump:%s", json_object_get_string(json_obj));
+ HMI_DEBUG("json_obj dump:%s", json_object_get_string(json_obj));
json_object *json_roles;
if (!json_object_object_get_ex(json_obj, "roles", &json_roles))
{
- HMI_ERROR("wm:pm", "Parse Error!!");
+ HMI_ERROR("Parse Error!!");
return -1;
}
int len = json_object_array_length(json_roles);
- HMI_DEBUG("wm:pm", "json_cfg len:%d", len);
- HMI_DEBUG("wm:pm", "json_cfg dump:%s", json_object_get_string(json_roles));
+ HMI_DEBUG("json_cfg len:%d", len);
+ HMI_DEBUG("json_cfg dump:%s", json_object_get_string(json_roles));
json_object *json_tmp;
const char *category;
@@ -782,7 +782,7 @@ int PolicyManager::loadRoleDb()
if ((nullptr == category) || (nullptr == roles) ||
(nullptr == areas) || (nullptr == layer))
{
- HMI_ERROR("wm:pm", "Parse Error!!");
+ HMI_ERROR("Parse Error!!");
return -1;
}
@@ -805,24 +805,24 @@ int PolicyManager::loadRoleDb()
}
// Check
- HMI_DEBUG("wm:pm", "Check role2category");
+ HMI_DEBUG("Check role2category");
for (const auto &x : this->role2category)
{
- HMI_DEBUG("wm:pm", "key:%s, val:%s", x.first.c_str(), x.second.c_str());
+ HMI_DEBUG("key:%s, val:%s", x.first.c_str(), x.second.c_str());
}
- HMI_DEBUG("wm:pm", "Check category2role");
+ HMI_DEBUG("Check category2role");
for (const auto &x : this->category2role)
{
- HMI_DEBUG("wm:pm", "key:%s, val:%s", x.first.c_str(), x.second.c_str());
+ HMI_DEBUG("key:%s, val:%s", x.first.c_str(), x.second.c_str());
}
- HMI_DEBUG("wm:pm", "Check category2areas");
+ HMI_DEBUG("Check category2areas");
for (const auto &x : this->category2areas)
{
for (const auto &y : x.second)
{
- HMI_DEBUG("wm:pm", "key:%s, val:%s", x.first.c_str(), y.c_str());
+ HMI_DEBUG("key:%s, val:%s", x.first.c_str(), y.c_str());
}
}
return 0;
@@ -830,16 +830,16 @@ int PolicyManager::loadRoleDb()
int PolicyManager::loadStateDb()
{
- HMI_DEBUG("wm:pm", "Call");
+ HMI_DEBUG("Call");
// Get afm application installed dir
char const *afm_app_install_dir = getenv("AFM_APP_INSTALL_DIR");
- HMI_DEBUG("wm:pm", "afm_app_install_dir:%s", afm_app_install_dir);
+ HMI_DEBUG("afm_app_install_dir:%s", afm_app_install_dir);
std::string file_name;
if (!afm_app_install_dir)
{
- HMI_ERROR("wm:pm", "AFM_APP_INSTALL_DIR is not defined");
+ HMI_ERROR("AFM_APP_INSTALL_DIR is not defined");
}
else
{
@@ -851,23 +851,23 @@ int PolicyManager::loadStateDb()
int ret = this->inputJsonFilie(file_name.c_str(), &json_obj);
if (0 > ret)
{
- HMI_DEBUG("wm:pm", "Could not open states.db, so use default layout information");
+ HMI_DEBUG("Could not open states.db, so use default layout information");
json_obj = json_tokener_parse(kDefaultStateDb);
}
- HMI_DEBUG("wm:pm", "json_obj dump:%s", json_object_get_string(json_obj));
+ HMI_DEBUG("json_obj dump:%s", json_object_get_string(json_obj));
// Perse states
- HMI_DEBUG("wm:pm", "Perse states");
+ HMI_DEBUG("Perse states");
json_object *json_cfg;
if (!json_object_object_get_ex(json_obj, "states", &json_cfg))
{
- HMI_ERROR("wm:pm", "Parse Error!!");
+ HMI_ERROR("Parse Error!!");
return -1;
}
int len = json_object_array_length(json_cfg);
- HMI_DEBUG("wm:pm", "json_cfg len:%d", len);
- HMI_DEBUG("wm:pm", "json_cfg dump:%s", json_object_get_string(json_cfg));
+ HMI_DEBUG("json_cfg len:%d", len);
+ HMI_DEBUG("json_cfg dump:%s", json_object_get_string(json_cfg));
const char *layout;
const char *role;
@@ -879,21 +879,21 @@ int PolicyManager::loadStateDb()
layout = this->getStringFromJson(json_tmp, "name");
if (nullptr == layout)
{
- HMI_ERROR("wm:pm", "Parse Error!!");
+ HMI_ERROR("Parse Error!!");
return -1;
}
- HMI_DEBUG("wm:pm", "> layout:%s", layout);
+ HMI_DEBUG("> layout:%s", layout);
json_object *json_area_array;
if (!json_object_object_get_ex(json_tmp, "areas", &json_area_array))
{
- HMI_ERROR("wm:pm", "Parse Error!!");
+ HMI_ERROR("Parse Error!!");
return -1;
}
int len_area = json_object_array_length(json_area_array);
- HMI_DEBUG("wm:pm", "json_area_array len:%d", len_area);
- HMI_DEBUG("wm:pm", "json_area_array dump:%s", json_object_get_string(json_area_array));
+ HMI_DEBUG("json_area_array len:%d", len_area);
+ HMI_DEBUG("json_area_array dump:%s", json_object_get_string(json_area_array));
LayoutState layout_state;
AreaState area_state;
@@ -913,22 +913,22 @@ int PolicyManager::loadStateDb()
const char *area = this->getStringFromJson(json_area, "name");
if (nullptr == area)
{
- HMI_ERROR("wm:pm", "Parse Error!!");
+ HMI_ERROR("Parse Error!!");
return -1;
}
area_state.name = std::string(area);
- HMI_DEBUG("wm:pm", ">> area:%s", area);
+ HMI_DEBUG(">> area:%s", area);
// Get app attribute of the area
category = this->getStringFromJson(json_area, "category");
if (nullptr == category)
{
- HMI_ERROR("wm:pm", "Parse Error!!");
+ HMI_ERROR("Parse Error!!");
return -1;
}
area_state.category = std::string(category);
category_num[category]++;
- HMI_DEBUG("wm:pm", ">>> category:%s", category);
+ HMI_DEBUG(">>> category:%s", category);
role = this->getStringFromJson(json_area, "role");
if (nullptr != role)
@@ -940,7 +940,7 @@ int PolicyManager::loadStateDb()
{
area_state.role = std::string("");
}
- HMI_DEBUG("wm:pm", ">>> role:%s", role);
+ HMI_DEBUG(">>> role:%s", role);
layout_state.area_list.push_back(area_state);
}
@@ -960,14 +960,14 @@ int PolicyManager::loadStateDb()
for (auto itr_layout = this->default_layouts.begin();
itr_layout != this->default_layouts.end(); ++itr_layout)
{
- HMI_DEBUG("wm:pm", ">>> layout:%s", itr_layout->first.c_str());
+ HMI_DEBUG(">>> layout:%s", itr_layout->first.c_str());
for (auto itr_area = itr_layout->second.area_list.begin();
itr_area != itr_layout->second.area_list.end(); ++itr_area)
{
- HMI_DEBUG("wm:pm", ">>> >>> area :%s", itr_area->name.c_str());
- HMI_DEBUG("wm:pm", ">>> >>> category:%s", itr_area->category.c_str());
- HMI_DEBUG("wm:pm", ">>> >>> role :%s", itr_area->role.c_str());
+ HMI_DEBUG(">>> >>> area :%s", itr_area->name.c_str());
+ HMI_DEBUG(">>> >>> category:%s", itr_area->category.c_str());
+ HMI_DEBUG(">>> >>> role :%s", itr_area->role.c_str());
}
}
@@ -1017,7 +1017,7 @@ const char *PolicyManager::getStringFromJson(json_object *obj, const char *key)
json_object *tmp;
if (!json_object_object_get_ex(obj, key, &tmp))
{
- HMI_DEBUG("wm:pm", "Not found key \"%s\"", key);
+ HMI_DEBUG("Not found key \"%s\"", key);
return nullptr;
}
@@ -1029,13 +1029,13 @@ int PolicyManager::inputJsonFilie(const char *file, json_object **obj)
const int input_size = 128;
int ret = -1;
- HMI_DEBUG("wm:pm", "Input file: %s", file);
+ HMI_DEBUG("Input file: %s", file);
// Open json file
FILE *fp = fopen(file, "rb");
if (nullptr == fp)
{
- HMI_ERROR("wm:pm", "Could not open file");
+ HMI_ERROR("Could not open file");
return ret;
}
@@ -1050,7 +1050,7 @@ int PolicyManager::inputJsonFilie(const char *file, json_object **obj)
*obj = json_tokener_parse_ex(tokener, buffer, len);
if (nullptr != *obj)
{
- HMI_DEBUG("wm:pm", "File input is success");
+ HMI_DEBUG("File input is success");
ret = 0;
break;
}
@@ -1058,9 +1058,9 @@ int PolicyManager::inputJsonFilie(const char *file, json_object **obj)
json_error = json_tokener_get_error(tokener);
if ((json_tokener_continue != json_error) || (input_size > len))
{
- HMI_ERROR("wm:pm", "Failed to parse file (byte:%d err:%s)",
+ HMI_ERROR("Failed to parse file (byte:%d err:%s)",
(input_size * block_cnt), json_tokener_error_desc(json_error));
- HMI_ERROR("wm:pm", "\n%s", buffer);
+ HMI_ERROR("\n%s", buffer);
*obj = nullptr;
break;
}
@@ -1078,8 +1078,8 @@ int PolicyManager::inputJsonFilie(const char *file, json_object **obj)
void PolicyManager::dumpLayerState(std::unordered_map<std::string, LayerState> &layers)
{
- HMI_DEBUG("wm:pm", "-------------------------------------------------------------------------------------------------------");
- HMI_DEBUG("wm:pm", "|%-15s|%s|%-20s|%-20s|%-20s|%-20s|",
+ HMI_DEBUG("-------------------------------------------------------------------------------------------------------");
+ HMI_DEBUG("|%-15s|%s|%-20s|%-20s|%-20s|%-20s|",
"LAYER", "C", "LAYOUT", "AREA", "CATEGORY", "ROLE");
for (const auto &itr : layers)
{
@@ -1093,21 +1093,21 @@ void PolicyManager::dumpLayerState(std::unordered_map<std::string, LayerState> &
if (first)
{
first = false;
- HMI_DEBUG("wm:pm", "|%-15s|%1s|%-20s|%-20s|%-20s|%-20s|",
+ HMI_DEBUG("|%-15s|%1s|%-20s|%-20s|%-20s|%-20s|",
layer, changed, layout,
as.name.c_str(), as.category.c_str(), as.role.c_str());
}
else
- HMI_DEBUG("wm:pm", "|%-15s|%1s|%-20s|%-20s|%-20s|%-20s|",
+ HMI_DEBUG("|%-15s|%1s|%-20s|%-20s|%-20s|%-20s|",
"", "", "", as.name.c_str(), as.category.c_str(), as.role.c_str());
}
}
- HMI_DEBUG("wm:pm", "-------------------------------------------------------------------------------------------------------");
+ HMI_DEBUG("-------------------------------------------------------------------------------------------------------");
}
void PolicyManager::dumpInvisibleRoleHistory()
{
- HMI_DEBUG("wm:pm", ">>>>>>>>>> DUMP INVISIBLE ROLE HISTORY ( category [older > newer] )");
+ HMI_DEBUG(">>>>>>>>>> DUMP INVISIBLE ROLE HISTORY ( category [older > newer] )");
for (int ctg_no = StmCtgNoMin; ctg_no <= StmCtgNoMax; ctg_no++)
{
if (ctg_no == StmCtgNoNone)
@@ -1120,7 +1120,7 @@ void PolicyManager::dumpInvisibleRoleHistory()
str += (i + " > ");
str += "]";
- HMI_DEBUG("wm:pm", "%s", str.c_str());
+ HMI_DEBUG("%s", str.c_str());
}
}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 91908e8..223dd33 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -33,7 +33,7 @@ add_library(${TARGETS_WM} MODULE
${IVI_CON_PROTO}
json_helper.cpp
window_manager.cpp
- layers.cpp
+ wm_layer.cpp
wm_client.cpp
wm_error.cpp
applist.cpp
diff --git a/src/applist.cpp b/src/applist.cpp
index a5ae9f0..79df62c 100644
--- a/src/applist.cpp
+++ b/src/applist.cpp
@@ -16,7 +16,7 @@
#include <iostream>
#include <algorithm>
#include "applist.hpp"
-#include "../include/hmi-debug.h"
+#include "util.hpp"
using std::shared_ptr;
using std::string;
@@ -65,7 +65,7 @@ AppList::~AppList() {}
* @attention This function should be called once for the app
* Caller should take care not to be called more than once.
*/
-void AppList::addClient(const std::string &appid, unsigned layer, unsigned surface, const std::string &role)
+void AppList::addClient(const string &appid, unsigned layer, unsigned surface, const string &role)
{
std::lock_guard<std::mutex> lock(this->mtx);
shared_ptr<WMClient> client = std::make_shared<WMClient>(appid, layer, surface, role);
@@ -82,7 +82,7 @@ void AppList::removeClient(const string &appid)
{
std::lock_guard<std::mutex> lock(this->mtx);
this->app2client.erase(appid);
- HMI_INFO("wm", "Remove client %s", appid.c_str());
+ HMI_INFO("Remove client %s", appid.c_str());
}
/**
@@ -111,7 +111,7 @@ void AppList::removeSurface(unsigned surface){
{
ret = x.second->removeSurfaceIfExist(surface);
if(ret){
- HMI_DEBUG("wm", "remove surface %d from Client %s finish",
+ HMI_DEBUG("remove surface %d from Client %s finish",
surface, x.second->appID().c_str());
break;
}
@@ -351,7 +351,7 @@ WMError AppList::setAction(unsigned req_num, const struct WMAction &action)
* otherwise (visible is false) app should be invisible. Then enddraw_finished param is set to true.
* This function doesn't support actions for focus yet.
*/
-WMError AppList::setAction(unsigned req_num, const string &appid, const string &role, const string &area, TaskVisible visible)
+WMError AppList::setAction(unsigned req_num, shared_ptr<WMClient> client, const string &role, const string &area, TaskVisible visible)
{
std::lock_guard<std::mutex> lock(this->mtx);
WMError result = WMError::FAIL;
@@ -363,7 +363,7 @@ WMError AppList::setAction(unsigned req_num, const string &appid, const string &
}
// If visible task is not invisible, redraw is required -> true
bool edraw_f = (visible != TaskVisible::INVISIBLE) ? false : true;
- WMAction action{appid, role, area, visible, edraw_f};
+ WMAction action{req_num, client, role, area, visible, edraw_f};
x.sync_draw_req.push_back(action);
result = WMError::SUCCESS;
@@ -399,7 +399,7 @@ bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const st
{
for (auto &y : x.sync_draw_req)
{
- if (y.appid == appid && y.role == role)
+ if (y.client->appID() == appid && y.role == role)
{
HMI_SEQ_INFO(req_num, "Role %s finish redraw", y.role.c_str());
y.end_draw_finished = true;
@@ -514,7 +514,7 @@ void AppList::reqDump()
{
DUMP(
"Action : (APPID :%s, ROLE :%s, AREA :%s, VISIBLE : %s, END_DRAW_FINISHED: %d)",
- y.appid.c_str(),
+ y.client->appID().c_str(),
y.role.c_str(),
y.area.c_str(),
(y.visible == TaskVisible::INVISIBLE) ? "invisible" : "visible",
diff --git a/src/applist.hpp b/src/applist.hpp
index a794b53..54ccdd1 100644
--- a/src/applist.hpp
+++ b/src/applist.hpp
@@ -56,7 +56,7 @@ class AppList
unsigned getRequestNumber(const std::string &appid) const;
unsigned addRequest(WMRequest req);
WMError setAction(unsigned req_num, const struct WMAction &action);
- WMError setAction(unsigned req_num, const std::string &appid,
+ WMError setAction(unsigned req_num, std::shared_ptr<WMClient> client,
const std::string &role, const std::string &area, TaskVisible visible);
bool setEndDrawFinished(unsigned req_num, const std::string &appid, const std::string &role);
bool endDrawFullfilled(unsigned req_num);
diff --git a/src/json_helper.cpp b/src/json_helper.cpp
index b97f21d..cf13363 100644
--- a/src/json_helper.cpp
+++ b/src/json_helper.cpp
@@ -15,9 +15,7 @@
*/
#include "json_helper.hpp"
-#include "hmi-debug.h"
-
-#include <json.h>
+#include "util.hpp"
json_object *to_json(compositor::surface_properties const &s)
{
@@ -117,7 +115,7 @@ const char* getStringFromJson(json_object* obj, const char* key)
json_object* tmp;
if (!json_object_object_get_ex(obj, key, &tmp))
{
- HMI_DEBUG("wm:jh", "Not found key \"%s\"", key);
+ HMI_DEBUG("Not found key \"%s\"", key);
return nullptr;
}
@@ -129,7 +127,7 @@ int getIntFromJson(json_object *obj, const char *key)
json_object *tmp;
if (!json_object_object_get_ex(obj, key, &tmp))
{
- HMI_DEBUG("wm:jh", "Not found key \"%s\"", key);
+ HMI_DEBUG("Not found key \"%s\"", key);
return 0;
}
@@ -141,7 +139,7 @@ json_bool getBoolFromJson(json_object *obj, const char *key)
json_object *tmp;
if (!json_object_object_get_ex(obj, key, &tmp))
{
- HMI_DEBUG("wm:jh", "Not found key \"%s\"", key);
+ HMI_DEBUG("Not found key \"%s\"", key);
return FALSE;
}
@@ -153,13 +151,13 @@ int inputJsonFilie(const char* file, json_object** obj)
const int input_size = 128;
int ret = -1;
- HMI_DEBUG("wm:jh", "Input file: %s", file);
+ HMI_DEBUG("Input file: %s", file);
// Open json file
FILE *fp = fopen(file, "rb");
if (nullptr == fp)
{
- HMI_ERROR("wm:jh", "Could not open file");
+ HMI_ERROR("Could not open file");
return ret;
}
@@ -174,7 +172,7 @@ int inputJsonFilie(const char* file, json_object** obj)
*obj = json_tokener_parse_ex(tokener, buffer, len);
if (nullptr != *obj)
{
- HMI_DEBUG("wm:jh", "File input is success");
+ HMI_DEBUG("File input is success");
ret = 0;
break;
}
@@ -183,9 +181,9 @@ int inputJsonFilie(const char* file, json_object** obj)
if ((json_tokener_continue != json_error)
|| (input_size > len))
{
- HMI_ERROR("wm:jh", "Failed to parse file (byte:%d err:%s)",
+ HMI_ERROR("Failed to parse file (byte:%d err:%s)",
(input_size * block_cnt), json_tokener_error_desc(json_error));
- HMI_ERROR("wm:jh", "\n%s", buffer);
+ HMI_ERROR("\n%s", buffer);
*obj = nullptr;
break;
}
diff --git a/src/json_helper.hpp b/src/json_helper.hpp
index 5333130..2321f8b 100644
--- a/src/json_helper.hpp
+++ b/src/json_helper.hpp
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-#ifndef TMCAGLWM_JSON_HELPER_HPP
-#define TMCAGLWM_JSON_HELPER_HPP
+#ifndef JSON_HELPER_HPP
+#define JSON_HELPER_HPP
#include <json-c/json.h>
-#include "../include/json.hpp"
+#include <vector>
#include "wayland_ivi_wm.hpp"
struct json_object;
@@ -34,4 +34,4 @@ json_bool getBoolFromJson(json_object *obj, const char *key);
int inputJsonFilie(const char* file, json_object** obj);
} // namespace jh
-#endif // TMCAGLWM_JSON_HELPER_HPP
+#endif // JSON_HELPER_HPP
diff --git a/src/main.cpp b/src/main.cpp
index 0447f86..d9f0302 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -18,7 +18,6 @@
#include <algorithm>
#include <mutex>
#include <json.h>
-#include "../include/json.hpp"
#include "window_manager.hpp"
#include "json_helper.hpp"
#include "wayland_ivi_wm.hpp"
@@ -61,11 +60,9 @@ int afb_instance::init()
int display_event_callback(sd_event_source *evs, int /*fd*/, uint32_t events,
void * /*data*/)
{
- ST();
-
if ((events & EPOLLHUP) != 0)
{
- HMI_ERROR("wm", "The compositor hung up, dying now.");
+ HMI_ERROR("The compositor hung up, dying now.");
delete g_afb_instance;
g_afb_instance = nullptr;
goto error;
@@ -74,17 +71,14 @@ int display_event_callback(sd_event_source *evs, int /*fd*/, uint32_t events,
if ((events & EPOLLIN) != 0u)
{
{
- STN(display_read_events);
g_afb_instance->wmgr.display->read_events();
g_afb_instance->wmgr.set_pending_events();
}
{
// We want do dispatch pending wayland events from within
// the API context
- STN(winman_ping_api_call);
afb_service_call("windowmanager", "ping", json_object_new_object(),
[](void *c, int st, json_object *j) {
- STN(winman_ping_api_call_return);
},
nullptr);
}
@@ -103,17 +97,17 @@ error:
int _binding_init()
{
- HMI_NOTICE("wm", "WinMan ver. %s", WINMAN_VERSION_STRING);
+ HMI_NOTICE("WinMan ver. %s", WINMAN_VERSION_STRING);
if (g_afb_instance != nullptr)
{
- HMI_ERROR("wm", "Wayland context already initialized?");
+ HMI_ERROR("Wayland context already initialized?");
return 0;
}
if (getenv("XDG_RUNTIME_DIR") == nullptr)
{
- HMI_ERROR("wm", "Environment variable XDG_RUNTIME_DIR not set");
+ HMI_ERROR("Environment variable XDG_RUNTIME_DIR not set");
goto error;
}
@@ -126,10 +120,10 @@ int _binding_init()
cnt++;
if (20 <= cnt)
{
- HMI_ERROR("wm", "Could not connect to compositor");
+ HMI_ERROR("Could not connect to compositor");
goto error;
}
- HMI_ERROR("wm", "Wait to start weston ...");
+ HMI_ERROR("Wait to start weston ...");
sleep(1);
delete g_afb_instance;
g_afb_instance = new afb_instance;
@@ -138,7 +132,7 @@ int _binding_init()
if (g_afb_instance->init() == -1)
{
- HMI_ERROR("wm", "Could not connect to compositor");
+ HMI_ERROR("Could not connect to compositor");
goto error;
}
@@ -148,7 +142,7 @@ int _binding_init()
display_event_callback, g_afb_instance);
if (ret < 0)
{
- HMI_ERROR("wm", "Could not initialize afb_instance event handler: %d", -ret);
+ HMI_ERROR("Could not initialize afb_instance event handler: %d", -ret);
goto error;
}
}
@@ -171,7 +165,7 @@ int binding_init() noexcept
}
catch (std::exception &e)
{
- HMI_ERROR("wm", "Uncaught exception in binding_init(): %s", e.what());
+ HMI_ERROR("Uncaught exception in binding_init(): %s", e.what());
}
return -1;
}
@@ -183,19 +177,13 @@ static void cbRemoveClientCtxt(void *data)
{
return;
}
- HMI_DEBUG("wm", "remove app %s", ctxt->name.c_str());
+ HMI_DEBUG("remove app %s", ctxt->name.c_str());
// Policy Manager does not know this app was killed,
// so notify it by deactivate request.
g_afb_instance->wmgr.api_deactivate_surface(
ctxt->name.c_str(), ctxt->role.c_str(),
- [](const char *errmsg) {
- if (errmsg != nullptr)
- {
- HMI_ERROR("wm", errmsg);
- return;
- }
- });
+ [](const char *) {});
g_afb_instance->wmgr.removeClient(ctxt->name);
delete ctxt;
@@ -209,7 +197,7 @@ static void createSecurityContext(afb_req req, const char* appid, const char* ro
// Create Security Context at first time
const char *new_role = g_afb_instance->wmgr.convertRoleOldToNew(role);
WMClientCtxt *ctxt = new WMClientCtxt(appid, new_role);
- HMI_DEBUG("wm", "create session for %s", ctxt->name.c_str());
+ HMI_DEBUG("create session for %s", ctxt->name.c_str());
afb_req_session_set_LOA(req, 1);
afb_req_context_set(req, ctxt, cbRemoveClientCtxt);
}
@@ -218,9 +206,6 @@ static void createSecurityContext(afb_req req, const char* appid, const char* ro
void windowmanager_requestsurface(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
-#ifdef ST
- ST();
-#endif
if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
@@ -236,18 +221,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)
{
@@ -259,9 +252,6 @@ void windowmanager_requestsurface(afb_req req) noexcept
void windowmanager_requestsurfacexdg(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
-#ifdef ST
- ST();
-#endif
if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
@@ -287,19 +277,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;
- }
+ auto ret = g_afb_instance->wmgr.api_request_surface(
+ appid, a_drawing_name, a_ivi_id);
- createSecurityContext(req, appid, a_drawing_name);
-
- 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)
{
@@ -311,9 +305,6 @@ void windowmanager_requestsurfacexdg(afb_req req) noexcept
void windowmanager_activatewindow(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
-#ifdef ST
- ST();
-#endif
if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
@@ -336,22 +327,26 @@ 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(errmsg);
+ afb_req_fail(req, "failed", errmsg);
+ return;
+ }
+ afb_req_success(req, NULL, "success");
+ });
+ free(appid);
+ }
}
catch (std::exception &e)
{
- HMI_WARNING("wm", "failed: Uncaught exception while calling activatesurface: %s", e.what());
+ HMI_WARNING("failed: Uncaught exception while calling activatesurface: %s", e.what());
g_afb_instance->wmgr.exceptionProcessForTransition();
return;
}
@@ -360,9 +355,6 @@ void windowmanager_activatewindow(afb_req req) noexcept
void windowmanager_deactivatewindow(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
-#ifdef ST
- ST();
-#endif
if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
@@ -378,21 +370,26 @@ 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(errmsg);
+ afb_req_fail(req, "failed", errmsg);
+ return;
+ }
+ afb_req_success(req, NULL, "success");
+ });
+ free(appid);
+ }
}
catch (std::exception &e)
{
- HMI_WARNING("wm", "failed: Uncaught exception while calling deactivatesurface: %s", e.what());
+ HMI_WARNING("failed: Uncaught exception while calling deactivatesurface: %s", e.what());
g_afb_instance->wmgr.exceptionProcessForTransition();
return;
}
@@ -401,9 +398,6 @@ void windowmanager_deactivatewindow(afb_req req) noexcept
void windowmanager_enddraw(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
-#ifdef ST
- ST();
-#endif
if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
@@ -420,12 +414,16 @@ 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)
{
- HMI_WARNING("wm", "failed: Uncaught exception while calling enddraw: %s", e.what());
+ HMI_WARNING("failed: Uncaught exception while calling enddraw: %s", e.what());
g_afb_instance->wmgr.exceptionProcessForTransition();
return;
}
@@ -434,9 +432,6 @@ void windowmanager_enddraw(afb_req req) noexcept
void windowmanager_getdisplayinfo_thunk(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
-#ifdef ST
- ST();
-#endif
if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
@@ -464,9 +459,6 @@ void windowmanager_getdisplayinfo_thunk(afb_req req) noexcept
void windowmanager_getareainfo_thunk(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
-#ifdef ST
- ST();
-#endif
if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
@@ -504,9 +496,6 @@ void windowmanager_getareainfo_thunk(afb_req req) noexcept
void windowmanager_wm_subscribe(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
-#ifdef ST
- ST();
-#endif
if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
@@ -543,9 +532,6 @@ void windowmanager_wm_subscribe(afb_req req) noexcept
void windowmanager_list_drawing_names(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
-#ifdef ST
- ST();
-#endif
if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
@@ -575,9 +561,6 @@ void windowmanager_list_drawing_names(afb_req req) noexcept
void windowmanager_ping(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
-#ifdef ST
- ST();
-#endif
if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
@@ -601,9 +584,6 @@ void windowmanager_ping(afb_req req) noexcept
void windowmanager_debug_status(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
-#ifdef ST
- ST();
-#endif
if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
@@ -630,9 +610,6 @@ void windowmanager_debug_status(afb_req req) noexcept
void windowmanager_debug_layers(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
-#ifdef ST
- ST();
-#endif
if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
@@ -655,9 +632,6 @@ void windowmanager_debug_layers(afb_req req) noexcept
void windowmanager_debug_surfaces(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
-#ifdef ST
- ST();
-#endif
if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
@@ -686,9 +660,6 @@ void windowmanager_debug_surfaces(afb_req req) noexcept
void windowmanager_debug_terminate(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
-#ifdef ST
- ST();
-#endif
if (g_afb_instance == nullptr)
{
afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
@@ -714,13 +685,13 @@ 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},
+ {"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},
{"list_drawing_names", windowmanager_list_drawing_names, nullptr, nullptr, AFB_SESSION_NONE},
{"ping", windowmanager_ping, nullptr, nullptr, AFB_SESSION_NONE},
diff --git a/src/pm_wrapper.cpp b/src/pm_wrapper.cpp
index 1454bf9..8706128 100644
--- a/src/pm_wrapper.cpp
+++ b/src/pm_wrapper.cpp
@@ -16,7 +16,7 @@
#include "pm_wrapper.hpp"
#include "json_helper.hpp"
-#include "hmi-debug.h"
+#include "util.hpp"
namespace wm
{
@@ -33,7 +33,7 @@ static void onStateTransitioned(json_object *json_out)
static void onError(json_object *json_out)
{
- HMI_DEBUG("wm", "error message from PolicyManager:%s",
+ HMI_DEBUG("error message from PolicyManager:%s",
json_object_get_string(json_out));
g_context->processError();
@@ -50,7 +50,7 @@ int PMWrapper::initialize()
ret = this->pm.initialize();
if (0 > ret)
{
- HMI_ERROR("wm:pmw", "Faild to initialize PolicyManager");
+ HMI_ERROR("Faild to initialize PolicyManager");
}
g_context = this;
@@ -95,7 +95,7 @@ int PMWrapper::setInputEventData(Task task, std::string role, std::string area)
ret = this->pm.setInputEventData(json_in);
if (0 > ret)
{
- HMI_ERROR("wm:pmw", "Faild to set input event data to PolicyManager");
+ HMI_ERROR("Faild to set input event data to PolicyManager");
}
json_object_put(json_in);
@@ -108,7 +108,7 @@ int PMWrapper::executeStateTransition()
ret = this->pm.executeStateTransition();
if (0 > ret)
{
- HMI_ERROR("wm:pmw", "Failed to execute state transition for PolicyManager");
+ HMI_ERROR("Failed to execute state transition for PolicyManager");
}
return ret;
@@ -125,7 +125,7 @@ void PMWrapper::updateStates(json_object *json_out)
{
std::vector<WMAction> actions;
- HMI_DEBUG("wm", "json_out dump:%s", json_object_get_string(json_out));
+ HMI_DEBUG("json_out dump:%s", json_object_get_string(json_out));
this->createLayoutChangeAction(json_out, actions);
@@ -138,12 +138,12 @@ void PMWrapper::createLayoutChangeAction(json_object *json_out, std::vector<WMAc
json_object *json_layers;
if (!json_object_object_get_ex(json_out, "layers", &json_layers))
{
- HMI_DEBUG("wm", "Not found key \"layers\"");
+ HMI_DEBUG("Not found key \"layers\"");
return;
}
int len = json_object_array_length(json_layers);
- HMI_DEBUG("wm", "json_layers len:%d", len);
+ HMI_DEBUG("json_layers len:%d", len);
for (int i = 0; i < len; i++)
{
@@ -151,19 +151,19 @@ void PMWrapper::createLayoutChangeAction(json_object *json_out, std::vector<WMAc
std::string layer_name = jh::getStringFromJson(json_tmp, "name");
json_bool changed = jh::getBoolFromJson(json_tmp, "changed");
- HMI_DEBUG("wm", "layer:%s changed:%d", layer_name.c_str(), changed);
+ HMI_DEBUG("layer:%s changed:%d", layer_name.c_str(), changed);
if (changed)
{
json_object *json_areas;
if (!json_object_object_get_ex(json_tmp, "areas", &json_areas))
{
- HMI_DEBUG("wm", "Not found key \"areas\"");
+ HMI_DEBUG("Not found key \"areas\"");
return;
}
int len = json_object_array_length(json_areas);
- HMI_DEBUG("wm", "json_layers len:%d", len);
+ HMI_DEBUG("json_layers len:%d", len);
// Store previous role state in this layer
this->prvlayer2rolestate[layer_name] = this->crrlayer2rolestate[layer_name];
@@ -180,19 +180,20 @@ void PMWrapper::createLayoutChangeAction(json_object *json_out, std::vector<WMAc
crr_roles[role_name] = area_name;
auto i_prv = prv_roles.find(role_name);
- HMI_DEBUG("wm", "current role:%s area:%s",
+ HMI_DEBUG("current role:%s area:%s",
role_name.c_str(), area_name.c_str());
// If current role does not exist in previous
if (prv_roles.end() == i_prv)
{
- HMI_DEBUG("wm", "current role does not exist in previous");
+ HMI_DEBUG("current role does not exist in previous");
// Set activate action
bool end_draw_finished = false;
WMAction act
{
- "",
+ 0,
+ nullptr,
role_name,
area_name,
TaskVisible::VISIBLE,
@@ -202,19 +203,20 @@ void PMWrapper::createLayoutChangeAction(json_object *json_out, std::vector<WMAc
}
else
{
- HMI_DEBUG("wm", "previous role:%s area:%s",
+ HMI_DEBUG("previous role:%s area:%s",
i_prv->first.c_str(), i_prv->second.c_str());
// If current role exists in previous and area is different with previous
if (area_name != i_prv->second)
{
- HMI_DEBUG("wm", "current role exists in previous and area is different with previous");
+ HMI_DEBUG("current role exists in previous and area is different with previous");
// Set activate action
bool end_draw_finished = false;
WMAction act
{
- "",
+ 0,
+ nullptr,
role_name,
area_name,
TaskVisible::VISIBLE,
@@ -232,13 +234,14 @@ void PMWrapper::createLayoutChangeAction(json_object *json_out, std::vector<WMAc
// because these are not displayed in current layout
for (auto i_prv : prv_roles)
{
- HMI_DEBUG("wm", "Deactivate role:%s", i_prv.first.c_str());
+ HMI_DEBUG("Deactivate role:%s", i_prv.first.c_str());
// Set deactivate action
bool end_draw_finished = true;
WMAction act
{
- "",
+ 0,
+ nullptr,
i_prv.first,
"",
TaskVisible::INVISIBLE,
diff --git a/src/request.hpp b/src/request.hpp
index 6b2bda1..073dd27 100644
--- a/src/request.hpp
+++ b/src/request.hpp
@@ -19,10 +19,13 @@
#include <string>
#include <vector>
+#include <memory>
namespace wm
{
+class WMClient;
+
enum Task
{
TASK_ALLOCATE,
@@ -47,7 +50,8 @@ struct WMTrigger
struct WMAction
{
- std::string appid;
+ unsigned req_num;
+ std::shared_ptr<WMClient> client;
std::string role;
std::string area;
TaskVisible visible;
diff --git a/src/util.cpp b/src/util.cpp
index 672b089..37977f2 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -16,30 +16,14 @@
#include "util.hpp"
-#include <cerrno>
-#include <cstdarg>
-#include <cstdio>
-#include <cstdlib>
-#include <ctime>
+#include <time.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
#include <unistd.h>
-#ifdef SCOPE_TRACING
-thread_local int ScopeTrace::indent = 0;
-ScopeTrace::ScopeTrace(char const *func) : f(func)
-{
- fprintf(stderr, "%lu %*s%s -->\n", pthread_self(), 2 * indent++, "", this->f);
-}
-ScopeTrace::~ScopeTrace() { fprintf(stderr, "%lu %*s%s <--\n", pthread_self(), 2 * --indent, "", this->f); }
-#endif
-
-unique_fd::~unique_fd()
-{
- if (this->fd != -1)
- {
- close(this->fd);
- }
-}
+static char ERROR_FLAG[6][20] = {"NONE", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"};
void rectangle::fit(unsigned long to_width, unsigned long to_height)
{
@@ -93,3 +77,66 @@ void rectangle::set_aspect(double ratio)
}
}
+void _HMI_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, const char* prefix, const char* log, ...)
+{
+ const int log_level = (getenv("USE_HMI_DEBUG") == NULL)?LOG_LEVEL_ERROR:atoi(getenv("USE_HMI_DEBUG"));
+ if(log_level < level)
+ {
+ return;
+ }
+
+ char *message;
+ struct timespec tp;
+ unsigned int time;
+
+ clock_gettime(CLOCK_REALTIME, &tp);
+ time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
+
+ va_list args;
+ va_start(args, log);
+ if (log == NULL || vasprintf(&message, log, args) < 0)
+ message = NULL;
+ fprintf(stderr, "[%10.3f] [%s %s] [%s, %s(), Line:%d] >>> %s \n", time / 1000.0, prefix, ERROR_FLAG[level], file, func, line, message);
+ va_end(args);
+ free(message);
+}
+
+void _HMI_SEQ_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, unsigned seq_num, const char* log, ...){
+ const int log_level = (getenv("USE_HMI_DEBUG") == NULL) ? LOG_LEVEL_ERROR:atoi(getenv("USE_HMI_DEBUG"));
+ if(log_level < level)
+ {
+ return;
+ }
+
+ char *message;
+ struct timespec tp;
+ unsigned int time;
+
+ clock_gettime(CLOCK_REALTIME, &tp);
+ time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
+
+ va_list args;
+ va_start(args, log);
+ if (log == NULL || vasprintf(&message, log, args) < 0)
+ message = NULL;
+ fprintf(stderr, "[%10.3f] [wm %s] [%s, %s(), Line:%d] >>> req %d: %s \n", time / 1000.0, ERROR_FLAG[level], file, func, line, seq_num, message);
+ va_end(args);
+ free(message);
+}
+
+void _DUMP(enum LOG_LEVEL level, const char *log, ...)
+{
+ const int log_level = (getenv("USE_HMI_DEBUG") == NULL) ? LOG_LEVEL_ERROR : atoi(getenv("USE_HMI_DEBUG"));
+ if (log_level < level)
+ {
+ return;
+ }
+ char *message;
+ va_list args;
+ va_start(args, log);
+ if (log == NULL || vasprintf(&message, log, args) < 0)
+ message = NULL;
+ fprintf(stderr, "%s \n", message);
+ va_end(args);
+ free(message);
+} \ No newline at end of file
diff --git a/src/util.hpp b/src/util.hpp
index 2f17845..812a130 100644
--- a/src/util.hpp
+++ b/src/util.hpp
@@ -19,75 +19,38 @@
#include <functional>
#include <thread>
-#include <vector>
-
#include <sys/poll.h>
-
-#ifndef DO_NOT_USE_AFB
-extern "C"
-{
-#include <afb/afb-binding.h>
+#include <string.h>
+
+#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
+
+#define HMI_ERROR(args,...) _HMI_LOG(LOG_LEVEL_ERROR, __FILENAME__, __FUNCTION__, __LINE__,"wm",args, ##__VA_ARGS__)
+#define HMI_WARNING(args,...) _HMI_LOG(LOG_LEVEL_WARNING, __FILENAME__, __FUNCTION__,__LINE__, "wm", args,##__VA_ARGS__)
+#define HMI_NOTICE(args,...) _HMI_LOG(LOG_LEVEL_NOTICE, __FILENAME__, __FUNCTION__,__LINE__, "wm", args,##__VA_ARGS__)
+#define HMI_INFO(args,...) _HMI_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__,__LINE__, "wm", args,##__VA_ARGS__)
+#define HMI_DEBUG(args,...) _HMI_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__,__LINE__, "wm", args,##__VA_ARGS__)
+
+#define HMI_SEQ_ERROR(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_ERROR, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__)
+#define HMI_SEQ_WARNING(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_WARNING, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__)
+#define HMI_SEQ_NOTICE(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_NOTICE, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__)
+#define HMI_SEQ_INFO(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__)
+#define HMI_SEQ_DEBUG(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__)
+
+#define DUMP(args, ...) _DUMP(LOG_LEVEL_DEBUG, args, ##__VA_ARGS__)
+
+enum LOG_LEVEL{
+ LOG_LEVEL_NONE = 0,
+ LOG_LEVEL_ERROR,
+ LOG_LEVEL_WARNING,
+ LOG_LEVEL_NOTICE,
+ LOG_LEVEL_INFO,
+ LOG_LEVEL_DEBUG,
+ LOG_LEVEL_MAX = LOG_LEVEL_DEBUG
};
-#endif
-
-#define CONCAT_(X, Y) X##Y
-#define CONCAT(X, Y) CONCAT_(X, Y)
-
-#ifdef __GNUC__
-#define ATTR_FORMAT(stringindex, firsttocheck) \
- __attribute__((format(printf, stringindex, firsttocheck)))
-#define ATTR_NORETURN __attribute__((noreturn))
-#else
-#define ATTR_FORMAT(stringindex, firsttocheck)
-#define ATTR_NORETURN
-#endif
-
-#ifdef AFB_BINDING_VERSION
-#define lognotice(...) AFB_NOTICE(__VA_ARGS__)
-#define logerror(...) AFB_ERROR(__VA_ARGS__)
-#define fatal(...) \
- do \
- { \
- AFB_ERROR(__VA_ARGS__); \
- abort(); \
- } while (0)
-#else
-#define lognotice(...)
-#define logerror(...)
-#define fatal(...) \
- do \
- { \
- abort(); \
- } while (0)
-#endif
-
-#ifdef DEBUG_OUTPUT
-#ifdef AFB_BINDING_VERSION
-#define logdebug(...) AFB_DEBUG(__VA_ARGS__)
-#else
-#define logdebug(...)
-#endif
-#else
-#define logdebug(...)
-#endif
-
-#ifndef SCOPE_TRACING
-#define ST()
-#define STN(N)
-#else
-#define ST() \
- ScopeTrace __attribute__((unused)) CONCAT(trace_scope_, __LINE__)(__func__)
-#define STN(N) \
- ScopeTrace __attribute__((unused)) CONCAT(named_trace_scope_, __LINE__)(#N)
-
-struct ScopeTrace
-{
- thread_local static int indent;
- char const *f{};
- explicit ScopeTrace(char const *func);
- ~ScopeTrace();
-};
-#endif
+
+void _HMI_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, const char* prefix, const char* log, ...);
+void _HMI_SEQ_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, unsigned seq_num, const char* log, ...);
+void _DUMP(enum LOG_LEVEL level, const char *log, ...);
/**
* @struct unique_fd
diff --git a/src/wayland_ivi_wm.cpp b/src/wayland_ivi_wm.cpp
index 8b04c64..bbf745b 100644
--- a/src/wayland_ivi_wm.cpp
+++ b/src/wayland_ivi_wm.cpp
@@ -15,7 +15,6 @@
*/
#include "wayland_ivi_wm.hpp"
-#include "hmi-debug.h"
/**
* namespace wl
@@ -41,10 +40,8 @@ int display::dispatch_pending() { return wl_display_dispatch_pending(this->d.get
int display::read_events()
{
- ST();
while (wl_display_prepare_read(this->d.get()) == -1)
{
- STN(pending_events_dispatch);
if (wl_display_dispatch_pending(this->d.get()) == -1)
{
return -1;
@@ -112,7 +109,7 @@ void registry::global_created(uint32_t name, char const *iface, uint32_t v)
{
b->second(this->proxy.get(), name, v);
}
- HMI_DEBUG("wm", "wl::registry @ %p global n %u i %s v %u", this->proxy.get(), name,
+ HMI_DEBUG("wl::registry @ %p global n %u i %s v %u", this->proxy.get(), name,
iface, v);
}
@@ -163,8 +160,7 @@ void output::geometry(int32_t x, int32_t y, int32_t pw, int32_t ph,
int32_t subpel, char const *make, char const *model,
int32_t tx)
{
- HMI_DEBUG("wm",
- "wl::output %s @ %p x %i y %i w %i h %i spel %x make %s model %s tx %i",
+ HMI_DEBUG("wl::output %s @ %p x %i y %i w %i h %i spel %x make %s model %s tx %i",
__func__, this->proxy.get(), x, y, pw, ph, subpel, make, model, tx);
this->physical_width = pw;
this->physical_height = ph;
@@ -173,7 +169,7 @@ void output::geometry(int32_t x, int32_t y, int32_t pw, int32_t ph,
void output::mode(uint32_t flags, int32_t w, int32_t h, int32_t r)
{
- HMI_DEBUG("wm", "wl::output %s @ %p f %x w %i h %i r %i", __func__,
+ HMI_DEBUG("wl::output %s @ %p f %x w %i h %i r %i", __func__,
this->proxy.get(), flags, w, h, r);
if ((flags & WL_OUTPUT_MODE_CURRENT) != 0u)
{
@@ -185,7 +181,7 @@ void output::mode(uint32_t flags, int32_t w, int32_t h, int32_t r)
void output::done()
{
- HMI_DEBUG("wm", "wl::output %s @ %p done", __func__, this->proxy.get());
+ HMI_DEBUG("wl::output %s @ %p done", __func__, this->proxy.get());
// Pivot and flipped
if (this->transform == WL_OUTPUT_TRANSFORM_90 ||
this->transform == WL_OUTPUT_TRANSFORM_270 ||
@@ -199,7 +195,7 @@ void output::done()
void output::scale(int32_t factor)
{
- HMI_DEBUG("wm", "wl::output %s @ %p f %i", __func__, this->proxy.get(), factor);
+ HMI_DEBUG("wl::output %s @ %p f %i", __func__, this->proxy.get(), factor);
}
} // namespace wl
@@ -363,14 +359,14 @@ void layer_added(void *data,
struct ivi_wm_screen *ivi_wm_screen,
uint32_t layer_id)
{
- HMI_DEBUG("wm", "added layer_id:%d", layer_id);
+ HMI_DEBUG("added layer_id:%d", layer_id);
}
void connector_name(void *data,
struct ivi_wm_screen *ivi_wm_screen,
const char *process_name)
{
- HMI_DEBUG("wm", "process_name:%s", process_name);
+ HMI_DEBUG("process_name:%s", process_name);
}
void screen_error(void *data,
@@ -378,7 +374,7 @@ void screen_error(void *data,
uint32_t error,
const char *message)
{
- HMI_DEBUG("wm", "screen error:%d message:%s", error, message);
+ HMI_DEBUG("screen error:%d message:%s", error, message);
}
constexpr struct ivi_wm_screen_listener screen_listener = {
@@ -400,7 +396,7 @@ surface::surface(uint32_t i, struct controller *c)
void surface::set_visibility(uint32_t visibility)
{
- HMI_DEBUG("wm", "compositor::surface id:%d v:%d", this->id, visibility);
+ HMI_DEBUG("compositor::surface id:%d v:%d", this->id, visibility);
ivi_wm_set_surface_visibility(this->parent->proxy.get(), this->id, visibility);
}
@@ -459,7 +455,7 @@ screen::screen(uint32_t i, struct controller *c, struct wl_output *o)
: wayland_proxy(ivi_wm_create_screen(c->proxy.get(), o)),
controller_child(c, i)
{
- HMI_DEBUG("wm", "compositor::screen @ %p id %u o %p", this->proxy.get(), i, o);
+ HMI_DEBUG("compositor::screen @ %p id %u o %p", this->proxy.get(), i, o);
// Add listener for screen
ivi_wm_screen_add_listener(this->proxy.get(), &screen_listener, this);
@@ -469,7 +465,7 @@ void screen::clear() { ivi_wm_screen_clear(this->proxy.get()); }
void screen::screen_created(struct screen *screen, uint32_t id)
{
- HMI_DEBUG("wm", "compositor::screen @ %p screen %u (%x) @ %p", this->proxy.get(),
+ HMI_DEBUG("compositor::screen @ %p screen %u (%x) @ %p", this->proxy.get(),
id, id, screen);
this->id = id;
this->parent->screens[id] = screen;
@@ -484,7 +480,7 @@ void screen::set_render_order(std::vector<uint32_t> const &ro)
for (i = 0; i < ro.size(); i++)
{
- HMI_DEBUG("wm", "compositor::screen @ %p add layer %u", this->proxy.get(), ro[i]);
+ HMI_DEBUG("compositor::screen @ %p add layer %u", this->proxy.get(), ro[i]);
// Add the layer to screen render order at nearest z-position
ivi_wm_screen_add_layer(this->proxy.get(), ro[i]);
}
@@ -538,10 +534,10 @@ void controller::get_surface_properties(uint32_t surface_id, int param)
void controller::layer_created(uint32_t id)
{
- HMI_DEBUG("wm", "compositor::controller @ %p layer %u (%x)", this->proxy.get(), id, id);
+ HMI_DEBUG("compositor::controller @ %p layer %u (%x)", this->proxy.get(), id, id);
if (this->layers.find(id) != this->layers.end())
{
- HMI_DEBUG("wm", "WindowManager has created layer %u (%x) already", id, id);
+ HMI_DEBUG("WindowManager has created layer %u (%x) already", id, id);
}
else
{
@@ -552,13 +548,13 @@ void controller::layer_created(uint32_t id)
void controller::layer_error_detected(uint32_t object_id,
uint32_t error_code, const char *error_text)
{
- HMI_DEBUG("wm", "compositor::controller @ %p error o %d c %d text %s",
+ HMI_DEBUG("compositor::controller @ %p error o %d c %d text %s",
this->proxy.get(), object_id, error_code, error_text);
}
void controller::surface_visibility_changed(uint32_t id, int32_t visibility)
{
- HMI_DEBUG("wm", "compositor::surface %s @ %d v %i", __func__, id,
+ HMI_DEBUG("compositor::surface %s @ %d v %i", __func__, id,
visibility);
this->sprops[id].visibility = visibility;
this->chooks->surface_visibility(id, visibility);
@@ -566,7 +562,7 @@ void controller::surface_visibility_changed(uint32_t id, int32_t visibility)
void controller::surface_opacity_changed(uint32_t id, float opacity)
{
- HMI_DEBUG("wm", "compositor::surface %s @ %d o %f",
+ HMI_DEBUG("compositor::surface %s @ %d o %f",
__func__, id, opacity);
this->sprops[id].opacity = opacity;
}
@@ -575,7 +571,7 @@ void controller::surface_source_rectangle_changed(uint32_t id, int32_t x,
int32_t y, int32_t width,
int32_t height)
{
- HMI_DEBUG("wm", "compositor::surface %s @ %d x %i y %i w %i h %i", __func__,
+ HMI_DEBUG("compositor::surface %s @ %d x %i y %i w %i h %i", __func__,
id, x, y, width, height);
this->sprops[id].src_rect = rect{width, height, x, y};
}
@@ -584,7 +580,7 @@ void controller::surface_destination_rectangle_changed(uint32_t id, int32_t x,
int32_t y, int32_t width,
int32_t height)
{
- HMI_DEBUG("wm", "compositor::surface %s @ %d x %i y %i w %i h %i", __func__,
+ HMI_DEBUG("compositor::surface %s @ %d x %i y %i w %i h %i", __func__,
id, x, y, width, height);
this->sprops[id].dst_rect = rect{width, height, x, y};
this->chooks->surface_destination_rectangle(id, x, y, width, height);
@@ -593,7 +589,7 @@ void controller::surface_destination_rectangle_changed(uint32_t id, int32_t x,
void controller::surface_size_changed(uint32_t id, int32_t width,
int32_t height)
{
- HMI_DEBUG("wm", "compositor::surface %s @ %d w %i h %i", __func__, id,
+ HMI_DEBUG("compositor::surface %s @ %d w %i h %i", __func__, id,
width, height);
this->sprops[id].size = size{uint32_t(width), uint32_t(height)};
this->surfaces[id]->set_source_rectangle(0, 0, width, height);
@@ -601,20 +597,20 @@ void controller::surface_size_changed(uint32_t id, int32_t width,
void controller::surface_added_to_layer(uint32_t layer_id, uint32_t surface_id)
{
- HMI_DEBUG("wm", "compositor::surface %s @ %d l %u",
+ HMI_DEBUG("compositor::surface %s @ %d l %u",
__func__, layer_id, surface_id);
}
void controller::surface_stats_received(uint32_t surface_id,
uint32_t frame_count, uint32_t pid)
{
- HMI_DEBUG("wm", "compositor::surface %s @ %d f %u pid %u",
+ HMI_DEBUG("compositor::surface %s @ %d f %u pid %u",
__func__, surface_id, frame_count, pid);
}
void controller::surface_created(uint32_t id)
{
- HMI_DEBUG("wm", "compositor::controller @ %p surface %u (%x)", this->proxy.get(), id,
+ HMI_DEBUG("compositor::controller @ %p surface %u (%x)", this->proxy.get(), id,
id);
if (this->surfaces.find(id) == this->surfaces.end())
{
@@ -632,7 +628,7 @@ void controller::surface_created(uint32_t id)
void controller::surface_destroyed(uint32_t surface_id)
{
- HMI_DEBUG("wm", "compositor::surface %s @ %d", __func__, surface_id);
+ HMI_DEBUG("compositor::surface %s @ %d", __func__, surface_id);
this->chooks->surface_removed(surface_id);
this->sprops.erase(surface_id);
this->surfaces.erase(surface_id);
@@ -641,19 +637,19 @@ void controller::surface_destroyed(uint32_t surface_id)
void controller::surface_error_detected(uint32_t object_id,
uint32_t error_code, const char *error_text)
{
- HMI_DEBUG("wm", "compositor::controller @ %p error o %d c %d text %s",
+ HMI_DEBUG("compositor::controller @ %p error o %d c %d text %s",
this->proxy.get(), object_id, error_code, error_text);
}
void controller::layer_visibility_changed(uint32_t layer_id, int32_t visibility)
{
- HMI_DEBUG("wm", "compositor::layer %s @ %d v %i", __func__, layer_id, visibility);
+ HMI_DEBUG("compositor::layer %s @ %d v %i", __func__, layer_id, visibility);
this->lprops[layer_id].visibility = visibility;
}
void controller::layer_opacity_changed(uint32_t layer_id, float opacity)
{
- HMI_DEBUG("wm", "compositor::layer %s @ %d o %f", __func__, layer_id, opacity);
+ HMI_DEBUG("compositor::layer %s @ %d o %f", __func__, layer_id, opacity);
this->lprops[layer_id].opacity = opacity;
}
@@ -661,7 +657,7 @@ void controller::layer_source_rectangle_changed(uint32_t layer_id,
int32_t x, int32_t y,
int32_t width, int32_t height)
{
- HMI_DEBUG("wm", "compositor::layer %s @ %d x %i y %i w %i h %i",
+ HMI_DEBUG("compositor::layer %s @ %d x %i y %i w %i h %i",
__func__, layer_id, x, y, width, height);
this->lprops[layer_id].src_rect = rect{width, height, x, y};
}
@@ -670,14 +666,14 @@ void controller::layer_destination_rectangle_changed(uint32_t layer_id,
int32_t x, int32_t y,
int32_t width, int32_t height)
{
- HMI_DEBUG("wm", "compositor::layer %s @ %d x %i y %i w %i h %i",
+ HMI_DEBUG("compositor::layer %s @ %d x %i y %i w %i h %i",
__func__, layer_id, x, y, width, height);
this->lprops[layer_id].dst_rect = rect{width, height, x, y};
}
void controller::layer_destroyed(uint32_t layer_id)
{
- HMI_DEBUG("wm", "compositor::layer %s @ %d", __func__, layer_id);
+ HMI_DEBUG("compositor::layer %s @ %d", __func__, layer_id);
this->lprops.erase(layer_id);
this->layers.erase(layer_id);
}
@@ -685,40 +681,40 @@ void controller::layer_destroyed(uint32_t layer_id)
void controller::add_proxy_to_sid_mapping(struct ivi_wm *p,
uint32_t id)
{
- HMI_DEBUG("wm", "Add surface proxy mapping for %p (%u)", p, id);
+ HMI_DEBUG("Add surface proxy mapping for %p (%u)", p, id);
this->surface_proxy_to_id[uintptr_t(p)] = id;
this->sprops[id].id = id;
}
void controller::remove_proxy_to_sid_mapping(struct ivi_wm *p)
{
- HMI_DEBUG("wm", "Remove surface proxy mapping for %p", p);
+ HMI_DEBUG("Remove surface proxy mapping for %p", p);
this->surface_proxy_to_id.erase(uintptr_t(p));
}
void controller::add_proxy_to_lid_mapping(struct ivi_wm *p,
uint32_t id)
{
- HMI_DEBUG("wm", "Add layer proxy mapping for %p (%u)", p, id);
+ HMI_DEBUG("Add layer proxy mapping for %p (%u)", p, id);
this->layer_proxy_to_id[uintptr_t(p)] = id;
this->lprops[id].id = id;
}
void controller::remove_proxy_to_lid_mapping(struct ivi_wm *p)
{
- HMI_DEBUG("wm", "Remove layer proxy mapping for %p", p);
+ HMI_DEBUG("Remove layer proxy mapping for %p", p);
this->layer_proxy_to_id.erase(uintptr_t(p));
}
void controller::add_proxy_to_id_mapping(struct wl_output *p, uint32_t id)
{
- HMI_DEBUG("wm", "Add screen proxy mapping for %p (%u)", p, id);
+ HMI_DEBUG("Add screen proxy mapping for %p (%u)", p, id);
this->screen_proxy_to_id[uintptr_t(p)] = id;
}
void controller::remove_proxy_to_id_mapping(struct wl_output *p)
{
- HMI_DEBUG("wm", "Remove screen proxy mapping for %p", p);
+ HMI_DEBUG("Remove screen proxy mapping for %p", p);
this->screen_proxy_to_id.erase(uintptr_t(p));
}
diff --git a/src/window_manager.cpp b/src/window_manager.cpp
index 42930dc..3e1a8bc 100644
--- a/src/window_manager.cpp
+++ b/src/window_manager.cpp
@@ -26,6 +26,9 @@ extern "C"
#include <systemd/sd-event.h>
}
+using std::string;
+using std::vector;
+
namespace wm
{
@@ -68,7 +71,7 @@ result<json> file_to_json(char const *filename)
std::ifstream i(filename);
if (i.fail())
{
- HMI_DEBUG("wm", "Could not open config file, so use default layer information");
+ HMI_DEBUG("Could not open config file, so use default layer information");
j = default_layers_json;
}
else
@@ -81,7 +84,7 @@ result<json> file_to_json(char const *filename)
struct result<layer_map> load_layer_map(char const *filename)
{
- HMI_DEBUG("wm", "loading IDs from %s", filename);
+ HMI_DEBUG("loading IDs from %s", filename);
auto j = file_to_json(filename);
if (j.is_err())
@@ -95,12 +98,12 @@ struct result<layer_map> load_layer_map(char const *filename)
static int processTimerHandler(sd_event_source *s, uint64_t usec, void *userdata)
{
- HMI_NOTICE("wm", "Time out occurs because the client replys endDraw slow, so revert the request");
+ HMI_NOTICE("Time out occurs because the client replys endDraw slow, so revert the request");
reinterpret_cast<wm::WindowManager *>(userdata)->timerHandler();
return 0;
}
-static void onStateTransitioned(std::vector<WMAction> actions)
+static void onStateTransitioned(vector<WMAction> actions)
{
g_context->startTransitionWrapper(actions);
}
@@ -124,15 +127,15 @@ WindowManager::WindowManager(wl::display *d)
pending_events(false)
{
char const *path_layers_json = getenv("AFM_APP_INSTALL_DIR");
- std::string path;
+ string path;
if (!path_layers_json)
{
- HMI_ERROR("wm", "AFM_APP_INSTALL_DIR is not defined");
- path = std::string(path_layers_json);
+ HMI_ERROR("AFM_APP_INSTALL_DIR is not defined");
+ path = string(path_layers_json);
}
else
{
- path = std::string(path_layers_json) + std::string("/etc/layers.json");
+ path = string(path_layers_json) + string("/etc/layers.json");
}
try
@@ -145,13 +148,13 @@ WindowManager::WindowManager(wl::display *d)
}
else
{
- HMI_ERROR("wm", "%s", l.err().value());
+ HMI_ERROR("%s", l.err().value());
}
}
}
catch (std::exception &e)
{
- HMI_ERROR("wm", "Loading of configuration failed: %s", e.what());
+ HMI_ERROR("Loading of configuration failed: %s", e.what());
}
}
@@ -164,7 +167,7 @@ int WindowManager::init()
if (this->layers.mapping.empty())
{
- HMI_ERROR("wm", "No surface -> layer mapping loaded");
+ HMI_ERROR("No surface -> layer mapping loaded");
return -1;
}
@@ -245,14 +248,14 @@ result<int> WindowManager::api_request_surface(char const *appid, char const *dr
// so convert role old to new
const char *role = this->convertRoleOldToNew(drawing_name);
- auto lid = this->layers.get_layer_id(std::string(role));
+ auto lid = this->layers.get_layer_id(string(role));
if (!lid)
{
/**
* register drawing_name as fallback and make it displayed.
*/
- lid = this->layers.get_layer_id(std::string("fallback"));
- HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", role);
+ lid = this->layers.get_layer_id(string("fallback"));
+ HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role);
if (!lid)
{
return Err<int>("Drawing name does not match any role, fallback is disabled");
@@ -271,15 +274,15 @@ result<int> WindowManager::api_request_surface(char const *appid, char const *dr
this->layers.main_surface_name == drawing_name)
{
this->layers.main_surface = id;
- HMI_DEBUG("wm", "Set main_surface id to %u", id);
+ HMI_DEBUG("Set main_surface id to %u", id);
}
// add client into the db
- std::string appid_str(appid);
- g_app_list.addClient(appid_str, *lid, id, std::string(role));
+ string appid_str(appid);
+ g_app_list.addClient(appid_str, *lid, id, string(role));
// Set role map of (new, old)
- this->rolenew2old[role] = std::string(drawing_name);
+ this->rolenew2old[role] = string(drawing_name);
return Ok<int>(id);
}
@@ -291,13 +294,11 @@ result<int> WindowManager::api_request_surface(char const *appid, char const *dr
char const *WindowManager::api_request_surface(char const *appid, char const *drawing_name,
char const *ivi_id)
{
- ST();
-
// TODO: application requests by old role,
// so convert role old to new
const char *role = this->convertRoleOldToNew(drawing_name);
- auto lid = this->layers.get_layer_id(std::string(role));
+ auto lid = this->layers.get_layer_id(string(role));
unsigned sid = std::stol(ivi_id);
if (!lid)
@@ -305,8 +306,8 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr
/**
* register drawing_name as fallback and make it displayed.
*/
- lid = this->layers.get_layer_id(std::string("fallback"));
- HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", role);
+ lid = this->layers.get_layer_id(string("fallback"));
+ HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role);
if (!lid)
{
return "Drawing name does not match any role, fallback is disabled";
@@ -325,17 +326,17 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr
this->layers.add_surface(sid, *lid);
// this surface is already created
- HMI_DEBUG("wm", "surface_id is %u, layer_id is %u", sid, *lid);
+ HMI_DEBUG("surface_id is %u, layer_id is %u", sid, *lid);
this->controller->layers[*lid]->add_surface(sid);
this->layout_commit();
// add client into the db
- std::string appid_str(appid);
- g_app_list.addClient(appid_str, *lid, sid, std::string(role));
+ string appid_str(appid);
+ g_app_list.addClient(appid_str, *lid, sid, string(role));
// Set role map of (new, old)
- this->rolenew2old[role] = std::string(drawing_name);
+ this->rolenew2old[role] = string(drawing_name);
return nullptr;
}
@@ -343,15 +344,13 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr
void WindowManager::api_activate_surface(char const *appid, char const *drawing_name,
char const *drawing_area, const reply_func &reply)
{
- ST();
-
// TODO: application requests by old role,
// so convert role old to new
const char *c_role = this->convertRoleOldToNew(drawing_name);
- std::string id = appid;
- std::string role = c_role;
- std::string area = drawing_area;
+ string id = appid;
+ string role = c_role;
+ string area = drawing_area;
Task task = Task::TASK_ALLOCATE;
unsigned req_num = 0;
WMError ret = WMError::UNKNOWN;
@@ -360,7 +359,7 @@ void WindowManager::api_activate_surface(char const *appid, char const *drawing_
if(ret != WMError::SUCCESS)
{
- HMI_ERROR("wm", errorDescription(ret));
+ HMI_ERROR(errorDescription(ret));
reply("Failed to set request");
return;
}
@@ -390,8 +389,6 @@ void WindowManager::api_activate_surface(char const *appid, char const *drawing_
void WindowManager::api_deactivate_surface(char const *appid, char const *drawing_name,
const reply_func &reply)
{
- ST();
-
// TODO: application requests by old role,
// so convert role old to new
const char *c_role = this->convertRoleOldToNew(drawing_name);
@@ -399,9 +396,9 @@ void WindowManager::api_deactivate_surface(char const *appid, char const *drawin
/*
* Check Phase
*/
- std::string id = appid;
- std::string role = c_role;
- std::string area = ""; //drawing_area;
+ string id = appid;
+ string role = c_role;
+ string area = ""; //drawing_area;
Task task = Task::TASK_RELEASE;
unsigned req_num = 0;
WMError ret = WMError::UNKNOWN;
@@ -410,7 +407,7 @@ void WindowManager::api_deactivate_surface(char const *appid, char const *drawin
if (ret != WMError::SUCCESS)
{
- HMI_ERROR("wm", errorDescription(ret));
+ HMI_ERROR(errorDescription(ret));
reply("Failed to set request");
return;
}
@@ -443,14 +440,14 @@ void WindowManager::api_enddraw(char const *appid, char const *drawing_name)
// so convert role old to new
const char *c_role = this->convertRoleOldToNew(drawing_name);
- std::string id = appid;
- std::string role = c_role;
+ string id = appid;
+ string role = c_role;
unsigned current_req = g_app_list.currentRequestNumber();
bool result = g_app_list.setEndDrawFinished(current_req, id, role);
if (!result)
{
- HMI_ERROR("wm", "%s is not in transition state", id.c_str());
+ HMI_ERROR("%s is not in transition state", id.c_str());
return;
}
@@ -504,7 +501,7 @@ result<json_object *> WindowManager::api_get_display_info()
result<json_object *> WindowManager::api_get_area_info(char const *drawing_name)
{
- HMI_DEBUG("wm", "called");
+ HMI_DEBUG("called");
// TODO: application requests by old role,
// so convert role old to new
@@ -543,7 +540,7 @@ void WindowManager::api_ping() { this->dispatch_pending_events(); }
void WindowManager::send_event(char const *evname, char const *label)
{
- HMI_DEBUG("wm", "%s: %s(%s)", __func__, evname, label);
+ HMI_DEBUG("%s: %s(%s)", __func__, evname, label);
json_object *j = json_object_new_object();
json_object_object_add(j, kKeyDrawingName, json_object_new_string(label));
@@ -551,14 +548,14 @@ void WindowManager::send_event(char const *evname, char const *label)
int ret = afb_event_push(this->map_afb_event[evname], j);
if (ret != 0)
{
- HMI_DEBUG("wm", "afb_event_push failed: %m");
+ HMI_DEBUG("afb_event_push failed: %m");
}
}
void WindowManager::send_event(char const *evname, char const *label, char const *area,
int x, int y, int w, int h)
{
- HMI_DEBUG("wm", "%s: %s(%s, %s) x:%d y:%d w:%d h:%d",
+ HMI_DEBUG("%s: %s(%s, %s) x:%d y:%d w:%d h:%d",
__func__, evname, label, area, x, y, w, h);
json_object *j_rect = json_object_new_object();
@@ -575,7 +572,7 @@ void WindowManager::send_event(char const *evname, char const *label, char const
int ret = afb_event_push(this->map_afb_event[evname], j);
if (ret != 0)
{
- HMI_DEBUG("wm", "afb_event_push failed: %m");
+ HMI_DEBUG("afb_event_push failed: %m");
}
}
@@ -589,12 +586,12 @@ void WindowManager::surface_created(uint32_t surface_id)
auto layer_id = this->layers.get_layer_id(surface_id);
if (!layer_id)
{
- HMI_DEBUG("wm", "Newly created surfce %d is not associated with any layer!",
+ HMI_DEBUG("Newly created surfce %d is not associated with any layer!",
surface_id);
return;
}
- HMI_DEBUG("wm", "surface_id is %u, layer_id is %u", surface_id, *layer_id);
+ HMI_DEBUG("surface_id is %u, layer_id is %u", surface_id, *layer_id);
this->controller->layers[*layer_id]->add_surface(surface_id);
this->layout_commit();
@@ -602,15 +599,15 @@ void WindowManager::surface_created(uint32_t surface_id)
void WindowManager::surface_removed(uint32_t surface_id)
{
- HMI_DEBUG("wm", "Delete surface_id %u", surface_id);
+ HMI_DEBUG("Delete surface_id %u", surface_id);
this->id_alloc.remove_id(surface_id);
this->layers.remove_surface(surface_id);
g_app_list.removeSurface(surface_id);
}
-void WindowManager::removeClient(const std::string &appid)
+void WindowManager::removeClient(const string &appid)
{
- HMI_DEBUG("wm", "Remove clinet %s from list", appid.c_str());
+ HMI_DEBUG("Remove clinet %s from list", appid.c_str());
g_app_list.removeClient(appid);
}
@@ -632,7 +629,7 @@ void WindowManager::timerHandler()
this->processNextRequest();
}
-void WindowManager::startTransitionWrapper(std::vector<WMAction> &actions)
+void WindowManager::startTransitionWrapper(vector<WMAction> &actions)
{
WMError ret;
unsigned req_num = g_app_list.currentRequestNumber();
@@ -661,7 +658,7 @@ void WindowManager::startTransitionWrapper(std::vector<WMAction> &actions)
{
goto proc_remove_request;
}
- std::string appid = g_app_list.getAppID(*surface_id, act.role, &found);
+ string appid = g_app_list.getAppID(*surface_id, act.role, &found);
if (!found)
{
if (TaskVisible::INVISIBLE == act.visible)
@@ -676,7 +673,9 @@ void WindowManager::startTransitionWrapper(std::vector<WMAction> &actions)
goto error;
}
}
- act.appid = appid;
+ auto client = g_app_list.lookUpClient(appid);
+ act.req_num = req_num;
+ act.client = client;
}
ret = g_app_list.setAction(req_num, act);
@@ -737,9 +736,9 @@ bool WindowManager::pop_pending_events()
optional<int> WindowManager::lookup_id(char const *name)
{
- return this->id_alloc.lookup(std::string(name));
+ return this->id_alloc.lookup(string(name));
}
-optional<std::string> WindowManager::lookup_name(int id)
+optional<string> WindowManager::lookup_name(int id)
{
return this->id_alloc.lookup(id);
}
@@ -751,13 +750,13 @@ int WindowManager::init_layers()
{
if (!this->controller)
{
- HMI_ERROR("wm", "ivi_controller global not available");
+ HMI_ERROR("ivi_controller global not available");
return -1;
}
if (this->outputs.empty())
{
- HMI_ERROR("wm", "no output was set up!");
+ HMI_ERROR("no output was set up!");
return -1;
}
@@ -773,7 +772,7 @@ int WindowManager::init_layers()
uint32_t(o->physical_height)};
- HMI_DEBUG("wm", "SCALING: screen (%dx%d), physical (%dx%d)",
+ HMI_DEBUG("SCALING: screen (%dx%d), physical (%dx%d)",
o->width, o->height, o->physical_width, o->physical_height);
this->layers.loadAreaDb();
@@ -784,7 +783,7 @@ int WindowManager::init_layers()
dp_bg.set_aspect(static_cast<double>(css_bg.w) / css_bg.h);
dp_bg.fit(o->width, o->height);
dp_bg.center(o->width, o->height);
- HMI_DEBUG("wm", "SCALING: CSS BG(%dx%d) -> DDP %dx%d,(%dx%d)",
+ HMI_DEBUG("SCALING: CSS BG(%dx%d) -> DDP %dx%d,(%dx%d)",
css_bg.w, css_bg.h, dp_bg.left(), dp_bg.top(), dp_bg.width(), dp_bg.height());
// Clear scene
@@ -800,7 +799,7 @@ int WindowManager::init_layers()
auto &l = layers[i.second.layer_id];
l->set_destination_rectangle(dp_bg.left(), dp_bg.top(), dp_bg.width(), dp_bg.height());
l->set_visibility(1);
- HMI_DEBUG("wm", "Setting up layer %s (%d) for surface role match \"%s\"",
+ HMI_DEBUG("Setting up layer %s (%d) for surface role match \"%s\"",
i.second.name.c_str(), i.second.layer_id, i.second.role.c_str());
}
@@ -815,11 +814,11 @@ int WindowManager::init_layers()
return 0;
}
-void WindowManager::surface_set_layout(int surface_id, const std::string& area)
+void WindowManager::surface_set_layout(int surface_id, const string& area)
{
if (!this->controller->surface_exists(surface_id))
{
- HMI_ERROR("wm", "Surface %d does not exist", surface_id);
+ HMI_ERROR("Surface %d does not exist", surface_id);
return;
}
@@ -827,7 +826,7 @@ void WindowManager::surface_set_layout(int surface_id, const std::string& area)
if (!o_layer_id)
{
- HMI_ERROR("wm", "Surface %d is not associated with any layer!", surface_id);
+ HMI_ERROR("Surface %d is not associated with any layer!", surface_id);
return;
}
@@ -844,7 +843,7 @@ void WindowManager::surface_set_layout(int surface_id, const std::string& area)
int w = rect.w;
int h = rect.h;
- HMI_DEBUG("wm", "surface_set_layout for surface %u on layer %u", surface_id,
+ HMI_DEBUG("surface_set_layout for surface %u on layer %u", surface_id,
layer_id);
// set destination to the display rectangle
@@ -856,7 +855,7 @@ void WindowManager::surface_set_layout(int surface_id, const std::string& area)
this->area_info[surface_id].w = w;
this->area_info[surface_id].h = h;
- HMI_DEBUG("wm", "Surface %u now on layer %u with rect { %d, %d, %d, %d }",
+ HMI_DEBUG("Surface %u now on layer %u with rect { %d, %d, %d, %d }",
surface_id, layer_id, x, y, w, h);
}
@@ -881,7 +880,7 @@ void WindowManager::emit_syncdraw(char const *label, char const *area, int x, in
this->send_event(kListEventName[Event_SyncDraw], label, area, x, y, w, h);
}
-void WindowManager::emit_syncdraw(const std::string &role, const std::string &area)
+void WindowManager::emit_syncdraw(const string &role, const string &area)
{
compositor::rect rect = this->layers.getAreaSize(area);
this->send_event(kListEventName[Event_SyncDraw],
@@ -928,16 +927,16 @@ void WindowManager::activate(int id)
this->surface_bg.erase(i);
// Remove from BG layer (999)
- HMI_DEBUG("wm", "Remove %s(%d) from BG layer", label, id);
+ HMI_DEBUG("Remove %s(%d) from BG layer", label, id);
this->controller->layers[999]->remove_surface(id);
// Add to FG layer (1001)
- HMI_DEBUG("wm", "Add %s(%d) to FG layer", label, id);
+ HMI_DEBUG("Add %s(%d) to FG layer", label, id);
this->controller->layers[1001]->add_surface(id);
for (int j : this->surface_bg)
{
- HMI_DEBUG("wm", "Stored id:%d", j);
+ HMI_DEBUG("Stored id:%d", j);
}
break;
}
@@ -975,16 +974,16 @@ void WindowManager::deactivate(int id)
this->surface_bg.push_back(id);
// Remove from FG layer (1001)
- HMI_DEBUG("wm", "Remove %s(%d) from FG layer", label, id);
+ HMI_DEBUG("Remove %s(%d) from FG layer", label, id);
this->controller->layers[1001]->remove_surface(id);
// Add to BG layer (999)
- HMI_DEBUG("wm", "Add %s(%d) to BG layer", label, id);
+ HMI_DEBUG("Add %s(%d) to BG layer", label, id);
this->controller->layers[999]->add_surface(id);
for (int j : surface_bg)
{
- HMI_DEBUG("wm", "Stored id:%d", j);
+ HMI_DEBUG("Stored id:%d", j);
}
}
else
@@ -1004,7 +1003,7 @@ void WindowManager::deactivate(int id)
}
}
-WMError WindowManager::setRequest(const std::string& appid, const std::string &role, const std::string &area,
+WMError WindowManager::setRequest(const string& appid, const string &role, const string &area,
Task task, unsigned* req_num)
{
if (!g_app_list.contains(appid))
@@ -1057,7 +1056,7 @@ WMError WindowManager::checkPolicy(unsigned req_num)
ret = WMError::NO_ENTRY;
return ret;
}
- std::string req_area = trigger.area;
+ string req_area = trigger.area;
if (trigger.task == Task::TASK_ALLOCATE)
{
@@ -1113,7 +1112,7 @@ WMError WindowManager::startTransition(unsigned req_num)
// TODO: application requests by old role,
// so convert role new to old for emitting event
- std::string old_role = this->rolenew2old[action.role];
+ string old_role = this->rolenew2old[action.role];
this->emit_syncdraw(old_role, action.area);
/* TODO: emit event for app not subscriber
@@ -1132,9 +1131,9 @@ WMError WindowManager::startTransition(unsigned req_num)
// Make it deactivate here
for (const auto &x : actions)
{
- if (g_app_list.contains(x.appid))
+ if (g_app_list.contains(x.client->appID()))
{
- auto client = g_app_list.lookUpClient(x.appid);
+ auto client = g_app_list.lookUpClient(x.client->appID());
this->deactivate(client->surfaceID(x.role));
}
}
@@ -1163,7 +1162,7 @@ WMError WindowManager::doEndDraw(unsigned req_num)
if(act.visible != TaskVisible::NO_CHANGE)
{
// layout change
- if(!g_app_list.contains(act.appid)){
+ if(!g_app_list.contains(act.client->appID())){
ret = WMError::NOT_REGISTERED;
}
ret = this->layoutChange(act);
@@ -1194,7 +1193,7 @@ WMError WindowManager::doEndDraw(unsigned req_num)
{
// TODO: application requests by old role,
// so convert role new to old for emitting event
- std::string old_role = this->rolenew2old[act_flush.role];
+ string old_role = this->rolenew2old[act_flush.role];
this->emit_flushdraw(old_role.c_str());
}
@@ -1210,7 +1209,7 @@ WMError WindowManager::layoutChange(const WMAction &action)
// Visibility is not change -> no redraw is required
return WMError::SUCCESS;
}
- auto client = g_app_list.lookUpClient(action.appid);
+ auto client = g_app_list.lookUpClient(action.client->appID());
unsigned surface = client->surfaceID(action.role);
if (surface == 0)
{
@@ -1226,10 +1225,11 @@ WMError WindowManager::layoutChange(const WMAction &action)
WMError WindowManager::visibilityChange(const WMAction &action)
{
HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), "Change visibility");
- if(!g_app_list.contains(action.appid)){
+ if(!g_app_list.contains(action.client->appID()))
+ {
return WMError::NOT_REGISTERED;
}
- auto client = g_app_list.lookUpClient(action.appid);
+ auto client = g_app_list.lookUpClient(action.client->appID());
unsigned surface = client->surfaceID(action.role);
if(surface == 0)
{
@@ -1249,7 +1249,7 @@ WMError WindowManager::visibilityChange(const WMAction &action)
return WMError::SUCCESS;
}
-WMError WindowManager::setSurfaceSize(unsigned surface, const std::string &area)
+WMError WindowManager::setSurfaceSize(unsigned surface, const string &area)
{
this->surface_set_layout(surface, area);
@@ -1271,7 +1271,7 @@ void WindowManager::emitScreenUpdated(unsigned req_num)
{
if(action.visible != TaskVisible::INVISIBLE)
{
- json_object_array_add(jarray, json_object_new_string(action.appid.c_str()));
+ json_object_array_add(jarray, json_object_new_string(action.client->appID().c_str()));
}
}
json_object_object_add(j, kKeyIds, jarray);
@@ -1281,7 +1281,7 @@ void WindowManager::emitScreenUpdated(unsigned req_num)
this->map_afb_event[kListEventName[Event_ScreenUpdated]], j);
if (ret != 0)
{
- HMI_DEBUG("wm", "afb_event_push failed: %m");
+ HMI_DEBUG("afb_event_push failed: %m");
}
}
@@ -1289,7 +1289,7 @@ void WindowManager::setTimer()
{
struct timespec ts;
if (clock_gettime(CLOCK_BOOTTIME, &ts) != 0) {
- HMI_ERROR("wm", "Could't set time (clock_gettime() returns with error");
+ HMI_ERROR("Could't set time (clock_gettime() returns with error");
return;
}
@@ -1301,7 +1301,7 @@ void WindowManager::setTimer()
CLOCK_BOOTTIME, (uint64_t)(ts.tv_sec + kTimeOut) * 1000000ULL, 1, processTimerHandler, this);
if (ret < 0)
{
- HMI_ERROR("wm", "Could't set timer");
+ HMI_ERROR("Could't set timer");
}
}
else
@@ -1364,7 +1364,7 @@ const char* WindowManager::convertRoleOldToNew(char const *old_role)
new_role = old_role;
}
- HMI_DEBUG("wm", "old:%s -> new:%s", old_role, new_role);
+ HMI_DEBUG("old:%s -> new:%s", old_role, new_role);
return new_role;
}
@@ -1373,16 +1373,16 @@ int WindowManager::loadOldRoleDb()
{
// Get afm application installed dir
char const *afm_app_install_dir = getenv("AFM_APP_INSTALL_DIR");
- HMI_DEBUG("wm", "afm_app_install_dir:%s", afm_app_install_dir);
+ HMI_DEBUG("afm_app_install_dir:%s", afm_app_install_dir);
- std::string file_name;
+ string file_name;
if (!afm_app_install_dir)
{
- HMI_ERROR("wm", "AFM_APP_INSTALL_DIR is not defined");
+ HMI_ERROR("AFM_APP_INSTALL_DIR is not defined");
}
else
{
- file_name = std::string(afm_app_install_dir) + std::string("/etc/old_roles.db");
+ file_name = string(afm_app_install_dir) + string("/etc/old_roles.db");
}
// Load old_role.db
@@ -1390,22 +1390,22 @@ int WindowManager::loadOldRoleDb()
int ret = jh::inputJsonFilie(file_name.c_str(), &json_obj);
if (0 > ret)
{
- HMI_ERROR("wm", "Could not open old_role.db, so use default old_role information");
+ HMI_ERROR("Could not open old_role.db, so use default old_role information");
json_obj = json_tokener_parse(kDefaultOldRoleDb);
}
- HMI_DEBUG("wm", "json_obj dump:%s", json_object_get_string(json_obj));
+ HMI_DEBUG("json_obj dump:%s", json_object_get_string(json_obj));
// Perse apps
json_object* json_cfg;
if (!json_object_object_get_ex(json_obj, "old_roles", &json_cfg))
{
- HMI_ERROR("wm", "Parse Error!!");
+ HMI_ERROR("Parse Error!!");
return -1;
}
int len = json_object_array_length(json_cfg);
- HMI_DEBUG("wm", "json_cfg len:%d", len);
- HMI_DEBUG("wm", "json_cfg dump:%s", json_object_get_string(json_cfg));
+ HMI_DEBUG("json_cfg len:%d", len);
+ HMI_DEBUG("json_cfg dump:%s", json_object_get_string(json_cfg));
for (int i=0; i<len; i++)
{
@@ -1414,25 +1414,25 @@ int WindowManager::loadOldRoleDb()
const char* old_role = jh::getStringFromJson(json_tmp, "name");
if (nullptr == old_role)
{
- HMI_ERROR("wm", "Parse Error!!");
+ HMI_ERROR("Parse Error!!");
return -1;
}
const char* new_role = jh::getStringFromJson(json_tmp, "new");
if (nullptr == new_role)
{
- HMI_ERROR("wm", "Parse Error!!");
+ HMI_ERROR("Parse Error!!");
return -1;
}
- this->roleold2new[old_role] = std::string(new_role);
+ this->roleold2new[old_role] = string(new_role);
}
// Check
for(auto itr = this->roleold2new.begin();
itr != this->roleold2new.end(); ++itr)
{
- HMI_DEBUG("wm", ">>> role old:%s new:%s",
+ HMI_DEBUG(">>> role old:%s new:%s",
itr->first.c_str(), itr->second.c_str());
}
@@ -1462,7 +1462,7 @@ const char *WindowManager::check_surface_exist(const char *drawing_name)
return "Surface is not on any layer!";
}
- HMI_DEBUG("wm", "surface %d is detected", *surface_id);
+ HMI_DEBUG("surface %d is detected", *surface_id);
return nullptr;
}
diff --git a/src/window_manager.hpp b/src/window_manager.hpp
index 6cbd355..b591149 100644
--- a/src/window_manager.hpp
+++ b/src/window_manager.hpp
@@ -14,21 +14,25 @@
* limitations under the License.
*/
-#ifndef TMCAGLWM_APP_HPP
-#define TMCAGLWM_APP_HPP
+#ifndef WINDOW_MANAGER_HPP
+#define WINDOW_MANAGER_HPP
#include <atomic>
#include <memory>
#include <unordered_map>
#include <experimental/optional>
+#include "util.hpp"
#include "controller_hooks.hpp"
-#include "layers.hpp"
+#include "wm_layer.hpp"
#include "layout.hpp"
#include "wayland_ivi_wm.hpp"
#include "pm_wrapper.hpp"
-#include "hmi-debug.h"
#include "request.hpp"
#include "wm_error.hpp"
+extern "C"
+{
+#include <afb/afb-binding.h>
+}
struct json_object;
@@ -88,7 +92,7 @@ struct id_allocator
unsigned sid = this->next++;
this->id2name[sid] = name;
this->name2id[name] = sid;
- HMI_DEBUG("wm", "allocated new id %u with name %s", sid, name.c_str());
+ HMI_DEBUG("allocated new id %u with name %s", sid, name.c_str());
return sid;
}
@@ -97,7 +101,7 @@ struct id_allocator
{
this->id2name[sid] = name;
this->name2id[name] = sid;
- HMI_DEBUG("wm", "register id %u with name %s", sid, name.c_str());
+ HMI_DEBUG("register id %u with name %s", sid, name.c_str());
return;
}
@@ -286,4 +290,4 @@ class WindowManager
} // namespace wm
-#endif // TMCAGLWM_APP_HPP
+#endif // WINDOW_MANAGER_HPP
diff --git a/src/wm_client.cpp b/src/wm_client.cpp
index 09e2e00..2e12a69 100644
--- a/src/wm_client.cpp
+++ b/src/wm_client.cpp
@@ -16,7 +16,7 @@
#include <json-c/json.h>
#include "wm_client.hpp"
-#include "hmi-debug.h"
+#include "util.hpp"
#define INVALID_SURFACE_ID 0
@@ -137,10 +137,10 @@ void WMClient::registerLayer(unsigned layer)
*/
bool WMClient::addSurface(const string &role, unsigned surface)
{
- HMI_DEBUG("wm", "Add role %s with surface %d", role.c_str(), surface);
+ HMI_DEBUG("Add role %s with surface %d", role.c_str(), surface);
if (0 != this->role2surface.count(role))
{
- HMI_NOTICE("wm", "override surfaceID %d with %d", this->role2surface[role], surface);
+ HMI_NOTICE("override surfaceID %d with %d", this->role2surface[role], surface);
}
this->role2surface[role] = surface;
return true;
@@ -153,7 +153,7 @@ bool WMClient::removeSurfaceIfExist(unsigned surface)
{
if (surface == x.second)
{
- HMI_INFO("wm", "Remove surface from client %s: role %s, surface: %d",
+ HMI_INFO("Remove surface from client %s: role %s, surface: %d",
this->id.c_str(), x.first.c_str(), x.second);
this->role2surface.erase(x.first);
ret = true;
@@ -178,13 +178,13 @@ bool WMClient::removeRole(const string &role)
bool WMClient::subscribe(afb_req req, const string &evname)
{
if(evname != kKeyError){
- HMI_DEBUG("wm", "error is only enabeled for now");
+ HMI_DEBUG("error is only enabeled for now");
return false;
}
int ret = afb_req_subscribe(req, this->event2list[evname]);
if (ret)
{
- HMI_DEBUG("wm", "Failed to subscribe %s", evname.c_str());
+ HMI_DEBUG("Failed to subscribe %s", evname.c_str());
return false;
}
return true;
@@ -193,18 +193,18 @@ bool WMClient::subscribe(afb_req req, const string &evname)
void WMClient::emitError(WM_CLIENT_ERROR_EVENT ev)
{
if (!afb_event_is_valid(this->event2list[kKeyError])){
- HMI_ERROR("wm", "event err is not valid");
+ HMI_ERROR("event err is not valid");
return;
}
json_object *j = json_object_new_object();
json_object_object_add(j, kKeyError, json_object_new_int(ev));
json_object_object_add(j, kKeyErrorDesc, json_object_new_string(kErrorDescription[ev].c_str()));
- HMI_DEBUG("wm", "error: %d, description:%s", ev, kErrorDescription[ev].c_str());
+ HMI_DEBUG("error: %d, description:%s", ev, kErrorDescription[ev].c_str());
int ret = afb_event_push(this->event2list[kKeyError], j);
if (ret != 0)
{
- HMI_DEBUG("wm", "afb_event_push failed: %m");
+ HMI_DEBUG("afb_event_push failed: %m");
}
}
#endif
diff --git a/src/layers.cpp b/src/wm_layer.cpp
index b7a0fa2..6a98884 100644
--- a/src/layers.cpp
+++ b/src/wm_layer.cpp
@@ -16,9 +16,9 @@
#include <regex>
-#include "layers.hpp"
+#include "wm_layer.hpp"
#include "json_helper.hpp"
-#include "hmi-debug.h"
+#include "util.hpp"
namespace wm
{
@@ -31,7 +31,7 @@ layer::layer(nlohmann::json const &j)
this->name = j["name"];
this->layer_id = j["layer_id"];
- HMI_DEBUG("wm", "layer_id:%d name:%s", this->layer_id, this->name.c_str());
+ HMI_DEBUG("layer_id:%d name:%s", this->layer_id, this->name.c_str());
}
struct result<struct layer_map> to_layer_map(nlohmann::json const &j)
@@ -108,11 +108,11 @@ optional<int> layer_map::get_layer_id(std::string const &role)
auto re = std::regex(r.first);
if (std::regex_match(role, re))
{
- HMI_DEBUG("wm", "role %s matches layer %d", role.c_str(), r.second);
+ HMI_DEBUG("role %s matches layer %d", role.c_str(), r.second);
return optional<int>(r.second);
}
}
- HMI_DEBUG("wm", "role %s does NOT match any layer", role.c_str());
+ HMI_DEBUG("role %s does NOT match any layer", role.c_str());
return nullopt;
}
@@ -168,7 +168,7 @@ void layer_map::setupArea(double scaling)
i.second.w = static_cast<int>(scaling * i.second.w + 0.5);
i.second.h = static_cast<int>(scaling * i.second.h + 0.5);
- HMI_DEBUG("wm:lm", "area:%s size(after) : x:%d y:%d w:%d h:%d",
+ HMI_DEBUG("area:%s size(after) : x:%d y:%d w:%d h:%d",
i.first.c_str(), i.second.x, i.second.y, i.second.w, i.second.h);
}
}
@@ -180,16 +180,14 @@ compositor::rect layer_map::getAreaSize(const std::string &area)
int layer_map::loadAreaDb()
{
- HMI_DEBUG("wm:lm", "Call");
-
// Get afm application installed dir
char const *afm_app_install_dir = getenv("AFM_APP_INSTALL_DIR");
- HMI_DEBUG("wm:lm", "afm_app_install_dir:%s", afm_app_install_dir);
+ HMI_DEBUG("afm_app_install_dir:%s", afm_app_install_dir);
std::string file_name;
if (!afm_app_install_dir)
{
- HMI_ERROR("wm:lm", "AFM_APP_INSTALL_DIR is not defined");
+ HMI_ERROR("AFM_APP_INSTALL_DIR is not defined");
}
else
{
@@ -201,45 +199,45 @@ int layer_map::loadAreaDb()
int ret = jh::inputJsonFilie(file_name.c_str(), &json_obj);
if (0 > ret)
{
- HMI_DEBUG("wm:lm", "Could not open area.db, so use default area information");
+ HMI_DEBUG("Could not open area.db, so use default area information");
json_obj = json_tokener_parse(kDefaultAreaDb);
}
- HMI_DEBUG("wm:lm", "json_obj dump:%s", json_object_get_string(json_obj));
+ HMI_DEBUG("json_obj dump:%s", json_object_get_string(json_obj));
// Perse areas
- HMI_DEBUG("wm:lm", "Perse areas");
+ HMI_DEBUG("Perse areas");
json_object *json_cfg;
if (!json_object_object_get_ex(json_obj, "areas", &json_cfg))
{
- HMI_ERROR("wm:lm", "Parse Error!!");
+ HMI_ERROR("Parse Error!!");
return -1;
}
int len = json_object_array_length(json_cfg);
- HMI_DEBUG("wm:lm", "json_cfg len:%d", len);
- HMI_DEBUG("wm:lm", "json_cfg dump:%s", json_object_get_string(json_cfg));
+ HMI_DEBUG("json_cfg len:%d", len);
+ HMI_DEBUG("json_cfg dump:%s", json_object_get_string(json_cfg));
const char *area;
for (int i = 0; i < len; i++)
{
json_object *json_tmp = json_object_array_get_idx(json_cfg, i);
- HMI_DEBUG("wm:lm", "> json_tmp dump:%s", json_object_get_string(json_tmp));
+ HMI_DEBUG("> json_tmp dump:%s", json_object_get_string(json_tmp));
area = jh::getStringFromJson(json_tmp, "name");
if (nullptr == area)
{
- HMI_ERROR("wm:lm", "Parse Error!!");
+ HMI_ERROR("Parse Error!!");
return -1;
}
- HMI_DEBUG("wm:lm", "> area:%s", area);
+ HMI_DEBUG("> area:%s", area);
json_object *json_rect;
if (!json_object_object_get_ex(json_tmp, "rect", &json_rect))
{
- HMI_ERROR("wm:lm", "Parse Error!!");
+ HMI_ERROR("Parse Error!!");
return -1;
}
- HMI_DEBUG("wm:lm", "> json_rect dump:%s", json_object_get_string(json_rect));
+ HMI_DEBUG("> json_rect dump:%s", json_object_get_string(json_rect));
compositor::rect area_size;
area_size.x = jh::getIntFromJson(json_rect, "x");
@@ -254,7 +252,7 @@ int layer_map::loadAreaDb()
for (auto itr = this->area2size.begin();
itr != this->area2size.end(); ++itr)
{
- HMI_DEBUG("wm:lm", "area:%s x:%d y:%d w:%d h:%d",
+ HMI_DEBUG("area:%s x:%d y:%d w:%d h:%d",
itr->first.c_str(), itr->second.x, itr->second.y,
itr->second.w, itr->second.h);
}
diff --git a/src/layers.hpp b/src/wm_layer.hpp
index 3a16985..4dd4616 100644
--- a/src/layers.hpp
+++ b/src/wm_layer.hpp
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef TMCAGLWM_LAYERS_H
-#define TMCAGLWM_LAYERS_H
+#ifndef WM_LAYERS_H
+#define WM_LAYERS_H
#include <string>
@@ -155,4 +155,4 @@ static const nlohmann::json default_layers_json = {
};
} // namespace wm
-#endif // TMCAGLWM_LAYERS_H
+#endif // WM_LAYERS_H