Emergency 20 Dokumentation  4.2.0
UpdateCheck.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/Export.h"
14 
15 
16 //[-------------------------------------------------------]
17 //[ Namespace ]
18 //[-------------------------------------------------------]
19 namespace em5
20 {
21 
22 
23  //[-------------------------------------------------------]
24  //[ Classes ]
25  //[-------------------------------------------------------]
31  {
32 
33 
34  //[-------------------------------------------------------]
35  //[ Friends ]
36  //[-------------------------------------------------------]
37  friend class NetworkManager;
38 
39 
40  //[-------------------------------------------------------]
41  //[ Public definitions ]
42  //[-------------------------------------------------------]
43  public:
44  static const std::string UPDATE_URL;
45  static const std::string FORMAT_TYPE;
46  static const uint32 FORMAT_VERSION;
47  static const std::string UPDATE_SETUP_EXE_NAME;
48 
50  {
51  std::string applicationName;
52  std::string applicationVersion;
53  std::string architecture;
54  std::string region;
55  std::string languagePackage;
56  std::string edition;
57  std::string productVariant;
58  std::string launcherChecksum;
59  };
60 
61 
62  //[-------------------------------------------------------]
63  //[ Public boost signals ]
64  //[-------------------------------------------------------]
65  public:
67  boost::signals2::signal<void(uint32, uint32, uint64, uint64)> progress;
68 
70  boost::signals2::signal<void()> finished;
71 
73  boost::signals2::signal<void()> error;
74 
75 
76  //[-------------------------------------------------------]
77  //[ Public methods ]
78  //[-------------------------------------------------------]
79  public:
80  bool isCheckComplete() const;
81  bool isUpdateAvailable() const;
82  const std::string& getUpdateVersion() const;
83  bool startCheckForUpdates(const VersionInformation& versionInformation);
84  bool startDownloadAndInstallUpdate();
85  const std::string& getInfoText() const;
86  void getMatchmakingAddress(std::string& matchmakingUrl, uint16& matchmakingPort) const;
87 
88 
89  //[-------------------------------------------------------]
90  //[ Private methods ]
91  //[-------------------------------------------------------]
92  private:
97  UpdateCheck();
98 
103  virtual ~UpdateCheck();
104 
105  bool checkForUpdatesAtNextUrl();
106 
107  bool startDownload(const std::string& url, const std::string& absoluteFilename, uint32 currentFileIndex, uint32 totalFileCount, boost::function<void(const std::string&, const std::string&)> callback);
108 
109  void onDownloadProgress(uint64 currentBytes, uint64 totalBytes);
110  void onDownloadFinished(boost::function<void(const std::string&, const std::string&)> callback);
111  void onDownloadError();
112 
113  void parseUpdateInformation(const std::string& effectiveUrl, const std::string& absoluteFilename);
114 
115  void downloadedUpdatePackage(const std::string& effectiveUrl, const std::string& absoluteFilename);
116 
117  std::string searchPatchSetup() const;
118 
119 
120  //[-------------------------------------------------------]
121  //[ Private definitions ]
122  //[-------------------------------------------------------]
123  private:
124  struct Private;
125 
126 
127  //[-------------------------------------------------------]
128  //[ Private data ]
129  //[-------------------------------------------------------]
130  private:
131  bool mIsCheckComplete;
132  bool mIsUpdateAvailable;
133  std::string mUpdateVersion;
134  std::string mInfoText;
135 
136  // Progress reporting
137  uint32 mTotalFileCount;
138  uint32 mCurrentFileIndex;
139 
140  // Error handling
141  uint32 mTryCounter;
142 
143  // Internal data
144  Private& mPrivate;
145 
146 
147  };
148 
149 
150 //[-------------------------------------------------------]
151 //[ Namespace ]
152 //[-------------------------------------------------------]
153 } // em5
boost::signals2::signal< void(uint32, uint32, uint64, uint64)> progress
Definition: UpdateCheck.h:67
Definition: ActionPriority.h:13
unsigned int uint32
Definition: PlatformTypes.h:181
boost::signals2::signal< void()> finished
Definition: UpdateCheck.h:70
static const std::string FORMAT_TYPE
Definition: UpdateCheck.h:45
#define EM5_API_EXPORT
Definition: Export.h:28
EMERGENCY 5 update check class.
Definition: UpdateCheck.h:30
std::string edition
Definition: UpdateCheck.h:56
std::string productVariant
Definition: UpdateCheck.h:57
boost::signals2::signal< void()> error
Definition: UpdateCheck.h:73
uint64_t uint64
Definition: PlatformTypes.h:184
Definition: UpdateCheck.h:49
std::string region
Definition: UpdateCheck.h:54
unsigned short uint16
Definition: PlatformTypes.h:178
static const std::string UPDATE_SETUP_EXE_NAME
Definition: UpdateCheck.h:47
std::string applicationName
Definition: UpdateCheck.h:51
std::string languagePackage
Definition: UpdateCheck.h:55
std::string applicationVersion
Definition: UpdateCheck.h:52
static const std::string UPDATE_URL
Definition: UpdateCheck.h:44
static const uint32 FORMAT_VERSION
Definition: UpdateCheck.h:46
EMERGENCY 5 network manager class.
Definition: NetworkManager.h:63
std::string architecture
Definition: UpdateCheck.h:53
std::string launcherChecksum
Definition: UpdateCheck.h:58