Migrate call proto wrappers.

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

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

@ -31,7 +31,15 @@ class DebugUICalling: DebugUIPage {
guard let strongSelf = self else { return }
let kFakeCallId = UInt64(12345)
let hangupMessage = OWSCallHangupMessage(callId: kFakeCallId)
var hangupMessage: SSKProtoCallMessageHangup
do {
let hangupBuilder = SSKProtoCallMessageHangup.SSKProtoCallMessageHangupBuilder()
hangupBuilder.setId(kFakeCallId)
hangupMessage = try hangupBuilder.build()
} catch {
Logger.error("\(strongSelf.logTag) could not build proto")
return
}
let callMessage = OWSOutgoingCallMessage(thread: thread, hangupMessage: hangupMessage)
strongSelf.messageSender.sendPromise(message: callMessage).then {

@ -1201,17 +1201,25 @@ private class SignalCallData: NSObject {
}
// If the call hasn't started yet, we don't have a data channel to communicate the hang up. Use Signal Service Message.
let hangupMessage = OWSCallHangupMessage(callId: call.signalingId)
let callMessage = OWSOutgoingCallMessage(thread: call.thread, hangupMessage: hangupMessage)
let sendPromise = self.messageSender.sendPromise(message: callMessage).then {
Logger.debug("\(self.logTag) successfully sent hangup call message to \(call.thread.contactIdentifier())")
}.catch { error in
OWSProdInfo(OWSAnalyticsEvents.callServiceErrorHandleLocalHungupCall(), file: #file, function: #function, line: #line)
Logger.error("\(self.logTag) failed to send hangup call message to \(call.thread.contactIdentifier()) with error: \(error)")
}
sendPromise.retainUntilComplete()
terminateCall()
do {
let hangupBuilder = SSKProtoCallMessageHangup.SSKProtoCallMessageHangupBuilder()
hangupBuilder.setId(call.signalingId)
let hangupProto = try hangupBuilder.build()
let callMessage = OWSOutgoingCallMessage(thread: call.thread, hangupMessage: hangupProto)
let sendPromise = self.messageSender.sendPromise(message: callMessage).then {
Logger.debug("\(self.logTag) successfully sent hangup call message to \(call.thread.contactIdentifier())")
}.catch { error in
OWSProdInfo(OWSAnalyticsEvents.callServiceErrorHandleLocalHungupCall(), file: #file, function: #function, line: #line)
Logger.error("\(self.logTag) failed to send hangup call message to \(call.thread.contactIdentifier()) with error: \(error)")
}
sendPromise.retainUntilComplete()
terminateCall()
} catch {
handleFailedCall(failedCall: call, error: CallError.assertionError(description: "\(self.logTag) 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 SSKProtoCallMessageHangup;
/**
* Sent by either party in a call to indicate the user intentionally ended the call.
*/
@interface OWSCallHangupMessage : OWSOutgoingCallMessage
- (instancetype)initWithCallId:(UInt64)callId;
@property (nonatomic, readonly) UInt64 callId;
- (nullable SSKProtoCallMessageHangup *)asProtobuf;
@end
NS_ASSUME_NONNULL_END

@ -1,42 +0,0 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSCallHangupMessage.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@implementation OWSCallHangupMessage
- (instancetype)initWithCallId:(UInt64)callId
{
self = [super init];
if (!self) {
return self;
}
_callId = callId;
return self;
}
- (nullable SSKProtoCallMessageHangup *)asProtobuf
{
SSKProtoCallMessageHangupBuilder *builder = [SSKProtoCallMessageHangupBuilder new];
builder.id = self.callId;
NSError *error;
SSKProtoCallMessageHangup *_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

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

@ -5,7 +5,6 @@
#import "OWSOutgoingCallMessage.h"
#import "NSDate+OWS.h"
#import "OWSCallBusyMessage.h"
#import "OWSCallHangupMessage.h"
#import "ProtoUtils.h"
#import "SignalRecipient.h"
#import "TSContactThread.h"
@ -85,7 +84,7 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (instancetype)initWithThread:(TSThread *)thread hangupMessage:(OWSCallHangupMessage *)hangupMessage
- (instancetype)initWithThread:(TSThread *)thread hangupMessage:(SSKProtoCallMessageHangup *)hangupMessage
{
self = [self initWithThread:thread];
if (!self) {
@ -156,11 +155,7 @@ NS_ASSUME_NONNULL_BEGIN
}
if (self.hangupMessage) {
SSKProtoCallMessageHangup *_Nullable proto = [self.hangupMessage asProtobuf];
if (!proto) {
return nil;
}
[builder setHangup:proto];
[builder setHangup:self.hangupMessage];
}
if (self.busyMessage) {

Loading…
Cancel
Save