aboutsummaryrefslogtreecommitdiffstats
path: root/src/archive/mastodon.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/archive/mastodon.h')
-rw-r--r--src/archive/mastodon.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/archive/mastodon.h b/src/archive/mastodon.h
new file mode 100644
index 0000000..48be1f3
--- /dev/null
+++ b/src/archive/mastodon.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include "src/archive/base_archive.h"
+#include "src/activitypub/fields.h"
+#include "src/types.h"
+
+#include <QJsonDocument>
+#include <QJsonObject>
+#include <QJsonArray>
+#include <QListWidget>
+#include <QDir>
+
+class MastodonArchive : public Archive {
+public:
+ MastodonArchive(const QString& filename);
+ ~MastodonArchive();
+ std::variant<QString, InitError> init();
+
+ void update_status_list(ViewStatusTypes allowed_types, QListWidget *parent);
+ const QString get_html_status_info(int status_index, int text_zone_width, StatusType status_type, QLocale* locale);
+ const QString get_html_status_text(int status_index);
+private:
+ QDir archive_root_dir;
+ QDir attachment_dir;
+ bool attachment_dir_have_to_find = true;
+
+ QJsonObject *outbox_json = nullptr;
+ QJsonArray *outbox_items = nullptr;
+
+ bool is_status_type_allowed(StatusType status_type, ViewStatusTypes allowed_types);
+ StatusType get_status_type(QJsonObject obj);
+ QStringList get_status_object_list(QJsonObject obj, QString element_name) ;
+ QStringList get_status_object_language_list(QJsonObject obj, QString element_name);
+ std::vector<APAttachmentFields> get_status_attachments_list(QJsonValueRef attachments_ref);
+ void find_attachment_dir(QString example_attachment);
+
+ // Check the `object`, which may be a simple string or a QJsonArray, for the existance of a string `item`.
+ // Returns true if the `item` exists, else false.
+ bool json_check_item(const QJsonValue& object, const QString& item);
+};