From ada07351e18ce7e134ae0db6ad640d32923a6c9e Mon Sep 17 00:00:00 2001 From: Frederic Jacobs Date: Sun, 23 Aug 2015 00:00:39 +0200 Subject: [PATCH] Support for `supportsVOIP` attribute. - Deprecates RedPhone upgrade flow. - Adds a generic upgrade dialog. - Upgrades dependencies. - Reorganizes `TSStorageManager` & TSNetworkManager imports. --- Podfile | 3 +- Podfile.lock | 17 +- Pods | 2 +- Podspecs/UICKeyChainStore.podspec | 18 - Signal.xcodeproj/project.pbxproj | 30 +- Signal/Signal-Info.plist | 4 +- Signal/src/AppDelegate.m | 1 - Signal/src/contact/Contact.m | 1 - Signal/src/environment/Environment.h | 2 + Signal/src/environment/Environment.m | 1 - Signal/src/environment/PreferencesUtil.m | 1 - .../src/environment/PropertyListPreferences.m | 2 +- Signal/src/environment/VersionMigrations.h | 1 - Signal/src/environment/VersionMigrations.m | 324 ++++++------------ .../PhoneNumberDirectoryFilterManager.m | 3 +- .../src/textsecure/Account/TSAccountManager.m | 3 - Signal/src/textsecure/Account/TSAttributes.h | 17 + Signal/src/textsecure/Account/TSAttributes.m | 33 ++ .../src/textsecure/Account/TSPreKeyManager.m | 8 +- .../Messages/TSMessagesManager+attachments.m | 2 - .../Messages/TSMessagesManager+sendMessages.m | 6 - .../textsecure/Messages/TSMessagesManager.m | 6 +- .../Requests/TSContactsIntersectionRequest.h | 2 - .../API/Requests/TSRegisterWithTokenRequest.h | 2 +- .../API/Requests/TSRegisterWithTokenRequest.m | 8 +- .../API/Requests/TSUpdateAttributesRequest.h | 15 + .../API/Requests/TSUpdateAttributesRequest.m | 28 ++ .../textsecure/Network/API/TSNetworkManager.h | 19 +- .../TSStorageManager+SignedPreKeyStore.m | 8 +- .../src/textsecure/Storage/TSStorageHeaders.h | 22 ++ Signal/src/textsecure/TSConstants.h | 2 + .../FingerprintViewController.m | 4 +- .../LockInteractionController.h | 24 ++ .../LockInteractionController.m | 85 +++++ .../view controllers/MessagesViewController.m | 1 - .../PrivacySettingsTableViewController.m | 1 - .../UITests/SignalsViewController.m | 2 +- .../test/textsecure/VersionMigrationsTests.m | 130 ------- 38 files changed, 400 insertions(+), 438 deletions(-) delete mode 100644 Podspecs/UICKeyChainStore.podspec create mode 100644 Signal/src/textsecure/Account/TSAttributes.h create mode 100644 Signal/src/textsecure/Account/TSAttributes.m create mode 100644 Signal/src/textsecure/Network/API/Requests/TSUpdateAttributesRequest.h create mode 100644 Signal/src/textsecure/Network/API/Requests/TSUpdateAttributesRequest.m create mode 100644 Signal/src/textsecure/Storage/TSStorageHeaders.h create mode 100644 Signal/src/view controllers/LockInteractionController.h create mode 100644 Signal/src/view controllers/LockInteractionController.m delete mode 100644 Signal/test/textsecure/VersionMigrationsTests.m diff --git a/Podfile b/Podfile index fadbf171e..eb633f097 100644 --- a/Podfile +++ b/Podfile @@ -14,10 +14,9 @@ pod 'Mantle', '~> 2.0.4' pod 'FFCircularProgressView', '~> 0.5' pod 'SCWaveformView', '~> 1.0' pod 'YapDatabase/SQLCipher', '~> 2.7' -pod 'SSKeychain' +pod 'SSKeychain' pod 'DJWActionSheet' pod 'SocketRocket', :git => 'https://github.com/FredericJacobs/SocketRocket.git', :commit => 'f1567f1be7ce49ecf2c9d284ead8ea7c422ee99b' pod 'JSQMessagesViewController', :git => 'https://github.com/WhisperSystems/JSQMessagesViewController', :commit => 'e5582fef8a6b3e35f8070361ef37237222da712b' pod 'APDropDownNavToolbar', :git => 'https://github.com/corbett/APDropDownNavToolbar.git', :branch => 'master' -pod 'UICKeyChainStore', :podspec => 'Podspecs/UICKeyChainStore.podspec' diff --git a/Podfile.lock b/Podfile.lock index 31883ae18..046812507 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -56,23 +56,22 @@ PODS: - SSKeychain (1.2.3) - TwistedOakCollapsingFutures (1.0.0): - UnionFind (~> 1.0) - - UICKeyChainStore (1.0.7) - UnionFind (1.0.1) - - YapDatabase/SQLCipher (2.7): + - YapDatabase/SQLCipher (2.7.1): - CocoaLumberjack (~> 2) - SQLCipher/fts DEPENDENCIES: - - AFNetworking (~> 2.5.3) + - AFNetworking (~> 2.5.4) - APDropDownNavToolbar (from `https://github.com/corbett/APDropDownNavToolbar.git`, branch `master`) - AxolotlKit (~> 0.7) - DJWActionSheet - - FFCircularProgressView (>= 0.1) + - FFCircularProgressView (~> 0.5) - JSQMessagesViewController (from `https://github.com/WhisperSystems/JSQMessagesViewController`, commit `e5582fef8a6b3e35f8070361ef37237222da712b`) - - libPhoneNumber-iOS (~> 0.8.5) - - Mantle (~> 2.0.2) + - libPhoneNumber-iOS (~> 0.8.7) + - Mantle (~> 2.0.4) - OpenSSL (~> 1.0.204) - PastelogKit (~> 1.3) - SCWaveformView (~> 1.0) @@ -80,7 +79,6 @@ DEPENDENCIES: `f1567f1be7ce49ecf2c9d284ead8ea7c422ee99b`) - SSKeychain - TwistedOakCollapsingFutures (~> 1.0) - - UICKeyChainStore (from `Podspecs/UICKeyChainStore.podspec`) - YapDatabase/SQLCipher (~> 2.7) EXTERNAL SOURCES: @@ -93,8 +91,6 @@ EXTERNAL SOURCES: SocketRocket: :commit: f1567f1be7ce49ecf2c9d284ead8ea7c422ee99b :git: https://github.com/FredericJacobs/SocketRocket.git - UICKeyChainStore: - :podspec: Podspecs/UICKeyChainStore.podspec CHECKOUT OPTIONS: APDropDownNavToolbar: @@ -128,8 +124,7 @@ SPEC CHECKSUMS: SQLCipher: c44fcca49c31483c2489cfb79aa7a69407f3794a SSKeychain: 3f42991739c6c60a9cf1bbd4dff6c0d3694bcf3d TwistedOakCollapsingFutures: f359b90f203e9ab13dfb92c9ff41842a7fe1cd0c - UICKeyChainStore: d4c0f4e313d67b2f23b6614adca55351accac15a UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d - YapDatabase: 9ec61885759a832d41f965e27f7ee08a06d4c441 + YapDatabase: e9ff9a189e99268a331575411e8462e4c6df2bc3 COCOAPODS: 0.38.2 diff --git a/Pods b/Pods index c36469aa9..c43d25e93 160000 --- a/Pods +++ b/Pods @@ -1 +1 @@ -Subproject commit c36469aa9cc7ea2cc8c343065dfbf0353c0b5791 +Subproject commit c43d25e93c1b3d25a866e618ff1b45f3a940f332 diff --git a/Podspecs/UICKeyChainStore.podspec b/Podspecs/UICKeyChainStore.podspec deleted file mode 100644 index 14b9d904c..000000000 --- a/Podspecs/UICKeyChainStore.podspec +++ /dev/null @@ -1,18 +0,0 @@ -Pod::Spec.new do |s| - s.name = "UICKeyChainStore" - s.version = "1.0.7" - s.summary = "UICKeyChainStore is a simple wrapper for Keychain on iOS and OS X. Makes using Keychain APIs as easy as NSUserDefaults." - s.homepage = "https://github.com/kishikawakatsumi/UICKeyChainStore" - s.social_media_url = "https://twitter.com/k_katsumi" - s.license = { :type => "MIT", :file => "LICENSE" } - s.author = { "kishikawa katsumi" => "kishikawakatsumi@mac.com" } - s.source = { :git => "https://github.com/FredericJacobs/UICKeyChainStore.git", :tag => "v#{s.version}" } - - s.ios.deployment_target = "4.3" - s.osx.deployment_target = "10.6" - s.requires_arc = true - - s.source_files = "Lib/*" - - s.framework = "Security" -end diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 2582d061c..dd8b1a458 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -274,7 +274,6 @@ A547DD741A70A87800103EC7 /* DJWActionSheet+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = A547DD721A70A87800103EC7 /* DJWActionSheet+OWS.m */; }; A5509ECA1A69AB8B00ABA4BC /* Storyboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A5509EC91A69AB8B00ABA4BC /* Storyboard.storyboard */; }; A5509ECD1A69B1D600ABA4BC /* CountryCodeTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A5509ECC1A69B1D600ABA4BC /* CountryCodeTableViewCell.m */; }; - A5578C721A646E5300704A25 /* VersionMigrationsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A5578C711A646E5300704A25 /* VersionMigrationsTests.m */; }; A56977911A351BC400173BF2 /* ScanIdentityBarcodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A569778E1A351BC400173BF2 /* ScanIdentityBarcodeViewController.m */; }; A56977921A351BC400173BF2 /* PresentIdentityQRCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A569778F1A351BC400173BF2 /* PresentIdentityQRCodeViewController.m */; }; A5988A811A8A70D0002AD6BE /* UIButton+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = A5988A801A8A70D0002AD6BE /* UIButton+OWS.m */; }; @@ -341,6 +340,7 @@ B66B9F7D1AEAF40500E2E609 /* NotificationSettingsOptionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B66B9F7C1AEAF40500E2E609 /* NotificationSettingsOptionsViewController.m */; }; B66DBF4A19D5BBC8006EA940 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B66DBF4919D5BBC8006EA940 /* Images.xcassets */; }; B671B2461A93B238002BBD9D /* GroupContactsResult.m in Sources */ = {isa = PBXBuildFile; fileRef = B671B2451A93B238002BBD9D /* GroupContactsResult.m */; }; + B675C16C1B891B3900A7A87A /* TSAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = B675C16B1B891B3900A7A87A /* TSAttributes.m */; }; B67ADDC41989FF8700E1A773 /* RPServerRequestsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B67ADDC31989FF8700E1A773 /* RPServerRequestsManager.m */; }; B67EBF5D19194AC60084CCFD /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = B67EBF5C19194AC60084CCFD /* Settings.bundle */; }; B68112EA1A4D9EC400BA82FF /* UIImage+normalizeImage.m in Sources */ = {isa = PBXBuildFile; fileRef = B68112E91A4D9EC400BA82FF /* UIImage+normalizeImage.m */; }; @@ -394,6 +394,8 @@ B6B1013C196D213F007E3930 /* SignalKeyingStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B1013B196D213F007E3930 /* SignalKeyingStorage.m */; }; B6B50AAB1A4192C500F8F607 /* TSMessagesManager+attachments.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B50AAA1A4192C500F8F607 /* TSMessagesManager+attachments.m */; }; B6B9ECFC198B31BA00C620D3 /* PushManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B9ECFB198B31BA00C620D3 /* PushManager.m */; }; + B6BADBE41B88CB940086A80D /* TSUpdateAttributesRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B6BADBE31B88CB940086A80D /* TSUpdateAttributesRequest.m */; }; + B6BADBE71B88D1AC0086A80D /* LockInteractionController.m in Sources */ = {isa = PBXBuildFile; fileRef = B6BADBE61B88D1AC0086A80D /* LockInteractionController.m */; }; B6BE7EED1AB100250038D0C8 /* BloomFilterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B6BE7EEC1AB100250038D0C8 /* BloomFilterTests.m */; }; B6C6AE551A305ED1006BAF8F /* redphone.cer in Resources */ = {isa = PBXBuildFile; fileRef = B6C6AE531A305ED1006BAF8F /* redphone.cer */; }; B6C6AE561A305ED1006BAF8F /* textsecure.cer in Resources */ = {isa = PBXBuildFile; fileRef = B6C6AE541A305ED1006BAF8F /* textsecure.cer */; }; @@ -832,7 +834,6 @@ A5509EC91A69AB8B00ABA4BC /* Storyboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Storyboard.storyboard; path = Storyboard/Storyboard.storyboard; sourceTree = ""; }; A5509ECB1A69B1D600ABA4BC /* CountryCodeTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CountryCodeTableViewCell.h; sourceTree = ""; }; A5509ECC1A69B1D600ABA4BC /* CountryCodeTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CountryCodeTableViewCell.m; sourceTree = ""; }; - A5578C711A646E5300704A25 /* VersionMigrationsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VersionMigrationsTests.m; sourceTree = ""; }; A569778D1A351BC400173BF2 /* ScanIdentityBarcodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScanIdentityBarcodeViewController.h; sourceTree = ""; }; A569778E1A351BC400173BF2 /* ScanIdentityBarcodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScanIdentityBarcodeViewController.m; sourceTree = ""; }; A569778F1A351BC400173BF2 /* PresentIdentityQRCodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PresentIdentityQRCodeViewController.m; sourceTree = ""; }; @@ -946,6 +947,9 @@ B66DBF4919D5BBC8006EA940 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; B671B2441A93B238002BBD9D /* GroupContactsResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupContactsResult.h; sourceTree = ""; }; B671B2451A93B238002BBD9D /* GroupContactsResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GroupContactsResult.m; sourceTree = ""; }; + B675C16A1B891B3900A7A87A /* TSAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSAttributes.h; sourceTree = ""; }; + B675C16B1B891B3900A7A87A /* TSAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSAttributes.m; sourceTree = ""; }; + B675C16F1B891D6800A7A87A /* TSStorageHeaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TSStorageHeaders.h; path = ../TSStorageHeaders.h; sourceTree = ""; }; B676BCEF1AA544E7009637B8 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = translations/de.lproj/Localizable.strings; sourceTree = ""; }; B676BCF01AA544F5009637B8 /* el_GR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el_GR; path = translations/el_GR.lproj/Localizable.strings; sourceTree = ""; }; B676BCF11AA5451E009637B8 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = translations/es.lproj/Localizable.strings; sourceTree = ""; }; @@ -1066,6 +1070,10 @@ B6B50AAA1A4192C500F8F607 /* TSMessagesManager+attachments.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TSMessagesManager+attachments.m"; sourceTree = ""; }; B6B9ECFA198B31BA00C620D3 /* PushManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PushManager.h; sourceTree = ""; }; B6B9ECFB198B31BA00C620D3 /* PushManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PushManager.m; sourceTree = ""; }; + B6BADBE21B88CB940086A80D /* TSUpdateAttributesRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSUpdateAttributesRequest.h; sourceTree = ""; }; + B6BADBE31B88CB940086A80D /* TSUpdateAttributesRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSUpdateAttributesRequest.m; sourceTree = ""; }; + B6BADBE51B88D1AC0086A80D /* LockInteractionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LockInteractionController.h; sourceTree = ""; }; + B6BADBE61B88D1AC0086A80D /* LockInteractionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LockInteractionController.m; sourceTree = ""; }; B6BC3D0C1AA544B100C2907F /* da */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = da; path = translations/da.lproj/Localizable.strings; sourceTree = ""; }; B6BE7EEC1AB100250038D0C8 /* BloomFilterTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BloomFilterTests.m; sourceTree = ""; }; B6C6AE531A305ED1006BAF8F /* redphone.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = redphone.cer; sourceTree = ""; }; @@ -1850,6 +1858,8 @@ 76EB04FE18170B33006006FC /* view controllers */ = { isa = PBXGroup; children = ( + B6BADBE51B88D1AC0086A80D /* LockInteractionController.h */, + B6BADBE61B88D1AC0086A80D /* LockInteractionController.m */, FCFD25791A1543D500F4C644 /* Signup */, FC3196321A08142D0094C78E /* Signals */, FC3196311A08141D0094C78E /* Settings */, @@ -2180,6 +2190,8 @@ B63AF5BF1A1F757900D01AAD /* TSSubmitMessageRequest.m */, B63AF5AE1A1F757900D01AAD /* TSUnregisterAccountRequest.h */, B63AF5AF1A1F757900D01AAD /* TSUnregisterAccountRequest.m */, + B6BADBE21B88CB940086A80D /* TSUpdateAttributesRequest.h */, + B6BADBE31B88CB940086A80D /* TSUpdateAttributesRequest.m */, ); path = Requests; sourceTree = ""; @@ -2208,7 +2220,6 @@ isa = PBXGroup; children = ( B65031CE1A7862AA002EBBBD /* SignedPreKeyDeletionTests.m */, - A5578C711A646E5300704A25 /* VersionMigrationsTests.m */, B6B095DE1A1D25C5008BFAA6 /* CryptographyTests.mm */, B6B095DF1A1D25C5008BFAA6 /* TextSecureKitTests.m */, B6B095E01A1D25C5008BFAA6 /* TSMessageStorageTests.m */, @@ -2239,6 +2250,8 @@ B6B095EB1A1D25ED008BFAA6 /* Account */ = { isa = PBXGroup; children = ( + B675C16A1B891B3900A7A87A /* TSAttributes.h */, + B675C16B1B891B3900A7A87A /* TSAttributes.m */, B6B095EC1A1D25ED008BFAA6 /* TSAccountManager.h */, B6B095ED1A1D25ED008BFAA6 /* TSAccountManager.m */, B6B095F01A1D25ED008BFAA6 /* TSPreKeyManager.h */, @@ -2341,6 +2354,7 @@ B6B0963F1A1D25ED008BFAA6 /* AxolotlStore */ = { isa = PBXGroup; children = ( + B675C16F1B891D6800A7A87A /* TSStorageHeaders.h */, B6B096401A1D25ED008BFAA6 /* TSStorageManager+IdentityKeyStore.h */, B6B096411A1D25ED008BFAA6 /* TSStorageManager+IdentityKeyStore.m */, B6B096421A1D25ED008BFAA6 /* TSStorageManager+keyFromIntLong.h */, @@ -2969,6 +2983,7 @@ 76EB060218170B33006006FC /* InitiatorSessionDescriptor.m in Sources */, 76EB05FC18170B33006006FC /* CallConnectUtil_Server.m in Sources */, 76EB062418170B33006006FC /* PriorityQueue.m in Sources */, + B6BADBE71B88D1AC0086A80D /* LockInteractionController.m in Sources */, 76EB061A18170B33006006FC /* DiscardingLog.m in Sources */, B63AF5C71A1F757900D01AAD /* TSContactsIntersectionRequest.m in Sources */, B6B0968B1A1D25ED008BFAA6 /* TSStorageManager+SignedPreKeyStore.m in Sources */, @@ -3034,6 +3049,7 @@ 76EB05A618170B33006006FC /* RtpPacket.m in Sources */, 76EB064218170B33006006FC /* StringUtil.m in Sources */, A547DD741A70A87800103EC7 /* DJWActionSheet+OWS.m in Sources */, + B6BADBE41B88CB940086A80D /* TSUpdateAttributesRequest.m in Sources */, 76EB065A18170B34006006FC /* NextResponderScrollView.m in Sources */, 76EB062618170B33006006FC /* Queue.m in Sources */, D221A09A169C9E5E00537ABF /* main.m in Sources */, @@ -3058,6 +3074,7 @@ 76EB05E418170B33006006FC /* UdpSocket.m in Sources */, B6B096931A1D25ED008BFAA6 /* NSData+messagePadding.m in Sources */, B63AF5CE1A1F757900D01AAD /* TSAttachmentRequest.m in Sources */, + B675C16C1B891B3900A7A87A /* TSAttributes.m in Sources */, 76EB058218170B33006006FC /* Environment.m in Sources */, 76EB064418170B33006006FC /* ThreadManager.m in Sources */, E197B61E18BBEC6D00F073E5 /* AudioRouter.m in Sources */, @@ -3280,7 +3297,6 @@ 76EB05CF18170B33006006FC /* ZrtpHandshakeResult.m in Sources */, 76EB060518170B33006006FC /* PhoneNumberDirectoryFilter.m in Sources */, A157076817F0CD6D007C2BD6 /* ShortAuthenticationStringGeneratorTest.m in Sources */, - A5578C721A646E5300704A25 /* VersionMigrationsTests.m in Sources */, 76EB065718170B34006006FC /* InCallViewController.m in Sources */, A157076917F0CD6D007C2BD6 /* PregeneratedKeyAgreementParticipantProtocol.m in Sources */, 76EB062918170B33006006FC /* BadArgument.m in Sources */, @@ -3519,7 +3535,7 @@ CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = "iPhone Distribution"; COPY_PHASE_STRIP = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_GENERATE_TEST_COVERAGE_FILES = NO; @@ -3571,8 +3587,6 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CURRENT_PROJECT_VERSION = 1; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3626,8 +3640,6 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CURRENT_PROJECT_VERSION = 1; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index fb8c08396..e960492cc 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -23,7 +23,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 2.1.2 + 2.1.3 CFBundleSignature ???? CFBundleURLTypes @@ -40,7 +40,7 @@ CFBundleVersion - 2.1.65 + 2.1.70 LOGS_EMAIL support@whispersystems.org LOGS_URL diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 94adc46e4..0ce8d69a1 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -11,7 +11,6 @@ #import "TSPreKeyManager.h" #import "TSMessagesManager.h" #import "TSSocketManager.h" -#import "TSStorageManager.h" #import "VersionMigrations.h" #import "CodeVerificationViewController.h" diff --git a/Signal/src/contact/Contact.m b/Signal/src/contact/Contact.m index a3672aa27..9be4f2556 100644 --- a/Signal/src/contact/Contact.m +++ b/Signal/src/contact/Contact.m @@ -1,6 +1,5 @@ #import "Contact.h" #import "ContactsManager.h" -#import "TSStorageManager.h" #import "Environment.h" #import "TSRecipient.h" diff --git a/Signal/src/environment/Environment.h b/Signal/src/environment/Environment.h index ba1d5036c..13ebfb377 100644 --- a/Signal/src/environment/Environment.h +++ b/Signal/src/environment/Environment.h @@ -4,6 +4,8 @@ #import "PacketHandler.h" #import "SecureEndPoint.h" #import "TSGroupModel.h" +#import "TSStorageHeaders.h" + /** * * Environment is a data and data accessor class. diff --git a/Signal/src/environment/Environment.m b/Signal/src/environment/Environment.m index 3b572440f..74e460487 100644 --- a/Signal/src/environment/Environment.m +++ b/Signal/src/environment/Environment.m @@ -11,7 +11,6 @@ #import "SignalsViewController.h" #import "TSContactThread.h" #import "TSGroupThread.h" -#import "TSStorageManager.h" static NSString* const kCallSegue = @"2.0_6.0_Call_Segue"; #define isRegisteredUserDefaultString @"isRegistered" diff --git a/Signal/src/environment/PreferencesUtil.m b/Signal/src/environment/PreferencesUtil.m index 7511a7bb3..56b2b2c01 100644 --- a/Signal/src/environment/PreferencesUtil.m +++ b/Signal/src/environment/PreferencesUtil.m @@ -211,7 +211,6 @@ return currentVersion; } - #pragma mark Notification Preferences - (BOOL)soundInForeground { diff --git a/Signal/src/environment/PropertyListPreferences.m b/Signal/src/environment/PropertyListPreferences.m index d9ce25b2d..aa5c9cad0 100644 --- a/Signal/src/environment/PropertyListPreferences.m +++ b/Signal/src/environment/PropertyListPreferences.m @@ -1,6 +1,6 @@ #import "PropertyListPreferences.h" #import "Constraints.h" -#import "TSStorageManager.h" +#import "TSStorageHeaders.h" #define SignalDatabaseCollection @"SignalPreferences" diff --git a/Signal/src/environment/VersionMigrations.h b/Signal/src/environment/VersionMigrations.h index 21a8e6e28..b3b4e68c4 100644 --- a/Signal/src/environment/VersionMigrations.h +++ b/Signal/src/environment/VersionMigrations.h @@ -13,6 +13,5 @@ @interface VersionMigrations : NSObject + (void)performUpdateCheck; -+ (BOOL)isMigrating; @end diff --git a/Signal/src/environment/VersionMigrations.m b/Signal/src/environment/VersionMigrations.m index e09958683..a7cdf9b9c 100644 --- a/Signal/src/environment/VersionMigrations.m +++ b/Signal/src/environment/VersionMigrations.m @@ -9,18 +9,17 @@ #import "VersionMigrations.h" #import "Environment.h" +#import "LockInteractionController.h" #import "PhoneNumberDirectoryFilterManager.h" #import "PreferencesUtil.h" #import "PushManager.h" #import "TSAccountManager.h" +#import "TSNetworkManager.h" #import "RecentCallManager.h" #import "SignalKeyingStorage.h" -#import "UICKeyChainStore.h" - -#define IS_MIGRATING_FROM_1DOT0_TO_LARGER_KEY @"Migrating from 1.0 to Larger" -#define NEEDS_TO_REGISTER_PUSH_KEY @"Register For Push" - +#define NEEDS_TO_REGISTER_PUSH_KEY @"Register For Push" +#define NEEDS_TO_REGISTER_ATTRIBUTES @"Register Attributes" @interface SignalKeyingStorage(VersionMigrations) @@ -35,45 +34,30 @@ + (void)performUpdateCheck{ NSString *previousVersion = Environment.preferences.lastRanVersion; NSString *currentVersion = [Environment.preferences setAndGetCurrentVersion]; - BOOL isCurrentlyMigrating = [VersionMigrations isMigratingTo2Dot0]; - BOOL needsToRegisterPush = [VersionMigrations needsRegisterPush]; BOOL VOIPRegistration = [[PushManager sharedManager] supportsVOIPPush] - && ![Environment.preferences hasRegisteredVOIPPush]; + && ![Environment.preferences hasRegisteredVOIPPush]; + if (!previousVersion) { DDLogError(@"No previous version found. Possibly first launch since install."); return; } - if(([self isVersion:previousVersion atLeast:@"1.0.2" andLessThan:@"2.0"]) || isCurrentlyMigrating) { - [VersionMigrations migrateFrom1Dot0Dot2ToVersion2Dot0]; - } - - if(([self isVersion:previousVersion atLeast:@"2.0.0" andLessThan:@"2.0.18"])) { - [VersionMigrations migrateBloomFilter]; - } - - if ([self isVersion:previousVersion atLeast:@"2.0.0" andLessThan:@"2.0.21"] || needsToRegisterPush) { - [self clearVideoCache]; - [self blockingPushRegistration]; + if(([self isVersion:previousVersion atLeast:@"1.0.2" andLessThan:@"2.0"])) { + // We don't migrate from RedPhone anymore, too painful to maintain. + // Resetting the app data and quitting. + [Environment resetAppData]; + exit(0); } + // VOIP Push might need to be enabled because 1) user ran old version 2) Update to compatible iOS version if (VOIPRegistration && [TSAccountManager isRegistered]) { - [PushManager.sharedManager registrationAndRedPhoneTokenRequestWithSuccess:^(NSData *pushToken, NSData *voipToken, NSString *signupToken) { - [TSAccountManager registerWithRedPhoneToken:signupToken - pushToken:pushToken - voipToken:voipToken - success:^{[Environment.preferences setHasRegisteredVOIPPush:YES];} - failure:^(NSError *error) { - DDLogError(@"Couldn't register with TextSecure server: %@", error.debugDescription); - }]; - } failure:^(NSError *error) { - DDLogError(@"Couldn't register with RedPhone server."); - }]; + [self nonBlockingPushRegistration]; + } + + if ([self isVersion:previousVersion atLeast:@"2.0.0" andLessThan:@"2.1.70"] || [self needsRegisterAttributes]) { + [self clearVideoCache]; + [self blockingAttributesUpdate]; } -} - -+ (BOOL)isMigrating{ - return [self isMigratingTo2Dot0]; } + (BOOL) isVersion:(NSString *)thisVersionString atLeast:(NSString *)openLowerBoundVersionString andLessThan:(NSString *)closedUpperBoundVersionString { @@ -88,196 +72,55 @@ return [thisVersionString compare:thatVersionString options:NSNumericSearch] == NSOrderedAscending; } -+ (void)clearUserDefaults{ - NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier]; - [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain]; - - [Environment.preferences setAndGetCurrentVersion]; - [[NSUserDefaults standardUserDefaults] setObject:@YES forKey:IS_MIGRATING_FROM_1DOT0_TO_LARGER_KEY]; - [[NSUserDefaults standardUserDefaults] synchronize]; -} - -#pragma mark 2.0.1 - -+ (void)migrateBloomFilter { - // The bloom filter had to be moved to the cache folder after rejection of the 2.0.1 - NSString *oldBloomKey = @"Directory Bloom Data"; - [[Environment preferences] setValueForKey:oldBloomKey toValue:nil]; - return; -} - -#pragma mark 2.0 - -+ (void)migrateFrom1Dot0Dot2ToVersion2Dot0 { - - if (!([self wasRedPhoneRegistered] || [self isMigratingTo2Dot0])) { - return; - } - - if ([self wasRedPhoneRegistered]) { - [self migrateRecentCallsToVersion2Dot0]; - [self migrateKeyingStorageToVersion2Dot0]; - [self clearUserDefaults]; - } - - [UIApplication.sharedApplication setNetworkActivityIndicatorVisible:YES]; - - UIAlertController *waitingController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"REGISTER_TEXTSECURE_COMPONENT", nil) - message:nil - preferredStyle:UIAlertControllerStyleAlert]; - - [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:waitingController animated:YES completion:nil]; - - [PushManager.sharedManager registrationAndRedPhoneTokenRequestWithSuccess:^(NSData *pushToken, NSData *voipToken, NSString *signupToken) { - [TSAccountManager registerWithRedPhoneToken:signupToken pushToken:pushToken voipToken:voipToken success:^{ - [UIApplication.sharedApplication setNetworkActivityIndicatorVisible:NO]; - [self clearMigrationFlag]; - Environment *env = [Environment getCurrent]; - PhoneNumberDirectoryFilterManager *manager = [env phoneDirectoryManager]; - [manager forceUpdate]; - [waitingController dismissViewControllerAnimated:YES completion:nil]; - } failure:^(NSError *error) { - [self refreshLock:waitingController]; - DDLogError(@"Couldn't register with TextSecure server: %@", error.debugDescription); - }]; - } failure:^(NSError *error) { - [self refreshLock:waitingController]; - DDLogError(@"Couldn't register with RedPhone server."); - }]; -} - -+ (void)refreshLock:(UIAlertController*)waitingController { - [UIApplication.sharedApplication setNetworkActivityIndicatorVisible:NO]; - [waitingController dismissViewControllerAnimated:NO completion:^{ - UIAlertController *retryController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"REGISTER_TEXTSECURE_FAILED_TITLE", nil) - message:NSLocalizedString(@"REGISTER_TEXTSECURE_FAILED", nil) - preferredStyle:UIAlertControllerStyleAlert]; - - [retryController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"REGISTER_FAILED_TRY_AGAIN", nil) - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - [self migrateFrom1Dot0Dot2ToVersion2Dot0]; - }]]; - - [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:retryController animated:YES completion:nil]; - }]; -} - -+ (void) migrateRecentCallsToVersion2Dot0 { - NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults; - NSData *encodedData = [defaults objectForKey:RECENT_CALLS_DEFAULT_KEY]; - id data = [NSKeyedUnarchiver unarchiveObjectWithData:encodedData]; - - if(![data isKindOfClass:NSArray.class]) { - return; - } else { - NSMutableArray *allRecents = [NSMutableArray arrayWithArray:data]; - - for (RecentCall* recentCall in allRecents) { - [Environment.getCurrent.recentCallManager addRecentCall:recentCall]; - } - } -} - -+(BOOL)wasRedPhoneRegistered{ - BOOL hasLocalNumber = [UICKeyChainStore stringForKey:LOCAL_NUMBER_KEY]!=nil; - BOOL hasPassKey = [UICKeyChainStore stringForKey:SAVED_PASSWORD_KEY]!=nil; - BOOL hasSignaling = [UICKeyChainStore dataForKey:SIGNALING_MAC_KEY]!=nil; - BOOL hasCipherKey = [UICKeyChainStore dataForKey:SIGNALING_CIPHER_KEY]!=nil; - BOOL hasZIDKey = [UICKeyChainStore dataForKey:ZID_KEY]!=nil; - BOOL hasSignalingExtra = [UICKeyChainStore dataForKey:SIGNALING_EXTRA_KEY]!=nil; - - BOOL registered = [[NSUserDefaults.standardUserDefaults objectForKey:@"isRegistered"] boolValue]; - - return registered && hasLocalNumber && hasPassKey && hasSignaling - && hasCipherKey && hasZIDKey && hasSignalingExtra; -} - -+ (void)migrateKeyingStorageToVersion2Dot0{ - // if statements ensure that if this migration is called more than once for whatever reason, the original data isn't rewritten the second time - if([UICKeyChainStore stringForKey:LOCAL_NUMBER_KEY]!=nil) { - [SignalKeyingStorage storeString:[UICKeyChainStore stringForKey:LOCAL_NUMBER_KEY] forKey:LOCAL_NUMBER_KEY]; - } - if([UICKeyChainStore stringForKey:PASSWORD_COUNTER_KEY]!=nil) { - [SignalKeyingStorage storeString:[UICKeyChainStore stringForKey:PASSWORD_COUNTER_KEY] forKey:PASSWORD_COUNTER_KEY]; - } - if([UICKeyChainStore stringForKey:SAVED_PASSWORD_KEY]!=nil) { - [SignalKeyingStorage storeString:[UICKeyChainStore stringForKey:SAVED_PASSWORD_KEY] forKey:SAVED_PASSWORD_KEY]; - } - if([UICKeyChainStore dataForKey:SIGNALING_MAC_KEY]!=nil) { - [SignalKeyingStorage storeData:[UICKeyChainStore dataForKey:SIGNALING_MAC_KEY] forKey:SIGNALING_MAC_KEY]; - } - if([UICKeyChainStore dataForKey:SIGNALING_CIPHER_KEY]!=nil) { - [SignalKeyingStorage storeData:[UICKeyChainStore dataForKey:SIGNALING_CIPHER_KEY] forKey:SIGNALING_CIPHER_KEY]; - } - if([UICKeyChainStore dataForKey:ZID_KEY]!=nil) { - [SignalKeyingStorage storeData:[UICKeyChainStore dataForKey:ZID_KEY] forKey:ZID_KEY]; - } - if([UICKeyChainStore dataForKey:SIGNALING_EXTRA_KEY]!=nil) { - [SignalKeyingStorage storeData:[UICKeyChainStore dataForKey:SIGNALING_EXTRA_KEY] forKey:SIGNALING_EXTRA_KEY]; - } - // Erasing keys in the old key chain store - [UICKeyChainStore removeItemForKey:LOCAL_NUMBER_KEY]; - [UICKeyChainStore removeItemForKey:PASSWORD_COUNTER_KEY]; - [UICKeyChainStore removeItemForKey:SAVED_PASSWORD_KEY]; - [UICKeyChainStore removeItemForKey:SIGNALING_MAC_KEY]; - [UICKeyChainStore removeItemForKey:SIGNALING_CIPHER_KEY]; - [UICKeyChainStore removeItemForKey:ZID_KEY]; - [UICKeyChainStore removeItemForKey:SIGNALING_EXTRA_KEY]; -} - -+ (BOOL)isMigratingTo2Dot0{ - return [self userDefaultsBoolForKey:IS_MIGRATING_FROM_1DOT0_TO_LARGER_KEY]; -} - -+ (void)clearMigrationFlag{ - [[NSUserDefaults standardUserDefaults] removeObjectForKey:IS_MIGRATING_FROM_1DOT0_TO_LARGER_KEY]; -} - #pragma mark Upgrading to 2.1 - Needs to register VOIP token + Removing video cache folder -+ (void)blockingPushRegistration{ - [UIApplication.sharedApplication setNetworkActivityIndicatorVisible:YES]; - [[NSUserDefaults standardUserDefaults] setObject:@YES forKey:NEEDS_TO_REGISTER_PUSH_KEY]; - - UIAlertController *waitingController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Upgrading Signal ...", nil) - message:nil - preferredStyle:UIAlertControllerStyleAlert]; - - [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:waitingController - animated:YES - completion:nil]; - - __block failedPushRegistrationBlock failure = ^(NSError *error) { - [self refreshPushLock:waitingController]; ++ (void)nonBlockingPushRegistration{ + __block failedVerificationBlock failedBlock = ^(NSError *error) { + DDLogError(@"Failed to register VOIP push token: %@", error.debugDescription); }; - [[PushManager sharedManager] requestPushTokenWithSuccess:^(NSData *pushToken, NSData *voipToken) { [TSAccountManager registerForPushNotifications:pushToken voipToken:voipToken success:^{ - [UIApplication.sharedApplication setNetworkActivityIndicatorVisible:NO]; - [[NSUserDefaults standardUserDefaults] removeObjectForKey:NEEDS_TO_REGISTER_PUSH_KEY]; - [waitingController dismissViewControllerAnimated:YES completion:nil]; - } failure:failure]; - } failure:failure]; + DDLogWarn(@"Registered for VOIP Push."); + } failure:failedBlock]; + } failure:failedBlock]; + } -+ (void)refreshPushLock:(UIAlertController*)waitingController { - [UIApplication.sharedApplication setNetworkActivityIndicatorVisible:NO]; - [waitingController dismissViewControllerAnimated:NO completion:^{ - UIAlertController *retryController = [UIAlertController alertControllerWithTitle:@"Upgrading Signal failed" - message:@"An error occured while upgrading, please try again." - preferredStyle:UIAlertControllerStyleAlert]; ++ (void)blockingPushRegistration{ + LIControllerBlockingOperation blockingOperation = ^BOOL(void){ + [[NSUserDefaults standardUserDefaults] setObject:@YES forKey:NEEDS_TO_REGISTER_PUSH_KEY]; - [retryController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"REGISTER_FAILED_TRY_AGAIN", nil) - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - [self blockingPushRegistration]; - }]]; + __block dispatch_semaphore_t sema = dispatch_semaphore_create(0); - [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:retryController - animated:YES - completion:nil]; - }]; + __block BOOL success; + + __block failedVerificationBlock failedBlock = ^(NSError *error) { + success = NO; + dispatch_semaphore_signal(sema); + }; + + [[PushManager sharedManager] requestPushTokenWithSuccess:^(NSData *pushToken, NSData *voipToken) { + [TSAccountManager registerForPushNotifications:pushToken voipToken:voipToken success:^{ + success = YES; + dispatch_semaphore_signal(sema); + } failure:failedBlock]; + } failure:failedBlock]; + + dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); + + return success; + }; + + LIControllerRetryBlock retryBlock = [LockInteractionController defaultNetworkRetry]; + + [LockInteractionController performBlock:blockingOperation + completionBlock:^{ + [[NSUserDefaults standardUserDefaults] removeObjectForKey:NEEDS_TO_REGISTER_PUSH_KEY]; + DDLogWarn(@"Successfully migrated to 2.1"); + } + retryBlock:retryBlock + usesNetwork:YES]; + } + (BOOL)needsRegisterPush { @@ -293,10 +136,57 @@ if([[NSFileManager defaultManager] fileExistsAtPath:basePath]){ [NSFileManager.defaultManager removeItemAtPath:basePath error:&error]; } - DDLogError(@"An error occured while removing the videos cache folder from old location: %@", - error.debugDescription); + + if (error) { + DDLogError(@"An error occured while removing the videos cache folder from old location: %@", + error.debugDescription); + } } +#pragma mark Upgrading to 2.1.3 - Adding VOIP flag on TS Server + ++ (BOOL)needsRegisterAttributes { + return [self userDefaultsBoolForKey:NEEDS_TO_REGISTER_ATTRIBUTES]; +} + ++ (void)blockingAttributesUpdate { + LIControllerBlockingOperation blockingOperation = ^BOOL(void){ + [[NSUserDefaults standardUserDefaults] setObject:@YES forKey:NEEDS_TO_REGISTER_ATTRIBUTES]; + + __block dispatch_semaphore_t sema = dispatch_semaphore_create(0); + + __block BOOL success; + + TSUpdateAttributesRequest *request = [[TSUpdateAttributesRequest alloc] initWithUpdatedAttributes]; + [[TSNetworkManager sharedManager] queueAuthenticatedRequest:request success:^(NSURLSessionDataTask *task, id responseObject) { + success = YES; + dispatch_semaphore_signal(sema); + } failure:^(NSURLSessionDataTask *task, NSError *error) { + success = NO; + DDLogError(@"Updating attributess failed with error: %@", error.description); + dispatch_semaphore_signal(sema); + }]; + + + dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); + + return success; + }; + + LIControllerRetryBlock retryBlock = [LockInteractionController defaultNetworkRetry]; + + [LockInteractionController performBlock:blockingOperation + completionBlock:^{ + [[NSUserDefaults standardUserDefaults] removeObjectForKey:NEEDS_TO_REGISTER_ATTRIBUTES]; + DDLogWarn(@"Successfully updated attributes."); + } + retryBlock:retryBlock + usesNetwork:YES]; + +} + +#pragma mark Util + + (BOOL)userDefaultsBoolForKey:(NSString*)key { NSNumber *num = [[NSUserDefaults standardUserDefaults] objectForKey:key]; diff --git a/Signal/src/phone/signaling/number directory/PhoneNumberDirectoryFilterManager.m b/Signal/src/phone/signaling/number directory/PhoneNumberDirectoryFilterManager.m index 015334f98..cb28f1249 100644 --- a/Signal/src/phone/signaling/number directory/PhoneNumberDirectoryFilterManager.m +++ b/Signal/src/phone/signaling/number directory/PhoneNumberDirectoryFilterManager.m @@ -7,8 +7,7 @@ #import "PreferencesUtil.h" #import "RPServerRequestsManager.h" #import "ThreadManager.h" -#import "TSContactsIntersectionRequest.h" -#import "TSStorageManager.h" +#import "TSNetworkManager.h" #import "TSRecipient.h" #import "Util.h" diff --git a/Signal/src/textsecure/Account/TSAccountManager.m b/Signal/src/textsecure/Account/TSAccountManager.m index 9a4230b9a..22d48f4ea 100644 --- a/Signal/src/textsecure/Account/TSAccountManager.m +++ b/Signal/src/textsecure/Account/TSAccountManager.m @@ -18,9 +18,6 @@ #import "TSSocketManager.h" #import "TSStorageManager+keyingMaterial.h" #import "TSPreKeyManager.h" -#import "TSRegisterForPushRequest.h" -#import "TSRegisterWithTokenRequest.h" -#import "TSUnregisterAccountRequest.h" @interface TSAccountManager () diff --git a/Signal/src/textsecure/Account/TSAttributes.h b/Signal/src/textsecure/Account/TSAttributes.h new file mode 100644 index 000000000..18cf72933 --- /dev/null +++ b/Signal/src/textsecure/Account/TSAttributes.h @@ -0,0 +1,17 @@ +// +// TSAttributes.h +// Signal +// +// Created by Frederic Jacobs on 22/08/15. +// Copyright (c) 2015 Open Whisper Systems. All rights reserved. +// + +#import + +@interface TSAttributes : NSObject + ++ (NSDictionary*)attributesFromStorage; ++ (NSDictionary*)attributesWithSignalingKey:(NSString*)signalingKey + serverAuthToken:(NSString*)authToken; + +@end diff --git a/Signal/src/textsecure/Account/TSAttributes.m b/Signal/src/textsecure/Account/TSAttributes.m new file mode 100644 index 000000000..7d8355677 --- /dev/null +++ b/Signal/src/textsecure/Account/TSAttributes.m @@ -0,0 +1,33 @@ +// +// TSAttributes.m +// Signal +// +// Created by Frederic Jacobs on 22/08/15. +// Copyright (c) 2015 Open Whisper Systems. All rights reserved. +// + +#import "TSAttributes.h" + +#import "TSAccountManager.h" +#import "TSStorageHeaders.h" + +@implementation TSAttributes + + ++ (NSDictionary*)attributesFromStorage { + return [self attributesWithSignalingKey:[TSStorageManager signalingKey] + serverAuthToken:[TSStorageManager serverAuthToken]]; +} + ++ (NSDictionary*)attributesWithSignalingKey:(NSString*)signalingKey + serverAuthToken:(NSString*)authToken + +{ + return @{@"signalingKey" : signalingKey, + @"AuthKey" : authToken, + @"voice" : @YES, + @"registrationId": [NSString stringWithFormat:@"%i",[TSAccountManager getOrGenerateRegistrationId]] + }; +} + +@end diff --git a/Signal/src/textsecure/Account/TSPreKeyManager.m b/Signal/src/textsecure/Account/TSPreKeyManager.m index ddaab60d8..823285bcc 100644 --- a/Signal/src/textsecure/Account/TSPreKeyManager.m +++ b/Signal/src/textsecure/Account/TSPreKeyManager.m @@ -8,14 +8,8 @@ #import "TSPreKeyManager.h" -#import "TSAvailablePreKeysCountRequest.h" -#import "TSCurrentSignedPreKeyRequest.h" -#import "TSStorageManager.h" -#import "TSStorageManager+PreKeyStore.h" -#import "TSStorageManager+SignedPreKeyStore.h" -#import "TSStorageManager+IdentityKeyStore.h" +#import "TSStorageHeaders.h" #import "TSNetworkManager.h" -#import "TSRegisterPrekeysRequest.h" #define EPHEMERAL_PREKEYS_MINIMUM 15 diff --git a/Signal/src/textsecure/Messages/TSMessagesManager+attachments.m b/Signal/src/textsecure/Messages/TSMessagesManager+attachments.m index 739a699e7..645a95f69 100644 --- a/Signal/src/textsecure/Messages/TSMessagesManager+attachments.m +++ b/Signal/src/textsecure/Messages/TSMessagesManager+attachments.m @@ -11,9 +11,7 @@ #import "Cryptography.h" -#import "TSAllocAttachmentRequest.h" #import "TSAttachmentPointer.h" -#import "TSAttachmentRequest.h" #import "TSInfoMessage.h" #import "TSMessagesManager+attachments.h" #import "TSMessagesManager+sendMessages.h" diff --git a/Signal/src/textsecure/Messages/TSMessagesManager+sendMessages.m b/Signal/src/textsecure/Messages/TSMessagesManager+sendMessages.m index 5c4f27339..69fa7d083 100644 --- a/Signal/src/textsecure/Messages/TSMessagesManager+sendMessages.m +++ b/Signal/src/textsecure/Messages/TSMessagesManager+sendMessages.m @@ -17,18 +17,12 @@ #import "PreferencesUtil.h" #import "NSData+messagePadding.h" #import "TSStorageManager.h" -#import "TSStorageManager+SessionStore.h" -#import "TSStorageManager+IdentityKeyStore.h" -#import "TSStorageManager+PreKeyStore.h" -#import "TSStorageManager+SignedPreKeyStore.h" #import "PreKeyBundle+jsonDict.h" #import "SignalKeyingStorage.h" #import "TSNetworkManager.h" #import "TSServerMessage.h" -#import "TSSubmitMessageRequest.h" -#import "TSRecipientPrekeyRequest.h" #import "TSInfoMessage.h" diff --git a/Signal/src/textsecure/Messages/TSMessagesManager.m b/Signal/src/textsecure/Messages/TSMessagesManager.m index d8a96be72..3864389d1 100644 --- a/Signal/src/textsecure/Messages/TSMessagesManager.m +++ b/Signal/src/textsecure/Messages/TSMessagesManager.m @@ -18,11 +18,7 @@ #import "TSInfoMessage.h" #import "TSDatabaseView.h" -#import "TSStorageManager+keyingMaterial.h" -#import "TSStorageManager+IdentityKeyStore.h" -#import "TSStorageManager+SessionStore.h" -#import "TSStorageManager+SignedPreKeyStore.h" -#import "TSStorageManager+PreKeyStore.h" +#import "TSStorageManager.h" #import "TSMessagesManager+attachments.h" #import "SignalKeyingStorage.h" diff --git a/Signal/src/textsecure/Network/API/Requests/TSContactsIntersectionRequest.h b/Signal/src/textsecure/Network/API/Requests/TSContactsIntersectionRequest.h index 81998329b..7a794bc98 100644 --- a/Signal/src/textsecure/Network/API/Requests/TSContactsIntersectionRequest.h +++ b/Signal/src/textsecure/Network/API/Requests/TSContactsIntersectionRequest.h @@ -8,8 +8,6 @@ #import "TSRequest.h" -#import "TSNetworkManager.h" - @interface TSContactsIntersectionRequest : TSRequest - (id)initWithHashesArray:(NSArray*)hashes; diff --git a/Signal/src/textsecure/Network/API/Requests/TSRegisterWithTokenRequest.h b/Signal/src/textsecure/Network/API/Requests/TSRegisterWithTokenRequest.h index 3d1739e57..a7227e547 100644 --- a/Signal/src/textsecure/Network/API/Requests/TSRegisterWithTokenRequest.h +++ b/Signal/src/textsecure/Network/API/Requests/TSRegisterWithTokenRequest.h @@ -10,7 +10,7 @@ @interface TSRegisterWithTokenRequest : TSRequest -- (TSRequest*) initWithVerificationToken:(NSString*)verificationCode signalingKey:(NSString*)signalingKey authKey:(NSString*)authKey number:(NSString*)number; +- (instancetype)initWithVerificationToken:(NSString*)verificationCode signalingKey:(NSString*)signalingKey authKey:(NSString*)authKey number:(NSString*)number; @property NSString *numberToValidate; diff --git a/Signal/src/textsecure/Network/API/Requests/TSRegisterWithTokenRequest.m b/Signal/src/textsecure/Network/API/Requests/TSRegisterWithTokenRequest.m index bca8be00c..c542f1ff3 100644 --- a/Signal/src/textsecure/Network/API/Requests/TSRegisterWithTokenRequest.m +++ b/Signal/src/textsecure/Network/API/Requests/TSRegisterWithTokenRequest.m @@ -8,6 +8,7 @@ #import "TSConstants.h" #import "TSAccountManager.h" +#import "TSAttributes.h" #import "TSRegisterWithTokenRequest.h" @implementation TSRegisterWithTokenRequest @@ -21,10 +22,9 @@ self.numberToValidate = number; - [self.parameters addEntriesFromDictionary:@{@"signalingKey": signalingKey, - @"AuthKey": authKey, - @"supportsSMS": @"0", - @"registrationId": [NSString stringWithFormat:@"%i",[TSAccountManager getOrGenerateRegistrationId]]}]; + NSDictionary *attributes = [TSAttributes attributesWithSignalingKey:signalingKey serverAuthToken:authKey]; + + [self.parameters addEntriesFromDictionary:attributes]; [self setHTTPMethod:@"PUT"]; diff --git a/Signal/src/textsecure/Network/API/Requests/TSUpdateAttributesRequest.h b/Signal/src/textsecure/Network/API/Requests/TSUpdateAttributesRequest.h new file mode 100644 index 000000000..5cbd23aa9 --- /dev/null +++ b/Signal/src/textsecure/Network/API/Requests/TSUpdateAttributesRequest.h @@ -0,0 +1,15 @@ +// +// TSUpdateAttributesRequest.h +// Signal +// +// Created by Frederic Jacobs on 22/08/15. +// Copyright (c) 2015 Open Whisper Systems. All rights reserved. +// + +#import "TSRequest.h" + +@interface TSUpdateAttributesRequest : TSRequest + +- (instancetype)initWithUpdatedAttributes; + +@end diff --git a/Signal/src/textsecure/Network/API/Requests/TSUpdateAttributesRequest.m b/Signal/src/textsecure/Network/API/Requests/TSUpdateAttributesRequest.m new file mode 100644 index 000000000..0f5ecbfde --- /dev/null +++ b/Signal/src/textsecure/Network/API/Requests/TSUpdateAttributesRequest.m @@ -0,0 +1,28 @@ +// +// TSUpdateAttributesRequest.m +// Signal +// +// Created by Frederic Jacobs on 22/08/15. +// Copyright (c) 2015 Open Whisper Systems. All rights reserved. +// + +#import "TSConstants.h" +#import "TSUpdateAttributesRequest.h" +#import "TSAttributes.h" + +@implementation TSUpdateAttributesRequest + +- (instancetype)initWithUpdatedAttributes +{ + NSString *endPoint = [textSecureAccountsAPI stringByAppendingString:textSecureAttributesAPI]; + self = [super initWithURL:[NSURL URLWithString:endPoint]]; + + if (self) { + [self setHTTPMethod:@"PUT"]; + [self.parameters addEntriesFromDictionary:[TSAttributes attributesFromStorage]]; + } + + return self; +} + +@end diff --git a/Signal/src/textsecure/Network/API/TSNetworkManager.h b/Signal/src/textsecure/Network/API/TSNetworkManager.h index 6b5629967..97bc0e5ad 100644 --- a/Signal/src/textsecure/Network/API/TSNetworkManager.h +++ b/Signal/src/textsecure/Network/API/TSNetworkManager.h @@ -6,9 +6,26 @@ // Copyright (c) 2013 Open Whisper Systems. All rights reserved. // +/** + * TSNetworkManager imports all TSRequests to prevent massive imports + in classes that call TSNetworkManager + */ +#import "TSAllocAttachmentRequest.h" +#import "TSAttachmentRequest.h" +#import "TSAvailablePreKeysCountRequest.h" +#import "TSContactsIntersectionRequest.h" +#import "TSCurrentSignedPreKeyRequest.h" +#import "TSRecipientPrekeyRequest.h" +#import "TSRegisterForPushRequest.h" +#import "TSRegisterPrekeysRequest.h" +#import "TSRegisterWithTokenRequest.h" +#import "TSSubmitMessageRequest.h" +#import "TSUnregisterAccountRequest.h" +#import "TSUpdateAttributesRequest.h" + + #import #import -#import "TSRequest.h" @interface TSNetworkManager : NSObject diff --git a/Signal/src/textsecure/Storage/AxolotlStore/TSStorageManager+SignedPreKeyStore.m b/Signal/src/textsecure/Storage/AxolotlStore/TSStorageManager+SignedPreKeyStore.m index 3fcef2a7c..affefa644 100644 --- a/Signal/src/textsecure/Storage/AxolotlStore/TSStorageManager+SignedPreKeyStore.m +++ b/Signal/src/textsecure/Storage/AxolotlStore/TSStorageManager+SignedPreKeyStore.m @@ -5,13 +5,15 @@ // Created by Frederic Jacobs on 06/11/14. // Copyright (c) 2014 Open Whisper Systems. All rights reserved. // -#import "TSStorageManager+IdentityKeyStore.h" + + #import "TSStorageManager+SignedPreKeyStore.h" +#import "TSStorageManager+IdentityKeyStore.h" +#import "TSStorageManager+keyFromIntLong.h" + #import #import <25519/Ed25519.h> #import -#import "TSStorageManager+keyFromIntLong.h" - @implementation TSStorageManager (SignedPreKeyStore) diff --git a/Signal/src/textsecure/Storage/TSStorageHeaders.h b/Signal/src/textsecure/Storage/TSStorageHeaders.h new file mode 100644 index 000000000..3ef754799 --- /dev/null +++ b/Signal/src/textsecure/Storage/TSStorageHeaders.h @@ -0,0 +1,22 @@ +// +// TSStorageHeaders.h +// Signal +// +// Created by Frederic Jacobs on 22/08/15. +// Copyright (c) 2015 Open Whisper Systems. All rights reserved. +// + +#ifndef Signal_TSStorageHeaders_h +#define Signal_TSStorageHeaders_h + +#import "TSStorageManager.h" + +#import "TSStorageManager+keyingMaterial.h" +#import "TSStorageManager+messageIDs.h" +#import "TSStorageManager+PreKeyStore.h" +#import "TSStorageManager+SessionStore.h" +#import "TSStorageManager+keyFromIntLong.h" +#import "TSStorageManager+IdentityKeyStore.h" +#import "TSStorageManager+SignedPreKeyStore.h" + +#endif diff --git a/Signal/src/textsecure/TSConstants.h b/Signal/src/textsecure/TSConstants.h index 8ad78011b..7be7f10e4 100644 --- a/Signal/src/textsecure/TSConstants.h +++ b/Signal/src/textsecure/TSConstants.h @@ -37,6 +37,8 @@ typedef enum { #define textSecureGeneralAPI @"v1" #define textSecureAccountsAPI @"v1/accounts" + #define textSecureAttributesAPI @"/attributes/" + #define textSecureMessagesAPI @"v1/messages/" #define textSecureKeysAPI @"v2/keys" #define textSecureSignedKeysAPI @"v2/keys/signed" diff --git a/Signal/src/view controllers/FingerprintViewController.m b/Signal/src/view controllers/FingerprintViewController.m index f3d46fb54..38c80893b 100644 --- a/Signal/src/view controllers/FingerprintViewController.m +++ b/Signal/src/view controllers/FingerprintViewController.m @@ -11,14 +11,12 @@ #import #import <25519/Curve25519.h> #import "DJWActionSheet+OWS.h" -#import "TSStorageManager.h" -#import "TSStorageManager+IdentityKeyStore.h" -#import "TSStorageManager+SessionStore.h" #import "PresentIdentityQRCodeViewController.h" #import "ScanIdentityBarcodeViewController.h" #import "SignalsNavigationController.h" #import "TSFingerprintGenerator.h" +#import "TSStorageHeaders.h" @interface FingerprintViewController () @property TSContactThread *thread; diff --git a/Signal/src/view controllers/LockInteractionController.h b/Signal/src/view controllers/LockInteractionController.h new file mode 100644 index 000000000..81cdf4b3b --- /dev/null +++ b/Signal/src/view controllers/LockInteractionController.h @@ -0,0 +1,24 @@ +// +// LockInteractionController.h +// Signal +// +// Created by Frederic Jacobs on 22/08/15. +// Copyright (c) 2015 Open Whisper Systems. All rights reserved. +// + +#import + +@interface LockInteractionController : NSObject + +typedef void (^LIControllerCompletionBlock)(); +typedef BOOL (^LIControllerBlockingOperation)(); +typedef void (^LIControllerRetryBlock)(LIControllerBlockingOperation operationBlock, LIControllerCompletionBlock completionBlock); + ++ (void)performBlock:(LIControllerBlockingOperation)blockingOperation + completionBlock:(LIControllerCompletionBlock)completionBlock + retryBlock:(LIControllerRetryBlock)retryBlock + usesNetwork:(BOOL)networkFlag; + ++ (LIControllerRetryBlock)defaultNetworkRetry; + +@end diff --git a/Signal/src/view controllers/LockInteractionController.m b/Signal/src/view controllers/LockInteractionController.m new file mode 100644 index 000000000..ea1ca6269 --- /dev/null +++ b/Signal/src/view controllers/LockInteractionController.m @@ -0,0 +1,85 @@ +// +// LockInteractionController.m +// Signal +// +// Created by Frederic Jacobs on 22/08/15. +// Copyright (c) 2015 Open Whisper Systems. All rights reserved. +// + +#import "LockInteractionController.h" + +@interface LockInteractionController () +@property UIAlertController *alertController; +@end + +@implementation LockInteractionController + +MacrosSingletonImplemention + ++ (void)performBlock:(LIControllerBlockingOperation)blockingOperation + completionBlock:(LIControllerCompletionBlock)completionBlock + retryBlock:(LIControllerRetryBlock)retryBlock + usesNetwork:(BOOL)networkFlag + +{ + + + if (networkFlag) { + [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:networkFlag]; + } + + LockInteractionController *sharedInstance = [LockInteractionController sharedInstance]; + sharedInstance.alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Upgrading Signal ...", nil) + message:nil + preferredStyle:UIAlertControllerStyleAlert]; + + [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:sharedInstance.alertController + animated:YES + completion:nil]; + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + BOOL success = blockingOperation(); + + dispatch_async(dispatch_get_main_queue(), ^{ + [sharedInstance.alertController dismissViewControllerAnimated:YES completion:^{ + if (networkFlag) { + [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; + } + + if (!success) { + retryBlock(blockingOperation, completionBlock); + } else { + completionBlock(); + } + }]; + }); + + }); +} + + ++ (LIControllerRetryBlock)defaultNetworkRetry +{ + LIControllerRetryBlock retryBlock = ^void(LIControllerBlockingOperation blockingOperation, LIControllerCompletionBlock completionBlock) { + UIAlertController *retryController = [UIAlertController alertControllerWithTitle:@"Upgrading Signal failed" + message:@"An network error occured while upgrading, please check your connectivity and try again." + preferredStyle:UIAlertControllerStyleAlert]; + + [retryController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"REGISTER_FAILED_TRY_AGAIN", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + [self performBlock:blockingOperation + completionBlock:completionBlock + retryBlock:[LockInteractionController defaultNetworkRetry] + usesNetwork:YES]; + }]]; + + [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:retryController + animated:YES + completion:nil]; + }; + + return retryBlock; +} + +@end diff --git a/Signal/src/view controllers/MessagesViewController.m b/Signal/src/view controllers/MessagesViewController.m index f4974db44..b9e360748 100644 --- a/Signal/src/view controllers/MessagesViewController.m +++ b/Signal/src/view controllers/MessagesViewController.m @@ -24,7 +24,6 @@ #import "DJWActionSheet+OWS.h" #import -#import "TSStorageManager.h" #import "TSDatabaseView.h" #import "UIButton+OWS.h" #import diff --git a/Signal/src/view controllers/PrivacySettingsTableViewController.m b/Signal/src/view controllers/PrivacySettingsTableViewController.m index ec78436d6..ee67f569f 100644 --- a/Signal/src/view controllers/PrivacySettingsTableViewController.m +++ b/Signal/src/view controllers/PrivacySettingsTableViewController.m @@ -13,7 +13,6 @@ #import "Environment.h" #import "PreferencesUtil.h" #import "TSFingerprintGenerator.h" -#import "TSStorageManager+IdentityKeyStore.h" #import "UIUtil.h" @interface PrivacySettingsTableViewController () diff --git a/Signal/src/view controllers/UITests/SignalsViewController.m b/Signal/src/view controllers/UITests/SignalsViewController.m index c2dd7cc7d..1322dc9fa 100644 --- a/Signal/src/view controllers/UITests/SignalsViewController.m +++ b/Signal/src/view controllers/UITests/SignalsViewController.m @@ -92,7 +92,7 @@ static NSString* const kShowSignupFlowSegue = @"showSignupFlow"; [super viewWillAppear:animated]; [self checkIfEmptyView]; - if (![TSAccountManager isRegistered] && ![VersionMigrations isMigrating]){ + if (![TSAccountManager isRegistered]){ [self performSegueWithIdentifier:kShowSignupFlowSegue sender:self]; return; } diff --git a/Signal/test/textsecure/VersionMigrationsTests.m b/Signal/test/textsecure/VersionMigrationsTests.m deleted file mode 100644 index 20ed3de3d..000000000 --- a/Signal/test/textsecure/VersionMigrationsTests.m +++ /dev/null @@ -1,130 +0,0 @@ -// -// VersionMigrationsTests.m -// TextSecureKit -// -// Created by Frederic Jacobs on 06/11/14. -// Copyright (c) 2014 Open Whisper Systems. All rights reserved. -// - -#import -#import "VersionMigrations.h" - -#import "CategorizingLogger.h" -#import "Cryptography.h" -#import "Environment.h" -#import "TSStorageManager.h" -#import "RecentCall.h" -#import "RecentCallManager.h" -#import "Release.h" -#import "TestUtil.h" -#import "TSCall.h" -#import "TSDatabaseView.h" -#import "SignalKeyingStorage.h" -#import "UICKeyChainStore.h" - - -@interface VersionMigrations(Testing) -+(void) migrateRecentCallsToVersion2Dot0; -+(void) migrateKeyingStorageToVersion2Dot0; -@end - - -@interface SignalKeyingStorage(Testing) -+(void)storeData:(NSData*)data forKey:(NSString*)key; -+(NSData*)dataForKey:(NSString*)key; -+(void)storeString:(NSString*)string forKey:(NSString*)key; -+(NSString*)stringForKey:(NSString*)key; -@end - -@interface TSDatabaseView(Testing) -+ (BOOL)threadShouldBeInInbox:(TSThread*)thread; -@end - - -@interface VersionMigrationsTests : XCTestCase -@property (nonatomic,strong) NSString* localNumber; -@property (nonatomic,strong) NSString* passwordCounter; -@property (nonatomic,strong) NSString* savedPassword; - -@property (nonatomic,strong) NSData* signalingMacKey; -@property (nonatomic,strong) NSData* signalingCipherKey; -@property (nonatomic,strong) NSData* zidKey; -@property (nonatomic,strong) NSData* signalingExtraKey; -@property (nonatomic,strong) NSMutableArray* recentCalls; -@end - -@implementation VersionMigrationsTests - -- (void)setUp { - [super setUp]; - [Environment setCurrent:[Release unitTestEnvironment:@[]]]; - - - _localNumber = @"+123456789"; - _passwordCounter = @"20"; - _savedPassword = @"muchlettersverysecure"; - _signalingMacKey = [Cryptography generateRandomBytes:8]; - _signalingCipherKey = [Cryptography generateRandomBytes:8]; - _zidKey = [Cryptography generateRandomBytes:8]; - _signalingExtraKey = [Cryptography generateRandomBytes:8]; - - // setup the keys - [UICKeyChainStore setString:_localNumber forKey:LOCAL_NUMBER_KEY]; - [UICKeyChainStore setString:_passwordCounter forKey:PASSWORD_COUNTER_KEY]; - [UICKeyChainStore setString:_savedPassword forKey:SAVED_PASSWORD_KEY]; - [UICKeyChainStore setData:_signalingMacKey forKey:SIGNALING_MAC_KEY]; - [UICKeyChainStore setData:_signalingCipherKey forKey:SIGNALING_CIPHER_KEY]; - [UICKeyChainStore setData:_zidKey forKey:ZID_KEY]; - [UICKeyChainStore setData:_signalingExtraKey forKey:SIGNALING_EXTRA_KEY]; - - // setup the recent calls - RecentCall* r1 = [RecentCall recentCallWithContactID:123 - andNumber:testPhoneNumber1 - andCallType:RPRecentCallTypeIncoming]; - RecentCall* r2 = [RecentCall recentCallWithContactID:456 - andNumber:testPhoneNumber2 - andCallType:RPRecentCallTypeMissed]; - - r2.isArchived = YES; - - _recentCalls = [[NSMutableArray alloc] initWithObjects:r1,r2,nil]; - - NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults; - NSData *saveData = [NSKeyedArchiver archivedDataWithRootObject:_recentCalls.copy]; - [defaults setObject:saveData forKey:RECENT_CALLS_DEFAULT_KEY]; - [defaults synchronize]; - -} - -- (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. - [super tearDown]; -} - -- (void)testMigrateKeyingStorageToVersion2Dot0 { - // migrate keying storage - [VersionMigrations migrateKeyingStorageToVersion2Dot0]; - - // checking that everything is migrated correctly - XCTAssert([[SignalKeyingStorage stringForKey:LOCAL_NUMBER_KEY] isEqualToString:_localNumber]); - XCTAssert([[SignalKeyingStorage stringForKey:PASSWORD_COUNTER_KEY] isEqualToString:_passwordCounter]); - XCTAssert([[SignalKeyingStorage stringForKey:SAVED_PASSWORD_KEY] isEqualToString:_savedPassword]); - - XCTAssert([[SignalKeyingStorage dataForKey:SIGNALING_MAC_KEY] isEqualToData:_signalingMacKey]); - XCTAssert([[SignalKeyingStorage dataForKey:SIGNALING_CIPHER_KEY] isEqualToData:_signalingCipherKey]); - XCTAssert([[SignalKeyingStorage dataForKey:ZID_KEY] isEqualToData:_zidKey]); - XCTAssert([[SignalKeyingStorage dataForKey:SIGNALING_EXTRA_KEY] isEqualToData:_signalingExtraKey]); - - // checking that the old storage is empty - XCTAssert([UICKeyChainStore stringForKey:LOCAL_NUMBER_KEY] == nil); - XCTAssert([UICKeyChainStore stringForKey:PASSWORD_COUNTER_KEY] == nil); - XCTAssert([UICKeyChainStore stringForKey:SAVED_PASSWORD_KEY] == nil); - - XCTAssert([UICKeyChainStore dataForKey:SIGNALING_MAC_KEY] == nil); - XCTAssert([UICKeyChainStore dataForKey:SIGNALING_CIPHER_KEY] == nil); - XCTAssert([UICKeyChainStore dataForKey:ZID_KEY] == nil); - XCTAssert([UICKeyChainStore dataForKey:SIGNALING_EXTRA_KEY] == nil); - -} - -@end