Merge branch 'mkirk/manually-disable' into release/2.39.0

pull/2/head
Michael Kirk 6 years ago
commit 91945dbce6

@ -138,10 +138,17 @@ NS_ASSUME_NONNULL_BEGIN
@"Table header for the 'censorship circumvention' section."); @"Table header for the 'censorship circumvention' section.");
BOOL isAnySocketOpen = TSSocketManager.shared.highestSocketState == OWSWebSocketStateOpen; BOOL isAnySocketOpen = TSSocketManager.shared.highestSocketState == OWSWebSocketStateOpen;
if (OWSSignalService.sharedInstance.hasCensoredPhoneNumber) { if (OWSSignalService.sharedInstance.hasCensoredPhoneNumber) {
if (OWSSignalService.sharedInstance.isCensorshipCircumventionManuallyDisabled) {
censorshipSection.footerTitle censorshipSection.footerTitle
= NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER_AUTO_ENABLED", = NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER_MANUALLY_DISABLED",
@"Table footer for the 'censorship circumvention' section shown when censorship circumvention has "
@"been manually disabled.");
} else {
censorshipSection.footerTitle = NSLocalizedString(
@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER_AUTO_ENABLED",
@"Table footer for the 'censorship circumvention' section shown when censorship circumvention has been " @"Table footer for the 'censorship circumvention' section shown when censorship circumvention has been "
@"auto-enabled based on local phone number."); @"auto-enabled based on local phone number.");
}
} else if (isAnySocketOpen) { } else if (isAnySocketOpen) {
censorshipSection.footerTitle censorshipSection.footerTitle
= NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER_WEBSOCKET_CONNECTED", = NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER_WEBSOCKET_CONNECTED",
@ -170,20 +177,22 @@ NS_ASSUME_NONNULL_BEGIN
// censorship circumvention unnecessarily, e.g. if they just don't have a valid // censorship circumvention unnecessarily, e.g. if they just don't have a valid
// internet connection. // internet connection.
OWSTableSwitchBlock isCensorshipCircumventionOnBlock = ^{ OWSTableSwitchBlock isCensorshipCircumventionOnBlock = ^{
if (OWSSignalService.sharedInstance.hasCensoredPhoneNumber) { return OWSSignalService.sharedInstance.isCensorshipCircumventionActive;
return YES;
} else {
return OWSSignalService.sharedInstance.isCensorshipCircumventionManuallyActivated;
}
}; };
Reachability *reachability = self.reachability; Reachability *reachability = self.reachability;
OWSTableSwitchBlock isManualCensorshipCircumventionOnEnabledBlock = ^{ OWSTableSwitchBlock isManualCensorshipCircumventionOnEnabledBlock = ^{
BOOL isAnySocketOpen = TSSocketManager.shared.highestSocketState == OWSWebSocketStateOpen; OWSSignalService *service = OWSSignalService.sharedInstance;
BOOL value = (OWSSignalService.sharedInstance.isCensorshipCircumventionManuallyActivated if (service.isCensorshipCircumventionActive) {
|| (!OWSSignalService.sharedInstance.hasCensoredPhoneNumber && !isAnySocketOpen return YES;
&& reachability.isReachable)); } else if (service.hasCensoredPhoneNumber && service.isCensorshipCircumventionManuallyDisabled) {
return value; return YES;
} else if (TSSocketManager.shared.highestSocketState == OWSWebSocketStateOpen) {
return NO;
} else {
return reachability.isReachable;
}
}; };
[censorshipSection [censorshipSection
addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION", addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION",
@"Label for the 'manual censorship circumvention' switch.") @"Label for the 'manual censorship circumvention' switch.")
@ -286,7 +295,14 @@ NS_ASSUME_NONNULL_BEGIN
- (void)didToggleEnableCensorshipCircumventionSwitch:(UISwitch *)sender - (void)didToggleEnableCensorshipCircumventionSwitch:(UISwitch *)sender
{ {
OWSSignalService.sharedInstance.isCensorshipCircumventionManuallyActivated = sender.isOn; OWSSignalService *service = OWSSignalService.sharedInstance;
if (sender.isOn) {
service.isCensorshipCircumventionManuallyDisabled = NO;
service.isCensorshipCircumventionManuallyActivated = YES;
} else {
service.isCensorshipCircumventionManuallyDisabled = YES;
service.isCensorshipCircumventionManuallyActivated = NO;
}
[self updateTableContents]; [self updateTableContents];
} }

@ -2033,6 +2033,9 @@
/* Table footer for the 'censorship circumvention' section shown when censorship circumvention has been auto-enabled based on local phone number. */ /* Table footer for the 'censorship circumvention' section shown when censorship circumvention has been auto-enabled based on local phone number. */
"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER_AUTO_ENABLED" = "Censorship circumvention has been activated based on your account's phone number."; "SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER_AUTO_ENABLED" = "Censorship circumvention has been activated based on your account's phone number.";
/* Table footer for the 'censorship circumvention' section shown when censorship circumvention has been manually disabled. */
"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER_MANUALLY_DISABLED" = "You have manually disabled censorship circumvention.";
/* Table footer for the 'censorship circumvention' section shown when the app is not connected to the internet. */ /* Table footer for the 'censorship circumvention' section shown when the app is not connected to the internet. */
"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER_NO_CONNECTION" = "Censorship circumvention can only be activated when connected to the internet."; "SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER_NO_CONNECTION" = "Censorship circumvention can only be activated when connected to the internet.";
@ -2390,9 +2393,6 @@
/* Pressing this button moves an archived thread from the archive back to the inbox */ /* Pressing this button moves an archived thread from the archive back to the inbox */
"UNARCHIVE_ACTION" = "Unarchive"; "UNARCHIVE_ACTION" = "Unarchive";
/* In Inbox view, last message label for thread with corrupted attachment. */
"UNKNOWN_ATTACHMENT_LABEL" = "Unknown attachment";
/* Message shown in conversation view that offers to block an unknown user. */ /* Message shown in conversation view that offers to block an unknown user. */
"UNKNOWN_CONTACT_BLOCK_OFFER" = "User not in your contacts. Would you like to block this user?"; "UNKNOWN_CONTACT_BLOCK_OFFER" = "User not in your contacts. Would you like to block this user?";

@ -1,5 +1,5 @@
// //
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// //
#import "OWSReadReceiptManager.h" #import "OWSReadReceiptManager.h"
@ -524,22 +524,9 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
{ {
// We don't need to worry about races around this cached value. // We don't need to worry about races around this cached value.
if (!self.areReadReceiptsEnabledCached) { if (!self.areReadReceiptsEnabledCached) {
// Default to NO.
self.areReadReceiptsEnabledCached = @([self.dbConnection boolForKey:OWSReadReceiptManagerAreReadReceiptsEnabled self.areReadReceiptsEnabledCached = @([self.dbConnection boolForKey:OWSReadReceiptManagerAreReadReceiptsEnabled
inCollection:OWSReadReceiptManagerCollection]); inCollection:OWSReadReceiptManagerCollection
} defaultValue:NO]);
return [self.areReadReceiptsEnabledCached boolValue];
}
- (BOOL)areReadReceiptsEnabledWithTransaction:(YapDatabaseReadTransaction *)transaction
{
if (!self.areReadReceiptsEnabledCached) {
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
// Default to NO.
self.areReadReceiptsEnabledCached = [transaction objectForKey:OWSReadReceiptManagerAreReadReceiptsEnabled
inCollection:OWSReadReceiptManagerCollection];
}];
} }
return [self.areReadReceiptsEnabledCached boolValue]; return [self.areReadReceiptsEnabledCached boolValue];

@ -19,6 +19,7 @@ extern NSString *const OWSFrontingHost_GoogleQatar;
// returns best censorship configuration for country code. Will return a default if one hasn't // returns best censorship configuration for country code. Will return a default if one hasn't
// been specifically configured. // been specifically configured.
+ (instancetype)censorshipConfigurationWithCountryCode:(NSString *)countryCode; + (instancetype)censorshipConfigurationWithCountryCode:(NSString *)countryCode;
+ (instancetype)defaultConfiguration;
+ (BOOL)isCensoredPhoneNumber:(NSString *)e164PhoneNumber; + (BOOL)isCensoredPhoneNumber:(NSString *)e164PhoneNumber;

@ -38,22 +38,27 @@ NSString *const OWSFrontingHost_Default = @"www.google.com";
OWSAssertDebug(countryMetadadata); OWSAssertDebug(countryMetadadata);
NSString *_Nullable specifiedDomain = countryMetadadata.frontingDomain; NSString *_Nullable specifiedDomain = countryMetadadata.frontingDomain;
if (specifiedDomain.length == 0) {
return self.defaultConfiguration;
}
NSURL *baseURL;
AFSecurityPolicy *securityPolicy;
if (specifiedDomain.length > 0) {
NSString *frontingURLString = [NSString stringWithFormat:@"https://%@", specifiedDomain]; NSString *frontingURLString = [NSString stringWithFormat:@"https://%@", specifiedDomain];
baseURL = [NSURL URLWithString:frontingURLString]; NSURL *_Nullable baseURL = [NSURL URLWithString:frontingURLString];
securityPolicy = [self securityPolicyForDomain:(NSString *)specifiedDomain]; if (baseURL == nil) {
} else { OWSFailDebug(@"baseURL was unexpectedly nil with specifiedDomain: %@", specifiedDomain);
NSString *frontingURLString = [NSString stringWithFormat:@"https://%@", OWSFrontingHost_Default]; return self.defaultConfiguration;
baseURL = [NSURL URLWithString:frontingURLString];
securityPolicy = [self securityPolicyForDomain:OWSFrontingHost_Default];
} }
AFSecurityPolicy *securityPolicy = [self securityPolicyForDomain:specifiedDomain];
OWSAssertDebug(baseURL);
OWSAssertDebug(securityPolicy); OWSAssertDebug(securityPolicy);
return [[OWSCensorshipConfiguration alloc] initWithDomainFrontBaseURL:baseURL securityPolicy:securityPolicy];
}
+ (instancetype)defaultConfiguration
{
NSString *frontingURLString = [NSString stringWithFormat:@"https://%@", OWSFrontingHost_Default];
NSURL *baseURL = [NSURL URLWithString:frontingURLString];
AFSecurityPolicy *securityPolicy = [self securityPolicyForDomain:OWSFrontingHost_Default];
return [[OWSCensorshipConfiguration alloc] initWithDomainFrontBaseURL:baseURL securityPolicy:securityPolicy]; return [[OWSCensorshipConfiguration alloc] initWithDomainFrontBaseURL:baseURL securityPolicy:securityPolicy];
} }
@ -107,7 +112,6 @@ NSString *const OWSFrontingHost_Default = @"www.google.com";
}; };
} }
// Returns nil if the phone number is not known to be censored
+ (BOOL)isCensoredPhoneNumber:(NSString *)e164PhoneNumber; + (BOOL)isCensoredPhoneNumber:(NSString *)e164PhoneNumber;
{ {
return [self censoredCountryCodeWithPhoneNumber:e164PhoneNumber].length > 0; return [self censoredCountryCodeWithPhoneNumber:e164PhoneNumber].length > 0;

@ -24,6 +24,7 @@ extern NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidCha
@property (atomic, readonly) BOOL isCensorshipCircumventionActive; @property (atomic, readonly) BOOL isCensorshipCircumventionActive;
@property (atomic, readonly) BOOL hasCensoredPhoneNumber; @property (atomic, readonly) BOOL hasCensoredPhoneNumber;
@property (atomic) BOOL isCensorshipCircumventionManuallyActivated; @property (atomic) BOOL isCensorshipCircumventionManuallyActivated;
@property (atomic) BOOL isCensorshipCircumventionManuallyDisabled;
@property (atomic, nullable) NSString *manualCensorshipCircumventionCountryCode; @property (atomic, nullable) NSString *manualCensorshipCircumventionCountryCode;
/// For interacting with the Signal Service /// For interacting with the Signal Service

@ -18,6 +18,8 @@ NS_ASSUME_NONNULL_BEGIN
NSString *const kOWSPrimaryStorage_OWSSignalService = @"kTSStorageManager_OWSSignalService"; NSString *const kOWSPrimaryStorage_OWSSignalService = @"kTSStorageManager_OWSSignalService";
NSString *const kOWSPrimaryStorage_isCensorshipCircumventionManuallyActivated NSString *const kOWSPrimaryStorage_isCensorshipCircumventionManuallyActivated
= @"kTSStorageManager_isCensorshipCircumventionManuallyActivated"; = @"kTSStorageManager_isCensorshipCircumventionManuallyActivated";
NSString *const kOWSPrimaryStorage_isCensorshipCircumventionManuallyDisabled
= @"kTSStorageManager_isCensorshipCircumventionManuallyDisabled";
NSString *const kOWSPrimaryStorage_ManualCensorshipCircumventionDomain NSString *const kOWSPrimaryStorage_ManualCensorshipCircumventionDomain
= @"kTSStorageManager_ManualCensorshipCircumventionDomain"; = @"kTSStorageManager_ManualCensorshipCircumventionDomain";
NSString *const kOWSPrimaryStorage_ManualCensorshipCircumventionCountryCode NSString *const kOWSPrimaryStorage_ManualCensorshipCircumventionCountryCode
@ -28,8 +30,6 @@ NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidChange =
@interface OWSSignalService () @interface OWSSignalService ()
@property (nonatomic, nullable, readonly) OWSCensorshipConfiguration *censorshipConfiguration;
@property (atomic) BOOL hasCensoredPhoneNumber; @property (atomic) BOOL hasCensoredPhoneNumber;
@property (atomic) BOOL isCensorshipCircumventionActive; @property (atomic) BOOL isCensorshipCircumventionActive;
@ -104,7 +104,8 @@ NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidChange =
{ {
return return
[[OWSPrimaryStorage dbReadConnection] boolForKey:kOWSPrimaryStorage_isCensorshipCircumventionManuallyActivated [[OWSPrimaryStorage dbReadConnection] boolForKey:kOWSPrimaryStorage_isCensorshipCircumventionManuallyActivated
inCollection:kOWSPrimaryStorage_OWSSignalService]; inCollection:kOWSPrimaryStorage_OWSSignalService
defaultValue:NO];
} }
- (void)setIsCensorshipCircumventionManuallyActivated:(BOOL)value - (void)setIsCensorshipCircumventionManuallyActivated:(BOOL)value
@ -116,10 +117,34 @@ NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidChange =
[self updateIsCensorshipCircumventionActive]; [self updateIsCensorshipCircumventionActive];
} }
- (BOOL)isCensorshipCircumventionManuallyDisabled
{
return [[OWSPrimaryStorage dbReadConnection] boolForKey:kOWSPrimaryStorage_isCensorshipCircumventionManuallyDisabled
inCollection:kOWSPrimaryStorage_OWSSignalService
defaultValue:NO];
}
- (void)setIsCensorshipCircumventionManuallyDisabled:(BOOL)value
{
[[OWSPrimaryStorage dbReadWriteConnection] setObject:@(value)
forKey:kOWSPrimaryStorage_isCensorshipCircumventionManuallyDisabled
inCollection:kOWSPrimaryStorage_OWSSignalService];
[self updateIsCensorshipCircumventionActive];
}
- (void)updateIsCensorshipCircumventionActive - (void)updateIsCensorshipCircumventionActive
{ {
self.isCensorshipCircumventionActive if (self.isCensorshipCircumventionManuallyDisabled) {
= (self.isCensorshipCircumventionManuallyActivated || self.hasCensoredPhoneNumber); self.isCensorshipCircumventionActive = NO;
} else if (self.isCensorshipCircumventionManuallyActivated) {
self.isCensorshipCircumventionActive = YES;
} else if (self.hasCensoredPhoneNumber) {
self.isCensorshipCircumventionActive = YES;
} else {
self.isCensorshipCircumventionActive = NO;
}
} }
- (void)setIsCensorshipCircumventionActive:(BOOL)isCensorshipCircumventionActive - (void)setIsCensorshipCircumventionActive:(BOOL)isCensorshipCircumventionActive
@ -150,8 +175,9 @@ NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidChange =
- (AFHTTPSessionManager *)buildSignalServiceSessionManager - (AFHTTPSessionManager *)buildSignalServiceSessionManager
{ {
if (self.isCensorshipCircumventionActive) { if (self.isCensorshipCircumventionActive) {
OWSLogInfo(@"using reflector HTTPSessionManager via: %@", self.censorshipConfiguration.domainFrontBaseURL); OWSCensorshipConfiguration *censorshipConfiguration = [self buildCensorshipConfiguration];
return self.reflectorSignalServiceSessionManager; OWSLogInfo(@"using reflector HTTPSessionManager via: %@", censorshipConfiguration.domainFrontBaseURL);
return [self reflectorSignalServiceSessionManagerWithCensorshipConfiguration:censorshipConfiguration];
} else { } else {
return self.defaultSignalServiceSessionManager; return self.defaultSignalServiceSessionManager;
} }
@ -174,10 +200,9 @@ NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidChange =
return sessionManager; return sessionManager;
} }
- (AFHTTPSessionManager *)reflectorSignalServiceSessionManager - (AFHTTPSessionManager *)reflectorSignalServiceSessionManagerWithCensorshipConfiguration:
(OWSCensorshipConfiguration *)censorshipConfiguration
{ {
OWSCensorshipConfiguration *censorshipConfiguration = self.censorshipConfiguration;
NSURLSessionConfiguration *sessionConf = NSURLSessionConfiguration.ephemeralSessionConfiguration; NSURLSessionConfiguration *sessionConf = NSURLSessionConfiguration.ephemeralSessionConfiguration;
AFHTTPSessionManager *sessionManager = AFHTTPSessionManager *sessionManager =
[[AFHTTPSessionManager alloc] initWithBaseURL:censorshipConfiguration.domainFrontBaseURL [[AFHTTPSessionManager alloc] initWithBaseURL:censorshipConfiguration.domainFrontBaseURL
@ -186,7 +211,8 @@ NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidChange =
sessionManager.securityPolicy = censorshipConfiguration.domainFrontSecurityPolicy; sessionManager.securityPolicy = censorshipConfiguration.domainFrontSecurityPolicy;
sessionManager.requestSerializer = [AFJSONRequestSerializer serializer]; sessionManager.requestSerializer = [AFJSONRequestSerializer serializer];
[sessionManager.requestSerializer setValue:self.censorshipConfiguration.signalServiceReflectorHost forHTTPHeaderField:@"Host"]; [sessionManager.requestSerializer setValue:censorshipConfiguration.signalServiceReflectorHost
forHTTPHeaderField:@"Host"];
sessionManager.responseSerializer = [AFJSONResponseSerializer serializer]; sessionManager.responseSerializer = [AFJSONResponseSerializer serializer];
// Disable default cookie handling for all requests. // Disable default cookie handling for all requests.
sessionManager.requestSerializer.HTTPShouldHandleCookies = NO; sessionManager.requestSerializer.HTTPShouldHandleCookies = NO;
@ -199,8 +225,9 @@ NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidChange =
- (AFHTTPSessionManager *)CDNSessionManager - (AFHTTPSessionManager *)CDNSessionManager
{ {
if (self.isCensorshipCircumventionActive) { if (self.isCensorshipCircumventionActive) {
OWSLogInfo(@"using reflector CDNSessionManager via: %@", self.censorshipConfiguration.domainFrontBaseURL); OWSCensorshipConfiguration *censorshipConfiguration = [self buildCensorshipConfiguration];
return self.reflectorCDNSessionManager; OWSLogInfo(@"using reflector CDNSessionManager via: %@", censorshipConfiguration.domainFrontBaseURL);
return [self reflectorCDNSessionManagerWithCensorshipConfiguration:censorshipConfiguration];
} else { } else {
return self.defaultCDNSessionManager; return self.defaultCDNSessionManager;
} }
@ -223,12 +250,11 @@ NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidChange =
return sessionManager; return sessionManager;
} }
- (AFHTTPSessionManager *)reflectorCDNSessionManager - (AFHTTPSessionManager *)reflectorCDNSessionManagerWithCensorshipConfiguration:
(OWSCensorshipConfiguration *)censorshipConfiguration
{ {
NSURLSessionConfiguration *sessionConf = NSURLSessionConfiguration.ephemeralSessionConfiguration; NSURLSessionConfiguration *sessionConf = NSURLSessionConfiguration.ephemeralSessionConfiguration;
OWSCensorshipConfiguration *censorshipConfiguration = self.censorshipConfiguration;
AFHTTPSessionManager *sessionManager = AFHTTPSessionManager *sessionManager =
[[AFHTTPSessionManager alloc] initWithBaseURL:censorshipConfiguration.domainFrontBaseURL [[AFHTTPSessionManager alloc] initWithBaseURL:censorshipConfiguration.domainFrontBaseURL
sessionConfiguration:sessionConf]; sessionConfiguration:sessionConf];
@ -257,8 +283,10 @@ NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidChange =
#pragma mark - Manual Censorship Circumvention #pragma mark - Manual Censorship Circumvention
- (nullable OWSCensorshipConfiguration *)censorshipConfiguration - (OWSCensorshipConfiguration *)buildCensorshipConfiguration
{ {
OWSAssertDebug(self.isCensorshipCircumventionActive);
if (self.isCensorshipCircumventionManuallyActivated) { if (self.isCensorshipCircumventionManuallyActivated) {
NSString *countryCode = self.manualCensorshipCircumventionCountryCode; NSString *countryCode = self.manualCensorshipCircumventionCountryCode;
if (countryCode.length == 0) { if (countryCode.length == 0) {
@ -272,11 +300,15 @@ NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidChange =
return configuration; return configuration;
} }
OWSCensorshipConfiguration *configuration = OWSCensorshipConfiguration *_Nullable configuration =
[OWSCensorshipConfiguration censorshipConfigurationWithPhoneNumber:TSAccountManager.localNumber]; [OWSCensorshipConfiguration censorshipConfigurationWithPhoneNumber:TSAccountManager.localNumber];
if (configuration != nil) {
return configuration; return configuration;
} }
return OWSCensorshipConfiguration.defaultConfiguration;
}
- (nullable NSString *)manualCensorshipCircumventionCountryCode - (nullable NSString *)manualCensorshipCircumventionCountryCode
{ {
return return

@ -1,5 +1,5 @@
// //
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// //
#import <YapDatabase/YapDatabaseConnection.h> #import <YapDatabase/YapDatabaseConnection.h>
@ -13,7 +13,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface YapDatabaseConnection (OWS) @interface YapDatabaseConnection (OWS)
- (BOOL)hasObjectForKey:(NSString *)key inCollection:(NSString *)collection; - (BOOL)hasObjectForKey:(NSString *)key inCollection:(NSString *)collection;
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection;
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection defaultValue:(BOOL)defaultValue; - (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection defaultValue:(BOOL)defaultValue;
- (double)doubleForKey:(NSString *)key inCollection:(NSString *)collection defaultValue:(double)defaultValue; - (double)doubleForKey:(NSString *)key inCollection:(NSString *)collection defaultValue:(double)defaultValue;
- (int)intForKey:(NSString *)key inCollection:(NSString *)collection; - (int)intForKey:(NSString *)key inCollection:(NSString *)collection;

@ -51,11 +51,6 @@ NS_ASSUME_NONNULL_BEGIN
return [self objectForKey:key inCollection:collection ofExpectedType:[NSString class]]; return [self objectForKey:key inCollection:collection ofExpectedType:[NSString class]];
} }
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection
{
return [self boolForKey:key inCollection:collection defaultValue:NO];
}
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection defaultValue:(BOOL)defaultValue - (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection defaultValue:(BOOL)defaultValue
{ {
NSNumber *_Nullable value = [self objectForKey:key inCollection:collection ofExpectedType:[NSNumber class]]; NSNumber *_Nullable value = [self objectForKey:key inCollection:collection ofExpectedType:[NSNumber class]];

@ -12,7 +12,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface YapDatabaseReadTransaction (OWS) @interface YapDatabaseReadTransaction (OWS)
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection;
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection defaultValue:(BOOL)defaultValue; - (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection defaultValue:(BOOL)defaultValue;
- (int)intForKey:(NSString *)key inCollection:(NSString *)collection; - (int)intForKey:(NSString *)key inCollection:(NSString *)collection;
- (nullable NSDate *)dateForKey:(NSString *)key inCollection:(NSString *)collection; - (nullable NSDate *)dateForKey:(NSString *)key inCollection:(NSString *)collection;

@ -36,14 +36,6 @@ NS_ASSUME_NONNULL_BEGIN
return [self objectForKey:key inCollection:collection ofExpectedType:[NSString class]]; return [self objectForKey:key inCollection:collection ofExpectedType:[NSString class]];
} }
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection
{
OWSAssertDebug(key.length > 0);
OWSAssertDebug(collection.length > 0);
return [self boolForKey:key inCollection:collection defaultValue:NO];
}
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection defaultValue:(BOOL)defaultValue - (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection defaultValue:(BOOL)defaultValue
{ {
OWSAssertDebug(key.length > 0); OWSAssertDebug(key.length > 0);

Loading…
Cancel
Save