diff --git a/Makefile b/Makefile index e59ad1dc2..5bc1f29b8 100644 --- a/Makefile +++ b/Makefile @@ -8,19 +8,19 @@ WORKING_DIR = ./ SCHEME = Signal XCODE_BUILD = xcrun xcodebuild -workspace $(SCHEME).xcworkspace -scheme $(SCHEME) -sdk iphonesimulator -.PHONY: build test retest clean +.PHONY: build test retest clean dependencies default: test -ci: build_dependencies test +ci: dependencies test -build_dependencies: +dependencies: cd $(WORKING_DIR) && \ git submodule update --init pod install carthage build --platform iOS -build: build_dependencies +build: dependencies cd $(WORKING_DIR) && \ $(XCODE_BUILD) build | xcpretty @@ -32,6 +32,7 @@ test: optional_early_start_simulator clean: cd $(WORKING_DIR) && \ + rm -fr Carthage/Build && \ $(XCODE_BUILD) \ clean | xcpretty diff --git a/Podfile.lock b/Podfile.lock index 44d7ce478..31cbe87f0 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -44,7 +44,7 @@ PODS: - Reachability (3.2) - SAMKeychain (1.5.2) - SCWaveformView (1.0.0) - - SignalServiceKit (0.4.0): + - SignalServiceKit (0.5.0): - '25519' - AFNetworking - AxolotlKit @@ -140,7 +140,7 @@ CHECKOUT OPTIONS: :commit: 03cde781234ade464dd26914d87e6e95afde1119 :git: https://github.com/WhisperSystems/JSQMessagesViewController.git SignalServiceKit: - :commit: 47cad611e5a14127200747667b7ed9f50e8337ce + :commit: b4c504f61d4f7bbb01133d36b0cb97109ac13b5c :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :commit: 41b57bb2fc292a814f758441a05243eb38457027 @@ -164,7 +164,7 @@ SPEC CHECKSUMS: Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 SAMKeychain: 1865333198217411f35327e8da61b43de79b635b SCWaveformView: 52a96750255d817e300565a80c81fb643e233e07 - SignalServiceKit: 5c3877241082a778c8c130e1fed17d0904085205 + SignalServiceKit: ffb1542582ffe075809bc9c2092100083f22a31d SocketRocket: dbb1554b8fc288ef8ef370d6285aeca7361be31e SQLCipher: 4c768761421736a247ed6cf412d9045615d53dff TwistedOakCollapsingFutures: f359b90f203e9ab13dfb92c9ff41842a7fe1cd0c diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 07318fd74..bfa2608a3 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -61,6 +61,8 @@ 45CD81A61DBFF8FC004C9430 /* Registration.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 45CD81A51DBFF8FC004C9430 /* Registration.storyboard */; }; 45CD81EF1DC030E7004C9430 /* AccountManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CD81EE1DC030E7004C9430 /* AccountManager.swift */; }; 45CD81F21DC03A22004C9430 /* OWSLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 45CD81F11DC03A22004C9430 /* OWSLogger.m */; }; + 45D231771DC7E8F10034FA89 /* SessionResetJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D231761DC7E8F10034FA89 /* SessionResetJob.swift */; }; + 45D231781DC7E8F10034FA89 /* SessionResetJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D231761DC7E8F10034FA89 /* SessionResetJob.swift */; }; 45EB32CF1D7465C900735B2E /* OWSLinkedDevicesTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 45EB32CE1D7465C900735B2E /* OWSLinkedDevicesTableViewController.m */; }; 45F2B1941D9C9F48000D2C69 /* OWSOutgoingMessageCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 45F2B1931D9C9F48000D2C69 /* OWSOutgoingMessageCollectionViewCell.m */; }; 45F2B1971D9CA207000D2C69 /* OWSIncomingMessageCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 45F2B1951D9CA207000D2C69 /* OWSIncomingMessageCollectionViewCell.xib */; }; @@ -542,7 +544,7 @@ 450873C61D9D867B006B54F2 /* OWSIncomingMessageCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSIncomingMessageCollectionViewCell.m; sourceTree = ""; }; 450873C91D9D86F4006B54F2 /* OWSExpirableMessageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSExpirableMessageView.h; sourceTree = ""; }; 451DE9F11DC1585F00810E42 /* PromiseKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PromiseKit.framework; path = Carthage/Build/iOS/PromiseKit.framework; sourceTree = ""; }; - 451DE9FC1DC1A28200810E42 /* SyncPushTokensJob.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SyncPushTokensJob.swift; sourceTree = ""; }; + 451DE9FC1DC1A28200810E42 /* SyncPushTokensJob.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SyncPushTokensJob.swift; path = Models/SyncPushTokensJob.swift; sourceTree = ""; }; 4520D8D41D417D8E00123472 /* Photos.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Photos.framework; path = System/Library/Frameworks/Photos.framework; sourceTree = SDKROOT; }; 4526BD481CA61C8D00166BC8 /* OWSMessageEditing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSMessageEditing.h; sourceTree = ""; }; 452D1EE71DCA90D100A57EC4 /* MesssagesBubblesSizeCalculatorTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MesssagesBubblesSizeCalculatorTest.swift; path = Models/MesssagesBubblesSizeCalculatorTest.swift; sourceTree = ""; }; @@ -604,6 +606,7 @@ 45CD81EE1DC030E7004C9430 /* AccountManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountManager.swift; sourceTree = ""; }; 45CD81F01DC03A22004C9430 /* OWSLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSLogger.h; sourceTree = ""; }; 45CD81F11DC03A22004C9430 /* OWSLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSLogger.m; sourceTree = ""; }; + 45D231761DC7E8F10034FA89 /* SessionResetJob.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SessionResetJob.swift; path = Jobs/SessionResetJob.swift; sourceTree = ""; }; 45E282DE1D08E67800ADD4C8 /* gl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = gl; path = translations/gl.lproj/Localizable.strings; sourceTree = ""; }; 45E282DF1D08E6CC00ADD4C8 /* id */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = id; path = translations/id.lproj/Localizable.strings; sourceTree = ""; }; 45EB32CD1D7465C900735B2E /* OWSLinkedDevicesTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSLinkedDevicesTableViewController.h; sourceTree = ""; }; @@ -1218,7 +1221,6 @@ 45666EC71D994C0D008FE134 /* OWSGroupAvatarBuilder.h */, 45666EC81D994C0D008FE134 /* OWSGroupAvatarBuilder.m */, 45CD81EE1DC030E7004C9430 /* AccountManager.swift */, - 451DE9FC1DC1A28200810E42 /* SyncPushTokensJob.swift */, ); path = Models; sourceTree = ""; @@ -1260,6 +1262,15 @@ name = Storyboards; sourceTree = ""; }; + 45D231751DC7E8C50034FA89 /* Jobs */ = { + isa = PBXGroup; + children = ( + 451DE9FC1DC1A28200810E42 /* SyncPushTokensJob.swift */, + 45D231761DC7E8F10034FA89 /* SessionResetJob.swift */, + ); + name = Jobs; + sourceTree = ""; + }; 70B8009F190C529C0042E3F0 /* Products */ = { isa = PBXGroup; children = ( @@ -1308,6 +1319,7 @@ 76EB04B118170B33006006FC /* profiling */, B60959791C2C0FA9004E8797 /* rating */, 76EB04C818170B33006006FC /* util */, + 45D231751DC7E8C50034FA89 /* Jobs */, 457F3AC01D14A0F700C51351 /* Models */, 76EB052B18170B33006006FC /* Views */, 76EB04FE18170B33006006FC /* View Controllers */, @@ -2830,6 +2842,7 @@ 76EB05BC18170B33006006FC /* ConfirmAckPacket.m in Sources */, 76EB060C18170B33006006FC /* CategorizingLogger.m in Sources */, 76EB058A18170B33006006FC /* Release.m in Sources */, + 45D231771DC7E8F10034FA89 /* SessionResetJob.swift in Sources */, 76EB061018170B33006006FC /* EventWindow.m in Sources */, E197B62718BBF63B00F073E5 /* SoundBoard.m in Sources */, 450873C71D9D867B006B54F2 /* OWSIncomingMessageCollectionViewCell.m in Sources */, @@ -3027,6 +3040,7 @@ B660F7221C29988E00687D6E /* VersionMigrations.m in Sources */, B660F7231C29988E00687D6E /* DnsManager.m in Sources */, B660F7241C29988E00687D6E /* HostNameEndPoint.m in Sources */, + 45D231781DC7E8F10034FA89 /* SessionResetJob.swift in Sources */, B660F7251C29988E00687D6E /* IgnoredPacketFailure.m in Sources */, 458967111DC117CC00E9DD21 /* AccountManagerTest.swift in Sources */, B660F7261C29988E00687D6E /* UnrecognizedRequestFailure.m in Sources */, diff --git a/Signal/src/Jobs/SessionResetJob.swift b/Signal/src/Jobs/SessionResetJob.swift new file mode 100644 index 000000000..09c701fab --- /dev/null +++ b/Signal/src/Jobs/SessionResetJob.swift @@ -0,0 +1,55 @@ +// Created by Michael Kirk on 10/31/16. +// Copyright © 2016 Open Whisper Systems. All rights reserved. + +import Foundation +import PromiseKit + +@objc(OWSSessionResetJob) +class SessionResetJob: NSObject { + + let TAG = "SessionResetJob" + + let recipientId: String + let thread: TSThread + let storageManager: TSStorageManager + let messageSender: MessageSender + + required init(recipientId: String, thread: TSThread, messageSender: MessageSender, storageManager: TSStorageManager) { + self.thread = thread + self.recipientId = recipientId + self.messageSender = messageSender + self.storageManager = storageManager + } + + func run() { + Logger.info("\(TAG) Local user reset session.") + + let endSessionMessage = EndSessionMessage(timestamp:NSDate.ows_millisecondTimeStamp(), in: thread) + self.messageSender.send(endSessionMessage, success: { + Logger.info("\(self.TAG) successfully sent EndSession +#import #import +#import #import +#import +#import +#import +#import +#import #import +#import diff --git a/Signal/src/environment/Environment.h b/Signal/src/environment/Environment.h index 53f1ee236..23d63d73a 100644 --- a/Signal/src/environment/Environment.h +++ b/Signal/src/environment/Environment.h @@ -31,6 +31,7 @@ static NSString *const kCallSegue = @"2.0_6.0_Call_Segue"; @class TSGroupThread; @class ContactsUpdater; @class TSNetworkManager; +@class OWSMessageSender; @interface Environment : NSObject @@ -49,7 +50,8 @@ static NSString *const kCallSegue = @"2.0_6.0_Call_Segue"; zrtpVersionId:(NSData *)zrtpVersionId contactsManager:(OWSContactsManager *)contactsManager contactsUpdater:(ContactsUpdater *)contactsUpdater - networkManager:(TSNetworkManager *)networkManager; + networkManager:(TSNetworkManager *)networkManager + messageSender:(OWSMessageSender *)messageSender; @property (nonatomic, readonly) in_port_t serverPort; @property (nonatomic, readonly) id logging; @@ -67,6 +69,7 @@ static NSString *const kCallSegue = @"2.0_6.0_Call_Segue"; @property (nonatomic, readonly) OWSContactsManager *contactsManager; @property (nonatomic, readonly) ContactsUpdater *contactsUpdater; @property (nonatomic, readonly) TSNetworkManager *networkManager; +@property (nonatomic, readonly) OWSMessageSender *messageSender; @property (nonatomic, readonly) SignalsViewController *signalsViewController; @property (nonatomic, readonly, weak) UINavigationController *signUpFlowNavigationController; diff --git a/Signal/src/environment/Environment.m b/Signal/src/environment/Environment.m index e681d24c1..897696799 100644 --- a/Signal/src/environment/Environment.m +++ b/Signal/src/environment/Environment.m @@ -67,6 +67,7 @@ static Environment *environment = nil; contactsManager:(OWSContactsManager *)contactsManager contactsUpdater:(ContactsUpdater *)contactsUpdater networkManager:(TSNetworkManager *)networkManager + messageSender:(OWSMessageSender *)messageSender { ows_require(errorNoter != nil); ows_require(zrtpClientId != nil); @@ -105,6 +106,7 @@ static Environment *environment = nil; _zrtpVersionId = zrtpVersionId; _contactsManager = contactsManager; _networkManager = networkManager; + _messageSender = messageSender; if (recentCallManager != nil) { // recentCallManagers are nil in unit tests because they would require unnecessary allocations. Detailed diff --git a/Signal/src/environment/Release.m b/Signal/src/environment/Release.m index e43cc5df7..3c25491ba 100644 --- a/Signal/src/environment/Release.m +++ b/Signal/src/environment/Release.m @@ -4,6 +4,7 @@ #import "PhoneNumberUtil.h" #import "RecentCallManager.h" #import +#import #import #define RELEASE_ZRTP_CLIENT_ID @"Whisper 000 ".encodedAsAscii @@ -44,6 +45,13 @@ static unsigned char DH3K_PRIME[] = { DDLogError(@"%@: %@, %d", error, relatedInfo, causedTermination); }; + TSNetworkManager *networkManager = [TSNetworkManager sharedManager]; + OWSContactsManager *contactsManager = [OWSContactsManager new]; + ContactsUpdater *contactsUpdater = [ContactsUpdater sharedUpdater]; + OWSMessageSender *messageSender = [[OWSMessageSender alloc] initWithNetworkManager:networkManager + storageManager:[TSStorageManager sharedManager] + contactsManager:contactsManager + contactsUpdater:contactsUpdater]; return [[Environment alloc] initWithLogging:logging errorNoter:errorNoter serverPort:31337 @@ -57,9 +65,10 @@ static unsigned char DH3K_PRIME[] = { testingAndLegacyOptions:@[ ENVIRONMENT_LEGACY_OPTION_RTP_PADDING_BIT_IMPLIES_EXTENSION_BIT_AND_TWELVE_EXTRA_ZERO_BYTES_IN_HEADER ] zrtpClientId:RELEASE_ZRTP_CLIENT_ID zrtpVersionId:RELEASE_ZRTP_VERSION_ID - contactsManager:[OWSContactsManager new] - contactsUpdater:[ContactsUpdater sharedUpdater] - networkManager:[TSNetworkManager sharedManager]]; + contactsManager:contactsManager + contactsUpdater:contactsUpdater + networkManager:networkManager + messageSender:messageSender]; } + (Environment *)stagingEnvironmentWithLogging:(id)logging { @@ -67,6 +76,13 @@ static unsigned char DH3K_PRIME[] = { DDLogError(@"%@: %@, %d", error, relatedInfo, causedTermination); }; + TSNetworkManager *networkManager = [TSNetworkManager sharedManager]; + OWSContactsManager *contactsManager = [OWSContactsManager new]; + ContactsUpdater *contactsUpdater = [ContactsUpdater sharedUpdater]; + OWSMessageSender *messageSender = [[OWSMessageSender alloc] initWithNetworkManager:networkManager + storageManager:[TSStorageManager sharedManager] + contactsManager:contactsManager + contactsUpdater:contactsUpdater]; return [[Environment alloc] initWithLogging:logging errorNoter:errorNoter serverPort:31337 @@ -80,9 +96,10 @@ static unsigned char DH3K_PRIME[] = { testingAndLegacyOptions:@[ ENVIRONMENT_LEGACY_OPTION_RTP_PADDING_BIT_IMPLIES_EXTENSION_BIT_AND_TWELVE_EXTRA_ZERO_BYTES_IN_HEADER ] zrtpClientId:RELEASE_ZRTP_CLIENT_ID zrtpVersionId:RELEASE_ZRTP_VERSION_ID - contactsManager:[OWSContactsManager new] - contactsUpdater:[ContactsUpdater sharedUpdater] - networkManager:[TSNetworkManager sharedManager]]; + contactsManager:contactsManager + contactsUpdater:contactsUpdater + networkManager:networkManager + messageSender:messageSender]; } + (Environment *)unitTestEnvironment:(NSArray *)testingAndLegacyOptions { @@ -91,6 +108,14 @@ static unsigned char DH3K_PRIME[] = { keyAgreementProtocols = @[ [Release supportedDH3KKeyAgreementProtocol] ]; } + TSNetworkManager *networkManager = [TSNetworkManager sharedManager]; + OWSContactsManager *contactsManager = [OWSContactsManager new]; + ContactsUpdater *contactsUpdater = [ContactsUpdater sharedUpdater]; + OWSMessageSender *messageSender = [[OWSMessageSender alloc] initWithNetworkManager:networkManager + storageManager:[TSStorageManager sharedManager] + contactsManager:contactsManager + contactsUpdater:contactsUpdater]; + return [[Environment alloc] initWithLogging:[DiscardingLog discardingLog] errorNoter:^(id error, id relatedInfo, bool causedTermination) { } @@ -106,8 +131,9 @@ static unsigned char DH3K_PRIME[] = { zrtpClientId:TESTING_ZRTP_CLIENT_ID zrtpVersionId:TESTING_ZRTP_VERSION_ID contactsManager:nil - contactsUpdater:[ContactsUpdater sharedUpdater] - networkManager:[TSNetworkManager sharedManager]]; + contactsUpdater:contactsUpdater + networkManager:networkManager + messageSender:messageSender]; } + (NSArray *)supportedKeyAgreementProtocols { diff --git a/Signal/src/view controllers/CodeVerificationViewController.m b/Signal/src/view controllers/CodeVerificationViewController.m index 3f04a7e0d..5de09028b 100644 --- a/Signal/src/view controllers/CodeVerificationViewController.m +++ b/Signal/src/view controllers/CodeVerificationViewController.m @@ -58,19 +58,19 @@ NSString *const kCompletedRegistrationSegue = @"CompletedRegistration"; - (void)viewDidLoad { [super viewDidLoad]; [self initializeKeyboardHandlers]; - _headerLabel.text = NSLocalizedString(@"VERIFICATION_HEADER", @""); - _challengeTextField.placeholder = NSLocalizedString(@"VERIFICATION_CHALLENGE_DEFAULT_TEXT", @""); + _headerLabel.text = NSLocalizedString(@"VERIFICATION_HEADER", @"Navigation title in the registration flow - during the sms code verification process."); + _challengeTextField.placeholder = NSLocalizedString(@"VERIFICATION_CHALLENGE_DEFAULT_TEXT", @"Text field placeholder for SMS verification code during registartion"); _challengeTextField.delegate = self; - [_challengeButton setTitle:NSLocalizedString(@"VERIFICATION_CHALLENGE_SUBMIT_CODE", @"") + [_challengeButton setTitle:NSLocalizedString(@"VERIFICATION_CHALLENGE_SUBMIT_CODE", @"button text during registration to submit your SMS verification code") forState:UIControlStateNormal]; - [_sendCodeViaSMSAgainButton setTitle:NSLocalizedString(@"VERIFICATION_CHALLENGE_SUBMIT_AGAIN", @"") + [_sendCodeViaSMSAgainButton setTitle:NSLocalizedString(@"VERIFICATION_CHALLENGE_SUBMIT_AGAIN", @"button text during registration to request another SMS code be sent") forState:UIControlStateNormal]; [_sendCodeViaVoiceButton - setTitle:[@" " stringByAppendingString:NSLocalizedString(@"VERIFICATION_CHALLENGE_SEND_VIAVOICE", @"")] + setTitle:[@" " stringByAppendingString:NSLocalizedString(@"VERIFICATION_CHALLENGE_SEND_VIAVOICE", @"button text during registration to request phone number verification be done via phone call")] forState:UIControlStateNormal]; [_changeNumberButton - setTitle:[@" " stringByAppendingString:NSLocalizedString(@"VERIFICATION_CHALLENGE_CHANGE_NUMBER", @"")] + setTitle:[@" " stringByAppendingString:NSLocalizedString(@"VERIFICATION_CHALLENGE_CHANGE_NUMBER", @"button text during registration to make corrections to your submitted phone number")] forState:UIControlStateNormal]; } diff --git a/Signal/src/view controllers/FingerprintViewController.m b/Signal/src/view controllers/FingerprintViewController.m index bd8f43d3e..a35bd9e8f 100644 --- a/Signal/src/view controllers/FingerprintViewController.m +++ b/Signal/src/view controllers/FingerprintViewController.m @@ -8,6 +8,7 @@ #import "FingerprintViewController.h" #import "DJWActionSheet+OWS.h" +#import "Environment.h" #import "OWSConversationSettingsTableViewController.h" #import "Signal-Swift.h" #import @@ -23,7 +24,6 @@ NS_ASSUME_NONNULL_BEGIN @interface FingerprintViewController () @property (strong, nonatomic) TSStorageManager *storageManager; -@property (nonatomic) BOOL isPresentingDialog; @property (strong, nonatomic) TSThread *thread; @property (strong, nonatomic) OWSFingerprint *fingerprint; @property (strong, nonatomic) NSString *contactName; @@ -92,12 +92,6 @@ NS_ASSUME_NONNULL_BEGIN // Don't antialias QRCode self.privacyVerificationQRCode.layer.magnificationFilter = kCAFilterNearest; - - // Add session reset action. - UILongPressGestureRecognizer *longpressToResetSession = - [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(didLongpressToResetSession:)]; - longpressToResetSession.minimumPressDuration = 1.0; - [self.view addGestureRecognizer:longpressToResetSession]; } - (void)viewDidLayoutSubviews @@ -141,34 +135,6 @@ NS_ASSUME_NONNULL_BEGIN [self showScanner]; } -- (IBAction)didLongpressToResetSession:(id)sender -{ - if (!_isPresentingDialog) { - _isPresentingDialog = YES; - [DJWActionSheet showInView:self.view - withTitle:NSLocalizedString(@"FINGERPRINT_SHRED_KEYMATERIAL_CONFIRMATION", @"") - cancelButtonTitle:NSLocalizedString(@"TXT_CANCEL_TITLE", @"") - destructiveButtonTitle:nil - otherButtonTitles:@[ NSLocalizedString(@"FINGERPRINT_SHRED_KEYMATERIAL_BUTTON", @"") ] - tapBlock:^(DJWActionSheet *actionSheet, NSInteger tappedButtonIndex) { - _isPresentingDialog = NO; - if (tappedButtonIndex == actionSheet.cancelButtonIndex) { - DDLogDebug(@"User Cancelled"); - } else if (tappedButtonIndex == actionSheet.destructiveButtonIndex) { - DDLogDebug(@"Destructive button tapped"); - } else { - switch (tappedButtonIndex) { - case 0: - [self resetSession]; - break; - default: - break; - } - } - }]; - } -} - - (void)showScanner { DDLogInfo(@"%@ Showing Scanner", self.tag); @@ -187,19 +153,6 @@ NS_ASSUME_NONNULL_BEGIN [self.qrScanningController startCapture]; } -- (void)resetSession -{ - DDLogInfo(@"%@ local user reset session", self.tag); - [self.storageManager removeIdentityKeyForRecipient:self.fingerprint.theirStableId]; - [self.storageManager deleteAllSessionsForContact:self.fingerprint.theirStableId]; - - [[[TSInfoMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] - inThread:self.thread - messageType:TSInfoMessageTypeSessionDidEnd] save]; - - [self dismissViewControllerAnimated:YES completion:nil]; -} - // pragma mark - OWSQRScannerDelegate - (void)controller:(OWSQRCodeScanningViewController *)controller didDetectQRCodeWithData:(NSData *)data; { diff --git a/Signal/src/view controllers/MessagesViewController.m b/Signal/src/view controllers/MessagesViewController.m index d81605f04..c6049ca2d 100644 --- a/Signal/src/view controllers/MessagesViewController.m +++ b/Signal/src/view controllers/MessagesViewController.m @@ -27,6 +27,7 @@ #import "OWSOutgoingMessageCollectionViewCell.h" #import "PhoneManager.h" #import "PropertyListPreferences.h" +#import "Signal-Swift.h" #import "SignalKeyingStorage.h" #import "TSAttachmentPointer.h" #import "TSCall.h" @@ -117,13 +118,13 @@ typedef enum : NSUInteger { @property (nonatomic) BOOL composeOnOpen; @property (nonatomic) BOOL peek; -@property (nonatomic, readonly) TSStorageManager *storageManager; @property (nonatomic, readonly) OWSContactsManager *contactsManager; @property (nonatomic, readonly) ContactsUpdater *contactsUpdater; +@property (nonatomic, readonly) OWSMessageSender *messageSender; +@property (nonatomic, readonly) TSStorageManager *storageManager; @property (nonatomic, readonly) OWSDisappearingMessagesJob *disappearingMessagesJob; @property (nonatomic, readonly) TSMessagesManager *messagesManager; @property (nonatomic, readonly) TSNetworkManager *networkManager; -@property (nonatomic, readonly) OWSMessageSender *messageSender; @property NSCache *messageAdapterCache; @@ -143,16 +144,7 @@ typedef enum : NSUInteger { return self; } - _contactsManager = [Environment getCurrent].contactsManager; - _contactsUpdater = [Environment getCurrent].contactsUpdater; - _storageManager = [TSStorageManager sharedManager]; - _disappearingMessagesJob = [[OWSDisappearingMessagesJob alloc] initWithStorageManager:_storageManager]; - _messagesManager = [TSMessagesManager sharedManager]; - _networkManager = [TSNetworkManager sharedManager]; - _messageSender = [[OWSMessageSender alloc] initWithNetworkManager:_networkManager - storageManager:_storageManager - contactsManager:_contactsManager - contactsUpdater:_contactsUpdater]; + [self commonInit]; return self; } @@ -164,18 +156,20 @@ typedef enum : NSUInteger { return self; } + [self commonInit]; + + return self; +} + +- (void)commonInit +{ _contactsManager = [Environment getCurrent].contactsManager; _contactsUpdater = [Environment getCurrent].contactsUpdater; + _messageSender = [Environment getCurrent].messageSender; _storageManager = [TSStorageManager sharedManager]; _disappearingMessagesJob = [[OWSDisappearingMessagesJob alloc] initWithStorageManager:_storageManager]; _messagesManager = [TSMessagesManager sharedManager]; _networkManager = [TSNetworkManager sharedManager]; - _messageSender = [[OWSMessageSender alloc] initWithNetworkManager:_networkManager - storageManager:_storageManager - contactsManager:_contactsManager - contactsUpdater:_contactsUpdater]; - - return self; } - (void)peekSetup { @@ -1430,9 +1424,53 @@ typedef enum : NSUInteger { { if ([message isKindOfClass:[TSInvalidIdentityKeyErrorMessage class]]) { [self tappedInvalidIdentityKeyErrorMessage:(TSInvalidIdentityKeyErrorMessage *)message]; + } else if (message.errorType == TSErrorMessageInvalidMessage) { + [self tappedCorruptedMessage:message]; + } else { + DDLogWarn(@"%@ Unhandled tap for error message:%@", self.tag, message); } } +- (void)tappedCorruptedMessage:(TSErrorMessage *)message +{ + + NSString *actionSheetTitle = [NSString + stringWithFormat:NSLocalizedString(@"CORRUPTED_SESSION_DESCRIPTION", @"ActionSheet title"), self.thread.name]; + + [DJWActionSheet showInView:self.view + withTitle:actionSheetTitle + cancelButtonTitle:NSLocalizedString(@"TXT_CANCEL_TITLE", @"") + destructiveButtonTitle:nil + otherButtonTitles:@[ NSLocalizedString(@"FINGERPRINT_SHRED_KEYMATERIAL_BUTTON", nil) ] + tapBlock:^(DJWActionSheet *actionSheet, NSInteger tappedButtonIndex) { + if (tappedButtonIndex == actionSheet.cancelButtonIndex) { + DDLogDebug(@"User Cancelled"); + } else if (tappedButtonIndex == actionSheet.destructiveButtonIndex) { + DDLogDebug(@"Destructive button tapped"); + } else { + switch (tappedButtonIndex) { + case 0: { + if (![self.thread isKindOfClass:[TSContactThread class]]) { + // Corrupt Message errors only appear in contact threads. + DDLogError( + @"%@ Unexpected request to reset session in group thread. Refusing", + self.tag); + return; + } + TSContactThread *contactThread = (TSContactThread *)self.thread; + [OWSSessionResetJob runWithCorruptedMessage:message + contactThread:contactThread + messageSender:self.messageSender + storageManager:self.storageManager]; + break; + } + default: + break; + } + } + }]; +} + - (void)tappedInvalidIdentityKeyErrorMessage:(TSInvalidIdentityKeyErrorMessage *)errorMessage { NSString *keyOwner = [self.contactsManager nameStringForPhoneIdentifier:errorMessage.theirSignalId]; diff --git a/Signal/translations/ar.lproj/Localizable.strings b/Signal/translations/ar.lproj/Localizable.strings index 108a72929..d0318aa98 100644 Binary files a/Signal/translations/ar.lproj/Localizable.strings and b/Signal/translations/ar.lproj/Localizable.strings differ diff --git a/Signal/translations/az_AZ.lproj/Localizable.strings b/Signal/translations/az_AZ.lproj/Localizable.strings index 1e9e5bb41..326862ccf 100644 Binary files a/Signal/translations/az_AZ.lproj/Localizable.strings and b/Signal/translations/az_AZ.lproj/Localizable.strings differ diff --git a/Signal/translations/bg.lproj/Localizable.strings b/Signal/translations/bg.lproj/Localizable.strings index 01b14caab..416391da5 100644 Binary files a/Signal/translations/bg.lproj/Localizable.strings and b/Signal/translations/bg.lproj/Localizable.strings differ diff --git a/Signal/translations/bs.lproj/Localizable.strings b/Signal/translations/bs.lproj/Localizable.strings index 75e434489..6c99fa936 100644 Binary files a/Signal/translations/bs.lproj/Localizable.strings and b/Signal/translations/bs.lproj/Localizable.strings differ diff --git a/Signal/translations/ca.lproj/Localizable.strings b/Signal/translations/ca.lproj/Localizable.strings index 55dc6bc8e..b137f5de0 100644 Binary files a/Signal/translations/ca.lproj/Localizable.strings and b/Signal/translations/ca.lproj/Localizable.strings differ diff --git a/Signal/translations/cs.lproj/Localizable.strings b/Signal/translations/cs.lproj/Localizable.strings index b43266114..ba3e6a72a 100644 Binary files a/Signal/translations/cs.lproj/Localizable.strings and b/Signal/translations/cs.lproj/Localizable.strings differ diff --git a/Signal/translations/da.lproj/Localizable.strings b/Signal/translations/da.lproj/Localizable.strings index 6d5dd3f34..15ecd9b92 100644 Binary files a/Signal/translations/da.lproj/Localizable.strings and b/Signal/translations/da.lproj/Localizable.strings differ diff --git a/Signal/translations/de.lproj/Localizable.strings b/Signal/translations/de.lproj/Localizable.strings index 821a9be9d..d3c2af146 100644 Binary files a/Signal/translations/de.lproj/Localizable.strings and b/Signal/translations/de.lproj/Localizable.strings differ diff --git a/Signal/translations/el_GR.lproj/Localizable.strings b/Signal/translations/el_GR.lproj/Localizable.strings index 791ec6b19..3a63057d7 100644 Binary files a/Signal/translations/el_GR.lproj/Localizable.strings and b/Signal/translations/el_GR.lproj/Localizable.strings differ diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index a87f1e56b..803eea0f7 100644 Binary files a/Signal/translations/en.lproj/Localizable.strings and b/Signal/translations/en.lproj/Localizable.strings differ diff --git a/Signal/translations/es.lproj/Localizable.strings b/Signal/translations/es.lproj/Localizable.strings index 7c21425e4..a03f04d03 100644 Binary files a/Signal/translations/es.lproj/Localizable.strings and b/Signal/translations/es.lproj/Localizable.strings differ diff --git a/Signal/translations/fa.lproj/Localizable.strings b/Signal/translations/fa.lproj/Localizable.strings index 84dfd07a7..a9b808055 100644 Binary files a/Signal/translations/fa.lproj/Localizable.strings and b/Signal/translations/fa.lproj/Localizable.strings differ diff --git a/Signal/translations/fi.lproj/Localizable.strings b/Signal/translations/fi.lproj/Localizable.strings index 9d1a6580b..aeb8826a8 100644 Binary files a/Signal/translations/fi.lproj/Localizable.strings and b/Signal/translations/fi.lproj/Localizable.strings differ diff --git a/Signal/translations/fil.lproj/Localizable.strings b/Signal/translations/fil.lproj/Localizable.strings index 429f75c25..a585f49be 100644 Binary files a/Signal/translations/fil.lproj/Localizable.strings and b/Signal/translations/fil.lproj/Localizable.strings differ diff --git a/Signal/translations/fr.lproj/Localizable.strings b/Signal/translations/fr.lproj/Localizable.strings index 6247896ae..aef4c71a4 100644 Binary files a/Signal/translations/fr.lproj/Localizable.strings and b/Signal/translations/fr.lproj/Localizable.strings differ diff --git a/Signal/translations/gl.lproj/Localizable.strings b/Signal/translations/gl.lproj/Localizable.strings index 3bddb5fdd..8981fb8d3 100644 Binary files a/Signal/translations/gl.lproj/Localizable.strings and b/Signal/translations/gl.lproj/Localizable.strings differ diff --git a/Signal/translations/he.lproj/Localizable.strings b/Signal/translations/he.lproj/Localizable.strings index f97bfd1fe..9de5ba7c6 100644 Binary files a/Signal/translations/he.lproj/Localizable.strings and b/Signal/translations/he.lproj/Localizable.strings differ diff --git a/Signal/translations/hr.lproj/Localizable.strings b/Signal/translations/hr.lproj/Localizable.strings index a8eb2a44a..0c504337b 100644 Binary files a/Signal/translations/hr.lproj/Localizable.strings and b/Signal/translations/hr.lproj/Localizable.strings differ diff --git a/Signal/translations/hu.lproj/Localizable.strings b/Signal/translations/hu.lproj/Localizable.strings index 95130f506..c497f1cb9 100644 Binary files a/Signal/translations/hu.lproj/Localizable.strings and b/Signal/translations/hu.lproj/Localizable.strings differ diff --git a/Signal/translations/id.lproj/Localizable.strings b/Signal/translations/id.lproj/Localizable.strings index 17877a7cb..48aa660d6 100644 Binary files a/Signal/translations/id.lproj/Localizable.strings and b/Signal/translations/id.lproj/Localizable.strings differ diff --git a/Signal/translations/it_IT.lproj/Localizable.strings b/Signal/translations/it_IT.lproj/Localizable.strings index b33ba233e..22f415e41 100644 Binary files a/Signal/translations/it_IT.lproj/Localizable.strings and b/Signal/translations/it_IT.lproj/Localizable.strings differ diff --git a/Signal/translations/ja_JP.lproj/Localizable.strings b/Signal/translations/ja_JP.lproj/Localizable.strings index 609d2f97f..1330efa99 100644 Binary files a/Signal/translations/ja_JP.lproj/Localizable.strings and b/Signal/translations/ja_JP.lproj/Localizable.strings differ diff --git a/Signal/translations/ko_KR.lproj/Localizable.strings b/Signal/translations/ko_KR.lproj/Localizable.strings index d188bc54d..22e76184a 100644 Binary files a/Signal/translations/ko_KR.lproj/Localizable.strings and b/Signal/translations/ko_KR.lproj/Localizable.strings differ diff --git a/Signal/translations/lv.lproj/Localizable.strings b/Signal/translations/lv.lproj/Localizable.strings index a7cbec272..925e789c0 100644 Binary files a/Signal/translations/lv.lproj/Localizable.strings and b/Signal/translations/lv.lproj/Localizable.strings differ diff --git a/Signal/translations/mk.lproj/Localizable.strings b/Signal/translations/mk.lproj/Localizable.strings index 16b63633a..8a2ff1bf5 100644 Binary files a/Signal/translations/mk.lproj/Localizable.strings and b/Signal/translations/mk.lproj/Localizable.strings differ diff --git a/Signal/translations/nb_NO.lproj/Localizable.strings b/Signal/translations/nb_NO.lproj/Localizable.strings index fbfd7999a..bcb1c5489 100644 Binary files a/Signal/translations/nb_NO.lproj/Localizable.strings and b/Signal/translations/nb_NO.lproj/Localizable.strings differ diff --git a/Signal/translations/nl.lproj/Localizable.strings b/Signal/translations/nl.lproj/Localizable.strings index 730996c88..1e0ba62b4 100644 Binary files a/Signal/translations/nl.lproj/Localizable.strings and b/Signal/translations/nl.lproj/Localizable.strings differ diff --git a/Signal/translations/pl.lproj/Localizable.strings b/Signal/translations/pl.lproj/Localizable.strings index 768211a09..7527a76fb 100644 Binary files a/Signal/translations/pl.lproj/Localizable.strings and b/Signal/translations/pl.lproj/Localizable.strings differ diff --git a/Signal/translations/pt_BR.lproj/Localizable.strings b/Signal/translations/pt_BR.lproj/Localizable.strings index 0464255c5..3bba71635 100644 Binary files a/Signal/translations/pt_BR.lproj/Localizable.strings and b/Signal/translations/pt_BR.lproj/Localizable.strings differ diff --git a/Signal/translations/pt_PT.lproj/Localizable.strings b/Signal/translations/pt_PT.lproj/Localizable.strings index c06555adb..6403ad030 100644 Binary files a/Signal/translations/pt_PT.lproj/Localizable.strings and b/Signal/translations/pt_PT.lproj/Localizable.strings differ diff --git a/Signal/translations/ro.lproj/Localizable.strings b/Signal/translations/ro.lproj/Localizable.strings index 7a34a5fe9..cda202f4d 100644 Binary files a/Signal/translations/ro.lproj/Localizable.strings and b/Signal/translations/ro.lproj/Localizable.strings differ diff --git a/Signal/translations/ru.lproj/Localizable.strings b/Signal/translations/ru.lproj/Localizable.strings index 98286ff75..cd95832aa 100644 Binary files a/Signal/translations/ru.lproj/Localizable.strings and b/Signal/translations/ru.lproj/Localizable.strings differ diff --git a/Signal/translations/sl.lproj/Localizable.strings b/Signal/translations/sl.lproj/Localizable.strings index 0f0a1cbc5..e8a52e46a 100644 Binary files a/Signal/translations/sl.lproj/Localizable.strings and b/Signal/translations/sl.lproj/Localizable.strings differ diff --git a/Signal/translations/sn.lproj/Localizable.strings b/Signal/translations/sn.lproj/Localizable.strings index d394fc4ad..7bfbf3af4 100644 Binary files a/Signal/translations/sn.lproj/Localizable.strings and b/Signal/translations/sn.lproj/Localizable.strings differ diff --git a/Signal/translations/sq.lproj/Localizable.strings b/Signal/translations/sq.lproj/Localizable.strings index 682af4ea4..18ad9dc03 100644 Binary files a/Signal/translations/sq.lproj/Localizable.strings and b/Signal/translations/sq.lproj/Localizable.strings differ diff --git a/Signal/translations/sv_SE.lproj/Localizable.strings b/Signal/translations/sv_SE.lproj/Localizable.strings index 48395144d..9ecf4c9c7 100644 Binary files a/Signal/translations/sv_SE.lproj/Localizable.strings and b/Signal/translations/sv_SE.lproj/Localizable.strings differ diff --git a/Signal/translations/th_TH.lproj/Localizable.strings b/Signal/translations/th_TH.lproj/Localizable.strings index 24563fbc9..5c321323c 100644 Binary files a/Signal/translations/th_TH.lproj/Localizable.strings and b/Signal/translations/th_TH.lproj/Localizable.strings differ diff --git a/Signal/translations/tr_TR.lproj/Localizable.strings b/Signal/translations/tr_TR.lproj/Localizable.strings index 653e2bb4f..4c560e33c 100644 Binary files a/Signal/translations/tr_TR.lproj/Localizable.strings and b/Signal/translations/tr_TR.lproj/Localizable.strings differ diff --git a/Signal/translations/zh_CN.lproj/Localizable.strings b/Signal/translations/zh_CN.lproj/Localizable.strings index b06f79b0b..767343c61 100644 Binary files a/Signal/translations/zh_CN.lproj/Localizable.strings and b/Signal/translations/zh_CN.lproj/Localizable.strings differ