Migrate call proto wrappers.

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

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

@ -37,7 +37,7 @@ class DebugUICalling: DebugUIPage {
hangupBuilder.setId(kFakeCallId)
hangupMessage = try hangupBuilder.build()
} catch {
Logger.error("\(strongSelf.logTag) could not build proto")
owsFail("\(strongSelf.logTag) could not build proto")
return
}
let callMessage = OWSOutgoingCallMessage(thread: thread, hangupMessage: hangupMessage)
@ -52,7 +52,16 @@ class DebugUICalling: DebugUIPage {
guard let strongSelf = self else { return }
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)
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())")
SwiftAssertIsOnMainThread(#function)
let busyMessage = OWSCallBusyMessage(callId: call.signalingId)
let callMessage = OWSOutgoingCallMessage(thread: call.thread, busyMessage: busyMessage)
let sendPromise = messageSender.sendPromise(message: callMessage)
sendPromise.retainUntilComplete()
do {
let busyBuilder = SSKProtoCallMessageBusy.SSKProtoCallMessageBusyBuilder()
busyBuilder.setId(call.signalingId)
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
@class OWSCallBusyMessage;
@class SSKProtoCallMessageAnswer;
@class SSKProtoCallMessageBusy;
@class SSKProtoCallMessageHangup;
@class SSKProtoCallMessageIceUpdate;
@class SSKProtoCallMessageOffer;
@ -35,13 +35,13 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithThread:(TSThread *)thread
iceUpdateMessages:(NSArray<SSKProtoCallMessageIceUpdate *> *)iceUpdateMessage;
- (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) SSKProtoCallMessageAnswer *answerMessage;
@property (nullable, nonatomic, readonly) NSArray<SSKProtoCallMessageIceUpdate *> *iceUpdateMessages;
@property (nullable, nonatomic, readonly) SSKProtoCallMessageHangup *hangupMessage;
@property (nullable, nonatomic, readonly) OWSCallBusyMessage *busyMessage;
@property (nullable, nonatomic, readonly) SSKProtoCallMessageBusy *busyMessage;
@end

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

Loading…
Cancel
Save