wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
UpdateChecker.cpp File Reference
#include "App/Core/UpdateChecker.h"
#include <QDate>
#include <QDebug>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QSslError>
#include <QSysInfo>
#include <QVersionNumber>
#include "App/Core/Settings.h"
#include "App/Versions.h"
Include dependency graph for UpdateChecker.cpp:

Go to the source code of this file.

Functions

static QString currentPlatform ()
bool isMatchingReleaseAsset (const QString &name, const QString &platform, const QString &arch)
 True when a GitHub release asset filename is the binary for the given platform ("Windows"/"macOS"/"Linux") and CPU arch token (a QSysInfo arch name, e.g. "x86_64", "arm64").
bool isSafeGitHubUrl (const QUrl &url)
 True when url is safe to download from or hand to the OS's URL handler.
bool shouldOfferUpdate (const QString &tagName, const QVersionNumber &currentVersion, const QString &skippedVersion)
 True when the release tagged tagName should be offered to a user running currentVersion who may have suppressed skippedVersion.

Variables

static constexpr auto k_apiUrl = "https://api.github.com/repos/gibis-unifesp/wiredpanda/releases/latest"

Function Documentation

◆ currentPlatform()

QString currentPlatform ( )
static

Compile-time name of the platform this binary was built for, matching the platform token embedded in release asset filenames by deploy.yml.

Definition at line 24 of file UpdateChecker.cpp.

◆ isMatchingReleaseAsset()

bool isMatchingReleaseAsset ( const QString & name,
const QString & platform,
const QString & arch )

True when a GitHub release asset filename is the binary for the given platform ("Windows"/"macOS"/"Linux") and CPU arch token (a QSysInfo arch name, e.g. "x86_64", "arm64").

Exposed for testing. Linux (.AppImage) and Windows (.zip) releases ship a per-architecture asset, so the arch token must also match; macOS ships a single universal DMG and is matched on platform alone.

Definition at line 37 of file UpdateChecker.cpp.

◆ isSafeGitHubUrl()

bool isSafeGitHubUrl ( const QUrl & url)

True when url is safe to download from or hand to the OS's URL handler.

Exposed for testing. Requires scheme https and host github.com — the only shape GitHub's release JSON ever populates browser_download_url / html_url with (the CDN redirect for the actual asset happens only after fetching this URL, so the field itself never contains the CDN's host). Guards against a compromised/future-relaxed API response smuggling a file:// path (silently copies a local file into the Downloads folder) or an unexpected scheme/UNC-style URL into QDesktopServices::openUrl.

Definition at line 63 of file UpdateChecker.cpp.

◆ shouldOfferUpdate()

bool shouldOfferUpdate ( const QString & tagName,
const QVersionNumber & currentVersion,
const QString & skippedVersion )

True when the release tagged tagName should be offered to a user running currentVersion who may have suppressed skippedVersion.

Exposed for testing. A release is offered only when its tag parses to a valid version that is strictly newer than the running application and whose normalized string does not match the user's per-version suppression.

Definition at line 52 of file UpdateChecker.cpp.

Variable Documentation

◆ k_apiUrl

auto k_apiUrl = "https://api.github.com/repos/gibis-unifesp/wiredpanda/releases/latest"
staticconstexpr

Definition at line 20 of file UpdateChecker.cpp.

Referenced by UpdateChecker::checkForUpdates().