ddnet/src/engine/client/updater.h

80 lines
1.8 KiB
C
Raw Normal View History

#ifndef ENGINE_CLIENT_UPDATER_H
#define ENGINE_CLIENT_UPDATER_H
2014-12-31 14:29:34 +00:00
#include <engine/updater.h>
#include <engine/fetcher.h>
#include <map>
2014-12-31 14:29:34 +00:00
#include <string>
2015-03-13 14:13:19 +00:00
#define CLIENT_EXEC "DDNet"
#define SERVER_EXEC "DDNet-Server"
#if defined(CONF_FAMILY_WINDOWS)
#define PLAT_EXT ".exe"
#define PLAT_NAME CONF_PLATFORM_STRING
#elif defined(CONF_FAMILY_UNIX)
#define PLAT_EXT ""
#if defined(CONF_ARCH_IA32)
#define PLAT_NAME CONF_PLATFORM_STRING "-x86"
#elif defined(CONF_ARCH_AMD64)
#define PLAT_NAME CONF_PLATFORM_STRING "-x86_64"
2015-03-14 10:29:20 +00:00
#else
#define PLAT_NAME CONF_PLATFORM_STRING "-unsupported"
2015-03-13 14:13:19 +00:00
#endif
2015-03-14 10:31:06 +00:00
#else
#define PLAT_EXT ""
#define PLAT_NAME "unsupported-unsupported"
2015-03-13 14:13:19 +00:00
#endif
#define PLAT_CLIENT_DOWN CLIENT_EXEC "-" PLAT_NAME PLAT_EXT
#define PLAT_SERVER_DOWN SERVER_EXEC "-" PLAT_NAME PLAT_EXT
#define PLAT_CLIENT_EXEC CLIENT_EXEC PLAT_EXT
#define PLAT_SERVER_EXEC SERVER_EXEC PLAT_EXT
class CUpdater : public IUpdater
2014-12-31 14:29:34 +00:00
{
2015-03-13 14:13:19 +00:00
class IClient *m_pClient;
class IStorage *m_pStorage;
class IFetcher *m_pFetcher;
bool m_IsWinXP;
2015-03-13 14:13:19 +00:00
int m_State;
char m_Status[256];
int m_Percent;
char m_aLastFile[256];
bool m_ClientUpdate;
bool m_ServerUpdate;
std::map<std::string, bool> m_FileJobs;
2015-03-13 14:13:19 +00:00
void AddFileJob(const char *pFile, bool job);
2015-03-13 14:13:19 +00:00
void FetchFile(const char *pFile, const char *pDestPath = 0);
void MoveFile(const char *pFile);
2015-03-13 14:13:19 +00:00
void ParseUpdate();
void PerformUpdate();
void CommitUpdate();
2015-03-13 14:13:19 +00:00
void ReplaceClient();
void ReplaceServer();
public:
CUpdater();
2017-10-09 08:41:41 +00:00
static void ProgressCallback(IFetchTask *pTask, void *pUser);
static void CompletionCallback(IFetchTask *pTask, void *pUser);
2015-03-13 14:13:19 +00:00
int GetCurrentState() { return m_State; };
char *GetCurrentFile() { return m_Status; };
int GetCurrentPercent() { return m_Percent; };
virtual void InitiateUpdate();
void Init();
virtual void Update();
void WinXpRestart();
2014-12-31 14:29:34 +00:00
};
2015-03-13 14:13:19 +00:00
#endif