aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-09-13 21:30:39 +0200
committerdec05eba <dec05eba@protonmail.com>2021-09-13 21:30:39 +0200
commitb97c4c3ccad3c917e2073329e8d1c7b7351e96aa (patch)
tree0e5b5791ace6f1f72dac4ce42ca5d990165fc3c7 /src
parenta9d69f57a0cd4f9cccff07b2890a860695d1e7ed (diff)
Include refactoring
Diffstat (limited to 'src')
-rw-r--r--src/Body.cpp4
-rw-r--r--src/QuickMedia.cpp35
-rw-r--r--src/Storage.cpp5
-rw-r--r--src/plugins/FileManager.cpp1
-rw-r--r--src/plugins/Info.cpp1
-rw-r--r--src/plugins/MangaGeneric.cpp1
-rw-r--r--src/plugins/Manganelo.cpp1
-rw-r--r--src/plugins/Matrix.cpp4
-rw-r--r--src/plugins/MyAnimeList.cpp1
-rw-r--r--src/plugins/Page.cpp1
-rw-r--r--src/plugins/Peertube.cpp1
-rw-r--r--src/plugins/Soundcloud.cpp1
-rw-r--r--src/plugins/Youtube.cpp1
13 files changed, 34 insertions, 23 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index 45ca190..1117f5b 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -1,5 +1,4 @@
#include "../include/Body.hpp"
-#include "../include/QuickMedia.hpp"
#include "../include/Scale.hpp"
#include "../include/ResourceLoader.hpp"
#include "../include/AsyncImageLoader.hpp"
@@ -8,8 +7,11 @@
#include "../include/Theme.hpp"
#include "../include/StringUtils.hpp"
#include "../plugins/Plugin.hpp"
+#include <json/value.h>
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Window/Event.hpp>
+#include <SFML/Graphics/RenderWindow.hpp>
+#include <SFML/Graphics/Shader.hpp>
#include <assert.h>
#include <cmath>
#include <malloc.h>
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");
diff --git a/src/Storage.cpp b/src/Storage.cpp
index 3ceb606..2754bc8 100644
--- a/src/Storage.cpp
+++ b/src/Storage.cpp
@@ -9,6 +9,7 @@
#include <rapidjson/writer.h>
#include <rapidjson/stringbuffer.h>
#include <unordered_set>
+#include <filesystem>
#include <pwd.h>
#include <unistd.h>
@@ -238,7 +239,7 @@ namespace QuickMedia {
void for_files_in_dir(const Path &path, FileIteratorCallback callback) {
try {
for(auto &p : std::filesystem::directory_iterator(path.data)) {
- if(!callback(p.path()))
+ if(!callback(p.path().string()))
break;
}
} catch(const std::filesystem::filesystem_error &err) {
@@ -271,7 +272,7 @@ namespace QuickMedia {
});
for(auto &p : paths) {
- if(!callback(p.path()))
+ if(!callback(p.path().string()))
break;
}
}
diff --git a/src/plugins/FileManager.cpp b/src/plugins/FileManager.cpp
index 289a382..a92f3c1 100644
--- a/src/plugins/FileManager.cpp
+++ b/src/plugins/FileManager.cpp
@@ -2,6 +2,7 @@
#include "../../include/FileAnalyzer.hpp"
#include "../../include/ResourceLoader.hpp"
#include "../../include/Theme.hpp"
+#include "../../include/Storage.hpp"
#include "../../include/QuickMedia.hpp"
namespace QuickMedia {
diff --git a/src/plugins/Info.cpp b/src/plugins/Info.cpp
index a68033f..b488eba 100644
--- a/src/plugins/Info.cpp
+++ b/src/plugins/Info.cpp
@@ -4,6 +4,7 @@
#include "../../include/StringUtils.hpp"
#include "../../include/Program.hpp"
#include "../../include/Notification.hpp"
+#include "../../include/Storage.hpp"
namespace QuickMedia {
static const char *REVERSE_IMAGE_SEARCH_URL = "reverse-image-search://";
diff --git a/src/plugins/MangaGeneric.cpp b/src/plugins/MangaGeneric.cpp
index 78a2c39..98dc708 100644
--- a/src/plugins/MangaGeneric.cpp
+++ b/src/plugins/MangaGeneric.cpp
@@ -2,6 +2,7 @@
#include "../../include/StringUtils.hpp"
#include "../../include/Theme.hpp"
#include <quickmedia/HtmlSearch.h>
+#include <json/value.h>
#include <assert.h>
namespace QuickMedia {
diff --git a/src/plugins/Manganelo.cpp b/src/plugins/Manganelo.cpp
index 990a513..df86207 100644
--- a/src/plugins/Manganelo.cpp
+++ b/src/plugins/Manganelo.cpp
@@ -3,6 +3,7 @@
#include "../../include/NetUtils.hpp"
#include "../../include/Theme.hpp"
#include <quickmedia/HtmlSearch.h>
+#include <json/value.h>
namespace QuickMedia {
static bool string_view_contains(const QuickMediaStringView str, const char *sub) {
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 3f42437..13fd230 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -3817,8 +3817,8 @@ namespace QuickMedia {
remove(matrix_sync_data_path.data.c_str());
Path filter_cache_path = get_storage_dir().join("matrix").join("filter");
remove(filter_cache_path.data.c_str());
- for_files_in_dir(get_cache_dir().join("matrix").join("events"), [](const std::filesystem::path &filepath) {
- remove(filepath.c_str());
+ for_files_in_dir(get_cache_dir().join("matrix").join("events"), [](const Path &filepath) {
+ remove(filepath.data.c_str());
return true;
});
diff --git a/src/plugins/MyAnimeList.cpp b/src/plugins/MyAnimeList.cpp
index 16f07f9..ceba73a 100644
--- a/src/plugins/MyAnimeList.cpp
+++ b/src/plugins/MyAnimeList.cpp
@@ -3,6 +3,7 @@
#include "../../include/NetUtils.hpp"
#include "../../include/StringUtils.hpp"
#include <quickmedia/HtmlSearch.h>
+#include <json/value.h>
namespace QuickMedia {
// Returns {0, 0} if unknown
diff --git a/src/plugins/Page.cpp b/src/plugins/Page.cpp
index 5ce86e6..935d214 100644
--- a/src/plugins/Page.cpp
+++ b/src/plugins/Page.cpp
@@ -1,6 +1,7 @@
#include "../../plugins/Page.hpp"
#include "../../include/StringUtils.hpp"
#include "../../include/Theme.hpp"
+#include "../../include/Storage.hpp"
#include "../../include/QuickMedia.hpp"
#include <json/reader.h>
diff --git a/src/plugins/Peertube.cpp b/src/plugins/Peertube.cpp
index db55584..dd789d4 100644
--- a/src/plugins/Peertube.cpp
+++ b/src/plugins/Peertube.cpp
@@ -3,6 +3,7 @@
#include "../../include/Notification.hpp"
#include "../../include/Utils.hpp"
#include "../../include/StringUtils.hpp"
+#include <json/value.h>
namespace QuickMedia {
static const char* search_type_to_string(PeertubeSearchPage::SearchType search_type) {
diff --git a/src/plugins/Soundcloud.cpp b/src/plugins/Soundcloud.cpp
index 3a9a6e1..d54060d 100644
--- a/src/plugins/Soundcloud.cpp
+++ b/src/plugins/Soundcloud.cpp
@@ -5,6 +5,7 @@
#include "../../include/Scale.hpp"
#include "../../include/Theme.hpp"
#include <quickmedia/HtmlSearch.h>
+#include <json/value.h>
namespace QuickMedia {
static std::string client_id;
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index a258325..0316c6f 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -8,6 +8,7 @@
#include "../../include/VideoPlayer.hpp"
#include "../../include/Utils.hpp"
#include "../../include/Theme.hpp"
+#include <optional>
#include <json/reader.h>
extern "C" {
#include <HtmlParser.h>