2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
5 * Copyright (C) 2007, Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #ifndef _VIKING_DOWNLOAD_H
24 #define _VIKING_DOWNLOAD_H
30 /* File content check */
31 typedef gboolean (*VikFileContentCheckerFunc) (FILE*);
32 gboolean a_check_map_file(FILE*);
33 gboolean a_check_html_file(FILE*);
34 gboolean a_check_kml_file(FILE*);
36 void a_try_decompress_file (gchar *name);
37 typedef void (*VikFileContentConvertFunc) (gchar*); // filename (temporary)
41 * Check if the server has a more recent file than the one we have before downloading it
42 * This uses http header If-Modified-Since
44 gboolean check_file_server_time;
47 * Set if the server handle ETag
52 * The REFERER string to use.
58 * follow_location specifies the number of retries
59 * to follow a redirect while downloading a page.
61 glong follow_location;
64 * File content checker.
66 VikFileContentCheckerFunc check_file;
69 * If need to authenticate on download
70 * format: 'username:password'
75 * File manipulation if necessary such as uncompressing the downloaded file.
77 VikFileContentConvertFunc convert_file;
83 * Time sent to server on header If-Modified-Since
85 time_t time_condition;
87 * Etag sent by server on previous download
91 * Etag sent by server on this download
95 } DownloadFileOptions;
97 void a_download_init(void);
100 DOWNLOAD_FILE_WRITE_ERROR = -4, // Can't write downloaded file :(
101 DOWNLOAD_HTTP_ERROR = -2,
102 DOWNLOAD_CONTENT_ERROR = -1,
103 DOWNLOAD_SUCCESS = 0,
104 DOWNLOAD_NOT_REQUIRED = 1, // Also 'successful'. e.g. Because file already exists and no time checks used
107 /* TODO: convert to Glib */
108 DownloadResult_t a_http_download_get_url ( const char *hostname, const char *uri, const char *fn, DownloadMapOptions *opt, void *handle );
109 DownloadResult_t a_ftp_download_get_url ( const char *hostname, const char *uri, const char *fn, DownloadMapOptions *opt, void *handle );
110 void *a_download_handle_init ();
111 void a_download_handle_cleanup ( void *handle );
113 gchar *a_download_uri_to_tmp_file ( const gchar *uri, DownloadMapOptions *options );