aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-09-21 03:49:17 +0200
committerdec05eba <dec05eba@protonmail.com>2020-09-21 03:49:17 +0200
commit40e0f8f5d8c3e480f01a2d71b6a493247adcb77f (patch)
treeccc3c0a7c82be8f5dbe86dfc712cce3da7e2ad59 /include
parent5c72463c029804c85479d2c4426397d932c88ee1 (diff)
Initial matrix support
Diffstat (limited to 'include')
-rw-r--r--include/Body.hpp13
-rw-r--r--include/Notification.hpp22
-rw-r--r--include/Page.hpp6
-rw-r--r--include/QuickMedia.hpp2
-rw-r--r--include/Storage.hpp4
-rw-r--r--include/StringUtils.hpp2
6 files changed, 27 insertions, 22 deletions
diff --git a/include/Body.hpp b/include/Body.hpp
index 3dfbeaa..0bea3c2 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -21,8 +21,19 @@ namespace QuickMedia {
dirty = true;
}
+ void append_title(std::string str) {
+ title += str;
+ dirty = true;
+ }
+
void set_description(std::string new_description) {
description = std::move(new_description);
+ dirty_description = true;
+ }
+
+ void append_description(std::string str) {
+ description += str;
+ dirty_description = true;
}
const std::string& get_title() const { return title; }
@@ -35,6 +46,7 @@ namespace QuickMedia {
std::string author;
bool visible;
bool dirty;
+ bool dirty_description;
std::unique_ptr<Text> title_text;
std::unique_ptr<Text> description_text;
// Used by image boards for example. The elements are indices to other body items
@@ -62,6 +74,7 @@ namespace QuickMedia {
void select_first_item();
void reset_selected();
void clear_items();
+ void append_items(BodyItems new_items);
void clear_thumbnails();
BodyItem* get_selected() const;
diff --git a/include/Notification.hpp b/include/Notification.hpp
index 4f7fcc2..0e40f42 100644
--- a/include/Notification.hpp
+++ b/include/Notification.hpp
@@ -1,7 +1,5 @@
#pragma once
-#include "Program.h"
-#include <assert.h>
#include <string>
namespace QuickMedia {
@@ -11,22 +9,6 @@ namespace QuickMedia {
CRITICAL
};
- static const char* urgency_string(Urgency urgency) {
- switch(urgency) {
- case Urgency::LOW:
- return "low";
- case Urgency::NORMAL:
- return "normal";
- case Urgency::CRITICAL:
- return "critical";
- }
- assert(false);
- return nullptr;
- }
-
- static void show_notification(const std::string &title, const std::string &description, Urgency urgency = Urgency::NORMAL) {
- const char *args[] = { "notify-send", "-u", urgency_string(urgency), "--", title.c_str(), description.c_str(), nullptr };
- exec_program_async(args, nullptr);
- fprintf(stderr, "Notification: title: %s, description: %s\n", title.c_str(), description.c_str());
- }
+ const char* urgency_string(Urgency urgency);
+ void show_notification(const std::string &title, const std::string &description, Urgency urgency = Urgency::NORMAL);
} \ No newline at end of file
diff --git a/include/Page.hpp b/include/Page.hpp
index dc4051c..5bd8e0d 100644
--- a/include/Page.hpp
+++ b/include/Page.hpp
@@ -4,7 +4,7 @@ namespace QuickMedia {
enum class Page {
EXIT,
SEARCH_SUGGESTION,
- SEARCH_RESULT,
+ //SEARCH_RESULT,
VIDEO_CONTENT,
EPISODE_LIST,
IMAGES,
@@ -12,6 +12,8 @@ namespace QuickMedia {
CONTENT_LIST,
CONTENT_DETAILS,
IMAGE_BOARD_THREAD_LIST,
- IMAGE_BOARD_THREAD
+ IMAGE_BOARD_THREAD,
+ CHAT_LOGIN,
+ CHAT
};
} \ No newline at end of file
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index d3bff47..485aeca 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -52,6 +52,8 @@ namespace QuickMedia {
void content_details_page();
void image_board_thread_list_page();
void image_board_thread_page();
+ void chat_login_page();
+ void chat_page();
bool on_search_suggestion_submit_text(Body *input_body, Body *output_body);
diff --git a/include/Storage.hpp b/include/Storage.hpp
index 601336a..cdae7b0 100644
--- a/include/Storage.hpp
+++ b/include/Storage.hpp
@@ -3,6 +3,7 @@
#include "Path.hpp"
#include <functional>
#include <filesystem>
+#include <json/value.h>
namespace QuickMedia {
// Return false to stop the iterator
@@ -24,4 +25,7 @@ namespace QuickMedia {
int file_overwrite(const Path &path, const std::string &data);
void for_files_in_dir(const Path &path, FileIteratorCallback callback);
void for_files_in_dir_sort_last_modified(const Path &path, FileIteratorCallback callback);
+
+ bool read_file_as_json(const Path &filepath, Json::Value &result);
+ bool save_json_to_file_atomic(const Path &path, const Json::Value &json);
} \ No newline at end of file
diff --git a/include/StringUtils.hpp b/include/StringUtils.hpp
index b2efb1d..97c73dd 100644
--- a/include/StringUtils.hpp
+++ b/include/StringUtils.hpp
@@ -9,6 +9,8 @@ namespace QuickMedia {
void string_split(const std::string &str, char delimiter, StringSplitCallback callback_func);
// Returns the number of replaced substrings
+ size_t string_replace_all(std::string &str, char old_char, const std::string &new_str);
+ // Returns the number of replaced substrings
size_t string_replace_all(std::string &str, const std::string &old_str, const std::string &new_str);
std::string strip(const std::string &str);
bool string_ends_with(const std::string &str, const std::string &ends_with_str);