summaryrefslogtreecommitdiff
path: root/src/client/Client.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-06-22 18:04:38 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-06-22 18:04:38 (GMT)
commiteb52f759de6f0805865fb7f31444f2b1421b4d25 (patch)
tree49b259400c8946a8bea84c7af3f758f86a59d976 /src/client/Client.cpp
parent55d90a44a8425f70b08d864570e255f4bad8ba4c (diff)
downloadpowder-eb52f759de6f0805865fb7f31444f2b1421b4d25.zip
powder-eb52f759de6f0805865fb7f31444f2b1421b4d25.tar.gz
Success/Failure return from Asyn Task, Prompt to visit website upon update failure
Diffstat (limited to 'src/client/Client.cpp')
-rw-r--r--src/client/Client.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/client/Client.cpp b/src/client/Client.cpp
index ec88927..d0a7bee 100644
--- a/src/client/Client.cpp
+++ b/src/client/Client.cpp
@@ -114,7 +114,7 @@ Client::Client():
stampsLib.close();
//Begin version check
- versionCheckRequest = http_async_req_start(NULL, SERVER "/Version.json", NULL, 0, 1);
+ versionCheckRequest = http_async_req_start(NULL, SERVER "/Download/Version.json", NULL, 0, 1);
}
void Client::Tick()
@@ -127,7 +127,6 @@ void Client::Tick()
char * data = http_async_req_stop(versionCheckRequest, &status, &dataLength);
versionCheckRequest = NULL;
- notifyUpdateAvailable();
if(status != 200)
{
if(data)
@@ -144,25 +143,42 @@ void Client::Tick()
json::Object stableVersion = objDocument["Stable"];
json::Object betaVersion = objDocument["Beta"];
+ json::Object snapshotVersion = objDocument["Snapshot"];
json::Number stableMajor = stableVersion["Major"];
json::Number stableMinor = stableVersion["Minor"];
json::Number stableBuild = stableVersion["Build"];
+ json::String stableFile = stableVersion["File"];
json::Number betaMajor = betaVersion["Major"];
json::Number betaMinor = betaVersion["Minor"];
json::Number betaBuild = betaVersion["Build"];
+ json::String betaFile = betaVersion["File"];
+
+ json::Number snapshotMajor = snapshotVersion["Major"];
+ json::Number snapshotMinor = snapshotVersion["Minor"];
+ json::Number snapshotBuild = snapshotVersion["Build"];
+ json::String snapshotFile = snapshotVersion["File"];
+
+ if(stableMajor.Value()>SAVE_VERSION || (stableMinor.Value()>MINOR_VERSION && stableMajor.Value()==SAVE_VERSION) || stableBuild.Value()>BUILD_NUM)
+ {
+ updateAvailable = true;
+ updateInfo = UpdateInfo(stableMajor.Value(), stableMinor.Value(), stableBuild.Value(), stableFile.Value(), UpdateInfo::Stable);
+ }
#ifdef BETA
- if( (betaMajor.Value()>SAVE_VERSION || (betaMinor.Value()>MINOR_VERSION && betaMajor.Value()==SAVE_VERSION) || betaBuild.Value()>BUILD_NUM) ||
- (stableMajor.Value()>SAVE_VERSION || (stableMinor.Value()>MINOR_VERSION && stableMajor.Value()==SAVE_VERSION) || stableBuild.Value()>BUILD_NUM))
+ if(betaMajor.Value()>SAVE_VERSION || (betaMinor.Value()>MINOR_VERSION && betaMajor.Value()==SAVE_VERSION) || betaBuild.Value()>BUILD_NUM)
{
updateAvailable = true;
+ updateInfo = UpdateInfo(betaMajor.Value(), betaMinor.Value(), betaBuild.Value(), betaFile.Value(), UpdateInfo::Beta);
}
-#else
- if(stableMajor.Value()>SAVE_VERSION || (stableMinor.Value()>MINOR_VERSION && stableMajor.Value()==SAVE_VERSION) || stableBuild.Value()>BUILD_NUM)
+#endif
+
+#ifdef SNAPSHOT
+ if(snapshotMajor.Value()>SAVE_VERSION || (snapshotMinor.Value()>MINOR_VERSION && snapshotMajor.Value()==SAVE_VERSION) || snapshotBuild.Value()>BUILD_NUM)
{
updateAvailable = true;
+ updateInfo = UpdateInfo(snapshotMajor.Value(), snapshotMinor.Value(), snapshotBuild.Value(), snapshotFile.Value(), UpdateInfo::Snapshot);
}
#endif
@@ -182,6 +198,11 @@ void Client::Tick()
}
}
+UpdateInfo Client::GetUpdateInfo()
+{
+ return updateInfo;
+}
+
void Client::notifyUpdateAvailable()
{
for (std::vector<ClientListener*>::iterator iterator = listeners.begin(), end = listeners.end(); iterator != end; ++iterator)