From 5e7ca89930d9f2feb91bcf955131414fbddcb271 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 30 Nov 2017 16:57:56 -0800 Subject: [PATCH 1/8] Proper function prototypes // FREEBIE --- Signal/src/network/GiphyDownloader.swift | 2 +- SignalServiceKit/src/Account/TSPreKeyManager.m | 2 +- .../Messages/Attachments/OWSAttachmentsProcessor.m | 2 +- .../src/Messages/OWSMessageDecrypter.h | 2 +- .../src/Network/API/OWSUploadingService.m | 4 ++-- .../Network/API/Requests/OWSDeleteDeviceRequest.h | 6 ++++-- .../Requests/TSProfileAvatarUploadFormRequest.h | 2 +- .../Requests/TSProfileAvatarUploadFormRequest.m | 2 +- .../src/Storage/OWSOrphanedDataCleaner.h | 2 +- .../src/Storage/OWSOrphanedDataCleaner.m | 4 ++-- SignalServiceKit/src/Storage/TSStorageManager.h | 2 +- SignalServiceKit/src/Storage/TSStorageManager.m | 2 +- SignalServiceKit/src/Util/OWSAnalytics.h | 2 +- SignalServiceKit/src/Util/OWSAnalytics.m | 6 +++--- SignalServiceKit/src/Util/OWSDispatch.h | 2 +- SignalServiceKit/src/Util/OWSError.h | 14 +++++++------- 16 files changed, 29 insertions(+), 27 deletions(-) diff --git a/Signal/src/network/GiphyDownloader.swift b/Signal/src/network/GiphyDownloader.swift index dc05f3b7b..d4b5e9ba8 100644 --- a/Signal/src/network/GiphyDownloader.swift +++ b/Signal/src/network/GiphyDownloader.swift @@ -802,7 +802,7 @@ extension URLSessionTask { return } guard let httpResponse = task.response as? HTTPURLResponse else { - Logger.error("\(TAG) missing or unexpected response: \(task.response)") + Logger.error("\(TAG) missing or unexpected response: \(String(describing: task.response))") segmentRequestDidFail(assetRequest:assetRequest, assetSegment:assetSegment) return } diff --git a/SignalServiceKit/src/Account/TSPreKeyManager.m b/SignalServiceKit/src/Account/TSPreKeyManager.m index b9ae9477d..50618e153 100644 --- a/SignalServiceKit/src/Account/TSPreKeyManager.m +++ b/SignalServiceKit/src/Account/TSPreKeyManager.m @@ -344,7 +344,7 @@ static const NSTimeInterval kSignedPreKeyUpdateFailureMaxFailureDuration = 10 * [self clearSignedPreKeyRecordsWithKeyId:currentSignedPrekeyId success:nil]; } -+ (void)clearSignedPreKeyRecordsWithKeyId:(NSNumber *)keyId success:(void (^_Nullable)())successHandler ++ (void)clearSignedPreKeyRecordsWithKeyId:(NSNumber *)keyId success:(void (^_Nullable)(void))successHandler { if (!keyId) { OWSFail(@"%@ Ignoring request to clear signed preKeys since no keyId was specified", self.logTag); diff --git a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentsProcessor.m b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentsProcessor.m index b96cb4931..42af6c758 100644 --- a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentsProcessor.m +++ b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentsProcessor.m @@ -305,7 +305,7 @@ static const CGFloat kAttachmentDownloadProgressTheta = 0.001f; return; } - void (^abortDownload)() = ^{ + void (^abortDownload)(void) = ^{ OWSFail(@"%@ Download aborted.", self.logTag); [task cancel]; }; diff --git a/SignalServiceKit/src/Messages/OWSMessageDecrypter.h b/SignalServiceKit/src/Messages/OWSMessageDecrypter.h index b3dcfce76..8ac758a65 100644 --- a/SignalServiceKit/src/Messages/OWSMessageDecrypter.h +++ b/SignalServiceKit/src/Messages/OWSMessageDecrypter.h @@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN @class OWSSignalServiceProtosEnvelope; typedef void (^DecryptSuccessBlock)(NSData *_Nullable plaintextData); -typedef void (^DecryptFailureBlock)(); +typedef void (^DecryptFailureBlock)(void); @interface OWSMessageDecrypter : OWSMessageHandler diff --git a/SignalServiceKit/src/Network/API/OWSUploadingService.m b/SignalServiceKit/src/Network/API/OWSUploadingService.m index 122537257..03a203d3d 100644 --- a/SignalServiceKit/src/Network/API/OWSUploadingService.m +++ b/SignalServiceKit/src/Network/API/OWSUploadingService.m @@ -47,7 +47,7 @@ static const CGFloat kAttachmentUploadProgressTheta = 0.001f; success:(void (^)(void))successHandler failure:(RetryableFailureHandler)failureHandler { - void (^successHandlerWrapper)() = ^{ + void (^successHandlerWrapper)(void) = ^{ [self fireProgressNotification:1 attachmentId:attachmentStream.uniqueId]; successHandler(); @@ -61,7 +61,7 @@ static const CGFloat kAttachmentUploadProgressTheta = 0.001f; if (attachmentStream.serverId) { DDLogDebug(@"%@ Attachment previously uploaded.", self.logTag); - successHandlerWrapper(outgoingMessage); + successHandlerWrapper(); return; } diff --git a/SignalServiceKit/src/Network/API/Requests/OWSDeleteDeviceRequest.h b/SignalServiceKit/src/Network/API/Requests/OWSDeleteDeviceRequest.h index 044cd057e..f4ba003c9 100644 --- a/SignalServiceKit/src/Network/API/Requests/OWSDeleteDeviceRequest.h +++ b/SignalServiceKit/src/Network/API/Requests/OWSDeleteDeviceRequest.h @@ -1,4 +1,6 @@ -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// #import "TSRequest.h" @@ -12,4 +14,4 @@ NS_ASSUME_NONNULL_BEGIN @end -NS_ASSUME_NONNULL_END \ No newline at end of file +NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Network/API/Requests/TSProfileAvatarUploadFormRequest.h b/SignalServiceKit/src/Network/API/Requests/TSProfileAvatarUploadFormRequest.h index 5e80c51ec..8a32f12cd 100644 --- a/SignalServiceKit/src/Network/API/Requests/TSProfileAvatarUploadFormRequest.h +++ b/SignalServiceKit/src/Network/API/Requests/TSProfileAvatarUploadFormRequest.h @@ -8,7 +8,7 @@ NS_ASSUME_NONNULL_BEGIN @interface TSProfileAvatarUploadFormRequest : TSRequest -- (nullable instancetype)init; +- (instancetype)init; @end diff --git a/SignalServiceKit/src/Network/API/Requests/TSProfileAvatarUploadFormRequest.m b/SignalServiceKit/src/Network/API/Requests/TSProfileAvatarUploadFormRequest.m index bb820c210..0b0972a46 100644 --- a/SignalServiceKit/src/Network/API/Requests/TSProfileAvatarUploadFormRequest.m +++ b/SignalServiceKit/src/Network/API/Requests/TSProfileAvatarUploadFormRequest.m @@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN @implementation TSProfileAvatarUploadFormRequest -- (nullable instancetype)init +- (instancetype)init { self = [super initWithURL:[NSURL URLWithString:textSecureProfileAvatarFormAPI]]; diff --git a/SignalServiceKit/src/Storage/OWSOrphanedDataCleaner.h b/SignalServiceKit/src/Storage/OWSOrphanedDataCleaner.h index 960256a10..1b4f8fb2f 100644 --- a/SignalServiceKit/src/Storage/OWSOrphanedDataCleaner.h +++ b/SignalServiceKit/src/Storage/OWSOrphanedDataCleaner.h @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN + (void)auditAsync; // completion, if present, will be invoked on the main thread. -+ (void)auditAndCleanupAsync:(void (^_Nullable)())completion; ++ (void)auditAndCleanupAsync:(void (^_Nullable)(void))completion; + (NSSet *)filePathsInAttachmentsFolder; diff --git a/SignalServiceKit/src/Storage/OWSOrphanedDataCleaner.m b/SignalServiceKit/src/Storage/OWSOrphanedDataCleaner.m index 35fdfc30e..4d05cf886 100644 --- a/SignalServiceKit/src/Storage/OWSOrphanedDataCleaner.m +++ b/SignalServiceKit/src/Storage/OWSOrphanedDataCleaner.m @@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN }); } -+ (void)auditAndCleanupAsync:(void (^_Nullable)())completion ++ (void)auditAndCleanupAsync:(void (^_Nullable)(void))completion { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [OWSOrphanedDataCleaner auditAndCleanup:YES completion:completion]; @@ -47,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN // They can't be cleaned up - we don't want to delete the TSAttachmentStream or // its corresponding message. Better that the broken message shows up in the // conversation view. -+ (void)auditAndCleanup:(BOOL)shouldCleanup completion:(void (^_Nullable)())completion ++ (void)auditAndCleanup:(BOOL)shouldCleanup completion:(void (^_Nullable)(void))completion { NSSet *diskFilePaths = [self filePathsInAttachmentsFolder]; long long totalFileSize = [self fileSizeOfFilePaths:diskFilePaths.allObjects]; diff --git a/SignalServiceKit/src/Storage/TSStorageManager.h b/SignalServiceKit/src/Storage/TSStorageManager.h index 38ce97988..753408f8e 100644 --- a/SignalServiceKit/src/Storage/TSStorageManager.h +++ b/SignalServiceKit/src/Storage/TSStorageManager.h @@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN * Specifically, these migration should not depend on or affect the data * of any database view. */ -- (void)setupDatabaseWithSafeBlockingMigrations:(void (^_Nonnull)())safeBlockingMigrationsBlock; +- (void)setupDatabaseWithSafeBlockingMigrations:(void (^_Nonnull)(void))safeBlockingMigrationsBlock; - (void)deleteThreadsAndMessages; - (void)resetSignalStorage; diff --git a/SignalServiceKit/src/Storage/TSStorageManager.m b/SignalServiceKit/src/Storage/TSStorageManager.m index 207973206..503226efd 100644 --- a/SignalServiceKit/src/Storage/TSStorageManager.m +++ b/SignalServiceKit/src/Storage/TSStorageManager.m @@ -307,7 +307,7 @@ void setDatabaseInitialized() }; } -- (void)setupDatabaseWithSafeBlockingMigrations:(void (^_Nonnull)())safeBlockingMigrationsBlock +- (void)setupDatabaseWithSafeBlockingMigrations:(void (^_Nonnull)(void))safeBlockingMigrationsBlock { // Synchronously register extensions which are essential for views. [TSDatabaseView registerCrossProcessNotifier]; diff --git a/SignalServiceKit/src/Util/OWSAnalytics.h b/SignalServiceKit/src/Util/OWSAnalytics.h index 840f6a8cd..9cb59ed4d 100755 --- a/SignalServiceKit/src/Util/OWSAnalytics.h +++ b/SignalServiceKit/src/Util/OWSAnalytics.h @@ -44,7 +44,7 @@ typedef NS_ENUM(NSUInteger, OWSAnalyticsSeverity) { @end -typedef NSDictionary *_Nonnull (^OWSProdAssertParametersBlock)(); +typedef NSDictionary *_Nonnull (^OWSProdAssertParametersBlock)(void); // These methods should be used to assert errors for which we want to fire analytics events. // diff --git a/SignalServiceKit/src/Util/OWSAnalytics.m b/SignalServiceKit/src/Util/OWSAnalytics.m index 8e8662474..28ed30e25 100755 --- a/SignalServiceKit/src/Util/OWSAnalytics.m +++ b/SignalServiceKit/src/Util/OWSAnalytics.m @@ -222,8 +222,8 @@ NSString *NSStringForOWSAnalyticsSeverity(OWSAnalyticsSeverity severity) - (void)submitEvent:(NSDictionary *)eventDictionary eventKey:(NSString *)eventKey - success:(void (^_Nonnull)())successBlock - failure:(void (^_Nonnull)())failureBlock + success:(void (^_Nonnull)(void))successBlock + failure:(void (^_Nonnull)(void))failureBlock { OWSAssert(eventDictionary); OWSAssert(eventKey); @@ -311,7 +311,7 @@ NSString *NSStringForOWSAnalyticsSeverity(OWSAnalyticsSeverity severity) return; } - void (^addEvent)() = ^{ + void (^addEvent)(void) = ^{ // Add super properties. NSMutableDictionary *eventProperties = (properties ? [properties mutableCopy] : [NSMutableDictionary new]); [eventProperties addEntriesFromDictionary:self.eventSuperProperties]; diff --git a/SignalServiceKit/src/Util/OWSDispatch.h b/SignalServiceKit/src/Util/OWSDispatch.h index e31eebc35..9a3c9d4e5 100644 --- a/SignalServiceKit/src/Util/OWSDispatch.h +++ b/SignalServiceKit/src/Util/OWSDispatch.h @@ -24,6 +24,6 @@ NS_ASSUME_NONNULL_BEGIN @end -void AssertIsOnMainThread(); +void AssertIsOnMainThread(void); NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/OWSError.h b/SignalServiceKit/src/Util/OWSError.h index 834497c88..6fbe95752 100644 --- a/SignalServiceKit/src/Util/OWSError.h +++ b/SignalServiceKit/src/Util/OWSError.h @@ -30,12 +30,12 @@ typedef NS_ENUM(NSInteger, OWSErrorCode) { }; extern NSError *OWSErrorWithCodeDescription(OWSErrorCode code, NSString *description); -extern NSError *OWSErrorMakeUnableToProcessServerResponseError(); -extern NSError *OWSErrorMakeFailedToSendOutgoingMessageError(); -extern NSError *OWSErrorMakeNoSuchSignalRecipientError(); -extern NSError *OWSErrorMakeAssertionError(); -extern NSError *OWSErrorMakeMessageSendDisabledDueToPreKeyUpdateFailuresError(); -extern NSError *OWSErrorMakeMessageSendFailedToBlockListError(); -extern NSError *OWSErrorMakeWriteAttachmentDataError(); +extern NSError *OWSErrorMakeUnableToProcessServerResponseError(void); +extern NSError *OWSErrorMakeFailedToSendOutgoingMessageError(void); +extern NSError *OWSErrorMakeNoSuchSignalRecipientError(void); +extern NSError *OWSErrorMakeAssertionError(void); +extern NSError *OWSErrorMakeMessageSendDisabledDueToPreKeyUpdateFailuresError(void); +extern NSError *OWSErrorMakeMessageSendFailedToBlockListError(void); +extern NSError *OWSErrorMakeWriteAttachmentDataError(void); NS_ASSUME_NONNULL_END From 0dec643b94e486020a761bd0515f8c1e72b7e414 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 30 Nov 2017 16:59:17 -0800 Subject: [PATCH 2/8] update header to match implementation atomicity // FREEBIE --- SignalServiceKit/src/Network/OWSSignalService.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SignalServiceKit/src/Network/OWSSignalService.h b/SignalServiceKit/src/Network/OWSSignalService.h index 65db781bb..b66acfd72 100644 --- a/SignalServiceKit/src/Network/OWSSignalService.h +++ b/SignalServiceKit/src/Network/OWSSignalService.h @@ -20,7 +20,7 @@ extern NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidCha @property (atomic, readonly) BOOL isCensorshipCircumventionActive; -@property (nonatomic, readonly) BOOL hasCensoredPhoneNumber; +@property (atomic, readonly) BOOL hasCensoredPhoneNumber; + (instancetype)sharedInstance; From f96b7bc27cc87961775b8a27cebc8fd98fdab9ef Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 30 Nov 2017 16:59:58 -0800 Subject: [PATCH 3/8] CNContact doesn't exist before iOS9 // FREEBIE --- SignalServiceKit/src/Contacts/Contact.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SignalServiceKit/src/Contacts/Contact.h b/SignalServiceKit/src/Contacts/Contact.h index 194efe86e..be7f1a34f 100644 --- a/SignalServiceKit/src/Contacts/Contact.h +++ b/SignalServiceKit/src/Contacts/Contact.h @@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN andImage:(nullable UIImage *)image andContactID:(ABRecordID)record; -- (instancetype)initWithSystemContact:(CNContact *)contact; +- (instancetype)initWithSystemContact:(CNContact *)contact NS_AVAILABLE_IOS(9_0); - (NSString *)nameForPhoneNumber:(NSString *)recipientId; From 0138777343c50bfc3c461679ffb40633534cf9f2 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 1 Dec 2017 14:38:41 -0800 Subject: [PATCH 4/8] New @available syntax avoids compiler warnings // FREEBIE --- SignalMessaging/categories/UIFont+OWS.m | 12 ++++++------ SignalMessaging/categories/UIView+OWS.m | 14 +++++++------- SignalServiceKit/src/Messages/OWSMessageSender.m | 2 +- .../AxolotlStore/TSStorageManager+SessionStore.m | 2 +- SignalServiceKit/src/Util/OWSQueues.h | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/SignalMessaging/categories/UIFont+OWS.m b/SignalMessaging/categories/UIFont+OWS.m index 1e0d46c05..861552b96 100644 --- a/SignalMessaging/categories/UIFont+OWS.m +++ b/SignalMessaging/categories/UIFont+OWS.m @@ -8,7 +8,7 @@ + (UIFont *)ows_thinFontWithSize:(CGFloat)size { - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(8, 2)) { + if (@available(iOS 8.2, *)) { return [UIFont systemFontOfSize:size weight:UIFontWeightThin]; } else { return [UIFont fontWithName:@"HelveticaNeue-Thin" size:size]; @@ -17,7 +17,7 @@ + (UIFont *)ows_lightFontWithSize:(CGFloat)size { - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(8, 2)) { + if (@available(iOS 8.2, *)) { return [UIFont systemFontOfSize:size weight:UIFontWeightLight]; } else { return [UIFont fontWithName:@"HelveticaNeue-Light" size:size]; @@ -26,7 +26,7 @@ + (UIFont *)ows_regularFontWithSize:(CGFloat)size { - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(8, 2)) { + if (@available(iOS 8.2, *)) { return [UIFont systemFontOfSize:size weight:UIFontWeightRegular]; } else { return [UIFont fontWithName:@"HelveticaNeue" size:size]; @@ -35,7 +35,7 @@ + (UIFont *)ows_mediumFontWithSize:(CGFloat)size { - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(8, 2)) { + if (@available(iOS 8.2, *)) { return [UIFont systemFontOfSize:size weight:UIFontWeightMedium]; } else { return [UIFont fontWithName:@"HelveticaNeue-Medium" size:size]; @@ -83,7 +83,7 @@ + (UIFont *)ows_dynamicTypeTitle2Font { - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(9, 0)) { + if (@available(iOS 9.0, *)) { return [UIFont preferredFontForTextStyle:UIFontTextStyleTitle2]; } else { // Dynamic title font for ios8 defaults to bold 12.0 pt, whereas ios9+ it's 22.0pt regular weight. @@ -96,7 +96,7 @@ + (UIFont *)ows_dynamicTypeHeadlineFont { - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(9, 0)) { + if (@available(iOS 9.0, *)) { return [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]; } else { // See ows_dynamicTypeTitle2Font. diff --git a/SignalMessaging/categories/UIView+OWS.m b/SignalMessaging/categories/UIView+OWS.m index e762a4289..19f2e0dbc 100644 --- a/SignalMessaging/categories/UIView+OWS.m +++ b/SignalMessaging/categories/UIView+OWS.m @@ -252,7 +252,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) - (BOOL)isRTL { - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(9, 0)) { + if (@available(iOS 9.0, *)) { return ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft); } else { @@ -268,7 +268,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) - (NSLayoutConstraint *)autoPinLeadingToSuperviewWithMargin:(CGFloat)margin { - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(9, 0)) { + if (@available(iOS 9.0, *)) { NSLayoutConstraint *constraint = [self.leadingAnchor constraintEqualToAnchor:self.superview.layoutMarginsGuide.leadingAnchor constant:margin]; @@ -287,7 +287,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) - (NSLayoutConstraint *)autoPinTrailingToSuperviewWithMargin:(CGFloat)margin { - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(9, 0)) { + if (@available(iOS 9.0, *)) { NSLayoutConstraint *constraint = [self.trailingAnchor constraintEqualToAnchor:self.superview.layoutMarginsGuide.trailingAnchor constant:-margin]; @@ -310,7 +310,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) { OWSAssert(view); - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(9, 0)) { + if (@available(iOS 9.0, *)) { NSLayoutConstraint *constraint = [self.leadingAnchor constraintEqualToAnchor:view.trailingAnchor constant:margin]; constraint.active = YES; @@ -331,7 +331,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) { OWSAssert(view); - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(9, 0)) { + if (@available(iOS 9.0, *)) { NSLayoutConstraint *constraint = [self.trailingAnchor constraintEqualToAnchor:view.leadingAnchor constant:-margin]; constraint.active = YES; @@ -352,7 +352,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) { OWSAssert(view); - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(9, 0)) { + if (@available(iOS 9.0, *)) { NSLayoutConstraint *constraint = [self.leadingAnchor constraintEqualToAnchor:view.leadingAnchor constant:margin]; constraint.active = YES; @@ -373,7 +373,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) { OWSAssert(view); - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(9, 0)) { + if (@available(iOS 9.0, *)) { NSLayoutConstraint *constraint = [self.trailingAnchor constraintEqualToAnchor:view.trailingAnchor constant:margin]; constraint.active = YES; diff --git a/SignalServiceKit/src/Messages/OWSMessageSender.m b/SignalServiceKit/src/Messages/OWSMessageSender.m index 06c74c3a3..286dca484 100644 --- a/SignalServiceKit/src/Messages/OWSMessageSender.m +++ b/SignalServiceKit/src/Messages/OWSMessageSender.m @@ -47,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN void AssertIsOnSendingQueue() { #ifdef DEBUG - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(10, 0)) { + if (@available(iOS 10.0, *)) { dispatch_assert_queue([OWSDispatch sendingQueue]); } // else, skip assert as it's a development convenience. #endif diff --git a/SignalServiceKit/src/Storage/AxolotlStore/TSStorageManager+SessionStore.m b/SignalServiceKit/src/Storage/AxolotlStore/TSStorageManager+SessionStore.m index 2da207e97..cc236c9c1 100644 --- a/SignalServiceKit/src/Storage/AxolotlStore/TSStorageManager+SessionStore.m +++ b/SignalServiceKit/src/Storage/AxolotlStore/TSStorageManager+SessionStore.m @@ -11,7 +11,7 @@ NSString *const kSessionStoreDBConnectionKey = @"kSessionStoreDBConnectionKey"; void AssertIsOnSessionStoreQueue() { #ifdef DEBUG - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(10, 0)) { + if (@available(iOS 10.0, *)) { dispatch_assert_queue([OWSDispatch sessionStoreQueue]); } // else, skip assert as it's a development convenience. #endif diff --git a/SignalServiceKit/src/Util/OWSQueues.h b/SignalServiceKit/src/Util/OWSQueues.h index 50e6f813f..1325c2538 100644 --- a/SignalServiceKit/src/Util/OWSQueues.h +++ b/SignalServiceKit/src/Util/OWSQueues.h @@ -8,7 +8,7 @@ NS_ASSUME_NONNULL_BEGIN #define AssertOnDispatchQueue(queue) \ { \ - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(10, 0)) { \ + if (@available(iOS 10.0, *)) { \ dispatch_assert_queue(queue); \ } else { \ _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \ From fcb17585b07c61ccc66aa3c980e4688e76e6a631 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 1 Dec 2017 15:17:26 -0800 Subject: [PATCH 5/8] fix compiler warnings // FREEBIE --- .../ViewControllers/ModalActivityIndicatorViewController.swift | 2 +- .../src/environment/ExperienceUpgrades/ExperienceUpgrade.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Signal/src/ViewControllers/ModalActivityIndicatorViewController.swift b/Signal/src/ViewControllers/ModalActivityIndicatorViewController.swift index aa60ffe40..5f095ca45 100644 --- a/Signal/src/ViewControllers/ModalActivityIndicatorViewController.swift +++ b/Signal/src/ViewControllers/ModalActivityIndicatorViewController.swift @@ -67,7 +67,7 @@ class ModalActivityIndicatorViewController: OWSViewController { override func loadView() { super.loadView() - self.view.backgroundColor = UIColor(colorLiteralRed: 0, green: 0, blue: 0, alpha: 0.25) + self.view.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.25) self.view.isOpaque = false let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle:.whiteLarge) diff --git a/Signal/src/environment/ExperienceUpgrades/ExperienceUpgrade.swift b/Signal/src/environment/ExperienceUpgrades/ExperienceUpgrade.swift index 79f29d2cd..d3e5735bc 100644 --- a/Signal/src/environment/ExperienceUpgrades/ExperienceUpgrade.swift +++ b/Signal/src/environment/ExperienceUpgrades/ExperienceUpgrade.swift @@ -28,7 +28,7 @@ class ExperienceUpgrade: TSYapDatabaseObject { super.init(uniqueId: uniqueId) } - required init!(coder: NSCoder!) { + required init!(coder: NSCoder) { // This is the unfortunate seam between strict swift and fast-and-loose objc // we can't leave these properties nil, since we really "don't know" that the superclass // will assign them. From 2af818b3ba82b799207af8db80c76794afd216d0 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 1 Dec 2017 15:43:40 -0800 Subject: [PATCH 6/8] Make SignalMessaging AppExtension safe // FREEBIE --- Signal.xcodeproj/project.pbxproj | 3 +++ Signal/src/util/MainAppContext.m | 6 ++++++ SignalMessaging/categories/UIView+OWS.m | 4 ++-- SignalServiceKit/src/Util/AppContext.h | 2 ++ SignalShareExtension/utils/ShareAppExtensionContext.m | 9 +++++++++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 6aae4041e..d79e7e515 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -3493,6 +3493,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 9B533A9FA46206D3D99C9ADA /* Pods-SignalMessaging.debug.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; @@ -3546,6 +3547,7 @@ baseConfigurationReference = 948239851C08032C842937CC /* Pods-SignalMessaging.test.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; @@ -3618,6 +3620,7 @@ baseConfigurationReference = 8EEE74B0753448C085B48721 /* Pods-SignalMessaging.app store release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; diff --git a/Signal/src/util/MainAppContext.m b/Signal/src/util/MainAppContext.m index 89e9a685c..0a677cc45 100644 --- a/Signal/src/util/MainAppContext.m +++ b/Signal/src/util/MainAppContext.m @@ -18,6 +18,12 @@ NS_ASSUME_NONNULL_BEGIN return [UIApplication sharedApplication].applicationState == UIApplicationStateActive; } +- (BOOL)isRTL +{ + return + [[UIApplication sharedApplication] userInterfaceLayoutDirection] == UIUserInterfaceLayoutDirectionRightToLeft; +} + - (UIApplicationState)mainApplicationState { return [UIApplication sharedApplication].applicationState; diff --git a/SignalMessaging/categories/UIView+OWS.m b/SignalMessaging/categories/UIView+OWS.m index 19f2e0dbc..bed1ade89 100644 --- a/SignalMessaging/categories/UIView+OWS.m +++ b/SignalMessaging/categories/UIView+OWS.m @@ -4,6 +4,7 @@ #import "OWSMath.h" #import "UIView+OWS.h" +#import NS_ASSUME_NONNULL_BEGIN @@ -256,8 +257,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) return ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft); } else { - return - [UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft; + return [CurrentAppContext() isRTL]; } } diff --git a/SignalServiceKit/src/Util/AppContext.h b/SignalServiceKit/src/Util/AppContext.h index cb4d179ba..578cf9ec7 100755 --- a/SignalServiceKit/src/Util/AppContext.h +++ b/SignalServiceKit/src/Util/AppContext.h @@ -26,6 +26,8 @@ typedef void (^BackgroundTaskExpirationHandler)(void); // Should only be called if isMainApp is YES. - (void)setMainAppBadgeNumber:(NSInteger)value; +- (BOOL)isRTL; + @end id CurrentAppContext(void); diff --git a/SignalShareExtension/utils/ShareAppExtensionContext.m b/SignalShareExtension/utils/ShareAppExtensionContext.m index d3d5db6cd..b430e1dfa 100644 --- a/SignalShareExtension/utils/ShareAppExtensionContext.m +++ b/SignalShareExtension/utils/ShareAppExtensionContext.m @@ -18,6 +18,15 @@ NS_ASSUME_NONNULL_BEGIN return NO; } +- (BOOL)isRTL +{ + // Borrowed from PureLayout's AppExtension compatible RTL support. + // App Extensions may not access -[UIApplication sharedApplication]; fall back to checking the bundle's preferred + // localization character direction + return [NSLocale characterDirectionForLanguage:[[NSBundle mainBundle] preferredLocalizations][0]] + == NSLocaleLanguageDirectionRightToLeft; +} + - (UIApplicationState)mainApplicationState { OWSFail(@"%@ called %s.", self.logTag, __PRETTY_FUNCTION__); From 08c324f948bf1233b9e98370b450447cac240c51 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 1 Dec 2017 15:51:13 -0800 Subject: [PATCH 7/8] Fix compiler warnings around ambiguous macro redefinition. LMK if there's a better way to do this, which doesn't involve requiring modules. // FREEBIE --- Podfile.lock | 2 +- SignalServiceKit.podspec | 6 ++++++ SignalServiceKit/src/TSPrefix.h | 9 +++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 23d8fab2a..6d54d576a 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -185,7 +185,7 @@ SPEC CHECKSUMS: PureLayout: 4d550abe49a94f24c2808b9b95db9131685fe4cd Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 SAMKeychain: 483e1c9f32984d50ca961e26818a534283b4cd5c - SignalServiceKit: cfcc3b067458b74392750ed324fb40d5bcfa2b2a + SignalServiceKit: e1fa31c513e47afcb02c9c540d2931fd24d86311 SocketRocket: dbb1554b8fc288ef8ef370d6285aeca7361be31e SQLCipher: 43d12c0eb9c57fb438749618fc3ce0065509a559 TwistedOakCollapsingFutures: f359b90f203e9ab13dfb92c9ff41842a7fe1cd0c diff --git a/SignalServiceKit.podspec b/SignalServiceKit.podspec index 967aa075d..8a4deb692 100644 --- a/SignalServiceKit.podspec +++ b/SignalServiceKit.podspec @@ -27,6 +27,12 @@ An Objective-C library for communicating with the Signal messaging service. s.requires_arc = true s.source_files = 'SignalServiceKit/src/**/*.{h,m,mm}' + # We want to use modules to avoid clobbering CocoaLumberjack macros defined + # by other OWS modules which *also* import CocoaLumberjack. But because we + # also use Objective-C++, modules are disabled unless we explicitly enable + # them + s.compiler_flags = "-fcxx-modules" + s.prefix_header_file = 'SignalServiceKit/src/TSPrefix.h' s.xcconfig = { 'OTHER_CFLAGS' => '$(inherited) -DSQLITE_HAS_CODEC' } diff --git a/SignalServiceKit/src/TSPrefix.h b/SignalServiceKit/src/TSPrefix.h index 5620c039c..85837ee0c 100644 --- a/SignalServiceKit/src/TSPrefix.h +++ b/SignalServiceKit/src/TSPrefix.h @@ -4,15 +4,12 @@ #import -#import - -#define LOG_LEVEL_DEF sskLogLevel -#define LOG_ASYNC_ENABLED YES +@import CocoaLumberjack; #ifdef DEBUG -static const NSUInteger sskLogLevel = DDLogLevelAll; +static const NSUInteger ddLogLevel = DDLogLevelAll; #else -static const NSUInteger sskLogLevel = DDLogLevelInfo; +static const NSUInteger ddLogLevel = DDLogLevelInfo; #endif #import "Asserts.h" From 23d3006fd8d28bd05f495c66dbc232efabb8012b Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 1 Dec 2017 16:09:58 -0800 Subject: [PATCH 8/8] remove unused code // FREEBIE --- SignalServiceKit/src/TSConstants.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/SignalServiceKit/src/TSConstants.h b/SignalServiceKit/src/TSConstants.h index 717e2e0fc..6b9e06dc2 100644 --- a/SignalServiceKit/src/TSConstants.h +++ b/SignalServiceKit/src/TSConstants.h @@ -2,8 +2,6 @@ // Copyright (c) 2017 Open Whisper Systems. All rights reserved. // -@class TSNumberVerifier; - #ifndef TextSecureKit_Constants_h #define TextSecureKit_Constants_h @@ -15,8 +13,6 @@ typedef NS_ENUM(NSInteger, TSWhisperMessageType) { TSUnencryptedWhisperMessageType = 4, }; -typedef enum { kSMSVerification, kPhoneNumberVerification } VerificationTransportType; - #pragma mark Server Address #define textSecureHTTPTimeOut 10 @@ -41,7 +37,6 @@ typedef enum { kSMSVerification, kPhoneNumberVerification } VerificationTranspor // //#endif -#define textSecureGeneralAPI @"v1" #define textSecureAccountsAPI @"v1/accounts" #define textSecureAttributesAPI @"/attributes/" @@ -59,14 +54,4 @@ typedef enum { kSMSVerification, kPhoneNumberVerification } VerificationTranspor #define SignalApplicationGroup @"group.org.whispersystems.signal.group" -#pragma mark Push RegistrationSpecific Constants -typedef NS_ENUM(NSInteger, TSPushRegistrationError) { - TSPushRegistrationErrorNetwork, - TSPushRegistrationErrorAuthentication, - TSPushRegistrationErrorRequest -}; - -typedef void (^failedPushRegistrationRequestBlock)(TSPushRegistrationError error); - - #endif