1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-21 20:27:45 +00:00
astra/launcher/include/charactersync.h
Joshua Goins 807cf0e062 Improve character sync error handling, and the sync itself
Ported from libQuotient's invokeLogin to our own custom one, so we can
avoid the initial sync until login. Then, make sure we find the room
*after* the sync, not before it.

Also since I wiped the media cache from my server, I hit a crash since
it tried to open an invalid ZIP file. Now we can handle that.
2024-11-09 15:47:34 -05:00

34 lines
960 B
C++

// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <qcorotask.h>
#include "launchercore.h"
class LauncherCore;
class QNetworkReply;
/**
* @brief Works in tandem with @c SyncManager to synchronizes character data.
*/
class CharacterSync : public QObject
{
Q_OBJECT
public:
explicit CharacterSync(Account &account, LauncherCore &launcher, QObject *parent = nullptr);
/// Checks and synchronizes character files as necessary.
/// \param initialSync Whether this is the initial sync on game start.
/// \return False if the synchronization failed.
QCoro::Task<bool> sync(bool initialSync = true);
private:
QCoro::Task<void> uploadCharacterData(const QDir &dir, const QString &id);
QCoro::Task<bool> downloadCharacterData(const QDir &dir, const QString &id, const QString &contentUri);
LauncherCore &launcher;
Account &m_account;
};