Clean up ahead of PR.

pull/1/head
Matthew Chen 7 years ago
parent 2375cc2f76
commit 0cc7f3e00e

@ -104,8 +104,6 @@
34612A071FD7238600532771 /* OWSContactsSyncing.m in Sources */ = {isa = PBXBuildFile; fileRef = 34612A051FD7238500532771 /* OWSContactsSyncing.m */; };
346B66311F4E29B200E5122F /* CropScaleImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346B66301F4E29B200E5122F /* CropScaleImageViewController.swift */; };
3472229F1EB22FFE00E53955 /* AddToGroupViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3472229E1EB22FFE00E53955 /* AddToGroupViewController.m */; };
34782E452011428D00A6F16B /* OWSDatabaseConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = 34782E432011428D00A6F16B /* OWSDatabaseConverter.h */; settings = {ATTRIBUTES = (Public, ); }; };
34782E462011428D00A6F16B /* OWSDatabaseConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 34782E442011428D00A6F16B /* OWSDatabaseConverter.m */; };
347850311FD7494A007B8332 /* dripicons-v2.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 34330A5B1E787A9800DF2FB9 /* dripicons-v2.ttf */; };
347850321FD7494A007B8332 /* ElegantIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 34330A5D1E787BD800DF2FB9 /* ElegantIcons.ttf */; };
347850331FD7494A007B8332 /* fontawesome-webfont.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 34330A591E7875FB00DF2FB9 /* fontawesome-webfont.ttf */; };
@ -594,8 +592,6 @@
346B66301F4E29B200E5122F /* CropScaleImageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CropScaleImageViewController.swift; sourceTree = "<group>"; };
3472229D1EB22FFE00E53955 /* AddToGroupViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddToGroupViewController.h; sourceTree = "<group>"; };
3472229E1EB22FFE00E53955 /* AddToGroupViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddToGroupViewController.m; sourceTree = "<group>"; };
34782E432011428D00A6F16B /* OWSDatabaseConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSDatabaseConverter.h; sourceTree = "<group>"; };
34782E442011428D00A6F16B /* OWSDatabaseConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSDatabaseConverter.m; sourceTree = "<group>"; };
347850561FD86544007B8332 /* SAEFailedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SAEFailedViewController.swift; sourceTree = "<group>"; };
347850581FD9972E007B8332 /* SwiftSingletons.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftSingletons.swift; sourceTree = "<group>"; };
3478505A1FD999D5007B8332 /* et */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = et; path = translations/et.lproj/Localizable.strings; sourceTree = "<group>"; };
@ -1115,8 +1111,6 @@
45666EC51D99483D008FE134 /* OWSAvatarBuilder.m */,
45855F351D9498A40084F340 /* OWSContactAvatarBuilder.h */,
45855F361D9498A40084F340 /* OWSContactAvatarBuilder.m */,
34782E432011428D00A6F16B /* OWSDatabaseConverter.h */,
34782E442011428D00A6F16B /* OWSDatabaseConverter.m */,
346129A81FD1F0DF00532771 /* OWSFormat.h */,
346129AA1FD1F0EE00532771 /* OWSFormat.m */,
45666EC71D994C0D008FE134 /* OWSGroupAvatarBuilder.h */,
@ -2045,7 +2039,6 @@
buildActionMask = 2147483647;
files = (
451F8A3A1FD711D9005CB9DA /* ContactsViewHelper.h in Headers */,
34782E452011428D00A6F16B /* OWSDatabaseConverter.h in Headers */,
34480B491FD0A60200BC14EF /* OWSMath.h in Headers */,
346129E71FD5C0C600532771 /* OWSDatabaseMigrationRunner.h in Headers */,
344D6CEA20069E070042AF96 /* SelectRecipientViewController.h in Headers */,
@ -2804,7 +2797,6 @@
346129D01FD207F300532771 /* OWSAlerts.swift in Sources */,
454A965F1FD60EA3008D2A0E /* OWSFlatButton.swift in Sources */,
346129B61FD1F7E800532771 /* ProfileFetcherJob.swift in Sources */,
34782E462011428D00A6F16B /* OWSDatabaseConverter.m in Sources */,
346129F51FD5F31400532771 /* OWS102MoveLoggingPreferenceToUserDefaults.m in Sources */,
45194F8F1FD71FF500333B2C /* ThreadUtil.m in Sources */,
451F8A3B1FD71297005CB9DA /* UIUtil.m in Sources */,
@ -3146,7 +3138,11 @@
"DEBUG=1",
"$(inherited)",
);
"GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = "DEBUG=1 $(inherited) SSK_BUILDING_FOR_TESTS=1";
"GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = (
"DEBUG=1",
"$(inherited)",
"SSK_BUILDING_FOR_TESTS=1",
);
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;

