mirror of
https://github.com/redstrate/Astra.git
synced 2025-05-17 06:37:45 +00:00
Adapt to the new steamwrap interface
This doesn't give actual encrypted Steam tickets yet, just the base infrastructure needed to communicate with steamwrap.
This commit is contained in:
parent
74a3c5f5d2
commit
7065cc041b
6 changed files with 51 additions and 31 deletions
|
@ -75,9 +75,6 @@ public:
|
|||
LauncherCore();
|
||||
~LauncherCore() override;
|
||||
|
||||
/// Initializes the Steamworks API.
|
||||
void initializeSteam();
|
||||
|
||||
/// Begins the login process.
|
||||
/// It's designed to be opaque as possible to the caller.
|
||||
/// \note The login process is asynchronous.
|
||||
|
@ -130,6 +127,7 @@ public:
|
|||
[[nodiscard]] AccountManager *accountManager();
|
||||
[[nodiscard]] Headline *headline() const;
|
||||
[[nodiscard]] QString cachedLogoImage() const;
|
||||
[[nodiscard]] SteamAPI *steamApi() const;
|
||||
|
||||
/**
|
||||
* @brief Opens the official launcher. Useful if Astra decides not to work that day!
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QCoroTask>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QObject>
|
||||
|
||||
class LauncherCore;
|
||||
|
@ -12,7 +14,10 @@ class SteamAPI : public QObject
|
|||
public:
|
||||
explicit SteamAPI(QObject *parent = nullptr);
|
||||
|
||||
void setLauncherMode(bool isLauncher);
|
||||
QCoro::Task<> initialize();
|
||||
QCoro::Task<> shutdown();
|
||||
QCoro::Task<QString> getTicket();
|
||||
|
||||
[[nodiscard]] bool isDeck() const;
|
||||
private:
|
||||
QNetworkAccessManager m_qnam;
|
||||
};
|
|
@ -45,6 +45,7 @@ LauncherCore::LauncherCore()
|
|||
m_profileManager = new ProfileManager(this);
|
||||
m_accountManager = new AccountManager(this);
|
||||
m_runner = new GameRunner(*this, this);
|
||||
m_steamApi = new SteamAPI(this);
|
||||
|
||||
connect(m_accountManager, &AccountManager::accountAdded, this, &LauncherCore::fetchAvatar);
|
||||
connect(m_accountManager, &AccountManager::accountLodestoneIdChanged, this, &LauncherCore::fetchAvatar);
|
||||
|
@ -79,12 +80,6 @@ LauncherCore::~LauncherCore()
|
|||
m_config->save();
|
||||
}
|
||||
|
||||
void LauncherCore::initializeSteam()
|
||||
{
|
||||
m_steamApi = new SteamAPI(this);
|
||||
m_steamApi->setLauncherMode(true);
|
||||
}
|
||||
|
||||
void LauncherCore::login(Profile *profile, const QString &username, const QString &password, const QString &oneTimePassword)
|
||||
{
|
||||
Q_ASSERT(profile != nullptr);
|
||||
|
@ -445,6 +440,11 @@ QString LauncherCore::cachedLogoImage() const
|
|||
return m_cachedLogoImage;
|
||||
}
|
||||
|
||||
SteamAPI *LauncherCore::steamApi() const
|
||||
{
|
||||
return m_steamApi;
|
||||
}
|
||||
|
||||
#ifdef BUILD_SYNC
|
||||
SyncManager *LauncherCore::syncManager() const
|
||||
{
|
||||
|
@ -480,10 +480,6 @@ QCoro::Task<> LauncherCore::beginLogin(LoginInformation &info)
|
|||
|
||||
Q_EMIT stageChanged(i18n("Launching game..."));
|
||||
|
||||
if (isSteam()) {
|
||||
m_steamApi->setLauncherMode(false);
|
||||
}
|
||||
|
||||
m_runner->beginGameExecutable(*info.profile, auth);
|
||||
}
|
||||
|
||||
|
|
|
@ -133,11 +133,6 @@ int main(int argc, char *argv[])
|
|||
|
||||
QQmlApplicationEngine engine;
|
||||
|
||||
const auto core = engine.singletonInstance<LauncherCore *>(QStringLiteral("zone.xiv.astra"), QStringLiteral("LauncherCore"));
|
||||
if (parser.isSet(steamOption)) {
|
||||
core->initializeSteam();
|
||||
}
|
||||
|
||||
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::quit, &app, &QCoreApplication::quit);
|
||||
|
||||
|
|
|
@ -232,9 +232,12 @@ QCoro::Task<std::optional<SquareEnixLogin::StoredInfo>> SquareEnixLogin::getStor
|
|||
if (m_info->profile->account()->config()->license() == Account::GameLicense::WindowsSteam) {
|
||||
query.addQueryItem(QStringLiteral("issteam"), QString::number(1));
|
||||
|
||||
// TODO: get steam ticket information from steam api
|
||||
query.addQueryItem(QStringLiteral("session_ticket"), QString::number(1));
|
||||
query.addQueryItem(QStringLiteral("ticket_size"), QString::number(1));
|
||||
co_await m_launcher.steamApi()->initialize();
|
||||
|
||||
auto ticket = co_await m_launcher.steamApi()->getTicket();
|
||||
|
||||
query.addQueryItem(QStringLiteral("session_ticket"), ticket);
|
||||
query.addQueryItem(QStringLiteral("ticket_size"), QString::number(ticket.length()));
|
||||
}
|
||||
|
||||
QUrl url;
|
||||
|
|
|
@ -2,23 +2,46 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "steamapi.h"
|
||||
|
||||
#include "launchercore.h"
|
||||
|
||||
#include <QCoroNetwork>
|
||||
|
||||
SteamAPI::SteamAPI(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
// TODO: stub
|
||||
}
|
||||
|
||||
void SteamAPI::setLauncherMode(bool isLauncher)
|
||||
QCoro::Task<> SteamAPI::initialize()
|
||||
{
|
||||
Q_UNUSED(isLauncher)
|
||||
// TODO: stub
|
||||
QUrl url;
|
||||
url.setScheme(QStringLiteral("http"));
|
||||
url.setHost(QStringLiteral("127.0.0.1"));
|
||||
url.setPort(50481);
|
||||
url.setPath(QStringLiteral("/init"));
|
||||
|
||||
Q_UNUSED(co_await m_qnam.post(QNetworkRequest(url), QByteArray{}))
|
||||
}
|
||||
|
||||
bool SteamAPI::isDeck() const
|
||||
QCoro::Task<> SteamAPI::shutdown()
|
||||
{
|
||||
// TODO: stub
|
||||
return false;
|
||||
QUrl url;
|
||||
url.setScheme(QStringLiteral("http"));
|
||||
url.setHost(QStringLiteral("127.0.0.1"));
|
||||
url.setPort(50481);
|
||||
url.setPath(QStringLiteral("/shutdown"));
|
||||
|
||||
Q_UNUSED(co_await m_qnam.post(QNetworkRequest(url), QByteArray{}))
|
||||
}
|
||||
|
||||
QCoro::Task<QString> SteamAPI::getTicket()
|
||||
{
|
||||
QUrl url;
|
||||
url.setScheme(QStringLiteral("http"));
|
||||
url.setHost(QStringLiteral("127.0.0.1"));
|
||||
url.setPort(50481);
|
||||
url.setPath(QStringLiteral("/ticket"));
|
||||
|
||||
auto reply = co_await m_qnam.get(QNetworkRequest(url));
|
||||
|
||||
co_return QStringLiteral("todo");
|
||||
}
|
Loading…
Add table
Reference in a new issue