summaryrefslogtreecommitdiff
path: root/indra/viewer_components/updater
diff options
context:
space:
mode:
authorAndrew A. de Laix <alain@lindenlab.com>2010-10-29 11:20:54 -0700
committerAndrew A. de Laix <alain@lindenlab.com>2010-10-29 11:20:54 -0700
commit609f5bd6810ca16a409f209610e6fac972348cba (patch)
tree8e886894260f3a42b362781a2e1b16cbeeb1ecd8 /indra/viewer_components/updater
parentca9594af28ce2e1cc8bb333a0fa7384dae718a9a (diff)
added periodic retry to look for updates
Diffstat (limited to 'indra/viewer_components/updater')
-rw-r--r--indra/viewer_components/updater/llupdatechecker.cpp19
-rw-r--r--indra/viewer_components/updater/llupdatechecker.h2
-rw-r--r--indra/viewer_components/updater/llupdaterservice.cpp63
3 files changed, 76 insertions, 8 deletions
diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp
index a19b8be607..ca2959a4ac 100644
--- a/indra/viewer_components/updater/llupdatechecker.cpp
+++ b/indra/viewer_components/updater/llupdatechecker.cpp
@@ -35,6 +35,7 @@ class LLUpdateChecker::Implementation:
public:
Implementation(Client & client);
+ ~Implementation();
void check(std::string const & host, std::string channel, std::string version);
// Responder:
@@ -49,6 +50,7 @@ private:
Client & mClient;
LLHTTPClient mHttpClient;
bool mInProgress;
+ LLHTTPClient::ResponderPtr mMe;
std::string mVersion;
LOG_CLASS(LLUpdateChecker::Implementation);
@@ -80,21 +82,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 +114,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();
}
}
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;
+}
//-----------------------------------------------------------------------