PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/viewer_components/updater/llupdatedownloader.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 94 lines | 29 code | 19 blank | 46 comment | 0 complexity | e52700deb6249c581d6ebde2b2ff8028 MD5 | raw file
 1/** 
 2 * @file llupdatedownloader.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_UPDATE_DOWNLOADER_H
27#define LL_UPDATE_DOWNLOADER_H
28
29
30#include <string>
31#include <boost/shared_ptr.hpp>
32#include "lluri.h"
33
34
35//
36// An asynchronous download service for fetching updates.
37//
38class LLUpdateDownloader
39{
40public:
41	class Client;
42	class Implementation;
43	
44	// Returns the path to the download marker file containing details of the
45	// latest download.
46	static std::string downloadMarkerPath(void);
47	
48	LLUpdateDownloader(Client & client);
49	
50	// Cancel any in progress download; a no op if none is in progress.  The
51	// client will not receive a complete or error callback.
52	void cancel(void);
53	
54	// Start a new download.
55	void download(LLURI const & uri,
56				  std::string const & hash, 
57				  std::string const & updateVersion,
58				  bool required=false);
59	
60	// Returns true if a download is in progress.
61	bool isDownloading(void);
62	
63	// Resume a partial download.
64	void resume(void);
65	
66	// Set a limit on the dowload rate.
67	void setBandwidthLimit(U64 bytesPerSecond);
68	
69private:
70	boost::shared_ptr<Implementation> mImplementation;
71};
72
73
74//
75// An interface to be implemented by clients initiating a update download.
76//
77class LLUpdateDownloader::Client {
78public:
79	
80	// The download has completed successfully.
81	// data is a map containing the following items:
82	// url - source (remote) location
83	// hash - the md5 sum that should match the installer file.
84	// path - destination (local) location
85	// required - boolean indicating if this is a required update.
86	// size - the size of the installer in bytes
87	virtual void downloadComplete(LLSD const & data) = 0;
88	
89	// The download failed.
90	virtual void downloadError(std::string const & message) = 0;
91};
92
93
94#endif