WebRTC calling

* Stun server request
* settable TextSecureEnv
* nullability annotations for TSCall
* Better debug logging for message sending
* fixup tests and expiration time

// FREEBIE
This commit is contained in:
Michael Kirk 2016-12-18 15:08:26 -06:00 committed by Matthew Chen
parent d7149c60dd
commit d1aa253f87
51 changed files with 3210 additions and 50 deletions

View File

@ -35,7 +35,7 @@ PODS:
- ProtocolBuffers (1.9.10)
- Reachability (3.2)
- SAMKeychain (1.5.0)
- SignalServiceKit (0.8.0):
- SignalServiceKit (0.8.1):
- '25519'
- AFNetworking
- AxolotlKit
@ -130,7 +130,7 @@ SPEC CHECKSUMS:
ProtocolBuffers: d088180c10072b3d24a9939a6314b7b9bcc2340b
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
SAMKeychain: 1fc9ae02f576365395758b12888c84704eebc423
SignalServiceKit: b4b9e425f4043ed74dd07e243de18de401252462
SignalServiceKit: 60f92ec89fbbf3196bd786b88f065c0214db9ca8
SocketRocket: 3f77ec2104cc113add553f817ad90a77114f5d43
SQLCipher: 4c768761421736a247ed6cf412d9045615d53dff
TwistedOakCollapsingFutures: f359b90f203e9ab13dfb92c9ff41842a7fe1cd0c

View File

@ -30,6 +30,9 @@
45731A6C1DA87AA1007E22AA /* TSOutgoingMessageTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 45731A6B1DA87AA1007E22AA /* TSOutgoingMessageTest.m */; };
459850C11D22C6F2006FFEDB /* PhoneNumberTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 459850C01D22C6F2006FFEDB /* PhoneNumberTest.m */; };
45A856AC1D220BFF0056CD4D /* TSAttributesTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 45A856AB1D220BFF0056CD4D /* TSAttributesTest.m */; };
45AE48491E072711004D96C2 /* OWSUnitTestEnvironment.m in Sources */ = {isa = PBXBuildFile; fileRef = 45AE48481E072711004D96C2 /* OWSUnitTestEnvironment.m */; };
45AE484C1E072871004D96C2 /* OWSFakeCallMessageHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 45AE484B1E072871004D96C2 /* OWSFakeCallMessageHandler.m */; };
45AE484F1E072906004D96C2 /* OWSFakeNotificationsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 45AE484E1E072906004D96C2 /* OWSFakeNotificationsManager.m */; };
45B700971D9841E400269FFD /* OWSDisappearingMessagesConfigurationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 45B700961D9841E400269FFD /* OWSDisappearingMessagesConfigurationTest.m */; };
45B840211D988DA100F9E938 /* OWSReadReceiptTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 45B840201D988DA100F9E938 /* OWSReadReceiptTest.m */; };
45C6A09A1D2F029B007D8AC0 /* TSMessageTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 45C6A0991D2F029B007D8AC0 /* TSMessageTest.m */; };
@ -86,6 +89,12 @@
459850C01D22C6F2006FFEDB /* PhoneNumberTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PhoneNumberTest.m; path = ../../../tests/Contacts/PhoneNumberTest.m; sourceTree = "<group>"; };
459FE0DA1D4AD49E00E1071A /* TSKitiOSTestApp-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TSKitiOSTestApp-Prefix.pch"; sourceTree = "<group>"; };
45A856AB1D220BFF0056CD4D /* TSAttributesTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSAttributesTest.m; sourceTree = "<group>"; };
45AE48471E072711004D96C2 /* OWSUnitTestEnvironment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWSUnitTestEnvironment.h; path = ../../../tests/TestSupport/Fakes/OWSUnitTestEnvironment.h; sourceTree = "<group>"; };
45AE48481E072711004D96C2 /* OWSUnitTestEnvironment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSUnitTestEnvironment.m; path = ../../../tests/TestSupport/Fakes/OWSUnitTestEnvironment.m; sourceTree = "<group>"; };
45AE484A1E072871004D96C2 /* OWSFakeCallMessageHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWSFakeCallMessageHandler.h; path = ../../../tests/TestSupport/Fakes/OWSFakeCallMessageHandler.h; sourceTree = "<group>"; };
45AE484B1E072871004D96C2 /* OWSFakeCallMessageHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSFakeCallMessageHandler.m; path = ../../../tests/TestSupport/Fakes/OWSFakeCallMessageHandler.m; sourceTree = "<group>"; };
45AE484D1E072906004D96C2 /* OWSFakeNotificationsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWSFakeNotificationsManager.h; path = ../../../tests/TestSupport/Fakes/OWSFakeNotificationsManager.h; sourceTree = "<group>"; };
45AE484E1E072906004D96C2 /* OWSFakeNotificationsManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSFakeNotificationsManager.m; path = ../../../tests/TestSupport/Fakes/OWSFakeNotificationsManager.m; sourceTree = "<group>"; };
45B700961D9841E400269FFD /* OWSDisappearingMessagesConfigurationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSDisappearingMessagesConfigurationTest.m; path = ../../../tests/Contacts/OWSDisappearingMessagesConfigurationTest.m; sourceTree = "<group>"; };
45B840201D988DA100F9E938 /* OWSReadReceiptTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSReadReceiptTest.m; path = ../../../tests/Devices/OWSReadReceiptTest.m; sourceTree = "<group>"; };
45C6A0991D2F029B007D8AC0 /* TSMessageTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TSMessageTest.m; path = ../../../tests/Messages/Interactions/TSMessageTest.m; sourceTree = "<group>"; };
@ -147,6 +156,12 @@
453E1FDA1DA83EFB00DDD7B7 /* OWSFakeContactsUpdater.m */,
454092F81DB7AFDE00579DE1 /* OWSFakeNetworkManager.h */,
454092F91DB7AFDE00579DE1 /* OWSFakeNetworkManager.m */,
45AE48471E072711004D96C2 /* OWSUnitTestEnvironment.h */,
45AE48481E072711004D96C2 /* OWSUnitTestEnvironment.m */,
45AE484A1E072871004D96C2 /* OWSFakeCallMessageHandler.h */,
45AE484B1E072871004D96C2 /* OWSFakeCallMessageHandler.m */,
45AE484D1E072906004D96C2 /* OWSFakeNotificationsManager.h */,
45AE484E1E072906004D96C2 /* OWSFakeNotificationsManager.m */,
);
name = Fakes;
sourceTree = "<group>";
@ -552,6 +567,8 @@
45458B761CC342B600A02153 /* TSAttachmentsTest.m in Sources */,
45C6A09A1D2F029B007D8AC0 /* TSMessageTest.m in Sources */,
453E1FCF1DA8313100DDD7B7 /* OWSMessageSenderTest.m in Sources */,
45AE484C1E072871004D96C2 /* OWSFakeCallMessageHandler.m in Sources */,
45AE48491E072711004D96C2 /* OWSUnitTestEnvironment.m in Sources */,
459850C11D22C6F2006FFEDB /* PhoneNumberTest.m in Sources */,
45458B7A1CC342B600A02153 /* TSStorageSignedPreKeyStore.m in Sources */,
453E1FDB1DA83EFB00DDD7B7 /* OWSFakeContactsUpdater.m in Sources */,
@ -565,6 +582,7 @@
45A856AC1D220BFF0056CD4D /* TSAttributesTest.m in Sources */,
45731A6C1DA87AA1007E22AA /* TSOutgoingMessageTest.m in Sources */,
6323E339D5B8F4CB77EB3ED4 /* SignalRecipientTest.m in Sources */,
45AE484F1E072906004D96C2 /* OWSFakeNotificationsManager.m in Sources */,
6323E1F7730289398452E5C5 /* OWSFingerprintTest.m in Sources */,
454092FA1DB7AFDE00579DE1 /* OWSFakeNetworkManager.m in Sources */,
);

View File

