Remove sqlite3 build dep.
[gmpc.git] / src / Tools / gmpc_easy_download.h
blob1bc41125f93c37c90ddfc025d809dc9f3fb34099
1 /* Gnome Music Player Client (GMPC)
2 * Copyright (C) 2004-2012 Qball Cow <qball@gmpclient.org>
3 * Project homepage: http://gmpclient.org/
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef __GMPC_EASY_DOWNLOAD_H__
21 #define __GMPC_EASY_DOWNLOAD_H__
22 /**
23 * Async easy download api
24 * This is based on libsoup
27 typedef struct _GEADAsyncHandler GEADAsyncHandler;
28 typedef enum {
29 GEAD_DONE,
30 GEAD_PROGRESS,
31 GEAD_FAILED,
32 GEAD_CANCELLED
33 } GEADStatus;
35 typedef void (*GEADAsyncCallback) (const GEADAsyncHandler * handle, GEADStatus status, gpointer user_data);
36 typedef void (*GEADAsyncCallbackVala) (const GEADAsyncHandler * handle, GEADStatus status, gpointer user_data,
37 gpointer userdata_callback);
38 /**
39 * @param uri the http uri to download
40 * @param callback the callback function. Giving status updates on the download.
41 * @param user_data Data to pass along to callback.
43 * returns: a GEADAsyncHandler (or NULL on failure), remember you need to free this. This can be done f.e. in the callback. (same Handler get passed)
45 GEADAsyncHandler *gmpc_easy_async_downloader(const gchar * uri, GEADAsyncCallback callback, gpointer user_data);
47 GEADAsyncHandler *gmpc_easy_async_downloader_with_headers(const gchar * uri,
48 GEADAsyncCallback callback, gpointer user_data, ...);
49 /**
50 * Cancel download, triggers GEAD_CANCEL in callback
52 void gmpc_easy_async_cancel(const GEADAsyncHandler * handle);
54 /**
55 * Get the size of the download, usefull for progressbar
57 goffset gmpc_easy_handler_get_content_size(const GEADAsyncHandler * handle);
58 const char *gmpc_easy_handler_get_uri(const GEADAsyncHandler * handle);
60 const char *gmpc_easy_handler_get_data(const GEADAsyncHandler * handle, goffset * length);
62 const guchar *gmpc_easy_handler_get_data_vala_wrap(const GEADAsyncHandler * handle, gint * length);
63 /**
64 * Get the data as a string.
65 * If you know it will be a text. This function will return the data \0
66 * terminated. (if you need length, without the trailing \0 use get_data
67 * This can be usefull for f.e. vala that might copy the 'raw'data and remove
68 * the trailing '\0'.
70 const char *gmpc_easy_handler_get_data_as_string(const GEADAsyncHandler * handle);
72 void gmpc_easy_handler_set_user_data(const GEADAsyncHandler *handle, gpointer user_data);
73 gpointer gmpc_easy_handler_get_user_data(const GEADAsyncHandler *handle);
76 char *gmpc_easy_download_uri_escape(const char *part);
77 GEADAsyncHandler * gmpc_easy_async_downloader_vala(const char *path, gpointer user_data2, GEADAsyncCallbackVala callback,
78 gpointer user_data
80 #endif
81 /* vim: set noexpandtab ts=4 sw=4 sts=4 tw=120: */