We aren't using ErrorMessage/InfoMessage. (#1412)

We incorrectly assumed some parameters were these types, but actually
they were TSMessageAdapters.

// FREEBIE
This commit is contained in:
Michael Kirk 2016-10-23 13:39:42 -04:00 committed by GitHub
parent 722c3a5e78
commit 7c32259a92
7 changed files with 6 additions and 205 deletions

View File

@ -16,8 +16,6 @@
4520D8D51D417D8E00123472 /* Photos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4520D8D41D417D8E00123472 /* Photos.framework */; };
452E3C8E1D935C77002A45B0 /* OWSConversationSettingsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 452E3C8D1D935C77002A45B0 /* OWSConversationSettingsTableViewController.m */; };
452E3C8F1D935C77002A45B0 /* OWSConversationSettingsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 452E3C8D1D935C77002A45B0 /* OWSConversationSettingsTableViewController.m */; };
453D28B31D32B87100D523F0 /* OWSErrorMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 453D28B01D32B87100D523F0 /* OWSErrorMessage.m */; };
453D28B41D32B87100D523F0 /* OWSInfoMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 453D28B21D32B87100D523F0 /* OWSInfoMessage.m */; };
453D28B71D32BA5F00D523F0 /* OWSDisplayedMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 453D28B61D32BA5F00D523F0 /* OWSDisplayedMessage.m */; };
453D28BA1D332DB100D523F0 /* OWSMessagesBubblesSizeCalculator.m in Sources */ = {isa = PBXBuildFile; fileRef = 453D28B91D332DB100D523F0 /* OWSMessagesBubblesSizeCalculator.m */; };
453D28BB1D332DB100D523F0 /* OWSMessagesBubblesSizeCalculator.m in Sources */ = {isa = PBXBuildFile; fileRef = 453D28B91D332DB100D523F0 /* OWSMessagesBubblesSizeCalculator.m */; };
@ -538,10 +536,6 @@
452E3C8C1D935C77002A45B0 /* OWSConversationSettingsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSConversationSettingsTableViewController.h; sourceTree = "<group>"; };
452E3C8D1D935C77002A45B0 /* OWSConversationSettingsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = OWSConversationSettingsTableViewController.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
453CC0361D08E1A60040EBA3 /* sn */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sn; path = translations/sn.lproj/Localizable.strings; sourceTree = "<group>"; };
453D28AF1D32B87100D523F0 /* OWSErrorMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSErrorMessage.h; sourceTree = "<group>"; };
453D28B01D32B87100D523F0 /* OWSErrorMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSErrorMessage.m; sourceTree = "<group>"; };
453D28B11D32B87100D523F0 /* OWSInfoMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSInfoMessage.h; sourceTree = "<group>"; };
453D28B21D32B87100D523F0 /* OWSInfoMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSInfoMessage.m; sourceTree = "<group>"; };
453D28B51D32BA5F00D523F0 /* OWSDisplayedMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSDisplayedMessage.h; sourceTree = "<group>"; };
453D28B61D32BA5F00D523F0 /* OWSDisplayedMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSDisplayedMessage.m; sourceTree = "<group>"; };
453D28B81D332DB100D523F0 /* OWSMessagesBubblesSizeCalculator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSMessagesBubblesSizeCalculator.h; sourceTree = "<group>"; };
@ -1193,10 +1187,6 @@
B62D53F41A23CC8B009AAF82 /* TSMessageAdapters */,
453D28B51D32BA5F00D523F0 /* OWSDisplayedMessage.h */,
453D28B61D32BA5F00D523F0 /* OWSDisplayedMessage.m */,
453D28AF1D32B87100D523F0 /* OWSErrorMessage.h */,
453D28B01D32B87100D523F0 /* OWSErrorMessage.m */,
453D28B11D32B87100D523F0 /* OWSInfoMessage.h */,
453D28B21D32B87100D523F0 /* OWSInfoMessage.m */,
45C681B51D305A580050903A /* OWSCall.h */,
45C681B61D305A580050903A /* OWSCall.m */,
453D28B81D332DB100D523F0 /* OWSMessagesBubblesSizeCalculator.h */,
@ -2793,12 +2783,10 @@
76EB05FE18170B33006006FC /* InitiateSignal.pb.m in Sources */,
76EB05CA18170B33006006FC /* RecipientUnavailable.m in Sources */,
E197B61418BBEC1A00F073E5 /* DropoutTracker.m in Sources */,
453D28B41D32B87100D523F0 /* OWSInfoMessage.m in Sources */,
FCAC963C19FEF9280046DFC5 /* SignalsViewController.m in Sources */,
76EB05DA18170B33006006FC /* LowLatencyConnector.m in Sources */,
76EB05EE18170B33006006FC /* CallTermination.m in Sources */,
B66B9F7D1AEAF40500E2E609 /* NotificationSettingsOptionsViewController.m in Sources */,
453D28B31D32B87100D523F0 /* OWSErrorMessage.m in Sources */,
E1CD329618BCFF9900B1A496 /* SoundInstance.m in Sources */,
76EB05B418170B33006006FC /* HashChain.m in Sources */,
76EB05E418170B33006006FC /* UdpSocket.m in Sources */,

