diff options
author | ConfuSomu | 2023-08-03 17:23:33 +0200 |
---|---|---|
committer | ConfuSomu | 2023-08-03 17:23:33 +0200 |
commit | bf73a19e11e5cccd22f58a5c97e1346dab5587c8 (patch) | |
tree | 64654503131a2eb77c5e9cbf25478330e8ce261b /src/archive_parser.h | |
parent | 1500681405804b932761db7a0182d498894ad81c (diff) | |
download | ActorViewer-bf73a19e11e5cccd22f58a5c97e1346dab5587c8.tar ActorViewer-bf73a19e11e5cccd22f58a5c97e1346dab5587c8.tar.gz ActorViewer-bf73a19e11e5cccd22f58a5c97e1346dab5587c8.zip |
Create an Archive base class
This class is inherited by MastodonArchive to provide Mastodon (and
compatible) archive reading support. A base Archive class allows
implementing reading support of other archive formats that are from
other services.
Diffstat (limited to 'src/archive_parser.h')
-rw-r--r-- | src/archive_parser.h | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/src/archive_parser.h b/src/archive_parser.h deleted file mode 100644 index 162787e..0000000 --- a/src/archive_parser.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once - -#include <QString> -#include <QJsonDocument> -#include <QJsonObject> -#include <QJsonArray> -#include <QListWidget> -#include <QDir> - -#include "types.h" -#include "activitypub/fields.h" - -enum ArchiveType { - MASTODON -}; - -class Archive { -public: - enum InitError { - NoError = 0, - FailedOpeningFile, - JsonParseError, - JsonEmpty, - JsonNull, - JsonNotObject, - JsonNotActivityStream // for ActivityPub archives - }; - - Archive(QString outbox_filename, ArchiveType archive_type); - ~Archive(); - 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: - QString outbox_filename; - QDir archive_root_dir; - ArchiveType archive_type; - 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); -}; |