@ -193,7 +193,7 @@ NS_ASSUME_NONNULL_BEGIN
{
DDLogInfo(@"%@ %s.", self.logTag, __PRETTY_FUNCTION__);
[NSException raise:@"OWSBackup_RestartAppToCompleteBackupRestore" format:@"Killing app to complete backup restore"];
OWSRaiseException(@"OWSBackup_RestartAppToCompleteBackupRestore", @"Killing app to complete backup restore");
}
#pragma mark - OWSBackupDelegate

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "UIImage+OWS.h"
@ -98,7 +98,7 @@
break;
default:
[NSException raise:NSInternalInconsistencyException format:@"Invalid image orientation"];
OWSRaiseException(NSInternalInconsistencyException, @"Invalid image orientation");
}
/////////////////////////////////////////////////////////////////////////////

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSDatabaseMigration.h"
@ -32,10 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSString *)migrationId
{
@throw [NSException
exceptionWithName:NSInternalInconsistencyException
reason:[NSString stringWithFormat:@"Must override %@ in subclass", NSStringFromSelector(_cmd)]
userInfo:nil];
OWSRaiseException(NSInternalInconsistencyException, @"Must override %@ in subclass", NSStringFromSelector(_cmd));
}
+ (NSString *)collection
@ -46,10 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)runUpWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
{
@throw [NSException
exceptionWithName:NSInternalInconsistencyException
reason:[NSString stringWithFormat:@"Must override %@ in subclass", NSStringFromSelector(_cmd)]
userInfo:nil];
OWSRaiseException(NSInternalInconsistencyException, @"Must override %@ in subclass", NSStringFromSelector(_cmd));
}
- (void)runUp

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSAvatarBuilder.h"
@ -8,6 +8,7 @@
#import "TSContactThread.h"
#import "TSGroupThread.h"
#import "UIColor+OWS.h"
// SHARINGEXTENSION FIXME
// intern or reimplement this so that SignalMessaging doesn't depend on JSQ
#import <JSQMessagesViewController/JSQMessagesAvatarImageFactory.h>
@ -85,18 +86,14 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable UIImage *)buildSavedImage
{
@throw [NSException
exceptionWithName:NSInternalInconsistencyException
reason:[NSString stringWithFormat:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)]
userInfo:nil];
OWSRaiseException(
NSInternalInconsistencyException, @"You must override %@ in a subclass", NSStringFromSelector(_cmd));
}
- (UIImage *)buildDefaultImage
{
@throw [NSException
exceptionWithName:NSInternalInconsistencyException
reason:[NSString stringWithFormat:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)]
userInfo:nil];
OWSRaiseException(
NSInternalInconsistencyException, @"You must override %@ in a subclass", NSStringFromSelector(_cmd));
}
@end

@ -122,7 +122,7 @@ NSString *const TSAccountManager_ServerSignalingKey = @"TSStorageServerSignaling
NSString *phoneNumber = self.phoneNumberAwaitingVerification;
if (!phoneNumber) {
@throw [NSException exceptionWithName:@"RegistrationFail" reason:@"Internal Corrupted State" userInfo:nil];
OWSRaiseException(@"RegistrationFail", @"Internal Corrupted State");
}
[self storeLocalNumber:phoneNumber];

@ -1262,9 +1262,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
if (messageDict) {
[messagesArray addObject:messageDict];
} else {
@throw [NSException exceptionWithName:InvalidMessageException
reason:@"Failed to encrypt message"
userInfo:nil];
OWSRaiseException(InvalidMessageException, @"Failed to encrypt message");
}
} @catch (NSException *exception) {
if ([exception.name isEqualToString:OWSMessageSenderInvalidDeviceException]) {
@ -1324,9 +1322,8 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
}
if (!bundle) {
@throw [NSException exceptionWithName:InvalidVersionException
reason:@"Can't get a prekey bundle from the server with required information"
userInfo:nil];
OWSRaiseException(
InvalidVersionException, @"Can't get a prekey bundle from the server with required information");
} else {
SessionBuilder *builder = [[SessionBuilder alloc] initWithSessionStore:storage
preKeyStore:storage
@ -1341,10 +1338,9 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
}
} @catch (NSException *exception) {
if ([exception.name isEqualToString:UntrustedIdentityKeyException]) {
@throw [NSException
exceptionWithName:UntrustedIdentityKeyException
reason:nil
userInfo:@{ TSInvalidPreKeyBundleKey : bundle, TSInvalidRecipientKey : identifier }];
OWSRaiseExceptionWithUserInfo(UntrustedIdentityKeyException,
(@{ TSInvalidPreKeyBundleKey : bundle, TSInvalidRecipientKey : identifier }),
@"");
}
@throw exception;
}

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "TSRequest.h"
@ -19,7 +19,7 @@
}
- (id)init {
[NSException raise:NSInternalInconsistencyException format:@"You must use the initWithURL: method"];
OWSRaiseException(NSInternalInconsistencyException, @"You must use the initWithURL: method");
return nil;
}
@ -29,7 +29,7 @@
- (id)initWithURL:(NSURL *)URL
cachePolicy:(NSURLRequestCachePolicy)cachePolicy
timeoutInterval:(NSTimeInterval)timeoutInterval {
[NSException raise:NSInternalInconsistencyException format:@"You must use the initWithURL method"];
OWSRaiseException(NSInternalInconsistencyException, @"You must use the initWithURL method");
return nil;
}

