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.cpp204
1 files changed, 110 insertions, 94 deletions
diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp
index 4da774a5f6..d6e06e5316 100644..100755
--- a/indra/viewer_components/updater/llupdatechecker.cpp
+++ b/indra/viewer_components/updater/llupdatechecker.cpp
@@ -51,37 +51,6 @@ public:
};
-class LLUpdateChecker::Implementation:
- public LLHTTPClient::Responder
-{
-public:
- Implementation(Client & client);
- ~Implementation();
- void checkVersion(std::string const & protocolVersion, std::string const & hostUrl,
- std::string const & servicePath, std::string channel, std::string version);
-
- // Responder:
- virtual void completed(U32 status,
- const std::string & reason,
- const LLSD& content);
- virtual void error(U32 status, const std::string & reason);
-
-private:
- static const char * sProtocolVersion;
-
- Client & mClient;
- LLHTTPClient mHttpClient;
- bool mInProgress;
- 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);
-};
-
-
-
// LLUpdateChecker
//-----------------------------------------------------------------------------
@@ -93,10 +62,15 @@ 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 & urlBase,
+ 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(urlBase, channel, version, platform, platform_version, uniqueid, willing_to_test);
}
@@ -105,12 +79,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.
}
@@ -122,47 +98,96 @@ 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 & urlBase,
+ 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 (!mInProgress)
+ {
+ mInProgress = true;
+
+ mUrlBase = urlBase;
+ mChannel = channel;
+ mVersion = version;
+ mPlatform = platform;
+ mPlatformVersion = platform_version;
+ memcpy(mUniqueId, uniqueid, MD5HEX_STR_SIZE);
+ mWillingToTest = willing_to_test;
- 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;
+ mProtocol = sProtocolVersion;
+
+ std::string checkUrl = buildUrl(urlBase, channel, version, platform, platform_version, uniqueid, willing_to_test);
+ LL_INFOS("UpdaterService") << "checking for updates at " << checkUrl << LL_ENDL;
- // The HTTP client will wrap a raw pointer in a boost::intrusive_ptr causing the
- // passed object to be silently and automatically deleted. We pass a self-
- // referential intrusive pointer to which we add a reference to keep the
- // client from deleting the update checker implementation instance.
- LLHTTPClient::ResponderPtr temporaryPtr(this);
- boost::intrusive_ptr_add_ref(temporaryPtr.get());
- mHttpClient.get(checkUrl, temporaryPtr);
+ mHttpClient.get(checkUrl, this);
+ }
+ else
+ {
+ LL_WARNS("UpdaterService") << "attempting to restart a check when one is in progress; ignored" << LL_ENDL;
+ }
}
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(mUrlBase, 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);
}
}
@@ -170,38 +195,29 @@ 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)
-{
-#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
-
+std::string LLUpdateChecker::Implementation::buildUrl(std::string const & urlBase,
+ 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)
+{
LLSD path;
- path.append(servicePath);
- path.append(protocolVersion);
+ path.append(mProtocol);
path.append(channel);
path.append(version);
path.append(platform);
- return LLURI::buildHTTP(hostUrl, path).asString();
+ if (mProtocol != sLegacyProtocolVersion)
+ {
+ path.append(platform_version);
+ path.append(willing_to_test ? "testok" : "testno");
+ path.append((char*)uniqueid);
+ }
+ return LLURI::buildHTTP(urlBase, path).asString();
}