1 /* This file is part of Cawbird, a Gtk+ linux Twitter client forked from Corebird. 2 * Copyright (C) 2016 Timm Bäder (Corebird) 3 * 4 * Cawbird is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * Cawbird is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with cawbird. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef _CB_INLINE_MEDIA_DOWNLOADER_H_ 19 #define _CB_INLINE_MEDIA_DOWNLOADER_H_ 20 21 #include <glib-object.h> 22 #include <libsoup/soup.h> 23 #include "CbMedia.h" 24 #include "CbTypes.h" 25 26 G_BEGIN_DECLS 27 28 struct _CbMediaDownloader 29 { 30 GObject parent_instance; 31 32 GCancellable *cancellable; 33 guint disabled : 1; 34 }; 35 36 typedef struct _CbMediaDownloader CbMediaDownloader; 37 38 #define CB_TYPE_MEDIA_DOWNLOADER (cb_media_downloader_get_type ()) 39 G_DECLARE_FINAL_TYPE (CbMediaDownloader, cb_media_downloader, CB, MEDIA_DOWNLOADER, GObject); 40 41 CbMediaDownloader * cb_media_downloader_get_default (void); 42 void cb_media_downloader_load_all (CbMediaDownloader *downloader, 43 CbMiniTweet *t); 44 void cb_media_downloader_load_async (CbMediaDownloader *downloader, 45 CbMedia *media, 46 GAsyncReadyCallback callback, 47 gpointer user_data); 48 void cb_media_downloader_reload_async (CbMediaDownloader *downloader, 49 CbMedia *media, 50 GAsyncReadyCallback callback, 51 gpointer user_data); 52 void cb_media_downloader_load_hires_async (CbMediaDownloader *downloader, 53 CbMedia *media, 54 GAsyncReadyCallback callback, 55 gpointer user_data); 56 gboolean cb_media_downloader_load_finish (CbMediaDownloader *downloader, 57 GAsyncResult *result, 58 GError **error); 59 void cb_media_downloader_disable (CbMediaDownloader *downloader); 60 void cb_media_downloader_shutdown (CbMediaDownloader *downloader); 61 gboolean is_media_candidate (const char *url); 62 gboolean is_twitter_media_candidate (const char *url); 63 64 G_END_DECLS 65 66 typedef enum { 67 CB_MEDIA_DOWNLOADER_ERROR_UNKNOWN, 68 CB_MEDIA_DOWNLOADER_ERROR_SOUP_MESSAGE_NEW 69 // We also use all SOUP_STATUS_... codes 70 } CbMediaDownloaderErrorCode; 71 72 #define CB_MEDIA_DOWNLOADER_ERROR cb_media_downloader_error_quark() 73 GQuark cb_media_downloader_error_quark (void); 74 75 #endif 76