diff options
author | Mark Palange (Mani) <palange@lindenlab.com> | 2010-11-01 15:22:02 -0700 |
---|---|---|
committer | Mark Palange (Mani) <palange@lindenlab.com> | 2010-11-01 15:22:02 -0700 |
commit | 730ffc4a483dec799d1ec770bff0bb2fcc8f9dc1 (patch) | |
tree | 925fa047a1fbfc2d060e88098a32c2ba8b30a233 /indra/viewer_components/updater/llupdaterservice.cpp | |
parent | 9b457982305c624468aa32e06a1c0df713d0b53c (diff) | |
parent | 2125bc0bbb3a5493b0b96bf68889b1f44b2db011 (diff) |
Merge
Diffstat (limited to 'indra/viewer_components/updater/llupdaterservice.cpp')
-rw-r--r-- | indra/viewer_components/updater/llupdaterservice.cpp | 88 |
1 files changed, 85 insertions, 3 deletions
diff --git a/indra/viewer_components/updater/llupdaterservice.cpp b/indra/viewer_components/updater/llupdaterservice.cpp index 28c942b5f2..1d0ead3cd4 100644 --- a/indra/viewer_components/updater/llupdaterservice.cpp +++ b/indra/viewer_components/updater/llupdaterservice.cpp @@ -25,16 +25,27 @@ #include "linden_common.h" +#include "llevents.h" +#include "lltimer.h" #include "llupdaterservice.h" +#include "llupdatechecker.h" #include "llpluginprocessparent.h" #include <boost/scoped_ptr.hpp> #include <boost/weak_ptr.hpp> +#if LL_WINDOWS +#pragma warning (disable : 4355) // 'this' used in initializer list: yes, intentionally +#endif + boost::weak_ptr<LLUpdaterServiceImpl> gUpdater; -class LLUpdaterServiceImpl : public LLPluginProcessParentOwner +class LLUpdaterServiceImpl : + public LLPluginProcessParentOwner, + public LLUpdateChecker::Client { + static const std::string ListenerName; + std::string mUrl; std::string mChannel; std::string mVersion; @@ -42,10 +53,17 @@ class LLUpdaterServiceImpl : public LLPluginProcessParentOwner unsigned int mCheckPeriod; bool mIsChecking; 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); @@ -62,17 +80,34 @@ public: void startChecking(); void stopChecking(); bool isChecking(); + + // LLUpdateChecker::Client: + virtual void error(std::string const & message); + virtual void optionalUpdate(std::string const & newVersion); + 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), mCheckPeriod(0), - mPlugin(0) + mPlugin(0), + mUpdateChecker(*this) { // Create the plugin parent, this is the owner. 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) { @@ -121,6 +156,8 @@ void LLUpdaterServiceImpl::startChecking() "LLUpdaterService::startCheck()."); } mIsChecking = true; + + mUpdateChecker.check(mUrl, mChannel, mVersion); } } @@ -137,6 +174,51 @@ bool LLUpdaterServiceImpl::isChecking() return mIsChecking; } +void LLUpdaterServiceImpl::error(std::string const & message) +{ + retry(); +} + +void LLUpdaterServiceImpl::optionalUpdate(std::string const & newVersion) +{ + retry(); +} + +void LLUpdaterServiceImpl::requiredUpdate(std::string const & newVersion) +{ + retry(); +} + +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; +} + + //----------------------------------------------------------------------- // Facade interface LLUpdaterService::LLUpdaterService() |