Rule management added.
[platform/core/security/suspicious-activity-monitor.git] / daemon / settingshandler.cpp
index 7d1023f..b31a455 100644 (file)
@@ -35,20 +35,22 @@ const std::string TIMEOUT_KEY{"timeout"};
 const std::string LOCK_KEY{"lock"};
 }
 
+namespace agent
+{
+
 const std::string SettingsHandler::SETTINGS_EVENT_TYPE{"settings"};
 
-SettingsHandler::SettingsHandler(NetworkManager::Connection& conn): NetworkManager::EventListener(conn, SETTINGS_EVENT_TYPE)
+SettingsHandler::SettingsHandler(communication::Connection& conn): communication::EventListener(conn, SETTINGS_EVENT_TYPE)
 {
 }
 
-void SettingsHandler::accept(NetworkManager::Event& event)
+void SettingsHandler::accept(communication::Event& event)
 {
     try {
         Json::Reader reader;
         Json::Value root;
 
         if (reader.parse(event.getContent(), root)) {
-
             bool modified = false;
 
             if (root.isMember(TIMEOUT_KEY)) {
@@ -56,7 +58,8 @@ void SettingsHandler::accept(NetworkManager::Event& event)
 
                 if (timeout > 0) {
                     LOG_D(TAG, "SettingsHandler: keepalive timeout set to %d", timeout);
-                    NetworkManager::Settings::instance().setKeepAliveTimeout(std::chrono::milliseconds(timeout));
+                    Settings::instance().setKeepAliveTimeout(std::chrono::milliseconds(timeout));
+                    connection.setkeepAliveTimeout(Settings::instance().getKeepAliveTimeout());
                     modified = true;
                 } else {
                     LOG_E(TAG, "SettingsHandler: wrong timeout value %d", timeout);
@@ -66,12 +69,12 @@ void SettingsHandler::accept(NetworkManager::Event& event)
             if (root.isMember(LOCK_KEY)) {
                 bool lock = root[LOCK_KEY].asBool();
                 LOG_D(TAG, "SettingsHandler: lock set to %d", int(lock));
-                NetworkManager::Settings::instance().setLock(lock);
+                Settings::instance().setLock(lock);
                 modified = true;
             }
 
             if (modified) {
-                NetworkManager::Settings::instance().save();
+                Settings::instance().save();
             }
 
             event.confirm();
@@ -80,3 +83,5 @@ void SettingsHandler::accept(NetworkManager::Event& event)
         LOG_E(TAG, "SettingsHandler: %s", e.what());
     }
 }
+
+} // namespace agent