diff --git a/src/slic3r/GUI/PresetArchiveDatabase.cpp b/src/slic3r/GUI/PresetArchiveDatabase.cpp index 632c8991af..19ffbafd02 100644 --- a/src/slic3r/GUI/PresetArchiveDatabase.cpp +++ b/src/slic3r/GUI/PresetArchiveDatabase.cpp @@ -320,6 +320,17 @@ PresetArchiveDatabase::PresetArchiveDatabase(AppConfig* app_config, wxEvtHandler set_local_archives(app_config); } +void PresetArchiveDatabase::set_used_archives(const std::vector& 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(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 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; diff --git a/src/slic3r/GUI/PresetArchiveDatabase.hpp b/src/slic3r/GUI/PresetArchiveDatabase.hpp index 6f19cd70e7..722963a784 100644 --- a/src/slic3r/GUI/PresetArchiveDatabase.hpp +++ b/src/slic3r/GUI/PresetArchiveDatabase.hpp @@ -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& get_used_archives() const { return m_used_archive_ids; } + void set_used_archives(const std::vector& 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 m_used_archive_ids; std::vector m_local_archive_adresses; std::string m_token; };