feat: track capabilities of application
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
906f26698b
commit
4103948132
@ -1569,6 +1569,16 @@ shared_qobject_ptr<Meta::Index> Application::metadataIndex()
|
|||||||
return m_metadataIndex;
|
return m_metadataIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Application::Capabilities Application::currentCapabilities()
|
||||||
|
{
|
||||||
|
Capabilities c;
|
||||||
|
if (!getMSAClientID().isEmpty())
|
||||||
|
c |= SupportsMSA;
|
||||||
|
if (!getFlameAPIKey().isEmpty())
|
||||||
|
c |= SupportsFlame;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
QString Application::getJarPath(QString jarFile)
|
QString Application::getJarPath(QString jarFile)
|
||||||
{
|
{
|
||||||
QStringList potentialPaths = {
|
QStringList potentialPaths = {
|
||||||
|
@ -93,6 +93,14 @@ public:
|
|||||||
Initialized
|
Initialized
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Capability {
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
SupportsMSA = 1 << 0,
|
||||||
|
SupportsFlame = 1 << 1,
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(Capabilities, Capability)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Application(int &argc, char **argv);
|
Application(int &argc, char **argv);
|
||||||
virtual ~Application();
|
virtual ~Application();
|
||||||
@ -157,6 +165,8 @@ public:
|
|||||||
|
|
||||||
shared_qobject_ptr<Meta::Index> metadataIndex();
|
shared_qobject_ptr<Meta::Index> metadataIndex();
|
||||||
|
|
||||||
|
Capabilities currentCapabilities();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Finds and returns the full path to a jar file.
|
* Finds and returns the full path to a jar file.
|
||||||
* Returns a null-string if it could not be found.
|
* Returns a null-string if it could not be found.
|
||||||
|
@ -117,7 +117,8 @@ void Download::executeTask()
|
|||||||
}
|
}
|
||||||
|
|
||||||
request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8());
|
request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8());
|
||||||
if (request.url().host().contains("api.curseforge.com")) {
|
if (APPLICATION->currentCapabilities() & Application::SupportsFlame
|
||||||
|
&& request.url().host().contains("api.curseforge.com")) {
|
||||||
request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8());
|
request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -174,7 +174,8 @@ namespace Net {
|
|||||||
}
|
}
|
||||||
|
|
||||||
request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8());
|
request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8());
|
||||||
if (request.url().host().contains("api.curseforge.com")) {
|
if (APPLICATION->currentCapabilities() & Application::SupportsFlame
|
||||||
|
&& request.url().host().contains("api.curseforge.com")) {
|
||||||
request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8());
|
request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8());
|
||||||
}
|
}
|
||||||
//TODO other types of post requests ?
|
//TODO other types of post requests ?
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <icons/IconList.h>
|
#include <icons/IconList.h>
|
||||||
#include <InstanceList.h>
|
#include <InstanceList.h>
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
#include "ProgressDialog.h"
|
#include "ProgressDialog.h"
|
||||||
#include "ReviewMessageBox.h"
|
#include "ReviewMessageBox.h"
|
||||||
|
|
||||||
@ -100,13 +101,13 @@ void ModDownloadDialog::accept()
|
|||||||
|
|
||||||
QList<BasePage *> ModDownloadDialog::getPages()
|
QList<BasePage *> ModDownloadDialog::getPages()
|
||||||
{
|
{
|
||||||
modrinthPage = new ModrinthModPage(this, m_instance);
|
QList<BasePage *> pages;
|
||||||
flameModPage = new FlameModPage(this, m_instance);
|
|
||||||
return
|
pages.append(new ModrinthModPage(this, m_instance));
|
||||||
{
|
if (APPLICATION->currentCapabilities() & Application::SupportsFlame)
|
||||||
modrinthPage,
|
pages.append(new FlameModPage(this, m_instance));
|
||||||
flameModPage
|
|
||||||
};
|
return pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModDownloadDialog::addSelectedMod(const QString& name, ModDownloadTask* task)
|
void ModDownloadDialog::addSelectedMod(const QString& name, ModDownloadTask* task)
|
||||||
|
@ -48,9 +48,6 @@ private:
|
|||||||
QDialogButtonBox * m_buttons = nullptr;
|
QDialogButtonBox * m_buttons = nullptr;
|
||||||
QVBoxLayout *m_verticalLayout = nullptr;
|
QVBoxLayout *m_verticalLayout = nullptr;
|
||||||
|
|
||||||
|
|
||||||
ModrinthModPage *modrinthPage = nullptr;
|
|
||||||
FlameModPage *flameModPage = nullptr;
|
|
||||||
QHash<QString, ModDownloadTask*> modTask;
|
QHash<QString, ModDownloadTask*> modTask;
|
||||||
BaseInstance *m_instance;
|
BaseInstance *m_instance;
|
||||||
};
|
};
|
||||||
|
@ -124,20 +124,21 @@ void NewInstanceDialog::accept()
|
|||||||
|
|
||||||
QList<BasePage *> NewInstanceDialog::getPages()
|
QList<BasePage *> NewInstanceDialog::getPages()
|
||||||
{
|
{
|
||||||
|
QList<BasePage *> pages;
|
||||||
|
|
||||||
importPage = new ImportPage(this);
|
importPage = new ImportPage(this);
|
||||||
flamePage = new FlamePage(this);
|
|
||||||
auto technicPage = new TechnicPage(this);
|
pages.append(new VanillaPage(this));
|
||||||
return
|
pages.append(importPage);
|
||||||
{
|
pages.append(new AtlPage(this));
|
||||||
new VanillaPage(this),
|
if (APPLICATION->currentCapabilities() & Application::SupportsFlame)
|
||||||
importPage,
|
pages.append(new FlamePage(this));
|
||||||
new AtlPage(this),
|
pages.append(new FtbPage(this));
|
||||||
flamePage,
|
pages.append(new LegacyFTB::Page(this));
|
||||||
new FtbPage(this),
|
pages.append(new ModrinthPage(this));
|
||||||
new LegacyFTB::Page(this),
|
pages.append(new TechnicPage(this));
|
||||||
new ModrinthPage(this),
|
|
||||||
technicPage
|
return pages;
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NewInstanceDialog::dialogTitle()
|
QString NewInstanceDialog::dialogTitle()
|
||||||
|
@ -69,7 +69,6 @@ private:
|
|||||||
|
|
||||||
QString InstIconKey;
|
QString InstIconKey;
|
||||||
ImportPage *importPage = nullptr;
|
ImportPage *importPage = nullptr;
|
||||||
FlamePage *flamePage = nullptr;
|
|
||||||
std::unique_ptr<InstanceTask> creationTask;
|
std::unique_ptr<InstanceTask> creationTask;
|
||||||
|
|
||||||
bool importIcon = false;
|
bool importIcon = false;
|
||||||
|
@ -96,7 +96,7 @@ AccountListPage::AccountListPage(QWidget *parent)
|
|||||||
updateButtonStates();
|
updateButtonStates();
|
||||||
|
|
||||||
// Xbox authentication won't work without a client identifier, so disable the button if it is missing
|
// Xbox authentication won't work without a client identifier, so disable the button if it is missing
|
||||||
if (APPLICATION->getMSAClientID().isEmpty()) {
|
if (APPLICATION->currentCapabilities() & Application::SupportsMSA) {
|
||||||
ui->actionAddMicrosoft->setVisible(false);
|
ui->actionAddMicrosoft->setVisible(false);
|
||||||
ui->actionAddMicrosoft->setToolTip(tr("No Microsoft Authentication client ID was set."));
|
ui->actionAddMicrosoft->setToolTip(tr("No Microsoft Authentication client ID was set."));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user