X-Git-Url: http://pilppa.org/gitweb/?p=libplp.git;a=blobdiff_plain;f=src%2FDeviceConfig.cc;h=b663259088aeba93fa22ff566e074dd1746989d8;hp=904257ec7f229743831c97a4d1409062b7478039;hb=23a30eb765fc6aaf347da839567140ae41e8cc6b;hpb=6eb270983373b863deeca1497b56fcb1d23f2c2b diff --git a/src/DeviceConfig.cc b/src/DeviceConfig.cc index 904257e..b663259 100644 --- a/src/DeviceConfig.cc +++ b/src/DeviceConfig.cc @@ -7,6 +7,7 @@ #include "DeviceConfig.hh" +#include #include #include @@ -34,7 +35,7 @@ DeviceConfig::DeviceConfig(string device_id_param) { device_id = device_id_param; uci_handle = load_device_config(device_id_param); if (uci_handle != NULL) { - device_type = get_cfg_value(DEVICE_CONFIG_VALUE_KEY__TYPE); + device_type = get_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE); } else { log_error("Could not read device configuration.\n"); @@ -85,7 +86,7 @@ string DeviceConfig::get_file_name(string device_id_param) { return ret_val; } -string DeviceConfig::get_cfg_value(string key) { +string DeviceConfig::get_config_value(string key) { struct uci_section *section; struct uci_option *option; string ret_val; @@ -113,18 +114,21 @@ string DeviceConfig::get_cfg_value(string key) { return ret_val; } -void DeviceConfig::set_cfg_value(string key, string value) { +void DeviceConfig::set_config_value(string key, + string value, + bool save_immediately) { string cfg_dir; string cfg_fl; cfg_dir = get_dir_name(device_id); cfg_fl = DEVICE_CONFIG__FILE_NAME; - set_config_value(cfg_dir.c_str(), + set_config_value_to_section(cfg_dir.c_str(), cfg_fl.c_str(), DEVICE_CONFIG__SECTION_TYPE, DEVICE_CONFIG__SECTION_NAME, key.c_str(), - value.c_str()); + value.c_str(), + save_immediately); } EnumSummaryCalculationType DeviceConfig::get_summary_calculation_type() { @@ -166,13 +170,13 @@ ConfigHandle *DeviceConfig::load_device_config(string device_id_param) { } else { log_debug("Failed to load device configuration: %s, err code: %d.\n", cfg_fl.c_str(), UCI_OK); - set_cfg_value(DEVICE_CONFIG_VALUE_KEY__TYPE, ""); + set_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE, "", true); uci_free_context(ctx); } } else { log_error("Failed to load device device configuration, memory allocation error.\n"); - set_cfg_value(DEVICE_CONFIG_VALUE_KEY__TYPE, ""); + set_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE, "", true); } } else {