style changes // fix compiler warnings

- log errors
- forward declare where possible
- clang-format
- remove inaccurate file headers
- include Pods in Example app build target to get SignalServiceKit warnings
- Fix those warnings!

// FREEBIE
This commit is contained in:
Michael Kirk 2016-07-27 16:58:49 -07:00
parent 5458a73cee
commit 2858694ee0
32 changed files with 106 additions and 181 deletions

View File

@ -34,7 +34,7 @@ PODS:
- Mantle/extobjc (2.0.7)
- ProtocolBuffers (1.9.10)
- Reachability (3.2)
- SignalServiceKit (0.0.6):
- SignalServiceKit (0.0.7):
- '25519'
- AFNetworking
- AxolotlKit
@ -129,7 +129,7 @@ SPEC CHECKSUMS:
Mantle: bc40bb061d8c2c6fb48d5083e04d928c3b7f73d9
ProtocolBuffers: d088180c10072b3d24a9939a6314b7b9bcc2340b
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
SignalServiceKit: 850620cd1535f8628474121e7ea142ff1fe236a6
SignalServiceKit: e0bc81d12cef07b621403ff49e1c9c6f64d96109
SocketRocket: 3f77ec2104cc113add553f817ad90a77114f5d43
SQLCipher: 4c768761421736a247ed6cf412d9045615d53dff
SSKeychain: c71293fa57216a40ab06c23f4085387583293de4

View File

@ -20,6 +20,20 @@
ReferencedContainer = "container:TSKitiOSTestApp.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D0826C97B09E58C83B3C228FBC535FA"
BuildableName = "libSignalServiceKit.a"
BlueprintName = "SignalServiceKit"
ReferencedContainer = "container:Pods/Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction

View File

@ -6,13 +6,12 @@
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "TSDatabaseView.h"
#import "TSInteraction.h"
#import "TSStorageManager.h"
#import "TSThread.h"
#import "TSDatabaseView.h"
#import "TSIncomingMessage.h"
#import "TSInteraction.h"
#import "TSOutgoingMessage.h"
#import "TSStorageManager.h"
@interface TSThread ()

View File

@ -1,15 +1,11 @@
//
// TSContactThread.m
// TextSecureKit
//
// Created by Frederic Jacobs on 16/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "TSContactThread.h"
#import "ContactsUpdater.h"
#import "IncomingPushMessageSignal.pb.h"
#import "TSContactThread.h"
#import "TextSecureKitEnv.h"
#import <YapDatabase/YapDatabaseTransaction.h>
#define TSContactThreadPrefix @"c"

View File

@ -1,14 +1,10 @@
//
// TSGroupThread.m
// TextSecureKit
//
// Created by Frederic Jacobs on 16/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "TSGroupThread.h"
#import "NSData+Base64.h"
#import "SignalRecipient.h"
#import "TSGroupThread.h"
#import <YapDatabase/YapDatabaseTransaction.h>
@implementation TSGroupThread

View File

@ -1,14 +1,8 @@
//
// TSAttachement.m
// TextSecureKit
//
// Created by Frederic Jacobs on 12/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "MIMETypeUtil.h"
#import "TSAttachment.h"
#import "MIMETypeUtil.h"
@implementation TSAttachment

View File

@ -1,15 +1,11 @@
//
// TSAttachementPointer.h
// Signal
//
// Created by Frederic Jacobs on 17/12/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "TSAttachment.h"
/**
* A TSAttachmentPointer is a yet-to-be-downloaded attachment.
*/
@interface TSAttachmentPointer : TSAttachment
- (instancetype)initWithIdentifier:(uint64_t)identifier

View File

@ -1,10 +1,5 @@
//
// TSAttachementPointer.m
// Signal
//
// Created by Frederic Jacobs on 17/12/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "TSAttachmentPointer.h"

View File

@ -1,10 +1,5 @@
//
// TSAttachementStream.h
// Signal
//
// Created by Frederic Jacobs on 17/12/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "TSAttachment.h"
#if TARGET_OS_IPHONE
@ -19,7 +14,6 @@
data:(NSData *)data
key:(NSData *)key
contentType:(NSString *)contentType NS_DESIGNATED_INITIALIZER;
;
#if TARGET_OS_IPHONE
- (UIImage *)image;

View File

