MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / ThreadFn

Method ThreadFn

Source/VersionChecker.cpp:130–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130void CVersionChecker::ThreadFn(bool startup, std::promise<std::optional<stVersionCheckResult>> p) noexcept try {
131 if (auto [json, verNum] = FindBestVersion(CHttpStringReader { }.ReadJson()); !json.empty()) {
132 auto [api, maj, min, rev] = verNum;
133 std::string verStr = std::to_string(api) + '.' + std::to_string(maj) + '.' + std::to_string(min) + '.' + std::to_string(rev);
134
135 std::string timeStr = json["published_at"];
136
137 std::string desc = json["body"];
138 if (auto pos = desc.find("\r\n\r\n"); pos != std::string::npos)
139 desc = desc.substr(pos + 4);
140 if (auto pos = desc.find("\r\n\r\n#"); pos != std::string::npos)
141 desc = desc.substr(0, pos);
142
143 std::string msg = "A new version of 0CC-FamiTracker is now available:\n\n";
144 msg += "Version " + verStr + " (released on " + timeStr + " %s)\n\n";
145 msg += "Pressing \"Yes\" will launch the Github web page for this release.";
146 if (startup)
147 msg += " (Version checking on startup may be disabled in the configuration menu.)";
148 std::string url = "https://github.com/HertzDevil/0CC-FamiTracker/releases/tag/v%s" + verStr;
149
150 p.set_value(stVersionCheckResult {std::move(msg), std::move(url), MB_YESNO | MB_ICONINFORMATION});
151 }
152 else
153 p.set_value(std::nullopt);
154}
155catch (...) {
156 p.set_value(std::nullopt);
157// p.set_value(stVersionCheckResult {
158// "Unable to get version information from the source repository.", "", MB_ICONERROR});
159}

Callers

nothing calls this directly

Calls 3

FindBestVersionFunction · 0.85
ReadJsonMethod · 0.80
emptyMethod · 0.80

Tested by

no test coverage detected