From cf1019859def2af4414def7991e95a9020b0688f Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Thu, 21 Feb 2013 16:47:52 -0500
Subject: add use of v1.1 update request protocol, with fallback to v1.0

---
 .../viewer_components/updater/llupdatechecker.cpp  | 119 ++++++++++++++++-----
 1 file changed, 92 insertions(+), 27 deletions(-)

(limited to 'indra/viewer_components/updater/llupdatechecker.cpp')

diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp
index 5edbbf9914..6d0758b226 100644
--- a/indra/viewer_components/updater/llupdatechecker.cpp
+++ b/indra/viewer_components/updater/llupdatechecker.cpp
@@ -62,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 & hostUrl, 
+								   std::string const & servicePath,
+								   std::string const & channel,
+								   std::string const & version,
+								   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_version, uniqueid, willing_to_test);
 }
 
 
@@ -74,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.
 }
@@ -91,39 +98,86 @@ 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_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;
+	mPlatformVersion = platform_version;
+	memcpy(mUniqueId, uniqueid, MD5HEX_STR_SIZE);
+	mWillingToTest   = willing_to_test;
+	
+	mProtocol = sProtocolVersion;
+
+	std::string checkUrl = buildUrl(hostUrl, servicePath, channel, version, 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;
+	if(status != 200)
+	{
+		if (status == 404)
+		{
+			if (mProtocol == sProtocolVersion)
+			{
+				mProtocol = sLegacyProtocolVersion;
+				std::string retryUrl = buildUrl(mHostUrl, mServicePath, mChannel, mVersion, mPlatformVersion, mUniqueId, mWillingToTest);
+
+				LL_WARNS("UpdaterService")
+					<< "update response using " << sProtocolVersion
+					<< " was 404... retry at " << retryUrl
+					<< " with legacy protocol"
+					<< LL_ENDL;
+	
+				mHttpClient.get(retryUrl, this);
+			}
+			else
+			{
+				LL_WARNS("UpdaterService")
+					<< "update response using " << sLegacyProtocolVersion
+					<< " was 404; request failed"
+					<< LL_ENDL;
+				mClient.error(reason);
+			}
+		}
+		else
+		{
+			LL_WARNS("UpdaterService") << "response error " << status << " (" << reason << ")" << LL_ENDL;
+			mClient.error(reason);
+		}
+	}
+	else if(!content.asBoolean())
+	{
+		LL_INFOS("UpdaterService") << "up to date" << LL_ENDL;
 		mClient.upToDate();
-	} else if(content["required"].asBoolean()) {
-		LL_INFOS("UpdateCheck") << "version invalid" << llendl;
+	}
+	else if(content["required"].asBoolean())
+	{
+		LL_INFOS("UpdaterService") << "version invalid" << LL_ENDL;
 		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;
+	}
+	else
+	{
+		LL_INFOS("UpdaterService") << "newer version " << content["version"].asString() << " available" << LL_ENDL;
 		LLURI uri(content["url"].asString());
 		mClient.optionalUpdate(content["version"].asString(), uri, content["hash"].asString());
 	}
@@ -133,13 +187,18 @@ 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_version,
+													  unsigned char       uniqueid[MD5HEX_STR_SIZE],
+													  bool                willing_to_test)
 {	
 #ifdef LL_WINDOWS
 	static const char * platform = "win";
@@ -162,9 +221,15 @@ std::string LLUpdateChecker::Implementation::buildUrl(std::string const & protoc
 	
 	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();
 }
-- 
cgit v1.2.3


From 49ed1a4e32013cda716998784338a01b12c663ef Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Wed, 27 Feb 2013 17:40:39 -0500
Subject: finish changes to update handling, including notices of channel
 changes

---
 .../viewer_components/updater/llupdatechecker.cpp  | 23 ++++++----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

(limited to 'indra/viewer_components/updater/llupdatechecker.cpp')

diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp
index 6d0758b226..734747c811 100644
--- a/indra/viewer_components/updater/llupdatechecker.cpp
+++ b/indra/viewer_components/updater/llupdatechecker.cpp
@@ -143,8 +143,8 @@ void LLUpdateChecker::Implementation::completed(U32 status,
 
 				LL_WARNS("UpdaterService")
 					<< "update response using " << sProtocolVersion
-					<< " was 404... retry at " << retryUrl
-					<< " with legacy protocol"
+					<< " was 404... retry with legacy protocol" << mProtocol
+					<< "\n at " << retryUrl
 					<< LL_ENDL;
 	
 				mHttpClient.get(retryUrl, this);
@@ -164,22 +164,9 @@ void LLUpdateChecker::Implementation::completed(U32 status,
 			mClient.error(reason);
 		}
 	}
-	else if(!content.asBoolean())
-	{
-		LL_INFOS("UpdaterService") << "up to date" << LL_ENDL;
-		mClient.upToDate();
-	}
-	else if(content["required"].asBoolean())
-	{
-		LL_INFOS("UpdaterService") << "version invalid" << LL_ENDL;
-		LLURI uri(content["url"].asString());
-		mClient.requiredUpdate(content["version"].asString(), uri, content["hash"].asString());
-	}
 	else
 	{
-		LL_INFOS("UpdaterService") << "newer version " << content["version"].asString() << " available" << LL_ENDL;
-		LLURI uri(content["url"].asString());
-		mClient.optionalUpdate(content["version"].asString(), uri, content["hash"].asString());
+		mClient.response(content);
 	}
 }
 
