CHOP-122 Initializing Facade service in the viewer. Rev. by Brad.

meow-7.2.2
Mark Palange (Mani) 2010-10-27 17:07:31 -07:00
parent 34db27c26f
commit be8c9fc217
9 changed files with 278 additions and 138 deletions

View File

@ -64,6 +64,7 @@ include_directories(
${LSCRIPT_INCLUDE_DIRS}
${LSCRIPT_INCLUDE_DIRS}/lscript_compile
${LLLOGIN_INCLUDE_DIRS}
${UPDATER_INCLUDE_DIRS}
)
set(viewer_SOURCE_FILES
@ -1679,6 +1680,7 @@ target_link_libraries(${VIEWER_BINARY_NAME}
${OPENSSL_LIBRARIES}
${CRYPTO_LIBRARIES}
${LLLOGIN_LIBRARIES}
${UPDATER_LIBRARIES}
${GOOGLE_PERFTOOLS_LIBRARIES}
)

View File

@ -10991,7 +10991,40 @@
<key>Value</key>
<integer>15</integer>
</map>
<key>UploadBakedTexOld</key>
<key>UpdaterServiceActive</key>
<map>
<key>Comment</key>
<string>Enable or disable the updater service.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>1</integer>
</map>
<key>UpdaterServiceCheckPeriod</key>
<map>
<key>Comment</key>
<string>Default period between update checking.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>3600</integer>
</map>
<key>UpdaterServiceURL</key>
<map>
<key>Comment</key>
<string>Default location for the updater service.</string>
<key>Persist</key>
<integer>0</integer>
<key>Type</key>
<string>String</string>
<key>Value</key>
<string>http://secondlife.com/app/update</string>
</map>
<key>UploadBakedTexOld</key>
<map>
<key>Comment</key>
<string>Forces the baked texture pipeline to upload using the old method.</string>

View File

@ -83,6 +83,7 @@
#include "llweb.h"
#include "llsecondlifeurls.h"
#include "llupdaterservice.h"
// Linden library includes
#include "llavatarnamecache.h"
@ -581,7 +582,8 @@ LLAppViewer::LLAppViewer() :
mAgentRegionLastAlive(false),
mRandomizeFramerate(LLCachedControl<bool>(gSavedSettings,"Randomize Framerate", FALSE)),
mPeriodicSlowFrame(LLCachedControl<bool>(gSavedSettings,"Periodic Slow Frame", FALSE)),
mFastTimerLogThread(NULL)
mFastTimerLogThread(NULL),
mUpdater(new LLUpdaterService())
{
if(NULL != sInstance)
{
@ -630,6 +632,9 @@ bool LLAppViewer::init()
if (!initConfiguration())
return false;
// Initialize updater service
initUpdater();
// write Google Breakpad minidump files to our log directory
std::string logdir = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "");
logdir += gDirUtilp->getDirDelimiter();
@ -2324,6 +2329,24 @@ bool LLAppViewer::initConfiguration()
return true; // Config was successful.
}
void LLAppViewer::initUpdater()
{
// Initialize the updater service.
// Generate URL to the udpater service
// Get Channel
// Get Version
std::string url = gSavedSettings.getString("UpdaterServiceURL");
std::string channel = gSavedSettings.getString("VersionChannelName");
std::string version = LLVersionInfo::getVersion();
U32 check_period = gSavedSettings.getU32("UpdaterServiceCheckPeriod");
mUpdater->setParams(url, channel, version);
mUpdater->setCheckPeriod(check_period);
if(gSavedSettings.getBOOL("UpdaterServiceActive"))
{
mUpdater->startChecking();
}
}
void LLAppViewer::checkForCrash(void)
{

View File

@ -39,7 +39,7 @@ class LLTextureCache;
class LLImageDecodeThread;
class LLTextureFetch;
class LLWatchdogTimeout;
class LLCommandLineParser;
class LLUpdaterService;
struct apr_dso_handle_t;
@ -186,7 +186,7 @@ private:
bool initThreads(); // Initialize viewer threads, return false on failure.
bool initConfiguration(); // Initialize settings from the command line/config file.
void initUpdater(); // Initialize the updater service.
bool initCache(); // Initialize local client cache.
@ -260,7 +260,13 @@ private:
std::set<struct apr_dso_handle_t*> mPlugins;
boost::scoped_ptr<LLUpdaterService> mUpdater;
//---------------------------------------------
//*NOTE: Mani - legacy updater stuff
// Still useable?
public:
//some information for updater
typedef struct
{
@ -270,6 +276,7 @@ public:
static LLUpdaterInfo *sUpdaterInfo ;
void launchUpdater();
//---------------------------------------------
};
// consts from viewer.h

View File

@ -36,7 +36,7 @@
#include "llbufferstream.h"
#include "llui.h"
#include "llversionviewer.h"
#include "llversioninfo.h"
#include "llviewercontrol.h"
#include "jsoncpp/reader.h"
@ -64,11 +64,11 @@ void LLTranslate::translateMessage(LLHTTPClient::ResponderPtr &result, const std
getTranslateUrl(url, from_lang, to_lang, mesg);
std::string user_agent = llformat("%s %d.%d.%d (%d)",
LL_CHANNEL,
LL_VERSION_MAJOR,
LL_VERSION_MINOR,
LL_VERSION_PATCH,
LL_VERSION_BUILD );
LLVersionInfo::getChannel(),
LLVersionInfo::getMajor(),
LLVersionInfo::getMinor(),
LLVersionInfo::getPatch(),
LLVersionInfo::getBuild());
if (!m_Header.size())
{

View File

@ -55,3 +55,13 @@ if(LL_TESTS)
LL_ADD_PROJECT_UNIT_TESTS(llupdaterservice "${llupdater_service_TEST_SOURCE_FILES}")
endif(LL_TESTS)
set(UPDATER_INCLUDE_DIRS
${LIBS_OPEN_DIR}/viewer_components/updater
CACHE INTERNAL ""
)
set(UPDATER_LIBRARIES
llupdaterservice
CACHE INTERNAL ""
)

View File

@ -27,18 +27,19 @@
#include "llupdaterservice.h"
#include "llsingleton.h"
#include "llpluginprocessparent.h"
#include <boost/scoped_ptr.hpp>
#include <boost/weak_ptr.hpp>
class LLUpdaterServiceImpl : public LLPluginProcessParentOwner,
public LLSingleton<LLUpdaterServiceImpl>
boost::weak_ptr<LLUpdaterServiceImpl> gUpdater;
class LLUpdaterServiceImpl : public LLPluginProcessParentOwner
{
std::string mUrl;
std::string mChannel;
std::string mVersion;
unsigned int mUpdateCheckPeriod;
unsigned int mCheckPeriod;
bool mIsChecking;
boost::scoped_ptr<LLPluginProcessParent> mPlugin;
@ -52,17 +53,20 @@ public:
virtual void pluginLaunchFailed();
virtual void pluginDied();
void setURL(const std::string& url);
void setChannel(const std::string& channel);
void setVersion(const std::string& version);
void setUpdateCheckPeriod(unsigned int seconds);
void setParams(const std::string& url,
const std::string& channel,
const std::string& version);
void setCheckPeriod(unsigned int seconds);
void startChecking();
void stopChecking();
bool isChecking();
};
LLUpdaterServiceImpl::LLUpdaterServiceImpl() :
mIsChecking(false),
mUpdateCheckPeriod(0),
mCheckPeriod(0),
mPlugin(0)
{
// Create the plugin parent, this is the owner.
@ -87,42 +91,35 @@ void LLUpdaterServiceImpl::pluginDied()
{
};
void LLUpdaterServiceImpl::setURL(const std::string& url)
void LLUpdaterServiceImpl::setParams(const std::string& url,
const std::string& channel,
const std::string& version)
{
if(mUrl != url)
if(mIsChecking)
{
mUrl = url;
throw LLUpdaterService::UsageError("Call LLUpdaterService::stopCheck()"
" before setting params.");
}
mUrl = url;
mChannel = channel;
mVersion = version;
}
void LLUpdaterServiceImpl::setChannel(const std::string& channel)
void LLUpdaterServiceImpl::setCheckPeriod(unsigned int seconds)
{
if(mChannel != channel)
{
mChannel = channel;
}
}
void LLUpdaterServiceImpl::setVersion(const std::string& version)
{
if(mVersion != version)
{
mVersion = version;
}
}
void LLUpdaterServiceImpl::setUpdateCheckPeriod(unsigned int seconds)
{
if(mUpdateCheckPeriod != seconds)
{
mUpdateCheckPeriod = seconds;
}
mCheckPeriod = seconds;
}
void LLUpdaterServiceImpl::startChecking()
{
if(!mIsChecking)
{
if(mUrl.empty() || mChannel.empty() || mVersion.empty())
{
throw LLUpdaterService::UsageError("Set params before call to "
"LLUpdaterService::startCheck().");
}
mIsChecking = true;
}
}
@ -135,42 +132,54 @@ void LLUpdaterServiceImpl::stopChecking()
}
}
bool LLUpdaterServiceImpl::isChecking()
{
return mIsChecking;
}
//-----------------------------------------------------------------------
// Facade interface
LLUpdaterService::LLUpdaterService()
{
if(gUpdater.expired())
{
mImpl =
boost::shared_ptr<LLUpdaterServiceImpl>(new LLUpdaterServiceImpl());
gUpdater = mImpl;
}
else
{
mImpl = gUpdater.lock();
}
}
LLUpdaterService::~LLUpdaterService()
{
}
void LLUpdaterService::setURL(const std::string& url)
void LLUpdaterService::setParams(const std::string& url,
const std::string& chan,
const std::string& vers)
{
LLUpdaterServiceImpl::getInstance()->setURL(url);
mImpl->setParams(url, chan, vers);
}
void LLUpdaterService::setChannel(const std::string& channel)
void LLUpdaterService::setCheckPeriod(unsigned int seconds)
{
LLUpdaterServiceImpl::getInstance()->setChannel(channel);
}
void LLUpdaterService::setVersion(const std::string& version)
{
LLUpdaterServiceImpl::getInstance()->setVersion(version);
}
void LLUpdaterService::setUpdateCheckPeriod(unsigned int seconds)
{
LLUpdaterServiceImpl::getInstance()->setUpdateCheckPeriod(seconds);
mImpl->setCheckPeriod(seconds);
}
void LLUpdaterService::startChecking()
{
LLUpdaterServiceImpl::getInstance()->startChecking();
mImpl->startChecking();
}
void LLUpdaterService::stopChecking()
{
LLUpdaterServiceImpl::getInstance()->stopChecking();
mImpl->stopChecking();
}
bool LLUpdaterService::isChecking()
{
return mImpl->isChecking();
}

View File

@ -26,11 +26,16 @@
#ifndef LL_UPDATERSERVICE_H
#define LL_UPDATERSERVICE_H
#include <boost/shared_ptr.hpp>
class LLUpdaterServiceImpl;
class LLUpdaterService
{
public:
class UsageError: public std::runtime_error
{
public:
UsageError(const std::string& msg) : std::runtime_error(msg) {}
};
@ -39,14 +44,18 @@ public:
// The base URL.
// *NOTE:Mani The grid, if any, would be embedded in the base URL.
void setURL(const std::string& url);
void setChannel(const std::string& channel);
void setVersion(const std::string& version);
void setUpdateCheckPeriod(unsigned int seconds);
void setParams(const std::string& url,
const std::string& channel,
const std::string& version);
void setCheckPeriod(unsigned int seconds);
void startChecking();
void stopChecking();
bool isChecking();
private:
boost::shared_ptr<LLUpdaterServiceImpl> mImpl;
};
#endif LL_UPDATERSERVICE_H

View File

@ -1,50 +1,50 @@
/**
* @file llupdaterservice_test.cpp
* @brief Tests of llupdaterservice.cpp.
*
* $LicenseInfo:firstyear=2010&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
// Precompiled header
#include "linden_common.h"
// associated header
#include "../llupdaterservice.h"
#include "../../../test/lltut.h"
//#define DEBUG_ON
#include "../../../test/debug.h"
#include "llevents.h"
#include "llpluginprocessparent.h"
/*****************************************************************************
* MOCK'd
*****************************************************************************/
LLPluginProcessParentOwner::~LLPluginProcessParentOwner() {}
LLPluginProcessParent::LLPluginProcessParent(LLPluginProcessParentOwner *owner)
: mOwner(owner),
mIncomingQueueMutex(NULL)
{
}
/**
* @file llupdaterservice_test.cpp
* @brief Tests of llupdaterservice.cpp.
*
* $LicenseInfo:firstyear=2010&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
// Precompiled header
#include "linden_common.h"
// associated header
#include "../llupdaterservice.h"
#include "../../../test/lltut.h"
//#define DEBUG_ON
#include "../../../test/debug.h"
#include "llevents.h"
#include "llpluginprocessparent.h"
/*****************************************************************************
* MOCK'd
*****************************************************************************/
LLPluginProcessParentOwner::~LLPluginProcessParentOwner() {}
LLPluginProcessParent::LLPluginProcessParent(LLPluginProcessParentOwner *owner)
: mOwner(owner),
mIncomingQueueMutex(gAPRPoolp)
{
}
LLPluginProcessParent::~LLPluginProcessParent() {}
LLPluginMessagePipeOwner::LLPluginMessagePipeOwner(){}
@ -52,30 +52,77 @@ LLPluginMessagePipeOwner::~LLPluginMessagePipeOwner(){}
void LLPluginProcessParent::receiveMessageRaw(const std::string &message) {}
int LLPluginMessagePipeOwner::socketError(int) { return 0; }
void LLPluginProcessParent::setMessagePipe(LLPluginMessagePipe *message_pipe) {}
void LLPluginMessagePipeOwner::setMessagePipe(class LLPluginMessagePipe *) {}
LLPluginMessage::~LLPluginMessage() {}
/*****************************************************************************
* TUT
*****************************************************************************/
namespace tut
{
struct llupdaterservice_data
{
llupdaterservice_data() :
pumps(LLEventPumps::instance())
{}
LLEventPumps& pumps;
};
typedef test_group<llupdaterservice_data> llupdaterservice_group;
typedef llupdaterservice_group::object llupdaterservice_object;
llupdaterservice_group llupdaterservicegrp("LLUpdaterService");
template<> template<>
void llupdaterservice_object::test<1>()
{
DEBUG;
ensure_equals("Dummy", 0, 0);
}
}
void LLPluginMessagePipeOwner::setMessagePipe(class LLPluginMessagePipe *) {}
LLPluginMessage::~LLPluginMessage() {}
/*****************************************************************************
* TUT
*****************************************************************************/
namespace tut
{
struct llupdaterservice_data
{
llupdaterservice_data() :
pumps(LLEventPumps::instance()),
test_url("dummy_url"),
test_channel("dummy_channel"),
test_version("dummy_version")
{}
LLEventPumps& pumps;
std::string test_url;
std::string test_channel;
std::string test_version;
};
typedef test_group<llupdaterservice_data> llupdaterservice_group;
typedef llupdaterservice_group::object llupdaterservice_object;
llupdaterservice_group llupdaterservicegrp("LLUpdaterService");
template<> template<>
void llupdaterservice_object::test<1>()
{
DEBUG;
LLUpdaterService updater;
bool got_usage_error = false;
try
{
updater.startChecking();
}
catch(LLUpdaterService::UsageError)
{
got_usage_error = true;
}
ensure("Caught start before params", got_usage_error);
}
template<> template<>
void llupdaterservice_object::test<2>()
{
DEBUG;
LLUpdaterService updater;
bool got_usage_error = false;
try
{
updater.setParams(test_url, test_channel, test_version);
updater.startChecking();
updater.setParams("other_url", test_channel, test_version);
}
catch(LLUpdaterService::UsageError)
{
got_usage_error = true;
}
ensure("Caught params while running", got_usage_error);
}
template<> template<>
void llupdaterservice_object::test<3>()
{
DEBUG;
LLUpdaterService updater;
updater.setParams(test_url, test_channel, test_version);
updater.startChecking();
ensure(updater.isChecking());
updater.stopChecking();
ensure(!updater.isChecking());
}
}