View File

@ -1,32 +0,0 @@
// Created by Dylan Bourgeois on 29/11/14.
// Copyright (c) 2014 Hexed Bits. All rights reserved.
// Portions Copyright (c) 2016 Open Whisper Systems. All rights reserved.
#import "OWSDisplayedMessage.h"
#import "TSMessageAdapter.h"
typedef NS_ENUM(NSInteger, OWSErrorMessageType) {
OWSErrorMessageNoSession,
OWSErrorMessageWrongTrustedIdentityKey,
OWSErrorMessageInvalidKeyException,
OWSErrorMessageMissingKeyId,
OWSErrorMessageInvalidMessage,
OWSErrorMessageDuplicateMessage,
OWSErrorMessageInvalidVersion
};
@interface OWSErrorMessage : OWSDisplayedMessage
@property (nonatomic) OWSErrorMessageType errorMessageType;
@property (nonatomic) TSMessageAdapterType messageType;
#pragma mark - Initialization
- (instancetype)initWithErrorType:(OWSErrorMessageType)messageType
senderId:(NSString *)senderId
senderDisplayName:(NSString *)senderDisplayName
date:(NSDate *)date;
- (NSString *)text;
@end

View File

@ -1,75 +0,0 @@
// Created by Dylan Bourgeois on 29/11/14.
// Copyright (c) 2014 Hexed Bits. All rights reserved.
#import "OWSErrorMessage.h"
@implementation OWSErrorMessage
- (instancetype)initWithErrorType:(OWSErrorMessageType)messageType
senderId:(NSString *)senderId
senderDisplayName:(NSString *)senderDisplayName
date:(NSDate *)date
{
self = [super initWithSenderId:senderId senderDisplayName:senderDisplayName date:date];
if (!self) {
return self;
}
_errorMessageType = messageType;
_messageType = TSErrorMessageAdapter;
return self;
}
- (NSString *)text
{
switch (self.errorMessageType) {
case OWSErrorMessageNoSession:
return [NSString stringWithFormat:@"No session error"];
break;
case OWSErrorMessageWrongTrustedIdentityKey:
return [NSString stringWithFormat:@"Error : Wrong trusted identity key for %@.", self.senderDisplayName];
break;
case OWSErrorMessageInvalidKeyException:
return [NSString stringWithFormat:@"Error : Invalid key exception for %@.", self.senderDisplayName];
break;
case OWSErrorMessageMissingKeyId:
return [NSString stringWithFormat:@"Error: Missing key identifier for %@", self.senderDisplayName];
break;
case OWSErrorMessageInvalidMessage:
return [NSString stringWithFormat:@"Error: Invalid message"];
break;
case OWSErrorMessageDuplicateMessage:
return [NSString stringWithFormat:@"Error: Duplicate message"];
break;
case OWSErrorMessageInvalidVersion:
return [NSString stringWithFormat:@"Error: Invalid version for contact %@.", self.senderDisplayName];
break;
default:
return nil;
break;
}
}
- (NSUInteger)hash
{
return self.senderId.hash ^ self.date.hash;
}
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: senderId=%@, senderDisplayName=%@, date=%@, type=%ld>",
[self class],
self.senderId,
self.senderDisplayName,
self.date,
(long)self.errorMessageType];
}
- (TSMessageAdapterType)messageType
{
return TSErrorMessageAdapter;
}
@end

View File

@ -1,23 +0,0 @@
// Created by Dylan Bourgeois on 29/11/14.
// Copyright (c) 2014 Hexed Bits. All rights reserved.
// Portions Copyright (c) 2016 Open Whisper Systems. All rights reserved.
#import "OWSDisplayedMessage.h"
#import "TSInfoMessage.h"
#import "TSMessageAdapter.h"
@interface OWSInfoMessage : OWSDisplayedMessage
@property (nonatomic) TSInfoMessageType infoMessageType;
@property (nonatomic) TSMessageAdapterType messageType;
#pragma mark - Initialization
- (instancetype)initWithInfoType:(TSInfoMessageType)messageType
senderId:(NSString *)senderId
senderDisplayName:(NSString *)senderDisplayName
date:(NSDate *)date;
- (NSString *)text;
@end