@ -1,13 +1,9 @@
//
// TSRequestVerificationCodeRequest.m
// Signal
//
// Created by Frederic Jacobs on 02/12/15.
// Copyright © 2015 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "TSConstants.h"
#import "TSRequestVerificationCodeRequest.h"
#import "TSConstants.h"
@implementation TSRequestVerificationCodeRequest
@ -30,10 +26,7 @@
case TSVerificationTransportVoice:
return @"voice";
default:
@throw [NSException
exceptionWithName:@"Unsupported transport exception"
reason:[NSString stringWithFormat:@"Transport %u in enum is not supported.", transport]
userInfo:nil];
OWSRaiseException(@"Unsupported transport exception", @"Transport %u in enum is not supported.", transport);
}
}

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSSignalService.h"
@ -310,16 +310,12 @@ NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidChange =
NSData *certData = [self certificateDataWithName:certName error:&error];
if (error) {
DDLogError(@"%@ Failed to get %@ certificate data with error: %@", self.logTag, certName, error);
@throw [NSException exceptionWithName:@"OWSSignalService_UnableToReadCertificate"
reason:error.description
userInfo:nil];
OWSRaiseException(@"OWSSignalService_UnableToReadCertificate", error.description);
}
if (!certData) {
DDLogError(@"%@ No data for certificate: %@", self.logTag, certName);
@throw [NSException exceptionWithName:@"OWSSignalService_UnableToReadCertificate"
reason:error.description
userInfo:nil];
OWSRaiseException(@"OWSSignalService_UnableToReadCertificate", error.description);
}
[certificates addObject:certData];
}

@ -1,9 +1,8 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSHTTPSecurityPolicy.h"
#import <AssertMacros.h>
@implementation OWSHTTPSecurityPolicy
@ -44,10 +43,7 @@
NSString *path = [bundle pathForResource:service ofType:@"cer"];
if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
@throw [NSException
exceptionWithName:@"Missing server certificate"
reason:[NSString stringWithFormat:@"Missing signing certificate for service %@", service]
userInfo:nil];
OWSRaiseException(@"Missing server certificate", @"Missing signing certificate for service %@", service);
}
NSData *certificateData = [NSData dataWithContentsOfFile:path];

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "TSStorageKeys.h"
@ -61,9 +61,7 @@
inCollection:TSStorageManagerPreKeyStoreCollection];
if (!preKeyRecord) {
@throw [NSException exceptionWithName:InvalidKeyIdException
reason:@"No pre key found matching key id"
userInfo:@{}];
OWSRaiseException(InvalidKeyIdException, @"No pre key found matching key id");
} else {
return preKeyRecord;
}

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSIdentityManager.h"
@ -41,9 +41,7 @@ NSString *const TSStorageManagerKeyPrekeyCurrentSignedPrekeyId = @"currentSigned
inCollection:TSStorageManagerSignedPreKeyStoreCollection];
if (!preKeyRecord) {
@throw [NSException exceptionWithName:InvalidKeyIdException
reason:@"No signed pre key found matching key id"
userInfo:@{}];
OWSRaiseException(InvalidKeyIdException, @"No signed pre key found matching key id");
} else {
return preKeyRecord;
}

