|
101 | 101 | Notifies the UI that a new version is available. |
102 | 102 | --- /dev/null |
103 | 103 | +++ b/third_party/winsparkle/src/ui_headless.cpp |
104 | | -@@ -0,0 +1,130 @@ |
| 104 | +@@ -0,0 +1,148 @@ |
105 | 105 | +// Copyright 2026 The Helium Authors |
106 | 106 | +// You can use, redistribute, and/or modify this source code under |
107 | 107 | +// the terms of the GPL-3.0 license that can be found in the LICENSE file. |
|
118 | 118 | +#include "settings.h" |
119 | 119 | +#include "threads.h" |
120 | 120 | +#include "ui.h" |
| 121 | ++#include "updatechecker.h" |
121 | 122 | +#include "updatedownloader.h" |
122 | 123 | +#include "utils.h" |
123 | 124 | +#include "winsparkle.h" |
|
130 | 131 | + |
131 | 132 | +CriticalSection g_downloaderCS; |
132 | 133 | +std::unique_ptr<UpdateDownloader> g_downloader; |
| 134 | ++std::string g_downloadedVersion; |
| 135 | ++ |
| 136 | ++bool UpdateAlreadyDownloaded(const std::string& version) { |
| 137 | ++ CriticalSectionLocker lock(g_downloaderCS); |
| 138 | ++ return !g_downloadedVersion.empty() && |
| 139 | ++ UpdateChecker::CompareVersions(version, g_downloadedVersion) <= 0; |
| 140 | ++} |
| 141 | ++ |
| 142 | ++void RememberDownloadedUpdate(const std::string& version) { |
| 143 | ++ CriticalSectionLocker lock(g_downloaderCS); |
| 144 | ++ g_downloadedVersion = version; |
| 145 | ++} |
133 | 146 | + |
134 | 147 | +// Terminate and destroy any outstanding downloader. MUST NOT be called |
135 | 148 | +// from the downloader's own thread |
|
184 | 197 | + |
185 | 198 | +// static |
186 | 199 | +void UI::NotifyUpdateAvailable(const Appcast& info, bool) { |
| 200 | ++ if (UpdateAlreadyDownloaded(info.Version)) { |
| 201 | ++ return; |
| 202 | ++ } |
| 203 | ++ |
187 | 204 | + ApplicationController::NotifyUpdateFound(); |
188 | 205 | + |
189 | 206 | + if (!info.HasDownload()) { |
|
211 | 228 | + |
212 | 229 | + switch (ApplicationController::UserRunInstallerCallback(updateFile.c_str())) { |
213 | 230 | + case 1: |
| 231 | ++ RememberDownloadedUpdate(appcast.Version); |
214 | 232 | + break; |
215 | 233 | + case WINSPARKLE_RETURN_ERROR: |
216 | 234 | + NotifyUpdateError("the installer callback reported a failure"); |
|
0 commit comments