@@ -215,8 +202,10 @@ std::string LLUpdateChecker::Implementation::buildUrl(std::string const & hostUr
     {
         platform = "mac";
     }
-#else
+#elif LL_LINUX
 	static const char * platform = "lnx";
+#else
+#   error "unsupported platform"
 #endif
 	
 	LLSD path;
-- 
cgit v1.2.3


From 1676dae754d19db28c9efafd90f38d0561fe3d17 Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Tue, 5 Mar 2013 16:47:03 -0500
Subject: remove old hack for legacy mac updates (no system that needed that
 will run this version anyway)

---
 indra/viewer_components/updater/llupdatechecker.cpp | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

(limited to 'indra/viewer_components/updater/llupdatechecker.cpp')

diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp
index 734747c811..10763b0adc 100644
--- a/indra/viewer_components/updater/llupdatechecker.cpp
+++ b/indra/viewer_components/updater/llupdatechecker.cpp
@@ -190,18 +190,7 @@ std::string LLUpdateChecker::Implementation::buildUrl(std::string const & hostUr
 #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";
-    }
+    static const char *platform = "mac";
 #elif LL_LINUX
 	static const char * platform = "lnx";
 #else
-- 
cgit v1.2.3


From ce73cc392c3f6e2a80c03e30a7dd975408e69f1c Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Wed, 6 Mar 2013 15:50:54 -0500
Subject: cosmetic logging fix

---
 indra/viewer_components/updater/llupdatechecker.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/viewer_components/updater/llupdatechecker.cpp')

diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp
index 10763b0adc..bb171aec01 100644
--- a/indra/viewer_components/updater/llupdatechecker.cpp
+++ b/indra/viewer_components/updater/llupdatechecker.cpp
@@ -143,7 +143,7 @@ void LLUpdateChecker::Implementation::completed(U32 status,
 
 				LL_WARNS("UpdaterService")
 					<< "update response using " << sProtocolVersion
-					<< " was 404... retry with legacy protocol" << mProtocol
+					<< " was 404... retry with legacy protocol " << mProtocol
 					<< "\n at " << retryUrl
 					<< LL_ENDL;
 	
-- 
cgit v1.2.3


From 8154621527171267af52a9534e541af1d6c07836 Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Tue, 26 Mar 2013 18:01:20 -0400
Subject: log any error code and text received as an llsd body in a failure
 response

---
 .../viewer_components/updater/llupdatechecker.cpp  | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

(limited to 'indra/viewer_components/updater/llupdatechecker.cpp')

diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp
index bb171aec01..daa867e692 100644
--- a/indra/viewer_components/updater/llupdatechecker.cpp
+++ b/indra/viewer_components/updater/llupdatechecker.cpp
@@ -134,6 +134,17 @@ void LLUpdateChecker::Implementation::completed(U32 status,
 	
 	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)
@@ -143,7 +154,8 @@ void LLUpdateChecker::Implementation::completed(U32 status,
 
 				LL_WARNS("UpdaterService")
 					<< "update response using " << sProtocolVersion
-					<< " was 404... retry with legacy protocol " << mProtocol
+					<< " was HTTP 404 (" << server_error
+					<< "); retry with legacy protocol " << mProtocol
 					<< "\n at " << retryUrl
 					<< LL_ENDL;
 	
@@ -153,14 +165,18 @@ void LLUpdateChecker::Implementation::completed(U32 status,
 			{
 				LL_WARNS("UpdaterService")
 					<< "update response using " << sLegacyProtocolVersion
-					<< " was 404; request failed"
+					<< " was 404 (" << server_error
+					<< "); request failed"
 					<< LL_ENDL;
 				mClient.error(reason);
 			}
 		}
 		else
 		{
-			LL_WARNS("UpdaterService") << "response error " << status << " (" << reason << ")" << LL_ENDL;
+			LL_WARNS("UpdaterService") << "response error " << status
+									   << " " << reason
+									   << " (" << server_error << ")"
+									   << LL_ENDL;
 			mClient.error(reason);
 		}
 	}
-- 
cgit v1.2.3


From c17db85e73a91c145d6eebe36b3b05e2289deae0 Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Wed, 27 Mar 2013 13:20:48 -0400
Subject: add platform and platform version to login request parameters for new
 version manager query

---
 indra/viewer_components/updater/llupdatechecker.cpp | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

(limited to 'indra/viewer_components/updater/llupdatechecker.cpp')

diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp
index daa867e692..39f68ac0f5 100644
--- a/indra/viewer_components/updater/llupdatechecker.cpp
+++ b/indra/viewer_components/updater/llupdatechecker.cpp
@@ -66,11 +66,12 @@ 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(hostUrl, servicePath, channel, version, platform_version, uniqueid, willing_to_test);
+	mImplementation->checkVersion(hostUrl, servicePath, channel, version, platform, platform_version, uniqueid, willing_to_test);
 }
 
 
@@ -102,6 +103,7 @@ 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)
@@ -114,13 +116,14 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & 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_version, uniqueid, willing_to_test);
+	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);
@@ -150,7 +153,7 @@ void LLUpdateChecker::Implementation::completed(U32 status,
 			if (mProtocol == sProtocolVersion)
 			{
 				mProtocol = sLegacyProtocolVersion;
-				std::string retryUrl = buildUrl(mHostUrl, mServicePath, mChannel, mVersion, mPlatformVersion, mUniqueId, mWillingToTest);
+				std::string retryUrl = buildUrl(mHostUrl, mServicePath, mChannel, mVersion, mPlatform, mPlatformVersion, mUniqueId, mWillingToTest);
 
 				LL_WARNS("UpdaterService")
 					<< "update response using " << sProtocolVersion
@@ -199,20 +202,11 @@ std::string LLUpdateChecker::Implementation::buildUrl(std::string const & hostUr
 													  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
-    static const char *platform = "mac";
-#elif LL_LINUX
-	static const char * platform = "lnx";
-#else
-#   error "unsupported platform"
-#endif
-	
 	LLSD path;
 	path.append(servicePath);
 	path.append(mProtocol);
-- 
cgit v1.2.3


From bf6182daa8b4d7cea79310547f71d7a3155e17b0 Mon Sep 17 00:00:00 2001
From: Graham Madarasz <graham@lindenlab.com>
Date: Fri, 29 Mar 2013 07:50:08 -0700
Subject: Update Mac and Windows breakpad builds to latest

---
 indra/viewer_components/updater/llupdatechecker.cpp | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 indra/viewer_components/updater/llupdatechecker.cpp

(limited to 'indra/viewer_components/updater/llupdatechecker.cpp')

diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp
old mode 100644
new mode 100755
-- 
cgit v1.2.3