Changeset 189

Show
Ignore:
Timestamp:
02/03/08 15:34:06 (4 years ago)
Author:
uncle_fungus
Message:

doxygenated httpDownloader

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.3.2beta3/src/httpDownloader.cpp

    r148 r189  
    3131 
    3232 
    33 /** 
    34 * Create a temporary file and download the remote resource to this file 
    35 * 
    36 * The path to the temporary file is stored in the parameter localFileName, empty string if it could not be created 
    37 * This file must be deleted by the caller, if this is needed, regardless of the return value 
    38 * 
    39 * Use the defined proxy in preferences, if any 
    40 * 
    41 * Using wxURL would have been a lot easier, but wxURL::SetProxy() doesn't work, and I can't ask 
    42 * users to patch their version of wxWindows to compile this app 
    43 **/ 
    4433HTTPDownloader::DownloadStatus HTTPDownloader::DownloadFile(const wxString& host, wxUint32 port, const wxString& resource, wxString& localFileName, ProgressManager& progressManager) 
    4534{ 
     
    197186 
    198187 
    199 /** 
    200 * Return the value of the content-length field, if found 
    201 * Return 0 otherwise 
    202 * 
    203 * ! buffer will be modified ! 
    204 **/ 
    205188wxUint32 HTTPDownloader::ExtractContentSize(wxByte* buffer, wxUint32 bufferSize) 
    206189{ 
     
    239222} 
    240223 
    241 /** 
    242  * Decontructs a "real" url into its Server, Port and Resource fields 
    243  * and downloads the file 
    244  **/ 
     224 
    245225HTTPDownloader::DownloadStatus HTTPDownloader::Url(const wxString& url, wxString& localFileName, ProgressManager& progressManager) 
    246226{ 
  • branches/2.3.2beta3/src/include/httpDownloader.h

    r122 r189  
    1515*/ 
    1616 
     17/** 
     18 * \file httpDownloader 
     19 * Create a class to download files over http. 
     20 * \author François Ingelrest 
     21 * \author Andrew Schofield 
     22 **/ 
     23 
    1724#ifndef _HTTPDOWNLOADER_H 
    1825#define _HTTPDOWNLOADER_H 
     
    2330 
    2431 
    25 /** 
    26 * Preferences used by this class 
    27 **/ 
    28 #define PREF_HTTPDOWNLOADER_USEPROXY    wxT("HTTPDownloader.UseProxy") 
    29 #define PREF_HTTPDOWNLOADER_USEPROXY_DV false 
     32#define PREF_HTTPDOWNLOADER_USEPROXY    wxT("HTTPDownloader.UseProxy") /**< Preference setting for whether a proxy should be used */ 
     33#define PREF_HTTPDOWNLOADER_USEPROXY_DV false /**< Default value for use of proxy setting */ 
    3034 
    31 #define PREF_HTTPDOWNLOADER_PROXYADDRESS    wxT("HTTPDownloader.ProxyAddress") 
    32 #define PREF_HTTPDOWNLOADER_PROXYADDRESS_DV wxT("") 
     35#define PREF_HTTPDOWNLOADER_PROXYADDRESS    wxT("HTTPDownloader.ProxyAddress") /**< Preference setting for proxy address */ 
     36#define PREF_HTTPDOWNLOADER_PROXYADDRESS_DV wxT("") /**< Default value for proxy address */ 
    3337 
    34 #define PREF_HTTPDOWNLOADER_PROXYPORT    wxT("HTTPDownloader.ProxyPort") 
    35 #define PREF_HTTPDOWNLOADER_PROXYPORT_DV 8080 
     38#define PREF_HTTPDOWNLOADER_PROXYPORT    wxT("HTTPDownloader.ProxyPort") /**< Preference setting for proxy port */ 
     39#define PREF_HTTPDOWNLOADER_PROXYPORT_DV 8080 /**< Default value for proxy port */ 
    3640 
    37 #define PREF_HTTPDOWNLOADER_USE_PROXY_AUTHENTICATION    wxT("HTTPDownloader.UseProxyAuthentication") 
    38 #define PREF_HTTPDOWNLOADER_USE_PROXY_AUTHENTICATION_DV false 
     41#define PREF_HTTPDOWNLOADER_USE_PROXY_AUTHENTICATION    wxT("HTTPDownloader.UseProxyAuthentication") /**< Preference setting for whether proxy authentication should be used */ 
     42#define PREF_HTTPDOWNLOADER_USE_PROXY_AUTHENTICATION_DV false /**< Default value for proxy authentication */ 
    3943 
    40 #define PREF_HTTPDOWNLOADER_PROXY_USERNAME    wxT("HTTPDownloader.ProxyUsername") 
    41 #define PREF_HTTPDOWNLOADER_PROXY_USERNAME_DV wxT("") 
     44#define PREF_HTTPDOWNLOADER_PROXY_USERNAME    wxT("HTTPDownloader.ProxyUsername") /**< Preference setting for proxy username */ 
     45#define PREF_HTTPDOWNLOADER_PROXY_USERNAME_DV wxT("") /**< Default value for proxy username */ 
    4246 
    43 #define PREF_HTTPDOWNLOADER_PROXY_PASSWORD    wxT("HTTPDownloader.ProxyPassword") 
    44 #define PREF_HTTPDOWNLOADER_PROXY_PASSWORD_DV wxT("") 
     47#define PREF_HTTPDOWNLOADER_PROXY_PASSWORD    wxT("HTTPDownloader.ProxyPassword") /**< Preference setting for proxy password */ 
     48#define PREF_HTTPDOWNLOADER_PROXY_PASSWORD_DV wxT("") /**< Default value for proxy password */ 
    4549 
    46 #define PREF_HTTPDOWNLOADER_USEALTERNATEUPDATE    wxT("HTTPDownloader.UseAlternateUpdate") 
    47 #define PREF_HTTPDOWNLOADER_USEALTERNATEUPDATE_DV true 
     50#define PREF_HTTPDOWNLOADER_USEALTERNATEUPDATE    wxT("HTTPDownloader.UseAlternateUpdate") /**< Preference setting for use of alternate update source */ 
     51#define PREF_HTTPDOWNLOADER_USEALTERNATEUPDATE_DV true /**< Default value for alternate update source */ 
    4852 
    49 #define PREF_HTTPDOWNLOADER_USELOCALFILE    wxT("HTTPDownloader.UseLocalFile") 
    50 #define PREF_HTTPDOWNLOADER_USELOCALFILE_DV false 
     53#define PREF_HTTPDOWNLOADER_USELOCALFILE    wxT("HTTPDownloader.UseLocalFile") /**< Preference setting for use of a local file as update source */ 
     54#define PREF_HTTPDOWNLOADER_USELOCALFILE_DV false /**< Default value for local file */ 
    5155 
    52 #define PREF_HTTPDOWNLOADER_LOCALFILELOCATION    wxT("HTTPDownloader.LocalFileLocation") 
    53 #define PREF_HTTPDOWNLOADER_LOCALFILELOCATION_DV wxT("") 
     56#define PREF_HTTPDOWNLOADER_LOCALFILELOCATION    wxT("HTTPDownloader.LocalFileLocation") /**< Preference setting for local file location */ 
     57#define PREF_HTTPDOWNLOADER_LOCALFILELOCATION_DV wxT("") /**< Default value for local file location */ 
    5458 
    55 #define PREF_HTTPDOWNLOADER_ALTERNATEUPDATEADDRESS    wxT("HTTPDownloader.AlternateUpdateAddress") 
    56 #define PREF_HTTPDOWNLOADER_ALTERNATEUPDATEADDRESS_DV wxT("http://fah-web.stanford.edu/psummary.html") 
     59#define PREF_HTTPDOWNLOADER_ALTERNATEUPDATEADDRESS    wxT("HTTPDownloader.AlternateUpdateAddress") /**< Preference setting for alternate update address */ 
     60#define PREF_HTTPDOWNLOADER_ALTERNATEUPDATEADDRESS_DV wxT("http://fah-web.stanford.edu/psummary.html") /**< Default value for alternate update address */ 
    5761 
    5862 
    59  
    60 // This class allows one to easily download files from a web server 
     63/** 
     64 * HTTPDownloader class. 
     65 * This class allows one to easily download files from a web server. 
     66 **/ 
    6167class HTTPDownloader 
    6268{ 
    6369        public: 
     70                /** 
     71                 * Download Status definition. 
     72                 **/ 
    6473                typedef enum _DOWNLOAD_STATUS 
    6574                { 
    66                         STATUS_TEMP_FILE_CREATION_ERROR, 
    67                         STATUS_TEMP_FILE_OPEN_ERROR, 
    68                         STATUS_CONNECT_ERROR, 
    69                         STATUS_SEND_REQUEST_ERROR, 
    70                         STATUS_ABORTED, 
    71                         STATUS_NO_ERROR 
     75                        STATUS_TEMP_FILE_CREATION_ERROR, /**< Temporary file creation error */ 
     76                        STATUS_TEMP_FILE_OPEN_ERROR, /**< Temporary file opening error */ 
     77                        STATUS_CONNECT_ERROR, /**< Connection error */ 
     78                        STATUS_SEND_REQUEST_ERROR, /**< Send request error */ 
     79                        STATUS_ABORTED, /**< Connection aborted */ 
     80                        STATUS_NO_ERROR /**< Connection successful */ 
    7281                } DownloadStatus; 
    7382 
    7483 
    7584        protected: 
     85                /** 
     86                 * Get the size of the downloaded content. 
     87                 * Uses the content-size field. 
     88                 * If no field is found, value is 0. 
     89                 * ! buffer will be modified by this function! 
     90                 * @param buffer The downloaded content buffer. 
     91                 * @param bufferSize The size of the downloaded content buffer. 
     92                 * @return The content size. 
     93                 **/ 
    7694                static wxUint32 ExtractContentSize(wxByte* buffer, wxUint32 bufferSize); 
    7795 
    7896        public: 
     97                /** 
     98                 * Create a temporary file and download the remote resource to this file. 
     99                 * 
     100                 * The path to the temporary file is stored in the parameter localFileName, empty string if it could not be created 
     101                 * This file must be deleted by the caller, if this is needed, regardless of the return value 
     102                 * 
     103                 * Use the defined proxy in preferences, if any 
     104                 * 
     105                 * Using wxURL would have been a lot easier, but wxURL::SetProxy() doesn't work, and I can't ask 
     106                 * users to patch their version of wxWindows to compile this app 
     107                 * @param host host part of the url 
     108                 * @param port port part of url (default is 80) 
     109                 * @param resource location of file on host 
     110                 * @param locaFileName Location to download file to 
     111                 * @param progressManager The progressManager object 
     112                 * @return A download status object. 
     113                 **/ 
    79114                static DownloadStatus DownloadFile(const wxString& host, wxUint32 port, const wxString& resource, wxString& localFileName, ProgressManager& progressManager); 
     115 
     116                /** 
     117                 * Decontructs a "real" url into its Server, Port and Resource fields. 
     118                 * This is a wrapper around the DownloadFile method to allow access by a readable url. 
     119                 * @param url The real url like 'http://fah-web.stanford.edu/psummary.html' 
     120                 * @param localFileName Location to download file to 
     121                 * @param progressManager The progressManager object 
     122                 * @return A download status object. 
     123                 **/ 
    80124                static DownloadStatus Url(const wxString& url, wxString& localFileName, ProgressManager& progressManager); 
    81125};