diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/app_settings/settings.xml | 2 | ||||
-rw-r--r-- | indra/viewer_components/updater/llupdatechecker.cpp | 29 | ||||
-rw-r--r-- | indra/viewer_components/updater/llupdatechecker.h | 2 | ||||
-rw-r--r-- | indra/viewer_components/updater/llupdaterservice.cpp | 63 | ||||
-rw-r--r-- | indra/viewer_components/updater/llupdaterservice.h | 2 |
5 files changed, 85 insertions, 13 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 371326c0f5..274c7fbeb8 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -11022,7 +11022,7 @@ <key>Type</key> <string>String</string> <key>Value</key> - <string>http://secondlife.com/app/update</string> + <string>http://localhost/agni</string> </map> <key>UploadBakedTexOld</key> <map> diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp index a19b8be607..941210d35b 100644 --- a/indra/viewer_components/updater/llupdatechecker.cpp +++ b/indra/viewer_components/updater/llupdatechecker.cpp @@ -26,7 +26,9 @@ #include "linden_common.h" #include <boost/format.hpp> #include "llhttpclient.h" +#include "llsd.h" #include "llupdatechecker.h" +#include "lluri.h" class LLUpdateChecker::Implementation: @@ -35,6 +37,7 @@ class LLUpdateChecker::Implementation: public: Implementation(Client & client); + ~Implementation(); void check(std::string const & host, std::string channel, std::string version); // Responder: @@ -49,6 +52,7 @@ private: Client & mClient; LLHTTPClient mHttpClient; bool mInProgress; + LLHTTPClient::ResponderPtr mMe; std::string mVersion; LOG_CLASS(LLUpdateChecker::Implementation); @@ -80,21 +84,28 @@ void LLUpdateChecker::check(std::string const & host, std::string channel, std:: LLUpdateChecker::Implementation::Implementation(LLUpdateChecker::Client & client): mClient(client), - mInProgress(false) + mInProgress(false), + mMe(this) { ; // No op. } +LLUpdateChecker::Implementation::~Implementation() +{ + mMe.reset(0); +} + + void LLUpdateChecker::Implementation::check(std::string const & host, std::string channel, std::string version) { - llassert(!mInProgress); + // llassert(!mInProgress); mInProgress = true; mVersion = version; std::string checkUrl = buildUrl(host, channel, version); LL_INFOS("UpdateCheck") << "checking for updates at " << checkUrl << llendl; - mHttpClient.get(checkUrl, this); + mHttpClient.get(checkUrl, mMe); } void LLUpdateChecker::Implementation::completed(U32 status, @@ -105,12 +116,16 @@ void LLUpdateChecker::Implementation::completed(U32 status, if(status != 200) { LL_WARNS("UpdateCheck") << "html error " << status << " (" << reason << ")" << llendl; + mClient.error(reason); } else if(!content["valid"].asBoolean()) { LL_INFOS("UpdateCheck") << "version invalid" << llendl; + mClient.requiredUpdate(content["latest_version"].asString()); } else if(content["latest_version"].asString() != mVersion) { LL_INFOS("UpdateCheck") << "newer version " << content["latest_version"].asString() << " available" << llendl; + mClient.optionalUpdate(content["latest_version"].asString()); } else { LL_INFOS("UpdateCheck") << "up to date" << llendl; + mClient.upToDate(); } } @@ -124,8 +139,10 @@ void LLUpdateChecker::Implementation::error(U32 status, const std::string & reas std::string LLUpdateChecker::Implementation::buildUrl(std::string const & host, std::string channel, std::string version) { - static boost::format urlFormat("%s/version/%s/%s"); - urlFormat % host % channel % version; - return urlFormat.str(); + LLSD path; + path.append("version"); + path.append(channel); + path.append(version); + return LLURI::buildHTTP(host, path).asString(); } diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index d2ec848e14..b630c4d8a6 100644 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -42,6 +42,7 @@ public: // Check status of current app on the given host for the channel and version provided. void check(std::string const & hostUrl, std::string channel, std::string version); + private: boost::shared_ptr<Implementation> mImplementation; }; @@ -52,6 +53,7 @@ private: // class LLUpdateChecker::Client { +public: // An error occurred while checking for an update. virtual void error(std::string const & message) = 0; diff --git a/indra/viewer_components/updater/llupdaterservice.cpp b/indra/viewer_components/updater/llupdaterservice.cpp index e0f23722dd..2633dbc015 100644 --- a/indra/viewer_components/updater/llupdaterservice.cpp +++ b/indra/viewer_components/updater/llupdaterservice.cpp @@ -25,6 +25,8 @@ #include "linden_common.h" +#include "llevents.h" +#include "lltimer.h" #include "llupdaterservice.h" #include "llupdatechecker.h" @@ -38,6 +40,8 @@ class LLUpdaterServiceImpl : public LLPluginProcessParentOwner, public LLUpdateChecker::Client { + static const std::string ListenerName; + std::string mUrl; std::string mChannel; std::string mVersion; @@ -47,10 +51,15 @@ class LLUpdaterServiceImpl : boost::scoped_ptr<LLPluginProcessParent> mPlugin; LLUpdateChecker mUpdateChecker; + LLTimer mTimer; + + void retry(void); + + LOG_CLASS(LLUpdaterServiceImpl); public: LLUpdaterServiceImpl(); - virtual ~LLUpdaterServiceImpl() {} + virtual ~LLUpdaterServiceImpl(); // LLPluginProcessParentOwner interfaces virtual void receivePluginMessage(const LLPluginMessage &message); @@ -74,8 +83,10 @@ public: virtual void requiredUpdate(std::string const & newVersion); virtual void upToDate(void); + bool onMainLoop(LLSD const & event); }; +const std::string LLUpdaterServiceImpl::ListenerName = "LLUpdaterServiceImpl"; LLUpdaterServiceImpl::LLUpdaterServiceImpl() : mIsChecking(false), @@ -87,6 +98,12 @@ LLUpdaterServiceImpl::LLUpdaterServiceImpl() : mPlugin.reset(new LLPluginProcessParent(this)); } +LLUpdaterServiceImpl::~LLUpdaterServiceImpl() +{ + LL_INFOS("UpdaterService") << "shutting down updater service" << LL_ENDL; + LLEventPumps::instance().obtain("mainloop").stopListening(ListenerName); +} + // LLPluginProcessParentOwner interfaces void LLUpdaterServiceImpl::receivePluginMessage(const LLPluginMessage &message) { @@ -153,13 +170,49 @@ bool LLUpdaterServiceImpl::isChecking() return mIsChecking; } -void LLUpdaterServiceImpl::error(std::string const & message) {} +void LLUpdaterServiceImpl::error(std::string const & message) +{ + retry(); +} -void LLUpdaterServiceImpl::optionalUpdate(std::string const & newVersion) {} +void LLUpdaterServiceImpl::optionalUpdate(std::string const & newVersion) +{ + retry(); +} -void LLUpdaterServiceImpl::requiredUpdate(std::string const & newVersion) {} +void LLUpdaterServiceImpl::requiredUpdate(std::string const & newVersion) +{ + retry(); +} -void LLUpdaterServiceImpl::upToDate(void) {} +void LLUpdaterServiceImpl::upToDate(void) +{ + retry(); +} + +void LLUpdaterServiceImpl::retry(void) +{ + LL_INFOS("UpdaterService") << "will check for update again in " << + mCheckPeriod << " seconds" << LL_ENDL; + mTimer.start(); + mTimer.setTimerExpirySec(mCheckPeriod); + LLEventPumps::instance().obtain("mainloop").listen( + ListenerName, boost::bind(&LLUpdaterServiceImpl::onMainLoop, this, _1)); +} + +bool LLUpdaterServiceImpl::onMainLoop(LLSD const & event) +{ + if(mTimer.hasExpired()) + { + mTimer.stop(); + LLEventPumps::instance().obtain("mainloop").stopListening(ListenerName); + mUpdateChecker.check(mUrl, mChannel, mVersion); + } else { + // Keep on waiting... + } + + return false; +} //----------------------------------------------------------------------- diff --git a/indra/viewer_components/updater/llupdaterservice.h b/indra/viewer_components/updater/llupdaterservice.h index 6459ca49f8..313ae8ada3 100644 --- a/indra/viewer_components/updater/llupdaterservice.h +++ b/indra/viewer_components/updater/llupdaterservice.h @@ -58,4 +58,4 @@ private: boost::shared_ptr<LLUpdaterServiceImpl> mImpl; }; -#endif LL_UPDATERSERVICE_H +#endif // LL_UPDATERSERVICE_H |