| 1 | /* |
| 2 | * LegacyClonk |
| 3 | * |
| 4 | * Copyright (c) RedWolf Design |
| 5 | * Copyright (c) 2007, matthes |
| 6 | * Copyright (c) 2017-2020, The LegacyClonk Team and contributors |
| 7 | * |
| 8 | * Distributed under the terms of the ISC license; see accompanying file |
| 9 | * "COPYING" for details. |
| 10 | * |
| 11 | * "Clonk" is a registered trademark of Matthes Bender, used with permission. |
| 12 | * See accompanying file "TRADEMARK" for details. |
| 13 | * |
| 14 | * To redistribute this file separately, substitute the full license texts |
| 15 | * for the above references. |
| 16 | */ |
| 17 | |
| 18 | // dialogs for update |
| 19 | |
| 20 | #pragma once |
| 21 | |
| 22 | #include "C4Gui.h" |
| 23 | #include "C4GuiDialogs.h" |
| 24 | #include "C4GameVersion.h" |
| 25 | #include "C4Network2Reference.h" |
| 26 | |
| 27 | // dialog showing info about a connected client |
| 28 | class C4UpdateDlg : public C4GUI::InfoDialog |
| 29 | { |
| 30 | protected: |
| 31 | virtual void UpdateText() override; |
| 32 | |
| 33 | bool UpdateRunning; |
| 34 | |
| 35 | // Misc process variables which are shared between the static DoUpdate and the update dialog |
| 36 | static int pid; |
| 37 | static int c4group_output[2]; |
| 38 | static bool succeeded; |
| 39 | |
| 40 | public: |
| 41 | C4UpdateDlg(); |
| 42 | |
| 43 | public: |
| 44 | static bool IsValidUpdate(const C4GameVersion &rNewVer); // Returns whether we can update to the specified version |
| 45 | static bool CheckForUpdates(C4GUI::Screen *pScreen = nullptr, bool fAutomatic = false); // Checks for available updates and prompts the user whether to apply |
| 46 | static bool DoUpdate(const C4GameVersion &rUpdateVersion, C4GUI::Screen *pScreen); // Static funtion for downloading and applying updates |
| 47 | static bool ApplyUpdate(const char *strUpdateFile, bool fDeleteUpdate, C4GUI::Screen *pScreen); // Static funtion for applying updates |
| 48 | }; |
| 49 | |
| 50 | // Loads current version string (mini-HTTP-client) |
| 51 | class C4Network2VersionInfoClient : public C4Network2HTTPClient |
| 52 | { |
| 53 | public: |
| 54 | C4Network2VersionInfoClient() : C4Network2HTTPClient() {} |
| 55 | |
| 56 | bool QueryVersion(); |
| 57 | bool GetVersion(C4GameVersion *pSaveToVer); |
| 58 | bool GetRedirect(StdStrBuf &rRedirect); |
| 59 | }; |
| 60 | |