#include <unistd.h>\r
#include "wm_layer_control.hpp"\r
#include "wm_layer.hpp"\r
+#include "json_helper.hpp"\r
\r
#define LC_AREA_PATH "/etc/area.db"\r
#define LC_LAYER_SETTING_PATH "/etc/layer_setting.json"\r
string area_path = root + LC_AREA_PATH;\r
string layer_path= root + LC_LAYER_SETTING_PATH;\r
// load layers.setting.json\r
+ WMError ret = this->loadLayerSetting(layer_path);\r
+ assert(ret == WMError::SUCCESS);\r
// load area.db\r
+ ret = this->loadAreaDb(area_path);\r
+ assert(ret == WMError::SUCCESS);\r
}\r
\r
WMError LayerControl::init()\r
\r
void LayerControl::undoUpdate() {}\r
\r
-WMError LayerControl::load(const string &path)\r
+WMError LayerControl::loadLayerSetting(const string &path)\r
{\r
return WMError::SUCCESS;\r
}\r
\r
+WMError LayerControl::loadAreaDb(const std::string& path)\r
+{\r
+ // Load area.db\r
+ json_object *json_obj;\r
+ int ret = jh::inputJsonFilie(path.c_str(), &json_obj);\r
+ if (0 > ret)\r
+ {\r
+ HMI_DEBUG("Could not open area.db, so use default area information");\r
+ return WMError::FAIL;\r
+ }\r
+ HMI_INFO("json_obj dump:%s", json_object_get_string(json_obj));\r
+\r
+ // Perse areas\r
+ json_object *json_cfg;\r
+ if (!json_object_object_get_ex(json_obj, "areas", &json_cfg))\r
+ {\r
+ HMI_ERROR("Parse Error!!");\r
+ return WMError::FAIL;\r
+ }\r
+\r
+ int len = json_object_array_length(json_cfg);\r
+ HMI_DEBUG("json_cfg len:%d", len);\r
+ HMI_DEBUG("json_cfg dump:%s", json_object_get_string(json_cfg));\r
+\r
+ const char *area;\r
+ for (int i = 0; i < len; i++)\r
+ {\r
+ json_object *json_tmp = json_object_array_get_idx(json_cfg, i);\r
+ HMI_DEBUG("> json_tmp dump:%s", json_object_get_string(json_tmp));\r
+\r
+ area = jh::getStringFromJson(json_tmp, "name");\r
+ if (nullptr == area)\r
+ {\r
+ HMI_ERROR("Parse Error!!");\r
+ return WMError::FAIL;\r
+ }\r
+ HMI_DEBUG("> area:%s", area);\r
+\r
+ json_object *json_rect;\r
+ if (!json_object_object_get_ex(json_tmp, "rect", &json_rect))\r
+ {\r
+ HMI_ERROR("Parse Error!!");\r
+ return WMError::FAIL;\r
+ }\r
+ HMI_DEBUG("> json_rect dump:%s", json_object_get_string(json_rect));\r
+\r
+ struct rect area_size;\r
+ area_size.x = jh::getIntFromJson(json_rect, "x");\r
+ area_size.y = jh::getIntFromJson(json_rect, "y");\r
+ area_size.w = jh::getIntFromJson(json_rect, "w");\r
+ area_size.h = jh::getIntFromJson(json_rect, "h");\r
+\r
+ this->area2size[area] = area_size;\r
+ }\r
+\r
+ // Check\r
+ for (const auto& itr : this->area2size)\r
+ {\r
+ HMI_DEBUG("area:%s x:%d y:%d w:%d h:%d",\r
+ itr.first.c_str(), itr.second.x, itr.second.y,\r
+ itr.second.w, itr.second.h);\r
+ }\r
+\r
+ // Release json_object\r
+ json_object_put(json_obj);\r
+\r
+ return WMError::SUCCESS;\r
+}\r
+\r
void LayerControl::dispatchILMEvent(ilmObjectType object, t_ilm_uint id, t_ilm_bool created)\r
{\r
;\r