diff options
| author | Oz Linden <oz@lindenlab.com> | 2013-05-10 10:56:40 -0400 | 
|---|---|---|
| committer | Oz Linden <oz@lindenlab.com> | 2013-05-10 10:56:40 -0400 | 
| commit | 4d22c32aa9ac42b4a720200386d68339e8656974 (patch) | |
| tree | c84419f0f3ac44d2f64b7082c3c69c1fbec919d2 /indra/viewer_components/updater/llupdaterservice.cpp | |
| parent | 73e6711268adb93025386ffb766055125f0d849e (diff) | |
| parent | 33d9adfa9a07e0bf6f6ebd8213e843048ec92392 (diff) | |
merge changes for 3.5.2-beta4
Diffstat (limited to 'indra/viewer_components/updater/llupdaterservice.cpp')
| -rwxr-xr-x[-rw-r--r--] | indra/viewer_components/updater/llupdaterservice.cpp | 204 | 
1 files changed, 132 insertions, 72 deletions
diff --git a/indra/viewer_components/updater/llupdaterservice.cpp b/indra/viewer_components/updater/llupdaterservice.cpp index bc73c72ddc..1bd9fa4fc0 100644..100755 --- a/indra/viewer_components/updater/llupdaterservice.cpp +++ b/indra/viewer_components/updater/llupdaterservice.cpp @@ -32,7 +32,6 @@  #include "lltimer.h"  #include "llupdatechecker.h"  #include "llupdateinstaller.h" -#include "llversionviewer.h"  #include <boost/scoped_ptr.hpp>  #include <boost/weak_ptr.hpp> @@ -44,6 +43,12 @@  #pragma warning (disable : 4355) // 'this' used in initializer list: yes, intentionally  #endif +#if ! defined(LL_VIEWER_VERSION_MAJOR)			\ + || ! defined(LL_VIEWER_VERSION_MINOR)			\ + || ! defined(LL_VIEWER_VERSION_PATCH)			\ + || ! defined(LL_VIEWER_VERSION_BUILD) +#error "Version information is undefined" +#endif  namespace   { @@ -60,6 +65,8 @@ namespace  	{  #ifdef LL_WINDOWS  		std::string scriptFile = "update_install.bat"; +#elif LL_DARWIN +		std::string scriptFile = "update_install.py";  #else  		std::string scriptFile = "update_install";  #endif @@ -71,6 +78,8 @@ namespace  #ifdef LL_WINDOWS  		return LL_COPY_INSTALL_SCRIPT_TO_TEMP;  #else +		// This is important on Mac because update_install.py looks at its own +		// script pathname to discover the viewer app bundle to update.  		return LL_RUN_INSTALL_SCRIPT_IN_PLACE;  #endif  	}; @@ -83,11 +92,15 @@ class LLUpdaterServiceImpl :  {  	static const std::string sListenerName; -	std::string mProtocolVersion; -	std::string mUrl; -	std::string mPath; -	std::string mChannel; -	std::string mVersion; +	std::string   mProtocolVersion; +	std::string   mUrl; +	std::string   mPath; +	std::string   mChannel; +	std::string   mVersion; +	std::string   mPlatform; +	std::string   mPlatformVersion; +	unsigned char mUniqueId[MD5HEX_STR_SIZE]; +	bool          mWillingToTest;  	unsigned int mCheckPeriod;  	bool mIsChecking; @@ -107,11 +120,15 @@ public:  	LLUpdaterServiceImpl();  	virtual ~LLUpdaterServiceImpl(); -	void initialize(const std::string& protocol_version, -				   const std::string& url,  -				   const std::string& path, -				   const std::string& channel, -				   const std::string& version); +	void initialize(const std::string& 	url,  +					const std::string& 	path, +					const std::string& 	channel, +					const std::string& 	version, +					const std::string&  platform, +					const std::string&  platform_version, +					const unsigned char uniqueid[MD5HEX_STR_SIZE], +					const bool&         willing_to_test					 +					);  	void setCheckPeriod(unsigned int seconds);  	void setBandwidthLimit(U64 bytesPerSecond); @@ -129,13 +146,9 @@ public:  	// LLUpdateChecker::Client:  	virtual void error(std::string const & message); -	virtual void optionalUpdate(std::string const & newVersion, -								LLURI const & uri, -								std::string const & hash); -	virtual void requiredUpdate(std::string const & newVersion, -								LLURI const & uri, -								std::string const & hash); -	virtual void upToDate(void); +	 +	// A successful response was received from the viewer version manager +	virtual void response(LLSD const & content);  	// LLUpdateDownloader::Client  	void downloadComplete(LLSD const & data); @@ -144,6 +157,7 @@ public:  	bool onMainLoop(LLSD const & event);  private: +	std::string mNewChannel;  	std::string mNewVersion;  	void restartTimer(unsigned int seconds); @@ -169,11 +183,14 @@ LLUpdaterServiceImpl::~LLUpdaterServiceImpl()  	LLEventPumps::instance().obtain("mainloop").stopListening(sListenerName);  } -void LLUpdaterServiceImpl::initialize(const std::string& protocol_version, -									  const std::string& url,  -									  const std::string& path, -									  const std::string& channel, -									  const std::string& version) +void LLUpdaterServiceImpl::initialize(const std::string&  url,  +									  const std::string&  path, +									  const std::string&  channel, +									  const std::string&  version, +									  const std::string&  platform, +									  const std::string&  platform_version, +									  const unsigned char uniqueid[MD5HEX_STR_SIZE], +									  const bool&         willing_to_test)  {  	if(mIsChecking || mIsDownloading)  	{ @@ -181,11 +198,22 @@ void LLUpdaterServiceImpl::initialize(const std::string& protocol_version,  										   "while updater is running.");  	} -	mProtocolVersion = protocol_version;  	mUrl = url;  	mPath = path;  	mChannel = channel;  	mVersion = version; +	mPlatform = platform; +	mPlatformVersion = platform_version; +	memcpy(mUniqueId, uniqueid, MD5HEX_STR_SIZE); +	mWillingToTest = willing_to_test; +	LL_DEBUGS("UpdaterService") +		<< "\n  url: " << mUrl +		<< "\n  path: " << mPath +		<< "\n  channel: " << mChannel +		<< "\n  version: " << mVersion +		<< "\n  uniqueid: " << mUniqueId +		<< "\n  willing: " << ( mWillingToTest ? "testok" : "testno" ) +		<< LL_ENDL;  }  void LLUpdaterServiceImpl::setCheckPeriod(unsigned int seconds) @@ -284,7 +312,7 @@ bool LLUpdaterServiceImpl::checkForInstall(bool launchInstaller)  			// the update.  Do not install this update.  			if(!path.asString().empty())  			{ -				llinfos << "ignoring update dowloaded by different client version" << llendl; +				LL_INFOS("UpdaterService") << "ignoring update dowloaded by different client version" << LL_ENDL;;  				LLFile::remove(path.asString());  				LLFile::remove(update_marker_path());  			} @@ -311,9 +339,13 @@ bool LLUpdaterServiceImpl::checkForInstall(bool launchInstaller)  				if((result == 0) && mAppExitCallback)  				{  					mAppExitCallback(); -				} else if(result != 0) { -					llwarns << "failed to run update install script" << LL_ENDL; -				} else { +				} +				else if(result != 0) +				{ +					LL_WARNS("UpdaterService") << "failed to run update install script" << LL_ENDL; +				} +				else +				{  					; // No op.  				}  			} @@ -341,15 +373,19 @@ bool LLUpdaterServiceImpl::checkForResume()  			{  				mIsDownloading = true;  				mNewVersion = download_info["update_version"].asString(); +				mNewChannel = download_info["update_channel"].asString();  				mUpdateDownloader.resume();  				result = true;  			}  			else   			{  				// The viewer that started this download is not the same as this viewer; ignore. -				llinfos << "ignoring partial download from different viewer version" << llendl; +				LL_INFOS("UpdaterService") << "ignoring partial download from different viewer version" << LL_ENDL;;  				std::string path = download_info["path"].asString(); -				if(!path.empty()) LLFile::remove(path); +				if(!path.empty()) +				{ +					LLFile::remove(path); +				}  				LLFile::remove(download_marker_path);  			}  		}  @@ -366,36 +402,43 @@ void LLUpdaterServiceImpl::error(std::string const & message)  	}  } -void LLUpdaterServiceImpl::optionalUpdate(std::string const & newVersion, -										  LLURI const & uri, -										  std::string const & hash) +// A successful response was received from the viewer version manager +void LLUpdaterServiceImpl::response(LLSD const & content)  { -	stopTimer(); -	mNewVersion = newVersion; -	mIsDownloading = true; -	setState(LLUpdaterService::DOWNLOADING); -	mUpdateDownloader.download(uri, hash, newVersion, false); -} - -void LLUpdaterServiceImpl::requiredUpdate(std::string const & newVersion, -										  LLURI const & uri, -										  std::string const & hash) -{ -	stopTimer(); -	mNewVersion = newVersion; -	mIsDownloading = true; -	setState(LLUpdaterService::DOWNLOADING); -	mUpdateDownloader.download(uri, hash, newVersion, true); -} - -void LLUpdaterServiceImpl::upToDate(void) -{ -	if(mIsChecking) +	if(!content.asBoolean()) // an empty response means "no update"  	{ -		restartTimer(mCheckPeriod); -	} +		LL_INFOS("UpdaterService") << "up to date" << LL_ENDL; +		if(mIsChecking) +		{ +			restartTimer(mCheckPeriod); +		} -	setState(LLUpdaterService::UP_TO_DATE); +		setState(LLUpdaterService::UP_TO_DATE); +	} +	else +	{ +		// there is an update available... +		stopTimer(); +		mNewChannel = content["channel"].asString(); +		if (mNewChannel.empty()) +		{ +			LL_INFOS("UpdaterService") << "no channel supplied, assuming current channel" << LL_ENDL; +			mNewChannel = mChannel; +		} +		mNewVersion = content["version"].asString(); +		mIsDownloading = true; +		setState(LLUpdaterService::DOWNLOADING); +		BOOL required = content["required"].asBoolean(); +		LLURI url(content["url"].asString()); +		std::string more_info = content["more_info"].asString(); +		LL_DEBUGS("UpdaterService") +			<< "Starting download of " +			<< ( required ? "required" : "optional" ) << " update" +			<< " to channel '" << mNewChannel << "' version " << mNewVersion +			<< " more info '" << more_info << "'" +			<< LL_ENDL; +		mUpdateDownloader.download(url, content["hash"].asString(), mNewChannel, mNewVersion, more_info, required); +	}  }  void LLUpdaterServiceImpl::downloadComplete(LLSD const & data)  @@ -413,9 +456,19 @@ void LLUpdaterServiceImpl::downloadComplete(LLSD const & data)  	payload["type"] = LLSD(LLUpdaterService::DOWNLOAD_COMPLETE);  	payload["required"] = data["required"];  	payload["version"] = mNewVersion; +	payload["channel"] = mNewChannel; +	payload["info_url"] = data["info_url"];  	event["payload"] = payload; +	LL_DEBUGS("UpdaterService") +		<< "Download complete " +		<< ( data["required"].asBoolean() ? "required" : "optional" ) +		<< " channel " << mNewChannel +		<< " version " << mNewVersion +		<< " info " << data["info_url"].asString() +		<< LL_ENDL; +  	LLEventPumps::instance().obtain("mainlooprepeater").post(event); -	 +  	setState(LLUpdaterService::TERMINAL);  } @@ -489,15 +542,18 @@ bool LLUpdaterServiceImpl::onMainLoop(LLSD const & event)  		// Check for failed install.  		if(LLFile::isfile(ll_install_failed_marker_path()))  		{ +			LL_DEBUGS("UpdaterService") << "found marker " << ll_install_failed_marker_path() << LL_ENDL;;  			int requiredValue = 0;   			{  				llifstream stream(ll_install_failed_marker_path());  				stream >> requiredValue; -				if(stream.fail()) requiredValue = 0; +				if(stream.fail()) +				{ +					requiredValue = 0; +				}  			}  			// TODO: notify the user. -			llinfos << "found marker " << ll_install_failed_marker_path() << llendl; -			llinfos << "last install attempt failed" << llendl; +			LL_WARNS("UpdaterService") << "last install attempt failed" << LL_ENDL;;  			LLFile::remove(ll_install_failed_marker_path());  			LLSD event; @@ -509,7 +565,7 @@ bool LLUpdaterServiceImpl::onMainLoop(LLSD const & event)  		}  		else  		{ -			mUpdateChecker.checkVersion(mProtocolVersion, mUrl, mPath, mChannel, mVersion); +			mUpdateChecker.checkVersion(mUrl, mPath, mChannel, mVersion, mPlatform, mPlatformVersion, mUniqueId, mWillingToTest);  			setState(LLUpdaterService::CHECKING_FOR_UPDATE);  		}  	}  @@ -554,13 +610,17 @@ LLUpdaterService::~LLUpdaterService()  {  } -void LLUpdaterService::initialize(const std::string& protocol_version, -								 const std::string& url,  -								 const std::string& path, -								 const std::string& channel, -								 const std::string& version) +void LLUpdaterService::initialize(const std::string& url,  +								  const std::string& path, +								  const std::string& channel, +								  const std::string& version, +								  const std::string& platform, +								  const std::string& platform_version, +								  const unsigned char uniqueid[MD5HEX_STR_SIZE], +								  const bool&         willing_to_test +)  { -	mImpl->initialize(protocol_version, url, path, channel, version); +	mImpl->initialize(url, path, channel, version, platform, platform_version, uniqueid, willing_to_test);  }  void LLUpdaterService::setCheckPeriod(unsigned int seconds) @@ -609,10 +669,10 @@ std::string const & ll_get_version(void) {  	if (version.empty()) {  		std::ostringstream stream; -		stream << LL_VERSION_MAJOR << "." -		<< LL_VERSION_MINOR << "." -		<< LL_VERSION_PATCH << "." -		<< LL_VERSION_BUILD; +		stream << LL_VIEWER_VERSION_MAJOR << "." +			   << LL_VIEWER_VERSION_MINOR << "." +			   << LL_VIEWER_VERSION_PATCH << "." +			   << LL_VIEWER_VERSION_BUILD;  		version = stream.str();  	}  | 
