|
|
@ -5,6 +5,10 @@ import 'package:kdbx/src/kdbx_xml.dart'; |
|
|
|
import 'package:quiver/iterables.dart'; |
|
|
|
import 'package:quiver/iterables.dart'; |
|
|
|
import 'package:xml/xml.dart'; |
|
|
|
import 'package:xml/xml.dart'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:logging/logging.dart'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final _logger = Logger('kdbx_times'); |
|
|
|
|
|
|
|
|
|
|
|
class KdbxTimes extends KdbxNode implements KdbxNodeContext { |
|
|
|
class KdbxTimes extends KdbxNode implements KdbxNodeContext { |
|
|
|
KdbxTimes.create(this.ctx) : super.create('Times') { |
|
|
|
KdbxTimes.create(this.ctx) : super.create('Times') { |
|
|
|
final now = clock.now().toUtc(); |
|
|
|
final now = clock.now().toUtc(); |
|
|
@ -16,15 +20,32 @@ class KdbxTimes extends KdbxNode implements KdbxNodeContext { |
|
|
|
usageCount.set(0); |
|
|
|
usageCount.set(0); |
|
|
|
locationChanged.set(now); |
|
|
|
locationChanged.set(now); |
|
|
|
} |
|
|
|
} |
|
|
|
KdbxTimes.read(XmlElement node, this.ctx) : super.read(node); |
|
|
|
KdbxTimes.read(XmlElement node, this.ctx) : super.read(node) { |
|
|
|
|
|
|
|
// backward compatibility - there was a bug setting/reading |
|
|
|
|
|
|
|
// modification, lastAccess and expiryTime. Make sure they are defined. |
|
|
|
|
|
|
|
final checkDates = { |
|
|
|
|
|
|
|
lastModificationTime: () => creationTime.get() ?? clock.now().toUtc(), |
|
|
|
|
|
|
|
lastAccessTime: () => lastModificationTime.get() ?? clock.now().toUtc(), |
|
|
|
|
|
|
|
expiryTime: () { |
|
|
|
|
|
|
|
expires.set(false); |
|
|
|
|
|
|
|
return clock.now().toUtc(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
for (final check in checkDates.entries) { |
|
|
|
|
|
|
|
if (check.key.get() == null) { |
|
|
|
|
|
|
|
final val = check.value(); |
|
|
|
|
|
|
|
_logger.warning('${check.key.name} was not defined. setting to $val'); |
|
|
|
|
|
|
|
check.key.set(val); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
final KdbxReadWriteContext ctx; |
|
|
|
final KdbxReadWriteContext ctx; |
|
|
|
|
|
|
|
|
|
|
|
DateTimeUtcNode get creationTime => DateTimeUtcNode(this, 'CreationTime'); |
|
|
|
DateTimeUtcNode get creationTime => DateTimeUtcNode(this, 'CreationTime'); |
|
|
|
DateTimeUtcNode get lastModificationTime => |
|
|
|
DateTimeUtcNode get lastModificationTime => |
|
|
|
DateTimeUtcNode(this, 'LastModificationTime', |
|
|
|
DateTimeUtcNode(this, 'LastModificationTime'); |
|
|
|
defaultValue: () => creationTime.get() ?? DateTimeUtcNode.minDate); |
|
|
|
|
|
|
|
DateTimeUtcNode get lastAccessTime => DateTimeUtcNode(this, 'LastAccessTime'); |
|
|
|
DateTimeUtcNode get lastAccessTime => DateTimeUtcNode(this, 'LastAccessTime'); |
|
|
|
DateTimeUtcNode get expiryTime => DateTimeUtcNode(this, 'ExpiryTime'); |
|
|
|
DateTimeUtcNode get expiryTime => DateTimeUtcNode(this, 'ExpiryTime'); |
|
|
|
BooleanNode get expires => BooleanNode(this, 'Expires'); |
|
|
|
BooleanNode get expires => BooleanNode(this, 'Expires'); |
|
|
|