1
0
mirror of synced 2024-11-14 11:07:43 +01:00
ImHex/plugins/builtin/include/content/views/view_store.hpp

58 lines
1.3 KiB
C++
Raw Normal View History

#pragma once
#include <hex.hpp>
#include <hex/views/view.hpp>
#include <hex/helpers/net.hpp>
#include <hex/helpers/paths.hpp>
#include <array>
#include <future>
#include <string>
#include <filesystem>
2021-12-07 22:47:41 +01:00
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;
void drawMenu() override;
2022-01-10 21:05:37 +01:00
[[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;
2022-01-13 14:33:30 +01:00
fs::path m_downloadPath;
std::vector<StoreEntry> m_patterns, m_includes, m_magics, m_constants, m_yara;
void drawStore();
void refresh();
void parseResponse();
void download(ImHexPath pathType, const std::string &fileName, const std::string &url, bool update);
void remove(ImHexPath pathType, const std::string &fileName);
};
}