Migrate call proto wrappers.

pull/1/head
Matthew Chen 7 years ago
parent 135a1655fd
commit dc012d46e4

@ -82,7 +82,6 @@
#import <SignalServiceKit/OWSAsserts.h> #import <SignalServiceKit/OWSAsserts.h>
#import <SignalServiceKit/OWSAttachmentsProcessor.h> #import <SignalServiceKit/OWSAttachmentsProcessor.h>
#import <SignalServiceKit/OWSBackgroundTask.h> #import <SignalServiceKit/OWSBackgroundTask.h>
#import <SignalServiceKit/OWSCallBusyMessage.h>
#import <SignalServiceKit/OWSCallMessageHandler.h> #import <SignalServiceKit/OWSCallMessageHandler.h>
#import <SignalServiceKit/OWSContactsOutputStream.h> #import <SignalServiceKit/OWSContactsOutputStream.h>
#import <SignalServiceKit/OWSDispatch.h> #import <SignalServiceKit/OWSDispatch.h>

@ -37,7 +37,7 @@ class DebugUICalling: DebugUIPage {
hangupBuilder.setId(kFakeCallId) hangupBuilder.setId(kFakeCallId)
hangupMessage = try hangupBuilder.build() hangupMessage = try hangupBuilder.build()
} catch { } catch {
Logger.error("\(strongSelf.logTag) could not build proto") owsFail("\(strongSelf.logTag) could not build proto")
return return
} }
let callMessage = OWSOutgoingCallMessage(thread: thread, hangupMessage: hangupMessage) let callMessage = OWSOutgoingCallMessage(thread: thread, hangupMessage: hangupMessage)
@ -52,7 +52,16 @@ class DebugUICalling: DebugUIPage {
guard let strongSelf = self else { return } guard let strongSelf = self else { return }
let kFakeCallId = UInt64(12345) let kFakeCallId = UInt64(12345)
let busyMessage = OWSCallBusyMessage(callId: kFakeCallId) var busyMessage: SSKProtoCallMessageBusy
do {
let busyBuilder = SSKProtoCallMessageBusy.SSKProtoCallMessageBusyBuilder()
busyBuilder.setId(kFakeCallId)
busyMessage = try busyBuilder.build()
} catch {
owsFail("Couldn't build proto in \(#function)")
return
}
let callMessage = OWSOutgoingCallMessage(thread: thread, busyMessage: busyMessage) let callMessage = OWSOutgoingCallMessage(thread: thread, busyMessage: busyMessage)
strongSelf.messageSender.sendPromise(message: callMessage).then { strongSelf.messageSender.sendPromise(message: callMessage).then {

@ -546,12 +546,19 @@ private class SignalCallData: NSObject {
Logger.info("\(self.logTag) \(#function) for call: \(call.identifiersForLogs) thread: \(call.thread.contactIdentifier())") Logger.info("\(self.logTag) \(#function) for call: \(call.identifiersForLogs) thread: \(call.thread.contactIdentifier())")
SwiftAssertIsOnMainThread(#function) SwiftAssertIsOnMainThread(#function)
let busyMessage = OWSCallBusyMessage(callId: call.signalingId) do {
let callMessage = OWSOutgoingCallMessage(thread: call.thread, busyMessage: busyMessage) let busyBuilder = SSKProtoCallMessageBusy.SSKProtoCallMessageBusyBuilder()
let sendPromise = messageSender.sendPromise(message: callMessage) busyBuilder.setId(call.signalingId)
sendPromise.retainUntilComplete() let busyMessage = try busyBuilder.build()
let callMessage = OWSOutgoingCallMessage(thread: call.thread, busyMessage: busyMessage)
let sendPromise = messageSender.sendPromise(message: callMessage)
sendPromise.retainUntilComplete()
handleMissedCall(call) handleMissedCall(call)
} catch {
owsFail("Couldn't build proto in \(#function)")
}
} }
/** /**

@ -1,24 +0,0 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSOutgoingCallMessage.h"
NS_ASSUME_NONNULL_BEGIN
@class SSKProtoCallMessageBusy;
/**
* Sent by the call recipient after receiving a call offer when they are already in a call.
*/
@interface OWSCallBusyMessage : OWSOutgoingCallMessage
- (instancetype)initWithCallId:(UInt64)callId;
@property (nonatomic, readonly) UInt64 callId;
- (nullable SSKProtoCallMessageBusy *)asProtobuf;
@end
NS_ASSUME_NONNULL_END

@ -1,41 +0,0 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSCallBusyMessage.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@implementation OWSCallBusyMessage
- (instancetype)initWithCallId:(UInt64)callId
{
self = [super init];
if (!self) {
return self;
}
_callId = callId;
return self;
}
- (nullable SSKProtoCallMessageBusy *)asProtobuf
{
SSKProtoCallMessageBusyBuilder *builder = [SSKProtoCallMessageBusyBuilder new];
builder.id = self.callId;
NSError *error;
SSKProtoCallMessageBusy *_Nullable result = [builder buildAndReturnError:&error];
if (error || !result) {
OWSFail(@"%@ could not build protobuf: %@", self.logTag, error);
return nil;
}
return result;
}
@end
NS_ASSUME_NONNULL_END

@ -6,8 +6,8 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class OWSCallBusyMessage;
@class SSKProtoCallMessageAnswer; @class SSKProtoCallMessageAnswer;
@class SSKProtoCallMessageBusy;
@class SSKProtoCallMessageHangup; @class SSKProtoCallMessageHangup;
@class SSKProtoCallMessageIceUpdate; @class SSKProtoCallMessageIceUpdate;
@class SSKProtoCallMessageOffer; @class SSKProtoCallMessageOffer;
@ -35,13 +35,13 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithThread:(TSThread *)thread - (instancetype)initWithThread:(TSThread *)thread
iceUpdateMessages:(NSArray<SSKProtoCallMessageIceUpdate *> *)iceUpdateMessage; iceUpdateMessages:(NSArray<SSKProtoCallMessageIceUpdate *> *)iceUpdateMessage;
- (instancetype)initWithThread:(TSThread *)thread hangupMessage:(SSKProtoCallMessageHangup *)hangupMessage; - (instancetype)initWithThread:(TSThread *)thread hangupMessage:(SSKProtoCallMessageHangup *)hangupMessage;
- (instancetype)initWithThread:(TSThread *)thread busyMessage:(OWSCallBusyMessage *)busyMessage; - (instancetype)initWithThread:(TSThread *)thread busyMessage:(SSKProtoCallMessageBusy *)busyMessage;
@property (nullable, nonatomic, readonly) SSKProtoCallMessageOffer *offerMessage; @property (nullable, nonatomic, readonly) SSKProtoCallMessageOffer *offerMessage;
@property (nullable, nonatomic, readonly) SSKProtoCallMessageAnswer *answerMessage; @property (nullable, nonatomic, readonly) SSKProtoCallMessageAnswer *answerMessage;
@property (nullable, nonatomic, readonly) NSArray<SSKProtoCallMessageIceUpdate *> *iceUpdateMessages; @property (nullable, nonatomic, readonly) NSArray<SSKProtoCallMessageIceUpdate *> *iceUpdateMessages;
@property (nullable, nonatomic, readonly) SSKProtoCallMessageHangup *hangupMessage; @property (nullable, nonatomic, readonly) SSKProtoCallMessageHangup *hangupMessage;
@property (nullable, nonatomic, readonly) OWSCallBusyMessage *busyMessage; @property (nullable, nonatomic, readonly) SSKProtoCallMessageBusy *busyMessage;
@end @end

@ -4,7 +4,6 @@
#import "OWSOutgoingCallMessage.h" #import "OWSOutgoingCallMessage.h"
#import "NSDate+OWS.h" #import "NSDate+OWS.h"
#import "OWSCallBusyMessage.h"
#import "ProtoUtils.h" #import "ProtoUtils.h"
#import "SignalRecipient.h" #import "SignalRecipient.h"
#import "TSContactThread.h" #import "TSContactThread.h"
@ -96,7 +95,7 @@ NS_ASSUME_NONNULL_BEGIN
return self; return self;
} }
- (instancetype)initWithThread:(TSThread *)thread busyMessage:(OWSCallBusyMessage *)busyMessage - (instancetype)initWithThread:(TSThread *)thread busyMessage:(SSKProtoCallMessageBusy *)busyMessage
{ {
self = [self initWithThread:thread]; self = [self initWithThread:thread];
if (!self) { if (!self) {
@ -159,11 +158,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
if (self.busyMessage) { if (self.busyMessage) {
SSKProtoCallMessageBusy *_Nullable proto = [self.busyMessage asProtobuf]; [builder setBusy:self.busyMessage];
if (!proto) {
return nil;
}
[builder setBusy:proto];
} }
[ProtoUtils addLocalProfileKeyIfNecessary:self.thread recipientId:recipientId callMessageBuilder:builder]; [ProtoUtils addLocalProfileKeyIfNecessary:self.thread recipientId:recipientId callMessageBuilder:builder];

Loading…
Cancel
Save