Planeshift

download.h

Go to the documentation of this file.
00001 /*
00002 * download.h
00003 *
00004 * Copyright (C) 2007 Atomic Blue ([email protected], http://www.atomicblue.org)
00005 *
00006 *
00007 * This program is free software; you can redistribute it and/or
00008 * modify it under the terms of the GNU General Public License
00009 * as published by the Free Software Foundation (version 2 of the License)
00010 * This program is distributed in the hope that it will be useful,
00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 * GNU General Public License for more details.
00014 * You should have received a copy of the GNU General Public License
00015 * along with this program; if not, write to the Free Software
00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 *
00018 */
00019 
00020 
00021 #ifndef __DOWNLOAD_H__
00022 #define __DOWNLOAD_H__
00023 
00024 #include <iutil/vfs.h>
00025 #include <csutil/csstring.h>
00026 #include <util/fileutil.h>
00027 
00028 class UpdaterEngine;
00029 class UpdaterConfig;
00030 
00031 typedef void CURL;
00032 
00033 class Downloader
00034 {
00035 public:
00036     Downloader(iVFS* _vfs, UpdaterConfig* _config);
00037     Downloader(iVFS* _vfs);
00038     ~Downloader();
00039 
00040     void Init(iVFS* _vfs);
00041 
00042     /*
00043      * If URL is false; download a file from 'file' and save to 'dest'.
00044      * If URL is true; download a file from 'file' where 'file' is the
00045      * full URL to the file, and save to 'dest'
00046      */
00047     bool DownloadFile (const char* file, const char* dest, bool URL, bool silent = false, uint retries = 1, bool vfsPath = false);
00048 
00049     /* Set the proxy server host and port */
00050     void SetProxy (const char* host, int port);
00051 private:
00052     /* The ID of the mirror we randomly selected. */
00053     uint32 startingMirrorID;
00054     
00055     /* The current active mirror. */
00056     uint32 activeMirrorID;
00057 
00058     /* Cycle our currently active mirror to the next */
00059     uint CycleActiveMirror();
00060 
00061     /* Curl object! */
00062     CURL* curl;
00063 
00064     /* curl error string */
00065     char* curlerror;
00066 
00067     /* VFS */
00068     csRef<iVFS> vfs;
00069 
00070     /* FileUtil pointer */
00071     FileUtil* fileUtil;
00072 
00073     /* Config pointer */
00074     UpdaterConfig* config;
00075 };
00076 
00077 #endif // __DOWNLOAD_H__