Cockatrice/oracle/src/oraclewizard.h
BruebachL 96b0888a73
Some checks are pending
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 cover (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 26 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Desktop / Prune caches (push) Waiting to run
Build Docker / Servatrice (arm) (push) Waiting to run
Build Docker / Servatrice (x86) (push) Waiting to run
Build Docker / Publish multi-platform Servatrice image (push) Blocked by required conditions
[Oracle] Don't report a cancelled card database update as successful (#7082)
* [Oracle] Don't report a cancelled card database update as successful (#3470)

Took 3 minutes

* [Oracle] Only report cancel when nothing was saved yet

Rejecting the wizard after SaveSetsPage or a download page already
wrote the database to disk still replaced cards.xml on disk, but
wasCancelled() forced exit code 1 so Cockatrice skipped the reload.
Track successful saves with OracleWizard::markDatabaseSaved() and only
treat a cancel as a failure when nothing was saved.

* [Oracle] Restore updater stderr in card update error dialog

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-10-15 15:21:07 +02:00

99 lines
2.3 KiB
C++

#ifndef ORACLEWIZARD_H
#define ORACLEWIZARD_H
#include <QByteArray>
#include <QString>
#include <QWizard>
#include <qtmetamacros.h>
#include <utility>
class QNetworkAccessManager;
class OracleImporter;
class QLocalServer;
class QSettings;
class QWidget;
class OracleWizard : public QWizard
{
Q_OBJECT
public:
explicit OracleWizard(QWidget *parent = nullptr);
void accept() override;
void reject() override;
bool wasCancelled()
{
return cancelled;
}
/** @brief Records that the card database was written to disk, so a later cancel still counts as an update. */
void markDatabaseSaved()
{
databaseSaved = true;
}
bool hasSavedDatabase()
{
return databaseSaved;
}
void enableButtons();
void disableButtons();
void retranslateUi();
void setTokensData(QByteArray _tokensData)
{
tokensData = std::move(_tokensData);
}
bool hasTokensData()
{
return !tokensData.isEmpty();
}
void setCardSourceUrl(const QString &sourceUrl)
{
cardSourceUrl = sourceUrl;
}
void setCardSourceVersion(const QString &sourceVersion)
{
cardSourceVersion = sourceVersion;
}
const QString &getCardSourceUrl() const
{
return cardSourceUrl;
}
const QString &getCardSourceVersion() const
{
return cardSourceVersion;
}
bool saveTokensToFile(const QString &fileName);
void runInBackground();
public:
OracleImporter *importer;
QSettings *settings;
QNetworkAccessManager *nam;
bool downloadedPlainXml = false;
QByteArray xmlData;
bool backgroundMode = false;
private slots:
void updateLanguage();
void handleRaiseRequest();
private:
QByteArray tokensData;
QString cardSourceUrl;
QString cardSourceVersion;
bool cancelled = false;
bool databaseSaved = false;
void migrateOracleSettings();
/**
* @brief Starts the local socket the hosting Cockatrice client uses to bring this wizard forward.
*/
void startRaiseServer();
/** @brief Shows, raises and activates the wizard window. */
void raiseWizard();
QLocalServer *raiseServer = nullptr; ///< listens for raise requests from the hosting client
protected:
void changeEvent(QEvent *event) override;
};
#endif