app: use config to determine json config file names
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>
Tue, 1 Aug 2017 15:15:19 +0000 (17:15 +0200)
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>
Tue, 8 Aug 2017 15:24:00 +0000 (17:24 +0200)
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
src/app.cpp
src/app.hpp

index 93877ba..aa3f644 100644 (file)
@@ -114,27 +114,34 @@ App::App(wl::display *d)
      display{d},
      controller{},
      outputs(),
+     config(),
      layouts(),
      layers() {
    assert(g_app == nullptr);
    g_app = this;
 
-   {
-      auto l = load_layer_map("../ids.json");
-      if (l.is_ok()) {
-         this->layers = l.unwrap();
-      } else {
-         logerror("%s", l.err().value());
+   try {
+      {
+         auto l = load_layer_map(
+                 this->config.get_string("layers.json").value().c_str());
+         if (l.is_ok()) {
+            this->layers = l.unwrap();
+         } else {
+            logerror("%s", l.err().value());
+         }
       }
-   }
 
-   {
-      auto l = load_layout("../layout.json");
-      if (l.is_ok()) {
-         this->layouts = l.unwrap();
-      } else {
-         logerror("%s", l.err().value());
+      {
+         auto l = load_layout(
+                 this->config.get_string("layout.json").value().c_str());
+         if (l.is_ok()) {
+            this->layouts = l.unwrap();
+         } else {
+            logerror("%s", l.err().value());
+         }
       }
+   } catch (std::exception &e) {
+      logerror("Loading of configuration failed: %s", e.what());
    }
 }
 
index 7b9164f..5bbd2db 100644 (file)
@@ -14,6 +14,7 @@
 #include "layout.hpp"
 #include "result.hpp"
 #include "wayland.hpp"
+#include "config.hpp"
 
 namespace wl {
 struct display;
@@ -35,6 +36,8 @@ struct App {
    std::unique_ptr<struct genivi::controller> controller;
    std::vector<std::unique_ptr<struct wl::output>> outputs;
 
+   struct config config;
+
    layouts_type layouts;
    layer_map layers;