diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-03-07 10:31:22 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-03-07 10:31:22 -0500 |
| commit | d0029a806b8b6d244a6a3ec5b243303a8203cdd5 (patch) | |
| tree | 978cfb8fc9ec880a99b0a4c0c1d8ffa2503db622 /src/tracker_config.cpp | |
| parent | 10d6eff4dc1ab7a79920721c0fe2ed371d7dfaf3 (diff) | |
| download | lingo-ap-tracker-d0029a806b8b6d244a6a3ec5b243303a8203cdd5.tar.gz lingo-ap-tracker-d0029a806b8b6d244a6a3ec5b243303a8203cdd5.tar.bz2 lingo-ap-tracker-d0029a806b8b6d244a6a3ec5b243303a8203cdd5.zip | |
Added connection history
Diffstat (limited to 'src/tracker_config.cpp')
| -rw-r--r-- | src/tracker_config.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
| diff --git a/src/tracker_config.cpp b/src/tracker_config.cpp index b0f4ac4..85164d5 100644 --- a/src/tracker_config.cpp +++ b/src/tracker_config.cpp | |||
| @@ -10,13 +10,23 @@ void TrackerConfig::Load() { | |||
| 10 | try { | 10 | try { |
| 11 | YAML::Node file = YAML::LoadFile(filename_); | 11 | YAML::Node file = YAML::LoadFile(filename_); |
| 12 | 12 | ||
| 13 | ap_server = file["ap_server"].as<std::string>(); | 13 | connection_details.ap_server = file["ap_server"].as<std::string>(); |
| 14 | ap_player = file["ap_player"].as<std::string>(); | 14 | connection_details.ap_player = file["ap_player"].as<std::string>(); |
| 15 | ap_password = file["ap_password"].as<std::string>(); | 15 | connection_details.ap_password = file["ap_password"].as<std::string>(); |
| 16 | asked_to_check_for_updates = file["asked_to_check_for_updates"].as<bool>(); | 16 | asked_to_check_for_updates = file["asked_to_check_for_updates"].as<bool>(); |
| 17 | should_check_for_updates = file["should_check_for_updates"].as<bool>(); | 17 | should_check_for_updates = file["should_check_for_updates"].as<bool>(); |
| 18 | hybrid_areas = file["hybrid_areas"].as<bool>(); | 18 | hybrid_areas = file["hybrid_areas"].as<bool>(); |
| 19 | show_hunt_panels = file["show_hunt_panels"].as<bool>(); | 19 | show_hunt_panels = file["show_hunt_panels"].as<bool>(); |
| 20 | |||
| 21 | if (file["connection_history"]) { | ||
| 22 | for (const auto& connection : file["connection_history"]) { | ||
| 23 | connection_history.push_back(ConnectionDetails{ | ||
| 24 | .ap_server = connection["ap_server"].as<std::string>(), | ||
| 25 | .ap_player = connection["ap_player"].as<std::string>(), | ||
| 26 | .ap_password = connection["ap_password"].as<std::string>() | ||
| 27 | }); | ||
| 28 | } | ||
| 29 | } | ||
| 20 | } catch (const std::exception&) { | 30 | } catch (const std::exception&) { |
| 21 | // It's fine if the file can't be loaded. | 31 | // It's fine if the file can't be loaded. |
| 22 | } | 32 | } |
| @@ -24,13 +34,23 @@ void TrackerConfig::Load() { | |||
| 24 | 34 | ||
| 25 | void TrackerConfig::Save() { | 35 | void TrackerConfig::Save() { |
| 26 | YAML::Node output; | 36 | YAML::Node output; |
| 27 | output["ap_server"] = ap_server; | 37 | output["ap_server"] = connection_details.ap_server; |
| 28 | output["ap_player"] = ap_player; | 38 | output["ap_player"] = connection_details.ap_player; |
| 29 | output["ap_password"] = ap_password; | 39 | output["ap_password"] = connection_details.ap_password; |
| 30 | output["asked_to_check_for_updates"] = asked_to_check_for_updates; | 40 | output["asked_to_check_for_updates"] = asked_to_check_for_updates; |
| 31 | output["should_check_for_updates"] = should_check_for_updates; | 41 | output["should_check_for_updates"] = should_check_for_updates; |
| 32 | output["hybrid_areas"] = hybrid_areas; | 42 | output["hybrid_areas"] = hybrid_areas; |
| 33 | output["show_hunt_panels"] = show_hunt_panels; | 43 | output["show_hunt_panels"] = show_hunt_panels; |
| 44 | |||
| 45 | output.remove("connection_history"); | ||
| 46 | for (const ConnectionDetails& details : connection_history) { | ||
| 47 | YAML::Node connection; | ||
| 48 | connection["ap_server"] = details.ap_server; | ||
| 49 | connection["ap_player"] = details.ap_player; | ||
| 50 | connection["ap_password"] = details.ap_password; | ||
| 51 | |||
| 52 | output["connection_history"].push_back(connection); | ||
| 53 | } | ||
| 34 | 54 | ||
| 35 | std::ofstream filewriter(filename_); | 55 | std::ofstream filewriter(filename_); |
| 36 | filewriter << output; | 56 | filewriter << output; |
