Planeshift
download.h
Go to the documentation of this file.
1 /*
2 * download.h
3 *
4 * Copyright (C) 2007 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5 *
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation (version 2 of the License)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 */
19 
20 
21 #ifndef __DOWNLOAD_H__
22 #define __DOWNLOAD_H__
23 
24 #include <iutil/vfs.h>
25 #include <csutil/csstring.h>
26 #include <util/fileutil.h>
27 
28 class UpdaterEngine;
30 
31 typedef void CURL;
32 
34 {
35 public:
36  Downloader(iVFS* _vfs, UpdaterConfig* _config);
37  Downloader(iVFS* _vfs);
38  ~Downloader();
39 
40  void Init(iVFS* _vfs);
41 
42  /*
43  * If URL is false; download a file from 'file' and save to 'dest'.
44  * If URL is true; download a file from 'file' where 'file' is the
45  * full URL to the file, and save to 'dest'
46  */
47  bool DownloadFile (const char* file, const char* dest, bool URL, bool silent = false, uint retries = 1, bool vfsPath = false);
48 
49  /* Set the proxy server host and port */
50  void SetProxy (const char* host, int port);
51 private:
52  /* The ID of the mirror we randomly selected. */
53  uint32 startingMirrorID;
54 
55  /* The current active mirror. */
56  uint32 activeMirrorID;
57 
58  /* Cycle our currently active mirror to the next */
59  uint CycleActiveMirror();
60 
61  /* Curl object! */
62  CURL* curl;
63 
64  /* curl error string */
65  char* curlerror;
66 
67  /* VFS */
68  csRef<iVFS> vfs;
69 
70  /* FileUtil pointer */
71  FileUtil* fileUtil;
72 
73  /* Config pointer */
74  UpdaterConfig* config;
75 };
76 
77 #endif // __DOWNLOAD_H__
void SetProxy(const char *host, int port)
void CURL
Definition: download.h:29
bool DownloadFile(const char *file, const char *dest, bool URL, bool silent=false, uint retries=1, bool vfsPath=false)
Downloader(iVFS *_vfs, UpdaterConfig *_config)
void Init(iVFS *_vfs)