diff options
| author | Mark Palange (Mani) <palange@lindenlab.com> | 2010-10-26 15:00:34 -0700 | 
|---|---|---|
| committer | Mark Palange (Mani) <palange@lindenlab.com> | 2010-10-26 15:00:34 -0700 | 
| commit | 34db27c26f9a5627b733cc8a04265afed68d199c (patch) | |
| tree | 87236ed82a37e9c5f91de911a1a8bce3a485835b /indra/viewer_components/updater | |
| parent | 0b9cd83642f297687989b0813a9dca83cc78cc15 (diff) | |
CHOP-122 Mowr work on the llupdater facade... Added LLPluginProcessParent, including mockery for unit tests. Re. by Jenn
Diffstat (limited to 'indra/viewer_components/updater')
4 files changed, 158 insertions, 6 deletions
| diff --git a/indra/viewer_components/updater/CMakeLists.txt b/indra/viewer_components/updater/CMakeLists.txt index 4dc5424142..df9404474c 100644 --- a/indra/viewer_components/updater/CMakeLists.txt +++ b/indra/viewer_components/updater/CMakeLists.txt @@ -7,9 +7,13 @@ if(LL_TESTS)    include(LLAddBuildTest)  endif(LL_TESTS)  include(LLCommon) +include(LLMessage) +include(LLPlugin)  include_directories(      ${LLCOMMON_INCLUDE_DIRS} +    ${LLMESSAGE_INCLUDE_DIRS} +    ${LLPLUGIN_INCLUDE_DIRS}      )  set(updater_service_SOURCE_FILES @@ -34,6 +38,8 @@ add_library(llupdaterservice  target_link_libraries(llupdaterservice      ${LLCOMMON_LIBRARIES} +    ${LLMESSAGE_LIBRARIES} +    ${LLPLUGIN_LIBRARIES}      )  if(LL_TESTS) diff --git a/indra/viewer_components/updater/llupdaterservice.cpp b/indra/viewer_components/updater/llupdaterservice.cpp index 14906bcef8..6c7619a2b9 100644 --- a/indra/viewer_components/updater/llupdaterservice.cpp +++ b/indra/viewer_components/updater/llupdaterservice.cpp @@ -25,6 +25,118 @@  #include "linden_common.h" +#include "llupdaterservice.h" + +#include "llsingleton.h" +#include "llpluginprocessparent.h" +#include <boost/scoped_ptr.hpp> + +class LLUpdaterServiceImpl : public LLPluginProcessParentOwner,  +							 public LLSingleton<LLUpdaterServiceImpl> +{ +	std::string mUrl; +	std::string mChannel; +	std::string mVersion; +	 +	unsigned int mUpdateCheckPeriod; +	bool mIsChecking; +	boost::scoped_ptr<LLPluginProcessParent> mPlugin; + +public: +	LLUpdaterServiceImpl(); +	virtual ~LLUpdaterServiceImpl() {} + +	// LLPluginProcessParentOwner interfaces +	virtual void receivePluginMessage(const LLPluginMessage &message); +	virtual bool receivePluginMessageEarly(const LLPluginMessage &message); +	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 startChecking(); +	void stopChecking(); +}; + +LLUpdaterServiceImpl::LLUpdaterServiceImpl() : +	mIsChecking(false), +	mUpdateCheckPeriod(0), +	mPlugin(0) +{ +	// Create the plugin parent, this is the owner. +	mPlugin.reset(new LLPluginProcessParent(this)); +} + +// LLPluginProcessParentOwner interfaces +void LLUpdaterServiceImpl::receivePluginMessage(const LLPluginMessage &message) +{ +} + +bool LLUpdaterServiceImpl::receivePluginMessageEarly(const LLPluginMessage &message)  +{ +	return false; +}; + +void LLUpdaterServiceImpl::pluginLaunchFailed()  +{ +}; + +void LLUpdaterServiceImpl::pluginDied()  +{ +}; + +void LLUpdaterServiceImpl::setURL(const std::string& url) +{ +	if(mUrl != url) +	{ +		mUrl = url; +	} +} + +void LLUpdaterServiceImpl::setChannel(const std::string& channel) +{ +	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; +	} +} + +void LLUpdaterServiceImpl::startChecking() +{ +	if(!mIsChecking) +	{ +		mIsChecking = true; +	} +} + +void LLUpdaterServiceImpl::stopChecking() +{ +	if(mIsChecking) +	{ +		mIsChecking = false; +	} +} + +//----------------------------------------------------------------------- +// Facade interface  LLUpdaterService::LLUpdaterService()  {  } @@ -35,24 +147,30 @@ LLUpdaterService::~LLUpdaterService()  void LLUpdaterService::setURL(const std::string& url)  { +	LLUpdaterServiceImpl::getInstance()->setURL(url);  }  void LLUpdaterService::setChannel(const std::string& channel)  { +	LLUpdaterServiceImpl::getInstance()->setChannel(channel);  }  void LLUpdaterService::setVersion(const std::string& version)  { +	LLUpdaterServiceImpl::getInstance()->setVersion(version);  } -void LLUpdaterService::setUpdateCheckFrequency(unsigned int seconds) +void LLUpdaterService::setUpdateCheckPeriod(unsigned int seconds)  { +	LLUpdaterServiceImpl::getInstance()->setUpdateCheckPeriod(seconds);  }  void LLUpdaterService::startChecking()  { +	LLUpdaterServiceImpl::getInstance()->startChecking();  }  void LLUpdaterService::stopChecking()  { +	LLUpdaterServiceImpl::getInstance()->stopChecking();  } diff --git a/indra/viewer_components/updater/llupdaterservice.h b/indra/viewer_components/updater/llupdaterservice.h index 7836c2cf7f..33d0dc0816 100644 --- a/indra/viewer_components/updater/llupdaterservice.h +++ b/indra/viewer_components/updater/llupdaterservice.h @@ -28,6 +28,12 @@  class LLUpdaterService  { +public: +	class UsageError: public std::runtime_error +	{ +		UsageError(const std::string& msg) : std::runtime_error(msg) {} +	}; +  	LLUpdaterService();  	~LLUpdaterService(); @@ -37,10 +43,10 @@ class LLUpdaterService  	void setChannel(const std::string& channel);  	void setVersion(const std::string& version); -	void setUpdateCheckFrequency(unsigned int seconds); +	void setUpdateCheckPeriod(unsigned int seconds);  	void startChecking();  	void stopChecking(); -} +};  #endif LL_UPDATERSERVICE_H diff --git a/indra/viewer_components/updater/tests/llupdaterservice_test.cpp b/indra/viewer_components/updater/tests/llupdaterservice_test.cpp index 37d1c8243e..9edf15ba11 100644 --- a/indra/viewer_components/updater/tests/llupdaterservice_test.cpp +++ b/indra/viewer_components/updater/tests/llupdaterservice_test.cpp @@ -33,6 +33,28 @@  //#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) +{ +} +
 +LLPluginProcessParent::~LLPluginProcessParent() {}
 +LLPluginMessagePipeOwner::LLPluginMessagePipeOwner(){}
 +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  *****************************************************************************/ @@ -47,13 +69,13 @@ namespace tut  	};      typedef test_group<llupdaterservice_data> llupdaterservice_group; -    typedef llviewerlogin_group::object llupdaterservice_object; +    typedef llupdaterservice_group::object llupdaterservice_object;      llupdaterservice_group llupdaterservicegrp("LLUpdaterService");      template<> template<> -    void llupdateservice_object::test<1>() +    void llupdaterservice_object::test<1>()      {          DEBUG; -		ensure_equals("Dummy", "true", "true"); +		ensure_equals("Dummy", 0, 0);  	}  } | 