View File

@ -1,55 +0,0 @@
// Created by Dylan Bourgeois on 29/11/14.
// Copyright (c) 2014 Hexed Bits. All rights reserved.
// Portions Copyright (c) 2016 Open Whisper Systems. All rights reserved.
#import "OWSInfoMessage.h"
@implementation OWSInfoMessage
- (instancetype)initWithInfoType:(TSInfoMessageType)messageType
senderId:(NSString *)senderId
senderDisplayName:(NSString *)senderDisplayName
date:(NSDate *)date
{
//@discussion: NSParameterAssert() ?
self = [super initWithSenderId:senderId senderDisplayName:senderDisplayName date:date];
if (!self) {
return self;
}
_infoMessageType = messageType;
_messageType = TSInfoMessageAdapter;
return self;
}
- (NSString *)text
{
switch (self.infoMessageType) {
case TSInfoMessageTypeSessionDidEnd:
return [NSString stringWithFormat:@"Session with %@ ended.", self.senderDisplayName];
break;
default:
return nil;
break;
}
}
- (NSUInteger)hash
{
return self.senderId.hash ^ self.date.hash;
}
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: senderId=%@, senderDisplayName=%@, date=%@, type=%ld>",
[self class],
self.senderId,
self.senderDisplayName,
self.date,
(long)self.infoMessageType];
}
@end

View File

@ -8,6 +8,7 @@
#import "OWSMessageData.h"
#import "OWSMessageEditing.h"
#import "TSInfoMessage.h"
NS_ASSUME_NONNULL_BEGIN
@ -21,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (id<OWSMessageData>)messageViewDataWithInteraction:(TSInteraction *)interaction inThread:(TSThread *)thread;
@property (nonatomic) TSInteraction *interaction;
@property (readonly) TSInfoMessageType infoMessageType;
@end

View File

@ -21,10 +21,8 @@
#import "OWSConversationSettingsTableViewController.h"
#import "OWSDisappearingMessagesJob.h"
#import "OWSDisplayedMessageCollectionViewCell.h"
#import "OWSErrorMessage.h"
#import "OWSExpirableMessageView.h"
#import "OWSIncomingMessageCollectionViewCell.h"
#import "OWSInfoMessage.h"
#import "OWSMessagesBubblesSizeCalculator.h"
#import "OWSOutgoingMessageCollectionViewCell.h"
#import "PhoneManager.h"
@ -740,12 +738,10 @@ typedef enum : NSUInteger {
cell = [self loadCallCellForCall:call atIndexPath:indexPath];
} break;
case TSInfoMessageAdapter: {
OWSInfoMessage *infoMessage = (OWSInfoMessage *)message;
cell = [self loadInfoMessageCellForMessage:infoMessage atIndexPath:indexPath];
cell = [self loadInfoMessageCellForMessage:(TSMessageAdapter *)message atIndexPath:indexPath];
} break;
case TSErrorMessageAdapter: {
OWSErrorMessage *errorMessage = (OWSErrorMessage *)message;
cell = [self loadErrorMessageCellForMessage:errorMessage atIndexPath:indexPath];
cell = [self loadErrorMessageCellForMessage:(TSMessageAdapter *)message atIndexPath:indexPath];
} break;
case TSIncomingMessageAdapter: {
cell = [self loadIncomingMessageCellForMessage:message atIndexPath:indexPath];
@ -878,7 +874,7 @@ typedef enum : NSUInteger {
return messageCell;
}
- (OWSDisplayedMessageCollectionViewCell *)loadInfoMessageCellForMessage:(OWSInfoMessage *)infoMessage
- (OWSDisplayedMessageCollectionViewCell *)loadInfoMessageCellForMessage:(TSMessageAdapter *)infoMessage
atIndexPath:(NSIndexPath *)indexPath
{
OWSDisplayedMessageCollectionViewCell *infoCell = [self loadDisplayedMessageCollectionViewCellForIndexPath:indexPath];
@ -908,7 +904,7 @@ typedef enum : NSUInteger {
return infoCell;
}
- (OWSDisplayedMessageCollectionViewCell *)loadErrorMessageCellForMessage:(OWSErrorMessage *)errorMessage
- (OWSDisplayedMessageCollectionViewCell *)loadErrorMessageCellForMessage:(TSMessageAdapter *)errorMessage
atIndexPath:(NSIndexPath *)indexPath
{
OWSDisplayedMessageCollectionViewCell *errorCell = [self loadDisplayedMessageCollectionViewCellForIndexPath:indexPath];