aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/Body.hpp8
-rw-r--r--include/QuickMedia.hpp5
-rw-r--r--include/Storage.hpp3
-rw-r--r--plugins/Mangadex.hpp1
-rw-r--r--plugins/Matrix.hpp3
-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
18 files changed, 45 insertions, 32 deletions
diff --git a/include/Body.hpp b/include/Body.hpp
index 2a82406..65645e9 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -1,13 +1,9 @@
#pragma once
#include "BodyItem.hpp"
-#include "AsyncImageLoader.hpp"
#include "RoundedRectangle.hpp"
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/Sprite.hpp>
-#include <json/value.h>
-#include <thread>
-#include <future>
namespace sf {
class RenderWindow;
@@ -16,6 +12,10 @@ namespace sf {
class Event;
}
+namespace Json {
+ class Value;
+}
+
namespace QuickMedia {
using BodyItemRenderCallback = std::function<void(std::shared_ptr<BodyItem> &body_item)>;
// Return true to merge
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index 56e9d3f..19c634e 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -1,9 +1,7 @@
#pragma once
#include "Body.hpp"
-#include "SearchBar.hpp"
#include "Page.hpp"
-#include "Storage.hpp"
#include "Tab.hpp"
#include "MessageQueue.hpp"
#include "AsyncTask.hpp"
@@ -14,8 +12,8 @@
#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Shader.hpp>
-#include <json/value.h>
#include <unordered_set>
+#include <json/value.h>
#include <future>
#include <thread>
#include <stack>
@@ -32,6 +30,7 @@ namespace QuickMedia {
class VideoPage;
class Tabs;
class VideoPlayer;
+ class SearchBar;
enum class ImageViewMode {
SINGLE,
diff --git a/include/Storage.hpp b/include/Storage.hpp
index 9107bb2..1bf44a9 100644
--- a/include/Storage.hpp
+++ b/include/Storage.hpp
@@ -2,7 +2,6 @@
#include "Path.hpp"
#include <functional>
-#include <filesystem>
#include <rapidjson/fwd.h>
namespace Json {
@@ -11,7 +10,7 @@ namespace Json {
namespace QuickMedia {
// Return false to stop the iterator
- using FileIteratorCallback = std::function<bool(const std::filesystem::path &filepath)>;
+ using FileIteratorCallback = std::function<bool(const Path &filepath)>;
enum class FileType {
FILE_NOT_FOUND,
diff --git a/plugins/Mangadex.hpp b/plugins/Mangadex.hpp
index 67f68b7..b92489d 100644
--- a/plugins/Mangadex.hpp
+++ b/plugins/Mangadex.hpp
@@ -2,6 +2,7 @@
#include "Manga.hpp"
#include <functional>
+#include <optional>
namespace QuickMedia {
PluginResult legacy_mangadex_id_to_new_manga_id(Page *page, const std::vector<int> &manga_ids, std::vector<std::pair<int, std::string>> &new_manga_ids);
diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp
index 341a534..cd7bdce 100644
--- a/plugins/Matrix.hpp
+++ b/plugins/Matrix.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "../include/FileAnalyzer.hpp"
+#include "../include/MessageQueue.hpp"
#include "Plugin.hpp"
#include "Page.hpp"
#include <SFML/Graphics/Color.hpp>
@@ -8,6 +9,8 @@
#include <unordered_set>
#include <set>
#include <mutex>
+#include <atomic>
+#include <thread>
#include <rapidjson/fwd.h>
namespace QuickMedia {
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>