WIP on updating the UI correctly

This commit is contained in:
Michael Starke
2021-01-18 20:15:44 +01:00
parent 5652abfb1e
commit 7d5edd1c98
3 changed files with 37 additions and 17 deletions

View File

@@ -1,4 +1,4 @@
github "sparkle-project/Sparkle" ~> 1.22 github "sparkle-project/Sparkle" ~> 1.22
github "mattt/TransformerKit" ~> 1.1.1 github "mattt/TransformerKit" ~> 1.1.1
github "MacPass/KeePassKit" "76e6ecda942f9e328efde7883ad75aed7290b632" github "MacPass/KeePassKit" "2e4c2de06e704b2cf3670a6868e1dd7f938ab859"
github "mstarke/HNHUi" ~> 4.0 github "mstarke/HNHUi" ~> 4.0

View File

@@ -1,4 +1,4 @@
github "MacPass/KeePassKit" "76e6ecda942f9e328efde7883ad75aed7290b632" github "MacPass/KeePassKit" "2e4c2de06e704b2cf3670a6868e1dd7f938ab859"
github "mattt/TransformerKit" "1.1.1" github "mattt/TransformerKit" "1.1.1"
github "mstarke/HNHUi" "4.0.3" github "mstarke/HNHUi" "4.0.3"
github "robbiehanson/KissXML" "5.3.3" github "robbiehanson/KissXML" "5.3.3"

View File

@@ -21,7 +21,6 @@
@property (strong) IBOutlet NSGridView *gridView; @property (strong) IBOutlet NSGridView *gridView;
@property (strong) IBOutlet NSPopUpButton *typePopUpButton; @property (strong) IBOutlet NSPopUpButton *typePopUpButton;
@property (strong) KPKTimeOTPGenerator *generator;
@property NSInteger timeSlice; @property NSInteger timeSlice;
@end @end
@@ -101,17 +100,38 @@ typedef NS_ENUM(NSUInteger, MPOTPType) {
} }
- (void)_updateView:(MPOTPUpdateSource)source { - (void)_updateView:(MPOTPUpdateSource)source {
self.generator = [[KPKTimeOTPGenerator alloc] initWithAttributes:((KPKEntry *)self.representedObject).attributes]; /*
MPOTPUpdateSourceQRImage,
MPOTPUpdateSourceURL,
MPOTPUpdateSourceSecret,
MPOTPUpdateSourceAlgorithm,
MPOTPUpdateSourceTimeSlice,
MPOTPUpdateSourceEntry
if(source == MPOTPUpdateSourceQRImage) { */
KPKTimeOTPGenerator *generator = [[KPKTimeOTPGenerator alloc] initWithAttributes:((KPKEntry *)self.representedObject).attributes];
switch(source) {
case MPOTPUpdateSourceQRImage: {
NSString *qrCodeString = self.qrCodeImageView.image.QRCodeString; NSString *qrCodeString = self.qrCodeImageView.image.QRCodeString;
NSURL *otpURL = [NSURL URLWithString:qrCodeString]; NSURL *otpURL = [NSURL URLWithString:qrCodeString];
if(!otpURL.isTimeOTPURL) {
return; // no valid URL
}
self.urlTextField.stringValue = otpURL.absoluteString; self.urlTextField.stringValue = otpURL.absoluteString;
// fallthroug
}
case MPOTPUpdateSourceURL:
generator = [[KPKTimeOTPGenerator alloc] initWithURL:self.urlTextField.stringValue];
break;
case MPOTPUpdateSourceSecret:
break;
case MPOTPUpdateSourceAlgorithm:
break;
case MPOTPUpdateSourceTimeSlice:
break;
case MPOTPUpdateSourceEntry:
break;
default:
return;
} }
/* FIXME: update correct values based on changes */ /* FIXME: update correct values based on changes */
@@ -130,14 +150,14 @@ typedef NS_ENUM(NSUInteger, MPOTPType) {
} }
/* secret */ /* secret */
NSString *secret = [self.generator.key base32EncodedString]; NSString *secret = [generator.key base32EncodedString];
self.secretTextField.stringValue = secret ? secret : @""; self.secretTextField.stringValue = secret ? secret : @"";
[self.algorithmPopUpButton selectItemWithTag:self.generator.hashAlgorithm]; [self.algorithmPopUpButton selectItemWithTag:generator.hashAlgorithm];
[self.digitCountPopUpButton selectItemWithTag:self.generator.numberOfDigits]; [self.digitCountPopUpButton selectItemWithTag:generator.numberOfDigits];
self.timeSlice = self.generator.timeSlice; self.timeSlice = generator.timeSlice;
} }