]>
Commit | Line | Data |
---|---|---|
85611cd9 GB |
1 | /* |
2 | * viking -- GPS Data and Topo Analyzer, Explorer, and Manager | |
3 | * | |
4 | * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net> | |
a482007a | 5 | * Copyright (C) 2007, Guilhem Bonnefille <guilhem.bonnefille@gmail.com> |
85611cd9 GB |
6 | * |
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. | |
11 | * | |
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. | |
16 | * | |
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 | |
20 | * | |
21 | */ | |
22 | ||
23 | #ifndef _VIKING_DOWNLOAD_H | |
24 | #define _VIKING_DOWNLOAD_H | |
80214df2 | 25 | |
1ac37c09 GB |
26 | #include <stdio.h> |
27 | ||
28 | /* File content check */ | |
29 | typedef gboolean (*VikFileContentCheckerFunc) (FILE*); | |
30 | gboolean a_check_map_file(FILE*); | |
31 | gboolean a_check_html_file(FILE*); | |
ae941b4c | 32 | gboolean a_check_kml_file(FILE*); |
1ac37c09 | 33 | |
80214df2 | 34 | typedef struct { |
6a4a29aa JJ |
35 | /** |
36 | * Check if the server has a more recent file than the one we have before downloading it | |
37 | * This uses http header If-Modified-Since | |
38 | */ | |
6693f5f9 | 39 | gboolean check_file_server_time; |
6a4a29aa | 40 | |
74fbca98 JJ |
41 | /** |
42 | * Set if the server handle ETag | |
43 | */ | |
44 | gboolean use_etag; | |
45 | ||
a3188993 GB |
46 | /** |
47 | * The REFERER string to use. | |
48 | * Could be NULL. | |
49 | */ | |
50 | gchar *referer; | |
1a8143e6 BZ |
51 | |
52 | /** | |
53 | * follow_location specifies the number of retries | |
54 | * to follow a redirect while downloading a page. | |
55 | */ | |
56 | glong follow_location; | |
1ac37c09 GB |
57 | |
58 | /** | |
59 | * File content checker. | |
60 | */ | |
61 | VikFileContentCheckerFunc check_file; | |
6a4a29aa | 62 | |
b529dc9c | 63 | } DownloadMapOptions; |
80214df2 | 64 | |
9a021e4f JJ |
65 | typedef struct { |
66 | /** | |
67 | * Time sent to server on header If-Modified-Since | |
68 | */ | |
69 | time_t time_condition; | |
ab716260 JJ |
70 | /** |
71 | * Etag sent by server on previous download | |
72 | */ | |
73 | char *etag; | |
74 | /** | |
75 | * Etag sent by server on this download | |
76 | */ | |
77 | char *new_etag; | |
9a021e4f JJ |
78 | |
79 | } DownloadFileOptions; | |
80 | ||
4b992365 GB |
81 | void a_download_init(void); |
82 | ||
85611cd9 | 83 | /* TODO: convert to Glib */ |
b529dc9c JJ |
84 | int a_http_download_get_url ( const char *hostname, const char *uri, const char *fn, DownloadMapOptions *opt, void *handle ); |
85 | int a_ftp_download_get_url ( const char *hostname, const char *uri, const char *fn, DownloadMapOptions *opt, void *handle ); | |
825413ba SW |
86 | void *a_download_handle_init (); |
87 | void a_download_handle_cleanup ( void *handle ); | |
85611cd9 | 88 | |
6a4a29aa JJ |
89 | /* Error messages returned by download functions */ |
90 | enum { DOWNLOAD_NO_ERROR = 0, | |
91 | DOWNLOAD_NO_NEWER_FILE, | |
92 | DOWNLOAD_ERROR }; | |
93 | ||
85611cd9 | 94 | #endif |