summaryrefslogtreecommitdiff
path: root/indra/viewer_components/updater/llupdatechecker.cpp
diff options
context:
space:
mode:
authorAndrew A. de Laix <alain@lindenlab.com>2010-11-04 15:49:19 -0700
committerAndrew A. de Laix <alain@lindenlab.com>2010-11-04 15:49:19 -0700
commit191e164a503b72c7feae0a46ad0422740b365556 (patch)
treee4f8d565e81bbe22fde904a67d2afa95eb9189e9 /indra/viewer_components/updater/llupdatechecker.cpp
parent070fe9ed262da5c990a5129474489647a0369fc9 (diff)
some better error handling.
Diffstat (limited to 'indra/viewer_components/updater/llupdatechecker.cpp')
-rw-r--r--indra/viewer_components/updater/llupdatechecker.cpp35
1 files changed, 28 insertions, 7 deletions
diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp
index 2c60636122..d31244cc9b 100644
--- a/indra/viewer_components/updater/llupdatechecker.cpp
+++ b/indra/viewer_components/updater/llupdatechecker.cpp
@@ -24,21 +24,35 @@
*/
#include "linden_common.h"
+#include <stdexcept>
#include <boost/format.hpp>
#include "llhttpclient.h"
#include "llsd.h"
#include "llupdatechecker.h"
#include "lluri.h"
+
#if LL_WINDOWS
#pragma warning (disable : 4355) // 'this' used in initializer list: yes, intentionally
#endif
+
+class LLUpdateChecker::CheckError:
+ public std::runtime_error
+{
+public:
+ CheckError(const char * message):
+ std::runtime_error(message)
+ {
+ ; // No op.
+ }
+};
+
+
class LLUpdateChecker::Implementation:
public LLHTTPClient::Responder
{
public:
-
Implementation(Client & client);
~Implementation();
void check(std::string const & protocolVersion, std::string const & hostUrl,
@@ -50,9 +64,8 @@ public:
const LLSD& content);
virtual void error(U32 status, const std::string & reason);
-private:
- std::string buildUrl(std::string const & protocolVersion, std::string const & hostUrl,
- std::string const & servicePath, std::string channel, std::string version);
+private:
+ static const char * sProtocolVersion;
Client & mClient;
LLHTTPClient mHttpClient;
@@ -60,6 +73,9 @@ private:
LLHTTPClient::ResponderPtr mMe;
std::string mVersion;
+ std::string buildUrl(std::string const & protocolVersion, std::string const & hostUrl,
+ std::string const & servicePath, std::string channel, std::string version);
+
LOG_CLASS(LLUpdateChecker::Implementation);
};
@@ -88,6 +104,9 @@ void LLUpdateChecker::check(std::string const & protocolVersion, std::string con
//-----------------------------------------------------------------------------
+const char * LLUpdateChecker::Implementation::sProtocolVersion = "v1.0";
+
+
LLUpdateChecker::Implementation::Implementation(LLUpdateChecker::Client & client):
mClient(client),
mInProgress(false),
@@ -106,7 +125,9 @@ LLUpdateChecker::Implementation::~Implementation()
void LLUpdateChecker::Implementation::check(std::string const & protocolVersion, std::string const & hostUrl,
std::string const & servicePath, std::string channel, std::string version)
{
- // llassert(!mInProgress);
+ llassert(!mInProgress);
+
+ if(protocolVersion != sProtocolVersion) throw CheckError("unsupported protocol");
mInProgress = true;
mVersion = version;
@@ -135,11 +156,11 @@ void LLUpdateChecker::Implementation::completed(U32 status,
} else if(content["required"].asBoolean()) {
LL_INFOS("UpdateCheck") << "version invalid" << llendl;
LLURI uri(content["url"].asString());
- mClient.requiredUpdate(content["version"].asString(), uri);
+ mClient.requiredUpdate(content["version"].asString(), uri, content["hash"].asString());
} else {
LL_INFOS("UpdateCheck") << "newer version " << content["version"].asString() << " available" << llendl;
LLURI uri(content["url"].asString());
- mClient.optionalUpdate(content["version"].asString(), uri);
+ mClient.optionalUpdate(content["version"].asString(), uri, content["hash"].asString());
}
}