diff options
| -rwxr-xr-x | indra/viewer_components/updater/CMakeLists.txt | 3 | ||||
| -rwxr-xr-x | indra/viewer_components/updater/llupdatechecker.cpp | 88 | ||||
| -rwxr-xr-x | indra/viewer_components/updater/llupdatechecker.h | 121 | 
3 files changed, 104 insertions, 108 deletions
| diff --git a/indra/viewer_components/updater/CMakeLists.txt b/indra/viewer_components/updater/CMakeLists.txt index 61fd4220e0..2e284bf993 100755 --- a/indra/viewer_components/updater/CMakeLists.txt +++ b/indra/viewer_components/updater/CMakeLists.txt @@ -9,12 +9,14 @@ endif(LL_TESTS)  include(CMakeCopyIfDifferent)  include(CURL)  include(LLCommon) +include(LLCoreHttp)  include(LLMessage)  include(LLPlugin)  include(LLVFS)  include_directories(      ${LLCOMMON_INCLUDE_DIRS} +	${LLCOREHTTP_INCLUDE_DIRS}      ${LLMESSAGE_INCLUDE_DIRS}      ${LLPLUGIN_INCLUDE_DIRS}      ${LLVFS_INCLUDE_DIRS} @@ -59,6 +61,7 @@ add_library(llupdaterservice  target_link_libraries(llupdaterservice      ${LLCOMMON_LIBRARIES} +	${LLCOREHTTP_LIBRARIES}      ${LLMESSAGE_LIBRARIES}      ${LLPLUGIN_LIBRARIES}      ${LLVFS_LIBRARIES} diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp index 8da4f88905..caeab35999 100755 --- a/indra/viewer_components/updater/llupdatechecker.cpp +++ b/indra/viewer_components/updater/llupdatechecker.cpp @@ -30,6 +30,7 @@  #include "llsd.h"  #include "llupdatechecker.h"  #include "lluri.h" +#include "llcorehttputil.h"  #if LL_DARWIN  #include <CoreServices/CoreServices.h>  #endif @@ -53,15 +54,12 @@ public:  // LLUpdateChecker  //----------------------------------------------------------------------------- - -  LLUpdateChecker::LLUpdateChecker(LLUpdateChecker::Client & client):  	mImplementation(new LLUpdateChecker::Implementation(client))  {  	; // No op.  } -  void LLUpdateChecker::checkVersion(std::string const & urlBase,   								   std::string const & channel,  								   std::string const & version, @@ -74,11 +72,8 @@ void LLUpdateChecker::checkVersion(std::string const & urlBase,  } -  // LLUpdateChecker::Implementation  //----------------------------------------------------------------------------- - -  const char * LLUpdateChecker::Implementation::sProtocolVersion = "v1.1"; @@ -121,57 +116,58 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase,  		std::string checkUrl = buildUrl(urlBase, channel, version, platform, platform_version, uniqueid, willing_to_test);  		LL_INFOS("UpdaterService") << "checking for updates at " << checkUrl << LL_ENDL; -	 -		mHttpClient.get(checkUrl, this); -	} -	else -	{ -		LL_WARNS("UpdaterService") << "attempting to restart a check when one is in progress; ignored" << LL_ENDL; -	} -} -void LLUpdateChecker::Implementation::httpCompleted() -{ -	mInProgress = false;	 +        LLCoros::instance().launch("LLUpdateChecker::Implementation::checkVersionCoro", +            boost::bind(&Implementation::checkVersionCoro, this, _1, checkUrl)); -	S32 status = getStatus(); -	const LLSD& content = getContent(); -	const std::string& reason = getReason(); -	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(); -		} - -		LL_WARNS("UpdaterService") << "response error " << status -								   << " " << reason -								   << " (" << server_error << ")" -								   << LL_ENDL; -		mClient.error(reason);  	}  	else  	{ -		mClient.response(content); +		LL_WARNS("UpdaterService") << "attempting to restart a check when one is in progress; ignored" << LL_ENDL;  	}  } - -void LLUpdateChecker::Implementation::httpFailure() +void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std::string &url)  { -	const std::string& reason = getReason(); -	mInProgress = false; -	LL_WARNS("UpdaterService") << "update check failed; " << reason << LL_ENDL; -	mClient.error(reason); +    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); +    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t +        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("checkVersionCoro", httpPolicy)); +    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + +    LL_INFOS("checkVersionCoro") << "Getting update information from " << url << LL_ENDL; + +    LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + +    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; +    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + +    mInProgress = false; + +    if (status != LLCore::HttpStatus(HTTP_OK)) +    { +        std::string server_error; +        if (result.has("error_code")) +        { +            server_error += result["error_code"].asString(); +        } +        if (result.has("error_text")) +        { +            server_error += server_error.empty() ? "" : ": "; +            server_error += result["error_text"].asString(); +        } + +        LL_WARNS("UpdaterService") << "response error " << status.getStatus() +            << " " << status.toString() +            << " (" << server_error << ")" +            << LL_ENDL; +        mClient.error(status.toString()); +        return; +    } + +    result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); +    mClient.response(result);  } -  std::string LLUpdateChecker::Implementation::buildUrl(std::string const & urlBase,   													  std::string const & channel,  													  std::string const & version, diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index 3163a6d53c..74af718a15 100755 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -31,60 +31,27 @@  #include "llmd5.h"  #include "llhttpclient.h" +#include "lleventcoro.h" +#include "llcoros.h"  //  // Implements asynchronous checking for updates.  //  class LLUpdateChecker {  public: -	class Client; -	class Implementation: public LLHTTPClient::Responder -	{ -	public: -		Implementation(Client & client); -		~Implementation(); -		void 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 -						  ); -	 -    protected: -		// Responder: -		virtual void httpCompleted(); -		virtual void httpFailure(); -	 -	private:	 -		static const char * sLegacyProtocolVersion; -		static const char * sProtocolVersion; -		const char* mProtocol; -		 -		Client & mClient; -		LLHTTPClient mHttpClient; -		bool         mInProgress; -		std::string   mVersion; -		std::string   mUrlBase; -		std::string   mChannel; -		std::string   mPlatform; -		std::string   mPlatformVersion; -		unsigned char mUniqueId[MD5HEX_STR_SIZE]; -		bool          mWillingToTest; -		 -		std::string 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); - -		LOG_CLASS(LLUpdateChecker::Implementation); -	}; +    // +    // The client interface implemented by a requestor checking for an update. +    // +    class Client +    { +    public: +        // An error occurred while checking for an update. +        virtual void error(std::string const & message) = 0; + +        // A successful response was received from the viewer version manager +        virtual void response(LLSD const & content) = 0; +    }; -	  	// An exception that may be raised on check errors.  	class CheckError; @@ -100,25 +67,55 @@ public:  					  bool                willing_to_test);  private: -	LLPointer<Implementation> mImplementation; -}; +    class Implementation +    { +    public: +        typedef boost::shared_ptr<Implementation> ptr_t; +        Implementation(Client & client); +        ~Implementation(); +        void 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 +            ); -class LLURI; // From lluri.h +    private: +        static const char * sLegacyProtocolVersion; +        static const char * sProtocolVersion; +        const char* mProtocol; -// -// The client interface implemented by a requestor checking for an update. -// -class LLUpdateChecker::Client -{ -public: -	// An error occurred while checking for an update. -	virtual void error(std::string const & message) = 0; -	 -	// A successful response was received from the viewer version manager -	virtual void response(LLSD const & content) = 0; -}; +        Client & mClient; +        LLHTTPClient mHttpClient; +        bool         mInProgress; +        std::string   mVersion; +        std::string   mUrlBase; +        std::string   mChannel; +        std::string   mPlatform; +        std::string   mPlatformVersion; +        unsigned char mUniqueId[MD5HEX_STR_SIZE]; +        bool          mWillingToTest; + +        std::string 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); + +        void checkVersionCoro(LLCoros::self& self, std::string &url); +        LOG_CLASS(LLUpdateChecker::Implementation); +    }; + + +    Implementation::ptr_t       mImplementation; +	//LLPointer<Implementation> mImplementation; +};  #endif | 
