#pragma once #include "uitypes.h" #include #include #include #include #include #include "binaryninjaapi.h" class BINARYNINJAUIAPI UpdateInfoFetcher : public QObject, public std::enable_shared_from_this { Q_OBJECT public: struct Version { QString versionStringToGiveToMainWindow; QVersionNumber version; QDateTime date; bool isCurrent = false; Version(BNUpdateVersionNew); }; struct ChangelogEntryItem { QString author; QString commit; QString body; bool isHidden = false; ChangelogEntryItem(const QString& author = "", const QString& commit = "", const QString& body = "", const bool isHidden = false) : author(author), commit(commit), body(body), isHidden(isHidden) {}; /// In-struct cache for wrapped text mutable QString bodyWrapCache; }; struct ChangelogEntry { QVersionNumber version; QDateTime date; bool isNew = false; std::vector entryItems; ChangelogEntry(BNChangelogEntry); }; struct Channel { QString name; QString description; std::vector versions; std::vector changelog; Channel(BNUpdateChannelFullInfo); Channel() {}; }; enum FetchError { NoError, ConnectionError, DeserError }; private: std::vector m_channels; std::mutex m_infoMutex; std::atomic m_done = false; struct UseCreate {}; public: // Instances must be created via `create()`. UpdateInfoFetcher(UseCreate) {} static std::shared_ptr create(); UpdateInfoFetcher(const UpdateInfoFetcher&) = delete; UpdateInfoFetcher& operator=(const UpdateInfoFetcher&) = delete; bool done() { return m_done; } void startFetch(); const std::vector& getChannels(); const Channel* getActiveChannel(); std::vector getFilteredChangelog(); signals: void fetchCompleted(const FetchError& error); };