diff --git a/Podfile b/Podfile index 293a88c8f..ec0dbc25f 100644 --- a/Podfile +++ b/Podfile @@ -5,6 +5,8 @@ use_frameworks! def shared_pods # OWS Pods + # pod 'SignalCoreKit', git: 'https://github.com/signalapp/SignalCoreKit.git', testspecs: ["Tests"] + # pod 'SignalCoreKit', path: '../SignalCoreKit', testspecs: ["Tests"] # pod 'SQLCipher', path: '../sqlcipher2' pod 'SQLCipher', :git => 'https://github.com/sqlcipher/sqlcipher.git', :commit => 'd5c2bec' # pod 'YapDatabase/SQLCipher', path: '../YapDatabase' diff --git a/Podfile.lock b/Podfile.lock index e2be611ee..c47e6dec7 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -48,6 +48,12 @@ PODS: - PureLayout (3.0.2) - Reachability (3.2) - SAMKeychain (1.5.3) + - SignalCoreKit (1.0.0): + - CocoaLumberjack + - GRKOpenSSLFramework + - SignalCoreKit/Tests (1.0.0): + - CocoaLumberjack + - GRKOpenSSLFramework - SignalServiceKit (0.9.0): - AFNetworking - AxolotlKit @@ -59,6 +65,7 @@ PODS: - PromiseKit (~> 4.0) - Reachability - SAMKeychain + - SignalCoreKit - SocketRocket - SwiftProtobuf - YapDatabase/SQLCipher @@ -73,6 +80,7 @@ PODS: - PromiseKit (~> 4.0) - Reachability - SAMKeychain + - SignalCoreKit - SocketRocket - SwiftProtobuf - YapDatabase/SQLCipher @@ -159,6 +167,8 @@ DEPENDENCIES: - Mantle - PureLayout - Reachability + - SignalCoreKit (from `https://github.com/signalapp/SignalCoreKit-Private.git`, branch `charlesmchen/sck3`) + - SignalCoreKit/Tests (from `https://github.com/signalapp/SignalCoreKit-Private.git`, branch `charlesmchen/sck3`) - SignalServiceKit (from `.`) - SignalServiceKit/Tests (from `.`) - SocketRocket (from `https://github.com/signalapp/SocketRocket.git`, branch `mkirk/handle-sec-err`) @@ -191,6 +201,9 @@ EXTERNAL SOURCES: :git: https://github.com/signalapp/GRKOpenSSLFramework HKDFKit: :git: https://github.com/signalapp/HKDFKit.git + SignalCoreKit: + :branch: charlesmchen/sck3 + :git: https://github.com/signalapp/SignalCoreKit-Private.git SignalServiceKit: :path: "." SocketRocket: @@ -216,6 +229,9 @@ CHECKOUT OPTIONS: HKDFKit: :commit: f6e051a765e0bc819fee72f9b7d18acee33a8b37 :git: https://github.com/signalapp/HKDFKit.git + SignalCoreKit: + :commit: 78ef62a0ed97146794d22236ca668cb5c7107372 + :git: https://github.com/signalapp/SignalCoreKit-Private.git SocketRocket: :commit: 9f9563a83cd8960503074aa8de72206f83fb7a69 :git: https://github.com/signalapp/SocketRocket.git @@ -239,7 +255,8 @@ SPEC CHECKSUMS: PureLayout: 4d550abe49a94f24c2808b9b95db9131685fe4cd Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 SAMKeychain: 483e1c9f32984d50ca961e26818a534283b4cd5c - SignalServiceKit: 89940928e278a1b43c40678e651eb547ab4b56d8 + SignalCoreKit: c2d8132cdedb95d35eb2f8ae7eac0957695d0a8b + SignalServiceKit: 5774a5aca3116653a1d94716bccfc9fc013abf2d SocketRocket: dbb1554b8fc288ef8ef370d6285aeca7361be31e SQLCipher: f9fcf29b2e59ced7defc2a2bdd0ebe79b40d4990 SSZipArchive: 51a800ebb77f95a8329b6ced1faaff394b47f509 @@ -247,6 +264,6 @@ SPEC CHECKSUMS: YapDatabase: b418a4baa6906e8028748938f9159807fd039af4 YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54 -PODFILE CHECKSUM: 99cf978c46911aa96f569649e7113245f4ed30b7 +PODFILE CHECKSUM: c2fee616779937ffcb46434198feeefa34d9dcf7 COCOAPODS: 1.5.3 diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 78c9fa0ff..e06753d37 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -3005,6 +3005,7 @@ "${BUILT_PRODUCTS_DIR}/SAMKeychain/SAMKeychain.framework", "${BUILT_PRODUCTS_DIR}/SQLCipher/SQLCipher.framework", "${BUILT_PRODUCTS_DIR}/SSZipArchive/SSZipArchive.framework", + "${BUILT_PRODUCTS_DIR}/SignalCoreKit/SignalCoreKit.framework", "${BUILT_PRODUCTS_DIR}/SignalServiceKit/SignalServiceKit.framework", "${BUILT_PRODUCTS_DIR}/SocketRocket/SocketRocket.framework", "${BUILT_PRODUCTS_DIR}/SwiftProtobuf/SwiftProtobuf.framework", @@ -3027,6 +3028,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SAMKeychain.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SQLCipher.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SSZipArchive.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SignalCoreKit.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SignalServiceKit.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SocketRocket.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftProtobuf.framework", @@ -3076,6 +3078,7 @@ "${BUILT_PRODUCTS_DIR}/Reachability/Reachability.framework", "${BUILT_PRODUCTS_DIR}/SAMKeychain/SAMKeychain.framework", "${BUILT_PRODUCTS_DIR}/SQLCipher/SQLCipher.framework", + "${BUILT_PRODUCTS_DIR}/SignalCoreKit/SignalCoreKit.framework", "${BUILT_PRODUCTS_DIR}/SignalServiceKit/SignalServiceKit.framework", "${BUILT_PRODUCTS_DIR}/SocketRocket/SocketRocket.framework", "${BUILT_PRODUCTS_DIR}/SwiftProtobuf/SwiftProtobuf.framework", @@ -3097,6 +3100,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Reachability.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SAMKeychain.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SQLCipher.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SignalCoreKit.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SignalServiceKit.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SocketRocket.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftProtobuf.framework", diff --git a/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme b/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme index c9ee2d500..34e517a55 100644 --- a/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme +++ b/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme @@ -28,7 +28,7 @@ buildForAnalyzing = "YES"> @@ -56,12 +56,22 @@ skipped = "NO"> + + + + + #import + #import + #import #import - #import #endif diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 0255b020d..eacb9b06d 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -21,6 +21,7 @@ #import "ViewControllerUtils.h" #import #import +#import #import #import #import @@ -48,7 +49,6 @@ #import #import #import -#import #import #import diff --git a/Signal/src/Models/OWSDeviceProvisioningURLParser.m b/Signal/src/Models/OWSDeviceProvisioningURLParser.m index 12158c187..41aebc6ab 100644 --- a/Signal/src/Models/OWSDeviceProvisioningURLParser.m +++ b/Signal/src/Models/OWSDeviceProvisioningURLParser.m @@ -3,8 +3,8 @@ // #import "OWSDeviceProvisioningURLParser.h" -#import "NSData+OWS.h" #import +#import NS_ASSUME_NONNULL_BEGIN diff --git a/Signal/src/Signal-Bridging-Header.h b/Signal/src/Signal-Bridging-Header.h index c37dc03d9..a2f3ef5e6 100644 --- a/Signal/src/Signal-Bridging-Header.h +++ b/Signal/src/Signal-Bridging-Header.h @@ -48,6 +48,12 @@ #import #import #import +#import +#import +#import +#import +#import +#import #import #import #import @@ -74,14 +80,10 @@ #import #import #import -#import -#import #import -#import #import #import #import -#import #import #import #import @@ -91,7 +93,6 @@ #import #import #import -#import #import #import #import @@ -122,7 +123,6 @@ #import #import #import -#import #import #import #import diff --git a/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m b/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m index d16710446..73dd715da 100644 --- a/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m @@ -6,10 +6,10 @@ #import "BlockListViewController.h" #import "OWS2FASettingsViewController.h" #import "Signal-Swift.h" +#import #import #import #import -#import #import #import diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageTimerView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageTimerView.m index c35c7a2aa..0c8647de0 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageTimerView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageTimerView.m @@ -4,11 +4,11 @@ #import "OWSMessageTimerView.h" #import "ConversationViewController.h" -#import "NSDate+OWS.h" #import "OWSMath.h" #import "UIColor+OWS.h" #import "UIView+OWS.h" #import +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index bce53d997..51cd7a1f5 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -46,6 +46,8 @@ #import #import #import +#import +#import #import #import #import @@ -61,7 +63,6 @@ #import #import #import -#import #import #import #import @@ -80,7 +81,6 @@ #import #import #import -#import #import #import #import diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIDiskUsage.m b/Signal/src/ViewControllers/DebugUI/DebugUIDiskUsage.m index 2675d3df1..b1a4ff97a 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIDiskUsage.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIDiskUsage.m @@ -6,7 +6,7 @@ #import "OWSOrphanDataCleaner.h" #import "OWSTableViewController.h" #import "Signal-Swift.h" -#import +#import #import #import #import diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m b/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m index b7d1b0a86..5cb52160c 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m @@ -9,9 +9,9 @@ #import "OWSTableViewController.h" #import "Signal-Swift.h" #import +#import #import #import -#import #import #import #import diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIStress.m b/Signal/src/ViewControllers/DebugUI/DebugUIStress.m index 300d67ec9..d08395b16 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIStress.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIStress.m @@ -8,9 +8,9 @@ #import "SignalApp.h" #import "ThreadUtil.h" #import +#import #import #import -#import #import #import #import diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index 7bad90f03..4bf70a2f7 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -19,16 +19,16 @@ #import "TSGroupThread.h" #import "ViewControllerUtils.h" #import +#import +#import #import #import #import #import -#import #import #import #import #import -#import #import #import #import diff --git a/Signal/src/ViewControllers/NewGroupViewController.m b/Signal/src/ViewControllers/NewGroupViewController.m index 3e988389d..c4040dcba 100644 --- a/Signal/src/ViewControllers/NewGroupViewController.m +++ b/Signal/src/ViewControllers/NewGroupViewController.m @@ -9,6 +9,7 @@ #import "Signal-Swift.h" #import "SignalApp.h" #import +#import #import #import #import @@ -20,7 +21,6 @@ #import #import #import -#import #import #import #import diff --git a/Signal/src/ViewControllers/ProfileViewController.m b/Signal/src/ViewControllers/ProfileViewController.m index d0630ba0a..330476c63 100644 --- a/Signal/src/ViewControllers/ProfileViewController.m +++ b/Signal/src/ViewControllers/ProfileViewController.m @@ -12,11 +12,11 @@ #import "UIColor+OWS.h" #import "UIFont+OWS.h" #import "UIView+OWS.h" +#import #import #import #import #import -#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m b/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m index 4d278a116..d6d920b5d 100644 --- a/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m @@ -9,10 +9,10 @@ #import "UIColor+OWS.h" #import "UIFont+OWS.h" #import "UIView+OWS.h" +#import #import #import #import -#import #import #import #import diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index e55896674..b36fba3d6 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -16,6 +16,7 @@ #import "UIView+OWS.h" #import "UpdateGroupViewController.h" #import +#import #import #import #import @@ -24,7 +25,6 @@ #import #import #import -#import #import #import #import diff --git a/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m b/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m index 00923f0f3..9a2cbd2fa 100644 --- a/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m @@ -8,6 +8,7 @@ #import "OWSNavigationController.h" #import "Signal-Swift.h" #import "ViewControllerUtils.h" +#import #import #import #import @@ -19,7 +20,6 @@ #import #import #import -#import #import #import #import diff --git a/Signal/src/environment/NotificationsManager.m b/Signal/src/environment/NotificationsManager.m index bc526ca11..eea4382cb 100644 --- a/Signal/src/environment/NotificationsManager.m +++ b/Signal/src/environment/NotificationsManager.m @@ -6,18 +6,18 @@ #import "PushManager.h" #import "Signal-Swift.h" #import +#import +#import #import #import #import #import #import -#import #import #import #import #import #import -#import #import @interface NotificationsManager () diff --git a/Signal/src/environment/SignalApp.m b/Signal/src/environment/SignalApp.m index 4a55e92ab..9f5698df9 100644 --- a/Signal/src/environment/SignalApp.m +++ b/Signal/src/environment/SignalApp.m @@ -6,12 +6,12 @@ #import "ConversationViewController.h" #import "HomeViewController.h" #import "Signal-Swift.h" +#import #import #import #import #import #import -#import NS_ASSUME_NONNULL_BEGIN diff --git a/Signal/src/network/PushManager.m b/Signal/src/network/PushManager.m index 76592ac6e..fa12f94be 100644 --- a/Signal/src/network/PushManager.m +++ b/Signal/src/network/PushManager.m @@ -8,10 +8,10 @@ #import "Signal-Swift.h" #import "SignalApp.h" #import "ThreadUtil.h" +#import +#import #import #import -#import -#import #import #import #import diff --git a/Signal/src/util/DateUtil.m b/Signal/src/util/DateUtil.m index cc7d70239..324fd167a 100644 --- a/Signal/src/util/DateUtil.m +++ b/Signal/src/util/DateUtil.m @@ -3,9 +3,9 @@ // #import "DateUtil.h" +#import #import #import -#import NS_ASSUME_NONNULL_BEGIN diff --git a/Signal/src/util/MainAppContext.m b/Signal/src/util/MainAppContext.m index 738724d89..6aaa75b31 100644 --- a/Signal/src/util/MainAppContext.m +++ b/Signal/src/util/MainAppContext.m @@ -4,11 +4,11 @@ #import "MainAppContext.h" #import "Signal-Swift.h" +#import #import #import #import #import -#import NS_ASSUME_NONNULL_BEGIN diff --git a/Signal/src/util/OWSBackupExportJob.m b/Signal/src/util/OWSBackupExportJob.m index 0cb2bedf0..05f8668f3 100644 --- a/Signal/src/util/OWSBackupExportJob.m +++ b/Signal/src/util/OWSBackupExportJob.m @@ -6,8 +6,9 @@ #import "OWSBackupIO.h" #import "OWSDatabaseMigration.h" #import "Signal-Swift.h" -#import -#import +#import +#import +#import #import #import #import @@ -15,7 +16,6 @@ #import #import #import -#import NS_ASSUME_NONNULL_BEGIN diff --git a/Signal/src/util/OWSBackupImportJob.m b/Signal/src/util/OWSBackupImportJob.m index 381e2dcae..bd726cb27 100644 --- a/Signal/src/util/OWSBackupImportJob.m +++ b/Signal/src/util/OWSBackupImportJob.m @@ -7,7 +7,7 @@ #import "OWSDatabaseMigration.h" #import "OWSDatabaseMigrationRunner.h" #import "Signal-Swift.h" -#import +#import #import #import #import diff --git a/Signal/src/util/OWSOrphanDataCleaner.m b/Signal/src/util/OWSOrphanDataCleaner.m index 97f15267a..f7536e7ea 100644 --- a/Signal/src/util/OWSOrphanDataCleaner.m +++ b/Signal/src/util/OWSOrphanDataCleaner.m @@ -4,11 +4,11 @@ #import "OWSOrphanDataCleaner.h" #import "DateUtil.h" +#import #import #import #import #import -#import #import #import #import diff --git a/Signal/src/util/Pastelog.m b/Signal/src/util/Pastelog.m index 777806c3c..17897a760 100644 --- a/Signal/src/util/Pastelog.m +++ b/Signal/src/util/Pastelog.m @@ -8,6 +8,7 @@ #import "zlib.h" #import #import +#import #import #import #import @@ -16,7 +17,6 @@ #import #import #import -#import NS_ASSUME_NONNULL_BEGIN diff --git a/Signal/src/util/UIViewController+Permissions.m b/Signal/src/util/UIViewController+Permissions.m index 898ee8d8e..2778571c1 100644 --- a/Signal/src/util/UIViewController+Permissions.m +++ b/Signal/src/util/UIViewController+Permissions.m @@ -6,8 +6,8 @@ #import "Signal-Swift.h" #import #import +#import #import -#import NS_ASSUME_NONNULL_BEGIN diff --git a/Signal/src/views/RemoteVideoView.m b/Signal/src/views/RemoteVideoView.m index 0d36a7702..018d35979 100644 --- a/Signal/src/views/RemoteVideoView.m +++ b/Signal/src/views/RemoteVideoView.m @@ -7,7 +7,7 @@ #import "UIView+OWS.h" #import #import -#import +#import #import #import #import diff --git a/Signal/test/Models/OWSDeviceProvisioningURLParserTest.m b/Signal/test/Models/OWSDeviceProvisioningURLParserTest.m index bfeb0c8ed..331791112 100644 --- a/Signal/test/Models/OWSDeviceProvisioningURLParserTest.m +++ b/Signal/test/Models/OWSDeviceProvisioningURLParserTest.m @@ -4,7 +4,7 @@ #import "OWSDeviceProvisioningURLParser.h" #import "SignalBaseTest.h" -#import +#import @interface OWSDeviceProvisioningURLParserTest : SignalBaseTest diff --git a/Signal/test/util/CDSSigningCertificateTest.m b/Signal/test/util/CDSSigningCertificateTest.m index 83a171b4b..db03dd751 100644 --- a/Signal/test/util/CDSSigningCertificateTest.m +++ b/Signal/test/util/CDSSigningCertificateTest.m @@ -3,8 +3,8 @@ // #import "SignalBaseTest.h" +#import #import -#import @interface CDSSigningCertificateTest : SignalBaseTest diff --git a/Signal/test/util/OWSDatabaseConverterTest.m b/Signal/test/util/OWSDatabaseConverterTest.m index 2786ec8e6..65af0f558 100644 --- a/Signal/test/util/OWSDatabaseConverterTest.m +++ b/Signal/test/util/OWSDatabaseConverterTest.m @@ -4,7 +4,7 @@ #import "OWSDatabaseConverterTest.h" #import -#import +#import #import #import #import diff --git a/Signal/test/util/ProtoParsingTest.m b/Signal/test/util/ProtoParsingTest.m index 520a69636..77efc6b60 100644 --- a/Signal/test/util/ProtoParsingTest.m +++ b/Signal/test/util/ProtoParsingTest.m @@ -4,8 +4,8 @@ #import "SignalBaseTest.h" #import +#import #import -#import #import #import #import diff --git a/Signal/test/util/UtilTest.m b/Signal/test/util/UtilTest.m index 308d3ae39..23bcd21fa 100644 --- a/Signal/test/util/UtilTest.m +++ b/Signal/test/util/UtilTest.m @@ -5,10 +5,10 @@ #import "UtilTest.h" #import "DateUtil.h" #import "TestUtil.h" +#import +#import +#import #import -#import -#import -#import @interface DateUtil (Test) diff --git a/SignalMessaging/SignalMessaging-Prefix.pch b/SignalMessaging/SignalMessaging-Prefix.pch index c52f07265..3d083f577 100644 --- a/SignalMessaging/SignalMessaging-Prefix.pch +++ b/SignalMessaging/SignalMessaging-Prefix.pch @@ -15,7 +15,8 @@ static const NSUInteger ddLogLevel = DDLogLevelInfo; #endif - #import + #import + #import #import - #import + #import #endif diff --git a/SignalMessaging/ViewControllers/SelectThreadViewController.m b/SignalMessaging/ViewControllers/SelectThreadViewController.m index 02877a8a0..6f02e3dc6 100644 --- a/SignalMessaging/ViewControllers/SelectThreadViewController.m +++ b/SignalMessaging/ViewControllers/SelectThreadViewController.m @@ -7,7 +7,6 @@ #import "ContactTableViewCell.h" #import "ContactsViewHelper.h" #import "Environment.h" -#import "NSString+OWS.h" #import "NewNonContactConversationViewController.h" #import "OWSContactsManager.h" #import "OWSSearchBar.h" @@ -16,6 +15,7 @@ #import "UIColor+OWS.h" #import "UIFont+OWS.h" #import "UIView+OWS.h" +#import #import #import #import diff --git a/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m b/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m index cb366fd75..52e7a6094 100644 --- a/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m +++ b/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m @@ -4,12 +4,12 @@ #import "SharingThreadPickerViewController.h" #import "Environment.h" -#import "NSString+OWS.h" #import "SignalApp.h" #import "ThreadUtil.h" #import "UIColor+OWS.h" #import "UIFont+OWS.h" #import "UIView+OWS.h" +#import #import #import #import diff --git a/SignalMessaging/Views/ContactsViewHelper.m b/SignalMessaging/Views/ContactsViewHelper.m index 7f7161948..4e358e685 100644 --- a/SignalMessaging/Views/ContactsViewHelper.m +++ b/SignalMessaging/Views/ContactsViewHelper.m @@ -4,8 +4,8 @@ #import "ContactsViewHelper.h" #import "Environment.h" -#import "NSString+OWS.h" #import "UIUtil.h" +#import #import #import #import diff --git a/SignalMessaging/attachments/AttachmentSharing.m b/SignalMessaging/attachments/AttachmentSharing.m index 098174c77..1c1c3aa4a 100644 --- a/SignalMessaging/attachments/AttachmentSharing.m +++ b/SignalMessaging/attachments/AttachmentSharing.m @@ -4,9 +4,9 @@ #import "AttachmentSharing.h" #import "UIUtil.h" +#import #import #import -#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalMessaging/categories/NSString+OWS.h b/SignalMessaging/categories/NSString+OWS.h index bcf120479..c346d8fcb 100644 --- a/SignalMessaging/categories/NSString+OWS.h +++ b/SignalMessaging/categories/NSString+OWS.h @@ -2,7 +2,7 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -#import +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalMessaging/categories/UIView+OWS.m b/SignalMessaging/categories/UIView+OWS.m index 6d577001d..76542be4d 100644 --- a/SignalMessaging/categories/UIView+OWS.m +++ b/SignalMessaging/categories/UIView+OWS.m @@ -4,8 +4,8 @@ #import "UIView+OWS.h" #import "OWSMath.h" +#import #import -#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalMessaging/categories/UIViewController+OWS.m b/SignalMessaging/categories/UIViewController+OWS.m index 3e8279ddb..86a231323 100644 --- a/SignalMessaging/categories/UIViewController+OWS.m +++ b/SignalMessaging/categories/UIViewController+OWS.m @@ -6,8 +6,8 @@ #import "UIColor+OWS.h" #import "UIView+OWS.h" #import "UIViewController+OWS.h" +#import #import -#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalMessaging/contacts/OWSContactsManager.m b/SignalMessaging/contacts/OWSContactsManager.m index c363d5234..c6ac01f1e 100644 --- a/SignalMessaging/contacts/OWSContactsManager.m +++ b/SignalMessaging/contacts/OWSContactsManager.m @@ -9,17 +9,18 @@ #import "OWSProfileManager.h" #import "OWSUserProfile.h" #import "ViewControllerUtils.h" +#import +#import +#import #import #import #import #import #import -#import #import #import #import #import -#import @import Contacts; diff --git a/SignalMessaging/profiles/OWSProfileManager.m b/SignalMessaging/profiles/OWSProfileManager.m index 393227074..b0efe1032 100644 --- a/SignalMessaging/profiles/OWSProfileManager.m +++ b/SignalMessaging/profiles/OWSProfileManager.m @@ -4,15 +4,15 @@ #import "OWSProfileManager.h" #import "Environment.h" -#import "NSString+OWS.h" #import "OWSUserProfile.h" +#import +#import +#import #import #import #import #import #import -#import -#import #import #import #import diff --git a/SignalMessaging/profiles/OWSUserProfile.m b/SignalMessaging/profiles/OWSUserProfile.m index 27d1d6f9e..05827a89f 100644 --- a/SignalMessaging/profiles/OWSUserProfile.m +++ b/SignalMessaging/profiles/OWSUserProfile.m @@ -3,10 +3,10 @@ // #import "OWSUserProfile.h" -#import "NSString+OWS.h" +#import +#import #import #import -#import #import #import #import diff --git a/SignalMessaging/utils/DebugLogger.m b/SignalMessaging/utils/DebugLogger.m index 769933b9f..ce52a765b 100644 --- a/SignalMessaging/utils/DebugLogger.m +++ b/SignalMessaging/utils/DebugLogger.m @@ -4,8 +4,8 @@ #import "DebugLogger.h" #import "OWSScrubbingLogFormatter.h" +#import #import -#import #import #pragma mark Logging - Production logging wants us to write some logs to a file in case we need it for debugging. diff --git a/SignalMessaging/utils/ThreadUtil.m b/SignalMessaging/utils/ThreadUtil.m index b5198df14..4d9029050 100644 --- a/SignalMessaging/utils/ThreadUtil.m +++ b/SignalMessaging/utils/ThreadUtil.m @@ -8,9 +8,9 @@ #import "OWSQuotedReplyModel.h" #import "OWSUnreadIndicator.h" #import "TSUnreadIndicatorInteraction.h" +#import #import #import -#import #import #import #import diff --git a/SignalServiceKit.podspec b/SignalServiceKit.podspec index 7eb74e7c6..406a62ed2 100644 --- a/SignalServiceKit.podspec +++ b/SignalServiceKit.podspec @@ -50,6 +50,7 @@ An Objective-C library for communicating with the Signal messaging service. s.dependency 'SAMKeychain' s.dependency 'Reachability' s.dependency 'SwiftProtobuf' + s.dependency 'SignalCoreKit' # Avoid PromiseKit 5/6 for now. # From the maintainer: diff --git a/SignalServiceKit/src/Account/TSAccountManager.m b/SignalServiceKit/src/Account/TSAccountManager.m index d5dbca936..c8b3f732c 100644 --- a/SignalServiceKit/src/Account/TSAccountManager.m +++ b/SignalServiceKit/src/Account/TSAccountManager.m @@ -4,7 +4,6 @@ #import "TSAccountManager.h" #import "AppContext.h" -#import "NSData+OWS.h" #import "NSNotificationCenter+OWS.h" #import "NSURLSessionDataTask+StatusCode.h" #import "OWSError.h" @@ -16,6 +15,7 @@ #import "YapDatabaseConnection+OWS.h" #import "YapDatabaseTransaction+OWS.h" #import +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Account/TSPreKeyManager.m b/SignalServiceKit/src/Account/TSPreKeyManager.m index b3f9d5fee..e24f57936 100644 --- a/SignalServiceKit/src/Account/TSPreKeyManager.m +++ b/SignalServiceKit/src/Account/TSPreKeyManager.m @@ -4,12 +4,12 @@ #import "TSPreKeyManager.h" #import "AppContext.h" -#import "NSDate+OWS.h" #import "NSURLSessionDataTask+StatusCode.h" #import "OWSIdentityManager.h" #import "OWSPrimaryStorage+SignedPreKeyStore.h" #import "TSNetworkManager.h" #import "TSStorageHeaders.h" +#import #import // Time before deletion of signed prekeys (measured in seconds) diff --git a/SignalServiceKit/src/Contacts/CDSSigningCertificate.m b/SignalServiceKit/src/Contacts/CDSSigningCertificate.m index 4206751c2..d1ef21b3b 100644 --- a/SignalServiceKit/src/Contacts/CDSSigningCertificate.m +++ b/SignalServiceKit/src/Contacts/CDSSigningCertificate.m @@ -4,8 +4,8 @@ #import "CDSSigningCertificate.h" #import "Cryptography.h" -#import "NSData+OWS.h" #import +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Contacts/Contact.m b/SignalServiceKit/src/Contacts/Contact.m index 3b015e41d..7fd96fab5 100644 --- a/SignalServiceKit/src/Contacts/Contact.m +++ b/SignalServiceKit/src/Contacts/Contact.m @@ -4,12 +4,12 @@ #import "Contact.h" #import "Cryptography.h" -#import "NSString+SSK.h" #import "OWSPrimaryStorage.h" #import "PhoneNumber.h" #import "SSKEnvironment.h" #import "SignalRecipient.h" #import "TSAccountManager.h" +#import @import Contacts; diff --git a/SignalServiceKit/src/Contacts/ContactDiscoveryService.m b/SignalServiceKit/src/Contacts/ContactDiscoveryService.m index 8f6fee440..6fac045e3 100644 --- a/SignalServiceKit/src/Contacts/ContactDiscoveryService.m +++ b/SignalServiceKit/src/Contacts/ContactDiscoveryService.m @@ -6,13 +6,13 @@ #import "CDSQuote.h" #import "CDSSigningCertificate.h" #import "Cryptography.h" -#import "NSData+OWS.h" -#import "NSDate+OWS.h" #import "OWSError.h" #import "OWSRequestFactory.h" #import "TSNetworkManager.h" #import #import +#import +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Contacts/ContactsUpdater.m b/SignalServiceKit/src/Contacts/ContactsUpdater.m index f1219b2f5..8561fbf1e 100644 --- a/SignalServiceKit/src/Contacts/ContactsUpdater.m +++ b/SignalServiceKit/src/Contacts/ContactsUpdater.m @@ -10,7 +10,7 @@ #import "PhoneNumber.h" #import "SSKEnvironment.h" #import "TSNetworkManager.h" -#import "Threading.h" +#import #import #import diff --git a/SignalServiceKit/src/Contacts/OWSDisappearingMessagesConfiguration.m b/SignalServiceKit/src/Contacts/OWSDisappearingMessagesConfiguration.m index 1acd19fba..c03b26b80 100644 --- a/SignalServiceKit/src/Contacts/OWSDisappearingMessagesConfiguration.m +++ b/SignalServiceKit/src/Contacts/OWSDisappearingMessagesConfiguration.m @@ -3,8 +3,8 @@ // #import "OWSDisappearingMessagesConfiguration.h" -#import "NSDate+OWS.h" -#import "NSString+SSK.h" +#import +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Contacts/SignalAccount.m b/SignalServiceKit/src/Contacts/SignalAccount.m index fb34ee5da..98c7f73d0 100644 --- a/SignalServiceKit/src/Contacts/SignalAccount.m +++ b/SignalServiceKit/src/Contacts/SignalAccount.m @@ -4,9 +4,9 @@ #import "SignalAccount.h" #import "Contact.h" -#import "NSString+SSK.h" #import "OWSPrimaryStorage.h" #import "SignalRecipient.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Contacts/TSThread.m b/SignalServiceKit/src/Contacts/TSThread.m index 59f298972..e59b98a7c 100644 --- a/SignalServiceKit/src/Contacts/TSThread.m +++ b/SignalServiceKit/src/Contacts/TSThread.m @@ -4,8 +4,6 @@ #import "TSThread.h" #import "Cryptography.h" -#import "NSDate+OWS.h" -#import "NSString+SSK.h" #import "OWSDisappearingMessagesConfiguration.h" #import "OWSPrimaryStorage.h" #import "OWSReadTracking.h" @@ -15,6 +13,8 @@ #import "TSInteraction.h" #import "TSInvalidIdentityKeyReceivingErrorMessage.h" #import "TSOutgoingMessage.h" +#import +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m b/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m index 248a5ae22..6d5eeaa17 100644 --- a/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m +++ b/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m @@ -3,8 +3,8 @@ // #import "TSGroupThread.h" -#import "NSData+OWS.h" #import "TSAttachmentStream.h" +#import #import #import #import diff --git a/SignalServiceKit/src/Devices/OWSChunkedOutputStream.m b/SignalServiceKit/src/Devices/OWSChunkedOutputStream.m index 23026bc19..16b42e9ee 100644 --- a/SignalServiceKit/src/Devices/OWSChunkedOutputStream.m +++ b/SignalServiceKit/src/Devices/OWSChunkedOutputStream.m @@ -3,7 +3,7 @@ // #import "OWSChunkedOutputStream.h" -#import "NSData+OWS.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Devices/OWSContactsOutputStream.m b/SignalServiceKit/src/Devices/OWSContactsOutputStream.m index b9270220d..d2d3dbc1d 100644 --- a/SignalServiceKit/src/Devices/OWSContactsOutputStream.m +++ b/SignalServiceKit/src/Devices/OWSContactsOutputStream.m @@ -7,13 +7,13 @@ #import "ContactsManagerProtocol.h" #import "Cryptography.h" #import "MIMETypeUtil.h" -#import "NSData+OWS.h" #import "NSData+keyVersionByte.h" #import "OWSBlockingManager.h" #import "OWSDisappearingMessagesConfiguration.h" #import "OWSRecipientIdentity.h" #import "SignalAccount.h" #import "TSContactThread.h" +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Devices/OWSDevice.m b/SignalServiceKit/src/Devices/OWSDevice.m index 6a9433ef4..87b41d4e8 100644 --- a/SignalServiceKit/src/Devices/OWSDevice.m +++ b/SignalServiceKit/src/Devices/OWSDevice.m @@ -3,13 +3,13 @@ // #import "OWSDevice.h" -#import "NSDate+OWS.h" #import "OWSError.h" #import "OWSPrimaryStorage.h" #import "YapDatabaseConnection+OWS.h" #import "YapDatabaseConnection.h" #import "YapDatabaseTransaction.h" #import +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Devices/OWSReadReceiptsForSenderMessage.m b/SignalServiceKit/src/Devices/OWSReadReceiptsForSenderMessage.m index 4d06a8d0e..d640f8038 100644 --- a/SignalServiceKit/src/Devices/OWSReadReceiptsForSenderMessage.m +++ b/SignalServiceKit/src/Devices/OWSReadReceiptsForSenderMessage.m @@ -3,8 +3,8 @@ // #import "OWSReadReceiptsForSenderMessage.h" -#import "NSDate+OWS.h" #import "SignalRecipient.h" +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/Attachments/TSAttachment.m b/SignalServiceKit/src/Messages/Attachments/TSAttachment.m index 07774a440..b829245bf 100644 --- a/SignalServiceKit/src/Messages/Attachments/TSAttachment.m +++ b/SignalServiceKit/src/Messages/Attachments/TSAttachment.m @@ -4,8 +4,8 @@ #import "TSAttachment.h" #import "MIMETypeUtil.h" -#import "NSString+SSK.h" -#import "iOSVersions.h" +#import +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m b/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m index 146febc68..d9396dddb 100644 --- a/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m +++ b/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m @@ -7,8 +7,8 @@ #import "NSData+Image.h" #import "OWSFileSystem.h" #import "TSAttachmentPointer.h" -#import "Threading.h" #import +#import #import #import diff --git a/SignalServiceKit/src/Messages/DeviceSyncing/OWSOutgoingSyncMessage.m b/SignalServiceKit/src/Messages/DeviceSyncing/OWSOutgoingSyncMessage.m index f457b3c85..6be259b0a 100644 --- a/SignalServiceKit/src/Messages/DeviceSyncing/OWSOutgoingSyncMessage.m +++ b/SignalServiceKit/src/Messages/DeviceSyncing/OWSOutgoingSyncMessage.m @@ -4,8 +4,8 @@ #import "OWSOutgoingSyncMessage.h" #import "Cryptography.h" -#import "NSDate+OWS.h" #import "ProtoUtils.h" +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncContactsMessage.m b/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncContactsMessage.m index 41ba71c74..b8828499d 100644 --- a/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncContactsMessage.m +++ b/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncContactsMessage.m @@ -5,7 +5,6 @@ #import "OWSSyncContactsMessage.h" #import "Contact.h" #import "ContactsManagerProtocol.h" -#import "NSDate+OWS.h" #import "OWSContactsOutputStream.h" #import "OWSIdentityManager.h" #import "ProfileManagerProtocol.h" @@ -14,6 +13,7 @@ #import "TSAttachment.h" #import "TSAttachmentStream.h" #import "TSContactThread.h" +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncGroupsMessage.m b/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncGroupsMessage.m index bf67d1652..de7d4202a 100644 --- a/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncGroupsMessage.m +++ b/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncGroupsMessage.m @@ -3,13 +3,13 @@ // #import "OWSSyncGroupsMessage.h" -#import "NSDate+OWS.h" #import "OWSGroupsOutputStream.h" #import "TSAttachment.h" #import "TSAttachmentStream.h" #import "TSContactThread.h" #import "TSGroupModel.h" #import "TSGroupThread.h" +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncGroupsRequestMessage.m b/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncGroupsRequestMessage.m index 7f491f9d2..076c0ff67 100644 --- a/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncGroupsRequestMessage.m +++ b/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncGroupsRequestMessage.m @@ -3,7 +3,7 @@ // #import "OWSSyncGroupsRequestMessage.h" -#import "NSDate+OWS.h" +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/Interactions/OWSContact.m b/SignalServiceKit/src/Messages/Interactions/OWSContact.m index cc94b64ff..c8e791570 100644 --- a/SignalServiceKit/src/Messages/Interactions/OWSContact.m +++ b/SignalServiceKit/src/Messages/Interactions/OWSContact.m @@ -5,12 +5,12 @@ #import "OWSContact.h" #import "Contact.h" #import "MimeTypeUtil.h" -#import "NSString+SSK.h" #import "OWSContact+Private.h" #import "PhoneNumber.h" #import "TSAttachment.h" #import "TSAttachmentPointer.h" #import "TSAttachmentStream.h" +#import #import #import diff --git a/SignalServiceKit/src/Messages/Interactions/OWSDisappearingConfigurationUpdateInfoMessage.m b/SignalServiceKit/src/Messages/Interactions/OWSDisappearingConfigurationUpdateInfoMessage.m index da4be6377..7302bd0c5 100644 --- a/SignalServiceKit/src/Messages/Interactions/OWSDisappearingConfigurationUpdateInfoMessage.m +++ b/SignalServiceKit/src/Messages/Interactions/OWSDisappearingConfigurationUpdateInfoMessage.m @@ -3,8 +3,8 @@ // #import "OWSDisappearingConfigurationUpdateInfoMessage.h" -#import "NSString+SSK.h" #import "OWSDisappearingMessagesConfiguration.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/Interactions/OWSDisappearingMessagesConfigurationMessage.m b/SignalServiceKit/src/Messages/Interactions/OWSDisappearingMessagesConfigurationMessage.m index cdeff4811..3c3744636 100644 --- a/SignalServiceKit/src/Messages/Interactions/OWSDisappearingMessagesConfigurationMessage.m +++ b/SignalServiceKit/src/Messages/Interactions/OWSDisappearingMessagesConfigurationMessage.m @@ -3,8 +3,8 @@ // #import "OWSDisappearingMessagesConfigurationMessage.h" -#import "NSDate+OWS.h" #import "OWSDisappearingMessagesConfiguration.h" +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/Interactions/OWSDynamicOutgoingMessage.m b/SignalServiceKit/src/Messages/Interactions/OWSDynamicOutgoingMessage.m index bfc008f15..452a1f1c7 100644 --- a/SignalServiceKit/src/Messages/Interactions/OWSDynamicOutgoingMessage.m +++ b/SignalServiceKit/src/Messages/Interactions/OWSDynamicOutgoingMessage.m @@ -3,7 +3,7 @@ // #import "OWSDynamicOutgoingMessage.h" -#import "NSDate+OWS.h" +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/Interactions/TSErrorMessage.m b/SignalServiceKit/src/Messages/Interactions/TSErrorMessage.m index c28750254..cc901929d 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSErrorMessage.m +++ b/SignalServiceKit/src/Messages/Interactions/TSErrorMessage.m @@ -4,11 +4,11 @@ #import "TSErrorMessage.h" #import "ContactsManagerProtocol.h" -#import "NSDate+OWS.h" #import "OWSMessageManager.h" #import "SSKEnvironment.h" #import "TSContactThread.h" #import "TSErrorMessage_privateConstructor.h" +#import #import #import diff --git a/SignalServiceKit/src/Messages/Interactions/TSIncomingMessage.m b/SignalServiceKit/src/Messages/Interactions/TSIncomingMessage.m index f88f097ec..7b0ab6639 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSIncomingMessage.m +++ b/SignalServiceKit/src/Messages/Interactions/TSIncomingMessage.m @@ -3,7 +3,6 @@ // #import "TSIncomingMessage.h" -#import "NSDate+OWS.h" #import "NSNotificationCenter+OWS.h" #import "OWSDisappearingMessagesConfiguration.h" #import "OWSDisappearingMessagesJob.h" @@ -12,6 +11,7 @@ #import "TSContactThread.h" #import "TSDatabaseSecondaryIndexes.h" #import "TSGroupThread.h" +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/Interactions/TSInfoMessage.m b/SignalServiceKit/src/Messages/Interactions/TSInfoMessage.m index 557f97e9a..4667c3691 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSInfoMessage.m +++ b/SignalServiceKit/src/Messages/Interactions/TSInfoMessage.m @@ -4,8 +4,8 @@ #import "TSInfoMessage.h" #import "ContactsManagerProtocol.h" -#import "NSDate+OWS.h" #import "SSKEnvironment.h" +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m index d76cfe9e5..10e4a27bd 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m +++ b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m @@ -3,10 +3,10 @@ // #import "TSInteraction.h" -#import "NSDate+OWS.h" #import "OWSPrimaryStorage+messageIDs.h" #import "TSDatabaseSecondaryIndexes.h" #import "TSThread.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/Interactions/TSMessage.m b/SignalServiceKit/src/Messages/Interactions/TSMessage.m index 06ac2abe2..78381f9f8 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSMessage.m +++ b/SignalServiceKit/src/Messages/Interactions/TSMessage.m @@ -5,14 +5,14 @@ #import "TSMessage.h" #import "AppContext.h" #import "MIMETypeUtil.h" -#import "NSDate+OWS.h" -#import "NSString+SSK.h" #import "OWSContact.h" #import "OWSDisappearingMessagesConfiguration.h" #import "TSAttachment.h" #import "TSAttachmentStream.h" #import "TSQuotedMessage.h" #import "TSThread.h" +#import +#import #import #import diff --git a/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m b/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m index 717b89b06..f34971a01 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m +++ b/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m @@ -3,8 +3,6 @@ // #import "TSOutgoingMessage.h" -#import "NSDate+OWS.h" -#import "NSString+SSK.h" #import "OWSContact.h" #import "OWSMessageSender.h" #import "OWSOutgoingSyncMessage.h" @@ -17,6 +15,8 @@ #import "TSContactThread.h" #import "TSGroupThread.h" #import "TSQuotedMessage.h" +#import +#import #import #import #import diff --git a/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m b/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m index b911c95ff..f0c65646b 100644 --- a/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m +++ b/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m @@ -17,7 +17,7 @@ #import "TSDatabaseView.h" #import "TSErrorMessage.h" #import "TSYapDatabaseObject.h" -#import "Threading.h" +#import #import #import #import diff --git a/SignalServiceKit/src/Messages/OWSDisappearingMessagesFinder.m b/SignalServiceKit/src/Messages/OWSDisappearingMessagesFinder.m index f66ed9bb4..48103ce88 100644 --- a/SignalServiceKit/src/Messages/OWSDisappearingMessagesFinder.m +++ b/SignalServiceKit/src/Messages/OWSDisappearingMessagesFinder.m @@ -3,12 +3,12 @@ // #import "OWSDisappearingMessagesFinder.h" -#import "NSDate+OWS.h" #import "OWSPrimaryStorage.h" #import "TSIncomingMessage.h" #import "TSMessage.h" #import "TSOutgoingMessage.h" #import "TSThread.h" +#import #import #import #import diff --git a/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m b/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m index 5bacb50d6..2015195be 100644 --- a/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m +++ b/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m @@ -6,7 +6,6 @@ #import "AppContext.h" #import "AppReadiness.h" #import "ContactsManagerProtocol.h" -#import "NSDate+OWS.h" #import "NSTimer+OWS.h" #import "OWSBackgroundTask.h" #import "OWSDisappearingConfigurationUpdateInfoMessage.h" @@ -16,6 +15,7 @@ #import "TSIncomingMessage.h" #import "TSMessage.h" #import "TSThread.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/OWSIdentityManager.m b/SignalServiceKit/src/Messages/OWSIdentityManager.m index 922115dc8..58d2bb461 100644 --- a/SignalServiceKit/src/Messages/OWSIdentityManager.m +++ b/SignalServiceKit/src/Messages/OWSIdentityManager.m @@ -5,7 +5,6 @@ #import "OWSIdentityManager.h" #import "AppContext.h" #import "AppReadiness.h" -#import "NSDate+OWS.h" #import "NSNotificationCenter+OWS.h" #import "NotificationsProtocol.h" #import "OWSError.h" @@ -26,6 +25,7 @@ #import "YapDatabaseTransaction+OWS.h" #import #import +#import #import #import diff --git a/SignalServiceKit/src/Messages/OWSIncompleteCallsJob.m b/SignalServiceKit/src/Messages/OWSIncompleteCallsJob.m index 97ca0eb36..18414a58f 100644 --- a/SignalServiceKit/src/Messages/OWSIncompleteCallsJob.m +++ b/SignalServiceKit/src/Messages/OWSIncompleteCallsJob.m @@ -4,9 +4,9 @@ #import "OWSIncompleteCallsJob.h" #import "AppContext.h" -#import "NSDate+OWS.h" #import "OWSPrimaryStorage.h" #import "TSCall.h" +#import #import #import #import diff --git a/SignalServiceKit/src/Messages/OWSMessageManager.m b/SignalServiceKit/src/Messages/OWSMessageManager.m index 2ff730a52..17888b7b7 100644 --- a/SignalServiceKit/src/Messages/OWSMessageManager.m +++ b/SignalServiceKit/src/Messages/OWSMessageManager.m @@ -8,8 +8,6 @@ #import "ContactsManagerProtocol.h" #import "Cryptography.h" #import "MimeTypeUtil.h" -#import "NSDate+OWS.h" -#import "NSString+SSK.h" #import "NotificationsProtocol.h" #import "OWSAttachmentsProcessor.h" #import "OWSBlockingManager.h" @@ -47,6 +45,8 @@ #import "TSNetworkManager.h" #import "TSOutgoingMessage.h" #import "TSQuotedMessage.h" +#import +#import #import #import diff --git a/SignalServiceKit/src/Messages/OWSMessageReceiver.m b/SignalServiceKit/src/Messages/OWSMessageReceiver.m index 3620d264e..80cebbb37 100644 --- a/SignalServiceKit/src/Messages/OWSMessageReceiver.m +++ b/SignalServiceKit/src/Messages/OWSMessageReceiver.m @@ -17,7 +17,7 @@ #import "TSDatabaseView.h" #import "TSErrorMessage.h" #import "TSYapDatabaseObject.h" -#import "Threading.h" +#import #import #import #import diff --git a/SignalServiceKit/src/Messages/OWSMessageSender.m b/SignalServiceKit/src/Messages/OWSMessageSender.m index fc92b82e5..3cf5a3f3d 100644 --- a/SignalServiceKit/src/Messages/OWSMessageSender.m +++ b/SignalServiceKit/src/Messages/OWSMessageSender.m @@ -6,7 +6,6 @@ #import "AppContext.h" #import "NSData+keyVersionByte.h" #import "NSData+messagePadding.h" -#import "NSDate+OWS.h" #import "NSError+MessageSending.h" #import "OWSBackgroundTask.h" #import "OWSBlockingManager.h" @@ -42,13 +41,14 @@ #import "TSQuotedMessage.h" #import "TSSocketManager.h" #import "TSThread.h" -#import "Threading.h" #import #import #import #import #import #import +#import +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/OWSMessageServiceParams.m b/SignalServiceKit/src/Messages/OWSMessageServiceParams.m index efed386da..b9653f50f 100644 --- a/SignalServiceKit/src/Messages/OWSMessageServiceParams.m +++ b/SignalServiceKit/src/Messages/OWSMessageServiceParams.m @@ -3,8 +3,8 @@ // #import "OWSMessageServiceParams.h" -#import "NSData+OWS.h" #import "TSConstants.h" +#import @implementation OWSMessageServiceParams diff --git a/SignalServiceKit/src/Messages/OWSOutgoingCallMessage.m b/SignalServiceKit/src/Messages/OWSOutgoingCallMessage.m index 82fea4cf5..da94b1e09 100644 --- a/SignalServiceKit/src/Messages/OWSOutgoingCallMessage.m +++ b/SignalServiceKit/src/Messages/OWSOutgoingCallMessage.m @@ -3,10 +3,10 @@ // #import "OWSOutgoingCallMessage.h" -#import "NSDate+OWS.h" #import "ProtoUtils.h" #import "SignalRecipient.h" #import "TSContactThread.h" +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/OWSOutgoingNullMessage.m b/SignalServiceKit/src/Messages/OWSOutgoingNullMessage.m index 2f3525a57..9120f8549 100644 --- a/SignalServiceKit/src/Messages/OWSOutgoingNullMessage.m +++ b/SignalServiceKit/src/Messages/OWSOutgoingNullMessage.m @@ -4,9 +4,9 @@ #import "OWSOutgoingNullMessage.h" #import "Cryptography.h" -#import "NSDate+OWS.h" #import "OWSVerificationStateSyncMessage.h" #import "TSContactThread.h" +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/OWSReadReceiptManager.m b/SignalServiceKit/src/Messages/OWSReadReceiptManager.m index c55432b67..77e391d26 100644 --- a/SignalServiceKit/src/Messages/OWSReadReceiptManager.m +++ b/SignalServiceKit/src/Messages/OWSReadReceiptManager.m @@ -4,7 +4,6 @@ #import "OWSReadReceiptManager.h" #import "AppReadiness.h" -#import "NSDate+OWS.h" #import "NSNotificationCenter+OWS.h" #import "OWSLinkedDeviceReadReceipt.h" #import "OWSMessageSender.h" @@ -18,8 +17,9 @@ #import "TSContactThread.h" #import "TSDatabaseView.h" #import "TSIncomingMessage.h" -#import "Threading.h" #import "YapDatabaseConnection+OWS.h" +#import +#import #import #import diff --git a/SignalServiceKit/src/Messages/PreKeyBundle+jsonDict.m b/SignalServiceKit/src/Messages/PreKeyBundle+jsonDict.m index d93284172..8e0df983b 100644 --- a/SignalServiceKit/src/Messages/PreKeyBundle+jsonDict.m +++ b/SignalServiceKit/src/Messages/PreKeyBundle+jsonDict.m @@ -2,8 +2,8 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -#import "NSData+OWS.h" #import "PreKeyBundle+jsonDict.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Messages/TSGroupModel.m b/SignalServiceKit/src/Messages/TSGroupModel.m index 146306a1e..1665c8133 100644 --- a/SignalServiceKit/src/Messages/TSGroupModel.m +++ b/SignalServiceKit/src/Messages/TSGroupModel.m @@ -4,7 +4,7 @@ #import "TSGroupModel.h" #import "FunctionalUtil.h" -#import "NSString+SSK.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Network/API/OWSRequestBuilder.m b/SignalServiceKit/src/Network/API/OWSRequestBuilder.m index d5fa82179..31dca1149 100644 --- a/SignalServiceKit/src/Network/API/OWSRequestBuilder.m +++ b/SignalServiceKit/src/Network/API/OWSRequestBuilder.m @@ -3,9 +3,9 @@ // #import "OWSRequestBuilder.h" -#import "NSData+OWS.h" #import "TSConstants.h" #import "TSRequest.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m b/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m index 04caf17a8..cea381d5f 100644 --- a/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m +++ b/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m @@ -3,7 +3,6 @@ // #import "OWSRequestFactory.h" -#import "NSData+OWS.h" #import "OWS2FAManager.h" #import "OWSDevice.h" #import "TSAttributes.h" @@ -12,6 +11,7 @@ #import #import #import +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Network/API/TSNetworkManager.m b/SignalServiceKit/src/Network/API/TSNetworkManager.m index 2c57838fd..46956f211 100644 --- a/SignalServiceKit/src/Network/API/TSNetworkManager.m +++ b/SignalServiceKit/src/Network/API/TSNetworkManager.m @@ -4,7 +4,6 @@ #import "TSNetworkManager.h" #import "AppContext.h" -#import "NSData+OWS.h" #import "NSError+messageSending.h" #import "NSURLSessionDataTask+StatusCode.h" #import "OWSSignalService.h" @@ -12,6 +11,7 @@ #import "TSAccountManager.h" #import "TSVerifyCodeRequest.h" #import +#import #import NSString *const TSNetworkManagerDomain = @"org.whispersystems.signal.networkManager"; diff --git a/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m b/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m index 490a90bee..f5374d422 100644 --- a/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m +++ b/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m @@ -21,7 +21,7 @@ #import "TSConstants.h" #import "TSErrorMessage.h" #import "TSRequest.h" -#import "Threading.h" +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Security/OWSFingerprint.m b/SignalServiceKit/src/Security/OWSFingerprint.m index 201a904da..2742b2a82 100644 --- a/SignalServiceKit/src/Security/OWSFingerprint.m +++ b/SignalServiceKit/src/Security/OWSFingerprint.m @@ -3,10 +3,10 @@ // #import "OWSFingerprint.h" -#import "NSData+OWS.h" #import "OWSError.h" #import #import +#import #import #import diff --git a/SignalServiceKit/src/Storage/OWSStorage.m b/SignalServiceKit/src/Storage/OWSStorage.m index cc6248acb..02664fb8d 100644 --- a/SignalServiceKit/src/Storage/OWSStorage.m +++ b/SignalServiceKit/src/Storage/OWSStorage.m @@ -4,7 +4,6 @@ #import "OWSStorage.h" #import "AppContext.h" -#import "NSData+OWS.h" #import "NSNotificationCenter+OWS.h" #import "NSUserDefaults+OWS.h" #import "OWSBackgroundTask.h" @@ -13,6 +12,7 @@ #import "OWSStorage+Subclass.h" #import "TSAttachmentStream.h" #import +#import #import #import #import diff --git a/SignalServiceKit/src/TSPrefix.h b/SignalServiceKit/src/TSPrefix.h index c87b0f144..424b2f935 100644 --- a/SignalServiceKit/src/TSPrefix.h +++ b/SignalServiceKit/src/TSPrefix.h @@ -11,6 +11,10 @@ static const NSUInteger ddLogLevel = DDLogLevelAll; #else static const NSUInteger ddLogLevel = DDLogLevelInfo; #endif -#import "NSObject+OWS.h" #import "OWSAnalytics.h" -#import "OWSAsserts.h" +#import "SSKAsserts.h" + +//#import +//#import +#import +#import diff --git a/SignalServiceKit/src/Util/AppReadiness.m b/SignalServiceKit/src/Util/AppReadiness.m index 4621e0cc1..33b799179 100755 --- a/SignalServiceKit/src/Util/AppReadiness.m +++ b/SignalServiceKit/src/Util/AppReadiness.m @@ -3,7 +3,7 @@ // #import "AppReadiness.h" -#import "Threading.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Util/Cryptography.m b/SignalServiceKit/src/Util/Cryptography.m index 54af4a3cb..8b44cfa97 100755 --- a/SignalServiceKit/src/Util/Cryptography.m +++ b/SignalServiceKit/src/Util/Cryptography.m @@ -3,11 +3,11 @@ // #import "Cryptography.h" -#import "NSData+OWS.h" #import "OWSError.h" #import #import #import +#import #import #define HMAC256_KEY_LENGTH 32 diff --git a/SignalServiceKit/src/Util/DataSource.m b/SignalServiceKit/src/Util/DataSource.m index 0bfd6e57d..33a9f890a 100755 --- a/SignalServiceKit/src/Util/DataSource.m +++ b/SignalServiceKit/src/Util/DataSource.m @@ -5,9 +5,9 @@ #import "DataSource.h" #import "MIMETypeUtil.h" #import "NSData+Image.h" -#import "NSString+SSK.h" #import "OWSFileSystem.h" -#import "iOSVersions.h" +#import +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Util/Logger.swift b/SignalServiceKit/src/Util/Logger.swift deleted file mode 100644 index be05f3e1c..000000000 --- a/SignalServiceKit/src/Util/Logger.swift +++ /dev/null @@ -1,77 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -import Foundation - -// Once we're on Swift4.2 we can mark this as inlineable -// @inlinable -public func owsFormatLogMessage(_ logString: String, - file: String = #file, - function: String = #function, - line: Int = #line) -> String { - let filename = (file as NSString).lastPathComponent - // We format the filename & line number in a format compatible - // with XCode's "Open Quickly..." feature. - return "[\(filename):\(line) \(function)]: \(logString)" -} - -/** - * A minimal DDLog wrapper for swift. - */ -open class Logger: NSObject { - - open class func verbose(_ logString: @autoclosure () -> String, - file: String = #file, - function: String = #function, - line: Int = #line) { - guard ShouldLogVerbose() else { - return - } - OWSLogger.verbose(owsFormatLogMessage(logString(), file: file, function: function, line: line)) - } - - open class func debug(_ logString: @autoclosure () -> String, - file: String = #file, - function: String = #function, - line: Int = #line) { - guard ShouldLogDebug() else { - return - } - OWSLogger.debug(owsFormatLogMessage(logString(), file: file, function: function, line: line)) - } - - open class func info(_ logString: @autoclosure () -> String, - file: String = #file, - function: String = #function, - line: Int = #line) { - guard ShouldLogInfo() else { - return - } - OWSLogger.info(owsFormatLogMessage(logString(), file: file, function: function, line: line)) - } - - open class func warn(_ logString: @autoclosure () -> String, - file: String = #file, - function: String = #function, - line: Int = #line) { - guard ShouldLogWarning() else { - return - } - OWSLogger.warn(owsFormatLogMessage(logString(), file: file, function: function, line: line)) - } - - open class func error(_ logString: @autoclosure () -> String, - file: String = #file, - function: String = #function, - line: Int = #line) { - guard ShouldLogError() else { - return - } - OWSLogger.error(owsFormatLogMessage(logString(), file: file, function: function, line: line)) - } - - open class func flush() { - OWSLogger.flush() - } -} diff --git a/SignalServiceKit/src/Util/NSData+OWS.h b/SignalServiceKit/src/Util/NSData+OWS.h deleted file mode 100644 index 1bf6baae8..000000000 --- a/SignalServiceKit/src/Util/NSData+OWS.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface NSData (OWS) - -+ (NSData *)join:(NSArray *)datas; - -- (NSData *)dataByAppendingData:(NSData *)data; - -- (NSString *)hexadecimalString; - -#pragma mark - Base64 - -+ (NSData *)dataFromBase64StringNoPadding:(NSString *)aString; -+ (NSData *)dataFromBase64String:(NSString *)aString; - -- (NSString *)base64EncodedString; - -@end - -NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/NSData+OWS.m b/SignalServiceKit/src/Util/NSData+OWS.m deleted file mode 100644 index 2a39f91a8..000000000 --- a/SignalServiceKit/src/Util/NSData+OWS.m +++ /dev/null @@ -1,95 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -#import "NSData+OWS.h" - -NS_ASSUME_NONNULL_BEGIN - -@implementation NSData (OWS) - -+ (NSData *)join:(NSArray *)datas -{ - OWSAssert(datas); - - NSMutableData *result = [NSMutableData new]; - for (NSData *data in datas) { - [result appendData:data]; - } - return [result copy]; -} - -- (NSData *)dataByAppendingData:(NSData *)data -{ - NSMutableData *result = [self mutableCopy]; - [result appendData:data]; - return [result copy]; -} - -- (NSString *)hexadecimalString -{ - /* Returns hexadecimal string of NSData. Empty string if data is empty. */ - const unsigned char *dataBuffer = (const unsigned char *)[self bytes]; - if (!dataBuffer) { - return @""; - } - - NSUInteger dataLength = [self length]; - NSMutableString *hexString = [NSMutableString stringWithCapacity:(dataLength * 2)]; - - for (NSUInteger i = 0; i < dataLength; ++i) { - [hexString appendFormat:@"%02x", dataBuffer[i]]; - } - return [hexString copy]; -} - -#pragma mark - Base64 - -+ (NSData *)dataFromBase64StringNoPadding:(NSString *)aString -{ - int padding = aString.length % 4; - - NSMutableString *strResult = [aString mutableCopy]; - if (padding != 0) { - int charsToAdd = 4 - padding; - for (int i = 0; i < charsToAdd; i++) { - [strResult appendString:@"="]; - } - } - return [self dataFromBase64String:strResult]; -} - -// -// dataFromBase64String: -// -// Creates an NSData object containing the base64 decoded representation of -// the base64 string 'aString' -// -// Parameters: -// aString - the base64 string to decode -// -// returns the NSData representation of the base64 string -// - -+ (NSData *)dataFromBase64String:(NSString *)aString -{ - return [[NSData alloc] initWithBase64EncodedString:aString options:NSDataBase64DecodingIgnoreUnknownCharacters]; -} - -// -// base64EncodedString -// -// Creates an NSString object that contains the base 64 encoding of the -// receiver's data. Lines are broken at 64 characters long. -// -// returns an NSString being the base 64 representation of the -// receiver. -// -- (NSString *)base64EncodedString -{ - return [self base64EncodedStringWithOptions:0]; -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/NSDate+OWS.h b/SignalServiceKit/src/Util/NSDate+OWS.h deleted file mode 100755 index 10167abad..000000000 --- a/SignalServiceKit/src/Util/NSDate+OWS.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -NS_ASSUME_NONNULL_BEGIN - -// These NSTimeInterval constants provide simplified durations for readability. -// -// These approximations should never be used for strict date/time calcuations. -extern const NSTimeInterval kSecondInterval; -extern const NSTimeInterval kMinuteInterval; -extern const NSTimeInterval kHourInterval; -extern const NSTimeInterval kDayInterval; -extern const NSTimeInterval kWeekInterval; -extern const NSTimeInterval kMonthInterval; -extern const NSTimeInterval kYearInterval; - -#define kSecondInMs ((uint64_t)1000) -#define kMinuteInMs (kSecondInMs * 60) -#define kHourInMs (kMinuteInMs * 60) -#define kDayInMs (kHourInMs * 24) -#define kWeekInMs (kDayInMs * 7) -#define kMonthInMs (kDayInMs * 30) - -// kYearsInMs is a double to avoid overflow -#define kYearsInMs (kDayInMs * 365.0) - -@interface NSDate (OWS) - -+ (uint64_t)ows_millisecondTimeStamp; -+ (NSDate *)ows_dateWithMillisecondsSince1970:(uint64_t)milliseconds; -+ (uint64_t)ows_millisecondsSince1970ForDate:(NSDate *)date; - -- (BOOL)isAfterDate:(NSDate *)otherDate; -- (BOOL)isBeforeDate:(NSDate *)otherDate; - -- (BOOL)isAfterNow; -- (BOOL)isBeforeNow; - -@end - -NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/NSDate+OWS.mm b/SignalServiceKit/src/Util/NSDate+OWS.mm deleted file mode 100644 index 2e81a44e0..000000000 --- a/SignalServiceKit/src/Util/NSDate+OWS.mm +++ /dev/null @@ -1,60 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -#import "NSDate+OWS.h" -#import - -NS_ASSUME_NONNULL_BEGIN - - -const NSTimeInterval kSecondInterval = 1; -const NSTimeInterval kMinuteInterval = 60; -const NSTimeInterval kHourInterval = 60 * kMinuteInterval; -const NSTimeInterval kDayInterval = 24 * kHourInterval; -const NSTimeInterval kWeekInterval = 7 * kDayInterval; -const NSTimeInterval kMonthInterval = 30 * kDayInterval; -const NSTimeInterval kYearInterval = 365 * kDayInterval; - -@implementation NSDate (OWS) - -+ (uint64_t)ows_millisecondTimeStamp -{ - uint64_t milliseconds - = (uint64_t)(std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1)); - return milliseconds; -} - -+ (NSDate *)ows_dateWithMillisecondsSince1970:(uint64_t)milliseconds -{ - return [NSDate dateWithTimeIntervalSince1970:(milliseconds / 1000.0)]; -} - -+ (uint64_t)ows_millisecondsSince1970ForDate:(NSDate *)date -{ - return (uint64_t)(date.timeIntervalSince1970 * 1000); -} - -- (BOOL)isAfterDate:(NSDate *)otherDate -{ - return [self compare:otherDate] == NSOrderedDescending; -} - -- (BOOL)isBeforeDate:(NSDate *)otherDate -{ - return [self compare:otherDate] == NSOrderedAscending; -} - -- (BOOL)isAfterNow -{ - return [self isAfterDate:[NSDate new]]; -} - -- (BOOL)isBeforeNow -{ - return [self isBeforeDate:[NSDate new]]; -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/NSObject+OWS.h b/SignalServiceKit/src/Util/NSObject+OWS.h deleted file mode 100644 index 478a197cd..000000000 --- a/SignalServiceKit/src/Util/NSObject+OWS.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -NS_ASSUME_NONNULL_BEGIN - -@interface NSObject (OWS) - -#pragma mark - Logging - -@property (nonatomic, readonly) NSString *logTag; - -@property (class, nonatomic, readonly) NSString *logTag; - -+ (BOOL)isNullableObject:(nullable NSObject *)left equalTo:(nullable NSObject *)right; - -@end - -NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/NSObject+OWS.m b/SignalServiceKit/src/Util/NSObject+OWS.m deleted file mode 100644 index 6934a0faa..000000000 --- a/SignalServiceKit/src/Util/NSObject+OWS.m +++ /dev/null @@ -1,37 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -#import "NSObject+OWS.h" -#import "TSYapDatabaseObject.h" - -NS_ASSUME_NONNULL_BEGIN - -@implementation NSObject (OWS) - -#pragma mark - Logging - -+ (NSString *)logTag -{ - return [NSString stringWithFormat:@"[%@]", self.class]; -} - -- (NSString *)logTag -{ - return self.class.logTag; -} - -+ (BOOL)isNullableObject:(nullable NSObject *)left equalTo:(nullable NSObject *)right -{ - if (!left && !right) { - return YES; - } else if (!left || !right) { - return NO; - } else { - return [left isEqual:right]; - } -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/NSString+SSK.h b/SignalServiceKit/src/Util/NSString+SSK.h deleted file mode 100644 index f156c8992..000000000 --- a/SignalServiceKit/src/Util/NSString+SSK.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -NS_ASSUME_NONNULL_BEGIN - -@interface NSString (SSK) - -- (NSString *)ows_stripped; - -- (NSString *)filterStringForDisplay; - -- (NSString *)filterFilename; - -- (BOOL)isValidE164; - -+ (NSString *)formatDurationSeconds:(uint32_t)durationSeconds useShortFormat:(BOOL)useShortFormat; - -@end - -NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/NSString+SSK.m b/SignalServiceKit/src/Util/NSString+SSK.m deleted file mode 100644 index a384c0fae..000000000 --- a/SignalServiceKit/src/Util/NSString+SSK.m +++ /dev/null @@ -1,372 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -#import "NSString+SSK.h" -#import "iOSVersions.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface UnicodeCodeRange : NSObject - -@property (nonatomic) unichar first; -@property (nonatomic) unichar last; - -@end - -#pragma mark - - -@implementation UnicodeCodeRange - -+ (UnicodeCodeRange *)rangeWithStart:(unichar)first last:(unichar)last -{ - OWSAssertDebug(first <= last); - - UnicodeCodeRange *range = [UnicodeCodeRange new]; - range.first = first; - range.last = last; - return range; -} - -- (NSComparisonResult)compare:(UnicodeCodeRange *)other -{ - - return self.first > other.first; -} - -@end - -#pragma mark - - -@implementation NSString (SSK) - -- (NSString *)ows_stripped -{ - return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; -} - -+ (BOOL)shouldFilterIndic -{ - static BOOL result = NO; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - result = (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(11, 0) && !SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(11, 3)); - }); - return result; -} - -+ (BOOL)isIndicVowel:(unichar)c -{ - static NSArray *ranges; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - // From: - // https://unicode.org/charts/PDF/U0C00.pdf - // https://unicode.org/charts/PDF/U0980.pdf - // https://unicode.org/charts/PDF/U0900.pdf - ranges = [@[ - // Telugu: - [UnicodeCodeRange rangeWithStart:0xC05 last:0xC14], - [UnicodeCodeRange rangeWithStart:0xC3E last:0xC4C], - [UnicodeCodeRange rangeWithStart:0xC60 last:0xC63], - // Bengali - [UnicodeCodeRange rangeWithStart:0x985 last:0x994], - [UnicodeCodeRange rangeWithStart:0x9BE last:0x9C8], - [UnicodeCodeRange rangeWithStart:0x9CB last:0x9CC], - [UnicodeCodeRange rangeWithStart:0x9E0 last:0x9E3], - // Devanagari - [UnicodeCodeRange rangeWithStart:0x904 last:0x914], - [UnicodeCodeRange rangeWithStart:0x93A last:0x93B], - [UnicodeCodeRange rangeWithStart:0x93E last:0x94C], - [UnicodeCodeRange rangeWithStart:0x94E last:0x94F], - [UnicodeCodeRange rangeWithStart:0x955 last:0x957], - [UnicodeCodeRange rangeWithStart:0x960 last:0x963], - [UnicodeCodeRange rangeWithStart:0x972 last:0x977], - ] sortedArrayUsingSelector:@selector(compare:)]; - }); - - for (UnicodeCodeRange *range in ranges) { - if (c < range.first) { - // For perf, we can take advantage of the fact that the - // ranges are sorted to exit early if the character lies - // before the current range. - return NO; - } - if (range.first <= c && c <= range.last) { - return YES; - } - } - return NO; -} - -+ (NSCharacterSet *)problematicCharacterSetForIndicScript -{ - static NSCharacterSet *characterSet; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - characterSet = [NSCharacterSet characterSetWithCharactersInString:@"\u200C"]; - }); - - return characterSet; -} - -// See: https://manishearth.github.io/blog/2018/02/15/picking-apart-the-crashing-ios-string/ -- (NSString *)filterForIndicScripts -{ - if (!NSString.shouldFilterIndic) { - return self; - } - - if ([self rangeOfCharacterFromSet:[[self class] problematicCharacterSetForIndicScript]].location == NSNotFound) { - return self; - } - - NSMutableString *filteredForIndic = [NSMutableString new]; - for (NSUInteger index = 0; index < self.length; index++) { - unichar c = [self characterAtIndex:index]; - if (c == 0x200C) { - NSUInteger nextIndex = index + 1; - if (nextIndex < self.length) { - unichar next = [self characterAtIndex:nextIndex]; - if ([NSString isIndicVowel:next]) { - // Discard ZWNJ (zero-width non-joiner) whenever we find a ZWNJ - // followed by an Indic (Telugu, Bengali, Devanagari) vowel - // and replace it with 0xFFFD, the Unicode "replacement character." - [filteredForIndic appendFormat:@"\uFFFD"]; - OWSLogError(@"Filtered unsafe Indic script."); - // Then discard the vowel too. - index++; - continue; - } - } - } - [filteredForIndic appendFormat:@"%C", c]; - } - return [filteredForIndic copy]; -} - -+ (NSCharacterSet *)unsafeFilenameCharacterSet -{ - static NSCharacterSet *characterSet; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - // 0x202D and 0x202E are the unicode ordering letters - // and can be used to control the rendering of text. - // They could be used to construct misleading attachment - // filenames that appear to have a different file extension, - // for example. - characterSet = [NSCharacterSet characterSetWithCharactersInString:@"\u202D\u202E"]; - }); - - return characterSet; -} - -- (NSString *)filterUnsafeFilenameCharacters -{ - NSCharacterSet *unsafeCharacterSet = [[self class] unsafeFilenameCharacterSet]; - NSRange range = [self rangeOfCharacterFromSet:unsafeCharacterSet]; - if (range.location == NSNotFound) { - return self; - } - NSMutableString *filtered = [NSMutableString new]; - NSString *remainder = [self copy]; - while (range.location != NSNotFound) { - if (range.location > 0) { - [filtered appendString:[remainder substringToIndex:range.location]]; - } - // The "replacement" code point. - [filtered appendString:@"\uFFFD"]; - remainder = [remainder substringFromIndex:range.location + range.length]; - range = [remainder rangeOfCharacterFromSet:unsafeCharacterSet]; - } - [filtered appendString:remainder]; - return filtered; -} - -- (NSString *)filterStringForDisplay -{ - return self.ows_stripped.filterForIndicScripts.filterForExcessiveDiacriticals; -} - -- (NSString *)filterFilename -{ - return self.ows_stripped.filterForIndicScripts.filterForExcessiveDiacriticals.filterUnsafeFilenameCharacters; -} - -- (NSString *)filterForExcessiveDiacriticals -{ - if (!self.hasExcessiveDiacriticals) { - return self; - } - return [self stringByFoldingWithOptions:NSDiacriticInsensitiveSearch locale:[NSLocale currentLocale]]; -} - -- (BOOL)hasExcessiveDiacriticals -{ - // discard any zalgo style text, by detecting maximum number of glyphs per character - NSUInteger index = 0; - while (index < self.length) { - // Walk the grapheme clusters in the string. - NSRange range = [self rangeOfComposedCharacterSequenceAtIndex:index]; - if (range.length > 8) { - // There are too many characters in this grapheme cluster. - return YES; - } else if (range.location != index || range.length < 1) { - // This should never happen. - OWSFailDebug( - @"unexpected composed character sequence: %lu, %@", (unsigned long)index, NSStringFromRange(range)); - return YES; - } - index = range.location + range.length; - } - return NO; -} - -- (BOOL)isValidE164 -{ - NSError *error = nil; - NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^\\+\\d+$" - options:NSRegularExpressionCaseInsensitive - error:&error]; - if (error || !regex) { - OWSFailDebug(@"could not compile regex: %@", error); - return NO; - } - return [regex rangeOfFirstMatchInString:self options:0 range:NSMakeRange(0, self.length)].location != NSNotFound; -} - -+ (NSString *)formatDurationSeconds:(uint32_t)durationSeconds useShortFormat:(BOOL)useShortFormat -{ - NSString *amountFormat; - uint32_t duration; - - uint32_t secondsPerMinute = 60; - uint32_t secondsPerHour = secondsPerMinute * 60; - uint32_t secondsPerDay = secondsPerHour * 24; - uint32_t secondsPerWeek = secondsPerDay * 7; - - if (durationSeconds < secondsPerMinute) { // XX Seconds - if (useShortFormat) { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_SECONDS_SHORT_FORMAT", - @"Label text below navbar button, embeds {{number of seconds}}. Must be very short, like 1 or 2 " - @"characters, The space is intentionally omitted between the text and the embedded duration so that " - @"we get, e.g. '5s' not '5 s'. See other *_TIME_AMOUNT strings"); - } else { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_SECONDS", - @"{{number of seconds}} embedded in strings, e.g. 'Alice updated disappearing messages " - @"expiration to {{5 seconds}}'. See other *_TIME_AMOUNT strings"); - } - - duration = durationSeconds; - } else if (durationSeconds < secondsPerMinute * 1.5) { // 1 Minute - if (useShortFormat) { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_MINUTES_SHORT_FORMAT", - @"Label text below navbar button, embeds {{number of minutes}}. Must be very short, like 1 or 2 " - @"characters, The space is intentionally omitted between the text and the embedded duration so that " - @"we get, e.g. '5m' not '5 m'. See other *_TIME_AMOUNT strings"); - } else { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_SINGLE_MINUTE", - @"{{1 minute}} embedded in strings, e.g. 'Alice updated disappearing messages " - @"expiration to {{1 minute}}'. See other *_TIME_AMOUNT strings"); - } - duration = durationSeconds / secondsPerMinute; - } else if (durationSeconds < secondsPerHour) { // Multiple Minutes - if (useShortFormat) { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_MINUTES_SHORT_FORMAT", - @"Label text below navbar button, embeds {{number of minutes}}. Must be very short, like 1 or 2 " - @"characters, The space is intentionally omitted between the text and the embedded duration so that " - @"we get, e.g. '5m' not '5 m'. See other *_TIME_AMOUNT strings"); - } else { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_MINUTES", - @"{{number of minutes}} embedded in strings, e.g. 'Alice updated disappearing messages " - @"expiration to {{5 minutes}}'. See other *_TIME_AMOUNT strings"); - } - - duration = durationSeconds / secondsPerMinute; - } else if (durationSeconds < secondsPerHour * 1.5) { // 1 Hour - if (useShortFormat) { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_HOURS_SHORT_FORMAT", - @"Label text below navbar button, embeds {{number of hours}}. Must be very short, like 1 or 2 " - @"characters, The space is intentionally omitted between the text and the embedded duration so that " - @"we get, e.g. '5h' not '5 h'. See other *_TIME_AMOUNT strings"); - } else { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_SINGLE_HOUR", - @"{{1 hour}} embedded in strings, e.g. 'Alice updated disappearing messages " - @"expiration to {{1 hour}}'. See other *_TIME_AMOUNT strings"); - } - - duration = durationSeconds / secondsPerHour; - } else if (durationSeconds < secondsPerDay) { // Multiple Hours - if (useShortFormat) { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_HOURS_SHORT_FORMAT", - @"Label text below navbar button, embeds {{number of hours}}. Must be very short, like 1 or 2 " - @"characters, The space is intentionally omitted between the text and the embedded duration so that " - @"we get, e.g. '5h' not '5 h'. See other *_TIME_AMOUNT strings"); - } else { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_HOURS", - @"{{number of hours}} embedded in strings, e.g. 'Alice updated disappearing messages " - @"expiration to {{5 hours}}'. See other *_TIME_AMOUNT strings"); - } - - duration = durationSeconds / secondsPerHour; - } else if (durationSeconds < secondsPerDay * 1.5) { // 1 Day - if (useShortFormat) { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_DAYS_SHORT_FORMAT", - @"Label text below navbar button, embeds {{number of days}}. Must be very short, like 1 or 2 " - @"characters, The space is intentionally omitted between the text and the embedded duration so that " - @"we get, e.g. '5d' not '5 d'. See other *_TIME_AMOUNT strings"); - } else { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_SINGLE_DAY", - @"{{1 day}} embedded in strings, e.g. 'Alice updated disappearing messages " - @"expiration to {{1 day}}'. See other *_TIME_AMOUNT strings"); - } - - duration = durationSeconds / secondsPerDay; - } else if (durationSeconds < secondsPerWeek) { // Multiple Days - if (useShortFormat) { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_DAYS_SHORT_FORMAT", - @"Label text below navbar button, embeds {{number of days}}. Must be very short, like 1 or 2 " - @"characters, The space is intentionally omitted between the text and the embedded duration so that " - @"we get, e.g. '5d' not '5 d'. See other *_TIME_AMOUNT strings"); - } else { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_DAYS", - @"{{number of days}} embedded in strings, e.g. 'Alice updated disappearing messages " - @"expiration to {{5 days}}'. See other *_TIME_AMOUNT strings"); - } - - duration = durationSeconds / secondsPerDay; - } else if (durationSeconds < secondsPerWeek * 1.5) { // 1 Week - if (useShortFormat) { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_WEEKS_SHORT_FORMAT", - @"Label text below navbar button, embeds {{number of weeks}}. Must be very short, like 1 or 2 " - @"characters, The space is intentionally omitted between the text and the embedded duration so that " - @"we get, e.g. '5w' not '5 w'. See other *_TIME_AMOUNT strings"); - } else { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_SINGLE_WEEK", - @"{{1 week}} embedded in strings, e.g. 'Alice updated disappearing messages " - @"expiration to {{1 week}}'. See other *_TIME_AMOUNT strings"); - } - - duration = durationSeconds / secondsPerWeek; - } else { // Multiple weeks - if (useShortFormat) { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_WEEKS_SHORT_FORMAT", - @"Label text below navbar button, embeds {{number of weeks}}. Must be very short, like 1 or 2 " - @"characters, The space is intentionally omitted between the text and the embedded duration so that " - @"we get, e.g. '5w' not '5 w'. See other *_TIME_AMOUNT strings"); - } else { - amountFormat = NSLocalizedString(@"TIME_AMOUNT_WEEKS", - @"{{number of weeks}}, embedded in strings, e.g. 'Alice updated disappearing messages " - @"expiration to {{5 weeks}}'. See other *_TIME_AMOUNT strings"); - } - - duration = durationSeconds / secondsPerWeek; - } - - return [NSString stringWithFormat:amountFormat, - [NSNumberFormatter localizedStringFromNumber:@(duration) numberStyle:NSNumberFormatterNoStyle]]; -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/OWSAsserts.h b/SignalServiceKit/src/Util/OWSAsserts.h deleted file mode 100755 index 35e9748f1..000000000 --- a/SignalServiceKit/src/Util/OWSAsserts.h +++ /dev/null @@ -1,241 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -#import "AppContext.h" -#import "OWSLogger.h" - -NS_ASSUME_NONNULL_BEGIN - -#ifndef OWSAssert - -#define CONVERT_TO_STRING(X) #X -#define CONVERT_EXPR_TO_STRING(X) CONVERT_TO_STRING(X) - -#ifdef DEBUG - -#define USE_ASSERTS - -// OWSAssertDebug() and OWSFailDebug() should be used in Obj-C methods. -// OWSCAssertDebug() and OWSCFailDebug() should be used in free functions. - -#define OWSAssertDebug(X) \ - do { \ - if (!(X)) { \ - OWSLogError(@"Assertion failed: %s", CONVERT_EXPR_TO_STRING(X)); \ - [DDLog flushLog]; \ - NSAssert(0, @"Assertion failed: %s", CONVERT_EXPR_TO_STRING(X)); \ - } \ - } while (NO) - -#define OWSCAssertDebug(X) \ - do { \ - if (!(X)) { \ - OWSLogError(@"Assertion failed: %s", CONVERT_EXPR_TO_STRING(X)); \ - [DDLog flushLog]; \ - NSCAssert(0, @"Assertion failed: %s", CONVERT_EXPR_TO_STRING(X)); \ - } \ - } while (NO) - -#define OWSFailWithoutLogging(message, ...) \ - do { \ - NSString *formattedMessage = [NSString stringWithFormat:message, ##__VA_ARGS__]; \ - NSAssert(0, formattedMessage); \ - } while (NO) - -#define OWSCFailWithoutLogging(message, ...) \ - do { \ - NSString *formattedMessage = [NSString stringWithFormat:message, ##__VA_ARGS__]; \ - NSCAssert(0, formattedMessage); \ - } while (NO) - -#define OWSFailNoFormat(message) \ - do { \ - OWSLogError(@"%@", message); \ - [DDLog flushLog]; \ - NSAssert(0, message); \ - } while (NO) - -#define OWSCFailNoFormat(message) \ - do { \ - OWSLogError(@"%@", message); \ - [DDLog flushLog]; \ - NSCAssert(0, message); \ - } while (NO) - -#else - -#define OWSAssertDebug(X) -#define OWSCAssertDebug(X) -#define OWSFailWithoutLogging(message, ...) -#define OWSCFailWithoutLogging(message, ...) -#define OWSFailNoFormat(X) -#define OWSCFailNoFormat(X) - -#endif - -#endif - -// Like OWSAssertDebug, but will fail in production, terminating the app -#define OWSAssert(X) \ - do { \ - if (!(X)) { \ - OWSFail(@"Assertion failed: %s", CONVERT_EXPR_TO_STRING(X)); \ - } \ - } while (NO) - -#define OWSCAssert(X) \ - do { \ - if (!(X)) { \ - OWSCFail(@"Assertion failed: %s", CONVERT_EXPR_TO_STRING(X)); \ - } \ - } while (NO) - -#define OWSAbstractMethod() OWSFail(@"Method needs to be implemented by subclasses.") - -#pragma mark - Singleton Asserts - -// The "singleton asserts" can be used to ensure -// that we only create a singleton once. -// -// The simplest way to use them is the OWSSingletonAssert() macro. -// It is intended to be used inside the singleton's initializer. -// -// If, however, a singleton has multiple possible initializers, -// you need to: -// -// 1. Use OWSSingletonAssertFlag() outside the class definition. -// 2. Use OWSSingletonAssertInit() in each initializer. - -#ifdef DEBUG - -#define ENFORCE_SINGLETONS - -#endif - -#ifdef ENFORCE_SINGLETONS - -#define OWSSingletonAssertFlag() static BOOL _isSingletonCreated = NO; - -#define OWSSingletonAssertInit() \ - @synchronized([self class]) \ - { \ - if (!CurrentAppContext().isRunningTests) { \ - OWSAssertDebug(!_isSingletonCreated); \ - _isSingletonCreated = YES; \ - } \ - } - -#define OWSSingletonAssert() OWSSingletonAssertFlag() OWSSingletonAssertInit() - -#else - -#define OWSSingletonAssertFlag() -#define OWSSingletonAssertInit() -#define OWSSingletonAssert() - -#endif - -// This macro is intended for use in Objective-C. -#define OWSAssertIsOnMainThread() OWSCAssertDebug([NSThread isMainThread]) - -#define OWSFailDebug(_messageFormat, ...) \ - do { \ - OWSLogError(_messageFormat, ##__VA_ARGS__); \ - [DDLog flushLog]; \ - OWSFailWithoutLogging(_messageFormat, ##__VA_ARGS__); \ - } while (0) - -#define OWSCFailDebug(_messageFormat, ...) \ - do { \ - OWSLogError(_messageFormat, ##__VA_ARGS__); \ - [DDLog flushLog]; \ - OWSCFailWithoutLogging(_messageFormat, ##__VA_ARGS__); \ - } while (NO) - -void SwiftExit(NSString *message, const char *file, const char *function, int line); - -#define OWSFail(_messageFormat, ...) \ - do { \ - OWSFailDebug(_messageFormat, ##__VA_ARGS__); \ - \ - NSString *_message = [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]; \ - SwiftExit(_message, __FILE__, __PRETTY_FUNCTION__, __LINE__); \ - } while (0) - -#define OWSCFail(_messageFormat, ...) \ - do { \ - OWSCFailDebug(_messageFormat, ##__VA_ARGS__); \ - \ - NSString *_message = [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]; \ - SwiftExit(_message, __FILE__, __PRETTY_FUNCTION__, __LINE__); \ - } while (NO) - -// Avoids Clang analyzer warning: -// Value stored to 'x' during it's initialization is never read -#define SUPPRESS_DEADSTORE_WARNING(x) \ - do { \ - (void)x; \ - } while (0) - -__attribute__((annotate("returns_localized_nsstring"))) static inline NSString *LocalizationNotNeeded(NSString *s) -{ - return s; -} - -#define OWSRaiseException(name, formatParam, ...) \ - do { \ - OWSLogError(@"Exception: %@ %@", name, [NSString stringWithFormat:formatParam, ##__VA_ARGS__]); \ - [DDLog flushLog]; \ - @throw [NSException exceptionWithName:name \ - reason:[NSString stringWithFormat:formatParam, ##__VA_ARGS__] \ - userInfo:nil]; \ - } while (NO) - -#define OWSRaiseExceptionWithUserInfo(name, userInfoParam, formatParam, ...) \ - do { \ - OWSLogError( \ - @"Exception: %@ %@ %@", name, userInfoParam, [NSString stringWithFormat:formatParam, ##__VA_ARGS__]); \ - [DDLog flushLog]; \ - @throw [NSException exceptionWithName:name \ - reason:[NSString stringWithFormat:formatParam, ##__VA_ARGS__] \ - userInfo:userInfoParam]; \ - } while (NO) - - -// UI JANK -// -// In pursuit of smooth UI, we want to continue moving blocking operations off the main thread. -// Add `OWSJanksUI` in code paths that shouldn't be called on the main thread. -// Because we have pervasively broken this tenant, enabling it by default would be too disruptive -// but it's helpful while unjanking and maybe someday we can have it enabled by default. -//#define DEBUG_UI_JANK 1 - -#ifdef DEBUG -#ifdef DEBUG_UI_JANK -#define OWSJanksUI() \ - do { \ - OWSAssertDebug(![NSThread isMainThread]) \ - } while (NO) -#endif -#endif - -#ifndef OWSJanksUI -#define OWSJanksUI() -#endif - -#pragma mark - Overflow Math - -#define ows_add_overflow(a, b, resultRef) \ - do { \ - BOOL _didOverflow = __builtin_add_overflow(a, b, resultRef); \ - OWSAssert(!_didOverflow); \ - } while (NO) - -#define ows_sub_overflow(a, b, resultRef) \ - do { \ - BOOL _didOverflow = __builtin_sub_overflow(a, b, resultRef); \ - OWSAssert(!_didOverflow); \ - } while (NO) - -NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/OWSAsserts.m b/SignalServiceKit/src/Util/OWSAsserts.m deleted file mode 100755 index a5afbe2d7..000000000 --- a/SignalServiceKit/src/Util/OWSAsserts.m +++ /dev/null @@ -1,17 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -#import "OWSAsserts.h" -#import - -NS_ASSUME_NONNULL_BEGIN - -void SwiftExit(NSString *message, const char *file, const char *function, int line) -{ - NSString *_file = [NSString stringWithFormat:@"%s", file]; - NSString *_function = [NSString stringWithFormat:@"%s", function]; - [OWSSwiftUtils owsFail:message file:_file function:_function line:line]; -} - -NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/OWSBackgroundTask.m b/SignalServiceKit/src/Util/OWSBackgroundTask.m index 127368bdc..af746bf41 100644 --- a/SignalServiceKit/src/Util/OWSBackgroundTask.m +++ b/SignalServiceKit/src/Util/OWSBackgroundTask.m @@ -5,7 +5,7 @@ #import "OWSBackgroundTask.h" #import "AppContext.h" #import "NSTimer+OWS.h" -#import "Threading.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/src/Util/OWSLogger.h b/SignalServiceKit/src/Util/OWSLogger.h deleted file mode 100644 index c8525309f..000000000 --- a/SignalServiceKit/src/Util/OWSLogger.h +++ /dev/null @@ -1,80 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -@import CocoaLumberjack; - -NS_ASSUME_NONNULL_BEGIN - -static inline BOOL ShouldLogVerbose() -{ - return ddLogLevel >= DDLogLevelVerbose; -} - -static inline BOOL ShouldLogDebug() -{ - return ddLogLevel >= DDLogLevelDebug; -} - -static inline BOOL ShouldLogInfo() -{ - return ddLogLevel >= DDLogLevelInfo; -} - -static inline BOOL ShouldLogWarning() -{ - return ddLogLevel >= DDLogLevelWarning; -} - -static inline BOOL ShouldLogError() -{ - return ddLogLevel >= DDLogLevelError; -} - -/** - * A minimal DDLog wrapper for swift. - */ -@interface OWSLogger : NSObject - -+ (void)verbose:(NSString *)logString; -+ (void)debug:(NSString *)logString; -+ (void)info:(NSString *)logString; -+ (void)warn:(NSString *)logString; -+ (void)error:(NSString *)logString; - -+ (void)flush; - -@end - -#define OWSLogPrefix() \ - ([NSString stringWithFormat:@"[%@:%d %s]: ", \ - [[NSString stringWithUTF8String:__FILE__] lastPathComponent], \ - __LINE__, \ - __PRETTY_FUNCTION__]) - -#define OWSLogVerbose(_messageFormat, ...) \ - do { \ - DDLogVerbose(@"%@%@", OWSLogPrefix(), [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]); \ - } while (0) - -#define OWSLogDebug(_messageFormat, ...) \ - do { \ - DDLogDebug(@"%@%@", OWSLogPrefix(), [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]); \ - } while (0) - -#define OWSLogInfo(_messageFormat, ...) \ - do { \ - DDLogInfo(@"%@%@", OWSLogPrefix(), [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]); \ - } while (0) - -#define OWSLogWarn(_messageFormat, ...) \ - do { \ - DDLogWarn(@"%@%@", OWSLogPrefix(), [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]); \ - } while (0) - -#define OWSLogError(_messageFormat, ...) \ - do { \ - DDLogError(@"%@%@", OWSLogPrefix(), [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]); \ - } while (0) - -NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/OWSLogger.m b/SignalServiceKit/src/Util/OWSLogger.m deleted file mode 100644 index ae1a484cb..000000000 --- a/SignalServiceKit/src/Util/OWSLogger.m +++ /dev/null @@ -1,43 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -#import "OWSLogger.h" - -NS_ASSUME_NONNULL_BEGIN - -@implementation OWSLogger - -+ (void)verbose:(NSString *)logString -{ - DDLogVerbose(@"%@", logString); -} - -+ (void)debug:(NSString *)logString -{ - DDLogDebug(@"%@", logString); -} - -+ (void)info:(NSString *)logString -{ - DDLogInfo(@"%@", logString); -} - -+ (void)warn:(NSString *)logString -{ - DDLogWarn(@"%@", logString); -} - -+ (void)error:(NSString *)logString -{ - DDLogError(@"%@", logString); -} - -+ (void)flush -{ - [DDLog flushLog]; -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/OWSSwiftUtils.swift b/SignalServiceKit/src/Util/OWSSwiftUtils.swift deleted file mode 100644 index bcea05665..000000000 --- a/SignalServiceKit/src/Util/OWSSwiftUtils.swift +++ /dev/null @@ -1,71 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -import Foundation - -/** - * We synchronize access to state in this class using this queue. - */ -public func assertOnQueue(_ queue: DispatchQueue) { - if #available(iOS 10.0, *) { - dispatchPrecondition(condition: .onQueue(queue)) - } else { - // Skipping check on Never { - - owsFailDebug(logMessage, file: file, function: function, line: line) - let formattedMessage = owsFormatLogMessage(logMessage, file: file, function: function, line: line) - fatalError(formattedMessage) -} - -// Once we're on Swift4.2 we can mark this as inlineable -// @inlinable -public func notImplemented(file: String = #file, - function: String = #function, - line: Int = #line) -> Never { - owsFail("Method not implemented.", file: file, function: function, line: line) -} - -@objc public class OWSSwiftUtils: NSObject { - // This method can be invoked from Obj-C to exit the app. - @objc public class func owsFail(_ logMessage: String, - file: String = #file, - function: String = #function, - line: Int = #line) -> Never { - - owsFailDebug(logMessage, file: file, function: function, line: line) - let formattedMessage = owsFormatLogMessage(logMessage, file: file, function: function, line: line) - fatalError(formattedMessage) - } -} diff --git a/SignalServiceKit/src/Util/SSKAsserts.h b/SignalServiceKit/src/Util/SSKAsserts.h new file mode 100755 index 000000000..722962a4c --- /dev/null +++ b/SignalServiceKit/src/Util/SSKAsserts.h @@ -0,0 +1,55 @@ +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// + +#import "AppContext.h" + +//#import +//#import +//#import + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - Singleton Asserts + +// The "singleton asserts" can be used to ensure +// that we only create a singleton once. +// +// The simplest way to use them is the OWSSingletonAssert() macro. +// It is intended to be used inside the singleton's initializer. +// +// If, however, a singleton has multiple possible initializers, +// you need to: +// +// 1. Use OWSSingletonAssertFlag() outside the class definition. +// 2. Use OWSSingletonAssertInit() in each initializer. + +#ifdef DEBUG + +#define ENFORCE_SINGLETONS + +#endif + +#ifdef ENFORCE_SINGLETONS + +#define OWSSingletonAssertFlag() static BOOL _isSingletonCreated = NO; + +#define OWSSingletonAssertInit() \ + @synchronized([self class]) { \ + if (!CurrentAppContext().isRunningTests) { \ + OWSAssertDebug(!_isSingletonCreated); \ + _isSingletonCreated = YES; \ + } \ + } + +#define OWSSingletonAssert() OWSSingletonAssertFlag() OWSSingletonAssertInit() + +#else + +#define OWSSingletonAssertFlag() +#define OWSSingletonAssertInit() +#define OWSSingletonAssert() + +#endif + +NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/Threading.h b/SignalServiceKit/src/Util/Threading.h deleted file mode 100644 index dca1d19a7..000000000 --- a/SignalServiceKit/src/Util/Threading.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -NS_ASSUME_NONNULL_BEGIN - -// The block is executed immediately if called from the -// main thread; otherwise it is dispatched async to the -// main thread. -void DispatchMainThreadSafe(dispatch_block_t block); - -// The block is executed immediately if called from the -// main thread; otherwise it is dispatched sync to the -// main thread. -void DispatchSyncMainThreadSafe(dispatch_block_t block); - -NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/Threading.m b/SignalServiceKit/src/Util/Threading.m deleted file mode 100644 index a2ea94b68..000000000 --- a/SignalServiceKit/src/Util/Threading.m +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -#import "Threading.h" - -NS_ASSUME_NONNULL_BEGIN - -void DispatchMainThreadSafe(dispatch_block_t block) -{ - OWSCAssertDebug(block); - - if ([NSThread isMainThread]) { - block(); - } else { - dispatch_async(dispatch_get_main_queue(), ^{ - block(); - }); - } -} - -void DispatchSyncMainThreadSafe(dispatch_block_t block) -{ - OWSCAssertDebug(block); - - if ([NSThread isMainThread]) { - block(); - } else { - dispatch_sync(dispatch_get_main_queue(), ^{ - block(); - }); - } -} - -NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/iOSVersions.h b/SignalServiceKit/src/Util/iOSVersions.h deleted file mode 100644 index a056aae26..000000000 --- a/SignalServiceKit/src/Util/iOSVersions.h +++ /dev/null @@ -1,8 +0,0 @@ -// -// Copyright (c) 2017 Open Whisper Systems. All rights reserved. -// - -#include - -#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(major, minor) \ - ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){.majorVersion = major, .minorVersion = minor, .patchVersion = 0}]) diff --git a/SignalServiceKit/tests/Messages/Interactions/TSMessageTest.m b/SignalServiceKit/tests/Messages/Interactions/TSMessageTest.m index 403fe930d..35ee47ca8 100644 --- a/SignalServiceKit/tests/Messages/Interactions/TSMessageTest.m +++ b/SignalServiceKit/tests/Messages/Interactions/TSMessageTest.m @@ -2,11 +2,11 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -#import "TSMessage.h" -#import "NSDate+OWS.h" #import "SSKBaseTest.h" #import "TSAttachmentStream.h" #import "TSContactThread.h" +#import "TSMessage.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/tests/Messages/OWSDisappearingMessageFinderTest.m b/SignalServiceKit/tests/Messages/OWSDisappearingMessageFinderTest.m index 15ccce312..fea3e31f7 100644 --- a/SignalServiceKit/tests/Messages/OWSDisappearingMessageFinderTest.m +++ b/SignalServiceKit/tests/Messages/OWSDisappearingMessageFinderTest.m @@ -3,13 +3,13 @@ // #import "MockSSKEnvironment.h" -#import "NSDate+OWS.h" #import "OWSDisappearingMessagesFinder.h" #import "OWSPrimaryStorage.h" #import "SSKBaseTest.h" #import "TSContactThread.h" #import "TSMessage.h" #import "TestAppContext.h" +#import #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/tests/Messages/OWSDisappearingMessagesJobTest.m b/SignalServiceKit/tests/Messages/OWSDisappearingMessagesJobTest.m index 8c81b4cd0..53900aa8a 100644 --- a/SignalServiceKit/tests/Messages/OWSDisappearingMessagesJobTest.m +++ b/SignalServiceKit/tests/Messages/OWSDisappearingMessagesJobTest.m @@ -2,15 +2,15 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -#import "OWSDisappearingMessagesJob.h" -#import "NSDate+OWS.h" #import "OWSDisappearingMessagesConfiguration.h" #import "OWSDisappearingMessagesFinder.h" +#import "OWSDisappearingMessagesJob.h" #import "OWSFakeContactsManager.h" #import "OWSPrimaryStorage.h" #import "SSKBaseTest.h" #import "TSContactThread.h" #import "TSMessage.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/tests/SSKBaseTest.h b/SignalServiceKit/tests/SSKBaseTest.h index c2e2d639d..2e7f87ba1 100644 --- a/SignalServiceKit/tests/SSKBaseTest.h +++ b/SignalServiceKit/tests/SSKBaseTest.h @@ -2,7 +2,7 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -#import "MockSSKEnvironment.h" +#import #import #import diff --git a/SignalServiceKit/tests/Util/CryptographyTests.m b/SignalServiceKit/tests/Util/CryptographyTests.m index dc04d6160..0ace7ce4b 100644 --- a/SignalServiceKit/tests/Util/CryptographyTests.m +++ b/SignalServiceKit/tests/Util/CryptographyTests.m @@ -3,8 +3,8 @@ // #import "Cryptography.h" -#import "NSData+OWS.h" #import "SSKBaseTest.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalServiceKit/tests/Util/OWSAnalyticsTests.m b/SignalServiceKit/tests/Util/OWSAnalyticsTests.m index 3e0f3e7b1..bff4feca5 100644 --- a/SignalServiceKit/tests/Util/OWSAnalyticsTests.m +++ b/SignalServiceKit/tests/Util/OWSAnalyticsTests.m @@ -2,9 +2,9 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -#import "NSData+OWS.h" #import "OWSAnalytics.h" #import "SSKBaseTest.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalShareExtension/SignalShareExtension-Bridging-Header.h b/SignalShareExtension/SignalShareExtension-Bridging-Header.h index 4afe7d72b..83c92c2df 100644 --- a/SignalShareExtension/SignalShareExtension-Bridging-Header.h +++ b/SignalShareExtension/SignalShareExtension-Bridging-Header.h @@ -8,6 +8,9 @@ // Separate iOS Frameworks from other imports. #import "SAEScreenLockViewController.h" #import "ShareAppExtensionContext.h" +#import +#import +#import #import #import #import @@ -21,8 +24,5 @@ #import #import #import -#import -#import -#import #import #import diff --git a/SignalShareExtension/SignalShareExtension-Prefix.pch b/SignalShareExtension/SignalShareExtension-Prefix.pch index c52f07265..881d5e4c7 100644 --- a/SignalShareExtension/SignalShareExtension-Prefix.pch +++ b/SignalShareExtension/SignalShareExtension-Prefix.pch @@ -15,7 +15,7 @@ static const NSUInteger ddLogLevel = DDLogLevelInfo; #endif - #import + #import #import - #import + #import #endif