pollymc/launcher/minecraft/launch/InjectAuthlib.h
fn2006 0170e8b177 Add Ely.by accounts (#17)
* Initial Ely.by support

* Fix profile pictures for Ely.by

* Disable upload and delete skin buttons for Ely.by accounts

* Port UltimMC's authlib injector to PollyMC
2022-08-19 12:22:38 +01:00

76 lines
1.9 KiB
C++

/* Copyright 2013-2021 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <launch/LaunchStep.h>
#include <QObjectPtr.h>
#include <LoggedProcess.h>
#include <java/JavaChecker.h>
#include <net/Mode.h>
#include <net/NetJob.h>
struct AuthlibInjector
{
QString javaArg;
AuthlibInjector(const QString arg)
{
javaArg = std::move(arg);
qDebug() << "NEW INJECTOR" << javaArg;
}
};
typedef std::shared_ptr<AuthlibInjector> AuthlibInjectorPtr;
// FIXME: stupid. should be defined by the instance type? or even completely abstracted away...
class InjectAuthlib : public LaunchStep
{
Q_OBJECT
public:
InjectAuthlib(LaunchTask *parent, AuthlibInjectorPtr *injector);
virtual ~InjectAuthlib(){};
void executeTask() override;
bool canAbort() const override;
void proceed() override;
void setAuthServer(QString server)
{
m_authServer = server;
};
void setOfflineMode(bool offline) {
m_offlineMode = offline;
}
public slots:
bool abort() override;
private slots:
void onVersionDownloadSucceeded();
void onDownloadSucceeded();
void onDownloadFailed(QString reason);
private:
shared_qobject_ptr<NetJob> jobPtr;
bool m_aborted = false;
bool m_offlineMode;
QString m_versionName;
QString m_authServer;
AuthlibInjectorPtr *m_injector;
};