@ -33,6 +33,41 @@ message Envelope {
message Content {
optional DataMessage dataMessage = 1;
optional SyncMessage syncMessage = 2;
optional CallMessage callMessage = 3;
}
message CallMessage {
message Offer {
optional uint64 id = 1;
optional string sessionDescription = 2;
}
message Answer {
optional uint64 id = 1;
optional string sessionDescription = 2;
}
message IceUpdate {
optional uint64 id = 1;
optional string sdpMid = 2;
optional uint32 sdpMLineIndex = 3;
optional string sdp = 4;
}
message Busy {
optional uint64 id = 1;
}
message Hangup {
optional uint64 id = 1;
}
optional Offer offer = 1;
optional Answer answer = 2;
repeated IceUpdate iceUpdate = 3;
optional Hangup hangup = 4;
optional Busy busy = 5;
}
message DataMessage {

View File

@ -19,11 +19,15 @@ static NSString *const TSRegistrationErrorUserInfoHTTPStatus = @"TSHTTPStatus";
@interface TSAccountManager : NSObject
#pragma mark - Initializers
- (instancetype)initWithNetworkManager:(TSNetworkManager *)networkManager
storageManager:(TSStorageManager *)storageManager;
+ (instancetype)sharedInstance;
@property (nonatomic, strong, readonly) TSNetworkManager *networkManager;
/**
* Returns if a user is registered or not
*

View File

@ -23,7 +23,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface TSAccountManager ()
@property (nullable, nonatomic, retain) NSString *phoneNumberAwaitingVerification;
@property (nonatomic, strong, readonly) TSNetworkManager *networkManager;
@property (nonatomic, strong, readonly) TSStorageManager *storageManager;
@end

View File

@ -1,6 +1,7 @@
#import "Constraints.h"
#import "FunctionalUtil.h"
#import "PhoneNumberUtil.h"
#import "Constraints.h"
#import "ContactsManagerProtocol.h"
#import "FunctionalUtil.h"
#import "TextSecureKitEnv.h"
#import "Util.h"

View File

@ -7,7 +7,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface TSContactThread : TSThread
+ (instancetype)getOrCreateThreadWithContactId:(NSString *)contactId;
+ (instancetype)getOrCreateThreadWithContactId:(NSString *)contactId NS_SWIFT_NAME(getOrCreateThread(contactId:));
+ (instancetype)getOrCreateThreadWithContactId:(NSString *)contactId
transaction:(YapDatabaseReadWriteTransaction *)transaction;

View File

@ -2,7 +2,9 @@
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
#import "TSContactThread.h"
#import "ContactsManagerProtocol.h"
#import "ContactsUpdater.h"
#import "NotificationsProtocol.h"
#import "TSStorageManager+identityKeyStore.h"
#import "TextSecureKitEnv.h"
#import <YapDatabase/YapDatabaseConnection.h>

View File

@ -19,10 +19,16 @@ NS_ASSUME_NONNULL_BEGIN
return NO;
}
- (BOOL)isLegacyMessage
{
return NO;
}
- (OWSSignalServiceProtosSyncMessage *)buildSyncMessage
{
NSAssert(NO, @"buildSyncMessage must be overridden in subclass");
// e.g.
OWSSignalServiceProtosSyncMessageBuilder *syncMessageBuilder = [OWSSignalServiceProtosSyncMessageBuilder new];
return [syncMessageBuilder build];
}

View File

@ -7,6 +7,7 @@
//
#import "TSErrorMessage.h"
#import "NotificationsProtocol.h"
#import "TSContactThread.h"
#import "TSErrorMessage_privateConstructor.h"
#import "TSMessagesManager.h"
@ -35,7 +36,7 @@
}
_errorType = errorMessageType;
// TODO Move this out of model class.
[[TextSecureKitEnv sharedEnv].notificationsManager notifyUserForErrorMessage:self inThread:thread];
return self;

View File

@ -134,7 +134,7 @@ static const NSUInteger OWSMessageSchemaVersion = 3;
return self;
}
- (void)setexpiresInSeconds:(uint32_t)expiresInSeconds
- (void)setExpiresInSeconds:(uint32_t)expiresInSeconds
{
_expiresInSeconds = expiresInSeconds;
[self updateExpiresAt];

View File

@ -49,6 +49,13 @@ typedef NS_ENUM(NSInteger, TSOutgoingMessageState) {
@property NSString *customMessage;
@property (atomic, readonly) NSString *mostRecentFailureText;
/**
* Whether the message should be serialized as a modern aka Content, or the old style legacy message.
* Sync and Call messsages must be sent as Content, but other old style DataMessage payloads should be
* sent as legacy message until we're confident no significant number of legacy clients exist in the wild.
*/
@property (nonatomic, readonly) BOOL isLegacyMessage;
- (void)setSendingError:(NSError *)error;
/**

View File

@ -170,11 +170,18 @@ NS_ASSUME_NONNULL_BEGIN
return [[self dataMessageBuilder] build];
}
// For legacy message this is a serialized DataMessage.
// For modern messages, e.g. Sync and Call messages, this is a serialized Contact
- (NSData *)buildPlainTextData
{
return [[self buildDataMessage] data];
}
- (BOOL)isLegacyMessage
{
return YES;
}
- (BOOL)shouldSyncTranscript
{
return !self.hasSyncedTranscript;

View File

@ -0,0 +1,19 @@
// Created by Michael Kirk on 12/1/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosCallMessageAnswer;
@interface OWSCallAnswerMessage : NSObject
- (instancetype)initWithCallId:(UInt64)callId sessionDescription:(NSString *)sessionDescription;
@property (nonatomic, readonly) UInt64 callId;
@property (nonatomic, readonly, copy) NSString *sessionDescription;
- (OWSSignalServiceProtosCallMessageAnswer *)asProtobuf;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,36 @@
// Created by Michael Kirk on 12/1/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "OWSCallAnswerMessage.h"
#import "OWSSignalServiceProtos.pb.h"
NS_ASSUME_NONNULL_BEGIN
@implementation OWSCallAnswerMessage
- (instancetype)initWithCallId:(UInt64)callId sessionDescription:(NSString *)sessionDescription
{
self = [super init];
if (!self) {
return self;
}
_callId = callId;
_sessionDescription = sessionDescription;
return self;
}
- (OWSSignalServiceProtosCallMessageAnswer *)asProtobuf
{
OWSSignalServiceProtosCallMessageAnswerBuilder *builder = [OWSSignalServiceProtosCallMessageAnswerBuilder new];
builder.id = self.callId;
builder.sessionDescription = self.sessionDescription;
return [builder build];
}
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,20 @@
// Created by Michael Kirk on 12/1/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "OWSOutgoingCallMessage.h"
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosCallMessageBusy;
@interface OWSCallBusyMessage : OWSOutgoingCallMessage
- (instancetype)initWithCallId:(UInt64)callId;
@property (nonatomic, readonly) UInt64 callId;
- (OWSSignalServiceProtosCallMessageBusy *)asProtobuf;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,35 @@
// Created by Michael Kirk on 12/1/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "OWSCallBusyMessage.h"
#import "OWSSignalServiceProtos.pb.h"
NS_ASSUME_NONNULL_BEGIN
@implementation OWSCallBusyMessage
- (instancetype)initWithCallId:(UInt64)callId
{
self = [super init];
if (!self) {
return self;
}
_callId = callId;
return self;
}
- (OWSSignalServiceProtosCallMessageBusy *)asProtobuf
{
OWSSignalServiceProtosCallMessageBusyBuilder *builder = [OWSSignalServiceProtosCallMessageBusyBuilder new];
builder.id = self.callId;
return [builder build];
}
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,20 @@
// Created by Michael Kirk on 12/8/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "OWSOutgoingCallMessage.h"
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosCallMessageHangup;
@interface OWSCallHangupMessage : OWSOutgoingCallMessage
- (instancetype)initWithCallId:(UInt64)callId;
@property (nonatomic, readonly) UInt64 callId;
- (OWSSignalServiceProtosCallMessageHangup *)asProtobuf;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,35 @@
// Created by Michael Kirk on 12/8/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "OWSCallHangupMessage.h"
#import "OWSSignalServiceProtos.pb.h"
NS_ASSUME_NONNULL_BEGIN
@implementation OWSCallHangupMessage
- (instancetype)initWithCallId:(UInt64)callId
{
self = [super init];
if (!self) {
return self;
}
_callId = callId;
return self;
}
- (OWSSignalServiceProtosCallMessageHangup *)asProtobuf
{
OWSSignalServiceProtosCallMessageHangupBuilder *builder = [OWSSignalServiceProtosCallMessageHangupBuilder new];
builder.id = self.callId;
return [builder build];
}
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,24 @@
// Created by Michael Kirk on 12/6/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosCallMessageIceUpdate;
@interface OWSCallIceUpdateMessage : NSObject
- (instancetype)initWithCallId:(UInt64)callId
sdp:(NSString *)sdp
sdpMLineIndex:(SInt32)sdpMLineIndex
sdpMid:(nullable NSString *)sdpMid;
@property (nonatomic, readonly) UInt64 callId;
@property (nonatomic, readonly, copy) NSString *sdp;
@property (nonatomic, readonly) SInt32 sdpMLineIndex;
@property (nullable, nonatomic, readonly, copy) NSString *sdpMid;
- (OWSSignalServiceProtosCallMessageIceUpdate *)asProtobuf;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,40 @@
// Created by Michael Kirk on 12/6/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "OWSCallIceUpdateMessage.h"
#import "OWSSignalServiceProtos.pb.h"
@implementation OWSCallIceUpdateMessage
- (instancetype)initWithCallId:(UInt64)callId
sdp:(NSString *)sdp
sdpMLineIndex:(SInt32)sdpMLineIndex
sdpMid:(nullable NSString *)sdpMid
{
self = [super init];
if (!self) {
return self;
}
_callId = callId;
_sdp = sdp;
_sdpMLineIndex = sdpMLineIndex;
_sdpMid = sdpMid;
return self;
}
- (OWSSignalServiceProtosCallMessageIceUpdate *)asProtobuf
{
OWSSignalServiceProtosCallMessageIceUpdateBuilder *builder =
[OWSSignalServiceProtosCallMessageIceUpdateBuilder new];
[builder setId:self.callId];
[builder setSdp:self.sdp];
[builder setSdpMlineIndex:self.sdpMLineIndex];
[builder setSdpMid:self.sdpMid];
return [builder build];
}
@end

View File

@ -0,0 +1,19 @@
// Created by Michael Kirk on 12/1/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosCallMessageOffer;
@interface OWSCallOfferMessage : NSObject
- (instancetype)initWithCallId:(UInt64)callId sessionDescription:(NSString *)sessionDescription;
@property (nonatomic, readonly) UInt64 callId;
@property (nonatomic, readonly, copy) NSString *sessionDescription;
- (OWSSignalServiceProtosCallMessageOffer *)asProtobuf;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,36 @@
// Created by Michael Kirk on 12/1/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "OWSCallOfferMessage.h"
#import "OWSSignalServiceProtos.pb.h"
NS_ASSUME_NONNULL_BEGIN
@implementation OWSCallOfferMessage
- (instancetype)initWithCallId:(UInt64)callId sessionDescription:(NSString *)sessionDescription
{
self = [super init];
if (!self) {
return self;
}
_callId = callId;
_sessionDescription = sessionDescription;
return self;
}
- (OWSSignalServiceProtosCallMessageOffer *)asProtobuf
{
OWSSignalServiceProtosCallMessageOfferBuilder *builder = [OWSSignalServiceProtosCallMessageOfferBuilder new];
builder.id = self.callId;
builder.sessionDescription = self.sessionDescription;
return [builder build];
}
@end
NS_ASSUME_NONNULL_END

View File

@ -83,6 +83,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
success:(void (^)())successHandler
failure:(void (^)(NSError *error))failureHandler
{
DDLogDebug(@"%@ sending message: %@", self.tag, message.debugDescription);
void (^markAndFailureHandler)(NSError *error) = ^(NSError *error) {
[self saveMessage:message withError:error];
failureHandler(error);
@ -625,14 +626,11 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
for (NSNumber *deviceNumber in recipient.devices) {
@try {
// DEPRECATED - Remove after all clients have been upgraded.
BOOL isLegacyMessage = ![message isKindOfClass:[OWSOutgoingSyncMessage class]];
NSDictionary *messageDict = [self encryptedMessageWithPlaintext:plainText
toRecipient:recipient.uniqueId
deviceId:deviceNumber
keyingStorage:[TSStorageManager sharedManager]
legacy:isLegacyMessage];
legacy:message.isLegacyMessage];
if (messageDict) {
[messagesArray addObject:messageDict];
} else {

View File

@ -0,0 +1,34 @@
// Created by Michael Kirk on 12/1/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "TSOutgoingMessage.h"
NS_ASSUME_NONNULL_BEGIN
@class OWSCallOfferMessage;
@class OWSCallAnswerMessage;
@class OWSCallIceUpdateMessage;
@class OWSCallHangupMessage;
@class OWSCallBusyMessage;
@class TSThread;
@interface OWSOutgoingCallMessage : TSOutgoingMessage
- (instancetype)initWithThread:(TSThread *)thread offerMessage:(OWSCallOfferMessage *)offerMessage;
- (instancetype)initWithThread:(TSThread *)thread answerMessage:(OWSCallAnswerMessage *)answerMessage;
- (instancetype)initWithThread:(TSThread *)thread iceUpdateMessage:(OWSCallIceUpdateMessage *)iceUpdateMessage;
- (instancetype)initWithThread:(TSThread *)thread
iceUpdateMessages:(NSArray<OWSCallIceUpdateMessage *> *)iceUpdateMessage;
- (instancetype)initWithThread:(TSThread *)thread hangupMessage:(OWSCallHangupMessage *)hangupMessage;
- (instancetype)initWithThread:(TSThread *)thread busyMessage:(OWSCallBusyMessage *)busyMessage;
@property (nullable, nonatomic, readonly, strong) OWSCallOfferMessage *offerMessage;
@property (nullable, nonatomic, readonly, strong) OWSCallAnswerMessage *answerMessage;
@property (nullable, nonatomic, readonly, strong) NSArray<OWSCallIceUpdateMessage *> *iceUpdateMessages;
@property (nullable, nonatomic, readonly, strong) OWSCallHangupMessage *hangupMessage;
@property (nullable, nonatomic, readonly, strong) OWSCallBusyMessage *busyMessage;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,198 @@
// Created by Michael Kirk on 12/1/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "OWSOutgoingCallMessage.h"
#import "NSDate+millisecondTimeStamp.h"
#import "OWSCallAnswerMessage.h"
#import "OWSCallBusyMessage.h"
#import "OWSCallHangupMessage.h"
#import "OWSCallIceUpdateMessage.h"
#import "OWSCallOfferMessage.h"
#import "OWSSignalServiceProtos.pb.h"
NS_ASSUME_NONNULL_BEGIN
@implementation OWSOutgoingCallMessage
//@synthesize thread = _thread;
- (instancetype)initWithThread:(TSThread *)thread
{
// These records aren't saved, but their timestamp is used in the event
// of a failing message send to insert the error at the appropriate place.
self = [super initWithTimestamp:[NSDate ows_millisecondTimeStamp] inThread:thread];
if (!self) {
return self;
}
return self;
}
- (instancetype)initWithThread:(TSThread *)thread offerMessage:(OWSCallOfferMessage *)offerMessage
{
self = [self initWithThread:thread];
if (!self) {
return self;
}
_offerMessage = offerMessage;
return self;
}
- (instancetype)initWithThread:(TSThread *)thread answerMessage:(OWSCallAnswerMessage *)answerMessage
{
self = [self initWithThread:thread];
if (!self) {
return self;
}
_answerMessage = answerMessage;
return self;
}
- (instancetype)initWithThread:(TSThread *)thread iceUpdateMessage:(OWSCallIceUpdateMessage *)iceUpdateMessage
{
self = [self initWithThread:thread];
if (!self) {
return self;
}
_iceUpdateMessages = @[ iceUpdateMessage ];
return self;
}
- (instancetype)initWithThread:(TSThread *)thread
iceUpdateMessages:(NSArray<OWSCallIceUpdateMessage *> *)iceUpdateMessages
{
self = [self initWithThread:thread];
if (!self) {
return self;
}
_iceUpdateMessages = iceUpdateMessages;
return self;
}
- (instancetype)initWithThread:(TSThread *)thread hangupMessage:(OWSCallHangupMessage *)hangupMessage
{
self = [self initWithThread:thread];
if (!self) {
return self;
}
_hangupMessage = hangupMessage;
return self;
}
- (instancetype)initWithThread:(TSThread *)thread busyMessage:(OWSCallBusyMessage *)busyMessage
{
self = [self initWithThread:thread];
if (!self) {
return self;
}
_busyMessage = busyMessage;
return self;
}
#pragma mark - TSOutgoingMessage overrides
- (BOOL)shouldSyncTranscript
{
return NO;
}
- (BOOL)isLegacyMessage
{
return NO;
}
//
///**
// * override thread accessor in superclass, since this model is never saved.
// * TODO review
// */
//- (TSThread *)thread
//{
// return _thread;
//}
- (NSData *)buildPlainTextData
{
OWSSignalServiceProtosContentBuilder *contentBuilder = [OWSSignalServiceProtosContentBuilder new];
[contentBuilder setCallMessage:[self asProtobuf]];
return [[contentBuilder build] data];
}
- (OWSSignalServiceProtosCallMessage *)asProtobuf
{
OWSSignalServiceProtosCallMessageBuilder *builder = [OWSSignalServiceProtosCallMessageBuilder new];
if (self.offerMessage) {
[builder setOffer:[self.offerMessage asProtobuf]];
}
if (self.answerMessage) {
[builder setAnswer:[self.answerMessage asProtobuf]];
}
if (self.iceUpdateMessages) {
for (OWSCallIceUpdateMessage *iceUpdateMessage in self.iceUpdateMessages) {
[builder addIceUpdate:[iceUpdateMessage asProtobuf]];
}
}
if (self.hangupMessage) {
[builder setHangup:[self.hangupMessage asProtobuf]];
}
if (self.busyMessage) {
[builder setBusy:[self.busyMessage asProtobuf]];
}
return [builder build];
}
#pragma mark - TSYapDatabaseObject overrides
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
{
// override superclass with no-op.
//
// There's no need to save this message, since it's not displayed to the user.
//
// Should we find a need to save this in the future, we need to exclude any non-serializable properties.
}
- (NSString *)debugDescription
{
NSString *className = NSStringFromClass([self class]);
NSString *payload;
if (self.offerMessage) {
payload = @"offerMessage";
} else if (self.answerMessage) {
payload = @"answerMessage";
} else if (self.iceUpdateMessages.count > 0) {
payload = @"iceUpdateMessage";
} else if (self.hangupMessage) {
payload = @"hangupMessage";
} else if (self.busyMessage) {
payload = @"busyMessage";
} else {
payload = @"none";
}
return [NSString stringWithFormat:@"%@ with payload: %@", className, payload];
}
@end
NS_ASSUME_NONNULL_END

View File

@ -6,6 +6,18 @@
@class OWSSignalServiceProtosAttachmentPointer;
@class OWSSignalServiceProtosAttachmentPointerBuilder;
@class OWSSignalServiceProtosCallMessage;
@class OWSSignalServiceProtosCallMessageAnswer;
@class OWSSignalServiceProtosCallMessageAnswerBuilder;
@class OWSSignalServiceProtosCallMessageBuilder;
@class OWSSignalServiceProtosCallMessageBusy;
@class OWSSignalServiceProtosCallMessageBusyBuilder;
@class OWSSignalServiceProtosCallMessageHangup;
@class OWSSignalServiceProtosCallMessageHangupBuilder;
@class OWSSignalServiceProtosCallMessageIceUpdate;
@class OWSSignalServiceProtosCallMessageIceUpdateBuilder;
@class OWSSignalServiceProtosCallMessageOffer;
@class OWSSignalServiceProtosCallMessageOfferBuilder;
@class OWSSignalServiceProtosContactDetails;
@class OWSSignalServiceProtosContactDetailsAvatar;
@class OWSSignalServiceProtosContactDetailsAvatarBuilder;
@ -240,17 +252,22 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro
#define Content_dataMessage @"dataMessage"
#define Content_syncMessage @"syncMessage"
#define Content_callMessage @"callMessage"
@interface OWSSignalServiceProtosContent : PBGeneratedMessage<GeneratedMessageProtocol> {
@private
BOOL hasDataMessage_:1;
BOOL hasSyncMessage_:1;
BOOL hasCallMessage_:1;
OWSSignalServiceProtosDataMessage* dataMessage;
OWSSignalServiceProtosSyncMessage* syncMessage;
OWSSignalServiceProtosCallMessage* callMessage;
}
- (BOOL) hasDataMessage;
- (BOOL) hasSyncMessage;
- (BOOL) hasCallMessage;
@property (readonly, strong) OWSSignalServiceProtosDataMessage* dataMessage;
@property (readonly, strong) OWSSignalServiceProtosSyncMessage* syncMessage;
@property (readonly, strong) OWSSignalServiceProtosCallMessage* callMessage;
+ (instancetype) defaultInstance;
- (instancetype) defaultInstance;
@ -300,6 +317,411 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro
- (OWSSignalServiceProtosContentBuilder*) setSyncMessageBuilder:(OWSSignalServiceProtosSyncMessageBuilder*) builderForValue;
- (OWSSignalServiceProtosContentBuilder*) mergeSyncMessage:(OWSSignalServiceProtosSyncMessage*) value;
- (OWSSignalServiceProtosContentBuilder*) clearSyncMessage;
- (BOOL) hasCallMessage;
- (OWSSignalServiceProtosCallMessage*) callMessage;
- (OWSSignalServiceProtosContentBuilder*) setCallMessage:(OWSSignalServiceProtosCallMessage*) value;
- (OWSSignalServiceProtosContentBuilder*) setCallMessageBuilder:(OWSSignalServiceProtosCallMessageBuilder*) builderForValue;
- (OWSSignalServiceProtosContentBuilder*) mergeCallMessage:(OWSSignalServiceProtosCallMessage*) value;
- (OWSSignalServiceProtosContentBuilder*) clearCallMessage;
@end
#define CallMessage_offer @"offer"
#define CallMessage_answer @"answer"
#define CallMessage_iceUpdate @"iceUpdate"
#define CallMessage_hangup @"hangup"
#define CallMessage_busy @"busy"
@interface OWSSignalServiceProtosCallMessage : PBGeneratedMessage<GeneratedMessageProtocol> {
@private
BOOL hasOffer_:1;
BOOL hasAnswer_:1;
BOOL hasHangup_:1;
BOOL hasBusy_:1;
OWSSignalServiceProtosCallMessageOffer* offer;
OWSSignalServiceProtosCallMessageAnswer* answer;
OWSSignalServiceProtosCallMessageHangup* hangup;
OWSSignalServiceProtosCallMessageBusy* busy;
NSMutableArray * iceUpdateArray;
}
- (BOOL) hasOffer;
- (BOOL) hasAnswer;
- (BOOL) hasHangup;
- (BOOL) hasBusy;
@property (readonly, strong) OWSSignalServiceProtosCallMessageOffer* offer;
@property (readonly, strong) OWSSignalServiceProtosCallMessageAnswer* answer;
@property (readonly, strong) NSArray<OWSSignalServiceProtosCallMessageIceUpdate*> * iceUpdate;
@property (readonly, strong) OWSSignalServiceProtosCallMessageHangup* hangup;
@property (readonly, strong) OWSSignalServiceProtosCallMessageBusy* busy;
- (OWSSignalServiceProtosCallMessageIceUpdate*)iceUpdateAtIndex:(NSUInteger)index;
+ (instancetype) defaultInstance;
- (instancetype) defaultInstance;
- (BOOL) isInitialized;
- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output;
- (OWSSignalServiceProtosCallMessageBuilder*) builder;
+ (OWSSignalServiceProtosCallMessageBuilder*) builder;
+ (OWSSignalServiceProtosCallMessageBuilder*) builderWithPrototype:(OWSSignalServiceProtosCallMessage*) prototype;
- (OWSSignalServiceProtosCallMessageBuilder*) toBuilder;
+ (OWSSignalServiceProtosCallMessage*) parseFromData:(NSData*) data;
+ (OWSSignalServiceProtosCallMessage*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignalServiceProtosCallMessage*) parseFromInputStream:(NSInputStream*) input;
+ (OWSSignalServiceProtosCallMessage*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignalServiceProtosCallMessage*) parseFromCodedInputStream:(PBCodedInputStream*) input;
+ (OWSSignalServiceProtosCallMessage*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
@end
#define Offer_id @"id"
#define Offer_sessionDescription @"sessionDescription"
@interface OWSSignalServiceProtosCallMessageOffer : PBGeneratedMessage<GeneratedMessageProtocol> {
@private
BOOL hasId_:1;
BOOL hasSessionDescription_:1;
UInt64 id;
NSString* sessionDescription;
}
- (BOOL) hasId;
- (BOOL) hasSessionDescription;
@property (readonly) UInt64 id;
@property (readonly, strong) NSString* sessionDescription;
+ (instancetype) defaultInstance;
- (instancetype) defaultInstance;
- (BOOL) isInitialized;
- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output;
- (OWSSignalServiceProtosCallMessageOfferBuilder*) builder;
+ (OWSSignalServiceProtosCallMessageOfferBuilder*) builder;
+ (OWSSignalServiceProtosCallMessageOfferBuilder*) builderWithPrototype:(OWSSignalServiceProtosCallMessageOffer*) prototype;
- (OWSSignalServiceProtosCallMessageOfferBuilder*) toBuilder;
+ (OWSSignalServiceProtosCallMessageOffer*) parseFromData:(NSData*) data;
+ (OWSSignalServiceProtosCallMessageOffer*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignalServiceProtosCallMessageOffer*) parseFromInputStream:(NSInputStream*) input;
+ (OWSSignalServiceProtosCallMessageOffer*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignalServiceProtosCallMessageOffer*) parseFromCodedInputStream:(PBCodedInputStream*) input;
+ (OWSSignalServiceProtosCallMessageOffer*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
@end
@interface OWSSignalServiceProtosCallMessageOfferBuilder : PBGeneratedMessageBuilder {
@private
OWSSignalServiceProtosCallMessageOffer* resultOffer;
}
- (OWSSignalServiceProtosCallMessageOffer*) defaultInstance;
- (OWSSignalServiceProtosCallMessageOfferBuilder*) clear;
- (OWSSignalServiceProtosCallMessageOfferBuilder*) clone;
- (OWSSignalServiceProtosCallMessageOffer*) build;
- (OWSSignalServiceProtosCallMessageOffer*) buildPartial;
- (OWSSignalServiceProtosCallMessageOfferBuilder*) mergeFrom:(OWSSignalServiceProtosCallMessageOffer*) other;
- (OWSSignalServiceProtosCallMessageOfferBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input;
- (OWSSignalServiceProtosCallMessageOfferBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
- (BOOL) hasId;
- (UInt64) id;
- (OWSSignalServiceProtosCallMessageOfferBuilder*) setId:(UInt64) value;
- (OWSSignalServiceProtosCallMessageOfferBuilder*) clearId;
- (BOOL) hasSessionDescription;
- (NSString*) sessionDescription;
- (OWSSignalServiceProtosCallMessageOfferBuilder*) setSessionDescription:(NSString*) value;
- (OWSSignalServiceProtosCallMessageOfferBuilder*) clearSessionDescription;
@end
#define Answer_id @"id"
#define Answer_sessionDescription @"sessionDescription"
@interface OWSSignalServiceProtosCallMessageAnswer : PBGeneratedMessage<GeneratedMessageProtocol> {
@private
BOOL hasId_:1;
BOOL hasSessionDescription_:1;
UInt64 id;
NSString* sessionDescription;
}
- (BOOL) hasId;
- (BOOL) hasSessionDescription;
@property (readonly) UInt64 id;
@property (readonly, strong) NSString* sessionDescription;
+ (instancetype) defaultInstance;
- (instancetype) defaultInstance;
- (BOOL) isInitialized;
- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output;
- (OWSSignalServiceProtosCallMessageAnswerBuilder*) builder;
+ (OWSSignalServiceProtosCallMessageAnswerBuilder*) builder;
+ (OWSSignalServiceProtosCallMessageAnswerBuilder*) builderWithPrototype:(OWSSignalServiceProtosCallMessageAnswer*) prototype;
- (OWSSignalServiceProtosCallMessageAnswerBuilder*) toBuilder;
+ (OWSSignalServiceProtosCallMessageAnswer*) parseFromData:(NSData*) data;
+ (OWSSignalServiceProtosCallMessageAnswer*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignalServiceProtosCallMessageAnswer*) parseFromInputStream:(NSInputStream*) input;
+ (OWSSignalServiceProtosCallMessageAnswer*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignalServiceProtosCallMessageAnswer*) parseFromCodedInputStream:(PBCodedInputStream*) input;
+ (OWSSignalServiceProtosCallMessageAnswer*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
@end
@interface OWSSignalServiceProtosCallMessageAnswerBuilder : PBGeneratedMessageBuilder {
@private
OWSSignalServiceProtosCallMessageAnswer* resultAnswer;
}
- (OWSSignalServiceProtosCallMessageAnswer*) defaultInstance;
- (OWSSignalServiceProtosCallMessageAnswerBuilder*) clear;
- (OWSSignalServiceProtosCallMessageAnswerBuilder*) clone;
- (OWSSignalServiceProtosCallMessageAnswer*) build;
- (OWSSignalServiceProtosCallMessageAnswer*) buildPartial;
- (OWSSignalServiceProtosCallMessageAnswerBuilder*) mergeFrom:(OWSSignalServiceProtosCallMessageAnswer*) other;
- (OWSSignalServiceProtosCallMessageAnswerBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input;
- (OWSSignalServiceProtosCallMessageAnswerBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
- (BOOL) hasId;
- (UInt64) id;
- (OWSSignalServiceProtosCallMessageAnswerBuilder*) setId:(UInt64) value;
- (OWSSignalServiceProtosCallMessageAnswerBuilder*) clearId;
- (BOOL) hasSessionDescription;
- (NSString*) sessionDescription;
- (OWSSignalServiceProtosCallMessageAnswerBuilder*) setSessionDescription:(NSString*) value;
- (OWSSignalServiceProtosCallMessageAnswerBuilder*) clearSessionDescription;
@end
#define IceUpdate_id @"id"
#define IceUpdate_sdpMid @"sdpMid"
#define IceUpdate_sdpMLineIndex @"sdpMlineIndex"
#define IceUpdate_sdp @"sdp"
@interface OWSSignalServiceProtosCallMessageIceUpdate : PBGeneratedMessage<GeneratedMessageProtocol> {
@private
BOOL hasId_:1;
BOOL hasSdpMid_:1;
BOOL hasSdp_:1;
BOOL hasSdpMlineIndex_:1;
UInt64 id;
NSString* sdpMid;
NSString* sdp;
UInt32 sdpMlineIndex;
}
- (BOOL) hasId;
- (BOOL) hasSdpMid;
- (BOOL) hasSdpMlineIndex;
- (BOOL) hasSdp;
@property (readonly) UInt64 id;
@property (readonly, strong) NSString* sdpMid;
@property (readonly) UInt32 sdpMlineIndex;
@property (readonly, strong) NSString* sdp;
+ (instancetype) defaultInstance;
- (instancetype) defaultInstance;
- (BOOL) isInitialized;
- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output;
- (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) builder;
+ (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) builder;
+ (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) builderWithPrototype:(OWSSignalServiceProtosCallMessageIceUpdate*) prototype;
- (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) toBuilder;
+ (OWSSignalServiceProtosCallMessageIceUpdate*) parseFromData:(NSData*) data;
+ (OWSSignalServiceProtosCallMessageIceUpdate*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignalServiceProtosCallMessageIceUpdate*) parseFromInputStream:(NSInputStream*) input;
+ (OWSSignalServiceProtosCallMessageIceUpdate*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignalServiceProtosCallMessageIceUpdate*) parseFromCodedInputStream:(PBCodedInputStream*) input;
+ (OWSSignalServiceProtosCallMessageIceUpdate*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
@end
@interface OWSSignalServiceProtosCallMessageIceUpdateBuilder : PBGeneratedMessageBuilder {
@private
OWSSignalServiceProtosCallMessageIceUpdate* resultIceUpdate;
}
- (OWSSignalServiceProtosCallMessageIceUpdate*) defaultInstance;
- (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) clear;
- (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) clone;
- (OWSSignalServiceProtosCallMessageIceUpdate*) build;
- (OWSSignalServiceProtosCallMessageIceUpdate*) buildPartial;
- (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) mergeFrom:(OWSSignalServiceProtosCallMessageIceUpdate*) other;
- (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input;
- (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
- (BOOL) hasId;
- (UInt64) id;
- (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) setId:(UInt64) value;
- (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) clearId;
- (BOOL) hasSdpMid;
- (NSString*) sdpMid;
- (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) setSdpMid:(NSString*) value;
- (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) clearSdpMid;
- (BOOL) hasSdpMlineIndex;
- (UInt32) sdpMlineIndex;
- (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) setSdpMlineIndex:(UInt32) value;
- (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) clearSdpMlineIndex;
- (BOOL) hasSdp;
- (NSString*) sdp;
- (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) setSdp:(NSString*) value;
- (OWSSignalServiceProtosCallMessageIceUpdateBuilder*) clearSdp;
@end
#define Busy_id @"id"
@interface OWSSignalServiceProtosCallMessageBusy : PBGeneratedMessage<GeneratedMessageProtocol> {
@private
BOOL hasId_:1;
UInt64 id;
}
- (BOOL) hasId;
@property (readonly) UInt64 id;
+ (instancetype) defaultInstance;
- (instancetype) defaultInstance;
- (BOOL) isInitialized;
- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output;
- (OWSSignalServiceProtosCallMessageBusyBuilder*) builder;
+ (OWSSignalServiceProtosCallMessageBusyBuilder*) builder;
+ (OWSSignalServiceProtosCallMessageBusyBuilder*) builderWithPrototype:(OWSSignalServiceProtosCallMessageBusy*) prototype;
- (OWSSignalServiceProtosCallMessageBusyBuilder*) toBuilder;
+ (OWSSignalServiceProtosCallMessageBusy*) parseFromData:(NSData*) data;
+ (OWSSignalServiceProtosCallMessageBusy*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignalServiceProtosCallMessageBusy*) parseFromInputStream:(NSInputStream*) input;
+ (OWSSignalServiceProtosCallMessageBusy*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignalServiceProtosCallMessageBusy*) parseFromCodedInputStream:(PBCodedInputStream*) input;
+ (OWSSignalServiceProtosCallMessageBusy*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
@end
@interface OWSSignalServiceProtosCallMessageBusyBuilder : PBGeneratedMessageBuilder {
@private
OWSSignalServiceProtosCallMessageBusy* resultBusy;
}
- (OWSSignalServiceProtosCallMessageBusy*) defaultInstance;
- (OWSSignalServiceProtosCallMessageBusyBuilder*) clear;
- (OWSSignalServiceProtosCallMessageBusyBuilder*) clone;
- (OWSSignalServiceProtosCallMessageBusy*) build;
- (OWSSignalServiceProtosCallMessageBusy*) buildPartial;
- (OWSSignalServiceProtosCallMessageBusyBuilder*) mergeFrom:(OWSSignalServiceProtosCallMessageBusy*) other;
- (OWSSignalServiceProtosCallMessageBusyBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input;
- (OWSSignalServiceProtosCallMessageBusyBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
- (BOOL) hasId;
- (UInt64) id;
- (OWSSignalServiceProtosCallMessageBusyBuilder*) setId:(UInt64) value;
- (OWSSignalServiceProtosCallMessageBusyBuilder*) clearId;
@end
#define Hangup_id @"id"
@interface OWSSignalServiceProtosCallMessageHangup : PBGeneratedMessage<GeneratedMessageProtocol> {
@private
BOOL hasId_:1;
UInt64 id;
}
- (BOOL) hasId;
@property (readonly) UInt64 id;
+ (instancetype) defaultInstance;
- (instancetype) defaultInstance;
- (BOOL) isInitialized;
- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output;
- (OWSSignalServiceProtosCallMessageHangupBuilder*) builder;
+ (OWSSignalServiceProtosCallMessageHangupBuilder*) builder;
+ (OWSSignalServiceProtosCallMessageHangupBuilder*) builderWithPrototype:(OWSSignalServiceProtosCallMessageHangup*) prototype;
- (OWSSignalServiceProtosCallMessageHangupBuilder*) toBuilder;
+ (OWSSignalServiceProtosCallMessageHangup*) parseFromData:(NSData*) data;
+ (OWSSignalServiceProtosCallMessageHangup*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignalServiceProtosCallMessageHangup*) parseFromInputStream:(NSInputStream*) input;
+ (OWSSignalServiceProtosCallMessageHangup*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignalServiceProtosCallMessageHangup*) parseFromCodedInputStream:(PBCodedInputStream*) input;
+ (OWSSignalServiceProtosCallMessageHangup*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
@end
@interface OWSSignalServiceProtosCallMessageHangupBuilder : PBGeneratedMessageBuilder {
@private
OWSSignalServiceProtosCallMessageHangup* resultHangup;
}
- (OWSSignalServiceProtosCallMessageHangup*) defaultInstance;
- (OWSSignalServiceProtosCallMessageHangupBuilder*) clear;
- (OWSSignalServiceProtosCallMessageHangupBuilder*) clone;
- (OWSSignalServiceProtosCallMessageHangup*) build;
- (OWSSignalServiceProtosCallMessageHangup*) buildPartial;
- (OWSSignalServiceProtosCallMessageHangupBuilder*) mergeFrom:(OWSSignalServiceProtosCallMessageHangup*) other;
- (OWSSignalServiceProtosCallMessageHangupBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input;
- (OWSSignalServiceProtosCallMessageHangupBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
- (BOOL) hasId;
- (UInt64) id;
- (OWSSignalServiceProtosCallMessageHangupBuilder*) setId:(UInt64) value;
- (OWSSignalServiceProtosCallMessageHangupBuilder*) clearId;
@end
@interface OWSSignalServiceProtosCallMessageBuilder : PBGeneratedMessageBuilder {
@private
OWSSignalServiceProtosCallMessage* resultCallMessage;
}
- (OWSSignalServiceProtosCallMessage*) defaultInstance;
- (OWSSignalServiceProtosCallMessageBuilder*) clear;
- (OWSSignalServiceProtosCallMessageBuilder*) clone;
- (OWSSignalServiceProtosCallMessage*) build;
- (OWSSignalServiceProtosCallMessage*) buildPartial;
- (OWSSignalServiceProtosCallMessageBuilder*) mergeFrom:(OWSSignalServiceProtosCallMessage*) other;
- (OWSSignalServiceProtosCallMessageBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input;
- (OWSSignalServiceProtosCallMessageBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
- (BOOL) hasOffer;
- (OWSSignalServiceProtosCallMessageOffer*) offer;
- (OWSSignalServiceProtosCallMessageBuilder*) setOffer:(OWSSignalServiceProtosCallMessageOffer*) value;
- (OWSSignalServiceProtosCallMessageBuilder*) setOfferBuilder:(OWSSignalServiceProtosCallMessageOfferBuilder*) builderForValue;
- (OWSSignalServiceProtosCallMessageBuilder*) mergeOffer:(OWSSignalServiceProtosCallMessageOffer*) value;
- (OWSSignalServiceProtosCallMessageBuilder*) clearOffer;
- (BOOL) hasAnswer;
- (OWSSignalServiceProtosCallMessageAnswer*) answer;
- (OWSSignalServiceProtosCallMessageBuilder*) setAnswer:(OWSSignalServiceProtosCallMessageAnswer*) value;
- (OWSSignalServiceProtosCallMessageBuilder*) setAnswerBuilder:(OWSSignalServiceProtosCallMessageAnswerBuilder*) builderForValue;
- (OWSSignalServiceProtosCallMessageBuilder*) mergeAnswer:(OWSSignalServiceProtosCallMessageAnswer*) value;
- (OWSSignalServiceProtosCallMessageBuilder*) clearAnswer;
- (NSMutableArray<OWSSignalServiceProtosCallMessageIceUpdate*> *)iceUpdate;
- (OWSSignalServiceProtosCallMessageIceUpdate*)iceUpdateAtIndex:(NSUInteger)index;
- (OWSSignalServiceProtosCallMessageBuilder *)addIceUpdate:(OWSSignalServiceProtosCallMessageIceUpdate*)value;
- (OWSSignalServiceProtosCallMessageBuilder *)setIceUpdateArray:(NSArray<OWSSignalServiceProtosCallMessageIceUpdate*> *)array;
- (OWSSignalServiceProtosCallMessageBuilder *)clearIceUpdate;
- (BOOL) hasHangup;
- (OWSSignalServiceProtosCallMessageHangup*) hangup;
- (OWSSignalServiceProtosCallMessageBuilder*) setHangup:(OWSSignalServiceProtosCallMessageHangup*) value;
- (OWSSignalServiceProtosCallMessageBuilder*) setHangupBuilder:(OWSSignalServiceProtosCallMessageHangupBuilder*) builderForValue;
- (OWSSignalServiceProtosCallMessageBuilder*) mergeHangup:(OWSSignalServiceProtosCallMessageHangup*) value;
- (OWSSignalServiceProtosCallMessageBuilder*) clearHangup;
- (BOOL) hasBusy;
- (OWSSignalServiceProtosCallMessageBusy*) busy;
- (OWSSignalServiceProtosCallMessageBuilder*) setBusy:(OWSSignalServiceProtosCallMessageBusy*) value;
- (OWSSignalServiceProtosCallMessageBuilder*) setBusyBuilder:(OWSSignalServiceProtosCallMessageBusyBuilder*) builderForValue;
- (OWSSignalServiceProtosCallMessageBuilder*) mergeBusy:(OWSSignalServiceProtosCallMessageBusy*) value;
- (OWSSignalServiceProtosCallMessageBuilder*) clearBusy;
@end
#define DataMessage_body @"body"

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,8 @@
#import "TSInteraction.h"
NS_ASSUME_NONNULL_BEGIN
@class TSContactThread;
typedef enum {
@ -15,9 +17,11 @@ typedef enum {
@property (nonatomic, readonly) RPRecentCallType callType;
- (instancetype)initWithTimestamp:(uint64_t)timeStamp
- (instancetype)initWithTimestamp:(uint64_t)timestamp
withCallNumber:(NSString *)contactNumber
callType:(RPRecentCallType)callType
inThread:(TSContactThread *)thread;
@end
NS_ASSUME_NONNULL_END

View File

@ -4,13 +4,16 @@
#import "TSCall.h"
#import "TSContactThread.h"
NS_ASSUME_NONNULL_BEGIN
@implementation TSCall
- (instancetype)initWithTimestamp:(uint64_t)timeStamp
- (instancetype)initWithTimestamp:(uint64_t)timestamp
withCallNumber:(NSString *)contactNumber
callType:(RPRecentCallType)callType
inThread:(TSContactThread *)thread {
self = [super initWithTimestamp:timeStamp inThread:thread];
inThread:(TSContactThread *)thread
{
self = [super initWithTimestamp:timestamp inThread:thread];
if (self) {
_callType = callType;
@ -31,3 +34,5 @@
}
@end
NS_ASSUME_NONNULL_END

View File

@ -15,12 +15,15 @@ NS_ASSUME_NONNULL_BEGIN
@class OWSDisappearingMessagesJob;
@class OWSMessageSender;
@protocol ContactsManagerProtocol;
@protocol OWSCallMessageHandler;
@interface TSMessagesManager : NSObject
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithNetworkManager:(TSNetworkManager *)networkManager
storageManager:(TSStorageManager *)storageManager
callMessageHandler:(id<OWSCallMessageHandler>)callMessageHandler
contactsManager:(id<ContactsManagerProtocol>)contactsManager
contactsUpdater:(ContactsUpdater *)contactsUpdater
messageSender:(OWSMessageSender *)messageSender NS_DESIGNATED_INITIALIZER;

View File

@ -7,7 +7,9 @@
#import "MimeTypeUtil.h"
#import "NSData+messagePadding.h"
#import "NSDate+millisecondTimeStamp.h"
#import "NotificationsProtocol.h"
#import "OWSAttachmentsProcessor.h"
#import "OWSCallMessageHandler.h"
#import "OWSDisappearingConfigurationUpdateInfoMessage.h"
#import "OWSDisappearingMessagesConfiguration.h"
#import "OWSDisappearingMessagesJob.h"
@ -36,6 +38,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface TSMessagesManager ()
@property (nonatomic, readonly) id<OWSCallMessageHandler> callMessageHandler;
@property (nonatomic, readonly) id<ContactsManagerProtocol> contactsManager;
@property (nonatomic, readonly) TSStorageManager *storageManager;
@property (nonatomic, readonly) OWSMessageSender *messageSender;
@ -59,6 +62,7 @@ NS_ASSUME_NONNULL_BEGIN
TSNetworkManager *networkManager = [TSNetworkManager sharedManager];
TSStorageManager *storageManager = [TSStorageManager sharedManager];
id<ContactsManagerProtocol> contactsManager = [TextSecureKitEnv sharedEnv].contactsManager;
id<OWSCallMessageHandler> callMessageHandler = [TextSecureKitEnv sharedEnv].callMessageHandler;
ContactsUpdater *contactsUpdater = [ContactsUpdater sharedUpdater];
OWSMessageSender *messageSender = [[OWSMessageSender alloc] initWithNetworkManager:networkManager
storageManager:storageManager
@ -67,6 +71,7 @@ NS_ASSUME_NONNULL_BEGIN
return [self initWithNetworkManager:networkManager
storageManager:storageManager
callMessageHandler:callMessageHandler
contactsManager:contactsManager
contactsUpdater:contactsUpdater
messageSender:messageSender];
@ -74,6 +79,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithNetworkManager:(TSNetworkManager *)networkManager
storageManager:(TSStorageManager *)storageManager
callMessageHandler:(id<OWSCallMessageHandler>)callMessageHandler
contactsManager:(id<ContactsManagerProtocol>)contactsManager
contactsUpdater:(ContactsUpdater *)contactsUpdater
messageSender:(OWSMessageSender *)messageSender
@ -86,6 +92,7 @@ NS_ASSUME_NONNULL_BEGIN
_storageManager = storageManager;
_networkManager = networkManager;
_callMessageHandler = callMessageHandler;
_contactsManager = contactsManager;
_contactsUpdater = contactsUpdater;
_messageSender = messageSender;
@ -229,6 +236,8 @@ NS_ASSUME_NONNULL_BEGIN
[self handleIncomingEnvelope:envelope withSyncMessage:content.syncMessage];
} else if (content.hasDataMessage) {
[self handleIncomingEnvelope:envelope withDataMessage:content.dataMessage];
} else if (content.hasCallMessage) {
[self handleIncomingEnvelope:envelope withCallMessage:content.callMessage];
} else {
DDLogWarn(@"%@ Ignoring envelope.Content with no known payload", self.tag);
}
@ -279,6 +288,30 @@ NS_ASSUME_NONNULL_BEGIN
}
}
- (void)handleIncomingEnvelope:(OWSSignalServiceProtosEnvelope *)incomingEnvelope
withCallMessage:(OWSSignalServiceProtosCallMessage *)callMessage
{
if (callMessage.hasOffer) {
DDLogVerbose(@"%@ Received CallMessage with Offer.", self.tag);
[self.callMessageHandler receivedOffer:callMessage.offer fromCallerId:incomingEnvelope.source];
} else if (callMessage.hasAnswer) {
DDLogVerbose(@"%@ Received CallMessage with Answer.", self.tag);
[self.callMessageHandler receivedAnswer:callMessage.answer fromCallerId:incomingEnvelope.source];
} else if (callMessage.iceUpdate.count > 0) {
DDLogVerbose(@"%@ Received CallMessage with %lu IceUpdates.", self.tag, (unsigned long)callMessage.iceUpdate.count);
for (OWSSignalServiceProtosCallMessageIceUpdate *iceUpdate in callMessage.iceUpdate) {
[self.callMessageHandler receivedIceUpdate:iceUpdate fromCallerId:incomingEnvelope.source];
}
} else if (callMessage.hasHangup) {
DDLogVerbose(@"%@ Received CallMessage with Hangup.", self.tag);
[self.callMessageHandler receivedHangup:callMessage.hangup fromCallerId:incomingEnvelope.source];
} else if (callMessage.hasBusy) {
[self.callMessageHandler receivedBusy:callMessage.busy fromCallerId:incomingEnvelope.source];
} else {
DDLogWarn(@"%@ Ignoring Received CallMessage without actionable content: %@", self.tag, callMessage);
}
}
- (void)handleReceivedGroupAvatarUpdateWithEnvelope:(OWSSignalServiceProtosEnvelope *)envelope
dataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
{
@ -587,7 +620,8 @@ NS_ASSUME_NONNULL_BEGIN
NSString *name = [thread name];
[[TextSecureKitEnv sharedEnv].notificationsManager notifyUserForIncomingMessage:incomingMessage
from:name
inThread:thread];
inThread:thread
contactsManager:self.contactsManager];
}
return incomingMessage;

View File

@ -0,0 +1,13 @@
// Created by Michael Kirk on 11/12/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "TSRequest.h"
NS_ASSUME_NONNULL_BEGIN
NS_SWIFT_NAME(TurnServerInfoRequest)
@interface OWSTurnServerInfoRequest : TSRequest
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,26 @@
// Created by Michael Kirk on 11/12/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "OWSTurnServerInfoRequest.h"
NS_ASSUME_NONNULL_BEGIN
NSString *const OWSTurnServerInfoRequestPath = @"v1/accounts/turn";
@implementation OWSTurnServerInfoRequest
- (instancetype)init
{
self = [super initWithURL:[NSURL URLWithString:OWSTurnServerInfoRequestPath]];
if (!self) {
return self;
}
[self setHTTPMethod:@"GET"];
return self;
}
@end
NS_ASSUME_NONNULL_END

View File

@ -28,6 +28,8 @@
#import <AFNetworking/AFHTTPSessionManager.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface TSNetworkManager : NSObject
+ (id)sharedManager;
@ -37,3 +39,5 @@
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure NS_SWIFT_NAME(makeRequest(_:success:failure:));
@end
NS_ASSUME_NONNULL_END

View File

@ -1,22 +1,17 @@
//
// NotificationsProtocol.h
// Pods
//
// Created by Frederic Jacobs on 05/12/15.
//
//
#import <Foundation/Foundation.h>
// Copyright © 2015 Open Whisper Systems. All rights reserved.
@class TSErrorMessage;
@class TSIncomingMessage;
@class TSThread;
@protocol ContactsManagerProtocol;
@protocol NotificationsProtocol <NSObject>
- (void)notifyUserForIncomingMessage:(TSIncomingMessage *)incomingMessage
from:(NSString *)name
inThread:(TSThread *)thread;
inThread:(TSThread *)thread
contactsManager:(id<ContactsManagerProtocol>)contactsManager;
- (void)notifyUserForErrorMessage:(TSErrorMessage *)error inThread:(TSThread *)thread;

View File

@ -0,0 +1,27 @@
// Created by Michael Kirk on 12/4/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosCallMessageOffer;
@class OWSSignalServiceProtosCallMessageAnswer;
@class OWSSignalServiceProtosCallMessageIceUpdate;
@class OWSSignalServiceProtosCallMessageHangup;
@class OWSSignalServiceProtosCallMessageBusy;
@protocol OWSCallMessageHandler <NSObject>
- (void)receivedOffer:(OWSSignalServiceProtosCallMessageOffer *)offer
fromCallerId:(NSString *)callerId NS_SWIFT_NAME(receivedOffer(_:from:));
- (void)receivedAnswer:(OWSSignalServiceProtosCallMessageAnswer *)answer
fromCallerId:(NSString *)callerId NS_SWIFT_NAME(receivedAnswer(_:from:));
- (void)receivedIceUpdate:(OWSSignalServiceProtosCallMessageIceUpdate *)iceUpdate
fromCallerId:(NSString *)callerId NS_SWIFT_NAME(receivedIceUpdate(_:from:));
- (void)receivedHangup:(OWSSignalServiceProtosCallMessageHangup *)hangup
fromCallerId:(NSString *)callerId NS_SWIFT_NAME(receivedHangup(_:from:));
- (void)receivedBusy:(OWSSignalServiceProtosCallMessageBusy *)busy
fromCallerId:(NSString *)callerId NS_SWIFT_NAME(receivedBusy(_:from:));
@end
NS_ASSUME_NONNULL_END

View File

@ -3,19 +3,29 @@
// Pods
//
// Created by Frederic Jacobs on 05/12/15.
//
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
#import "ContactsManagerProtocol.h"
#import "NotificationsProtocol.h"
@protocol ContactsManagerProtocol;
@protocol NotificationsProtocol;
@protocol OWSCallMessageHandler;
@interface TextSecureKitEnv : NSObject
@property (nonatomic, retain) id<ContactsManagerProtocol> contactsManager;
@property (nonatomic, retain) id<NotificationsProtocol> notificationsManager;
- (instancetype)initWithCallMessageHandler:(id<OWSCallMessageHandler>)callMessageHandler
contactsManager:(id<ContactsManagerProtocol>)contactsManager
notificationsManager:(id<NotificationsProtocol>)notificationsManager NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)sharedEnv;
+ (void)setSharedEnv:(TextSecureKitEnv *)env;
@property (nonatomic, readonly, strong) id<OWSCallMessageHandler> callMessageHandler;
@property (nonatomic, readonly, strong) id<ContactsManagerProtocol> contactsManager;
@property (nonatomic, readonly, strong) id<NotificationsProtocol> notificationsManager;
@end
NS_ASSUME_NONNULL_END

View File

@ -1,22 +1,47 @@
//
// TextSecureKitEnv.m
// Pods
//
// Created by Frederic Jacobs on 05/12/15.
//
//
// Copyright © 2015 Open Whisper Systems. All rights reserved.
#import "TextSecureKitEnv.h"
NS_ASSUME_NONNULL_BEGIN
static TextSecureKitEnv *TextSecureKitEnvSharedInstance;
@implementation TextSecureKitEnv
+ (instancetype)sharedEnv {
static dispatch_once_t onceToken;
static id sharedInstance = nil;
dispatch_once(&onceToken, ^{
sharedInstance = [self.class new];
});
return sharedInstance;
@synthesize callMessageHandler = _callMessageHandler;
@synthesize contactsManager = _contactsManager;
@synthesize notificationsManager = _notificationsManager;
- (instancetype)initWithCallMessageHandler:(id<OWSCallMessageHandler>)callMessageHandler
contactsManager:(id<ContactsManagerProtocol>)contactsManager
notificationsManager:(id<NotificationsProtocol>)notificationsManager
{
self = [super init];
if (!self) {
return self;
}
_callMessageHandler = callMessageHandler;
_contactsManager = contactsManager;
_notificationsManager = notificationsManager;
return self;
}
+ (instancetype)sharedEnv
{
NSAssert(TextSecureKitEnvSharedInstance, @"Trying to access shared TextSecureKitEnv before it's been set");
return TextSecureKitEnvSharedInstance;
}
+ (void)setSharedEnv:(TextSecureKitEnv *)env
{
@synchronized (self) {
NSAssert(TextSecureKitEnvSharedInstance == nil, @"Trying to set shared TextSecureKitEnv which has already been set");
TextSecureKitEnvSharedInstance = env;
}
}
- (id<ContactsManagerProtocol>)contactsManager {
@ -26,3 +51,5 @@
}
@end
NS_ASSUME_NONNULL_END

View File

@ -23,5 +23,6 @@ extern NSError *OWSErrorWithCodeDescription(OWSErrorCode code, NSString *descrip
extern NSError *OWSErrorMakeUnableToProcessServerResponseError();
extern NSError *OWSErrorMakeFailedToSendOutgoingMessageError();
extern NSError *OWSErrorMakeNoSuchSignalRecipientError();
extern NSError *OWSErrorMakeAssertionError();
NS_ASSUME_NONNULL_END

View File

@ -32,4 +32,10 @@ NSError *OWSErrorMakeNoSuchSignalRecipientError()
@"ERROR_DESCRIPTION_UNREGISTERED_RECIPIENT", @"Error message when attempting to send message"));
}
NSError *OWSErrorMakeAssertionError()
{
return OWSErrorWithCodeDescription(OWSErrorCodeFailedToSendOutgoingMessage,
NSLocalizedString(@"ERROR_DESCRIPTION_UNKNOWN_ERROR", @"Worst case generic error message"));
}
NS_ASSUME_NONNULL_END

View File

@ -19,9 +19,10 @@ NS_ASSUME_NONNULL_BEGIN
// Unfortunately this test will break every time you add, remove, or rename a property, but on the
// plus side it has a chance of catching when you indadvertently remove our ephemeral properties
// from our Mantle storage blacklist.
NSArray<NSString *> *expected = @[ @"senderId", @"uniqueId", @"timestamp" ];
NSSet<NSString *> *expected = [NSSet setWithArray:@[ @"senderId", @"uniqueId", @"timestamp" ]];
NSSet<NSString *> *actual = [NSSet setWithArray:[readReceipt.dictionaryValue allKeys]];
XCTAssertEqualObjects(expected, [readReceipt.dictionaryValue allKeys]);
XCTAssertEqualObjects(expected, actual);
}
@end

View File

@ -153,7 +153,7 @@ NS_ASSUME_NONNULL_BEGIN
XCTAssertNil(self.finder.nextExpirationTimestamp);
}
- (void)testNextExpirationTimestampNilWithUpcomingExpiringMessages
- (void)testNextExpirationTimestampNotNilWithUpcomingExpiringMessages
{
TSMessage *soonToExpireMessage = [[TSMessage alloc] initWithTimestamp:1
inThread:self.thread

View File

@ -6,6 +6,7 @@
#import "ContactsManagerProtocol.h"
#import "ContactsUpdater.h"
#import "Cryptography.h"
#import "OWSFakeCallMessageHandler.h"
#import "OWSFakeContactsManager.h"
#import "OWSFakeContactsUpdater.h"
#import "OWSFakeNetworkManager.h"
@ -73,6 +74,7 @@ NS_ASSUME_NONNULL_BEGIN
{
return [[TSMessagesManager alloc] initWithNetworkManager:[OWSFakeNetworkManager new]
storageManager:[TSStorageManager sharedManager]
callMessageHandler:[OWSFakeCallMessageHandler new]
contactsManager:[OWSFakeContactsManager new]
contactsUpdater:[OWSFakeContactsUpdater new]
messageSender:messageSender];

View File

@ -9,10 +9,12 @@
#import <XCTest/XCTest.h>
#import <25519/Curve25519.h>
#import "OWSUnitTestEnvironment.h"
#import "SecurityUtils.h"
#import "TSPrivacyPreferences.h"
#import "TSStorageManager+IdentityKeyStore.h"
#import "TSStorageManager.h"
#import "TextSecureKitEnv.h"
@interface TSStorageIdentityKeyStoreTests : XCTestCase
@ -67,7 +69,7 @@
}
- (void)testChangedKeyWIthNonBlockingIdentityChanges
- (void)testChangedKeyWithNonBlockingIdentityChanges
{
TSPrivacyPreferences *preferences = [TSPrivacyPreferences sharedInstance];
preferences.shouldBlockOnIdentityChange = NO;
@ -82,6 +84,7 @@
NSData *otherKey = [SecurityUtils generateRandomBytes:32];
[TextSecureKitEnv setSharedEnv:[OWSUnitTestEnvironment new]];
XCTAssertTrue([[TSStorageManager sharedManager] isTrustedIdentityKey:otherKey recipientId:recipientId]);
}

View File

@ -0,0 +1,12 @@
// Created by Michael Kirk on 12/18/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "OWSCallMessageHandler.h"
NS_ASSUME_NONNULL_BEGIN
@interface OWSFakeCallMessageHandler : NSObject <OWSCallMessageHandler>
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,37 @@
// Created by Michael Kirk on 12/18/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "OWSFakeCallMessageHandler.h"
NS_ASSUME_NONNULL_BEGIN
@implementation OWSFakeCallMessageHandler
- (void)receivedOffer:(OWSSignalServiceProtosCallMessageOffer *)offer fromCallerId:(NSString *)callerId
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)receivedAnswer:(OWSSignalServiceProtosCallMessageAnswer *)answer fromCallerId:(NSString *)callerId
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)receivedIceUpdate:(OWSSignalServiceProtosCallMessageIceUpdate *)iceUpdate fromCallerId:(NSString *)callerId
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)receivedHangup:(OWSSignalServiceProtosCallMessageHangup *)hangup fromCallerId:(NSString *)callerId
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)receivedBusy:(OWSSignalServiceProtosCallMessageBusy *)busy fromCallerId:(NSString *)callerId
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,12 @@
// Created by Michael Kirk on 12/18/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "NotificationsProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@interface OWSFakeNotificationsManager : NSObject <NotificationsProtocol>
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,25 @@
// Created by Michael Kirk on 12/18/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "OWSFakeNotificationsManager.h"
NS_ASSUME_NONNULL_BEGIN
@implementation OWSFakeNotificationsManager
- (void)notifyUserForIncomingMessage:(TSIncomingMessage *)incomingMessage
from:(NSString *)name
inThread:(TSThread *)thread
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)notifyUserForErrorMessage:(TSErrorMessage *)error inThread:(TSThread *)thread
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,14 @@
// Created by Michael Kirk on 12/18/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "TextSecureKitEnv.h"
NS_ASSUME_NONNULL_BEGIN
@interface OWSUnitTestEnvironment : TextSecureKitEnv
- (instancetype)initDefault;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,22 @@
// Created by Michael Kirk on 12/18/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "OWSUnitTestEnvironment.h"
#import "OWSFakeCallMessageHandler.h"
#import "OWSFakeContactsManager.h"
#import "OWSFakeNotificationsManager.h"
NS_ASSUME_NONNULL_BEGIN
@implementation OWSUnitTestEnvironment
- (instancetype)init
{
return [super initWithCallMessageHandler:[OWSFakeCallMessageHandler new]
contactsManager:[OWSFakeContactsManager new]
notificationsManager:[OWSFakeNotificationsManager new]];
}
@end
NS_ASSUME_NONNULL_END