summaryrefslogtreecommitdiff
path: root/indra/viewer_components/updater/llupdatechecker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/viewer_components/updater/llupdatechecker.cpp')
-rwxr-xr-x[-rw-r--r--]indra/viewer_components/updater/llupdatechecker.cpp155
1 files changed, 104 insertions, 51 deletions
diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp
index 5edbbf9914..39f68ac0f5 100644..100755
--- a/indra/viewer_components/updater/llupdatechecker.cpp
+++ b/indra/viewer_components/updater/llupdatechecker.cpp
@@ -62,10 +62,16 @@ LLUpdateChecker::LLUpdateChecker(LLUpdateChecker::Client & client):
}
-void LLUpdateChecker::checkVersion(std::string const & protocolVersion, std::string const & hostUrl,
- std::string const & servicePath, std::string channel, std::string version)
+void LLUpdateChecker::checkVersion(std::string const & hostUrl,
+ std::string const & servicePath,
+ std::string const & channel,
+ std::string const & version,
+ std::string const & platform,
+ std::string const & platform_version,
+ unsigned char uniqueid[MD5HEX_STR_SIZE],
+ bool willing_to_test)
{
- mImplementation->checkVersion(protocolVersion, hostUrl, servicePath, channel, version);
+ mImplementation->checkVersion(hostUrl, servicePath, channel, version, platform, platform_version, uniqueid, willing_to_test);
}
@@ -74,12 +80,14 @@ void LLUpdateChecker::checkVersion(std::string const & protocolVersion, std::str
//-----------------------------------------------------------------------------
-const char * LLUpdateChecker::Implementation::sProtocolVersion = "v1.0";
+const char * LLUpdateChecker::Implementation::sLegacyProtocolVersion = "v1.0";
+const char * LLUpdateChecker::Implementation::sProtocolVersion = "v1.1";
LLUpdateChecker::Implementation::Implementation(LLUpdateChecker::Client & client):
mClient(client),
- mInProgress(false)
+ mInProgress(false),
+ mProtocol(sProtocolVersion)
{
; // No op.
}
@@ -91,41 +99,93 @@ LLUpdateChecker::Implementation::~Implementation()
}
-void LLUpdateChecker::Implementation::checkVersion(std::string const & protocolVersion, std::string const & hostUrl,
- std::string const & servicePath, std::string channel, std::string version)
+void LLUpdateChecker::Implementation::checkVersion(std::string const & hostUrl,
+ std::string const & servicePath,
+ std::string const & channel,
+ std::string const & version,
+ std::string const & platform,
+ std::string const & platform_version,
+ unsigned char uniqueid[MD5HEX_STR_SIZE],
+ bool willing_to_test)
{
llassert(!mInProgress);
- if(protocolVersion != sProtocolVersion) throw CheckError("unsupported protocol");
-
mInProgress = true;
- mVersion = version;
- std::string checkUrl = buildUrl(protocolVersion, hostUrl, servicePath, channel, version);
- LL_INFOS("UpdateCheck") << "checking for updates at " << checkUrl << llendl;
+
+ mHostUrl = hostUrl;
+ mServicePath = servicePath;
+ mChannel = channel;
+ mVersion = version;
+ mPlatform = platform;
+ mPlatformVersion = platform_version;
+ memcpy(mUniqueId, uniqueid, MD5HEX_STR_SIZE);
+ mWillingToTest = willing_to_test;
+
+ mProtocol = sProtocolVersion;
+
+ std::string checkUrl = buildUrl(hostUrl, servicePath, channel, version, platform, platform_version, uniqueid, willing_to_test);
+ LL_INFOS("UpdaterService") << "checking for updates at " << checkUrl << LL_ENDL;
mHttpClient.get(checkUrl, this);
}
void LLUpdateChecker::Implementation::completed(U32 status,
- const std::string & reason,
- const LLSD & content)
+ const std::string & reason,
+ const LLSD & content)
{
mInProgress = false;
- if(status != 200) {
- LL_WARNS("UpdateCheck") << "html error " << status << " (" << reason << ")" << llendl;
- mClient.error(reason);
- } else if(!content.asBoolean()) {
- LL_INFOS("UpdateCheck") << "up to date" << llendl;
- mClient.upToDate();
- } else if(content["required"].asBoolean()) {
- LL_INFOS("UpdateCheck") << "version invalid" << llendl;
- LLURI uri(content["url"].asString());
- 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, content["hash"].asString());
+ if(status != 200)
+ {
+ std::string server_error;
+ if ( content.has("error_code") )
+ {
+ server_error += content["error_code"].asString();
+ }
+ if ( content.has("error_text") )
+ {
+ server_error += server_error.empty() ? "" : ": ";
+ server_error += content["error_text"].asString();
+ }
+
+ if (status == 404)
+ {
+ if (mProtocol == sProtocolVersion)
+ {
+ mProtocol = sLegacyProtocolVersion;
+ std::string retryUrl = buildUrl(mHostUrl, mServicePath, mChannel, mVersion, mPlatform, mPlatformVersion, mUniqueId, mWillingToTest);
+
+ LL_WARNS("UpdaterService")
+ << "update response using " << sProtocolVersion
+ << " was HTTP 404 (" << server_error
+ << "); retry with legacy protocol " << mProtocol
+ << "\n at " << retryUrl
+ << LL_ENDL;
+
+ mHttpClient.get(retryUrl, this);
+ }
+ else
+ {
+ LL_WARNS("UpdaterService")
+ << "update response using " << sLegacyProtocolVersion
+ << " was 404 (" << server_error
+ << "); request failed"
+ << LL_ENDL;
+ mClient.error(reason);
+ }
+ }
+ else
+ {
+ LL_WARNS("UpdaterService") << "response error " << status
+ << " " << reason
+ << " (" << server_error << ")"
+ << LL_ENDL;
+ mClient.error(reason);
+ }
+ }
+ else
+ {
+ mClient.response(content);
}
}
@@ -133,38 +193,31 @@ void LLUpdateChecker::Implementation::completed(U32 status,
void LLUpdateChecker::Implementation::error(U32 status, const std::string & reason)
{
mInProgress = false;
- LL_WARNS("UpdateCheck") << "update check failed; " << reason << llendl;
+ LL_WARNS("UpdaterService") << "update check failed; " << reason << LL_ENDL;
mClient.error(reason);
}
-std::string LLUpdateChecker::Implementation::buildUrl(std::string const & protocolVersion, std::string const & hostUrl,
- std::string const & servicePath, std::string channel, std::string version)
+std::string LLUpdateChecker::Implementation::buildUrl(std::string const & hostUrl,
+ std::string const & servicePath,
+ std::string const & channel,
+ std::string const & version,
+ std::string const & platform,
+ std::string const & platform_version,
+ unsigned char uniqueid[MD5HEX_STR_SIZE],
+ bool willing_to_test)
{
-#ifdef LL_WINDOWS
- static const char * platform = "win";
-#elif LL_DARWIN
- long versMin;
- Gestalt(gestaltSystemVersionMinor, &versMin);
-
- static const char *platform;
- if (versMin == 5) //OS 10.5
- {
- platform = "mac_legacy";
- }
- else
- {
- platform = "mac";
- }
-#else
- static const char * platform = "lnx";
-#endif
-
LLSD path;
path.append(servicePath);
- path.append(protocolVersion);
+ path.append(mProtocol);
path.append(channel);
path.append(version);
path.append(platform);
+ if (mProtocol != sLegacyProtocolVersion)
+ {
+ path.append(platform_version);
+ path.append(willing_to_test ? "testok" : "testno");
+ path.append((char*)uniqueid);
+ }
return LLURI::buildHTTP(hostUrl, path).asString();
}