PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/viewer_components/updater/llupdaterservice.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 108 lines | 60 code | 17 blank | 31 comment | 0 complexity | 6c9ed8789dd2622e17095c926fae21ed MD5 | raw file
  1/** 
  2 * @file llupdaterservice.h
  3 *
  4 * $LicenseInfo:firstyear=2010&license=viewerlgpl$
  5 * Second Life Viewer Source Code
  6 * Copyright (C) 2010, Linden Research, Inc.
  7 * 
  8 * This library is free software; you can redistribute it and/or
  9 * modify it under the terms of the GNU Lesser General Public
 10 * License as published by the Free Software Foundation;
 11 * version 2.1 of the License only.
 12 * 
 13 * This library is distributed in the hope that it will be useful,
 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 16 * Lesser General Public License for more details.
 17 * 
 18 * You should have received a copy of the GNU Lesser General Public
 19 * License along with this library; if not, write to the Free Software
 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 21 * 
 22 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 23 * $/LicenseInfo$
 24 */
 25
 26#ifndef LL_UPDATERSERVICE_H
 27#define LL_UPDATERSERVICE_H
 28
 29#include <boost/shared_ptr.hpp>
 30#include <boost/function.hpp>
 31
 32class LLUpdaterServiceImpl;
 33
 34class LLUpdaterService
 35{
 36public:
 37	class UsageError: public std::runtime_error
 38	{
 39	public:
 40		UsageError(const std::string& msg) : std::runtime_error(msg) {}
 41	};
 42	
 43	// Name of the event pump through which update events will be delivered.
 44	static std::string const & pumpName(void);
 45	
 46	// Returns true if an update has been completely downloaded and is now ready to install.
 47	static bool updateReadyToInstall(void);
 48	
 49	// Type codes for events posted by this service.  Stored the event's 'type' element.
 50	enum eUpdaterEvent {
 51		INVALID,
 52		DOWNLOAD_COMPLETE,
 53		DOWNLOAD_ERROR,
 54		INSTALL_ERROR,
 55		PROGRESS,
 56		STATE_CHANGE
 57	};
 58	
 59	enum eUpdaterState {
 60		INITIAL,
 61		CHECKING_FOR_UPDATE,
 62		TEMPORARY_ERROR,
 63		DOWNLOADING,
 64		INSTALLING,
 65		UP_TO_DATE,
 66		TERMINAL,
 67		FAILURE
 68	};
 69
 70	LLUpdaterService();
 71	~LLUpdaterService();
 72
 73	void initialize(const std::string& protocol_version,
 74				    const std::string& url, 
 75				    const std::string& path,
 76				    const std::string& channel,
 77				    const std::string& version);
 78
 79	void setCheckPeriod(unsigned int seconds);
 80	void setBandwidthLimit(U64 bytesPerSecond);
 81	
 82	void startChecking(bool install_if_ready = false);
 83	void stopChecking();
 84	bool isChecking();
 85	eUpdaterState getState();
 86
 87	typedef boost::function<void (void)> app_exit_callback_t;
 88	template <typename F>
 89	void setAppExitCallback(F const &callable) 
 90	{ 
 91		app_exit_callback_t aecb = callable;
 92		setImplAppExitCallback(aecb);
 93	}
 94	
 95	// If an update is or has been downloaded, this method will return the
 96	// version string for that update.  An empty string will be returned
 97	// otherwise.
 98	std::string updatedVersion(void);
 99
100private:
101	boost::shared_ptr<LLUpdaterServiceImpl> mImpl;
102	void setImplAppExitCallback(app_exit_callback_t aecb);
103};
104
105// Returns the full version as a string.
106std::string const & ll_get_version(void);
107
108#endif // LL_UPDATERSERVICE_H