Merge branch 'charlesmchen/voiceAndWebrtcDefaults'

pull/1/head
Matthew Chen 8 years ago
commit adee71ba9b

@ -192,17 +192,12 @@ NS_ASSUME_NONNULL_BEGIN
[SignalRecipient recipientWithTextSecureIdentifier:identifier withTransaction:transaction]; [SignalRecipient recipientWithTextSecureIdentifier:identifier withTransaction:transaction];
if (!recipient) { if (!recipient) {
recipient = [[SignalRecipient alloc] initWithTextSecureIdentifier:identifier recipient = [[SignalRecipient alloc] initWithTextSecureIdentifier:identifier
relay:nil relay:nil];
supportsVoice:NO
supportsWebRTC:NO];
} }
NSDictionary *attributes = [attributesForIdentifier objectForKey:identifier]; NSDictionary *attributes = [attributesForIdentifier objectForKey:identifier];
recipient.relay = attributes[@"relay"]; recipient.relay = attributes[@"relay"];
recipient.supportsVoice = [attributes[@"voice"] boolValue];
// The key for the "supports WebRTC audio/video" property is "video".
recipient.supportsWebRTC = [attributes[@"video"] boolValue];
[recipient saveWithTransaction:transaction]; [recipient saveWithTransaction:transaction];
} }

@ -1,5 +1,6 @@
// Created by Frederic Jacobs on 17/11/14. //
// Copyright (c) 2014 Open Whisper Systems. All rights reserved. // Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "TSYapDatabaseObject.h" #import "TSYapDatabaseObject.h"
@ -8,9 +9,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface SignalRecipient : TSYapDatabaseObject @interface SignalRecipient : TSYapDatabaseObject
- (instancetype)initWithTextSecureIdentifier:(NSString *)textSecureIdentifier - (instancetype)initWithTextSecureIdentifier:(NSString *)textSecureIdentifier
relay:(nullable NSString *)relay relay:(nullable NSString *)relay;
supportsVoice:(BOOL)voiceCapable
supportsWebRTC:(BOOL)supportsWebRTC;
+ (instancetype)selfRecipient; + (instancetype)selfRecipient;
+ (nullable instancetype)recipientWithTextSecureIdentifier:(NSString *)textSecureIdentifier; + (nullable instancetype)recipientWithTextSecureIdentifier:(NSString *)textSecureIdentifier;
@ -23,9 +22,10 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, nullable) NSString *relay; @property (nonatomic, nullable) NSString *relay;
@property (nonatomic, retain) NSMutableOrderedSet *devices; @property (nonatomic, retain) NSMutableOrderedSet *devices;
@property BOOL supportsVoice;
- (BOOL)supportsVoice;
// This property indicates support for both WebRTC audio and video calls. // This property indicates support for both WebRTC audio and video calls.
@property BOOL supportsWebRTC; - (BOOL)supportsWebRTC;
@end @end

@ -1,5 +1,6 @@
// Created by Frederic Jacobs on 17/11/14. //
// Copyright (c) 2014 Open Whisper Systems. All rights reserved. // Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "SignalRecipient.h" #import "SignalRecipient.h"
#import "TSStorageHeaders.h" #import "TSStorageHeaders.h"
@ -15,8 +16,6 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithTextSecureIdentifier:(NSString *)textSecureIdentifier - (instancetype)initWithTextSecureIdentifier:(NSString *)textSecureIdentifier
relay:(nullable NSString *)relay relay:(nullable NSString *)relay
supportsVoice:(BOOL)voiceCapable
supportsWebRTC:(BOOL)supportsWebRTC
{ {
self = [super initWithUniqueId:textSecureIdentifier]; self = [super initWithUniqueId:textSecureIdentifier];
if (!self) { if (!self) {
@ -25,8 +24,6 @@ NS_ASSUME_NONNULL_BEGIN
_devices = [NSMutableOrderedSet orderedSetWithObject:[NSNumber numberWithInt:1]]; _devices = [NSMutableOrderedSet orderedSetWithObject:[NSNumber numberWithInt:1]];
_relay = [relay isEqualToString:@""] ? nil : relay; _relay = [relay isEqualToString:@""] ? nil : relay;
_supportsVoice = voiceCapable;
_supportsWebRTC = supportsWebRTC;
return self; return self;
} }
@ -51,11 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
SignalRecipient *myself = [self recipientWithTextSecureIdentifier:[TSStorageManager localNumber]]; SignalRecipient *myself = [self recipientWithTextSecureIdentifier:[TSStorageManager localNumber]];
if (!myself) { if (!myself) {
myself = [[self alloc] initWithTextSecureIdentifier:[TSStorageManager localNumber] myself = [[self alloc] initWithTextSecureIdentifier:[TSStorageManager localNumber]
relay:nil relay:nil];
supportsVoice:YES
// This property may be inaccurate, but it's fine since this will only be
// sent to the current user's other devices, which will ignore this value.
supportsWebRTC:YES];
} }
return myself; return myself;
} }
@ -80,6 +73,16 @@ NS_ASSUME_NONNULL_BEGIN
} }
} }
- (BOOL)supportsVoice
{
return YES;
}
- (BOOL)supportsWebRTC
{
return YES;
}
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -38,10 +38,7 @@ NS_ASSUME_NONNULL_BEGIN
// for immediate use, then ask ContactsUpdater to try to update it async. // for immediate use, then ask ContactsUpdater to try to update it async.
recipient = recipient =
[[SignalRecipient alloc] initWithTextSecureIdentifier:contactId [[SignalRecipient alloc] initWithTextSecureIdentifier:contactId
relay:relay relay:relay];
supportsVoice:YES
// Default to NO; ContactsUpdater will try to update this property.
supportsWebRTC:NO];
[recipient saveWithTransaction:transaction]; [recipient saveWithTransaction:transaction];
// Update recipient with Server record async. // Update recipient with Server record async.

Loading…
Cancel
Save