summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-07-22 17:51:05 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-07-22 17:51:05 (GMT)
commit97bf9a517e63e87eebeedd6a6d393e83f6354a23 (patch)
tree9c523987a49d8cd2ae28becc3b2c520b8fbbf35d /src
parenta1b4168b30979fc9bb8571d382b4bfc6aa8f87f0 (diff)
downloadpowder-97bf9a517e63e87eebeedd6a6d393e83f6354a23.zip
powder-97bf9a517e63e87eebeedd6a6d393e83f6354a23.tar.gz
Snapshot checking
Diffstat (limited to 'src')
-rw-r--r--src/Config.h4
-rw-r--r--src/client/Client.cpp8
-rw-r--r--src/client/Client.h6
-rw-r--r--src/client/HTTP.cpp20
-rw-r--r--src/dialogues/ConfirmPrompt.cpp2
5 files changed, 28 insertions, 12 deletions
diff --git a/src/Config.h b/src/Config.h
index 5bf10cc..1ad3e09 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -21,6 +21,10 @@
#define BETA
#define SNAPSHOT
#define BUILD_NUM 155
+
+#ifndef SNAPSHOT_ID
+#define SNAPSHOT_ID 0
+#endif
//VersionInfoEnd
#if defined(SNAPSHOT)
diff --git a/src/client/Client.cpp b/src/client/Client.cpp
index 116fa02..de37a6c 100644
--- a/src/client/Client.cpp
+++ b/src/client/Client.cpp
@@ -155,9 +155,7 @@ void Client::Tick()
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::Number snapshotSnapshot = snapshotVersion["Snapshot"];
json::String snapshotFile = snapshotVersion["File"];
if(stableMajor.Value()>SAVE_VERSION || (stableMinor.Value()>MINOR_VERSION && stableMajor.Value()==SAVE_VERSION) || stableBuild.Value()>BUILD_NUM)
@@ -175,10 +173,10 @@ void Client::Tick()
#endif
#ifdef SNAPSHOT
- if(snapshotMajor.Value()>SAVE_VERSION || (snapshotMinor.Value()>MINOR_VERSION && snapshotMajor.Value()==SAVE_VERSION) || snapshotBuild.Value()>BUILD_NUM)
+ if(snapshotSnapshot.Value() > SNAPSHOT_ID)
{
updateAvailable = true;
- updateInfo = UpdateInfo(snapshotMajor.Value(), snapshotMinor.Value(), snapshotBuild.Value(), snapshotFile.Value(), UpdateInfo::Snapshot);
+ updateInfo = UpdateInfo(snapshotSnapshot.Value(), snapshotFile.Value(), UpdateInfo::Snapshot);
}
#endif
diff --git a/src/client/Client.h b/src/client/Client.h
index a2d8720..cb39f2e 100644
--- a/src/client/Client.h
+++ b/src/client/Client.h
@@ -35,9 +35,11 @@ public:
int Major;
int Minor;
int Build;
+ int Time;
BuildType Type;
- UpdateInfo() : Major(0), Minor(0), Build(0), File(""), Type(Stable) {}
- UpdateInfo(int major, int minor, int build, std::string file, BuildType type) : Major(major), Minor(minor), Build(build), File(file), Type(type) {}
+ UpdateInfo() : Major(0), Minor(0), Build(0), Time(0), File(""), Type(Stable) {}
+ UpdateInfo(int major, int minor, int build, std::string file, BuildType type) : Major(major), Minor(minor), Build(build), Time(0), File(file), Type(type) {}
+ UpdateInfo(int time, std::string file, BuildType type) : Major(0), Minor(0), Build(0), Time(time), File(file), Type(type) {}
};
class ClientListener;
diff --git a/src/client/HTTP.cpp b/src/client/HTTP.cpp
index d622a81..686a6ee 100644
--- a/src/client/HTTP.cpp
+++ b/src/client/HTTP.cpp
@@ -20,6 +20,8 @@
*/
+#include <string>
+#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -68,6 +70,7 @@
#define PCLOSE close
#endif
+char * userAgent;
static int http_up = 0;
static long http_timeout = 15;
static int http_use_proxy = 0;
@@ -180,6 +183,15 @@ void http_init(char *proxy)
free(host);
free(port);
}
+ std::stringstream userAgentBuilder;
+ userAgentBuilder << "PowderToy/" << SAVE_VERSION << "." << MINOR_VERSION << " ";
+ userAgentBuilder << "(" << IDENT_PLATFORM << "; " << IDENT_BUILD << "; M0) ";
+ userAgentBuilder << "TPTPP/" << SAVE_VERSION << "." << MINOR_VERSION << "." << BUILD_NUM << IDENT_RELTYPE << "." << SNAPSHOT_ID;
+ std::string newUserAgent = userAgentBuilder.str();
+ userAgent = new char[newUserAgent.length()+1];
+ std::copy(newUserAgent.begin(), newUserAgent.end(), userAgent);
+ userAgent[newUserAgent.length()] = 0;
+ //"User-Agent: PowderToy/%d.%d (%s; %s; M%d) TPTPP/%d.%d.%d%s.%d\n", SAVE_VERSION, MINOR_VERSION, IDENT_PLATFORM, IDENT_BUILD, 0, SAVE_VERSION, MINOR_VERSION, BUILD_NUM, IDENT_RELTYPE, SNAPSHOT_ID
}
void http_done(void)
@@ -468,7 +480,7 @@ int http_async_req_status(void *ctx)
if (cx->txdl)
{
// generate POST
- cx->tbuf = (char *)malloc(strlen(cx->host) + strlen(cx->path) + 141 + 128 + cx->txdl + cx->thlen);
+ cx->tbuf = (char *)malloc(strlen(cx->host) + strlen(cx->path) + 126 + strlen(userAgent) + cx->txdl + cx->thlen);
cx->tptr = 0;
cx->tlen = 0;
cx->tlen += sprintf(cx->tbuf+cx->tlen, "POST %s HTTP/1.1\n", cx->path);
@@ -484,7 +496,7 @@ int http_async_req_status(void *ctx)
cx->thlen = 0;
}
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Content-Length: %d\n", cx->txdl);
- cx->tlen += sprintf(cx->tbuf+cx->tlen, "User-Agent: PowderToy/%d.%d (%s; %s; M%d) TPTPP/%d.%d.%d%s\n", SAVE_VERSION, MINOR_VERSION, IDENT_PLATFORM, IDENT_BUILD, 0, SAVE_VERSION, MINOR_VERSION, BUILD_NUM, IDENT_RELTYPE);
+ cx->tlen += sprintf(cx->tbuf+cx->tlen, "User-Agent: %s\n", userAgent);
cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n");
memcpy(cx->tbuf+cx->tlen, cx->txd, cx->txdl);
cx->tlen += cx->txdl;
@@ -495,7 +507,7 @@ int http_async_req_status(void *ctx)
else
{
// generate GET
- cx->tbuf = (char *)malloc(strlen(cx->host) + strlen(cx->path) + 100 + 128 + cx->thlen);
+ cx->tbuf = (char *)malloc(strlen(cx->host) + strlen(cx->path) + 93 + strlen(userAgent) + cx->thlen);
cx->tptr = 0;
cx->tlen = 0;
cx->tlen += sprintf(cx->tbuf+cx->tlen, "GET %s HTTP/1.1\n", cx->path);
@@ -510,7 +522,7 @@ int http_async_req_status(void *ctx)
}
if (!cx->keep)
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Connection: close\n");
- cx->tlen += sprintf(cx->tbuf+cx->tlen, "User-Agent: PowderToy/%d.%d (%s; %s; M%d) TPTPP/%d.%d.%d%s\n", SAVE_VERSION, MINOR_VERSION, IDENT_PLATFORM, IDENT_BUILD, 0, SAVE_VERSION, MINOR_VERSION, BUILD_NUM, IDENT_RELTYPE);
+ cx->tlen += sprintf(cx->tbuf+cx->tlen, "User-Agent: %s\n", userAgent);
cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n");
}
cx->state = HTS_XMIT;
diff --git a/src/dialogues/ConfirmPrompt.cpp b/src/dialogues/ConfirmPrompt.cpp
index 93ef06a..ed53800 100644
--- a/src/dialogues/ConfirmPrompt.cpp
+++ b/src/dialogues/ConfirmPrompt.cpp
@@ -28,7 +28,7 @@ ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, ConfirmDial
messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
AddComponent(messageLabel);
- Size.Y += messageLabel->Size.Y;
+ Size.Y += messageLabel->Size.Y+12;
Position.Y = (ui::Engine::Ref().GetHeight()-Size.Y)/2;
class CloseAction: public ui::ButtonAction