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 @@ - + - +