Add loadLayerSetting
[apps/agl-service-windowmanager-2017.git] / src / wm_layer_control.cpp
index a14c334..b15ebbb 100644 (file)
@@ -118,6 +118,34 @@ void LayerControl::undoUpdate() {}
 \r
 WMError LayerControl::loadLayerSetting(const string &path)\r
 {\r
+    HMI_DEBUG("loading WMLayer(Application Containers) Setting from %s", path);\r
+\r
+    json_object *json_obj, *json_cfg;\r
+    int ret = jh::inputJsonFilie(path.c_str(), &json_obj);\r
+    if (0 > ret)\r
+    {\r
+        HMI_DEBUG("Could not open %s, so use default area information", path.c_str());\r
+        return WMError::FAIL;\r
+    }\r
+    HMI_INFO("json_obj dump:%s", json_object_get_string(json_obj));\r
+\r
+    if (!json_object_object_get_ex(json_obj, "mappings", &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
+\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
+        this->wm_layers.emplace_back(std::make_shared<WMLayer>(json_tmp));\r
+    }\r
+\r
     return WMError::SUCCESS;\r
 }\r
 \r
@@ -128,7 +156,7 @@ WMError LayerControl::loadAreaDb(const std::string& path)
     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
+        HMI_DEBUG("Could not open %s, so use default area information", path.c_str());\r
         return WMError::FAIL;\r
     }\r
     HMI_INFO("json_obj dump:%s", json_object_get_string(json_obj));\r
@@ -143,7 +171,6 @@ WMError LayerControl::loadAreaDb(const std::string& path)
 \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