Browse Source

make custom data private

remove-cryptography-dependency
Herbert Poul 5 years ago
parent
commit
f474b08593
  1. 16
      lib/src/kdbx_custom_data.dart

16
lib/src/kdbx_custom_data.dart

@ -5,11 +5,11 @@ import 'package:kdbx/src/internal/extension_utils.dart';
class KdbxCustomData extends KdbxNode { class KdbxCustomData extends KdbxNode {
KdbxCustomData.create() KdbxCustomData.create()
: data = {}, : _data = {},
super.create(TAG_NAME); super.create(TAG_NAME);
KdbxCustomData.read(xml.XmlElement node) KdbxCustomData.read(xml.XmlElement node)
: data = Map.fromEntries( : _data = Map.fromEntries(
node.findElements(KdbxXml.NODE_CUSTOM_DATA_ITEM).map((el) { node.findElements(KdbxXml.NODE_CUSTOM_DATA_ITEM).map((el) {
final key = el.singleTextNode(KdbxXml.NODE_KEY); final key = el.singleTextNode(KdbxXml.NODE_KEY);
final value = el.singleTextNode(KdbxXml.NODE_VALUE); final value = el.singleTextNode(KdbxXml.NODE_VALUE);
@ -19,14 +19,22 @@ class KdbxCustomData extends KdbxNode {
static const String TAG_NAME = 'CustomData'; static const String TAG_NAME = 'CustomData';
final Map<String, String> data; final Map<String, String> _data;
Iterable<MapEntry<String, String>> get entries => _data.entries;
String operator [](String key) => _data[key];
void operator []=(String key, String value) {
_data[key] = value;
isDirty = true;
}
@override @override
xml.XmlElement toXml() { xml.XmlElement toXml() {
final el = super.toXml(); final el = super.toXml();
el.children.clear(); el.children.clear();
el.children.addAll( el.children.addAll(
data.entries _data.entries
.map((e) => XmlUtils.createNode(KdbxXml.NODE_CUSTOM_DATA_ITEM, [ .map((e) => XmlUtils.createNode(KdbxXml.NODE_CUSTOM_DATA_ITEM, [
XmlUtils.createTextNode(KdbxXml.NODE_KEY, e.key), XmlUtils.createTextNode(KdbxXml.NODE_KEY, e.key),
XmlUtils.createTextNode(KdbxXml.NODE_VALUE, e.value), XmlUtils.createTextNode(KdbxXml.NODE_VALUE, e.value),

Loading…
Cancel
Save