servatrice/cockatrice/src/releasechannel.h
ctrlaltca ed70099e36 Rework of the card database, xml format and oracle parser (#3511)
* CardDB: merge all card properties in a new structure

* Pre Json parser changes

 * Cockatrice: use qt's builtin json support
 * Move qt-json src dir from cockatrice to oracle
 * Add dummy cockatricexml4 parser (yet to be implemented)

* Implement a new parser and xml format

 * cockatricexml4: new xml parser following the "generic properties hash" pattern;
 * oracleimporter: refactor the parsing code to better adapt to cockatricexml4; rewrote split cards parsing
 * carddb: change "colors" from a stringlist to a string
 * carddb: move the getMainCardType() method to the cockatricexml3 parser
 *

* CardInfo: show all properties (stil missing: nice name + translation)

* Rework the "add related card" feature so that it doesn't change the card name in the carddb

Also, fix token count display

* Picture loader: Added support for transform cards

* Fix side information for flip cards

Mtgjson uses side a/b for flip cards, while scryfall doesn't

* Pictureloader: dynamic tag resolution from card properties

Examples old => new
* !cardid! => !set:muid!
* !uuid!   => !set:uuid!
* !collectornumber! => !set:num!
New examples:
 * !prop:type!
 * !prop:manacost!

* Start moving mtg-related property names to a specific file

* Clangify

* Fix tests

* Make gcc an happy puppy

* Revert "Make gcc an happy puppy"

This reverts commit 446ec5f27516c4d3b32dbfc79557f4827c5c5bdf.

* Some gcc fixes

* Share set list between different db parsers, so they won't overwrite one each other

* All glory to the hypnoclangifier!

* Fix test compilation

* Cleanup edited files in the prior PR. (#3519)

* Cleanup edited files in the prior PR.

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Fix includes

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Update carddatabase.h
2019-01-23 18:17:10 -05:00

157 lines
No EOL
3.2 KiB
C++

#ifndef RELEASECHANNEL_H
#define RELEASECHANNEL_H
#include <QDate>
#include <QObject>
#include <QString>
#include <QVariantMap>
#include <utility>
class QNetworkReply;
class QNetworkAccessManager;
class Release
{
friend class StableReleaseChannel;
friend class BetaReleaseChannel;
public:
Release() = default;
~Release() = default;
private:
QString name, descriptionUrl, downloadUrl, commitHash;
QDate publishDate;
bool compatibleVersionFound = false;
protected:
void setName(QString _name)
{
name = std::move(_name);
}
void setDescriptionUrl(QString _descriptionUrl)
{
descriptionUrl = std::move(_descriptionUrl);
}
void setDownloadUrl(QString _downloadUrl)
{
downloadUrl = std::move(_downloadUrl);
compatibleVersionFound = true;
}
void setCommitHash(QString _commitHash)
{
commitHash = std::move(_commitHash);
}
void setPublishDate(QDate _publishDate)
{
publishDate = _publishDate;
}
public:
QString getName() const
{
return name;
}
QString getDescriptionUrl() const
{
return descriptionUrl;
}
QString getDownloadUrl() const
{
return downloadUrl;
}
QString getCommitHash() const
{
return commitHash;
}
QDate getPublishDate() const
{
return publishDate;
}
bool isCompatibleVersionFound() const
{
return compatibleVersionFound;
}
};
class ReleaseChannel : public QObject
{
Q_OBJECT
public:
ReleaseChannel();
~ReleaseChannel() override;
protected:
// shared by all instances
static int sharedIndex;
int index;
QNetworkAccessManager *netMan;
QNetworkReply *response;
Release *lastRelease;
protected:
static bool downloadMatchesCurrentOS(const QString &fileName);
virtual QString getReleaseChannelUrl() const = 0;
public:
int getIndex() const
{
return index;
}
Release *getLastRelease()
{
return lastRelease;
}
virtual QString getManualDownloadUrl() const = 0;
virtual QString getName() const = 0;
void checkForUpdates();
signals:
void finishedCheck(bool needToUpdate, bool isCompatible, Release *release);
void error(QString errorString);
protected slots:
virtual void releaseListFinished() = 0;
virtual void fileListFinished() = 0;
};
class StableReleaseChannel : public ReleaseChannel
{
Q_OBJECT
public:
StableReleaseChannel() = default;
~StableReleaseChannel() override = default;
QString getManualDownloadUrl() const override;
QString getName() const override;
protected:
QString getReleaseChannelUrl() const override;
protected slots:
void releaseListFinished() override;
void tagListFinished();
void fileListFinished() override;
};
class BetaReleaseChannel : public ReleaseChannel
{
Q_OBJECT
public:
BetaReleaseChannel() = default;
~BetaReleaseChannel() override = default;
QString getManualDownloadUrl() const override;
QString getName() const override;
protected:
QString getReleaseChannelUrl() const override;
protected slots:
void releaseListFinished() override;
void fileListFinished() override;
};
#endif