diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-09-13 21:30:39 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-09-13 21:30:39 +0200 |
commit | b97c4c3ccad3c917e2073329e8d1c7b7351e96aa (patch) | |
tree | 0e5b5791ace6f1f72dac4ce42ca5d990165fc3c7 /src/QuickMedia.cpp | |
parent | a9d69f57a0cd4f9cccff07b2890a860695d1e7ed (diff) |
Include refactoring
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r-- | src/QuickMedia.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index d91f2a1..38ff610 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -35,6 +35,8 @@ #include "../include/Theme.hpp" #include "../include/Utils.hpp" #include "../include/Downloader.hpp" +#include "../include/Storage.hpp" +#include "../include/AsyncImageLoader.hpp" #include "../plugins/youtube/YoutubeMediaProxy.hpp" #include "../include/gui/Button.hpp" #include "../external/hash-library/sha256.h" @@ -946,8 +948,8 @@ namespace QuickMedia { show_notification("QuickMedia", "Upgrading mangadex ids", Urgency::LOW); std::vector<int> legacy_manga_ids; - for_files_in_dir_sort_last_modified(content_storage_dir, [&legacy_manga_ids](const std::filesystem::path &filepath) { - if(filepath.extension() == ".tmp") + for_files_in_dir_sort_last_modified(content_storage_dir, [&legacy_manga_ids](const Path &filepath) { + if(strcmp(filepath.ext(), ".tmp") == 0) return true; std::string filename = filepath.filename(); @@ -1409,32 +1411,29 @@ namespace QuickMedia { } time_t now = time(NULL); - for_files_in_dir_sort_last_modified(content_storage_dir, [&history_items, plugin_name, now](const std::filesystem::path &filepath) { + for_files_in_dir_sort_last_modified(content_storage_dir, [&history_items, plugin_name, now](const Path &filepath) { // This can happen when QuickMedia crashes/is killed while writing to storage. // In that case, the storage wont be corrupt but there will be .tmp files. // TODO: Remove these .tmp files if they exist during startup - if(filepath.extension() == ".tmp") + if(strcmp(filepath.ext(), ".tmp") == 0) return true; - Path fullpath(filepath.c_str()); Json::Value body; - if(!read_file_as_json(fullpath, body) || !body.isObject()) { - fprintf(stderr, "Failed to read json file: %s\n", fullpath.data.c_str()); + if(!read_file_as_json(filepath, body) || !body.isObject()) { + fprintf(stderr, "Failed to read json file: %s\n", filepath.data.c_str()); return true; } // TODO: Manga combined - auto filename = filepath.filename(); - if(filename.empty()) - return true; + const char *filename = filepath.filename(); const Json::Value &manga_name = body["name"]; if(!manga_name.isString()) return true; time_t last_modified_time = 0; - file_get_last_modified_time_seconds(filepath.c_str(), &last_modified_time); + file_get_last_modified_time_seconds(filepath.data.c_str(), &last_modified_time); // TODO: Add thumbnail auto body_item = BodyItem::create(manga_name.asString()); @@ -1442,19 +1441,19 @@ namespace QuickMedia { body_item->set_description_color(get_theme().faded_text_color); if(strcmp(plugin_name, "manganelo") == 0) - body_item->url = "https://manganelo.com/manga/" + base64_url_decode(filename.string()); + body_item->url = "https://manganelo.com/manga/" + base64_url_decode(filename); else if(strcmp(plugin_name, "manganelos") == 0) - body_item->url = "http://manganelos.com/manga/" + base64_url_decode(filename.string()); + body_item->url = "http://manganelos.com/manga/" + base64_url_decode(filename); else if(strcmp(plugin_name, "mangadex") == 0) - body_item->url = base64_url_decode(filename.string()); + body_item->url = base64_url_decode(filename); else if(strcmp(plugin_name, "mangatown") == 0) - body_item->url = "https://mangatown.com/manga/" + base64_url_decode(filename.string()); + body_item->url = "https://mangatown.com/manga/" + base64_url_decode(filename); else if(strcmp(plugin_name, "mangakatana") == 0) - body_item->url = "https://mangakatana.com/manga/" + base64_url_decode(filename.string()); + body_item->url = "https://mangakatana.com/manga/" + base64_url_decode(filename); else if(strcmp(plugin_name, "onimanga") == 0) - body_item->url = "https://onimanga.com/" + base64_url_decode(filename.string()); + body_item->url = "https://onimanga.com/" + base64_url_decode(filename); else if(strcmp(plugin_name, "readm") == 0) - body_item->url = "https://readm.org/manga/" + base64_url_decode(filename.string()); + body_item->url = "https://readm.org/manga/" + base64_url_decode(filename); else fprintf(stderr, "Error: Not implemented: filename to manga chapter list\n"); |