summaryrefslogtreecommitdiff
path: root/indra/viewer_components/updater
diff options
context:
space:
mode:
authorAndrew A. de Laix <alain@lindenlab.com>2010-11-04 14:08:14 -0700
committerAndrew A. de Laix <alain@lindenlab.com>2010-11-04 14:08:14 -0700
commitdfeb7abe5f690bbd3a908c84c53bbea20a5adb7c (patch)
tree79ec9dbeb8520a3b377915785e97f082099a0313 /indra/viewer_components/updater
parent7622ab9249506539894d0e33d4c2a8fd9fb3e3ac (diff)
checker working with v1.0 update protocol.
Diffstat (limited to 'indra/viewer_components/updater')
-rw-r--r--indra/viewer_components/updater/llupdatechecker.cpp52
-rw-r--r--indra/viewer_components/updater/llupdatechecker.h3
-rw-r--r--indra/viewer_components/updater/llupdatedownloader.cpp1
-rw-r--r--indra/viewer_components/updater/llupdaterservice.cpp28
-rw-r--r--indra/viewer_components/updater/llupdaterservice.h6
-rw-r--r--indra/viewer_components/updater/tests/llupdaterservice_test.cpp11
6 files changed, 65 insertions, 36 deletions
diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp
index 596b122a25..2c60636122 100644
--- a/indra/viewer_components/updater/llupdatechecker.cpp
+++ b/indra/viewer_components/updater/llupdatechecker.cpp
@@ -41,7 +41,8 @@ public:
Implementation(Client & client);
~Implementation();
- void check(std::string const & host, std::string channel, std::string version);
+ void check(std::string const & protocolVersion, std::string const & hostUrl,
+ std::string const & servicePath, std::string channel, std::string version);
// Responder:
virtual void completed(U32 status,
@@ -50,7 +51,8 @@ public:
virtual void error(U32 status, const std::string & reason);
private:
- std::string buildUrl(std::string const & host, std::string channel, std::string version);
+ std::string buildUrl(std::string const & protocolVersion, std::string const & hostUrl,
+ std::string const & servicePath, std::string channel, std::string version);
Client & mClient;
LLHTTPClient mHttpClient;
@@ -74,9 +76,10 @@ LLUpdateChecker::LLUpdateChecker(LLUpdateChecker::Client & client):
}
-void LLUpdateChecker::check(std::string const & host, std::string channel, std::string version)
+void LLUpdateChecker::check(std::string const & protocolVersion, std::string const & hostUrl,
+ std::string const & servicePath, std::string channel, std::string version)
{
- mImplementation->check(host, channel, version);
+ mImplementation->check(protocolVersion, hostUrl, servicePath, channel, version);
}
@@ -100,13 +103,14 @@ LLUpdateChecker::Implementation::~Implementation()
}
-void LLUpdateChecker::Implementation::check(std::string const & host, std::string channel, std::string version)
+void LLUpdateChecker::Implementation::check(std::string const & protocolVersion, std::string const & hostUrl,
+ std::string const & servicePath, std::string channel, std::string version)
{
// llassert(!mInProgress);
mInProgress = true;
mVersion = version;
- std::string checkUrl = buildUrl(host, channel, version);
+ std::string checkUrl = buildUrl(protocolVersion, hostUrl, servicePath, channel, version);
LL_INFOS("UpdateCheck") << "checking for updates at " << checkUrl << llendl;
// The HTTP client will wrap a raw pointer in a boost::intrusive_ptr causing the
@@ -125,17 +129,17 @@ 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;
- LLURI uri(content["download_url"].asString());
- mClient.requiredUpdate(content["latest_version"].asString(), uri);
- } else if(content["latest_version"].asString() != mVersion) {
- LL_INFOS("UpdateCheck") << "newer version " << content["latest_version"].asString() << " available" << llendl;
- LLURI uri(content["download_url"].asString());
- mClient.optionalUpdate(content["latest_version"].asString(), uri);
- } else {
+ } else if(!content.asBoolean()) {
LL_INFOS("UpdateCheck") << "up to date" << llendl;
mClient.upToDate();
+ } else if(content["required"].asBoolean()) {
+ LL_INFOS("UpdateCheck") << "version invalid" << llendl;
+ LLURI uri(content["url"].asString());
+ mClient.requiredUpdate(content["version"].asString(), uri);
+ } else {
+ LL_INFOS("UpdateCheck") << "newer version " << content["version"].asString() << " available" << llendl;
+ LLURI uri(content["url"].asString());
+ mClient.optionalUpdate(content["version"].asString(), uri);
}
}
@@ -144,14 +148,26 @@ void LLUpdateChecker::Implementation::error(U32 status, const std::string & reas
{
mInProgress = false;
LL_WARNS("UpdateCheck") << "update check failed; " << reason << llendl;
+ mClient.error(reason);
}
-std::string LLUpdateChecker::Implementation::buildUrl(std::string const & host, std::string channel, std::string version)
+std::string LLUpdateChecker::Implementation::buildUrl(std::string const & protocolVersion, std::string const & hostUrl,
+ std::string const & servicePath, std::string channel, std::string version)
{
+#ifdef LL_WINDOWS
+ static const char * platform = "win";
+#elif LL_DARWIN
+ static const char * platform = "mac";
+#else
+ static const char * platform = "lnx";
+#endif
+
LLSD path;
- path.append("version");
+ path.append(servicePath);
+ path.append(protocolVersion);
path.append(channel);
path.append(version);
- return LLURI::buildHTTP(host, path).asString();
+ path.append(platform);
+ return LLURI::buildHTTP(hostUrl, path).asString();
}
diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h
index 1f8c6d8a91..58aaee4e3d 100644
--- a/indra/viewer_components/updater/llupdatechecker.h
+++ b/indra/viewer_components/updater/llupdatechecker.h
@@ -41,7 +41,8 @@ public:
LLUpdateChecker(Client & client);
// 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);
+ void check(std::string const & protocolVersion, std::string const & hostUrl,
+ std::string const & servicePath, std::string channel, std::string version);
private:
boost::shared_ptr<Implementation> mImplementation;
diff --git a/indra/viewer_components/updater/llupdatedownloader.cpp b/indra/viewer_components/updater/llupdatedownloader.cpp
index 21e4ce94cc..087d79f804 100644
--- a/indra/viewer_components/updater/llupdatedownloader.cpp
+++ b/indra/viewer_components/updater/llupdatedownloader.cpp
@@ -222,6 +222,7 @@ void LLUpdateDownloader::Implementation::initializeCurlGet(std::string const & u
CURLcode code;
code = curl_easy_setopt(mCurl, CURLOPT_NOSIGNAL, true);
+ code = curl_easy_setopt(mCurl, CURLOPT_FOLLOWLOCATION, true);
code = curl_easy_setopt(mCurl, CURLOPT_WRITEFUNCTION, &write_function);
code = curl_easy_setopt(mCurl, CURLOPT_WRITEDATA, this);
code = curl_easy_setopt(mCurl, CURLOPT_HEADERFUNCTION, &header_function);
diff --git a/indra/viewer_components/updater/llupdaterservice.cpp b/indra/viewer_components/updater/llupdaterservice.cpp
index a1b6de38e5..e865552fb3 100644
--- a/indra/viewer_components/updater/llupdaterservice.cpp
+++ b/indra/viewer_components/updater/llupdaterservice.cpp
@@ -48,7 +48,9 @@ class LLUpdaterServiceImpl :
{
static const std::string sListenerName;
+ std::string mProtocolVersion;
std::string mUrl;
+ std::string mPath;
std::string mChannel;
std::string mVersion;
@@ -74,10 +76,12 @@ public:
virtual void pluginLaunchFailed();
virtual void pluginDied();
- void setParams(const std::string& url,
+ void setParams(const std::string& protocol_version,
+ const std::string& url,
+ const std::string& path,
const std::string& channel,
const std::string& version);
-
+
void setCheckPeriod(unsigned int seconds);
void startChecking();
@@ -134,7 +138,9 @@ void LLUpdaterServiceImpl::pluginDied()
{
};
-void LLUpdaterServiceImpl::setParams(const std::string& url,
+void LLUpdaterServiceImpl::setParams(const std::string& protocol_version,
+ const std::string& url,
+ const std::string& path,
const std::string& channel,
const std::string& version)
{
@@ -144,7 +150,9 @@ void LLUpdaterServiceImpl::setParams(const std::string& url,
" before setting params.");
}
+ mProtocolVersion = protocol_version;
mUrl = url;
+ mPath = path;
mChannel = channel;
mVersion = version;
}
@@ -165,7 +173,7 @@ void LLUpdaterServiceImpl::startChecking()
}
mIsChecking = true;
- mUpdateChecker.check(mUrl, mChannel, mVersion);
+ mUpdateChecker.check(mProtocolVersion, mUrl, mPath, mChannel, mVersion);
}
}
@@ -218,7 +226,7 @@ bool LLUpdaterServiceImpl::onMainLoop(LLSD const & event)
{
mTimer.stop();
LLEventPumps::instance().obtain("mainloop").stopListening(sListenerName);
- mUpdateChecker.check(mUrl, mChannel, mVersion);
+ mUpdateChecker.check(mProtocolVersion, mUrl, mPath, mChannel, mVersion);
} else {
// Keep on waiting...
}
@@ -247,11 +255,13 @@ LLUpdaterService::~LLUpdaterService()
{
}
-void LLUpdaterService::setParams(const std::string& url,
- const std::string& chan,
- const std::string& vers)
+void LLUpdaterService::setParams(const std::string& protocol_version,
+ const std::string& url,
+ const std::string& path,
+ const std::string& channel,
+ const std::string& version)
{
- mImpl->setParams(url, chan, vers);
+ mImpl->setParams(protocol_version, url, path, channel, version);
}
void LLUpdaterService::setCheckPeriod(unsigned int seconds)
diff --git a/indra/viewer_components/updater/llupdaterservice.h b/indra/viewer_components/updater/llupdaterservice.h
index 313ae8ada3..83b09c4bdd 100644
--- a/indra/viewer_components/updater/llupdaterservice.h
+++ b/indra/viewer_components/updater/llupdaterservice.h
@@ -42,9 +42,9 @@ public:
LLUpdaterService();
~LLUpdaterService();
- // The base URL.
- // *NOTE:Mani The grid, if any, would be embedded in the base URL.
- void setParams(const std::string& url,
+ void setParams(const std::string& version,
+ const std::string& url,
+ const std::string& path,
const std::string& channel,
const std::string& version);
diff --git a/indra/viewer_components/updater/tests/llupdaterservice_test.cpp b/indra/viewer_components/updater/tests/llupdaterservice_test.cpp
index 0ffc1f2c70..958526e35b 100644
--- a/indra/viewer_components/updater/tests/llupdaterservice_test.cpp
+++ b/indra/viewer_components/updater/tests/llupdaterservice_test.cpp
@@ -60,9 +60,10 @@ LLPluginMessage::LLPluginMessage(LLPluginMessage const&) {}
LLUpdateChecker::LLUpdateChecker(LLUpdateChecker::Client & client)
{}
-void LLUpdateChecker::check(std::string const & host, std::string channel, std::string version){}
-LLUpdateDownloader::LLUpdateDownloader(LLUpdateDownloader::Client & client)
+void LLUpdateChecker::check(std::string const & protocolVersion, std::string const & hostUrl,
+ std::string const & servicePath, std::string channel, std::string version)
{}
+LLUpdateDownloader::LLUpdateDownloader(Client & ) {}
void LLUpdateDownloader::download(LLURI const & ){}
/*****************************************************************************
@@ -113,9 +114,9 @@ namespace tut
bool got_usage_error = false;
try
{
- updater.setParams(test_url, test_channel, test_version);
+ updater.setParams("1.0",test_url, "update" ,test_channel, test_version);
updater.startChecking();
- updater.setParams("other_url", test_channel, test_version);
+ updater.setParams("1.0", "other_url", "update", test_channel, test_version);
}
catch(LLUpdaterService::UsageError)
{
@@ -129,7 +130,7 @@ namespace tut
{
DEBUG;
LLUpdaterService updater;
- updater.setParams(test_url, test_channel, test_version);
+ updater.setParams("1.0", test_url, "update", test_channel, test_version);
updater.startChecking();
ensure(updater.isChecking());
updater.stopChecking();