From cdf8d103f1ed6a932eb30b589b578d23ca66a514 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 10 May 2021 18:49:44 +0200 Subject: Add downloader, fix room navigation lag Fix bug where getting next page fails if there is no search bar --- include/DownloadUtils.hpp | 2 ++ include/NetUtils.hpp | 1 + include/QuickMedia.hpp | 3 ++- include/Storage.hpp | 2 ++ include/StringUtils.hpp | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/DownloadUtils.hpp b/include/DownloadUtils.hpp index 0a68069..964e74b 100644 --- a/include/DownloadUtils.hpp +++ b/include/DownloadUtils.hpp @@ -27,5 +27,7 @@ namespace QuickMedia { DownloadResult download_to_string_cache(const std::string &url, std::string &result, const std::vector &additional_args, bool use_browser_useragent = false, DownloadErrorHandler error_handler = nullptr, Path cache_path = ""); // Note: This function saves the content to the file atomically DownloadResult download_to_file(const std::string &url, const std::string &destination_filepath, const std::vector &additional_args, bool use_browser_useragent = false); + // Returns false if there was an error trying to create the download process + bool download_async_gui(const std::string &url, bool use_youtube_dl, bool no_video); DownloadResult download_to_json(const std::string &url, rapidjson::Document &result, const std::vector &additional_args, bool use_browser_useragent = false, bool fail_on_error = true); } \ No newline at end of file diff --git a/include/NetUtils.hpp b/include/NetUtils.hpp index e719c82..bacafc7 100644 --- a/include/NetUtils.hpp +++ b/include/NetUtils.hpp @@ -15,4 +15,5 @@ namespace QuickMedia { std::vector extract_urls(const std::string &str); std::vector ranges_get_strings(const std::string &str, const std::vector &ranges); void convert_utf8_to_utf32_ranges(const std::string &str, std::vector &ranges); + std::string header_extract_value(const std::string &header, const std::string &type); } \ No newline at end of file diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp index 30836aa..01baf76 100644 --- a/include/QuickMedia.hpp +++ b/include/QuickMedia.hpp @@ -100,7 +100,7 @@ namespace QuickMedia { Json::Value load_video_history_json(); private: - void init(Window parent_window); + void init(Window parent_window, std::string &program_path); void load_plugin_by_name(std::vector &tabs, const char *start_dir, int &start_tab_index, FileManagerMimeType fm_mime_type, FileSelectionHandler file_selection_handler); // Returns true if the window was closed bool handle_window_close(); @@ -119,6 +119,7 @@ namespace QuickMedia { void chat_login_page(); bool chat_page(MatrixChatPage *matrix_chat_page, RoomData *current_room, std::vector &room_tabs, int room_selected_tab); void after_matrix_login_page(); + void download_page(const char *url, bool download_use_youtube_dl); enum class LoadImageResult { OK, diff --git a/include/Storage.hpp b/include/Storage.hpp index 4dab9b3..93d13ff 100644 --- a/include/Storage.hpp +++ b/include/Storage.hpp @@ -36,4 +36,6 @@ namespace QuickMedia { int rename_atomic(const char *oldpath, const char *newpath); bool is_program_executable_by_name(const char *name); + + std::string file_size_to_human_readable_string(size_t bytes); } \ No newline at end of file diff --git a/include/StringUtils.hpp b/include/StringUtils.hpp index 6df16db..8a94d2f 100644 --- a/include/StringUtils.hpp +++ b/include/StringUtils.hpp @@ -17,4 +17,5 @@ namespace QuickMedia { std::string strip(const std::string &str); bool string_starts_with(const std::string &str, const char *sub); bool string_ends_with(const std::string &str, const std::string &ends_with_str); + size_t str_find_case_insensitive(const std::string &str, size_t start_index, const char *substr, size_t substr_len); } \ No newline at end of file -- cgit v1.2.3