@ -1,14 +1,10 @@
//
// TSattachmentStream.m
// Signal
//
// Created by Frederic Jacobs on 17/12/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import <AVFoundation/AVFoundation.h>
#import "MIMETypeUtil.h"
#import "TSAttachmentStream.h"
#import "MIMETypeUtil.h"
#import <AVFoundation/AVFoundation.h>
#import <YapDatabase/YapDatabaseTransaction.h>
NSString *const TSAttachementFileRelationshipEdge = @"TSAttachementFileEdge";
@ -17,12 +13,17 @@ NSString *const TSAttachementFileRelationshipEdge = @"TSAttachementFileEdge";
- (instancetype)initWithIdentifier:(NSString *)identifier
data:(NSData *)data
key:(NSData *)key
contentType:(NSString *)contentType {
contentType:(NSString *)contentType
{
self = [super initWithIdentifier:identifier encryptionKey:key contentType:contentType];
if (!self) {
return self;
}
[[NSFileManager defaultManager] createFileAtPath:self.filePath contents:data attributes:nil];
[[NSFileManager defaultManager] createFileAtPath:[self filePath] contents:data attributes:nil];
DDLogInfo(@"Created file at %@", [self filePath]);
_isDownloaded = YES;
return self;
}
@ -35,19 +36,19 @@ NSString *const TSAttachementFileRelationshipEdge = @"TSAttachementFileEdge";
return @[ attachmentFileEdge ];
}
+ (NSString *)attachmentsFolder {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *fileURL = [[fileManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
NSString *path = [fileURL path];
NSString *attachmentFolder = [path stringByAppendingFormat:@"/Attachments"];
+ (NSString *)attachmentsFolder
{
NSString *documentsPath =
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
NSString *attachmentFolder = [documentsPath stringByAppendingFormat:@"/Attachments"];
NSError *error = nil;
[[NSFileManager defaultManager] createDirectoryAtPath:attachmentFolder
withIntermediateDirectories:YES
attributes:nil
error:&error];
if (error != nil) {
DDLogError(@"Failed to create attachments directory: %@", error.description);
if (error) {
DDLogError(@"Failed to create attachments directory: %@", error);
}
return attachmentFolder;
@ -88,7 +89,6 @@ NSString *const TSAttachementFileRelationshipEdge = @"TSAttachementFileEdge";
}
}
- (UIImage *)videoThumbnail {
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:self.filePath] options:nil];
AVAssetImageGenerator *generate = [[AVAssetImageGenerator alloc] initWithAsset:asset];
@ -99,10 +99,10 @@ NSString *const TSAttachementFileRelationshipEdge = @"TSAttachementFileEdge";
return [[UIImage alloc] initWithCGImage:imgRef];
}
+ (void)deleteAttachments {
NSFileManager *fm = [NSFileManager defaultManager];
+ (void)deleteAttachments
{
NSError *error;
[fm removeItemAtPath:[self attachmentsFolder] error:&error];
[[NSFileManager defaultManager] removeItemAtPath:[self attachmentsFolder] error:&error];
if (error) {
DDLogError(@"Failed to delete attachment folder with error: %@", error.debugDescription);
}

View File

@ -7,6 +7,7 @@
//
#import "TSErrorMessage.h"
#import "TSContactThread.h"
#import "TSErrorMessage_privateConstructor.h"
#import "TSMessagesManager.h"
#import "TextSecureKitEnv.h"

View File

@ -8,6 +8,9 @@
#import "TSMessage.h"
@class TSContactThread;
@class TSGroupThread;
@interface TSIncomingMessage : TSMessage
/**

View File

@ -7,6 +7,8 @@
//
#import "TSIncomingMessage.h"
#import "TSContactThread.h"
#import "TSGroupThread.h"
@implementation TSIncomingMessage

View File

@ -1,18 +1,9 @@
//
// TSInteraction.h
// TextSecureKit
//
// Created by Frederic Jacobs on 12/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <YapDatabase/YapDatabaseRelationshipNode.h>
#import "TSYapDatabaseObject.h"
#import "TSContactThread.h"
#import "TSGroupThread.h"
@class TSThread;
extern const struct TSMessageRelationships { __unsafe_unretained NSString *threadUniqueId; } TSMessageRelationships;

View File

@ -7,9 +7,9 @@
//
#import "TSInteraction.h"
#import "TSDatabaseSecondaryIndexes.h"
#import "TSStorageManager+messageIDs.h"
#import "TSThread.h"
const struct TSMessageRelationships TSMessageRelationships = {

View File

@ -1,17 +1,10 @@
//
// TSMessage.h
// TextSecureKit
//
// Created by Frederic Jacobs on 12/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "TSAttachment.h"
#import "TSInteraction.h"
/**
* Abstract message class. Is instantiated by either
* Abstract message class.
*/
typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {

View File

@ -1,12 +1,9 @@
//
// TSMessage.m
// TextSecureKit
//
// Created by Frederic Jacobs on 12/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "TSMessage.h"
#import "TSAttachment.h"
#import <YapDatabase/YapDatabaseTransaction.h>
NSString *const TSAttachementsRelationshipEdgeName = @"TSAttachmentEdge";

View File

@ -1,12 +1,8 @@
//
// TSOutgoingMessage.m
// TextSecureKit
//
// Created by Frederic Jacobs on 15/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "TSOutgoingMessage.h"
#import "TSGroupThread.h"
@implementation TSOutgoingMessage

View File

@ -1,23 +1,18 @@
//
// TSInvalidIdentityKeyErrorMessage.m
// Signal
//
// Created by Frederic Jacobs on 31/12/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import <YapDatabase/YapDatabaseTransaction.h>
#import <YapDatabase/YapDatabaseView.h>
#import <AxolotlKit/NSData+keyVersionByte.h>
#import <AxolotlKit/PreKeyWhisperMessage.h>
#import "TSInvalidIdentityKeyReceivingErrorMessage.h"
#import "TSContactThread.h"
#import "TSDatabaseView.h"
#import "TSErrorMessage_privateConstructor.h"
#import "TSFingerprintGenerator.h"
#import "TSInvalidIdentityKeyReceivingErrorMessage.h"
#import "TSMessagesManager.h"
#import "TSStorageManager+IdentityKeyStore.h"
#import "TSStorageManager.h"
#import <AxolotlKit/NSData+keyVersionByte.h>
#import <AxolotlKit/PreKeyWhisperMessage.h>
#import <YapDatabase/YapDatabaseTransaction.h>
#import <YapDatabase/YapDatabaseView.h>
@implementation TSInvalidIdentityKeyReceivingErrorMessage

View File

@ -11,6 +11,7 @@
#import <AxolotlKit/NSData+keyVersionByte.h>
#import "PreKeyBundle+jsonDict.h"
#import "TSContactThread.h"
#import "TSErrorMessage_privateConstructor.h"
#import "TSFingerprintGenerator.h"
#import "TSInvalidIdentityKeySendingErrorMessage.h"

View File

@ -1,14 +1,10 @@
//
// TSCall.h
// TextSecureKit
//
// Created by Frederic Jacobs on 12/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "TSInteraction.h"
@class TSContactThread;
typedef enum {
RPRecentCallTypeIncoming = 1,
RPRecentCallTypeOutgoing,

View File

@ -1,12 +1,8 @@
//
// TSCall.m
// TextSecureKit
//
// Created by Frederic Jacobs on 12/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "TSCall.h"
#import "TSContactThread.h"
@implementation TSCall

View File

@ -1,19 +1,18 @@
//
// TSMessagesManager+attachments.m
// Signal
//
// Created by Frederic Jacobs on 17/12/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import <YapDatabase/YapDatabaseConnection.h>
#import "Cryptography.h"
#import "MIMETypeUtil.h"
#import "NSDate+millisecondTimeStamp.h"
#import "TSAttachmentPointer.h"
#import "TSContactThread.h"
#import "TSGroupModel.h"
#import "TSGroupThread.h"
#import "TSInfoMessage.h"
#import "TSMessagesManager+attachments.h"
#import "TSNetworkManager.h"
#import <YapDatabase/YapDatabaseConnection.h>
#import <YapDatabase/YapDatabaseTransaction.h>
@interface TSMessagesManager ()
@ -195,6 +194,9 @@ dispatch_queue_t attachmentsQueue() {
[self decryptedAndSaveAttachment:attachment data:data messageId:messageId];
}
});
} else {
DDLogError(@"Failed retrieval of attachment. Response had unexpected format.");
[self setFailedAttachment:attachment inMessage:messageId];
}
}
failure:^(NSURLSessionDataTask *task, NSError *error) {

View File

@ -8,6 +8,8 @@
#import "TSMessagesManager.h"
@class SignalRecipient;
@interface TSMessagesManager (sendMessages)
typedef void (^successSendingCompletionBlock)();

View File

@ -1,27 +1,23 @@
//
// TSMessagesManager+sendMessages.m
// TextSecureKit
//
// Created by Frederic Jacobs on 17/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "TSMessagesManager+sendMessages.h"
#import <AxolotlKit/AxolotlExceptions.h>
#import <AxolotlKit/SessionBuilder.h>
#import <AxolotlKit/SessionCipher.h>
#import <Mantle/Mantle.h>
#import <TwistedOakCollapsingFutures/CollapsingFutures.h>
#import "ContactsUpdater.h"
#import "NSData+messagePadding.h"
#import "PreKeyBundle+jsonDict.h"
#import "TSAccountManager.h"
#import "TSAttachmentStream.h"
#import "TSContactThread.h"
#import "TSGroupThread.h"
#import "TSInfoMessage.h"
#import "TSNetworkManager.h"
#import "TSServerMessage.h"
#import "TSStorageHeaders.h"
#import <AxolotlKit/AxolotlExceptions.h>
#import <AxolotlKit/SessionBuilder.h>
#import <AxolotlKit/SessionCipher.h>
#import <Mantle/Mantle.h>
#import <TwistedOakCollapsingFutures/CollapsingFutures.h>
#define RETRY_ATTEMPTS 3
@ -92,7 +88,6 @@ dispatch_queue_t sendingQueue() {
{
if ([thread isKindOfClass:[TSGroupThread class]]) {
dispatch_async(sendingQueue(), ^{
TSGroupThread *groupThread = (TSGroupThread *)thread;
[self groupSend:@[ recipient ] // Avoid spamming entire group when resending failed message.
Message:message
inThread:thread

View File

@ -1,17 +1,13 @@
//
// TSMessagesHandler.h
// TextSecureKit
//
// Created by Frederic Jacobs on 11/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "IncomingPushMessageSignal.pb.h"
#import "TSIncomingMessage.h"
#import "TSInvalidIdentityKeySendingErrorMessage.h"
#import "TSOutgoingMessage.h"
@class TSCall;
@class YapDatabaseConnection;
@interface TSMessagesManager : NSObject

View File

@ -1,28 +1,23 @@
//
// TSMessagesHandler.m
// TextSecureKit
//
// Created by Frederic Jacobs on 11/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "TSMessagesManager.h"
#import <AxolotlKit/AxolotlExceptions.h>
#import <AxolotlKit/SessionCipher.h>
#import "NSData+messagePadding.h"
#import "TSAccountManager.h"
#import "TSAttachmentStream.h"
#import "TSCall.h"
#import "TSContactThread.h"
#import "TSDatabaseView.h"
#import "TSGroupModel.h"
#import "TSGroupThread.h"
#import "TSInfoMessage.h"
#import "TSInvalidIdentityKeyReceivingErrorMessage.h"
#import "TSMessagesManager+attachments.h"
#import "TSStorageHeaders.h"
#import "TextSecureKitEnv.h"
@interface TSMessagesManager ()
@end

View File

@ -1,22 +1,17 @@
//
// TSStorageManager.m
// TextSecureKit
//
// Created by Frederic Jacobs on 27/10/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import <25519/Randomness.h>
#import <SSKeychain/SSKeychain.h>
#import <YapDatabase/YapDatabaseRelationship.h>
#import "TSStorageManager.h"
#import "NSData+Base64.h"
#import "SignalRecipient.h"
#import "TSAttachmentStream.h"
#import "TSDatabaseSecondaryIndexes.h"
#import "TSDatabaseView.h"
#import "TSInteraction.h"
#import "TSStorageManager.h"
#import "TSThread.h"
#import <25519/Randomness.h>
#import <SSKeychain/SSKeychain.h>
#import <YapDatabase/YapDatabaseRelationship.h>
NSString *const TSUIDatabaseConnectionDidUpdateNotification = @"TSUIDatabaseConnectionDidUpdateNotification";

View File

@ -1,16 +1,10 @@
//
// TSYapDatabaseObject.h
// TextSecureKit
//
// Created by Frederic Jacobs on 16/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Mantle/MTLModel+NSCoding.h>
#import "YapDatabaseRelationshipNode.h"
#import "YapDatabaseTransaction.h"
@class YapDatabaseReadTransaction;
@class YapDatabaseReadWriteTransaction;
@interface TSYapDatabaseObject : MTLModel
@ -29,16 +23,16 @@
*
* @return Key (string) identifying the collection
*/
+ (NSString *)collection;
/**
* Fetches the object with the provided identifier
*
* @param uniqueID Unique identifier of the entry in a collection
* @param transaction Transaction used for fetching the object
*
* @return Returns and instance of the object or nil if non-existent
* @return Instance of the object or nil if non-existent
*/
+ (instancetype)fetchObjectWithUniqueID:(NSString *)uniqueID transaction:(YapDatabaseReadTransaction *)transaction;

View File

@ -1,13 +1,9 @@
//
// TSYapDatabaseObject.m
// TextSecureKit
//
// Created by Frederic Jacobs on 16/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "TSStorageManager.h"
#import "TSYapDatabaseObject.h"
#import "TSStorageManager.h"
#import <YapDatabase/YapDatabaseTransaction.h>
@implementation TSYapDatabaseObject
@ -40,7 +36,6 @@
[transaction removeObjectForKey:self.uniqueId inCollection:[[self class] collection]];
}
- (void)remove {
[[TSStorageManager sharedManager]
.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
@ -49,7 +44,6 @@
}];
}
#pragma mark Class Methods
+ (NSString *)collection {

View File

@ -1,10 +1,5 @@
//
// Constants.h
// TextSecureKit
//
// Created by Frederic Jacobs on 28/10/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
@class TSNumberVerifier;

View File

@ -1,6 +1,8 @@
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "TSMessage.h"
#import "TSThread.h"
#import "TSAttachment.h"
#import <XCTest/XCTest.h>