}
}
}
+
+
+bool
+DKDMGroup::contains(string dkdm_id) const
+{
+ for (auto child: _children) {
+ if (auto child_group = dynamic_pointer_cast<DKDMGroup>(child)) {
+ if (child_group->contains(dkdm_id)) {
+ return true;
+ }
+ } else if (auto child_dkdm = dynamic_pointer_cast<DKDM>(child)) {
+ if (child_dkdm->dkdm().id() == dkdm_id) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
void add (std::shared_ptr<DKDMBase> child, std::shared_ptr<DKDM> previous = std::shared_ptr<DKDM>());
void remove (std::shared_ptr<DKDMBase> child);
+ bool contains(std::string dkdm_id) const;
+
private:
std::string _name;
std::list<std::shared_ptr<DKDMBase>> _children;
dcp::DecryptedKDM dkdm(ekdm, chain->key().get());
auto new_dkdm = make_shared<DKDM>(ekdm);
+
+ if (Config::instance()->dkdms()->contains(new_dkdm->dkdm().id())) {
+ error_dialog(
+ this,
+ wxString::Format(_("DKDM %s is already in the DKDM list and will not be added again."), std_to_wx(new_dkdm->dkdm().id()))
+ );
+ return;
+ }
+
auto group = dynamic_pointer_cast<DKDMGroup> (selected_dkdm());
if (!group) {
group = Config::instance()->dkdms ();