From 21b0e4c0f2d6d65a6d8265d75c3cae4ee9757ba0 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Fri, 8 Jan 2021 09:08:02 +0100 Subject: [PATCH] Minor updates to view update. --- MacPass/MPTOTPSetupViewController.m | 25 +++++++++++++++++++++++-- MacPass/MPTOTPSetupViewController.xib | 6 +++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/MacPass/MPTOTPSetupViewController.m b/MacPass/MPTOTPSetupViewController.m index 0ce69fe2..c938eb64 100644 --- a/MacPass/MPTOTPSetupViewController.m +++ b/MacPass/MPTOTPSetupViewController.m @@ -23,6 +23,14 @@ @end +typedef NS_ENUM(NSUInteger, MPOTPUpdateSource) { + MPOTPUpdateSourceQRImage, + MPOTPUpdateSourceURL, + MPOTPUpdateSourceSecret, + MPOTPUpdateSourceAlgorithm, + MPOTPUpdateSourceTimeSlice +}; + @implementation MPTOTPSetupViewController - (void)viewDidLoad { @@ -30,10 +38,19 @@ NSAssert([self.representedObject isKindOfClass:KPKEntry.class], @"represented object needs to be a KPKEntry"); self.generator = [[KPKTimeOTPGenerator alloc] initWithEntry:((KPKEntry *)self.representedObject)]; - /**/ + /* URL and QR code */ KPKEntry *entry = self.representedObject; NSString *url = [entry attributeWithKey:kKPKAttributeKeyOTPOAuthURL].value; - self.urlTextField.stringValue = url ? url : @""; + + self.urlTextField.stringValue = @""; + + if(url) { + NSURL *authURL = [NSURL URLWithString:url]; + if(authURL.isTimeOTPURL) { + self.urlTextField.stringValue = authURL.absoluteString; + self.qrCodeImageView.image = [NSImage QRCodeImageWithString:authURL.absoluteString]; + } + } /* secret */ NSString *secret = [self.generator.key base32EncodedString]; @@ -83,4 +100,8 @@ self.urlTextField.stringValue = otpURL.absoluteString; } +- (void)_updateView:(MPOTPUpdateSource)source { + // TODO: implement update +} + @end diff --git a/MacPass/MPTOTPSetupViewController.xib b/MacPass/MPTOTPSetupViewController.xib index f5ca8e68..bc962917 100644 --- a/MacPass/MPTOTPSetupViewController.xib +++ b/MacPass/MPTOTPSetupViewController.xib @@ -20,7 +20,7 @@ - + @@ -64,13 +64,13 @@ - + - +