diff --git a/Podfile b/Podfile index 5d2b3e30a..0fbe1c479 100644 --- a/Podfile +++ b/Podfile @@ -12,7 +12,7 @@ pod 'AxolotlKit', '~> 0.1' pod 'PastelogKit', '~> 1.2' pod 'TwistedOakCollapsingFutures','~> 1.0' pod 'YapDatabase/SQLCipher' -pod 'AFNetworking', '~> 2.4' +pod 'AFNetworking', '~> 2.5' pod 'Mantle', '~> 1.5' pod 'JSQMessagesViewController', :git => 'https://github.com/dtsbourg/JSQMessagesViewController', :branch => 'JSignalQ' diff --git a/Podfile.lock b/Podfile.lock index dbe221471..5d32aeda3 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -58,7 +58,7 @@ PODS: - YapDatabase/common DEPENDENCIES: - - AFNetworking (~> 2.4) + - AFNetworking (~> 2.5) - AxolotlKit (~> 0.1) - DJWActionSheet - JSQMessagesViewController (from `https://github.com/dtsbourg/JSQMessagesViewController`, branch `JSignalQ`) diff --git a/Pods b/Pods index 5f331e116..bc9ebd5dc 160000 --- a/Pods +++ b/Pods @@ -1 +1 @@ -Subproject commit 5f331e11627a49c73b1f7b6b8b55c97a78008bfe +Subproject commit bc9ebd5dc7fb4100c78e5bb4dda15cfcc3b6734a diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index b7ac64daa..b13a28fd1 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -153,7 +153,7 @@ 76EB05FC18170B33006006FC /* CallConnectUtil_Server.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB04A218170B33006006FC /* CallConnectUtil_Server.m */; }; 76EB05FD18170B33006006FC /* CallConnectUtil_Server.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB04A218170B33006006FC /* CallConnectUtil_Server.m */; }; 76EB05FE18170B33006006FC /* InitiateSignal.pb.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB04A418170B33006006FC /* InitiateSignal.pb.m */; settings = {COMPILER_FLAGS = "-w"; }; }; - 76EB05FF18170B33006006FC /* InitiateSignal.pb.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB04A418170B33006006FC /* InitiateSignal.pb.m */; }; + 76EB05FF18170B33006006FC /* InitiateSignal.pb.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB04A418170B33006006FC /* InitiateSignal.pb.m */; settings = {COMPILER_FLAGS = "-w"; }; }; 76EB060118170B33006006FC /* InitiateSignal.proto in Resources */ = {isa = PBXBuildFile; fileRef = 76EB04A518170B33006006FC /* InitiateSignal.proto */; }; 76EB060218170B33006006FC /* InitiatorSessionDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB04A718170B33006006FC /* InitiatorSessionDescriptor.m */; }; 76EB060318170B33006006FC /* InitiatorSessionDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB04A718170B33006006FC /* InitiatorSessionDescriptor.m */; }; @@ -420,6 +420,10 @@ B684A46D19C3446200B11029 /* PushManagerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B684A46C19C3446200B11029 /* PushManagerTest.m */; }; B6850E5A1995A4710068E715 /* whisperFake.cer in Resources */ = {isa = PBXBuildFile; fileRef = B6850E591995A4710068E715 /* whisperFake.cer */; }; B69CD25119773E79005CE69A /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B69CD25019773E79005CE69A /* XCTest.framework */; }; + B6AE33B91A1EB0AF003DF39D /* DemoDataFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = B6AE33B61A1EB0AF003DF39D /* DemoDataFactory.m */; }; + B6AE33BA1A1EB0AF003DF39D /* DemoDataModel.m in Sources */ = {isa = PBXBuildFile; fileRef = B6AE33B81A1EB0AF003DF39D /* DemoDataModel.m */; }; + B6AE33BD1A1EB121003DF39D /* GroupModel.m in Sources */ = {isa = PBXBuildFile; fileRef = B6AE33BC1A1EB121003DF39D /* GroupModel.m */; }; + B6AE33C01A1EB2DD003DF39D /* Socket.m in Sources */ = {isa = PBXBuildFile; fileRef = B6AE33BF1A1EB2DD003DF39D /* Socket.m */; }; B6B095E41A1D25C5008BFAA6 /* CryptographyTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = B6B095DE1A1D25C5008BFAA6 /* CryptographyTests.mm */; }; B6B095E51A1D25C5008BFAA6 /* TextSecureKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B095DF1A1D25C5008BFAA6 /* TextSecureKitTests.m */; }; B6B095E61A1D25C5008BFAA6 /* TSMessageStorageTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B095E01A1D25C5008BFAA6 /* TSMessageStorageTests.m */; }; @@ -476,7 +480,7 @@ B6B096931A1D25ED008BFAA6 /* NSData+messagePadding.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B0965C1A1D25ED008BFAA6 /* NSData+messagePadding.m */; }; B6B096941A1D25ED008BFAA6 /* NSString+escape.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B0965E1A1D25ED008BFAA6 /* NSString+escape.m */; }; B6B096951A1D25ED008BFAA6 /* NSURLSessionDataTask+StatusCode.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B096601A1D25ED008BFAA6 /* NSURLSessionDataTask+StatusCode.m */; }; - B6B1013C196D213F007E3930 /* SGNKeychainUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B1013B196D213F007E3930 /* SGNKeychainUtil.m */; }; + B6B1013C196D213F007E3930 /* SignalKeyingStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B1013B196D213F007E3930 /* SignalKeyingStorage.m */; }; B6B9ECFC198B31BA00C620D3 /* PushManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B9ECFB198B31BA00C620D3 /* PushManager.m */; }; B6C93C4E199567AD00EDF894 /* DebugLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = B6C93C4D199567AD00EDF894 /* DebugLogger.m */; }; B90418E6183E9DD40038554A /* DateUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = B90418E5183E9DD40038554A /* DateUtil.m */; }; @@ -572,15 +576,12 @@ FC31962A1A067D8F0094C78E /* MessageComposeTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC3196291A067D8F0094C78E /* MessageComposeTableViewController.m */; }; FC31962D1A06A2190094C78E /* FingerprintViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC31962C1A06A2190094C78E /* FingerprintViewController.m */; }; FC3196301A0814130094C78E /* SettingsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC31962F1A0814130094C78E /* SettingsTableViewController.m */; }; - FC4FA0231A1B8A8D00DA100A /* Socket.m in Sources */ = {isa = PBXBuildFile; fileRef = FC4FA0221A1B8A8D00DA100A /* Socket.m */; }; FC4FA0261A1B9DC600DA100A /* SignalsNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC4FA0251A1B9DC600DA100A /* SignalsNavigationController.m */; }; FC4FA0331A1D46AE00DA100A /* InitialViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC4FA0321A1D46AE00DA100A /* InitialViewController.m */; }; FCAC963519FEF4E20046DFC5 /* Storyboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FCAC963419FEF4E20046DFC5 /* Storyboard.storyboard */; }; FCAC963C19FEF9280046DFC5 /* SignalsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCAC963B19FEF9280046DFC5 /* SignalsViewController.m */; }; - FCAC964019FEF99A0046DFC5 /* TableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = FCAC963E19FEF99A0046DFC5 /* TableViewCell.m */; }; - FCAC964119FEF99A0046DFC5 /* TableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = FCAC963F19FEF99A0046DFC5 /* TableViewCell.xib */; }; - FCAC964419FEFD8B0046DFC5 /* DemoDataFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = FCAC964319FEFD8B0046DFC5 /* DemoDataFactory.m */; }; - FCAC964719FEFE1A0046DFC5 /* DemoDataModel.m in Sources */ = {isa = PBXBuildFile; fileRef = FCAC964619FEFE1A0046DFC5 /* DemoDataModel.m */; }; + FCAC964019FEF99A0046DFC5 /* InboxTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = FCAC963E19FEF99A0046DFC5 /* InboxTableViewCell.m */; }; + FCAC964119FEF99A0046DFC5 /* InboxTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = FCAC963F19FEF99A0046DFC5 /* InboxTableViewCell.xib */; }; FCAC965119FF0A6E0046DFC5 /* MessagesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCAC965019FF0A6E0046DFC5 /* MessagesViewController.m */; }; FCAFC33F1A0F948F00AE5136 /* ActionContactDetailCell.m in Sources */ = {isa = PBXBuildFile; fileRef = FCAFC33E1A0F948F00AE5136 /* ActionContactDetailCell.m */; }; FCB11D8A1A1284BB002F93FB /* SettingsTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = FCB11D891A1284BB002F93FB /* SettingsTableViewCell.m */; }; @@ -590,7 +591,6 @@ FCF72A131A02D27F006BC849 /* ContactDetailTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCF72A111A02D27F006BC849 /* ContactDetailTableViewController.m */; }; FCF72A161A02D2BB006BC849 /* ContactDetailCell.m in Sources */ = {isa = PBXBuildFile; fileRef = FCF72A151A02D2BB006BC849 /* ContactDetailCell.m */; }; FCFD256F1A151BCB00F4C644 /* NewGroupViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCFD256E1A151BCB00F4C644 /* NewGroupViewController.m */; }; - FCFD25721A1524DB00F4C644 /* GroupModel.m in Sources */ = {isa = PBXBuildFile; fileRef = FCFD25711A1524DB00F4C644 /* GroupModel.m */; }; FCFD257F1A154B2C00F4C644 /* RegistrationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCFD257E1A154B2C00F4C644 /* RegistrationViewController.m */; }; FCFD25821A154B3800F4C644 /* CodeVerificationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCFD25811A154B3800F4C644 /* CodeVerificationViewController.m */; }; /* End PBXBuildFile section */ @@ -1123,6 +1123,14 @@ B684A46C19C3446200B11029 /* PushManagerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PushManagerTest.m; path = Signal/test/push/PushManagerTest.m; sourceTree = SOURCE_ROOT; }; B6850E591995A4710068E715 /* whisperFake.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = whisperFake.cer; sourceTree = ""; }; B69CD25019773E79005CE69A /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; + B6AE33B51A1EB0AF003DF39D /* DemoDataFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoDataFactory.h; sourceTree = ""; }; + B6AE33B61A1EB0AF003DF39D /* DemoDataFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoDataFactory.m; sourceTree = ""; }; + B6AE33B71A1EB0AF003DF39D /* DemoDataModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoDataModel.h; sourceTree = ""; }; + B6AE33B81A1EB0AF003DF39D /* DemoDataModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoDataModel.m; sourceTree = ""; }; + B6AE33BB1A1EB121003DF39D /* GroupModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupModel.h; sourceTree = ""; }; + B6AE33BC1A1EB121003DF39D /* GroupModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GroupModel.m; sourceTree = ""; }; + B6AE33BE1A1EB2DD003DF39D /* Socket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Socket.h; sourceTree = ""; }; + B6AE33BF1A1EB2DD003DF39D /* Socket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Socket.m; sourceTree = ""; }; B6B095DE1A1D25C5008BFAA6 /* CryptographyTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CryptographyTests.mm; sourceTree = ""; }; B6B095DF1A1D25C5008BFAA6 /* TextSecureKitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TextSecureKitTests.m; sourceTree = ""; }; B6B095E01A1D25C5008BFAA6 /* TSMessageStorageTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSMessageStorageTests.m; sourceTree = ""; }; @@ -1231,8 +1239,8 @@ B6B0965E1A1D25ED008BFAA6 /* NSString+escape.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+escape.m"; sourceTree = ""; }; B6B0965F1A1D25ED008BFAA6 /* NSURLSessionDataTask+StatusCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSURLSessionDataTask+StatusCode.h"; sourceTree = ""; }; B6B096601A1D25ED008BFAA6 /* NSURLSessionDataTask+StatusCode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURLSessionDataTask+StatusCode.m"; sourceTree = ""; }; - B6B1013A196D213F007E3930 /* SGNKeychainUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SGNKeychainUtil.h; sourceTree = ""; }; - B6B1013B196D213F007E3930 /* SGNKeychainUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SGNKeychainUtil.m; sourceTree = ""; }; + B6B1013A196D213F007E3930 /* SignalKeyingStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SignalKeyingStorage.h; sourceTree = ""; }; + B6B1013B196D213F007E3930 /* SignalKeyingStorage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SignalKeyingStorage.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 = ""; }; B6C93C4C199567AD00EDF894 /* DebugLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebugLogger.h; sourceTree = ""; }; @@ -1350,8 +1358,6 @@ FC31962C1A06A2190094C78E /* FingerprintViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FingerprintViewController.m; sourceTree = ""; }; FC31962E1A0814130094C78E /* SettingsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsTableViewController.h; sourceTree = ""; }; FC31962F1A0814130094C78E /* SettingsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingsTableViewController.m; sourceTree = ""; }; - FC4FA0211A1B8A8D00DA100A /* Socket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Socket.h; sourceTree = ""; }; - FC4FA0221A1B8A8D00DA100A /* Socket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Socket.m; sourceTree = ""; }; FC4FA0241A1B9DC600DA100A /* SignalsNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SignalsNavigationController.h; sourceTree = ""; }; FC4FA0251A1B9DC600DA100A /* SignalsNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SignalsNavigationController.m; sourceTree = ""; }; FC4FA0311A1D46AE00DA100A /* InitialViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InitialViewController.h; sourceTree = ""; }; @@ -1359,13 +1365,9 @@ FCAC963419FEF4E20046DFC5 /* Storyboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Storyboard.storyboard; path = Signal/src/Storyboard/Storyboard.storyboard; sourceTree = SOURCE_ROOT; }; FCAC963A19FEF9280046DFC5 /* SignalsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SignalsViewController.h; path = UITests/SignalsViewController.h; sourceTree = ""; }; FCAC963B19FEF9280046DFC5 /* SignalsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SignalsViewController.m; path = UITests/SignalsViewController.m; sourceTree = ""; }; - FCAC963D19FEF99A0046DFC5 /* TableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableViewCell.h; sourceTree = ""; }; - FCAC963E19FEF99A0046DFC5 /* TableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TableViewCell.m; sourceTree = ""; }; - FCAC963F19FEF99A0046DFC5 /* TableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TableViewCell.xib; sourceTree = ""; }; - FCAC964219FEFD8B0046DFC5 /* DemoDataFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoDataFactory.h; sourceTree = ""; }; - FCAC964319FEFD8B0046DFC5 /* DemoDataFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoDataFactory.m; sourceTree = ""; }; - FCAC964519FEFE1A0046DFC5 /* DemoDataModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoDataModel.h; sourceTree = ""; }; - FCAC964619FEFE1A0046DFC5 /* DemoDataModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoDataModel.m; sourceTree = ""; }; + FCAC963D19FEF99A0046DFC5 /* InboxTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InboxTableViewCell.h; sourceTree = ""; }; + FCAC963E19FEF99A0046DFC5 /* InboxTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InboxTableViewCell.m; sourceTree = ""; }; + FCAC963F19FEF99A0046DFC5 /* InboxTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = InboxTableViewCell.xib; sourceTree = ""; }; FCAC964F19FF0A6E0046DFC5 /* MessagesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessagesViewController.h; sourceTree = ""; }; FCAC965019FF0A6E0046DFC5 /* MessagesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessagesViewController.m; sourceTree = ""; }; FCAFC33D1A0F948F00AE5136 /* ActionContactDetailCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionContactDetailCell.h; sourceTree = ""; }; @@ -1383,8 +1385,6 @@ FCF72A151A02D2BB006BC849 /* ContactDetailCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactDetailCell.m; sourceTree = ""; }; FCFD256D1A151BCB00F4C644 /* NewGroupViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewGroupViewController.h; sourceTree = ""; }; FCFD256E1A151BCB00F4C644 /* NewGroupViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewGroupViewController.m; sourceTree = ""; }; - FCFD25701A1524DB00F4C644 /* GroupModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupModel.h; sourceTree = ""; }; - FCFD25711A1524DB00F4C644 /* GroupModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GroupModel.m; sourceTree = ""; }; FCFD257D1A154B2C00F4C644 /* RegistrationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegistrationViewController.h; sourceTree = ""; }; FCFD257E1A154B2C00F4C644 /* RegistrationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RegistrationViewController.m; sourceTree = ""; }; FCFD25801A154B3800F4C644 /* CodeVerificationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeVerificationViewController.h; sourceTree = ""; }; @@ -1584,8 +1584,8 @@ 76EB041918170B33006006FC /* PropertyListPreferences.m */, 76EB041A18170B33006006FC /* Release.h */, 76EB041B18170B33006006FC /* Release.m */, - B6B1013A196D213F007E3930 /* SGNKeychainUtil.h */, - B6B1013B196D213F007E3930 /* SGNKeychainUtil.m */, + B6B1013A196D213F007E3930 /* SignalKeyingStorage.h */, + B6B1013B196D213F007E3930 /* SignalKeyingStorage.m */, B60C16631988999D00E97A6C /* VersionMigrations.h */, B60C16641988999D00E97A6C /* VersionMigrations.m */, ); @@ -2743,6 +2743,21 @@ name = Requests; sourceTree = ""; }; + B6AE33B41A1EB0A0003DF39D /* temp */ = { + isa = PBXGroup; + children = ( + B6AE33BB1A1EB121003DF39D /* GroupModel.h */, + B6AE33BC1A1EB121003DF39D /* GroupModel.m */, + B6AE33B51A1EB0AF003DF39D /* DemoDataFactory.h */, + B6AE33B61A1EB0AF003DF39D /* DemoDataFactory.m */, + B6AE33B71A1EB0AF003DF39D /* DemoDataModel.h */, + B6AE33B81A1EB0AF003DF39D /* DemoDataModel.m */, + B6AE33BE1A1EB2DD003DF39D /* Socket.h */, + B6AE33BF1A1EB2DD003DF39D /* Socket.m */, + ); + name = temp; + sourceTree = ""; + }; B6B095DD1A1D25C5008BFAA6 /* textsecure */ = { isa = PBXGroup; children = ( @@ -3221,7 +3236,7 @@ FCAC963919FEF8A00046DFC5 /* UI Tests */ = { isa = PBXGroup; children = ( - FCAC964819FEFE210046DFC5 /* DemoData */, + B6AE33B41A1EB0A0003DF39D /* temp */, FCAC964E19FF061C0046DFC5 /* ViewControllers */, FCAC964D19FF06110046DFC5 /* Views */, ); @@ -3229,29 +3244,14 @@ path = "view controllers"; sourceTree = ""; }; - FCAC964819FEFE210046DFC5 /* DemoData */ = { - isa = PBXGroup; - children = ( - FCAC964219FEFD8B0046DFC5 /* DemoDataFactory.h */, - FCAC964319FEFD8B0046DFC5 /* DemoDataFactory.m */, - FCAC964519FEFE1A0046DFC5 /* DemoDataModel.h */, - FCAC964619FEFE1A0046DFC5 /* DemoDataModel.m */, - FCFD25701A1524DB00F4C644 /* GroupModel.h */, - FCFD25711A1524DB00F4C644 /* GroupModel.m */, - FC4FA0211A1B8A8D00DA100A /* Socket.h */, - FC4FA0221A1B8A8D00DA100A /* Socket.m */, - ); - name = DemoData; - sourceTree = ""; - }; FCAC964D19FF06110046DFC5 /* Views */ = { isa = PBXGroup; children = ( FCF72A141A02D2BB006BC849 /* ContactDetailCell.h */, FCF72A151A02D2BB006BC849 /* ContactDetailCell.m */, - FCAC963D19FEF99A0046DFC5 /* TableViewCell.h */, - FCAC963E19FEF99A0046DFC5 /* TableViewCell.m */, - FCAC963F19FEF99A0046DFC5 /* TableViewCell.xib */, + FCAC963D19FEF99A0046DFC5 /* InboxTableViewCell.h */, + FCAC963E19FEF99A0046DFC5 /* InboxTableViewCell.m */, + FCAC963F19FEF99A0046DFC5 /* InboxTableViewCell.xib */, FCAFC33D1A0F948F00AE5136 /* ActionContactDetailCell.h */, FCAFC33E1A0F948F00AE5136 /* ActionContactDetailCell.m */, FCB11D881A1284BB002F93FB /* SettingsTableViewCell.h */, @@ -3514,7 +3514,7 @@ B633C5D91A1D190B0059AC12 /* settings.png in Resources */, B633C5FB1A1D190B0059AC12 /* volume_high.png in Resources */, B633C5971A1D190B0059AC12 /* delete@2x.png in Resources */, - FCAC964119FEF99A0046DFC5 /* TableViewCell.xib in Resources */, + FCAC964119FEF99A0046DFC5 /* InboxTableViewCell.xib in Resources */, B633C5E21A1D190B0059AC12 /* speaker_icon@2x.png in Resources */, B633C5A91A1D190B0059AC12 /* icon_favourites.png in Resources */, B66DBF4A19D5BBC8006EA940 /* Images.xcassets in Resources */, @@ -3718,6 +3718,7 @@ 76EB063E18170B33006006FC /* Operation.m in Sources */, 76EB05F618170B33006006FC /* CallConnectUtil.m in Sources */, 76EB061218170B33006006FC /* LoggingUtil.m in Sources */, + B6AE33B91A1EB0AF003DF39D /* DemoDataFactory.m in Sources */, 76EB060E18170B33006006FC /* DecayingSampleEstimator.m in Sources */, 76EB05BA18170B33006006FC /* CommitPacket.m in Sources */, 76EB060218170B33006006FC /* InitiatorSessionDescriptor.m in Sources */, @@ -3750,6 +3751,7 @@ B6B9ECFC198B31BA00C620D3 /* PushManager.m in Sources */, 76EB05D618170B33006006FC /* ZrtpResponder.m in Sources */, 7095B7B018F46D35002C66E2 /* PhoneNumberUtil.m in Sources */, + B6AE33C01A1EB2DD003DF39D /* Socket.m in Sources */, B6B096791A1D25ED008BFAA6 /* TSRecipientPrekeyRequest.m in Sources */, E197B61618BBEC1A00F073E5 /* StretchFactorController.m in Sources */, FCFD257F1A154B2C00F4C644 /* RegistrationViewController.m in Sources */, @@ -3767,6 +3769,7 @@ 76EB05F218170B33006006FC /* PhoneNumber.m in Sources */, E197B61718BBEC1A00F073E5 /* AnonymousAudioCallbackHandler.m in Sources */, 76EB05BC18170B33006006FC /* ConfirmAckPacket.m in Sources */, + B6AE33BA1A1EB0AF003DF39D /* DemoDataModel.m in Sources */, 76EB060C18170B33006006FC /* CategorizingLogger.m in Sources */, 76EB058A18170B33006006FC /* Release.m in Sources */, 76EB061018170B33006006FC /* EventWindow.m in Sources */, @@ -3780,6 +3783,7 @@ 76EB065A18170B34006006FC /* NextResponderScrollView.m in Sources */, 76EB062618170B33006006FC /* Queue.m in Sources */, D221A09A169C9E5E00537ABF /* main.m in Sources */, + B6AE33BD1A1EB121003DF39D /* GroupModel.m in Sources */, 76EB061618170B33006006FC /* AnonymousOccurrenceLogger.m in Sources */, 76EB063018170B33006006FC /* Conversions.m in Sources */, FCAFC33F1A0F948F00AE5136 /* ActionContactDetailCell.m in Sources */, @@ -3821,9 +3825,8 @@ B6B096851A1D25ED008BFAA6 /* TSSocketManager.m in Sources */, 76EB057618170B33006006FC /* Contact.m in Sources */, B6B0968F1A1D25ED008BFAA6 /* TSYapDatabaseObject.m in Sources */, - FCAC964719FEFE1A0046DFC5 /* DemoDataModel.m in Sources */, E197B61118BBEC1A00F073E5 /* AudioProcessor.m in Sources */, - FCAC964019FEF99A0046DFC5 /* TableViewCell.m in Sources */, + FCAC964019FEF99A0046DFC5 /* InboxTableViewCell.m in Sources */, 76EB05EA18170B33006006FC /* CallProgress.m in Sources */, 76EB05C218170B33006006FC /* DhPacketSharedSecretHashes.m in Sources */, B6B096701A1D25ED008BFAA6 /* TSInfoMessage.m in Sources */, @@ -3836,7 +3839,6 @@ E197B60C18BBEC1A00F073E5 /* AudioPacker.m in Sources */, E197B61218BBEC1A00F073E5 /* AudioStretcher.m in Sources */, 76EB05A218170B33006006FC /* IpEndPoint.m in Sources */, - FCFD25721A1524DB00F4C644 /* GroupModel.m in Sources */, E197B61A18BBEC1A00F073E5 /* SpeexCodec.m in Sources */, B6B0967F1A1D25ED008BFAA6 /* TSRequestAttachmentId.m in Sources */, 76EB05F018170B33006006FC /* PhoneManager.m in Sources */, @@ -3857,7 +3859,6 @@ B6B096881A1D25ED008BFAA6 /* TSStorageManager+keyFromIntLong.m in Sources */, 76EB059018170B33006006FC /* IgnoredPacketFailure.m in Sources */, 765052AF182AC9B5008313E1 /* DialerButtonView.m in Sources */, - FCAC964419FEFD8B0046DFC5 /* DemoDataFactory.m in Sources */, 76EB05D418170B33006006FC /* ZrtpManager.m in Sources */, 76EB058E18170B33006006FC /* HostNameEndPoint.m in Sources */, B6B096841A1D25ED008BFAA6 /* TSNetworkManager.m in Sources */, @@ -3885,7 +3886,6 @@ FCFD256F1A151BCB00F4C644 /* NewGroupViewController.m in Sources */, 76EB059E18170B33006006FC /* HttpSocket.m in Sources */, E197B60E18BBEC1A00F073E5 /* CallAudioManager.m in Sources */, - FC4FA0231A1B8A8D00DA100A /* Socket.m in Sources */, 76EB054018170B33006006FC /* AppDelegate.m in Sources */, 76EB05D018170B33006006FC /* ZrtpHandshakeSocket.m in Sources */, B63761EF19E1FBE8005735D1 /* HttpResponse.m in Sources */, @@ -3900,7 +3900,7 @@ 76EB057218170B33006006FC /* RecentCall.m in Sources */, 76EB060418170B33006006FC /* PhoneNumberDirectoryFilter.m in Sources */, B97CBFA818860EA3008E0DE9 /* CountryCodeViewController.m in Sources */, - B6B1013C196D213F007E3930 /* SGNKeychainUtil.m in Sources */, + B6B1013C196D213F007E3930 /* SignalKeyingStorage.m in Sources */, B6B0967E1A1D25ED008BFAA6 /* TSRequestAttachment.m in Sources */, 76EB059218170B33006006FC /* UnrecognizedRequestFailure.m in Sources */, 76EB05F818170B33006006FC /* CallConnectUtil_Initiator.m in Sources */, @@ -4606,6 +4606,7 @@ "$(inherited)", ); PRODUCT_NAME = SignalTests; + PROVISIONING_PROFILE = "a377b8e6-d43e-485d-8830-bc7bfa3d1731"; TEST_HOST = "$(BUNDLE_LOADER)"; VALID_ARCHS = "arm64 armv7s armv7 i386 x86_64"; }; @@ -4892,6 +4893,7 @@ "$(inherited)", ); PRODUCT_NAME = SignalTests; + PROVISIONING_PROFILE = "a377b8e6-d43e-485d-8830-bc7bfa3d1731"; TEST_HOST = "$(BUNDLE_LOADER)"; VALID_ARCHS = "arm64 armv7s armv7 i386 x86_64"; }; @@ -4939,6 +4941,7 @@ "$(inherited)", ); PRODUCT_NAME = SignalTests; + PROVISIONING_PROFILE = "a377b8e6-d43e-485d-8830-bc7bfa3d1731"; TEST_HOST = "$(BUNDLE_LOADER)"; VALID_ARCHS = "arm64 armv7s armv7 i386 x86_64"; }; diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index 31aa88476..85c59b48c 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -48,8 +48,6 @@ remote-notification voip - UILaunchStoryboardName - Storyboard UIRequiredDeviceCapabilities armv7 diff --git a/Signal/src/Storyboard/Storyboard.storyboard b/Signal/src/Storyboard/Storyboard.storyboard index bec089a38..341984788 100644 --- a/Signal/src/Storyboard/Storyboard.storyboard +++ b/Signal/src/Storyboard/Storyboard.storyboard @@ -1,5 +1,5 @@ - + @@ -1441,6 +1441,7 @@ Lorem ipsum : Quick explanation of Fingerprints + @@ -2253,9 +2254,6 @@ Lorem ipsum : Quick explanation of Fingerprints - - - @@ -2287,8 +2285,7 @@ Lorem ipsum : Quick explanation of Fingerprints - - + @@ -2371,14 +2368,14 @@ Lorem ipsum : Quick explanation of Fingerprints - - - - - + + + + + @@ -2388,14 +2385,14 @@ Lorem ipsum : Quick explanation of Fingerprints - - - - - + + + + + diff --git a/Signal/src/environment/Environment.m b/Signal/src/environment/Environment.m index 331c0ef30..b7ec65c28 100644 --- a/Signal/src/environment/Environment.m +++ b/Signal/src/environment/Environment.m @@ -9,7 +9,7 @@ #import "ContactsManager.h" #import "PreferencesUtil.h" #import "PhoneNumberDirectoryFilterManager.h" -#import "SGNKeychainUtil.h" +#import "SignalKeyingStorage.h" #define isRegisteredUserDefaultString @"isRegistered" @@ -149,10 +149,10 @@ phoneDirectoryManager; +(BOOL)isRegistered{ // Attributes that need to be set - NSData *signalingKey = SGNKeychainUtil.signalingCipherKey; - NSData *macKey = SGNKeychainUtil.signalingMacKey; - NSData *extra = SGNKeychainUtil.signalingExtraKey; - NSString *serverAuth = SGNKeychainUtil.serverAuthPassword; + NSData *signalingKey = SignalKeyingStorage.signalingCipherKey; + NSData *macKey = SignalKeyingStorage.signalingMacKey; + NSData *extra = SignalKeyingStorage.signalingExtraKey; + NSString *serverAuth = SignalKeyingStorage.serverAuthPassword; BOOL registered = [[NSUserDefaults.standardUserDefaults objectForKey:isRegisteredUserDefaultString] boolValue]; return signalingKey && macKey && extra && serverAuth && registered; @@ -167,7 +167,7 @@ phoneDirectoryManager; } +(void)resetAppData{ - [SGNKeychainUtil wipeKeychain]; + [SignalKeyingStorage wipeKeychain]; [Environment.preferences clear]; if (self.preferences.loggingIsEnabled) { [DebugLogger.sharedInstance wipeLogs]; diff --git a/Signal/src/environment/PropertyListPreferences.m b/Signal/src/environment/PropertyListPreferences.m index fcef4a274..d500a9448 100644 --- a/Signal/src/environment/PropertyListPreferences.m +++ b/Signal/src/environment/PropertyListPreferences.m @@ -1,6 +1,9 @@ #import "PropertyListPreferences.h" #import "Constraints.h" #import +#import "TSStorageManager.h" + +#define SignalDatabaseCollection @"SignalPreferences" @implementation PropertyListPreferences @@ -11,21 +14,16 @@ } } --(id) tryGetValueForKey:(NSString *)key { +- (id)tryGetValueForKey:(NSString *)key { require(key != nil); - @synchronized(self) { - return [NSUserDefaults.standardUserDefaults objectForKey:key]; - } + return [TSStorageManager.sharedManager objectForKey:key inCollection:SignalDatabaseCollection]; } --(void) setValueForKey:(NSString *)key toValue:(id)value { +- (void)setValueForKey:(NSString *)key toValue:(id)value { require(key != nil); - @synchronized(self) { - NSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults; - [userDefaults setObject:value forKey:key]; - [userDefaults synchronize]; - } + + [TSStorageManager.sharedManager setObject:value forKey:key inCollection:SignalDatabaseCollection]; } --(id) adjustAndTryGetNewValueForKey:(NSString *)key afterAdjuster:(id (^)(id))adjuster { +- (id)adjustAndTryGetNewValueForKey:(NSString *)key afterAdjuster:(id (^)(id))adjuster { require(key != nil); require(adjuster != nil); @synchronized(self) { diff --git a/Signal/src/environment/Release.m b/Signal/src/environment/Release.m index 7b208c536..0eec2ea25 100644 --- a/Signal/src/environment/Release.m +++ b/Signal/src/environment/Release.m @@ -46,13 +46,13 @@ static unsigned char DH3K_PRIME[]={ +(Environment*) releaseEnvironmentWithLogging:(id)logging { //ErrorHandlerBlock errorDiscarder = ^(id error, id relatedInfo, bool causedTermination) {}; - ErrorHandlerBlock errorNoter = ^(id error, id relatedInfo, bool causedTermination) { DDLogError(@"%@: %@, %d", error, relatedInfo, causedTermination); }; + ErrorHandlerBlock errorNoter = ^(id error, id relatedInfo, bool causedTermination) {DDLogError(@"%@: %@, %d", error, relatedInfo, causedTermination); }; return [Environment environmentWithLogging:logging andErrorNoter:errorNoter andServerPort:31337 - andMasterServerHostName:@"master.whispersystems.org" - andDefaultRelayName:@"relay" + andMasterServerHostName:@"testing.whispersystems.org" + andDefaultRelayName:@"testing" andRelayServerHostNameSuffix:@"whispersystems.org" andCertificate:[Certificate certificateFromResourcePath:@"whisperReal" ofType:@"cer"] andCurrentRegionCodeForPhoneNumbers:[(NSLocale*)NSLocale.currentLocale objectForKey:NSLocaleCountryCode] diff --git a/Signal/src/environment/SGNKeychainUtil.h b/Signal/src/environment/SignalKeyingStorage.h similarity index 90% rename from Signal/src/environment/SGNKeychainUtil.h rename to Signal/src/environment/SignalKeyingStorage.h index ede876c41..d7c209bb2 100644 --- a/Signal/src/environment/SGNKeychainUtil.h +++ b/Signal/src/environment/SignalKeyingStorage.h @@ -1,5 +1,5 @@ // -// SGNKeychainUtil.h +// SignalKeyingStorage.h // Signal // // Created by Frederic Jacobs on 09/07/14. @@ -10,7 +10,7 @@ #import "PhoneNumber.h" #import "Zid.h" -@interface SGNKeychainUtil : NSObject +@interface SignalKeyingStorage : NSObject +(void)generateSignaling; +(void)generateServerAuthPassword; diff --git a/Signal/src/environment/SGNKeychainUtil.m b/Signal/src/environment/SignalKeyingStorage.m similarity index 77% rename from Signal/src/environment/SGNKeychainUtil.m rename to Signal/src/environment/SignalKeyingStorage.m index 617afa940..de5762455 100644 --- a/Signal/src/environment/SGNKeychainUtil.m +++ b/Signal/src/environment/SignalKeyingStorage.m @@ -1,15 +1,15 @@ // -// SGNKeychainUtil.m +// SignalKeyingStorage.m // Signal // // Created by Frederic Jacobs on 09/07/14. // Copyright (c) 2014 Open Whisper Systems. All rights reserved. // #import "CryptoTools.h" -#import "SGNKeychainUtil.h" -#import +#import "SignalKeyingStorage.h" #import "Constraints.h" #import "Util.h" +#import "TSStorageManager.h" #define LOCAL_NUMBER_KEY @"Number" #define PASSWORD_COUNTER_KEY @"PasswordCounter" @@ -20,12 +20,14 @@ #define ZID_LENGTH 12 #define SIGNALING_EXTRA_KEY @"Signaling Extra Key" +#define SignalKeyingCollection @"SignalKeyingCollection" + #define SIGNALING_MAC_KEY_LENGTH 20 #define SIGNALING_CIPHER_KEY_LENGTH 16 #define SAVED_PASSWORD_LENGTH 18 #define SIGNALING_EXTRA_KEY_LENGTH 4 -@implementation SGNKeychainUtil +@implementation SignalKeyingStorage + (void)generateServerAuthPassword{ [self storeString:[[CryptoTools generateSecureRandomData:SAVED_PASSWORD_LENGTH] encodedAsBase64] forKey:SAVED_PASSWORD_KEY]; @@ -39,12 +41,12 @@ } +(void)wipeKeychain{ - [UICKeyChainStore removeAllItems]; + [TSStorageManager.sharedManager purgeCollection:SignalKeyingCollection]; } +(int64_t) getAndIncrementOneTimeCounter { __block int64_t oldCounter; - oldCounter = [[UICKeyChainStore stringForKey:PASSWORD_COUNTER_KEY] longLongValue]; + oldCounter = [[self stringForKey:PASSWORD_COUNTER_KEY] longLongValue]; int64_t newCounter = (oldCounter == INT64_MAX)?INT64_MIN:(oldCounter + 1); [self storeString:[@(newCounter) stringValue] forKey:PASSWORD_COUNTER_KEY]; return newCounter; @@ -98,12 +100,8 @@ #pragma mark Keychain wrapper methods -+(BOOL)storeData:(NSData*)data forKey:(NSString*)key{ - BOOL success = [UICKeyChainStore setData:data forKey:key]; - if (!success) { - DDLogError(@"Failed to set value for key: %@", key); - } - return success; ++(void)storeData:(NSData*)data forKey:(NSString*)key{ + [TSStorageManager.sharedManager setObject:data forKey:key inCollection:SignalKeyingCollection]; } +(NSData*)dataForKey:(NSString*)key andVerifyLength:(uint)length{ @@ -117,28 +115,15 @@ } +(NSData*)dataForKey:(NSString*)key{ - NSData *data = [UICKeyChainStore dataForKey:key]; - if (!data) { - DDLogError(@"Failed to get value for key: %@", key); - } - return data; + return [TSStorageManager.sharedManager dataForKey:key inCollection:SignalKeyingCollection]; } +(NSString*)stringForKey:(NSString*)key{ - NSString *string = [UICKeyChainStore stringForKey:key]; - if (!string) { - DDLogError(@"Failed to get value for key: %@", key); - } - return string; + return [TSStorageManager.sharedManager stringForKey:key inCollection:SignalKeyingCollection]; } -+(BOOL)storeString:(NSString*)string forKey:(NSString*)key{ - BOOL success = [UICKeyChainStore setString:string forKey:key]; - - if (!success) { - DDLogError(@"Failed to set value for key: %@", key); - } - return success; ++(void)storeString:(NSString*)string forKey:(NSString*)key{ + [TSStorageManager.sharedManager setObject:string forKey:key inCollection:SignalKeyingCollection]; } @end diff --git a/Signal/src/network/PushManager.m b/Signal/src/network/PushManager.m index aee567bb7..1e32570dd 100644 --- a/Signal/src/network/PushManager.m +++ b/Signal/src/network/PushManager.m @@ -9,6 +9,7 @@ #import "PushManager.h" #import "Environment.h" #import "RPServerRequestsManager.h" +#import "TSAccountManager.h" @interface PushManager () diff --git a/Signal/src/network/http/HttpRequestUtil.m b/Signal/src/network/http/HttpRequestUtil.m index 57eadaebb..ddfba2278 100644 --- a/Signal/src/network/http/HttpRequestUtil.m +++ b/Signal/src/network/http/HttpRequestUtil.m @@ -2,7 +2,7 @@ #import "Constraints.h" #import "PreferencesUtil.h" #import "Util.h" -#import "SGNKeychainUtil.h" +#import "SignalKeyingStorage.h" @implementation HttpRequest (HttpRequestUtil) @@ -18,8 +18,8 @@ return [HttpRequest httpRequestWithBasicAuthenticationAndMethod:method andLocation:location andOptionalBody:optionalBody - andLocalNumber:SGNKeychainUtil.localNumber - andPassword:SGNKeychainUtil.serverAuthPassword]; + andLocalNumber:SignalKeyingStorage.localNumber + andPassword:SignalKeyingStorage.serverAuthPassword]; } +(HttpRequest*)httpRequestWithOtpAuthenticationAndMethod:(NSString*)method andLocation:(NSString*)location { @@ -33,9 +33,9 @@ return [HttpRequest httpRequestWithOtpAuthenticationAndMethod:method andLocation:location andOptionalBody:optionalBody - andLocalNumber:SGNKeychainUtil.localNumber - andPassword:SGNKeychainUtil.serverAuthPassword - andCounter:[SGNKeychainUtil getAndIncrementOneTimeCounter]]; + andLocalNumber:SignalKeyingStorage.localNumber + andPassword:SignalKeyingStorage.serverAuthPassword + andCounter:[SignalKeyingStorage getAndIncrementOneTimeCounter]]; } +(HttpRequest*)httpRequestUnauthenticatedWithMethod:(NSString*)method andLocation:(NSString*)location { diff --git a/Signal/src/network/http/RPAPICall.m b/Signal/src/network/http/RPAPICall.m index 61dcc2c58..b5097a88b 100644 --- a/Signal/src/network/http/RPAPICall.m +++ b/Signal/src/network/http/RPAPICall.m @@ -11,7 +11,7 @@ #import "PhoneNumber.h" #import "RPAPICall.h" #import "SignalUtil.h" -#import "SGNKeychainUtil.h" +#import "SignalKeyingStorage.h" #import "Util.h" #define CLAIMED_INTEROP_VERSION_IN_INITIATE_SIGNAL 1 @@ -36,7 +36,7 @@ + (RPAPICall*)requestVerificationCode { - [SGNKeychainUtil generateServerAuthPassword]; + [SignalKeyingStorage generateServerAuthPassword]; RPAPICall *apiCall = [self defaultAPICall]; apiCall.method = HTTP_GET; apiCall.endPoint = @"/users/verification"; @@ -51,14 +51,13 @@ + (RPAPICall*)verifyVerificationCode:(NSString*)verificationCode { RPAPICall *apiCall = [self defaultAPICall]; - [SGNKeychainUtil generateSignaling]; + [SignalKeyingStorage generateSignaling]; apiCall.method = HTTP_PUT; - apiCall.endPoint = [NSString stringWithFormat:@"/users/verification/%@", SGNKeychainUtil.localNumber]; + apiCall.endPoint = [NSString stringWithFormat:@"/users/verification/%@", SignalKeyingStorage.localNumber]; - NSData* signalingCipherKey = SGNKeychainUtil.signalingCipherKey; - NSData* signalingMacKey = SGNKeychainUtil.signalingMacKey; - NSData* signalingExtraKeyData = SGNKeychainUtil.signalingCipherKey; - + NSData* signalingCipherKey = SignalKeyingStorage.signalingCipherKey; + NSData* signalingMacKey = SignalKeyingStorage.signalingMacKey; + NSData* signalingExtraKeyData = SignalKeyingStorage.signalingCipherKey; NSString* encodedSignalingKey = @[signalingCipherKey, signalingMacKey, signalingExtraKeyData].ows_concatDatas.encodedAsBase64; apiCall.parameters = @{@"key" : encodedSignalingKey, @"challenge" : verificationCode}; @@ -138,13 +137,13 @@ + (AFHTTPRequestSerializer*)basicAuthenticationSerializer { AFHTTPRequestSerializer *serializer = [AFJSONRequestSerializer serializerWithWritingOptions:0]; - [serializer setValue:[self computeBasicAuthorizationTokenForLocalNumber:SGNKeychainUtil.localNumber andPassword:SGNKeychainUtil.serverAuthPassword]forHTTPHeaderField:@"Authorization"]; + [serializer setValue:[self computeBasicAuthorizationTokenForLocalNumber:SignalKeyingStorage.localNumber andPassword:SignalKeyingStorage.serverAuthPassword]forHTTPHeaderField:@"Authorization"]; return serializer; } + (AFHTTPRequestSerializer*)otpAuthenticationSerializer { AFHTTPRequestSerializer *serializer = [AFJSONRequestSerializer serializerWithWritingOptions:0]; - [serializer setValue:[self computeOtpAuthorizationTokenForLocalNumber:SGNKeychainUtil.localNumber andCounterValue:[SGNKeychainUtil getAndIncrementOneTimeCounter] andPassword:SGNKeychainUtil.serverAuthPassword] forHTTPHeaderField:@"Authorization"]; + [serializer setValue:[self computeOtpAuthorizationTokenForLocalNumber:SignalKeyingStorage.localNumber andCounterValue:[SignalKeyingStorage getAndIncrementOneTimeCounter] andPassword:SignalKeyingStorage.serverAuthPassword] forHTTPHeaderField:@"Authorization"]; return serializer; } diff --git a/Signal/src/network/http/RPServerRequestsManager.m b/Signal/src/network/http/RPServerRequestsManager.m index bfc4ae8b7..394144122 100644 --- a/Signal/src/network/http/RPServerRequestsManager.m +++ b/Signal/src/network/http/RPServerRequestsManager.m @@ -12,7 +12,7 @@ #import "DataUtil.h" #import "Environment.h" #import "HostNameEndPoint.h" -#import "SGNKeychainUtil.h" +#import "SignalKeyingStorage.h" #import "Util.h" #import "AFHTTPSessionManager+SignalMethods.h" diff --git a/Signal/src/network/rtp/zrtp/ZrtpInitiator.m b/Signal/src/network/rtp/zrtp/ZrtpInitiator.m index 62b81fa7a..418a7b853 100644 --- a/Signal/src/network/rtp/zrtp/ZrtpInitiator.m +++ b/Signal/src/network/rtp/zrtp/ZrtpInitiator.m @@ -7,7 +7,7 @@ #import "Util.h" #import "ZrtpInitiator.h" #import "PreferencesUtil.h" -#import "SGNKeychainUtil.h" +#import "SignalKeyingStorage.h" #define DHRS1_LENGTH 8 #define DHRS2_LENGTH 8 @@ -24,7 +24,7 @@ s->allowedKeyAgreementProtocols = Environment.getCurrent.keyAgreementProtocolsInDescendingPriority; s->dhSharedSecretHashes = [DhPacketSharedSecretHashes dhPacketSharedSecretHashesRandomized]; - s->zid = [SGNKeychainUtil zid]; + s->zid = [SignalKeyingStorage zid]; s->confirmIv = [CryptoTools generateSecureRandomData:IV_LENGTH]; s->hashChain = [HashChain hashChainWithSecureGeneratedData]; s->badPacketLogger = [Environment.logging getOccurrenceLoggerForSender:self withKey:@"Bad Packet"]; diff --git a/Signal/src/network/rtp/zrtp/ZrtpResponder.m b/Signal/src/network/rtp/zrtp/ZrtpResponder.m index 819dfa1dc..73faa9137 100644 --- a/Signal/src/network/rtp/zrtp/ZrtpResponder.m +++ b/Signal/src/network/rtp/zrtp/ZrtpResponder.m @@ -8,7 +8,7 @@ #import "ZrtpResponder.h" #import "HelloAckPacket.h" #import "ConfirmAckPacket.h" -#import "SGNKeychainUtil.h" +#import "SignalKeyingStorage.h" #define DHRS1_LENGTH 8 #define DHRS2_LENGTH 8 @@ -30,7 +30,7 @@ s->badPacketLogger = [Environment.logging getOccurrenceLoggerForSender:self withKey:@"Bad Packet"]; s->localHello = [HelloPacket helloPacketWithDefaultsAndHashChain:s->hashChain - andZid:[SGNKeychainUtil zid] + andZid:[SignalKeyingStorage zid] andKeyAgreementProtocols:s->allowedKeyAgreementProtocols]; s->packetExpectation = EXPECTING_HELLO; s->callController = callController; diff --git a/Signal/src/phone/signaling/ResponderSessionDescriptor.m b/Signal/src/phone/signaling/ResponderSessionDescriptor.m index 602f1f68f..a448eee3a 100644 --- a/Signal/src/phone/signaling/ResponderSessionDescriptor.m +++ b/Signal/src/phone/signaling/ResponderSessionDescriptor.m @@ -5,7 +5,7 @@ #import "PreferencesUtil.h" #import "Util.h" #import "InitiateSignal.pb.h" -#import "SGNKeychainUtil.h" +#import "SignalKeyingStorage.h" #define MessagePropertyKey @"m" #define RelayPortKey @"p" @@ -89,7 +89,7 @@ checkOperation(data.length >= HMAC_TRUNCATED_SIZE); NSData* includedMac = [data takeLast:HMAC_TRUNCATED_SIZE]; NSData* payload = [data skipLast:HMAC_TRUNCATED_SIZE]; - NSData* signalingMacKey = SGNKeychainUtil.signalingMacKey; + NSData* signalingMacKey = SignalKeyingStorage.signalingMacKey; require(signalingMacKey != nil); NSData* computedMac = [[payload hmacWithSha1WithKey:signalingMacKey] takeLast:HMAC_TRUNCATED_SIZE]; checkOperation([includedMac isEqualToData_TimingSafe:computedMac]); @@ -98,7 +98,7 @@ +(NSData*) decryptRemoteNotificationData:(NSData*)data { require(data != nil); checkOperation(data.length >= VERSION_SIZE + IV_SIZE); - NSData* cipherKey = SGNKeychainUtil.signalingCipherKey; + NSData* cipherKey = SignalKeyingStorage.signalingCipherKey; require(cipherKey != nil); NSData* iv = [data subdataWithRange:NSMakeRange(VERSION_SIZE, IV_SIZE)]; NSData* cipherText = [data skip:VERSION_SIZE+IV_SIZE]; diff --git a/Signal/src/phone/signaling/SignalUtil.m b/Signal/src/phone/signaling/SignalUtil.m index adffde096..cad644fb8 100644 --- a/Signal/src/phone/signaling/SignalUtil.m +++ b/Signal/src/phone/signaling/SignalUtil.m @@ -4,7 +4,7 @@ #import "Environment.h" #import "PreferencesUtil.h" #import "Util.h" -#import "SGNKeychainUtil.h" +#import "SignalKeyingStorage.h" #define CLAIMED_INTEROP_VERSION_IN_INITIATE_SIGNAL 1 @@ -80,13 +80,14 @@ +(HttpRequest*) httpRequestToVerifyAccessToPhoneNumberWithChallenge:(NSString*)challenge { require(challenge != nil); - PhoneNumber* localPhoneNumber = SGNKeychainUtil.localNumber; + PhoneNumber* localPhoneNumber = SignalKeyingStorage.localNumber; NSString* query = [NSString stringWithFormat:@"/users/verification/%@", localPhoneNumber.toE164]; - [SGNKeychainUtil generateSignaling]; + [SignalKeyingStorage generateSignaling]; + + NSData* signalingCipherKey = SignalKeyingStorage.signalingCipherKey; + NSData* signalingMacKey = SignalKeyingStorage.signalingMacKey; + NSData* signalingExtraKeyData = SignalKeyingStorage.signalingCipherKey; - NSData* signalingCipherKey = SGNKeychainUtil.signalingCipherKey; - NSData* signalingMacKey = SGNKeychainUtil.signalingMacKey; - NSData* signalingExtraKeyData = SGNKeychainUtil.signalingCipherKey; NSString* encodedSignalingKey = @[signalingCipherKey, signalingMacKey, signalingExtraKeyData].ows_concatDatas.encodedAsBase64; NSString* body = @{@"key" : encodedSignalingKey, @"challenge" : challenge}.encodedAsJson; diff --git a/Signal/src/textsecure/Account/TSAccountManager.m b/Signal/src/textsecure/Account/TSAccountManager.m index 89b1fb565..501a30741 100644 --- a/Signal/src/textsecure/Account/TSAccountManager.m +++ b/Signal/src/textsecure/Account/TSAccountManager.m @@ -67,8 +67,6 @@ return registrationID; } -#if TARGET_OS_IPHONE - + (void)registerForPushNotifications:(NSData *)pushToken success:(successCompletionBlock)success failure:(failedVerificationBlock)failureBlock{ NSString *stringToken = [[pushToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<> "]]; @@ -91,13 +89,11 @@ } + (void)registerWithRedPhoneToken:(NSString*)tsToken pushToken:(NSData*)pushToken success:(successCompletionBlock)successBlock failure:(failedVerificationBlock)failureBlock{ - NSLog(@"PushToken:%@ TStoken: %@", pushToken, tsToken); NSString *authToken = [self generateNewAccountAuthenticationToken]; NSString *signalingKey = [self generateNewSignalingKeyToken]; NSString *phoneNumber = [[tsToken componentsSeparatedByString:@":"] objectAtIndex:0]; - NSLog(@"Phone Number %@", phoneNumber); - + require(phoneNumber != nil); require(signalingKey != nil); require(authToken != nil); @@ -113,21 +109,28 @@ if (statuscode == 200 || statuscode == 204) { [TSStorageManager storeServerToken:authToken signalingKey:signalingKey phoneNumber:phoneNumber]; + [self registerPreKeys:successBlock failure:failureBlock]; - [self registerForPushNotifications:pushToken success:^{ - successBlock(); - } failure:^(TSRegistrationFailure failureType) { - failureBlock(kTSRegistrationFailureNetwork); - }]; } else{ failureBlock(kTSRegistrationFailureNetwork); } } failure:^(NSURLSessionDataTask *task, NSError *error) { + //TODO: Cover all error types: https://github.com/WhisperSystems/TextSecure-Server/wiki/API-Protocol failureBlock(kTSRegistrationFailureNetwork); }]; } ++ (void)registerPreKeysAfterPush:(NSData*)pushToken + success:(successCompletionBlock)successBlock + failure:(failedVerificationBlock)failureBlock +{ + [self registerForPushNotifications:pushToken success:^{ + [self registerPreKeys:successBlock + failure:failureBlock]; + } failure:failureBlock]; +} + + (void)registerPreKeys:(successCompletionBlock)successBlock failure:(failedVerificationBlock)failureBlock { [TSPreKeyManager registerPreKeysWithSuccess:^{ [TSAccountManager setRegistered:YES]; @@ -135,7 +138,6 @@ } failure:failureBlock]; } - #pragma mark Server keying material + (NSString*)generateNewAccountAuthenticationToken { @@ -152,6 +154,4 @@ } -#endif - @end diff --git a/Signal/src/textsecure/Contacts/TSThread.h b/Signal/src/textsecure/Contacts/TSThread.h index e483d037c..6578569f2 100644 --- a/Signal/src/textsecure/Contacts/TSThread.h +++ b/Signal/src/textsecure/Contacts/TSThread.h @@ -25,7 +25,24 @@ - (BOOL)isGroupThread; -@property (getter=isBlocked) BOOL blocked; -@property (nonatomic, copy) NSDate *lastMessageDate; +/** + * Returns the name of the thread. + * + * @return name of the thread + */ + +- (NSString*)name; + +/** + * Returns the image representing the thread. Nil if not available. + * + * @return UIImage of the thread, or nil. + */ + +- (UIImage*)image; + +@property (getter=isBlocked) BOOL blocked; +@property (nonatomic) uint64_t lastMessageId; +- (NSDate*)lastMessageDate; @end diff --git a/Signal/src/textsecure/Messages/TSInteraction.h b/Signal/src/textsecure/Messages/TSInteraction.h index ca4cd39d6..f368e1288 100644 --- a/Signal/src/textsecure/Messages/TSInteraction.h +++ b/Signal/src/textsecure/Messages/TSInteraction.h @@ -34,5 +34,4 @@ extern const struct TSMessageEdges { #pragma mark Utility Method + (NSString*)stringFromTimeStamp:(uint64_t)timestamp; - @end diff --git a/Signal/src/textsecure/Network/Requests/TSContactsIntersectionRequest.h b/Signal/src/textsecure/Network/Requests/TSContactsIntersectionRequest.h index 36b187ddd..7a794bc98 100644 --- a/Signal/src/textsecure/Network/Requests/TSContactsIntersectionRequest.h +++ b/Signal/src/textsecure/Network/Requests/TSContactsIntersectionRequest.h @@ -12,4 +12,4 @@ - (id)initWithHashesArray:(NSArray*)hashes; -@end \ No newline at end of file +@end diff --git a/Signal/src/textsecure/Storage/TSStorageManager.m b/Signal/src/textsecure/Storage/TSStorageManager.m index 1bc41ab17..fb7994aef 100644 --- a/Signal/src/textsecure/Storage/TSStorageManager.m +++ b/Signal/src/textsecure/Storage/TSStorageManager.m @@ -20,6 +20,7 @@ static NSString * keychainDBPassAccount = @"TSDatabasePass"; @interface TSStorageManager () @property YapDatabase *database; +@property YapDatabaseConnection *dbConnection; @end @@ -34,6 +35,40 @@ static NSString * keychainDBPassAccount = @"TSDatabasePass"; return sharedMyManager; } +- (instancetype)init { + self = [super init]; + + if (self) { + self.database = [self newDatabaseInit]; + self.dbConnection = self.databaseConnection; + } + + return self; +} + +- (YapDatabase*)newDatabaseInit{ + YapDatabaseOptions *options = [[YapDatabaseOptions alloc] init]; + options.corruptAction = YapDatabaseCorruptAction_Fail; + options.passphraseBlock = ^{ + return [self databasePassword]; + }; + + return [[YapDatabase alloc] initWithPath:[self dbPath] + objectSerializer:NULL + objectDeserializer:NULL + metadataSerializer:NULL + metadataDeserializer:NULL + objectSanitizer:NULL + metadataSanitizer:NULL + options:options]; + + +} + +- (YapDatabaseConnection *)databaseConnection { + return self.database.newConnection; +} + - (BOOL)userSetPassword { return FALSE; } @@ -80,70 +115,30 @@ static NSString * keychainDBPassAccount = @"TSDatabasePass"; return dbPassword; } -- (instancetype)init { - self = [super init]; - - if (self) { - self.database = [self newDatabaseInit]; - } - - return self; -} - -- (YapDatabase*)newDatabaseInit{ - YapDatabaseOptions *options = [[YapDatabaseOptions alloc] init]; - options.corruptAction = YapDatabaseCorruptAction_Fail; - options.passphraseBlock = ^{ - return [self databasePassword]; - }; - - return [[YapDatabase alloc] initWithPath:[self dbPath] - objectSerializer:NULL - objectDeserializer:NULL - metadataSerializer:NULL - metadataDeserializer:NULL - objectSanitizer:NULL - metadataSanitizer:NULL - options:options]; - - -} - -- (YapDatabaseConnection *)databaseConnection { - return self.database.newConnection; -} - #pragma mark convenience methods - (void)purgeCollection:(NSString*)collection { - YapDatabaseConnection *dbConn = [self databaseConnection]; - - [dbConn readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { + [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [transaction removeAllObjectsInCollection:collection]; }]; } - (void)setObject:(id)object forKey:(NSString*)key inCollection:(NSString*)collection { - YapDatabaseConnection *dbConn = [self databaseConnection]; - - [dbConn readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { + [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [transaction setObject:object forKey:key inCollection:collection]; }]; } - (void)removeObjectForKey:(NSString*)string inCollection:(NSString *)collection{ - YapDatabaseConnection *dbConn = [self databaseConnection]; - - [dbConn readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { + [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [transaction removeObjectForKey:string inCollection:collection]; }]; } - (id)objectForKey:(NSString*)key inCollection:(NSString *)collection { - YapDatabaseConnection *dbConn = [self databaseConnection]; __block NSString *object; - [dbConn readWithBlock:^(YapDatabaseReadTransaction *transaction) { + [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { object = [transaction objectForKey:key inCollection:collection]; }]; @@ -151,10 +146,9 @@ static NSString * keychainDBPassAccount = @"TSDatabasePass"; } - (NSDictionary*)dictionaryForKey:(NSString*)key inCollection:(NSString *)collection { - YapDatabaseConnection *dbConn = [self databaseConnection]; __block NSDictionary *object; - [dbConn readWithBlock:^(YapDatabaseReadTransaction *transaction) { + [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { object = [transaction objectForKey:key inCollection:collection]; }]; @@ -216,6 +210,7 @@ static NSString * keychainDBPassAccount = @"TSDatabasePass"; } self.database = [self newDatabaseInit]; + self.dbConnection = self.databaseConnection; } @end diff --git a/Signal/src/textsecure/Storage/TSYapDatabaseObject.m b/Signal/src/textsecure/Storage/TSYapDatabaseObject.m index 4ed440fc6..d18cd1188 100644 --- a/Signal/src/textsecure/Storage/TSYapDatabaseObject.m +++ b/Signal/src/textsecure/Storage/TSYapDatabaseObject.m @@ -49,7 +49,7 @@ } -#pragma - mark Class Methods +#pragma mark Class Methods + (NSString *)collection{ return NSStringFromClass([self class]); diff --git a/Signal/src/textsecure/TSConstants.h b/Signal/src/textsecure/TSConstants.h index 06460e559..46f98ab1c 100644 --- a/Signal/src/textsecure/TSConstants.h +++ b/Signal/src/textsecure/TSConstants.h @@ -29,7 +29,7 @@ typedef enum { #define textSecureHTTPTimeOut 10 -#define textSecureWebSocketAPI @"wss://textsecure-service.whispersystems.org/v1/websocket/" +#define textSecureWebSocketAPI @"wss://textsecure-service-staging.whispersystems.org/v1/websocket/" //#define textSecureServerURL @"https://textsecure-service.whispersystems.org/" #define textSecureServerURL @"https://textsecure-service-staging.whispersystems.org/" diff --git a/Signal/src/view controllers/CodeVerificationViewController.m b/Signal/src/view controllers/CodeVerificationViewController.m index 1b83b8cee..eeee8727d 100644 --- a/Signal/src/view controllers/CodeVerificationViewController.m +++ b/Signal/src/view controllers/CodeVerificationViewController.m @@ -11,7 +11,7 @@ #import "RPServerRequestsManager.h" #import "LocalizableText.h" #import "PushManager.h" -#import "SGNKeychainUtil.h" +#import "SignalKeyingStorage.h" #import "TSAccountManager.h" @interface CodeVerificationViewController () @@ -36,19 +36,32 @@ - (IBAction)verifyChallengeAction:(id)sender { [_challengeTextField resignFirstResponder]; - //TODO: Lock UI interactions + [self registerWithSuccess:^{ + [self performSegueWithIdentifier:@"verifiedSegue" sender:self]; + } failure:^{ + // TODO: Unlock UI + NSLog(@"Failed to register"); + }]; +} + + +- (void)registerWithSuccess:(void(^)())success failure:(void(^)())failure{ + //TODO: Refactor this to use futures? Better error handling needed. Good enough for PoC + [[RPServerRequestsManager sharedInstance] performRequest:[RPAPICall verifyVerificationCode:_challengeTextField.text] success:^(NSURLSessionDataTask *task, id responseObject) { [PushManager.sharedManager registrationAndRedPhoneTokenRequestWithSuccess:^(NSData *pushToken, NSString *signupToken) { + [TSAccountManager registerWithRedPhoneToken:signupToken pushToken:pushToken success:^{ - [self performSegueWithIdentifier:@"verifiedSegue" sender:self]; + success(); } failure:^(TSRegistrationFailure failureType) { - NSLog(@":("); + failure(); }]; + } failure:^{ - + failure(); }]; } failure:^(NSURLSessionDataTask *task, NSError *error) { NSString *alertTitle = NSLocalizedString(@"REGISTRATION_ERROR", @""); @@ -65,6 +78,7 @@ }]; } + #pragma mark - Keyboard notifications - (void)initializeKeyboardHandlers{ @@ -77,14 +91,4 @@ [self.view endEditing:NO]; } -/* -#pragma mark - Navigation - -// In a storyboard-based application, you will often want to do a little preparation before navigation -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. -} -*/ - @end diff --git a/Signal/src/view controllers/ContactsTableViewController.h b/Signal/src/view controllers/ContactsTableViewController.h index 1ab476fdd..5d7b409d6 100644 --- a/Signal/src/view controllers/ContactsTableViewController.h +++ b/Signal/src/view controllers/ContactsTableViewController.h @@ -10,4 +10,6 @@ @interface ContactsTableViewController : UITableViewController +@property (nonatomic, strong) IBOutlet UITableView *contactTableView; + @end diff --git a/Signal/src/view controllers/ContactsTableViewController.m b/Signal/src/view controllers/ContactsTableViewController.m index fb3d6c106..afa7d1bdd 100644 --- a/Signal/src/view controllers/ContactsTableViewController.m +++ b/Signal/src/view controllers/ContactsTableViewController.m @@ -15,24 +15,26 @@ #import "Environment.h" #import "Contact.h" #import "ContactsManager.h" +#import "LocalizableText.h" #import "PhoneNumberDirectoryFilterManager.h" - -#import "DemoDataFactory.h" +#import "NotificationManifest.h" #import +#define REFRESH_TIMEOUT 20 + static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableViewCell"; @interface ContactsTableViewController () { - NSMutableDictionary *latestAlphabeticalContacts; - NSArray *latestSortedAlphabeticalContactKeys; - NSArray * latestContacts; - - NSArray * searchResults; + NSDictionary *latestAlphabeticalContacts; + NSArray *searchResults; } + +@property NSArray *latestSortedAlphabeticalContactKeys; +@property NSArray *latestContacts; @property (nonatomic, strong) UISearchController *searchController; @end @@ -44,13 +46,19 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; - //Hide search bar + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contactsDidRefresh) name:NOTIFICATION_DIRECTORY_WAS_UPDATED object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contactRefreshFailed) name:NOTIFICATION_DIRECTORY_FAILED object:nil]; + UIRefreshControl *refreshControl = [[UIRefreshControl alloc] + init]; + [refreshControl addTarget:self action:@selector(refreshContacts) forControlEvents:UIControlEventValueChanged]; + self.refreshControl = refreshControl; + [self.contactTableView addSubview:self.refreshControl]; + self.tableView.contentOffset = CGPointMake(0, 44); [self initializeSearch]; - + [self setupContacts]; - searchResults = latestContacts; [self.tableView reloadData]; } @@ -105,45 +113,24 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView - (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope { NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"fullName contains[c] %@", searchText]; - searchResults = [latestContacts filteredArrayUsingPredicate:resultPredicate]; - if (!searchResults.count && _searchController.searchBar.text.length == 0) searchResults = latestContacts; + searchResults = [self.latestContacts filteredArrayUsingPredicate:resultPredicate]; + if (!searchResults.count && _searchController.searchBar.text.length == 0) searchResults = self.latestContacts; } #pragma mark - Contact functions - (void)setupContacts { - // ObservableValue *observableContacts = Environment.getCurrent.contactsManager.getObservableWhisperUsers; - // - // [observableContacts watchLatestValue:^(NSArray *latestContacts) { - // _latestContacts = latestContacts; - // } onThread:NSThread.mainThread untilCancelled:nil]; - - latestContacts = [DemoDataFactory makeFakeContacts]; - - NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"firstName" ascending:YES]; - NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor]; - latestSortedAlphabeticalContactKeys = [latestContacts sortedArrayUsingDescriptors:sortDescriptors]; - - latestAlphabeticalContacts = [self alphabetDictionaryInit]; - - for (Contact*contact in latestContacts) - { - NSString * firstLetter = [contact.firstName substringToIndex:1]; - - NSMutableArray * mutArray = [[latestAlphabeticalContacts objectForKey:firstLetter] mutableCopy]; - if (![mutArray containsObject:contact]) - [mutArray addObject:contact]; - [latestAlphabeticalContacts setObject:mutArray forKey:firstLetter]; - - } - - latestSortedAlphabeticalContactKeys = [[latestAlphabeticalContacts allKeys]sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; + ObservableValue *observableContacts = Environment.getCurrent.contactsManager.getObservableWhisperUsers; + [observableContacts watchLatestValue:^(NSArray *latestContacts) { + _latestContacts = latestContacts; + [self onSearchOrContactChange:nil]; + } onThread:NSThread.mainThread untilCancelled:nil]; } - (NSArray *)contactsForSectionIndex:(NSUInteger)index { - return [latestAlphabeticalContacts valueForKey:latestSortedAlphabeticalContactKeys[index]]; + return [latestAlphabeticalContacts valueForKey:self.latestSortedAlphabeticalContactKeys[index]]; } @@ -177,8 +164,7 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView @"W": @[], @"X": @[], @"Y": @[], - @"Z": @[], - + @"Z": @[] }; return [dic mutableCopy]; @@ -198,7 +184,7 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if ([[self contactsForSectionIndex:(NSUInteger)section] count]) { - return latestSortedAlphabeticalContactKeys[(NSUInteger)section]; + return self.latestSortedAlphabeticalContactKeys[(NSUInteger)section]; } else { return nil; } @@ -216,6 +202,7 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView if (self.searchController.active) { return 1; } else { + NSLog(@"Sections contacts %@", latestAlphabeticalContacts); return (NSInteger)[[latestAlphabeticalContacts allKeys] count]; } } @@ -223,7 +210,7 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { tableView.sectionIndexBackgroundColor = [UIColor clearColor]; - return latestSortedAlphabeticalContactKeys; + return _latestSortedAlphabeticalContactKeys; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { @@ -231,7 +218,7 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView if (!cell) { cell = [[ContactTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault - reuseIdentifier:CONTACT_BROWSE_TABLE_CELL_IDENTIFIER]; + reuseIdentifier:CONTACT_BROWSE_TABLE_CELL_IDENTIFIER]; } @@ -255,6 +242,7 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView } else { NSArray *contactSection = [self contactsForSectionIndex:(NSUInteger)indexPath.section]; contact = contactSection[(NSUInteger)indexPath.row]; + NSLog(@"Contact: %@", contact); } return contact; @@ -292,8 +280,7 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView DialerViewController * dialer = [DialerViewController new]; - UINavigationController *navigationController = [[UINavigationController alloc] - initWithRootViewController:dialer]; + UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:dialer]; navigationController.tabBarController.hidesBottomBarWhenPushed = NO; dialer.phoneNumber = nil; @@ -304,9 +291,34 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView navigationController.hidesBottomBarWhenPushed = YES; navigationController.navigationBarHidden=YES; - [self.tabBarController presentViewController:navigationController animated:YES completion:^(){ + [self.tabBarController presentViewController:navigationController animated:YES completion:nil]; +} + +#pragma mark - Refresh controls + +- (void)onSearchOrContactChange:(NSString *)searchTerm { + if (_latestContacts) { + latestAlphabeticalContacts = [ContactsManager groupContactsByFirstLetter:_latestContacts + matchingSearchString:searchTerm]; - }]; + NSArray *contactKeys = [latestAlphabeticalContacts allKeys]; + _latestSortedAlphabeticalContactKeys = [contactKeys sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; + [_contactTableView reloadData]; + } +} + +- (void)refreshContacts{ + [Environment.getCurrent.phoneDirectoryManager forceUpdate]; +} + +- (void)contactRefreshFailed{ + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:TIMEOUT message:TIMEOUT_CONTACTS_DETAIL delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:nil]; + [alert show]; + [self.refreshControl endRefreshing]; +} + +- (void)contactsDidRefresh{ + [self.refreshControl endRefreshing]; } @end diff --git a/Signal/src/view controllers/DialerViewController.m b/Signal/src/view controllers/DialerViewController.m index 77dcf3e41..26396af91 100644 --- a/Signal/src/view controllers/DialerViewController.m +++ b/Signal/src/view controllers/DialerViewController.m @@ -121,7 +121,7 @@ BOOL shouldTryCall = [Environment.getCurrent.phoneDirectoryManager.getCurrentFilter containsPhoneNumber:phoneNumber] || [Environment.getCurrent.recentCallManager isPhoneNumberPresentInRecentCalls:phoneNumber]; - if( shouldTryCall){ + if (shouldTryCall){ [self initiateCallToPhoneNumber:phoneNumber]; }else if(phoneNumber.isValid){ [self promptToInvitePhoneNumber:phoneNumber]; diff --git a/Signal/src/view controllers/TableViewCell.h b/Signal/src/view controllers/InboxTableViewCell.h similarity index 85% rename from Signal/src/view controllers/TableViewCell.h rename to Signal/src/view controllers/InboxTableViewCell.h index b8926d4b4..2a20f8e61 100644 --- a/Signal/src/view controllers/TableViewCell.h +++ b/Signal/src/view controllers/InboxTableViewCell.h @@ -15,15 +15,16 @@ typedef enum : NSUInteger { kInboxState, } CellState; -@class TableViewCell; + +@class InboxTableViewCell; @protocol TableViewCellDelegate -- (void)tableViewCellTappedDelete:(TableViewCell *)cell; -- (void)tableViewCellTappedArchive:(TableViewCell *)cell; +- (void)tableViewCellTappedDelete:(InboxTableViewCell *)cell; +- (void)tableViewCellTappedArchive:(InboxTableViewCell *)cell; @end -@interface TableViewCell : UITableViewCell +@interface InboxTableViewCell : UITableViewCell @property (nonatomic, strong) IBOutlet UIImageView* lastActionImageView; diff --git a/Signal/src/view controllers/TableViewCell.m b/Signal/src/view controllers/InboxTableViewCell.m similarity index 99% rename from Signal/src/view controllers/TableViewCell.m rename to Signal/src/view controllers/InboxTableViewCell.m index abcd14a61..0881be125 100644 --- a/Signal/src/view controllers/TableViewCell.m +++ b/Signal/src/view controllers/InboxTableViewCell.m @@ -6,7 +6,7 @@ // Copyright (c) 2014 Open Whisper Systems. All rights reserved. // -#import "TableViewCell.h" +#import "InboxTableViewCell.h" #import "Util.h" #define ARCHIVE_IMAGE_VIEW_WIDTH 22.0f @@ -15,7 +15,7 @@ #define DATE_LABEL_SIZE 13 -@implementation TableViewCell +@implementation InboxTableViewCell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [NSBundle.mainBundle loadNibNamed:NSStringFromClass(self.class) @@ -33,7 +33,6 @@ _deleteImageView.image = [_deleteImageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; _archiveImageView.image = [_archiveImageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; - } return self; } diff --git a/Signal/src/view controllers/TableViewCell.xib b/Signal/src/view controllers/InboxTableViewCell.xib similarity index 98% rename from Signal/src/view controllers/TableViewCell.xib rename to Signal/src/view controllers/InboxTableViewCell.xib index 96a393ddc..4880c67a7 100644 --- a/Signal/src/view controllers/TableViewCell.xib +++ b/Signal/src/view controllers/InboxTableViewCell.xib @@ -1,5 +1,5 @@ - + @@ -7,7 +7,7 @@ - + diff --git a/Signal/src/view controllers/RegistrationViewController.m b/Signal/src/view controllers/RegistrationViewController.m index 3b031017b..e06095e81 100644 --- a/Signal/src/view controllers/RegistrationViewController.m +++ b/Signal/src/view controllers/RegistrationViewController.m @@ -19,7 +19,7 @@ #import "PushManager.h" #import "RPServerRequestsManager.h" #import "SignalUtil.h" -#import "SGNKeychainUtil.h" +#import "SignalKeyingStorage.h" #import "ThreadManager.h" #import "Util.h" @@ -71,7 +71,7 @@ [_phoneNumberTextField resignFirstResponder]; - [SGNKeychainUtil setLocalNumberTo:localNumber]; + [SignalKeyingStorage setLocalNumberTo:localNumber]; [[RPServerRequestsManager sharedInstance]performRequest:[RPAPICall requestVerificationCode] success:^(NSURLSessionDataTask *task, id responseObject) { [self performSegueWithIdentifier:@"codeSent" sender:self]; diff --git a/Signal/src/view controllers/UITests/SignalsViewController.h b/Signal/src/view controllers/UITests/SignalsViewController.h index dd3e630da..3676f6de5 100644 --- a/Signal/src/view controllers/UITests/SignalsViewController.h +++ b/Signal/src/view controllers/UITests/SignalsViewController.h @@ -6,7 +6,7 @@ // Copyright (c) 2014 Open Whisper Systems. All rights reserved. // -#include "TableViewCell.h" +#include "InboxTableViewCell.h" #import #import "GroupModel.h" diff --git a/Signal/src/view controllers/UITests/SignalsViewController.m b/Signal/src/view controllers/UITests/SignalsViewController.m index 20ed4020d..e61c1b296 100644 --- a/Signal/src/view controllers/UITests/SignalsViewController.m +++ b/Signal/src/view controllers/UITests/SignalsViewController.m @@ -8,7 +8,7 @@ #import "AppDelegate.h" #import "DemoDataFactory.h" -#import "TableViewCell.h" +#import "InboxTableViewCell.h" #import "MessagesViewController.h" #import "SignalsViewController.h" @@ -73,7 +73,7 @@ static NSString *const kSegueIndentifier = @"showSegue"; return (NSInteger)numberOfCells; } - - (TableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { +- (InboxTableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { return [self inboxFeedCellForIndexPath:indexPath]; } @@ -81,13 +81,13 @@ static NSString *const kSegueIndentifier = @"showSegue"; return CELL_HEIGHT; } --(TableViewCell*)inboxFeedCellForIndexPath:(NSIndexPath *)indexPath { +-(InboxTableViewCell*)inboxFeedCellForIndexPath:(NSIndexPath *)indexPath { - TableViewCell *cell = [self._tableView dequeueReusableCellWithIdentifier:kCellNibName]; + InboxTableViewCell *cell = [self._tableView dequeueReusableCellWithIdentifier:kCellNibName]; if (!cell) { - cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault + cell = [[InboxTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellNibName]; cell.delegate = self; } @@ -102,11 +102,11 @@ static NSString *const kSegueIndentifier = @"showSegue"; #pragma mark - HomeFeedTableViewCellDelegate -- (void)tableViewCellTappedDelete:(TableViewCell *)cell { +- (void)tableViewCellTappedDelete:(InboxTableViewCell*)cell { NSLog(@"Delete"); } -- (void)tableViewCellTappedArchive:(TableViewCell *)cell { +- (void)tableViewCellTappedArchive:(InboxTableViewCell*)cell { NSLog(@"Archive"); } diff --git a/Signal/src/view controllers/xibs/DialerViewController.xib b/Signal/src/view controllers/xibs/DialerViewController.xib index eb002fe1f..5ea967baf 100644 --- a/Signal/src/view controllers/xibs/DialerViewController.xib +++ b/Signal/src/view controllers/xibs/DialerViewController.xib @@ -109,7 +109,7 @@ - +