2021-08-29 09:10:48 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex.hpp>
|
|
|
|
|
2022-02-01 17:09:40 +00:00
|
|
|
#include <hex/ui/view.hpp>
|
2021-09-03 00:34:40 +00:00
|
|
|
#include <hex/helpers/net.hpp>
|
|
|
|
#include <hex/helpers/paths.hpp>
|
2021-08-29 09:10:48 +00:00
|
|
|
|
|
|
|
#include <array>
|
2021-09-03 00:34:40 +00:00
|
|
|
#include <future>
|
2021-08-29 09:10:48 +00:00
|
|
|
#include <string>
|
2021-09-23 20:56:49 +00:00
|
|
|
#include <filesystem>
|
2021-08-29 09:10:48 +00:00
|
|
|
|
2021-12-07 21:47:41 +00:00
|
|
|
namespace hex::plugin::builtin {
|
2021-08-29 09:10:48 +00:00
|
|
|
|
2021-09-03 00:34:40 +00:00
|
|
|
struct StoreEntry {
|
|
|
|
std::string name;
|
|
|
|
std::string description;
|
|
|
|
std::string fileName;
|
|
|
|
std::string link;
|
|
|
|
std::string hash;
|
2021-08-29 09:10:48 +00:00
|
|
|
|
2021-09-23 20:56:49 +00:00
|
|
|
bool isFolder;
|
|
|
|
|
2021-09-03 00:34:40 +00:00
|
|
|
bool downloading;
|
|
|
|
bool installed;
|
|
|
|
bool hasUpdate;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ViewStore : public View {
|
2021-08-29 09:10:48 +00:00
|
|
|
public:
|
2021-09-03 00:34:40 +00:00
|
|
|
ViewStore();
|
|
|
|
~ViewStore() override;
|
2021-08-29 09:10:48 +00:00
|
|
|
|
|
|
|
void drawContent() override;
|
|
|
|
|
2022-01-10 20:05:37 +00:00
|
|
|
[[nodiscard]] bool isAvailable() const override { return true; }
|
|
|
|
[[nodiscard]] bool hasViewMenuItemEntry() const override { return false; }
|
2021-09-03 00:34:40 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Net m_net;
|
|
|
|
std::future<Response<std::string>> m_apiRequest;
|
|
|
|
std::future<Response<void>> m_download;
|
2022-01-13 13:33:30 +00:00
|
|
|
fs::path m_downloadPath;
|
2021-09-03 00:34:40 +00:00
|
|
|
|
2022-01-23 20:52:24 +00:00
|
|
|
std::vector<StoreEntry> m_patterns, m_includes, m_magics, m_constants, m_yara, m_encodings;
|
2021-09-03 00:34:40 +00:00
|
|
|
|
|
|
|
void drawStore();
|
|
|
|
|
|
|
|
void refresh();
|
|
|
|
void parseResponse();
|
|
|
|
|
2022-01-23 20:52:24 +00:00
|
|
|
bool download(ImHexPath pathType, const std::string &fileName, const std::string &url, bool update);
|
|
|
|
bool remove(ImHexPath pathType, const std::string &fileName);
|
2021-08-29 09:10:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|