mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-28 06:02:02 +08:00
WIP interface for managing local repositories and used repositories
This commit is contained in:
parent
3e9c9d9558
commit
f6724ea0bd
@ -320,6 +320,17 @@ PresetArchiveDatabase::PresetArchiveDatabase(AppConfig* app_config, wxEvtHandler
|
||||
set_local_archives(app_config);
|
||||
}
|
||||
|
||||
void PresetArchiveDatabase::set_used_archives(const std::vector<std::string>& used_ids)
|
||||
{
|
||||
m_used_archive_ids = used_ids;
|
||||
}
|
||||
void PresetArchiveDatabase::add_local_archive(const boost::filesystem::path path)
|
||||
{
|
||||
}
|
||||
void PresetArchiveDatabase::remove_local_archive(const std::string& id)
|
||||
{
|
||||
}
|
||||
|
||||
void PresetArchiveDatabase::set_archives(const std::string& json_body)
|
||||
{
|
||||
m_archives.clear();
|
||||
@ -350,30 +361,21 @@ void PresetArchiveDatabase::set_archives(const std::string& json_body)
|
||||
m_archives.emplace_back(std::make_unique<LocalArchiveRepository>(std::move(header_data)));
|
||||
}
|
||||
}
|
||||
m_used_archive_ids.clear();
|
||||
m_used_archive_ids.reserve(m_archives.size());
|
||||
for (const auto& archive : m_archives) {
|
||||
m_used_archive_ids.emplace_back(archive->get_manifest().id);
|
||||
}
|
||||
}
|
||||
|
||||
void PresetArchiveDatabase::set_local_archives(AppConfig* app_config)
|
||||
{
|
||||
m_local_archive_adresses.clear();
|
||||
std::string opt = app_config->get("local_archives");
|
||||
std::vector<std::string> options;
|
||||
deserialize_string(opt, m_local_archive_adresses);
|
||||
}
|
||||
|
||||
// test_json is only for testing
|
||||
namespace {
|
||||
std::string test_json(bool secret)
|
||||
{
|
||||
std::string test = "["
|
||||
"{\"name\": \"Prusa Research\", \"id\": \"PrusaResearch\", \"url\": \"https://github.com/kocikdav/PrusaSlicer-settings/raw/master/archive_repos/PrusaResearch\", \"description\": \"Prusa Research\", \"visibility\":\"\"}, "
|
||||
"{\"name\": \"Other Vendors\", \"id\": \"OtherVendors\", \"url\": \"https://github.com/kocikdav/PrusaSlicer-settings/raw/master/archive_repos/OtherVendors\",\"description\": \"Other Vendors\", \"visibility\":\"\"} ";
|
||||
//if (secret) {
|
||||
// test += ", {\"name\": \"Davit\", \"id\": \"Davit\", \"archive_url\": \"https://github.com/kocikdav/PrusaSlicer-settings/raw/master/other_source\", \"secret\": true}";
|
||||
//}
|
||||
test += "]";
|
||||
return std::move(test);
|
||||
}
|
||||
|
||||
bool sync_inner(std::string& manifest)
|
||||
{
|
||||
bool ret = false;
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
virtual bool get_file(const std::string& source_subpath, const boost::filesystem::path& target_path, const std::string& repository_id) const = 0;
|
||||
// Gets file without id check - for not yet encountered vendors only!
|
||||
virtual bool get_ini_no_id(const std::string& source_subpath, const boost::filesystem::path& target_path) const = 0;
|
||||
const RepositoryManifest& get_manifest() const { return m_data; }
|
||||
protected:
|
||||
RepositoryManifest m_data;
|
||||
};
|
||||
@ -110,10 +111,15 @@ public:
|
||||
void set_token(const std::string token) { m_token = token; }
|
||||
void set_local_archives(AppConfig* app_config);
|
||||
void set_archives(const std::string& json_body);
|
||||
const std::vector<std::string>& get_used_archives() const { return m_used_archive_ids; }
|
||||
void set_used_archives(const std::vector<std::string>& used_ids);
|
||||
void add_local_archive(const boost::filesystem::path path);
|
||||
void remove_local_archive(const std::string& id);
|
||||
private:
|
||||
wxEvtHandler* p_evt_handler;
|
||||
boost::filesystem::path m_unq_tmp_path;
|
||||
ArchiveRepositoryVector m_archives;
|
||||
std::vector<std::string> m_used_archive_ids;
|
||||
std::vector<std::string> m_local_archive_adresses;
|
||||
std::string m_token;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user