@ -276,7 +276,7 @@ typedef NSData *_Nullable (^CreateDatabaseMetadataBlock)(void);
// Sleep to give analytics events time to be delivered.
[NSThread sleepForTimeInterval:15.0f];
[NSException raise:OWSStorageExceptionName_NoDatabase format:@"Failed to initialize database."];
OWSRaiseException(OWSStorageExceptionName_NoDatabase, @"Failed to initialize database.");
}
}
@ -384,6 +384,10 @@ typedef NSData *_Nullable (^CreateDatabaseMetadataBlock)(void);
// We determine the database password, salt and key spec first, since a side effect of
// this can be deleting any existing database file (if we're recovering
// from a corrupt keychain).
//
// Although we don't use databasePassword or databaseSalt in this method,
// we use their accessors to ensure that all three exist in the keychain
// and can be loaded or that we reset the database & keychain.
NSData *databasePassword = [self databasePassword];
OWSAssert(databasePassword.length > 0);
NSData *databaseSalt = [self databaseSalt];
@ -555,32 +559,6 @@ typedef NSData *_Nullable (^CreateDatabaseMetadataBlock)(void);
+ (nullable NSData *)tryToLoadDatabaseKeySpec:(NSError **)errorHandle
{
return [self tryToLoadKeyChainValue:keychainDBKeySpec errorHandle:errorHandle];
// NSData *_Nullable keySpecData = [self tryToLoadKeyChainValue:keychainDBKeySpec errorHandle:errorHandle];
//
// if (!keySpecData) {
// DDLogInfo(@"%@ Trying to derive database key spec.", self.logTag);
// NSData *_Nullable passwordData = [self tryToLoadDatabasePassword:errorHandle];
// if (passwordData && !*errorHandle) {
// NSData *_Nullable saltData = [self tryToLoadDatabaseSalt:errorHandle];
// if (saltData && !*errorHandle) {
// OWSAssert(passwordData.length > 0);
// OWSAssert(saltData.length == kSQLCipherSaltLength);
//
// keySpecData = [YapDatabaseCryptoUtils databaseKeySpecForPassword:passwordData saltData:saltData];
// OWSAssert(keySpecData.length == kSQLCipherKeySpecLength);
//
// if (keySpecData) {
// DDLogInfo(@"%@ database key spec derived.", self.logTag);
// [self storeDatabaseKeySpec:keySpecData];
// }
// }
// }
// }
//
// OWSAssert(keySpecData);
//
// return keySpecData;
}
- (NSData *)databasePassword
@ -743,8 +721,7 @@ typedef NSData *_Nullable (^CreateDatabaseMetadataBlock)(void);
// Presumably this happened in response to a push notification. It's possible that the keychain is corrupted
// but it could also just be that the user hasn't yet unlocked their device since our password is
// kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
[NSException raise:OWSStorageExceptionName_DatabasePasswordInaccessibleWhileBackgrounded
format:@"%@", errorDescription];
OWSRaiseException(OWSStorageExceptionName_DatabasePasswordInaccessibleWhileBackgrounded, @"%@", errorDescription);
}
+ (void)deletePasswordFromKeychain
@ -784,8 +761,8 @@ typedef NSData *_Nullable (^CreateDatabaseMetadataBlock)(void);
// Sleep to give analytics events time to be delivered.
[NSThread sleepForTimeInterval:15.0f];
[NSException raise:OWSStorageExceptionName_DatabasePasswordUnwritable
format:@"Setting keychain value failed with error: %@", error];
OWSRaiseException(
OWSStorageExceptionName_DatabasePasswordUnwritable, @"Setting keychain value failed with error: %@", error);
} else {
DDLogWarn(@"Succesfully set new keychain value.");
}

@ -161,8 +161,8 @@ void runAsyncRegistrationsForStorage(OWSStorage *storage)
NSString *databaseDirPath = [[OWSFileSystem appSharedDataDirectoryPath] stringByAppendingPathComponent:@"database"];
if (![OWSFileSystem ensureDirectoryExists:databaseDirPath]) {
[NSException raise:TSStorageManagerExceptionName_CouldNotCreateDatabaseDirectory
format:@"Could not create new database directory"];
OWSRaiseException(
TSStorageManagerExceptionName_CouldNotCreateDatabaseDirectory, @"Could not create new database directory");
}
return databaseDirPath;
}

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@ -124,4 +124,20 @@ NS_ASSUME_NONNULL_BEGIN
// This function is intended for use in Swift.
void AssertIsOnMainThread(void);
#define OWSRaiseException(name, formatParam, ...) \
{ \
[DDLog flushLog]; \
@throw [NSException exceptionWithName:name \
reason:[NSString stringWithFormat:formatParam, ##__VA_ARGS__] \
userInfo:nil]; \
}
#define OWSRaiseExceptionWithUserInfo(name, userInfoParam, formatParam, ...) \
{ \
[DDLog flushLog]; \
@throw [NSException exceptionWithName:name \
reason:[NSString stringWithFormat:formatParam, ##__VA_ARGS__] \
userInfo:userInfoParam]; \
}
NS_ASSUME_NONNULL_END

@ -83,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN
newFilePath,
error];
OWSFail(@"%@", errorDescription);
[NSException raise:exceptionName format:@"%@", errorDescription];
OWSRaiseException(exceptionName, @"%@", errorDescription);
}
DDLogInfo(@"%@ Moved file or directory from: %@ to: %@ in: %f",

Loading…
Cancel
Save