From c19a8ce07e55dc362c4475e204258de89e7f52f5 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 17 Jul 2018 16:42:09 -0600 Subject: [PATCH 1/4] Fixup tests // FREEBIE --- Signal.xcodeproj/project.pbxproj | 4 - .../MesssagesBubblesSizeCalculatorTest.swift | 117 ------------------ .../ConversationViewItemTest.m | 24 +++- .../test/call/PeerConnectionClientTest.swift | 4 +- Signal/test/util/SearcherTest.swift | 13 ++ 5 files changed, 33 insertions(+), 129 deletions(-) delete mode 100644 Signal/test/Models/MesssagesBubblesSizeCalculatorTest.swift diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 325ec37a8..b9d115406 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -308,7 +308,6 @@ 452C7CA72037628B003D51A5 /* Weak.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45F170D51E315310003FC1F2 /* Weak.swift */; }; 452D1AF12081059C00A67F7F /* StringAdditionsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452D1AF02081059C00A67F7F /* StringAdditionsTest.swift */; }; 452D1AF320810B6F00A67F7F /* String+OWS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452D1AF220810B6F00A67F7F /* String+OWS.swift */; }; - 452D1EE81DCA90D100A57EC4 /* MesssagesBubblesSizeCalculatorTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452D1EE71DCA90D100A57EC4 /* MesssagesBubblesSizeCalculatorTest.swift */; }; 452EA09E1EA7ABE00078744B /* AttachmentPointerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452EA09D1EA7ABE00078744B /* AttachmentPointerView.swift */; }; 452EC6DF205E9E30000E787C /* MediaGalleryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452EC6DE205E9E30000E787C /* MediaGalleryViewController.swift */; }; 452EC6E1205FF5DC000E787C /* Bench.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452EC6E0205FF5DC000E787C /* Bench.swift */; }; @@ -951,7 +950,6 @@ 452C468E1E427E200087B011 /* OutboundCallInitiator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OutboundCallInitiator.swift; sourceTree = ""; }; 452D1AF02081059C00A67F7F /* StringAdditionsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringAdditionsTest.swift; sourceTree = ""; }; 452D1AF220810B6F00A67F7F /* String+OWS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+OWS.swift"; sourceTree = ""; }; - 452D1EE71DCA90D100A57EC4 /* MesssagesBubblesSizeCalculatorTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MesssagesBubblesSizeCalculatorTest.swift; path = Models/MesssagesBubblesSizeCalculatorTest.swift; sourceTree = ""; }; 452EA09D1EA7ABE00078744B /* AttachmentPointerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttachmentPointerView.swift; sourceTree = ""; }; 452EC6DE205E9E30000E787C /* MediaGalleryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaGalleryViewController.swift; sourceTree = ""; }; 452EC6E0205FF5DC000E787C /* Bench.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bench.swift; sourceTree = ""; }; @@ -2004,7 +2002,6 @@ children = ( 458E38391D6699FA0094BD24 /* OWSDeviceProvisioningURLParserTest.m */, 458967101DC117CC00E9DD21 /* AccountManagerTest.swift */, - 452D1EE71DCA90D100A57EC4 /* MesssagesBubblesSizeCalculatorTest.swift */, ); name = Models; sourceTree = ""; @@ -3395,7 +3392,6 @@ 458967111DC117CC00E9DD21 /* AccountManagerTest.swift in Sources */, 340B02BA1FA0D6C700F9CFEC /* ConversationViewItemTest.m in Sources */, 458E383A1D6699FA0094BD24 /* OWSDeviceProvisioningURLParserTest.m in Sources */, - 452D1EE81DCA90D100A57EC4 /* MesssagesBubblesSizeCalculatorTest.swift in Sources */, 45360B901F9527DA00FA666C /* SearcherTest.swift in Sources */, B660F7561C29988E00687D6E /* PushManager.m in Sources */, 34DB0BED2011548B007B313F /* OWSDatabaseConverterTest.m in Sources */, diff --git a/Signal/test/Models/MesssagesBubblesSizeCalculatorTest.swift b/Signal/test/Models/MesssagesBubblesSizeCalculatorTest.swift deleted file mode 100644 index 30aa5e9b7..000000000 --- a/Signal/test/Models/MesssagesBubblesSizeCalculatorTest.swift +++ /dev/null @@ -1,117 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -import XCTest -import SignalServiceKit -@testable import Signal - -/** - * This is a brittle test, which will break if our layout changes. - * - * It serves mostly as documentation for cases to consider when changing the cell measurement logic. - * Primarily these test cases came out of a bug introduced in iOS10, - * which prevents us from computing proper bounding box for text that uses the UIEmoji font. - * - * If one of these tests breaks, it should be OK to update the expected value so long as you've tested the result renders - * correctly in the running app (the reference sizes were computed in the context of an iphone6 layout. - * @see `FakeiPhone6JSQMessagesCollectionViewFlowLayout` - */ -class MesssagesBubblesSizeCalculatorTest: XCTestCase { - - let thread = TSContactThread()! - let contactsManager = OWSContactsManager() - - func viewItemForText(_ text: String?) -> ConversationViewItem { - let interaction = TSOutgoingMessage(in: thread, messageBody: text, attachmentId: nil) - interaction.save() - - var viewItem: ConversationViewItem! - interaction.dbReadWriteConnection().readWrite { transaction in - viewItem = ConversationViewItem(interaction: interaction, isGroupThread: false, transaction: transaction) - } - - viewItem.shouldShowDate = false - viewItem.shouldHideRecipientStatus = true - return viewItem - } - - func messageBubbleSize(for viewItem: ConversationViewItem) -> CGSize { - viewItem.clearCachedLayoutState() - // These are the expected values on iPhone SE. - let viewWidth = 320 - let contentWidth = 300 - return viewItem.cellSize(forViewWidth: Int32(viewWidth), contentWidth: Int32(contentWidth)) - } - - func testHeightForEmptyMessage() { - let text: String? = "" - let viewItem = self.viewItemForText(text) - let actual = messageBubbleSize(for: viewItem) - XCTAssertEqual(36, actual.height) - } - - func testHeightForShort1LineMessage() { - let text = "foo" - let viewItem = self.viewItemForText(text) - let actual = messageBubbleSize(for: viewItem) - XCTAssertEqual(36, actual.height) - } - - func testHeightForLong1LineMessage() { - let text = "1 2 3 4 5 6 7 8 9 10 11 12 13 14 x" - let viewItem = self.viewItemForText(text) - let actual = messageBubbleSize(for: viewItem) - XCTAssertEqual(58, actual.height) - } - - func testHeightForShort2LineMessage() { - let text = "1 2 3 4 5 6 7 8 9 10 11 12 13 14 x 1" - let viewItem = self.viewItemForText(text) - let actual = messageBubbleSize(for: viewItem) - XCTAssertEqual(58, actual.height) - } - - func testHeightForLong2LineMessage() { - let text = "1 2 3 4 5 6 7 8 9 10 11 12 13 14 x 1 2 3 4 5 6 7 8 9 10 11 12 13 14 x" - let viewItem = self.viewItemForText(text) - let actual = messageBubbleSize(for: viewItem) - XCTAssertEqual(80, actual.height) - } - - func testHeightForiOS10EmojiBug() { - let viewItem = self.viewItemForText("Wunderschönen Guten Morgaaaahhhn 😝 - hast du gut geschlafen ☺️😘") - let actual = messageBubbleSize(for: viewItem) - - XCTAssertEqual(80, actual.height) - } - - func testHeightForiOS10EmojiBug2() { - let viewItem = self.viewItemForText("Test test test test test test test test test test test test 😊❤️❤️") - let actual = messageBubbleSize(for: viewItem) - - XCTAssertEqual(80, actual.height) - } - - func testHeightForChineseWithEmojiBug() { - let viewItem = self.viewItemForText("一二三四五六七八九十甲乙丙😝戊己庚辛壬圭咖啡牛奶餅乾水果蛋糕") - let actual = messageBubbleSize(for: viewItem) - // erroneously seeing 69 with the emoji fix in place. - XCTAssertEqual(80, actual.height) - } - - func testHeightForChineseWithoutEmojiBug() { - let viewItem = self.viewItemForText("一二三四五六七八九十甲乙丙丁戊己庚辛壬圭咖啡牛奶餅乾水果蛋糕") - let actual = messageBubbleSize(for: viewItem) - // erroneously seeing 69 with the emoji fix in place. - XCTAssertEqual(80, actual.height) - } - - func testHeightForiOS10DoubleSpaceNumbersBug() { - let viewItem = self.viewItemForText("12345678901234567890") - let actual = messageBubbleSize(for: viewItem) - // erroneously seeing 51 with emoji fix in place. It's the call to "fix string" - XCTAssertEqual(58, actual.height) - } - -} diff --git a/Signal/test/ViewControllers/ConversationViewItemTest.m b/Signal/test/ViewControllers/ConversationViewItemTest.m index 767babc29..21491b408 100644 --- a/Signal/test/ViewControllers/ConversationViewItemTest.m +++ b/Signal/test/ViewControllers/ConversationViewItemTest.m @@ -4,14 +4,20 @@ #import "ConversationViewItem.h" #import +#import +#import #import #import +#import #import #import #import @interface ConversationViewItemTest : XCTestCase +@property TSThread *thread; +@property ConversationStyle *conversationStyle; + @end @implementation ConversationViewItemTest @@ -19,6 +25,8 @@ - (void)setUp { [super setUp]; + self.thread = [TSContactThread getOrCreateThreadWithContactId:@"+15555555"]; + self.conversationStyle = [[ConversationStyle alloc] initWithThread:self.thread]; } - (void)tearDown @@ -27,8 +35,6 @@ [super tearDown]; } -// Test canPerformAction - - (NSString *)fakeTextMessageText { return @"abc"; @@ -37,11 +43,14 @@ - (ConversationViewItem *)textViewItem { TSOutgoingMessage *message = - [TSOutgoingMessage outgoingMessageInThread:nil messageBody:self.fakeTextMessageText attachmentId:nil]; + [TSOutgoingMessage outgoingMessageInThread:self.thread messageBody:self.fakeTextMessageText attachmentId:nil]; [message save]; __block ConversationViewItem *viewItem = nil; [TSYapDatabaseObject.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { - viewItem = [[ConversationViewItem alloc] initWithInteraction:message isGroupThread:NO transaction:transaction]; + viewItem = [[ConversationViewItem alloc] initWithInteraction:message + isGroupThread:NO + transaction:transaction + conversationStyle:self.conversationStyle]; }]; return viewItem; } @@ -63,12 +72,15 @@ OWSAssert(success); [attachment save]; TSOutgoingMessage *message = - [TSOutgoingMessage outgoingMessageInThread:nil messageBody:nil attachmentId:attachment.uniqueId]; + [TSOutgoingMessage outgoingMessageInThread:self.thread messageBody:nil attachmentId:attachment.uniqueId]; [message save]; __block ConversationViewItem *viewItem = nil; [TSYapDatabaseObject.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { - viewItem = [[ConversationViewItem alloc] initWithInteraction:message isGroupThread:NO transaction:transaction]; + viewItem = [[ConversationViewItem alloc] initWithInteraction:message + isGroupThread:NO + transaction:transaction + conversationStyle:self.conversationStyle]; }]; return viewItem; diff --git a/Signal/test/call/PeerConnectionClientTest.swift b/Signal/test/call/PeerConnectionClientTest.swift index 34ef23466..4dfe219d6 100644 --- a/Signal/test/call/PeerConnectionClientTest.swift +++ b/Signal/test/call/PeerConnectionClientTest.swift @@ -39,10 +39,10 @@ class FakePeerConnectionClientDelegate: PeerConnectionClientDelegate { dataChannelMessages.append(dataChannelMessage) } - func peerConnectionClient(_ peerconnectionClient: PeerConnectionClient, didUpdateLocal videoTrack: RTCVideoTrack?) { + func peerConnectionClient(_ peerconnectionClient: PeerConnectionClient, didUpdateLocalVideoCaptureSession captureSession: AVCaptureSession?) { } - func peerConnectionClient(_ peerconnectionClient: PeerConnectionClient, didUpdateRemote videoTrack: RTCVideoTrack?) { + func peerConnectionClient(_ peerconnectionClient: PeerConnectionClient, didUpdateRemoteVideoTrack videoTrack: RTCVideoTrack?) { } } diff --git a/Signal/test/util/SearcherTest.swift b/Signal/test/util/SearcherTest.swift index d8e1aa5c0..56484d660 100644 --- a/Signal/test/util/SearcherTest.swift +++ b/Signal/test/util/SearcherTest.swift @@ -43,6 +43,7 @@ class StubbableEnvironment: TextSecureKitEnv { @objc class FakeContactsManager: NSObject, ContactsManagerProtocol { + func displayName(forPhoneIdentifier phoneNumber: String?) -> String { if phoneNumber == aliceRecipientId { return "Alice" @@ -70,6 +71,18 @@ class FakeContactsManager: NSObject, ContactsManagerProtocol { return .orderedAscending } + + func cnContact(withId contactId: String?) -> CNContact? { + return nil + } + + func avatarData(forCNContactId contactId: String?) -> Data? { + return nil + } + + func avatarImage(forCNContactId contactId: String?) -> UIImage? { + return nil + } } let bobRecipientId = "+49030183000" From 8354a9c13feca496200033d3f7e92f1bdaf71781 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 17 Jul 2018 18:16:32 -0600 Subject: [PATCH 2/4] update fastlane to latest --- Gemfile.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6f9b4fb96..7d518f035 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -54,7 +54,7 @@ GEM declarative-option (0.1.0) domain_name (0.5.20180417) unf (>= 0.0.5, < 1.0.0) - dotenv (2.4.0) + dotenv (2.5.0) emoji_regex (0.1.1) escape (0.0.4) excon (0.62.0) @@ -66,7 +66,7 @@ GEM faraday_middleware (0.12.2) faraday (>= 0.7.4, < 1.0) fastimage (2.1.3) - fastlane (2.96.1) + fastlane (2.99.1) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.3, < 3.0.0) babosa (>= 1.0.2, < 2.0.0) @@ -90,7 +90,7 @@ GEM multipart-post (~> 2.0.0) plist (>= 3.1.0, < 4.0.0) public_suffix (~> 2.0.0) - rubyzip (>= 1.1.0, < 2.0.0) + rubyzip (>= 1.2.1, < 2.0.0) security (= 0.1.3) simctl (~> 1.6.3) slack-notifier (>= 2.0.0, < 3.0.0) @@ -100,7 +100,7 @@ GEM tty-spinner (>= 0.8.0, < 1.0.0) word_wrap (~> 1.0.0) xcodeproj (>= 1.5.7, < 2.0.0) - xcpretty (>= 0.2.4, < 1.0.0) + xcpretty (~> 0.2.8) xcpretty-travis-formatter (>= 0.0.3) fourflusher (2.0.1) fuzzy_match (2.0.4) @@ -142,9 +142,9 @@ GEM multi_json (1.13.1) multi_xml (0.6.0) multipart-post (2.0.0) - nanaimo (0.2.5) + nanaimo (0.2.6) nap (1.1.0) - naturally (2.1.0) + naturally (2.2.0) netrc (0.11.0) os (0.9.6) plist (3.4.0) @@ -153,9 +153,9 @@ GEM declarative (< 0.1.0) declarative-option (< 0.2.0) uber (< 0.2.0) - retriable (3.1.1) + retriable (3.1.2) rouge (2.0.7) - ruby-macho (1.1.0) + ruby-macho (1.2.0) rubyzip (1.2.1) security (0.1.3) signet (0.8.1) @@ -163,7 +163,7 @@ GEM faraday (~> 0.9) jwt (>= 1.5, < 3.0) multi_json (~> 1.10) - simctl (1.6.4) + simctl (1.6.5) CFPropertyList naturally slack-notifier (2.3.2) @@ -171,8 +171,8 @@ GEM terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) thread_safe (0.3.6) - tty-cursor (0.5.0) - tty-screen (0.6.4) + tty-cursor (0.6.0) + tty-screen (0.6.5) tty-spinner (0.8.0) tty-cursor (>= 0.5.0) tzinfo (1.2.5) @@ -181,7 +181,7 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.7.5) - unicode-display_width (1.3.2) + unicode-display_width (1.4.0) word_wrap (1.0.0) xcodeproj (1.5.9) CFPropertyList (>= 2.3.3, < 4.0) @@ -202,4 +202,4 @@ DEPENDENCIES fastlane BUNDLED WITH - 1.16.1 + 1.16.2 From d591fb7f2c6c62d1ae8b8adb2a29da3c2f7cd9b7 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 17 Jul 2018 19:08:53 -0600 Subject: [PATCH 3/4] Fix some compiler warnings --- Signal/src/AppDelegate.m | 2 +- Signal/src/Jobs/MessageFetcherJob.swift | 7 +++++-- .../Cells/AttachmentUploadView.m | 4 ++-- .../ViewControllers/HomeView/HomeViewCell.m | 2 +- SignalMessaging/SignalMessaging.h | 2 ++ .../ViewControllers/ScreenLockViewController.m | 2 +- SignalMessaging/categories/UIColor+OWS.m | 4 ++-- SignalMessaging/categories/UIView+OWS.m | 13 ++++++------- SignalMessaging/contacts/OWSContactsManager.m | 2 +- .../migrations/OWS105AttachmentFilePaths.m | 4 ++-- .../OWSResaveCollectionDBMigration.m | 4 ++-- SignalMessaging/profiles/OWSProfileManager.m | 8 ++++---- SignalMessaging/profiles/OWSUserProfile.m | 4 ++-- SignalMessaging/utils/OWSAudioPlayer.m | 4 ++-- .../utils/OWSContactAvatarBuilder.m | 2 +- SignalMessaging/utils/OWSMath.h | 2 +- SignalMessaging/utils/ThreadUtil.m | 4 ++-- .../src/Account/TSAccountManager.m | 2 +- .../Devices/OWSReadReceiptsForSenderMessage.m | 2 +- .../src/Messages/Interactions/TSErrorMessage.h | 18 +++++++++--------- .../src/Messages/Interactions/TSErrorMessage.m | 16 ++++++++-------- .../src/Messages/OWSBatchMessageProcessor.m | 4 ++-- .../src/Messages/OWSMessageManager.m | 4 ++-- .../src/Messages/OWSReadReceiptManager.m | 6 +++--- .../src/Network/API/TSNetworkManager.m | 4 ++-- .../src/Network/WebSockets/TSSocketManager.m | 3 +-- .../src/Security/OWSWebsocketSecurityPolicy.m | 11 ++++++++--- .../OWSPrimaryStorage+SessionStore.m | 5 ++++- SignalServiceKit/src/Util/NSString+SSK.m | 2 +- SignalServiceKit/src/Util/OWSAnalytics.m | 8 ++++---- SignalServiceKit/src/Util/OWSOperation.m | 4 ++-- 31 files changed, 85 insertions(+), 74 deletions(-) diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 2871f021e..083c4b8fb 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -925,7 +925,7 @@ static NSTimeInterval launchStartedAt; - (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification - completionHandler:(void (^)())completionHandler + completionHandler:(void (^)(void))completionHandler { OWSAssertIsOnMainThread(); diff --git a/Signal/src/Jobs/MessageFetcherJob.swift b/Signal/src/Jobs/MessageFetcherJob.swift index 9c4c88c63..52ae389d3 100644 --- a/Signal/src/Jobs/MessageFetcherJob.swift +++ b/Signal/src/Jobs/MessageFetcherJob.swift @@ -26,7 +26,8 @@ public class MessageFetcherJob: NSObject { SwiftSingletons.register(self) } - @discardableResult public func run() -> Promise { + @discardableResult + public func run() -> Promise { Logger.debug("\(self.logTag) in \(#function)") guard signalService.isCensorshipCircumventionActive else { @@ -58,7 +59,9 @@ public class MessageFetcherJob: NSObject { return promise } - @objc public func run() -> AnyPromise { + @objc + @discardableResult + public func run() -> AnyPromise { return AnyPromise(run()) } diff --git a/Signal/src/ViewControllers/ConversationView/Cells/AttachmentUploadView.m b/Signal/src/ViewControllers/ConversationView/Cells/AttachmentUploadView.m index cf28de377..9e707185c 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/AttachmentUploadView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/AttachmentUploadView.m @@ -138,8 +138,8 @@ NS_ASSUME_NONNULL_BEGIN NSString *attachmentID = [userinfo objectForKey:kAttachmentUploadAttachmentIDKey]; if ([self.attachment.uniqueId isEqual:attachmentID]) { if (!isnan(progress)) { - [self.progressView setProgress:progress]; - self.lastProgress = progress; + [self.progressView setProgress:(CGFloat)progress]; + self.lastProgress = (CGFloat)progress; self.isAttachmentReady = self.attachment.isUploaded; } else { OWSFail(@"%@ Invalid attachment progress.", self.logTag); diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.m b/Signal/src/ViewControllers/HomeView/HomeViewCell.m index 68d6eac7b..760f88c6b 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.m @@ -67,7 +67,7 @@ NS_ASSUME_NONNULL_BEGIN UIView *selectedBackgroundView = [UIView new]; selectedBackgroundView.backgroundColor = - [(UIColor.isThemeEnabled ? [UIColor ows_whiteColor] : [UIColor ows_blackColor]) colorWithAlphaComponent:0.08]; + [(UIColor.isThemeEnabled ? [UIColor ows_whiteColor] : [UIColor ows_blackColor]) colorWithAlphaComponent:0.08f]; self.selectedBackgroundView = selectedBackgroundView; diff --git a/SignalMessaging/SignalMessaging.h b/SignalMessaging/SignalMessaging.h index 1a6d3cdbd..cce161506 100644 --- a/SignalMessaging/SignalMessaging.h +++ b/SignalMessaging/SignalMessaging.h @@ -34,12 +34,14 @@ FOUNDATION_EXPORT const unsigned char SignalMessagingVersionString[]; #import #import #import +#import #import #import #import #import #import #import +#import #import #import #import diff --git a/SignalMessaging/ViewControllers/ScreenLockViewController.m b/SignalMessaging/ViewControllers/ScreenLockViewController.m index 958ee2cc3..24659c879 100644 --- a/SignalMessaging/ViewControllers/ScreenLockViewController.m +++ b/SignalMessaging/ViewControllers/ScreenLockViewController.m @@ -53,7 +53,7 @@ NSString *NSStringForScreenLockUIState(ScreenLockUIState value) const CGSize screenSize = UIScreen.mainScreen.bounds.size; const CGFloat shortScreenDimension = MIN(screenSize.width, screenSize.height); - const CGFloat imageSize = round(shortScreenDimension / 3.f); + const CGFloat imageSize = (CGFloat)round(shortScreenDimension / 3.f); [imageView autoSetDimension:ALDimensionWidth toSize:imageSize]; [imageView autoSetDimension:ALDimensionHeight toSize:imageSize]; diff --git a/SignalMessaging/categories/UIColor+OWS.m b/SignalMessaging/categories/UIColor+OWS.m index 22c242908..bbf0c9b35 100644 --- a/SignalMessaging/categories/UIColor+OWS.m +++ b/SignalMessaging/categories/UIColor+OWS.m @@ -2,8 +2,8 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -#import "OWSMath.h" #import "UIColor+OWS.h" +#import "OWSMath.h" #import "UIUtil.h" #import #import @@ -42,7 +42,7 @@ NSString *const UIColorKeyThemeEnabled = @"UIColorKeyThemeEnabled"; + (UIColor *)ows_signalBrandBlueColor { - return [UIColor colorWithRed:0.1135657504 green:0.4787300229 blue:0.89595204589999999 alpha:1.]; + return [UIColor colorWithRed:0.1135657504f green:0.4787300229f blue:0.89595204589999999f alpha:1.]; } + (UIColor *)ows_materialBlueColor diff --git a/SignalMessaging/categories/UIView+OWS.m b/SignalMessaging/categories/UIView+OWS.m index a55cf0371..7ff361669 100644 --- a/SignalMessaging/categories/UIView+OWS.m +++ b/SignalMessaging/categories/UIView+OWS.m @@ -19,7 +19,7 @@ static const CGFloat kIPhone7PlusScreenWidth = 414.f; CGFloat ScaleFromIPhone5To7Plus(CGFloat iPhone5Value, CGFloat iPhone7PlusValue) { CGFloat screenShortDimension = ScreenShortDimension(); - return round(CGFloatLerp(iPhone5Value, + return (CGFloat)round(CGFloatLerp(iPhone5Value, iPhone7PlusValue, CGFloatInverseLerp(screenShortDimension, kIPhone5ScreenWidth, kIPhone7PlusScreenWidth))); } @@ -27,7 +27,7 @@ CGFloat ScaleFromIPhone5To7Plus(CGFloat iPhone5Value, CGFloat iPhone7PlusValue) CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) { CGFloat screenShortDimension = ScreenShortDimension(); - return round(iPhone5Value * screenShortDimension / kIPhone5ScreenWidth); + return (CGFloat)round(iPhone5Value * screenShortDimension / kIPhone5ScreenWidth); } #pragma mark - @@ -135,7 +135,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) - (NSLayoutConstraint *)autoPinToAspectRatio:(CGFloat)ratio { // Clamp to ensure view has reasonable aspect ratio. - CGFloat clampedRatio = CGFloatClamp(ratio, 0.05, 95.0); + CGFloat clampedRatio = CGFloatClamp(ratio, 0.05f, 95.0f); if (clampedRatio != ratio) { OWSFail(@"Invalid aspect ratio: %f for view: %@", ratio, self); } @@ -254,10 +254,9 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) { OWSAssert(self.superview); - self.frame = CGRectMake(round((self.superview.width - self.width) * 0.5f), - round((self.superview.height - self.height) * 0.5f), - self.width, - self.height); + CGFloat x = (CGFloat)round((self.superview.width - self.width) * 0.5f); + CGFloat y = (CGFloat)round((self.superview.height - self.height) * 0.5f); + self.frame = CGRectMake(x, y, self.width, self.height); } #pragma mark - RTL diff --git a/SignalMessaging/contacts/OWSContactsManager.m b/SignalMessaging/contacts/OWSContactsManager.m index 9f576679e..8c0ac14a7 100644 --- a/SignalMessaging/contacts/OWSContactsManager.m +++ b/SignalMessaging/contacts/OWSContactsManager.m @@ -332,7 +332,7 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification NSMutableSet *seenRecipientIds = [NSMutableSet new]; for (Contact *contact in contacts) { NSArray *signalRecipients = contactIdToSignalRecipientsMap[contact.uniqueId]; - for (SignalRecipient *signalRecipient in [signalRecipients sortedArrayUsingSelector:@selector(compare:)]) { + for (SignalRecipient *signalRecipient in [signalRecipients sortedArrayUsingSelector:@selector((compare:))]) { if ([seenRecipientIds containsObject:signalRecipient.recipientId]) { DDLogDebug(@"Ignoring duplicate contact: %@, %@", signalRecipient.recipientId, contact.fullName); continue; diff --git a/SignalMessaging/environment/migrations/OWS105AttachmentFilePaths.m b/SignalMessaging/environment/migrations/OWS105AttachmentFilePaths.m index 7542315d7..571e22224 100644 --- a/SignalMessaging/environment/migrations/OWS105AttachmentFilePaths.m +++ b/SignalMessaging/environment/migrations/OWS105AttachmentFilePaths.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // #import "OWS105AttachmentFilePaths.h" @@ -32,7 +32,7 @@ static NSString *const OWS105AttachmentFilePathsMigrationId = @"105"; [attachmentStreams addObject:attachmentStream]; }]; - DDLogInfo(@"Saving %zd attachment streams.", attachmentStreams.count); + DDLogInfo(@"Saving %lu attachment streams.", (unsigned long)attachmentStreams.count); // Persist the new localRelativeFilePath property of TSAttachmentStream. // For performance, we want to upgrade all existing attachment streams in diff --git a/SignalMessaging/environment/migrations/OWSResaveCollectionDBMigration.m b/SignalMessaging/environment/migrations/OWSResaveCollectionDBMigration.m index f38e67812..666f4f9fb 100644 --- a/SignalMessaging/environment/migrations/OWSResaveCollectionDBMigration.m +++ b/SignalMessaging/environment/migrations/OWSResaveCollectionDBMigration.m @@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN NSMutableArray *recordIds = [NSMutableArray new]; [dbConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { [recordIds addObjectsFromArray:[transaction allKeysInCollection:collection]]; - DDLogInfo(@"%@ Migrating %zd records from: %@.", self.logTag, recordIds.count, collection); + DDLogInfo(@"%@ Migrating %lu records from: %@.", self.logTag, (unsigned long)recordIds.count, collection); } completionQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) completionBlock:^{ @@ -45,7 +45,7 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(dbConnection); OWSAssert(completion); - DDLogVerbose(@"%@ %s: %zd", self.logTag, __PRETTY_FUNCTION__, recordIds.count); + DDLogVerbose(@"%@ %s: %lu", self.logTag, __PRETTY_FUNCTION__, (unsigned long)recordIds.count); if (recordIds.count < 1) { completion(); diff --git a/SignalMessaging/profiles/OWSProfileManager.m b/SignalMessaging/profiles/OWSProfileManager.m index 72bcd180c..93254a9c4 100644 --- a/SignalMessaging/profiles/OWSProfileManager.m +++ b/SignalMessaging/profiles/OWSProfileManager.m @@ -531,14 +531,14 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640; - (void)logProfileWhitelist { [self.dbConnection asyncReadWithBlock:^(YapDatabaseReadTransaction *transaction) { - DDLogError(@"kOWSProfileManager_UserWhitelistCollection: %zd", - [transaction numberOfKeysInCollection:kOWSProfileManager_UserWhitelistCollection]); + DDLogError(@"kOWSProfileManager_UserWhitelistCollection: %lu", + (unsigned long)[transaction numberOfKeysInCollection:kOWSProfileManager_UserWhitelistCollection]); [transaction enumerateKeysInCollection:kOWSProfileManager_UserWhitelistCollection usingBlock:^(NSString *_Nonnull key, BOOL *_Nonnull stop) { DDLogError(@"\t profile whitelist user: %@", key); }]; - DDLogError(@"kOWSProfileManager_GroupWhitelistCollection: %zd", - [transaction numberOfKeysInCollection:kOWSProfileManager_GroupWhitelistCollection]); + DDLogError(@"kOWSProfileManager_GroupWhitelistCollection: %lu", + (unsigned long)[transaction numberOfKeysInCollection:kOWSProfileManager_GroupWhitelistCollection]); [transaction enumerateKeysInCollection:kOWSProfileManager_GroupWhitelistCollection usingBlock:^(NSString *_Nonnull key, BOOL *_Nonnull stop) { DDLogError(@"\t profile whitelist group: %@", key); diff --git a/SignalMessaging/profiles/OWSUserProfile.m b/SignalMessaging/profiles/OWSUserProfile.m index 0a2f460a4..2fcc75ace 100644 --- a/SignalMessaging/profiles/OWSUserProfile.m +++ b/SignalMessaging/profiles/OWSUserProfile.m @@ -330,11 +330,11 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId"; // This should only be used in verbose, developer-only logs. - (NSString *)debugDescription { - return [NSString stringWithFormat:@"%@ %p %@ %zd %@ %@ %@", + return [NSString stringWithFormat:@"%@ %p %@ %lu %@ %@ %@", self.logTag, self, self.recipientId, - self.profileKey.keyData.length, + (unsigned long)self.profileKey.keyData.length, self.profileName, self.avatarUrlPath, self.avatarFileName]; diff --git a/SignalMessaging/utils/OWSAudioPlayer.m b/SignalMessaging/utils/OWSAudioPlayer.m index 7863704ef..302ffe4aa 100644 --- a/SignalMessaging/utils/OWSAudioPlayer.m +++ b/SignalMessaging/utils/OWSAudioPlayer.m @@ -155,7 +155,7 @@ NS_ASSUME_NONNULL_BEGIN self.delegate.audioPlaybackState = AudioPlaybackState_Paused; [self.audioPlayer pause]; [self.audioPlayerPoller invalidate]; - [self.delegate setAudioProgress:[self.audioPlayer currentTime] duration:[self.audioPlayer duration]]; + [self.delegate setAudioProgress:(CGFloat)[self.audioPlayer currentTime] duration:(CGFloat)[self.audioPlayer duration]]; [OWSAudioSession.shared endAudioActivity:self.audioActivity]; [DeviceSleepManager.sharedInstance removeBlockWithBlockObject:self]; @@ -194,7 +194,7 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(self.audioPlayer); OWSAssert(self.audioPlayerPoller); - [self.delegate setAudioProgress:[self.audioPlayer currentTime] duration:[self.audioPlayer duration]]; + [self.delegate setAudioProgress:(CGFloat)[self.audioPlayer currentTime] duration:(CGFloat)[self.audioPlayer duration]]; } - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag diff --git a/SignalMessaging/utils/OWSContactAvatarBuilder.m b/SignalMessaging/utils/OWSContactAvatarBuilder.m index c190f5145..0cf165082 100644 --- a/SignalMessaging/utils/OWSContactAvatarBuilder.m +++ b/SignalMessaging/utils/OWSContactAvatarBuilder.m @@ -124,7 +124,7 @@ NS_ASSUME_NONNULL_BEGIN [initials appendString:@"#"]; } - CGFloat fontSize = (CGFloat)self.diameter / 2.8; + CGFloat fontSize = (CGFloat)self.diameter / 2.8f; UIImage *image = [[JSQMessagesAvatarImageFactory avatarImageWithUserInitials:initials backgroundColor:self.color diff --git a/SignalMessaging/utils/OWSMath.h b/SignalMessaging/utils/OWSMath.h index 4d4826017..e48779f71 100644 --- a/SignalMessaging/utils/OWSMath.h +++ b/SignalMessaging/utils/OWSMath.h @@ -30,7 +30,7 @@ static inline CGFloat CGFloatInverseLerp(CGFloat value, CGFloat minValue, CGFloa // Ceil to an even number static inline CGFloat CeilEven(CGFloat value) { - return 2.f * ceil(value * 0.5f); + return 2.f * (CGFloat)ceil(value * 0.5f); } void SetRandFunctionSeed(void); diff --git a/SignalMessaging/utils/ThreadUtil.m b/SignalMessaging/utils/ThreadUtil.m index e70951a8c..6d8c62cd1 100644 --- a/SignalMessaging/utils/ThreadUtil.m +++ b/SignalMessaging/utils/ThreadUtil.m @@ -731,7 +731,7 @@ NS_ASSUME_NONNULL_BEGIN OWSProdLogAndFail(@"%@ couldn't load uniqueIds for collection: %@.", self.logTag, collection); return; } - DDLogInfo(@"%@ Deleting %zd objects from: %@", self.logTag, uniqueIds.count, collection); + DDLogInfo(@"%@ Deleting %lu objects from: %@", self.logTag, (unsigned long)uniqueIds.count, collection); NSUInteger count = 0; for (NSString *uniqueId in uniqueIds) { // We need to fetch each object, since [TSYapDatabaseObject removeWithTransaction:] sometimes does important @@ -744,7 +744,7 @@ NS_ASSUME_NONNULL_BEGIN [object removeWithTransaction:transaction]; count++; }; - DDLogInfo(@"%@ Deleted %zd/%zd objects from: %@", self.logTag, count, uniqueIds.count, collection); + DDLogInfo(@"%@ Deleted %lu/%lu objects from: %@", self.logTag, (unsigned long)count, (unsigned long)uniqueIds.count, collection); } #pragma mark - Find Content diff --git a/SignalServiceKit/src/Account/TSAccountManager.m b/SignalServiceKit/src/Account/TSAccountManager.m index 0a5533296..e8805612d 100644 --- a/SignalServiceKit/src/Account/TSAccountManager.m +++ b/SignalServiceKit/src/Account/TSAccountManager.m @@ -414,7 +414,7 @@ NSString *const TSAccountManager_ServerSignalingKey = @"TSStorageServerSignaling case 423: { NSString *localizedMessage = NSLocalizedString(@"REGISTRATION_VERIFICATION_FAILED_WRONG_PIN", "Error message indicating that registration failed due to a missing or incorrect 2FA PIN."); - DDLogError(@"%@ 2FA PIN required: %ld", self.logTag, error.code); + DDLogError(@"%@ 2FA PIN required: %ld", self.logTag, (long)error.code); NSError *error = OWSErrorWithCodeDescription(OWSErrorCodeRegistrationMissing2FAPIN, localizedMessage); failureBlock(error); diff --git a/SignalServiceKit/src/Devices/OWSReadReceiptsForSenderMessage.m b/SignalServiceKit/src/Devices/OWSReadReceiptsForSenderMessage.m index ae7a29a48..37fd29c0e 100644 --- a/SignalServiceKit/src/Devices/OWSReadReceiptsForSenderMessage.m +++ b/SignalServiceKit/src/Devices/OWSReadReceiptsForSenderMessage.m @@ -85,7 +85,7 @@ NS_ASSUME_NONNULL_BEGIN - (NSString *)debugDescription { - return [NSString stringWithFormat:@"%@ with message timestamps: %zd", self.logTag, self.messageTimestamps.count]; + return [NSString stringWithFormat:@"%@ with message timestamps: %lu", self.logTag, (unsigned long)self.messageTimestamps.count]; } @end diff --git a/SignalServiceKit/src/Messages/Interactions/TSErrorMessage.h b/SignalServiceKit/src/Messages/Interactions/TSErrorMessage.h index 1d2e62159..040b941ef 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSErrorMessage.h +++ b/SignalServiceKit/src/Messages/Interactions/TSErrorMessage.h @@ -36,23 +36,23 @@ typedef NS_ENUM(int32_t, TSErrorMessageType) { quotedMessage:(nullable TSQuotedMessage *)quotedMessage contactShare:(nullable OWSContact *)contact NS_UNAVAILABLE; +- (instancetype)initWithTimestamp:(uint64_t)timestamp + inThread:(nullable TSThread *)thread + messageBody:(nullable NSString *)body + attachmentIds:(NSArray *)attachmentIds + expiresInSeconds:(uint32_t)expiresInSeconds + expireStartedAt:(uint64_t)expireStartedAt NS_UNAVAILABLE; + - (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER; - (instancetype)initWithTimestamp:(uint64_t)timestamp - inThread:(TSThread *)thread + inThread:(nullable TSThread *)thread failedMessageType:(TSErrorMessageType)errorMessageType recipientId:(nullable NSString *)recipientId NS_DESIGNATED_INITIALIZER; -- (instancetype)initWithTimestamp:(uint64_t)timestamp - inThread:(TSThread *)thread - failedMessageType:(TSErrorMessageType)errorMessageType; - - (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread - messageBody:(nullable NSString *)body - attachmentIds:(NSArray *)attachmentIds - expiresInSeconds:(uint32_t)expiresInSeconds - expireStartedAt:(uint64_t)expireStartedAt NS_UNAVAILABLE; + failedMessageType:(TSErrorMessageType)errorMessageType; + (instancetype)corruptedMessageWithEnvelope:(OWSSignalServiceProtosEnvelope *)envelope withTransaction:(YapDatabaseReadWriteTransaction *)transaction; diff --git a/SignalServiceKit/src/Messages/Interactions/TSErrorMessage.m b/SignalServiceKit/src/Messages/Interactions/TSErrorMessage.m index 550aa1b92..ccb97a143 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSErrorMessage.m +++ b/SignalServiceKit/src/Messages/Interactions/TSErrorMessage.m @@ -48,14 +48,7 @@ NSUInteger TSErrorMessageSchemaVersion = 1; } - (instancetype)initWithTimestamp:(uint64_t)timestamp - inThread:(TSThread *)thread - failedMessageType:(TSErrorMessageType)errorMessageType -{ - return [self initWithTimestamp:timestamp inThread:thread failedMessageType:errorMessageType recipientId:nil]; -} - -- (instancetype)initWithTimestamp:(uint64_t)timestamp - inThread:(TSThread *)thread + inThread:(nullable TSThread *)thread failedMessageType:(TSErrorMessageType)errorMessageType recipientId:(nullable NSString *)recipientId { @@ -83,6 +76,13 @@ NSUInteger TSErrorMessageSchemaVersion = 1; return self; } +- (instancetype)initWithTimestamp:(uint64_t)timestamp + inThread:(nullable TSThread *)thread + failedMessageType:(TSErrorMessageType)errorMessageType +{ + return [self initWithTimestamp:timestamp inThread:thread failedMessageType:errorMessageType recipientId:nil]; +} + - (instancetype)initWithEnvelope:(OWSSignalServiceProtosEnvelope *)envelope withTransaction:(YapDatabaseReadWriteTransaction *)transaction failedMessageType:(TSErrorMessageType)errorMessageType diff --git a/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m b/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m index d33fc9607..7c875f7dc 100644 --- a/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m +++ b/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m @@ -356,11 +356,11 @@ NSString *const OWSMessageContentJobFinderExtensionGroup = @"OWSMessageContentJo backgroundTask = nil; - DDLogVerbose(@"%@ completed %lu/%lu jobs. %zd jobs left.", + DDLogVerbose(@"%@ completed %lu/%lu jobs. %lu jobs left.", self.logTag, (unsigned long)processedJobs.count, (unsigned long)batchJobs.count, - [OWSMessageContentJob numberOfKeysInCollection]); + (unsigned long)[OWSMessageContentJob numberOfKeysInCollection]); // Wait a bit in hopes of increasing the batch size. // This delay won't affect the first message to arrive when this queue is idle, diff --git a/SignalServiceKit/src/Messages/OWSMessageManager.m b/SignalServiceKit/src/Messages/OWSMessageManager.m index 1cf944b0e..74f49f420 100644 --- a/SignalServiceKit/src/Messages/OWSMessageManager.m +++ b/SignalServiceKit/src/Messages/OWSMessageManager.m @@ -257,9 +257,9 @@ NS_ASSUME_NONNULL_BEGIN DDLogInfo(@"%@ Missing message for delivery receipt: %llu", self.logTag, timestamp); } else { if (messages.count > 1) { - DDLogInfo(@"%@ More than one message (%zd) for delivery receipt: %llu", + DDLogInfo(@"%@ More than one message (%lu) for delivery receipt: %llu", self.logTag, - messages.count, + (unsigned long)messages.count, timestamp); } for (TSOutgoingMessage *outgoingMessage in messages) { diff --git a/SignalServiceKit/src/Messages/OWSReadReceiptManager.m b/SignalServiceKit/src/Messages/OWSReadReceiptManager.m index 0a5c1bf42..551e069b5 100644 --- a/SignalServiceKit/src/Messages/OWSReadReceiptManager.m +++ b/SignalServiceKit/src/Messages/OWSReadReceiptManager.m @@ -226,9 +226,9 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE [self.messageSender enqueueMessage:message success:^{ - DDLogInfo(@"%@ Successfully sent %zd read receipt to linked devices.", + DDLogInfo(@"%@ Successfully sent %lu read receipt to linked devices.", self.logTag, - readReceiptsForLinkedDevices.count); + (unsigned long)readReceiptsForLinkedDevices.count); } failure:^(NSError *error) { DDLogError(@"%@ Failed to send read receipt to linked devices with error: %@", self.logTag, error); @@ -250,7 +250,7 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE [self.messageSender enqueueMessage:message success:^{ - DDLogInfo(@"%@ Successfully sent %zd read receipts to sender.", self.logTag, timestamps.count); + DDLogInfo(@"%@ Successfully sent %lu read receipts to sender.", self.logTag, (unsigned long)timestamps.count); } failure:^(NSError *error) { DDLogError(@"%@ Failed to send read receipts to sender with error: %@", self.logTag, error); diff --git a/SignalServiceKit/src/Network/API/TSNetworkManager.m b/SignalServiceKit/src/Network/API/TSNetworkManager.m index b6dfb3215..d0414d70f 100644 --- a/SignalServiceKit/src/Network/API/TSNetworkManager.m +++ b/SignalServiceKit/src/Network/API/TSNetworkManager.m @@ -202,7 +202,7 @@ typedef void (^failureBlock)(NSURLSessionDataTask *task, NSError *error); break; } case 411: { - DDLogInfo(@"Multi-device pairing: %zd, %@, %@", statusCode, networkError.debugDescription, request); + DDLogInfo(@"Multi-device pairing: %ld, %@, %@", (long)statusCode, networkError.debugDescription, request); failureBlock(task, [self errorWithHTTPCode:statusCode description:NSLocalizedString(@"MULTIDEVICE_PAIRING_MAX_DESC", nil) @@ -239,7 +239,7 @@ typedef void (^failureBlock)(NSURLSessionDataTask *task, NSError *error); break; } default: { - DDLogWarn(@"Unknown error: %zd, %@, %@", statusCode, networkError.debugDescription, request); + DDLogWarn(@"Unknown error: %ld, %@, %@", (long)statusCode, networkError.debugDescription, request); failureBlock(task, error); break; } diff --git a/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m b/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m index a187f8275..63eab3066 100644 --- a/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m +++ b/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m @@ -584,8 +584,7 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_ if (message.hasBody) { responseData = message.body; } - NSArray *_Nullable responseHeaders = message.headers; - + BOOL hasValidResponse = YES; id responseObject = responseData; if (responseData) { diff --git a/SignalServiceKit/src/Security/OWSWebsocketSecurityPolicy.m b/SignalServiceKit/src/Security/OWSWebsocketSecurityPolicy.m index a86edc5f2..20fdce6d3 100644 --- a/SignalServiceKit/src/Security/OWSWebsocketSecurityPolicy.m +++ b/SignalServiceKit/src/Security/OWSWebsocketSecurityPolicy.m @@ -1,9 +1,10 @@ -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// #import "OWSWebsocketSecurityPolicy.h" - -#import #import "OWSHTTPSecurityPolicy.h" +#import @implementation OWSWebsocketSecurityPolicy @@ -11,7 +12,11 @@ static OWSWebsocketSecurityPolicy *websocketSecurityPolicy = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + // We use our own CA websocketSecurityPolicy = [[self alloc] initWithCertificateChainValidationEnabled:NO]; +#pragma clang diagnostic pop }); return websocketSecurityPolicy; } diff --git a/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SessionStore.m b/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SessionStore.m index a47cd5264..bcb7a00ca 100644 --- a/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SessionStore.m +++ b/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SessionStore.m @@ -2,8 +2,8 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -#import "OWSFileSystem.h" #import "OWSPrimaryStorage+SessionStore.h" +#import "OWSFileSystem.h" #import "YapDatabaseConnection+OWS.h" #import "YapDatabaseTransaction+OWS.h" #import @@ -66,6 +66,8 @@ NSString *const kSessionStoreDBConnectionKey = @"kSessionStoreDBConnectionKey"; return record; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" - (NSArray *)subDevicesSessions:(NSString *)contactIdentifier protocolContext:(nullable id)protocolContext { OWSAssert(contactIdentifier.length > 0); @@ -82,6 +84,7 @@ NSString *const kSessionStoreDBConnectionKey = @"kSessionStoreDBConnectionKey"; return dictionary ? dictionary.allKeys : @[]; } +#pragma clang diagnostic pop - (void)storeSession:(NSString *)contactIdentifier deviceId:(int)deviceId diff --git a/SignalServiceKit/src/Util/NSString+SSK.m b/SignalServiceKit/src/Util/NSString+SSK.m index 90406339c..549d23f4e 100644 --- a/SignalServiceKit/src/Util/NSString+SSK.m +++ b/SignalServiceKit/src/Util/NSString+SSK.m @@ -213,7 +213,7 @@ NS_ASSUME_NONNULL_BEGIN } else if (range.location != index || range.length < 1) { // This should never happen. OWSFail( - @"%@ unexpected composed character sequence: %zd, %@", self.logTag, index, NSStringFromRange(range)); + @"%@ unexpected composed character sequence: %lu, %@", self.logTag, (unsigned long)index, NSStringFromRange(range)); return YES; } index = range.location + range.length; diff --git a/SignalServiceKit/src/Util/OWSAnalytics.m b/SignalServiceKit/src/Util/OWSAnalytics.m index 121831c96..1a5f8178b 100755 --- a/SignalServiceKit/src/Util/OWSAnalytics.m +++ b/SignalServiceKit/src/Util/OWSAnalytics.m @@ -266,10 +266,10 @@ NSString *NSStringForOWSAnalyticsSeverity(OWSAnalyticsSeverity severity) static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ NSOperatingSystemVersion operatingSystemVersion = [[NSProcessInfo processInfo] operatingSystemVersion]; - result = [NSString stringWithFormat:@"%zd.%zd.%zd", - (NSUInteger)operatingSystemVersion.majorVersion, - (NSUInteger)operatingSystemVersion.minorVersion, - (NSUInteger)operatingSystemVersion.patchVersion]; + result = [NSString stringWithFormat:@"%lu.%lu.%lu", + (unsigned long)operatingSystemVersion.majorVersion, + (unsigned long)operatingSystemVersion.minorVersion, + (unsigned long)operatingSystemVersion.patchVersion]; }); return result; } diff --git a/SignalServiceKit/src/Util/OWSOperation.m b/SignalServiceKit/src/Util/OWSOperation.m index 59a005cbd..e9f02949e 100644 --- a/SignalServiceKit/src/Util/OWSOperation.m +++ b/SignalServiceKit/src/Util/OWSOperation.m @@ -98,12 +98,12 @@ NSString *const OWSOperationKeyIsFinished = @"isFinished"; - (void)reportError:(NSError *)error { - DDLogDebug(@"%@ reportError: %@, fatal?: %d, retryable?: %d, remainingRetries: %zd", + DDLogDebug(@"%@ reportError: %@, fatal?: %d, retryable?: %d, remainingRetries: %lu", self.logTag, error, error.isFatal, error.isRetryable, - self.remainingRetries); + (unsigned long)self.remainingRetries); if (error.isFatal) { [self failOperationWithError:error]; From 12ef25420a9f43c7400c7c66841dd47455bf9821 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 17 Jul 2018 19:32:44 -0600 Subject: [PATCH 4/4] Fixup SSK tests --- Signal/test/util/SearcherTest.swift | 3 ++- SignalServiceKit/src/Storage/FullTextSearchFinder.swift | 6 +++++- SignalServiceKit/src/TextSecureKitEnv.m | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Signal/test/util/SearcherTest.swift b/Signal/test/util/SearcherTest.swift index 56484d660..0152bfb69 100644 --- a/Signal/test/util/SearcherTest.swift +++ b/Signal/test/util/SearcherTest.swift @@ -112,13 +112,14 @@ class ConversationSearcherTest: XCTestCase { override func setUp() { super.setUp() - FullTextSearchFinder.syncRegisterDatabaseExtension(storage: OWSPrimaryStorage.shared()) + FullTextSearchFinder.ensureDatabaseExtensionRegistered(storage: OWSPrimaryStorage.shared()) TSContactThread.removeAllObjectsInCollection() TSGroupThread.removeAllObjectsInCollection() TSMessage.removeAllObjectsInCollection() originalEnvironment = TextSecureKitEnv.shared() + assert(originalEnvironment != nil) let testEnvironment: StubbableEnvironment = StubbableEnvironment(proxy: originalEnvironment!) testEnvironment.stubbedContactsManager = FakeContactsManager() diff --git a/SignalServiceKit/src/Storage/FullTextSearchFinder.swift b/SignalServiceKit/src/Storage/FullTextSearchFinder.swift index 39e935d30..b95fbfc6b 100644 --- a/SignalServiceKit/src/Storage/FullTextSearchFinder.swift +++ b/SignalServiceKit/src/Storage/FullTextSearchFinder.swift @@ -264,7 +264,11 @@ public class FullTextSearchFinder: NSObject { } // Only for testing. - public class func syncRegisterDatabaseExtension(storage: OWSStorage) { + public class func ensureDatabaseExtensionRegistered(storage: OWSStorage) { + guard storage.registeredExtension(dbExtensionName) == nil else { + return + } + storage.register(dbExtensionConfig, withName: dbExtensionName) } diff --git a/SignalServiceKit/src/TextSecureKitEnv.m b/SignalServiceKit/src/TextSecureKitEnv.m index a85015892..856c8ae80 100644 --- a/SignalServiceKit/src/TextSecureKitEnv.m +++ b/SignalServiceKit/src/TextSecureKitEnv.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // #import "TextSecureKitEnv.h" @@ -59,7 +59,7 @@ static TextSecureKitEnv *sharedTextSecureKitEnv; + (void)setSharedEnv:(TextSecureKitEnv *)env { OWSAssert(env); - OWSAssert(!sharedTextSecureKitEnv || !CurrentAppContext().isMainApp); + OWSAssert(!sharedTextSecureKitEnv || CurrentAppContext().isRunningTests); sharedTextSecureKitEnv = env; }