Respond to CR.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-09-19 17:45:18 -04:00
parent bd360262cb
commit 183f0f1ccd
35 changed files with 12 additions and 464 deletions

View file

@ -256,7 +256,6 @@
76EB058218170B33006006FC /* Environment.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB041318170B33006006FC /* Environment.m */; };
76EB058818170B33006006FC /* OWSPreferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB041918170B33006006FC /* OWSPreferences.m */; };
76EB058A18170B33006006FC /* Release.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB041B18170B33006006FC /* Release.m */; };
76EB062618170B33006006FC /* Queue.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB04D518170B33006006FC /* Queue.m */; };
76EB063A18170B33006006FC /* FunctionalUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB04EB18170B33006006FC /* FunctionalUtil.m */; };
76EB063C18170B33006006FC /* NumberUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB04ED18170B33006006FC /* NumberUtil.m */; };
76EB063E18170B33006006FC /* Operation.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB04EF18170B33006006FC /* Operation.m */; };
@ -309,7 +308,6 @@
B660F6D81C29868000687D6E /* CryptoToolsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B660F6A71C29868000687D6E /* CryptoToolsTest.m */; };
B660F6DA1C29868000687D6E /* ExceptionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B660F6AB1C29868000687D6E /* ExceptionsTest.m */; };
B660F6DB1C29868000687D6E /* FunctionalUtilTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B660F6AD1C29868000687D6E /* FunctionalUtilTest.m */; };
B660F6DD1C29868000687D6E /* ObservableTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B660F6AF1C29868000687D6E /* ObservableTest.m */; };
B660F6DF1C29868000687D6E /* QueueTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B660F6B21C29868000687D6E /* QueueTest.m */; };
B660F6E01C29868000687D6E /* UtilTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B660F6B41C29868000687D6E /* UtilTest.m */; };
B660F7171C29988E00687D6E /* OWSContactsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB040918170B33006006FC /* OWSContactsManager.m */; };
@ -327,11 +325,9 @@
B660F7751C29988E00687D6E /* UIColor+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = FCFA64B31A24F3880007FB87 /* UIColor+OWS.m */; };
B660F7761C29988E00687D6E /* UIFont+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = FCFA64B61A24F6730007FB87 /* UIFont+OWS.m */; };
B660F7771C29988E00687D6E /* UIImage+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = B68112E91A4D9EC400BA82FF /* UIImage+OWS.m */; };
B660F77B1C29988E00687D6E /* Queue.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB04D518170B33006006FC /* Queue.m */; };
B660F77F1C29988E00687D6E /* DateUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = B90418E5183E9DD40038554A /* DateUtil.m */; };
B660F7811C29988E00687D6E /* FunctionalUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB04EB18170B33006006FC /* FunctionalUtil.m */; };
B660F7831C29988E00687D6E /* NumberUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB04ED18170B33006006FC /* NumberUtil.m */; };
B660F7841C29988E00687D6E /* ObservableValue.m in Sources */ = {isa = PBXBuildFile; fileRef = BFB074C619A5611000F2947C /* ObservableValue.m */; };
B660F7871C29988E00687D6E /* StringUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB04F618170B33006006FC /* StringUtil.m */; };
B660F78A1C29988E00687D6E /* UIUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = B97940261832BD2400BD66CB /* UIUtil.m */; };
B660F78C1C29988E00687D6E /* UIDevice+TSHardwareVersion.m in Sources */ = {isa = PBXBuildFile; fileRef = FCC81A971A44558300DFEC7D /* UIDevice+TSHardwareVersion.m */; };
@ -353,7 +349,6 @@
B90418E6183E9DD40038554A /* DateUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = B90418E5183E9DD40038554A /* DateUtil.m */; };
B97940271832BD2400BD66CB /* UIUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = B97940261832BD2400BD66CB /* UIUtil.m */; };
B9EB5ABD1884C002007CBB57 /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9EB5ABC1884C002007CBB57 /* MessageUI.framework */; };
BFB074C919A5611000F2947C /* ObservableValue.m in Sources */ = {isa = PBXBuildFile; fileRef = BFB074C619A5611000F2947C /* ObservableValue.m */; };
D202868116DBE0E7009068E9 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AEACDB16C426DA00C364C0 /* CFNetwork.framework */; };
D202868216DBE0F4009068E9 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2179CFD16BB0B480006F3AB /* SystemConfiguration.framework */; };
D202868316DBE0FC009068E9 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2179CFB16BB0B3A0006F3AB /* CoreTelephony.framework */; };
@ -726,8 +721,6 @@
76EB041918170B33006006FC /* OWSPreferences.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSPreferences.m; sourceTree = "<group>"; };
76EB041A18170B33006006FC /* Release.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Release.h; sourceTree = "<group>"; };
76EB041B18170B33006006FC /* Release.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Release.m; sourceTree = "<group>"; };
76EB04D418170B33006006FC /* Queue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Queue.h; sourceTree = "<group>"; };
76EB04D518170B33006006FC /* Queue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Queue.m; sourceTree = "<group>"; };
76EB04EA18170B33006006FC /* FunctionalUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FunctionalUtil.h; sourceTree = "<group>"; };
76EB04EB18170B33006006FC /* FunctionalUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FunctionalUtil.m; sourceTree = "<group>"; };
76EB04EC18170B33006006FC /* NumberUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NumberUtil.h; sourceTree = "<group>"; };
@ -803,7 +796,6 @@
B660F6AB1C29868000687D6E /* ExceptionsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExceptionsTest.m; sourceTree = "<group>"; };
B660F6AC1C29868000687D6E /* FunctionalUtilTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FunctionalUtilTest.h; sourceTree = "<group>"; };
B660F6AD1C29868000687D6E /* FunctionalUtilTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FunctionalUtilTest.m; sourceTree = "<group>"; };
B660F6AF1C29868000687D6E /* ObservableTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObservableTest.m; sourceTree = "<group>"; };
B660F6B11C29868000687D6E /* QueueTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QueueTest.h; sourceTree = "<group>"; };
B660F6B21C29868000687D6E /* QueueTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QueueTest.m; sourceTree = "<group>"; };
B660F6B31C29868000687D6E /* UtilTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UtilTest.h; sourceTree = "<group>"; };
@ -859,8 +851,6 @@
B97940251832BD2400BD66CB /* UIUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIUtil.h; sourceTree = "<group>"; };
B97940261832BD2400BD66CB /* UIUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIUtil.m; sourceTree = "<group>"; };
B9EB5ABC1884C002007CBB57 /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; };
BFB074C519A5611000F2947C /* ObservableValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObservableValue.h; sourceTree = "<group>"; };
BFB074C619A5611000F2947C /* ObservableValue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObservableValue.m; sourceTree = "<group>"; };
D2179CFB16BB0B3A0006F3AB /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; };
D2179CFD16BB0B480006F3AB /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
D221A089169C9E5E00537ABF /* Signal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Signal.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -1427,7 +1417,6 @@
B6DA6B061B8A2F9A00CA6F98 /* AppStoreRating.m */,
34CCAF361F0C0599004084F4 /* AppUpdateNag.h */,
34CCAF371F0C0599004084F4 /* AppUpdateNag.m */,
76EB04CF18170B33006006FC /* collections */,
B90418E4183E9DD40038554A /* DateUtil.h */,
B90418E5183E9DD40038554A /* DateUtil.m */,
348F2EAD1F0D21BC00D4ECE0 /* DeviceSleepManager.swift */,
@ -1439,8 +1428,6 @@
B62F5E0F1C2980B4000D370C /* NSData+ows_StripToken.m */,
76EB04EC18170B33006006FC /* NumberUtil.h */,
76EB04ED18170B33006006FC /* NumberUtil.m */,
BFB074C519A5611000F2947C /* ObservableValue.h */,
BFB074C619A5611000F2947C /* ObservableValue.m */,
76EB04EE18170B33006006FC /* Operation.h */,
76EB04EF18170B33006006FC /* Operation.m */,
34D99C911F2937CC00D284D6 /* OWSAnalytics.swift */,
@ -1473,15 +1460,6 @@
path = util;
sourceTree = "<group>";
};
76EB04CF18170B33006006FC /* collections */ = {
isa = PBXGroup;
children = (
76EB04D418170B33006006FC /* Queue.h */,
76EB04D518170B33006006FC /* Queue.m */,
);
path = collections;
sourceTree = "<group>";
};
76EB052B18170B33006006FC /* Views */ = {
isa = PBXGroup;
children = (
@ -1665,7 +1643,6 @@
B660F6AB1C29868000687D6E /* ExceptionsTest.m */,
B660F6AC1C29868000687D6E /* FunctionalUtilTest.h */,
B660F6AD1C29868000687D6E /* FunctionalUtilTest.m */,
B660F6AF1C29868000687D6E /* ObservableTest.m */,
B660F6B11C29868000687D6E /* QueueTest.h */,
B660F6B21C29868000687D6E /* QueueTest.m */,
B660F6B31C29868000687D6E /* UtilTest.h */,
@ -2285,7 +2262,6 @@
342FCE6B1EF9C375002690AD /* OWS105AttachmentFilePaths.m in Sources */,
45BFFFA81D898AF0004A12A7 /* OWSStaleNotificationObserver.m in Sources */,
45C681B71D305A580050903A /* OWSCall.m in Sources */,
76EB062618170B33006006FC /* Queue.m in Sources */,
D221A09A169C9E5E00537ABF /* main.m in Sources */,
345671011E89A5F1006EE662 /* ThreadUtil.m in Sources */,
4585C4601ED4FD0400896AEA /* OWS104CreateRecipientIdentities.m in Sources */,
@ -2381,7 +2357,6 @@
34B3F89C1E8DF3270035BE1A /* BlockListViewController.m in Sources */,
45F2B1941D9C9F48000D2C69 /* OWSOutgoingMessageCollectionViewCell.m in Sources */,
34C42D5B1F45F7A80072EC04 /* OWSNavigationController.m in Sources */,
BFB074C919A5611000F2947C /* ObservableValue.m in Sources */,
B68EF9BA1C0B1EBD009C3DCD /* FLAnimatedImage.m in Sources */,
B68112EA1A4D9EC400BA82FF /* UIImage+OWS.m in Sources */,
B609597C1C2C0FC6004E8797 /* iRate.m in Sources */,
@ -2476,14 +2451,12 @@
B660F7761C29988E00687D6E /* UIFont+OWS.m in Sources */,
B660F7771C29988E00687D6E /* UIImage+OWS.m in Sources */,
954AEE6A1DF33E01002E5410 /* ContactsPickerTest.swift in Sources */,
B660F77B1C29988E00687D6E /* Queue.m in Sources */,
455AC69C1F4F79E500134004 /* ImageCache.swift in Sources */,
4556FA691F54AA9500AF40DD /* DebugUIProfile.swift in Sources */,
45666F581D9B2880008FE134 /* OWSScrubbingLogFormatterTest.m in Sources */,
B660F77F1C29988E00687D6E /* DateUtil.m in Sources */,
B660F7811C29988E00687D6E /* FunctionalUtil.m in Sources */,
B660F7831C29988E00687D6E /* NumberUtil.m in Sources */,
B660F7841C29988E00687D6E /* ObservableValue.m in Sources */,
B660F7871C29988E00687D6E /* StringUtil.m in Sources */,
45FBC5C91DF8575700E9B410 /* CallKitCallManager.swift in Sources */,
B660F78A1C29988E00687D6E /* UIUtil.m in Sources */,
@ -2504,7 +2477,6 @@
B660F6DF1C29868000687D6E /* QueueTest.m in Sources */,
B660F6BB1C29868000687D6E /* OWSContactsManagerTest.m in Sources */,
45A6DAD71EBBF85500893231 /* ReminderView.swift in Sources */,
B660F6DD1C29868000687D6E /* ObservableTest.m in Sources */,
B660F6D21C29868000687D6E /* PushManagerTest.m in Sources */,
45C0DC1F1E69011F00E04C47 /* UIStoryboard+OWS.swift in Sources */,
4505C2C01E648EA300CEBF41 /* ExperienceUpgrade.swift in Sources */,

View file

@ -2,8 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
@class TSAttachmentStream;
@interface AttachmentSharing : NSObject

View file

@ -1,12 +1,6 @@
//
// LockInteractionController.h
// Signal
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
// Created by Frederic Jacobs on 22/08/15.
// Copyright (c) 2015 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface LockInteractionController : NSObject

View file

@ -1,12 +1,6 @@
//
// DebugLogger.h
// Signal
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
// Created by Frederic Jacobs on 08/08/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CocoaLumberjack/DDFileLogger.h>

View file

@ -5,7 +5,6 @@
#import "OWSPreferences.h"
#import "TSGroupModel.h"
#import "TSStorageHeaders.h"
#import <Foundation/Foundation.h>
/**
*

View file

@ -2,7 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Environment.h"
@interface Release : NSObject

View file

@ -2,7 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "PhoneNumber.h"
#define LOCAL_NUMBER_KEY @"Number"

View file

@ -2,8 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#define RECENT_CALLS_DEFAULT_KEY @"RPRecentCallsDefaultKey"
@interface VersionMigrations : NSObject

View file

@ -1,12 +1,6 @@
//
// AppStoreRating.h
// Signal
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
// Created by Frederic Jacobs on 23/08/15.
// Copyright (c) 2015 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface AppStoreRating : NSObject

View file

@ -1,4 +1,6 @@
#import <Foundation/Foundation.h>
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
@interface DateUtil : NSObject

View file

@ -1,4 +1,6 @@
#import <Foundation/Foundation.h>
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
@interface NSArray (FunctionalUtil)

View file

@ -1,12 +1,6 @@
//
// NSData+ows_StripToken.h
// Signal
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
// Created by Frederic Jacobs on 14/04/15.
// Copyright (c) 2015 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSData (ows_StripToken)

View file

@ -2,8 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSString (OWS)
- (NSString *)ows_stripped;

View file

@ -2,7 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "StringUtil.h"
@interface NumberUtil : NSObject

View file

@ -1,42 +0,0 @@
#import <Foundation/Foundation.h>
#import "CollapsingFutures.h"
#import "Queue.h"
typedef void (^LatestValueCallback)(id latestValue);
/**
*
* An ObservableValue represents an asynchronous stream of values, such as 'latest state of toggle' or 'latest sensor
* reading'.
*
*/
@interface ObservableValue : NSObject {
@protected
NSMutableSet *callbacks;
@private
Queue *queuedActionsToRun;
@private
bool isRunningActions;
@protected
bool sealed;
}
@property (readonly, atomic) id currentValue;
- (void)watchLatestValueOnArbitraryThread:(LatestValueCallback)callback
untilCancelled:(TOCCancelToken *)untilCancelledToken;
- (void)watchLatestValue:(LatestValueCallback)callback
onThread:(NSThread *)thread
untilCancelled:(TOCCancelToken *)untilCancelledToken;
@end
@interface ObservableValueController : ObservableValue
+ (ObservableValueController *)observableValueControllerWithInitialValue:(id)value;
- (void)updateValue:(id)value;
- (void)adjustValue:(id (^)(id))adjustment;
- (void)sealValue;
@end

View file

@ -1,136 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "Environment.h"
#import "ObservableValue.h"
#import "Util.h"
@implementation ObservableValue
@synthesize currentValue;
- (ObservableValue *)initWithValue:(id)value {
callbacks = [NSMutableSet set];
queuedActionsToRun = [Queue new];
currentValue = value;
return self;
}
- (void)watchLatestValueOnArbitraryThread:(LatestValueCallback)callback
untilCancelled:(TOCCancelToken *)untilCancelledToken {
ows_require(callback != nil);
if (untilCancelledToken.isAlreadyCancelled)
return;
void (^callbackCopy)(id value) = [callback copy];
[self queueRun:^{
callbackCopy(self.currentValue);
[callbacks addObject:callbackCopy];
}];
[untilCancelledToken whenCancelledDo:^{
[self queueRun:^{
[callbacks removeObject:callbackCopy];
}];
}];
}
- (void)watchLatestValue:(LatestValueCallback)callback
onThread:(NSThread *)thread
untilCancelled:(TOCCancelToken *)untilCancelledToken {
ows_require(callback != nil);
ows_require(thread != nil);
void (^callbackCopy)(id value) = [callback copy];
void (^threadedCallback)(id value) = ^(id value) {
[Operation asyncRun:^{
callbackCopy(value);
}
onThread:thread];
};
[self watchLatestValueOnArbitraryThread:threadedCallback untilCancelled:untilCancelledToken];
}
/// used for avoiding re-entrancy issues (e.g. a callback registering another callback during enumeration)
- (void)queueRun:(void (^)())action {
@synchronized(self) {
if (isRunningActions) {
[queuedActionsToRun enqueue:[action copy]];
return;
}
isRunningActions = true;
}
while (true) {
@try {
action();
} @catch (id ex) {
DDLogError(@"A queued action failed and may have stalled an ObservableValue.");
@synchronized(self) {
isRunningActions = false;
}
[ex raise];
}
@
synchronized(self) {
action = [queuedActionsToRun tryDequeue];
if (action == nil) {
isRunningActions = false;
break;
}
}
}
}
- (void)updateValue:(id)value {
[self queueRun:^{
if (value == currentValue)
return;
requireState(!sealed);
currentValue = value;
for (void (^callback)(id value) in callbacks) {
callback(value);
}
}];
}
- (void)adjustValue:(id (^)(id))adjustment {
ows_require(adjustment != nil);
[self queueRun:^{
id oldValue = currentValue;
id newValue = adjustment(oldValue);
if (oldValue == newValue)
return;
requireState(!sealed);
currentValue = newValue;
for (void (^callback)(id value) in callbacks) {
callback(currentValue);
}
}];
}
@end
@implementation ObservableValueController
+ (ObservableValueController *)observableValueControllerWithInitialValue:(id)value {
return [[ObservableValueController alloc] initWithValue:value];
}
- (void)updateValue:(id)value {
[super updateValue:value];
}
- (void)adjustValue:(id (^)(id))adjustment {
[super adjustValue:adjustment];
}
- (void)sealValue {
[self queueRun:^{
sealed = true;
callbacks = nil;
}];
}
@end

View file

@ -2,7 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "StringUtil.h"
typedef void (^Action)(void);

View file

@ -2,8 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSString (Util)
/// The utf-8 encoding of the string's text.

View file

@ -2,8 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "MIMETypeUtil.h"
#import "UIColor+OWS.h"
#import "UIFont+OWS.h"

View file

@ -2,7 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "DateUtil.h"
#import "FunctionalUtil.h"
#import "NumberUtil.h"

View file

@ -1,10 +0,0 @@
#import <Foundation/Foundation.h>
@interface Queue : NSObject
- (void)enqueue:(id)item;
- (id)dequeue;
- (id)tryDequeue;
- (id)peek;
- (id)peekAt:(NSUInteger)offset;
- (NSUInteger)count;
@end

View file

@ -1,42 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "Queue.h"
@implementation Queue {
@private
NSMutableArray *items;
}
- (id)init {
if (self = [super init]) {
self->items = [NSMutableArray array];
}
return self;
}
- (void)enqueue:(id)item {
[items addObject:item];
}
- (id)tryDequeue {
if (self.count == 0)
return nil;
return [self dequeue];
}
- (id)dequeue {
requireState(self.count > 0);
id result = items[0];
[items removeObjectAtIndex:0];
return result;
}
- (id)peek {
requireState(self.count > 0);
return items[0];
}
- (id)peekAt:(NSUInteger)offset {
ows_require(offset < self.count);
return items[offset];
}
- (NSUInteger)count {
return items.count;
}
@end

View file

@ -2,7 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Release.h"
#define testPhoneNumber1 [PhoneNumber phoneNumberFromE164:@"+19027777777"]

View file

@ -1,134 +0,0 @@
#import <XCTest/XCTest.h>
#import "ObservableValue.h"
#import "TestUtil.h"
@interface ObservableTest : XCTestCase
@end
@implementation ObservableTest
-(void) testObservableAddRemove {
ObservableValueController* s = [ObservableValueController observableValueControllerWithInitialValue:@""];
ObservableValue* t = s;
NSMutableArray* a = [NSMutableArray array];
TOCCancelTokenSource* c = [TOCCancelTokenSource new];
[t watchLatestValueOnArbitraryThread:^(id value) {[a addObject:value];}
untilCancelled:c.token];
test([a isEqualToArray:@[@""]]);
[s updateValue:@5];
test([a isEqualToArray:(@[@"", @5])]);
[s updateValue:@7];
test([a isEqualToArray:(@[@"", @5, @7])]);
[c cancel];
[s updateValue:@11];
test([a isEqualToArray:(@[@"", @5, @7])]);
}
-(void) testObservableAddAdd {
ObservableValueController* s = [ObservableValueController observableValueControllerWithInitialValue:@""];
ObservableValue* t = s;
NSMutableArray* a = [NSMutableArray array];
TOCCancelTokenSource* c = [TOCCancelTokenSource new];
[t watchLatestValueOnArbitraryThread:^(id value) {[a addObject:value];}
untilCancelled:c.token];
[t watchLatestValueOnArbitraryThread:^(id value) {[a addObject:value];}
untilCancelled:c.token];
[t watchLatestValueOnArbitraryThread:^(id value) {[a addObject:value];}
untilCancelled:c.token];
test([a isEqualToArray:(@[@"", @"", @""])]);
[s updateValue:@5];
test([a isEqualToArray:(@[@"", @"", @"", @5, @5, @5])]);
}
-(void) testObservableRedundantSetIgnored {
id v1 = @"";
id v2 = nil;
id v3 = @1;
ObservableValueController* s = [ObservableValueController observableValueControllerWithInitialValue:v1];
ObservableValue* t = s;
__block id latest = nil;
__block int count = 0;
[t watchLatestValueOnArbitraryThread:^(id value) {latest = value;count++;}
untilCancelled:nil];
test(latest == v1);
test(count == 1);
[s updateValue:v1];
test(latest == v1);
test(count == 1);
[s updateValue:v2];
test(latest == v2);
test(count == 2);
[s updateValue:v2];
test(latest == v2);
test(count == 2);
[s updateValue:v1];
test(latest == v1);
test(count == 3);
[s updateValue:v3];
test(latest == v3);
test(count == 4);
}
-(void) testObservableReentrantAdd {
ObservableValueController* s = [ObservableValueController observableValueControllerWithInitialValue:@""];
ObservableValue* t = s;
NSMutableArray* a = [NSMutableArray array];
TOCCancelTokenSource* c = [TOCCancelTokenSource new];
__block void(^registerSelf)() = nil;
void(^registerSelf_builder)() = ^{
__block bool first = true;
[t watchLatestValueOnArbitraryThread:^(id value) {
if (!first) registerSelf();
first = false;
[a addObject:value];
} untilCancelled:c.token];
};
registerSelf = [registerSelf_builder copy];
registerSelf();
// adding during a callback counts as adding after the callback
// so we should see a doubling each time
test([a isEqualToArray:@[@""]]);
[s updateValue:@1];
test([a isEqualToArray:(@[@"", @1, @1])]);
[s updateValue:@2];
test([a isEqualToArray:(@[@"", @1, @1, @2, @2, @2, @2])]);
[s updateValue:@3];
test([a isEqualToArray:(@[@"", @1, @1, @2, @2, @2, @2, @3, @3, @3, @3, @3, @3, @3, @3])]);
}
-(void) testObservableReentrantRemove {
ObservableValueController* s = [ObservableValueController observableValueControllerWithInitialValue:@""];
ObservableValue* t = s;
NSMutableArray* a = [NSMutableArray array];
TOCCancelTokenSource* c = [TOCCancelTokenSource new];
for (int i = 0; i < 3; i++) {
__block bool first = true;
[t watchLatestValueOnArbitraryThread:^(id value) {
if (!first) {
[c cancel];
[a addObject:value];
}
first = false;
} untilCancelled:c.token];
}
// removing during a callback counts as removing after the callback
// so we should see all the callbacks run, then they're all cancelled
test([a isEqualToArray:(@[])]);
[s updateValue:@1];
test([a isEqualToArray:(@[@1, @1, @1])]);
[s updateValue:@2];
test([a isEqualToArray:(@[@1, @1, @1])]);
}
@end

View file

@ -2,7 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "TSConstants.h"
NS_ASSUME_NONNULL_BEGIN

View file

@ -1,12 +1,6 @@
//
// TSAttributes.h
// Signal
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
// Created by Frederic Jacobs on 22/08/15.
// Copyright (c) 2015 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TSAttributes : NSObject

View file

@ -2,7 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "TSAccountManager.h"
typedef NS_ENUM(NSInteger, RefreshPreKeysMode) {

View file

@ -2,8 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TSRequest : NSMutableURLRequest
@property (nonatomic, retain) NSMutableDictionary *parameters;

View file

@ -20,7 +20,6 @@
#import "TSUpdateAttributesRequest.h"
#import "TSVerifyCodeRequest.h"
#import <AFNetworking/AFHTTPSessionManager.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN

View file

@ -2,7 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SRWebSocket.h"
static void *SocketManagerStateObservationContext = &SocketManagerStateObservationContext;

View file

@ -1,12 +1,6 @@
//
// TSDatabaseSecondaryIndexes.h
// Signal
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
// Created by Frederic Jacobs on 26/01/15.
// Copyright (c) 2015 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <YapDatabase/YapDatabaseSecondaryIndex.h>
#import <YapDatabase/YapDatabaseTransaction.h>

View file

@ -2,7 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <YapDatabase/YapDatabaseViewTransaction.h>
extern NSString *const kNSNotificationName_DatabaseViewRegistrationComplete;

View file

@ -4,7 +4,6 @@
#import "TSStorageKeys.h"
#import "YapDatabaseConnection+OWS.h"
#import <Foundation/Foundation.h>
#import <YapDatabase/YapDatabase.h>
@class ECKeyPair;

View file

@ -2,7 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
@class TSNumberVerifier;
#ifndef TextSecureKit_Constants_h

View file

@ -2,8 +2,6 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#ifndef OWSAssert
#ifdef DEBUG