]> git.street.me.uk Git - andy/viking.git/blame - src/download.h
Add Church as a Wikipedia waypoint feature type.
[andy/viking.git] / src / download.h
CommitLineData
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
722b5481
RN
28G_BEGIN_DECLS
29
1ac37c09
GB
30/* File content check */
31typedef gboolean (*VikFileContentCheckerFunc) (FILE*);
32gboolean a_check_map_file(FILE*);
33gboolean a_check_html_file(FILE*);
ae941b4c 34gboolean a_check_kml_file(FILE*);
a3697549
RN
35// Convert
36void a_try_decompress_file (gchar *name);
37typedef void (*VikFileContentConvertFunc) (gchar*); // filename (temporary)
1ac37c09 38
80214df2 39typedef struct {
6a4a29aa
JJ
40 /**
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
43 */
6693f5f9 44 gboolean check_file_server_time;
6a4a29aa 45
74fbca98
JJ
46 /**
47 * Set if the server handle ETag
48 */
49 gboolean use_etag;
50
a3188993
GB
51 /**
52 * The REFERER string to use.
53 * Could be NULL.
54 */
55 gchar *referer;
1a8143e6
BZ
56
57 /**
58 * follow_location specifies the number of retries
59 * to follow a redirect while downloading a page.
60 */
61 glong follow_location;
1ac37c09
GB
62
63 /**
64 * File content checker.
65 */
66 VikFileContentCheckerFunc check_file;
6a4a29aa 67
0807f24b
RN
68 /**
69 * If need to authenticate on download
70 * format: 'username:password'
71 */
72 gchar *user_pass;
73
a3697549
RN
74 /**
75 * File manipulation if necessary such as uncompressing the downloaded file.
76 */
77 VikFileContentConvertFunc convert_file;
78
9a021e4f
JJ
79} DownloadFileOptions;
80
4b992365 81void a_download_init(void);
e3da2277 82void a_download_uninit(void);
4b992365 83
4e815e90 84typedef enum {
4dc72a1d 85 DOWNLOAD_PARAMETERS_ERROR = -8, // Configuration issue
4e815e90
RN
86 DOWNLOAD_FILE_WRITE_ERROR = -4, // Can't write downloaded file :(
87 DOWNLOAD_HTTP_ERROR = -2,
88 DOWNLOAD_CONTENT_ERROR = -1,
89 DOWNLOAD_SUCCESS = 0,
90 DOWNLOAD_NOT_REQUIRED = 1, // Also 'successful'. e.g. Because file already exists and no time checks used
91} DownloadResult_t;
92
85611cd9 93/* TODO: convert to Glib */
686baff0
RN
94DownloadResult_t a_http_download_get_url ( const char *hostname, const char *uri, const char *fn, DownloadFileOptions *opt, void *handle );
95DownloadResult_t a_ftp_download_get_url ( const char *hostname, const char *uri, const char *fn, DownloadFileOptions *opt, void *handle );
825413ba
SW
96void *a_download_handle_init ();
97void a_download_handle_cleanup ( void *handle );
85611cd9 98
686baff0 99gchar *a_download_uri_to_tmp_file ( const gchar *uri, DownloadFileOptions *options );
e09b94fe 100
722b5481
RN
101G_END_DECLS
102
85611cd9 103#endif