1
0
mirror of synced 2024-11-27 17:10:51 +01:00
ImHex/plugins/builtin/include/content/views/view_store.hpp
WerWolv 1991afb87b
sys: Get rid of SharedData struct and cleanup code structure (#411)
* sys: Initial refactoring of the SharedData class

* sys/pattern: More refactoring, make every provider have its own patterns

* sys: Finished up refactoring. No more SharedData!

* sys: Fixed compile on Unix

* tests: Fixed unit tests

* sys: Moved view and lang files

* pattern: Added assignment operator support to for loops

* tests: Fixed compile issue
2022-02-01 18:09:40 +01:00

57 lines
1.3 KiB
C++

#pragma once
#include <hex.hpp>
#include <hex/ui/view.hpp>
#include <hex/helpers/net.hpp>
#include <hex/helpers/paths.hpp>
#include <array>
#include <future>
#include <string>
#include <filesystem>
namespace hex::plugin::builtin {
struct StoreEntry {
std::string name;
std::string description;
std::string fileName;
std::string link;
std::string hash;
bool isFolder;
bool downloading;
bool installed;
bool hasUpdate;
};
class ViewStore : public View {
public:
ViewStore();
~ViewStore() override;
void drawContent() override;
[[nodiscard]] bool isAvailable() const override { return true; }
[[nodiscard]] bool hasViewMenuItemEntry() const override { return false; }
private:
Net m_net;
std::future<Response<std::string>> m_apiRequest;
std::future<Response<void>> m_download;
fs::path m_downloadPath;
std::vector<StoreEntry> m_patterns, m_includes, m_magics, m_constants, m_yara, m_encodings;
void drawStore();
void refresh();
void parseResponse();
bool download(ImHexPath pathType, const std::string &fileName, const std::string &url, bool update);
bool remove(ImHexPath pathType, const std::string &fileName);
};
}