2014-12-06 22:27:43 +01:00
|
|
|
//
|
|
|
|
// ScanIdentityBarcodeViewController.m
|
|
|
|
// Signal-iOS
|
|
|
|
//
|
|
|
|
// Created by Christine Corbett Moran on 3/29/14.
|
|
|
|
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
|
2016-08-19 01:47:21 +02:00
|
|
|
#import "ScanIdentityBarcodeViewController.h"
|
|
|
|
#import "NSData+Base64.h"
|
2014-12-06 22:27:43 +01:00
|
|
|
|
|
|
|
@implementation ScanIdentityBarcodeViewController
|
|
|
|
|
2016-08-19 01:47:21 +02:00
|
|
|
- (void)didDetectQRCodeWithString:(NSString *)string
|
|
|
|
{
|
|
|
|
NSData *data = [NSData dataFromBase64String:string];
|
|
|
|
NSString *dialogTitle;
|
|
|
|
NSString *dialogDescription;
|
2015-12-22 12:45:09 +01:00
|
|
|
|
2016-08-19 01:47:21 +02:00
|
|
|
if ([data isEqualToData:self.identityKey]) {
|
|
|
|
dialogTitle = NSLocalizedString(@"SCAN_KEY_VERIFIED_TITLE", @"");
|
|
|
|
dialogDescription = NSLocalizedString(@"SCAN_KEY_VERIFIED_TEXT", @"");
|
2014-12-06 22:27:43 +01:00
|
|
|
} else {
|
2016-08-19 01:47:21 +02:00
|
|
|
dialogTitle = NSLocalizedString(@"SCAN_KEY_CONFLICT_TITLE", @"");
|
|
|
|
dialogDescription = NSLocalizedString(@"SCAN_KEY_CONFLICT_TEXT", @"");
|
2014-12-06 22:27:43 +01:00
|
|
|
}
|
|
|
|
|
2016-08-19 01:47:21 +02:00
|
|
|
UIAlertController *controller = [UIAlertController alertControllerWithTitle:dialogTitle
|
|
|
|
message:dialogDescription
|
|
|
|
preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
[self
|
|
|
|
presentViewController:controller
|
|
|
|
animated:YES
|
|
|
|
completion:^{
|
|
|
|
[self performSelector:@selector(dismissScannerAfterSuccesfullScan) withObject:nil afterDelay:5];
|
|
|
|
}];
|
2014-12-06 22:27:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Action
|
2015-02-17 00:14:50 +01:00
|
|
|
|
|
|
|
- (void)dismissScannerAfterSuccesfullScan {
|
2015-12-22 12:45:09 +01:00
|
|
|
[self dismissViewControllerAnimated:YES
|
|
|
|
completion:^{
|
2016-08-19 01:47:21 +02:00
|
|
|
[self closeButtonAction:nil];
|
2015-12-22 12:45:09 +01:00
|
|
|
}];
|
2014-12-06 22:27:43 +01:00
|
|
|
}
|
|
|
|
|
2015-12-22 12:45:09 +01:00
|
|
|
- (IBAction)closeButtonAction:(id)sender {
|
2015-02-17 00:14:50 +01:00
|
|
|
[self performSegueWithIdentifier:@"UnwindToIdentityKeyWasVerifiedSegue" sender:self];
|
|
|
|
}
|
2014-12-06 22:27:43 +01:00
|
|
|
|
|
|
|
@end
|