mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Recursively added dot syntax, translating more terms when they were encountered in the dif
FREEBIE
This commit is contained in:
parent
f582dd7a24
commit
f1de95ab06
98 changed files with 415 additions and 418 deletions
|
@ -5,6 +5,6 @@
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass(AppDelegate.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@
|
|||
|
||||
- (void)performUpdateCheck{
|
||||
// We check if NSUserDefaults key for version exists.
|
||||
NSString *previousVersion = [[Environment preferences] lastRanVersion];
|
||||
NSString *currentVersion = [[Environment preferences] setAndGetCurrentVersion];
|
||||
NSString *previousVersion = Environment.preferences.lastRanVersion;
|
||||
NSString *currentVersion = [Environment.preferences setAndGetCurrentVersion];
|
||||
|
||||
if (!previousVersion) {
|
||||
DDLogError(@"No previous version found. Possibly first launch since install.");
|
||||
|
@ -69,7 +69,7 @@
|
|||
NSDictionary *attrs = @{NSFileProtectionKey: NSFileProtectionCompleteUntilFirstUserAuthentication};
|
||||
[[NSFileManager defaultManager] setAttributes:attrs ofItemAtPath:preferencesPath error:&error];
|
||||
|
||||
[pathsToExclude addObject:[[preferencesPath stringByAppendingString:[[NSBundle mainBundle] bundleIdentifier]] stringByAppendingString:@".plist"]];
|
||||
[pathsToExclude addObject:[[preferencesPath stringByAppendingString:NSBundle.mainBundle.bundleIdentifier] stringByAppendingString:@".plist"]];
|
||||
|
||||
NSString *logPath = [NSHomeDirectory() stringByAppendingString:@"/Library/Caches/Logs/"];
|
||||
NSArray *logsFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:logPath error:&error];
|
||||
|
@ -111,7 +111,7 @@
|
|||
[DebugLogger.sharedInstance enableTTYLogging];
|
||||
|
||||
#elif RELEASE
|
||||
loggingIsEnabled = [[Environment preferences] loggingIsEnabled];
|
||||
loggingIsEnabled = Environment.preferences.loggingIsEnabled;
|
||||
#endif
|
||||
|
||||
if (loggingIsEnabled) {
|
||||
|
@ -121,7 +121,7 @@
|
|||
[self performUpdateCheck];
|
||||
[self protectPreferenceFiles];
|
||||
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
|
||||
|
||||
[self prepareScreenshotProtection];
|
||||
|
||||
|
@ -130,8 +130,8 @@
|
|||
CategorizingLogger* logger = [CategorizingLogger categorizingLogger];
|
||||
[logger addLoggingCallback:^(NSString *category, id details, NSUInteger index) {}];
|
||||
[Environment setCurrent:[Release releaseEnvironmentWithLogging:logger]];
|
||||
[[Environment getCurrent].phoneDirectoryManager startUntilCancelled:nil];
|
||||
[[Environment getCurrent].contactsManager doAfterEnvironmentInitSetup];
|
||||
[Environment.getCurrent.phoneDirectoryManager startUntilCancelled:nil];
|
||||
[Environment.getCurrent.contactsManager doAfterEnvironmentInitSetup];
|
||||
[UIApplication.sharedApplication setStatusBarStyle:UIStatusBarStyleDefault];
|
||||
|
||||
LeftSideMenuViewController *leftSideMenuViewController = [LeftSideMenuViewController new];
|
||||
|
@ -147,15 +147,15 @@
|
|||
[self application:application didReceiveRemoteNotification:remoteNotif];
|
||||
}
|
||||
|
||||
[[[Environment phoneManager] currentCallObservable] watchLatestValue:^(CallState* latestCall) {
|
||||
[Environment.phoneManager.currentCallObservable watchLatestValue:^(CallState* latestCall) {
|
||||
if (latestCall == nil){
|
||||
return;
|
||||
}
|
||||
|
||||
InCallViewController *callViewController = [InCallViewController inCallViewControllerWithCallState:latestCall
|
||||
andOptionallyKnownContact:[latestCall potentiallySpecifiedContact]];
|
||||
andOptionallyKnownContact:latestCall.potentiallySpecifiedContact];
|
||||
[_drawerController.centerViewController presentViewController:callViewController animated:YES completion:nil];
|
||||
} onThread:[NSThread mainThread] untilCancelled:nil];
|
||||
} onThread:NSThread.mainThread untilCancelled:nil];
|
||||
|
||||
|
||||
return YES;
|
||||
|
@ -185,7 +185,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
[[Environment phoneManager] incomingCallWithSession:call];
|
||||
[Environment.phoneManager incomingCallWithSession:call];
|
||||
}
|
||||
|
||||
-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
|
||||
|
@ -228,8 +228,8 @@
|
|||
}
|
||||
|
||||
- (void)protectScreen{
|
||||
if ([[Environment preferences] screenSecurityIsEnabled]) {
|
||||
self.blankWindow.rootViewController = [[UIViewController alloc] init];
|
||||
if (Environment.preferences.screenSecurityIsEnabled) {
|
||||
self.blankWindow.rootViewController = [UIViewController new];
|
||||
UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.blankWindow.bounds];
|
||||
if (self.blankWindow.bounds.size.height == 568) {
|
||||
imageView.image = [UIImage imageNamed:@"Default-568h"];
|
||||
|
@ -243,7 +243,7 @@
|
|||
}
|
||||
|
||||
- (void)removeScreenProtection{
|
||||
if ([[Environment preferences] screenSecurityIsEnabled]) {
|
||||
if (Environment.preferences.screenSecurityIsEnabled) {
|
||||
self.blankWindow.rootViewController = nil;
|
||||
self.blankWindow.hidden = YES;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ AppAudioManager* sharedAppAudioManager;
|
|||
+(AppAudioManager*) sharedInstance {
|
||||
@synchronized(self){
|
||||
if( nil == sharedAppAudioManager){
|
||||
sharedAppAudioManager = [[AppAudioManager alloc] init];
|
||||
sharedAppAudioManager = [AppAudioManager new];
|
||||
sharedAppAudioManager.soundPlayer = [SoundPlayer new];
|
||||
[sharedAppAudioManager setAudioEnabled:YES];
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
+(BOOL) isOutputRoutedToSpeaker{
|
||||
AVAudioSession* session = AVAudioSession.sharedInstance;
|
||||
AVAudioSessionRouteDescription* routeDesc = [session currentRoute];
|
||||
AVAudioSessionRouteDescription* routeDesc = session.currentRoute;
|
||||
|
||||
for( AVAudioSessionPortDescription* portDesc in routeDesc.outputs){
|
||||
if (AVAudioSessionPortBuiltInSpeaker == [portDesc portType]){
|
||||
|
@ -36,7 +36,7 @@
|
|||
|
||||
+(BOOL) isOutputRoutedToReciever{
|
||||
AVAudioSession* session = AVAudioSession.sharedInstance;
|
||||
AVAudioSessionRouteDescription* routeDesc = [session currentRoute];
|
||||
AVAudioSessionRouteDescription* routeDesc = session.currentRoute;
|
||||
|
||||
for( AVAudioSessionPortDescription* portDesc in routeDesc.outputs){
|
||||
if (AVAudioSessionPortBuiltInReceiver == [portDesc portType]){
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
+(NSURL*) urlToFile:(NSString*) file {
|
||||
return [NSURL fileURLWithPath:
|
||||
[NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath],file]];
|
||||
[NSString stringWithFormat:@"%@/%@", NSBundle.mainBundle.resourcePath,file]];
|
||||
}
|
||||
|
||||
+(AVAudioPlayer*) createAudioPlayerForFile:(NSString*) audioFile {
|
||||
|
|
|
@ -23,11 +23,11 @@ NSMutableDictionary* currentActiveAudioPlayers;
|
|||
[sound setCompeletionBlock:^(SoundInstance* soundInst) {
|
||||
[self removeSoundFromManifest:soundInst];
|
||||
}];
|
||||
[currentActiveAudioPlayers setValue:sound forKey:[sound getId]];
|
||||
[currentActiveAudioPlayers setValue:sound forKey:sound.getId];
|
||||
}
|
||||
}
|
||||
-(void) removeSoundFromManifest:(SoundInstance*) sound {
|
||||
[self removeSoundFromMainifestById:[sound getId]];
|
||||
[self removeSoundFromMainifestById:sound.getId];
|
||||
}
|
||||
|
||||
-(void) removeSoundFromMainifestById:(NSString*) soundId {
|
||||
|
@ -44,7 +44,7 @@ NSMutableDictionary* currentActiveAudioPlayers;
|
|||
}
|
||||
|
||||
-(void) stopSound:(SoundInstance*) sound {
|
||||
SoundInstance* playingSoundInstance = currentActiveAudioPlayers[[sound getId]];
|
||||
SoundInstance* playingSoundInstance = currentActiveAudioPlayers[sound.getId];
|
||||
[self removeSoundFromManifest:sound];
|
||||
[playingSoundInstance stop];
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ NSMutableDictionary* currentActiveAudioPlayers;
|
|||
}
|
||||
|
||||
-(BOOL) isSoundPlaying:(SoundInstance*) sound {
|
||||
return nil != currentActiveAudioPlayers[[sound getId]];
|
||||
return nil != currentActiveAudioPlayers[sound.getId];
|
||||
}
|
||||
|
||||
-(void) awake {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
-(void)packFrame:(EncodedAudioFrame*)frame{
|
||||
require(frame != nil);
|
||||
require(!frame.isMissingAudioData);
|
||||
[framesToSend addObject:[frame tryGetAudioData]];
|
||||
[framesToSend addObject:frame.tryGetAudioData];
|
||||
}
|
||||
|
||||
-(EncodedAudioPacket*) tryGetFinishedAudioPacket{
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
PacketHandlerBlock valueHandler = ^(RtpPacket* rtpPacket) {
|
||||
require(rtpPacket != nil);
|
||||
require([rtpPacket isKindOfClass:[RtpPacket class]]);
|
||||
require([rtpPacket isKindOfClass:RtpPacket.class]);
|
||||
[handler handlePacket:[EncodedAudioPacket encodedAudioPacketWithAudioData:rtpPacket.payload
|
||||
andTimeStamp:rtpPacket.timeStamp
|
||||
andSequenceNumber:rtpPacket.sequenceNumber]];
|
||||
|
|
|
@ -27,14 +27,14 @@ static bool doesActiveInstanceExist;
|
|||
doesActiveInstanceExist = true;
|
||||
|
||||
RemoteIOAudio* newRemoteIoInterface = [RemoteIOAudio new];
|
||||
newRemoteIoInterface->starveLogger = [[Environment logging] getOccurrenceLoggerForSender:newRemoteIoInterface withKey:@"starve"];
|
||||
newRemoteIoInterface->conditionLogger = [[Environment logging] getConditionLoggerForSender:newRemoteIoInterface];
|
||||
newRemoteIoInterface->starveLogger = [Environment.logging getOccurrenceLoggerForSender:newRemoteIoInterface withKey:@"starve"];
|
||||
newRemoteIoInterface->conditionLogger = [Environment.logging getConditionLoggerForSender:newRemoteIoInterface];
|
||||
newRemoteIoInterface->recordingQueue = [CyclicalBuffer new];
|
||||
newRemoteIoInterface->playbackQueue = [CyclicalBuffer new];
|
||||
newRemoteIoInterface->unusedBuffers = [NSMutableSet set];
|
||||
newRemoteIoInterface->state = NOT_STARTED;
|
||||
newRemoteIoInterface->playbackBufferSizeLogger = [[Environment logging] getValueLoggerForValue:@"|playback queue|" from:newRemoteIoInterface];
|
||||
newRemoteIoInterface->recordingQueueSizeLogger = [[Environment logging] getValueLoggerForValue:@"|recording queue|" from:newRemoteIoInterface];
|
||||
newRemoteIoInterface->playbackBufferSizeLogger = [Environment.logging getValueLoggerForValue:@"|playback queue|" from:newRemoteIoInterface];
|
||||
newRemoteIoInterface->recordingQueueSizeLogger = [Environment.logging getValueLoggerForValue:@"|recording queue|" from:newRemoteIoInterface];
|
||||
|
||||
while (newRemoteIoInterface->unusedBuffers.count < INITIAL_NUMBER_OF_BUFFERS) {
|
||||
[newRemoteIoInterface addUnusedBuffer];
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
+(SpeexCodec*) speexCodec {
|
||||
SpeexCodec* c = [SpeexCodec new];
|
||||
c->logging = [[Environment logging] getConditionLoggerForSender:self];
|
||||
c->logging = [Environment.logging getConditionLoggerForSender:self];
|
||||
[c openSpeex];
|
||||
return c;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
haveReceivedDataYet |= !frame.isMissingAudioData;
|
||||
if (!haveReceivedDataYet) return nil;
|
||||
|
||||
NSData* raw = [codec decode:[frame tryGetAudioData]];
|
||||
NSData* raw = [codec decode:frame.tryGetAudioData];
|
||||
double stretch = [stretchFactorController getAndUpdateDesiredStretchFactor];
|
||||
return [audioStretcher stretchAudioData:raw stretchFactor:stretch];
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
NSTimeInterval audioDurationPerPacket = (NSTimeInterval)(AUDIO_FRAMES_PER_PACKET*[SpeexCodec frameSizeInSamples])
|
||||
/ SAMPLE_RATE;
|
||||
double initialDesiredBufferDepth = [[Environment preferences] getCachedOrDefaultDesiredBufferDepth];
|
||||
double initialDesiredBufferDepth = Environment.preferences.getCachedOrDefaultDesiredBufferDepth;
|
||||
|
||||
DropoutTracker* dropoutTracker = [DropoutTracker dropoutTrackerWithAudioDurationPerPacket:audioDurationPerPacket];
|
||||
|
||||
|
@ -28,16 +28,16 @@
|
|||
DesiredBufferDepthController* result = [DesiredBufferDepthController new];
|
||||
result->dropoutTracker = dropoutTracker;
|
||||
result->decayingDesiredBufferDepth = decayingDesiredBufferDepth;
|
||||
result->desiredDelayLogger = [[Environment logging] getValueLoggerForValue:@"desired buffer depth" from:self];
|
||||
result->desiredDelayLogger = [Environment.logging getValueLoggerForValue:@"desired buffer depth" from:self];
|
||||
|
||||
[jitterQueue registerWatcher:result];
|
||||
return result;
|
||||
}
|
||||
|
||||
-(double) getAndUpdateDesiredBufferDepth {
|
||||
double r = [decayingDesiredBufferDepth currentEstimate];
|
||||
double r = decayingDesiredBufferDepth.currentEstimate;
|
||||
[decayingDesiredBufferDepth updateWithNextSample:[dropoutTracker getDepthForThreshold:DROPOUT_THRESHOLD]];
|
||||
[decayingDesiredBufferDepth forceEstimateTo:[NumberUtil clamp:[decayingDesiredBufferDepth currentEstimate]
|
||||
[decayingDesiredBufferDepth forceEstimateTo:[NumberUtil clamp:decayingDesiredBufferDepth.currentEstimate
|
||||
toMin:MIN_DESIRED_FRAME_DELAY
|
||||
andMax:MAX_DESIRED_FRAME_DELAY]];
|
||||
[desiredDelayLogger logValue:r];
|
||||
|
@ -59,7 +59,7 @@
|
|||
}
|
||||
|
||||
-(void) terminate {
|
||||
[[Environment preferences] setCachedDesiredBufferDepth:[decayingDesiredBufferDepth currentEstimate]];
|
||||
[Environment.preferences setCachedDesiredBufferDepth:decayingDesiredBufferDepth.currentEstimate];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
JitterQueue* q = [JitterQueue new];
|
||||
q->readHeadSpan = READ_HEAD_BAD_SPAN_THRESHOLD+1;
|
||||
q->watchers = [NSMutableArray array];
|
||||
[q registerWatcher:[[Environment logging] jitterQueueNotificationReceiver]];
|
||||
[q registerWatcher:Environment.logging.jitterQueueNotificationReceiver];
|
||||
return q;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,17 +27,17 @@ static double STRETCH_MODE_FACTORS[] = {1/0.95, 1, 1/1.05, 0.5};
|
|||
p->currentStretchMode = STRETCH_MODE_NORMAL;
|
||||
p->bufferDepthMeasure = jitterQueue;
|
||||
p->decayingBufferDepthMeasure = [DecayingSampleEstimator decayingSampleEstimatorWithInitialEstimate:0 andDecayPerUnitSample:BUFFER_DEPTH_DECAYING_FACTOR];
|
||||
p->stretchModeChangeLogger = [[Environment logging] getValueLoggerForValue:@"stretch factor" from:self];
|
||||
p->stretchModeChangeLogger = [Environment.logging getValueLoggerForValue:@"stretch factor" from:self];
|
||||
return p;
|
||||
}
|
||||
|
||||
-(int) reconsiderStretchMode {
|
||||
int16_t currentBufferDepth = [bufferDepthMeasure currentBufferDepth];
|
||||
int16_t currentBufferDepth = bufferDepthMeasure.currentBufferDepth;
|
||||
[decayingBufferDepthMeasure updateWithNextSample:currentBufferDepth];
|
||||
double desiredBufferDepth = [desiredBufferDepthController getAndUpdateDesiredBufferDepth];
|
||||
double desiredBufferDepth = desiredBufferDepthController.getAndUpdateDesiredBufferDepth;
|
||||
|
||||
double currentBufferDepthDelta = currentBufferDepth - desiredBufferDepth;
|
||||
double decayingBufferDepthDelta = [decayingBufferDepthMeasure currentEstimate] - desiredBufferDepth;
|
||||
double decayingBufferDepthDelta = decayingBufferDepthMeasure.currentEstimate - desiredBufferDepth;
|
||||
|
||||
bool shouldStartSuperShrink = currentBufferDepthDelta > SUPER_SHRINK_THRESHOLD;
|
||||
bool shouldMaintainSuperShrink = currentBufferDepthDelta > 0 && currentStretchMode == STRETCH_MODE_SUPER_SHRINK;
|
||||
|
|
|
@ -34,7 +34,7 @@ typedef BOOL (^SearchTermConditionalBlock)(RecentCall*, NSUInteger, BOOL*);
|
|||
}
|
||||
|
||||
-(void) watchForContactUpdatesFrom:(ContactsManager*) contactManager untillCancelled:(TOCCancelToken*) cancelToken{
|
||||
[[contactManager getObservableWhisperUsers] watchLatestValue:^(NSArray* latestUsers) {
|
||||
[contactManager.getObservableWhisperUsers watchLatestValue:^(NSArray* latestUsers) {
|
||||
for (RecentCall* recentCall in _allRecents) {
|
||||
if (![contactManager latestContactWithRecordId:recentCall.contactRecordID]) {
|
||||
Contact* contact = [contactManager latestContactForPhoneNumber:recentCall.phoneNumber];
|
||||
|
@ -43,18 +43,18 @@ typedef BOOL (^SearchTermConditionalBlock)(RecentCall*, NSUInteger, BOOL*);
|
|||
}
|
||||
}
|
||||
}
|
||||
} onThread:[NSThread mainThread] untilCancelled:cancelToken];
|
||||
} onThread:NSThread.mainThread untilCancelled:cancelToken];
|
||||
}
|
||||
|
||||
-(void) watchForCallsThrough:(PhoneManager*)phoneManager
|
||||
untilCancelled:(TOCCancelToken*)untilCancelledToken {
|
||||
require(phoneManager != nil);
|
||||
|
||||
[[phoneManager currentCallObservable] watchLatestValue:^(CallState* latestCall) {
|
||||
if (latestCall != nil && [[Environment preferences] getHistoryLogEnabled]) {
|
||||
[phoneManager.currentCallObservable watchLatestValue:^(CallState* latestCall) {
|
||||
if (latestCall != nil && Environment.preferences.getHistoryLogEnabled) {
|
||||
[self addCall:latestCall];
|
||||
}
|
||||
} onThread:[NSThread mainThread] untilCancelled:untilCancelledToken];
|
||||
} onThread:NSThread.mainThread untilCancelled:untilCancelledToken];
|
||||
}
|
||||
|
||||
-(void) addCall:(CallState*)call {
|
||||
|
@ -81,7 +81,7 @@ typedef BOOL (^SearchTermConditionalBlock)(RecentCall*, NSUInteger, BOOL*);
|
|||
}
|
||||
|
||||
-(Contact*) tryGetContactForNumber:(PhoneNumber*)number {
|
||||
return [[[Environment getCurrent] contactsManager] latestContactForPhoneNumber:number];
|
||||
return [Environment.getCurrent.contactsManager latestContactForPhoneNumber:number];
|
||||
}
|
||||
|
||||
- (void)addMissedCallDueToBusy:(ResponderSessionDescriptor*)incomingCallDescriptor {
|
||||
|
@ -101,7 +101,7 @@ typedef BOOL (^SearchTermConditionalBlock)(RecentCall*, NSUInteger, BOOL*);
|
|||
|
||||
- (void)addRecentCall:(RecentCall *)recentCall {
|
||||
[_allRecents insertObject:recentCall atIndex:0];
|
||||
[[Environment preferences] setFreshInstallTutorialsEnabled:NO];
|
||||
[Environment.preferences setFreshInstallTutorialsEnabled:NO];
|
||||
[observableRecentsController updateValue:_allRecents.copy];
|
||||
[self saveContactsToDefaults];
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ typedef BOOL (^SearchTermConditionalBlock)(RecentCall*, NSUInteger, BOOL*);
|
|||
}
|
||||
|
||||
- (void)saveContactsToDefaults {
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
|
||||
NSData *saveData = [NSKeyedArchiver archivedDataWithRootObject:_allRecents.copy];
|
||||
|
||||
[defaults setObject:saveData forKey:RECENT_CALLS_DEFAULT_KEY];
|
||||
|
@ -135,11 +135,11 @@ typedef BOOL (^SearchTermConditionalBlock)(RecentCall*, NSUInteger, BOOL*);
|
|||
}
|
||||
|
||||
- (NSMutableArray *)loadContactsFromDefaults {
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
|
||||
NSData *encodedData = [defaults objectForKey:RECENT_CALLS_DEFAULT_KEY];
|
||||
id data = [NSKeyedUnarchiver unarchiveObjectWithData:encodedData];
|
||||
|
||||
if(![data isKindOfClass:[NSArray class]]) {
|
||||
if(![data isKindOfClass:NSArray.class]) {
|
||||
return [NSMutableArray array];
|
||||
} else {
|
||||
return [NSMutableArray arrayWithArray:data];
|
||||
|
@ -147,7 +147,7 @@ typedef BOOL (^SearchTermConditionalBlock)(RecentCall*, NSUInteger, BOOL*);
|
|||
}
|
||||
|
||||
- (NSArray *)recentsForSearchString:(NSString *)optionalSearchString andExcludeArchived:(BOOL)excludeArchived {
|
||||
ContactsManager *contactsManager = [[Environment getCurrent] contactsManager];
|
||||
ContactsManager *contactsManager = Environment.getCurrent.contactsManager;
|
||||
SearchTermConditionalBlock searchBlock = ^BOOL(RecentCall *obj, NSUInteger idx, BOOL *stop) {
|
||||
BOOL nameMatchesSearch = YES;
|
||||
BOOL numberMatchesSearch = YES;
|
||||
|
|
|
@ -74,7 +74,7 @@ static NSString *const DEFAULTS_KEY_DATE = @"DefaultsKeyDate";
|
|||
}
|
||||
|
||||
- (UIImage *)image {
|
||||
if ([[Environment preferences] getContactImagesEnabled]) {
|
||||
if (Environment.preferences.getContactImagesEnabled) {
|
||||
return image;
|
||||
} else {
|
||||
return nil;
|
||||
|
|
|
@ -365,7 +365,7 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
|
|||
}
|
||||
|
||||
+(BOOL)name:(NSString *)nameString matchesQuery:(NSString *)queryString {
|
||||
NSCharacterSet *whitespaceSet = [NSCharacterSet whitespaceCharacterSet];
|
||||
NSCharacterSet *whitespaceSet = NSCharacterSet.whitespaceCharacterSet;
|
||||
NSArray *queryStrings = [queryString componentsSeparatedByCharactersInSet:whitespaceSet];
|
||||
NSArray *nameStrings = [nameString componentsSeparatedByCharactersInSet:whitespaceSet];
|
||||
|
||||
|
@ -402,14 +402,14 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
|
|||
#pragma mark - Favourites
|
||||
|
||||
-(NSMutableArray *)loadFavouriteIds {
|
||||
NSArray *favourites = [[NSUserDefaults standardUserDefaults] objectForKey:FAVOURITES_DEFAULT_KEY];
|
||||
NSArray *favourites = [NSUserDefaults.standardUserDefaults objectForKey:FAVOURITES_DEFAULT_KEY];
|
||||
return favourites == nil ? [NSMutableArray array] : favourites.mutableCopy;
|
||||
}
|
||||
|
||||
-(void)saveFavouriteIds {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[_favouriteContactIds copy]
|
||||
[NSUserDefaults.standardUserDefaults setObject:[_favouriteContactIds copy]
|
||||
forKey:FAVOURITES_DEFAULT_KEY];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
[NSUserDefaults.standardUserDefaults synchronize];
|
||||
[observableFavouritesController updateValue:[self contactsForContactIds:_favouriteContactIds]];
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
|
|||
NSSet *oldSet = [NSSet setWithArray:oldArray];
|
||||
|
||||
[newSet minusSet:oldSet];
|
||||
return [newSet allObjects];
|
||||
return newSet.allObjects;
|
||||
}
|
||||
|
||||
- (BOOL)isContactRegisteredWithWhisper:(Contact*) contact {
|
||||
|
@ -497,7 +497,7 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
|
|||
}
|
||||
|
||||
- (BOOL)isPhoneNumberRegisteredWithWhisper:(PhoneNumber *)phoneNumber {
|
||||
PhoneNumberDirectoryFilter* directory = [[[Environment getCurrent] phoneDirectoryManager] getCurrentFilter];
|
||||
PhoneNumberDirectoryFilter* directory = Environment.getCurrent.phoneDirectoryManager.getCurrentFilter;
|
||||
return phoneNumber != nil && [directory containsPhoneNumber:phoneNumber];
|
||||
}
|
||||
|
||||
|
@ -508,29 +508,29 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
|
|||
NSMutableSet *users = [NSMutableSet setWithArray:latestWhisperUsersById.allValues];
|
||||
[users addObjectsFromArray:contacts];
|
||||
|
||||
[observableWhisperUsersController updateValue:[users allObjects]];
|
||||
[observableWhisperUsersController updateValue:users.allObjects];
|
||||
[self saveKnownWhisperUsers];
|
||||
}
|
||||
|
||||
-(BOOL) knownUserStoreInitialized{
|
||||
NSUserDefaults *d = [[NSUserDefaults standardUserDefaults] objectForKey:KNOWN_USERS_DEFAULT_KEY];
|
||||
NSUserDefaults *d = [NSUserDefaults.standardUserDefaults objectForKey:KNOWN_USERS_DEFAULT_KEY];
|
||||
return (Nil != d);
|
||||
}
|
||||
|
||||
-(NSMutableArray*) loadKnownWhisperUsers{
|
||||
NSArray *knownUsers = [[NSUserDefaults standardUserDefaults] objectForKey:KNOWN_USERS_DEFAULT_KEY];
|
||||
NSArray *knownUsers = [NSUserDefaults.standardUserDefaults objectForKey:KNOWN_USERS_DEFAULT_KEY];
|
||||
return knownUsers == nil ? [NSMutableArray array] : knownUsers.mutableCopy;
|
||||
}
|
||||
|
||||
-(void) saveKnownWhisperUsers{
|
||||
_knownWhisperUserIds = [NSMutableArray arrayWithArray:[latestWhisperUsersById allKeys]];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[_knownWhisperUserIds copy] forKey:KNOWN_USERS_DEFAULT_KEY];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
[NSUserDefaults.standardUserDefaults setObject:[_knownWhisperUserIds copy] forKey:KNOWN_USERS_DEFAULT_KEY];
|
||||
[NSUserDefaults.standardUserDefaults synchronize];
|
||||
}
|
||||
|
||||
-(void) clearKnownWhisUsers{
|
||||
[[NSUserDefaults standardUserDefaults] setObject:@[] forKey:KNOWN_USERS_DEFAULT_KEY];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
[NSUserDefaults.standardUserDefaults setObject:@[] forKey:KNOWN_USERS_DEFAULT_KEY];
|
||||
[NSUserDefaults.standardUserDefaults synchronize];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
MacrosSingletonImplemention
|
||||
|
||||
- (void)enableFileLogging{
|
||||
self.fileLogger = [[DDFileLogger alloc] init]; //Logging to file, because it's in the Cache folder, they are not uploaded in iTunes/iCloud backups.
|
||||
self.fileLogger = [DDFileLogger new]; //Logging to file, because it's in the Cache folder, they are not uploaded in iTunes/iCloud backups.
|
||||
self.fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling.
|
||||
self.fileLogger.logFileManager.maximumNumberOfLogFiles = 3; // Keep three days of logs.
|
||||
[DDLog addLogger:self.fileLogger];
|
||||
|
|
|
@ -35,7 +35,7 @@ contactsManager,
|
|||
phoneDirectoryManager;
|
||||
|
||||
+(NSString*) currentRegionCodeForPhoneNumbers {
|
||||
return [[self getCurrent] currentRegionCodeForPhoneNumbers];
|
||||
return self.getCurrent.currentRegionCodeForPhoneNumbers;
|
||||
}
|
||||
|
||||
+(Environment*) getCurrent {
|
||||
|
@ -46,26 +46,26 @@ phoneDirectoryManager;
|
|||
environment = curEnvironment;
|
||||
}
|
||||
+(ErrorHandlerBlock) errorNoter {
|
||||
return [[self getCurrent] errorNoter];
|
||||
return self.getCurrent.errorNoter;
|
||||
}
|
||||
+(bool) hasEnabledTestingOrLegacyOption:(NSString*)flag {
|
||||
return [[self getCurrent].testingAndLegacyOptions containsObject:flag];
|
||||
return [self.getCurrent.testingAndLegacyOptions containsObject:flag];
|
||||
}
|
||||
|
||||
+(NSString*) relayServerNameToHostName:(NSString*)name {
|
||||
return [NSString stringWithFormat:@"%@.%@",
|
||||
name,
|
||||
[[Environment getCurrent] relayServerHostNameSuffix]];
|
||||
Environment.getCurrent.relayServerHostNameSuffix];
|
||||
}
|
||||
+(SecureEndPoint*) getMasterServerSecureEndPoint {
|
||||
return [[Environment getCurrent] masterServerSecureEndPoint];
|
||||
return Environment.getCurrent.masterServerSecureEndPoint;
|
||||
}
|
||||
+(SecureEndPoint*) getSecureEndPointToDefaultRelayServer {
|
||||
return [Environment getSecureEndPointToSignalingServerNamed:[Environment getCurrent].defaultRelayName];
|
||||
return [Environment getSecureEndPointToSignalingServerNamed:Environment.getCurrent.defaultRelayName];
|
||||
}
|
||||
+(SecureEndPoint*) getSecureEndPointToSignalingServerNamed:(NSString*)name {
|
||||
require(name != nil);
|
||||
Environment* env = [Environment getCurrent];
|
||||
Environment* env = Environment.getCurrent;
|
||||
|
||||
NSString* hostName = [self relayServerNameToHostName:name];
|
||||
HostNameEndPoint* location = [HostNameEndPoint hostNameEndPointWithHostName:hostName andPort:env.serverPort];
|
||||
|
@ -101,7 +101,7 @@ phoneDirectoryManager;
|
|||
|
||||
// must support DH3k
|
||||
require([keyAgreementProtocolsInDescendingPriority any:^int(id p) {
|
||||
return [p isKindOfClass:[DH3KKeyAgreementProtocol class]];
|
||||
return [p isKindOfClass:DH3KKeyAgreementProtocol.class];
|
||||
}]);
|
||||
|
||||
Environment* e = [Environment new];
|
||||
|
@ -137,46 +137,42 @@ phoneDirectoryManager;
|
|||
}
|
||||
|
||||
+(PhoneManager*) phoneManager {
|
||||
return [[Environment getCurrent] phoneManager];
|
||||
return Environment.getCurrent.phoneManager;
|
||||
}
|
||||
+(id<Logging>) logging {
|
||||
// Many tests create objects that rely on Environment only for logging.
|
||||
// So we bypass the nil check in getCurrent and silently don't log during unit testing, instead of failing hard.
|
||||
if (environment == nil) return nil;
|
||||
|
||||
return [[Environment getCurrent] logging];
|
||||
return Environment.getCurrent.logging;
|
||||
}
|
||||
|
||||
+(BOOL)isRegistered{
|
||||
// Attributes that need to be set
|
||||
NSData *signalingKey = [SGNKeychainUtil signalingCipherKey];
|
||||
NSData *macKey = [SGNKeychainUtil signalingMacKey];
|
||||
NSData *extra = [SGNKeychainUtil signalingExtraKey];
|
||||
NSString *serverAuth = [SGNKeychainUtil serverAuthPassword];
|
||||
BOOL registered = [[[NSUserDefaults standardUserDefaults] objectForKey:isRegisteredUserDefaultString] boolValue];
|
||||
NSData *signalingKey = SGNKeychainUtil.signalingCipherKey;
|
||||
NSData *macKey = SGNKeychainUtil.signalingMacKey;
|
||||
NSData *extra = SGNKeychainUtil.signalingExtraKey;
|
||||
NSString *serverAuth = SGNKeychainUtil.serverAuthPassword;
|
||||
BOOL registered = [[NSUserDefaults.standardUserDefaults objectForKey:isRegisteredUserDefaultString] boolValue];
|
||||
|
||||
if (signalingKey && macKey && extra && serverAuth && registered) {
|
||||
return YES;
|
||||
} else{
|
||||
return NO;
|
||||
}
|
||||
return signalingKey && macKey && extra && serverAuth && registered;
|
||||
}
|
||||
|
||||
+(void)setRegistered:(BOOL)status{
|
||||
[[NSUserDefaults standardUserDefaults] setObject:status?@YES:@NO forKey:isRegisteredUserDefaultString];
|
||||
[NSUserDefaults.standardUserDefaults setObject:status?@YES:@NO forKey:isRegisteredUserDefaultString];
|
||||
}
|
||||
|
||||
+(PropertyListPreferences*)preferences{
|
||||
return [[PropertyListPreferences alloc]init];
|
||||
return [PropertyListPreferences new];
|
||||
}
|
||||
|
||||
+(void)resetAppData{
|
||||
[SGNKeychainUtil wipeKeychain];
|
||||
[[Environment preferences] clear];
|
||||
if ([[self preferences] loggingIsEnabled]) {
|
||||
[Environment.preferences clear];
|
||||
if (self.preferences.loggingIsEnabled) {
|
||||
[DebugLogger.sharedInstance wipeLogs];
|
||||
}
|
||||
[[self preferences] setAndGetCurrentVersion];
|
||||
[self.preferences setAndGetCurrentVersion];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
NSData* data = [[phoneNumberDirectoryFilter bloomFilter] data];
|
||||
NSNumber* hashCount = @([[phoneNumberDirectoryFilter bloomFilter] hashCount]);
|
||||
NSDate* expiry = [phoneNumberDirectoryFilter getExpirationDate];
|
||||
NSDate* expiry = phoneNumberDirectoryFilter.getExpirationDate;
|
||||
[self setValueForKey:PHONE_DIRECTORY_BLOOM_FILTER_DATA_KEY toValue:data];
|
||||
[self setValueForKey:PHONE_DIRECTORY_BLOOM_FILTER_HASH_COUNT_KEY toValue:hashCount];
|
||||
[self setValueForKey:PHONE_DIRECTORY_EXPIRATION toValue:expiry];
|
||||
|
@ -147,14 +147,15 @@
|
|||
}
|
||||
|
||||
-(NSString*)lastRanVersion{
|
||||
return [[NSUserDefaults standardUserDefaults] objectForKey:kSignalVersionKey];
|
||||
return [NSUserDefaults.standardUserDefaults objectForKey:kSignalVersionKey];
|
||||
}
|
||||
|
||||
-(NSString*)setAndGetCurrentVersion{
|
||||
NSString *lastVersion = self.lastRanVersion;
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithFormat:@"%@", [[NSBundle mainBundle] infoDictionary][@"CFBundleVersion"]] forKey:kSignalVersionKey];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
[NSUserDefaults.standardUserDefaults setObject:[NSString stringWithFormat:@"%@", NSBundle.mainBundle.infoDictionary[@"CFBundleVersion"]]
|
||||
forKey:kSignalVersionKey];
|
||||
[NSUserDefaults.standardUserDefaults synchronize];
|
||||
return lastVersion;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,21 +6,21 @@
|
|||
|
||||
-(void) clear {
|
||||
@synchronized(self) {
|
||||
NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier];
|
||||
[[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain];
|
||||
NSString *appDomain = NSBundle.mainBundle.bundleIdentifier;
|
||||
[NSUserDefaults.standardUserDefaults removePersistentDomainForName:appDomain];
|
||||
}
|
||||
}
|
||||
|
||||
-(id) tryGetValueForKey:(NSString *)key {
|
||||
require(key != nil);
|
||||
@synchronized(self) {
|
||||
return [[NSUserDefaults standardUserDefaults] objectForKey:key];
|
||||
return [NSUserDefaults.standardUserDefaults objectForKey:key];
|
||||
}
|
||||
}
|
||||
-(void) setValueForKey:(NSString *)key toValue:(id)value {
|
||||
require(key != nil);
|
||||
@synchronized(self) {
|
||||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
NSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults;
|
||||
[userDefaults setObject:value forKey:key];
|
||||
[userDefaults synchronize];
|
||||
}
|
||||
|
@ -45,9 +45,9 @@
|
|||
[UICKeyChainStore removeItemForKey:key];
|
||||
DDLogWarn(@"Removing object for key: %@", key);
|
||||
} else {
|
||||
if ([value isKindOfClass:[NSData class]]) {
|
||||
if ([value isKindOfClass:NSData.class]) {
|
||||
[UICKeyChainStore setData:value forKey:key];
|
||||
} else if ([value isKindOfClass:[NSString class]]){
|
||||
} else if ([value isKindOfClass:NSString.class]){
|
||||
[UICKeyChainStore setString:value forKey:key];
|
||||
} else{
|
||||
DDLogError(@"Unexpected class stored in the Keychain.");
|
||||
|
|
|
@ -55,14 +55,14 @@ static unsigned char DH3K_PRIME[]={
|
|||
andDefaultRelayName:@"relay"
|
||||
andRelayServerHostNameSuffix:@"whispersystems.org"
|
||||
andCertificate:[Certificate certificateFromResourcePath:@"whisperReal" ofType:@"cer"]
|
||||
andCurrentRegionCodeForPhoneNumbers:[(NSLocale*)[NSLocale currentLocale] objectForKey:NSLocaleCountryCode]
|
||||
andCurrentRegionCodeForPhoneNumbers:[(NSLocale*)NSLocale.currentLocale objectForKey:NSLocaleCountryCode]
|
||||
andSupportedKeyAgreementProtocols:[self supportedKeyAgreementProtocols]
|
||||
andPhoneManager:[PhoneManager phoneManagerWithErrorHandler:errorNoter]
|
||||
andRecentCallManager:[RecentCallManager new]
|
||||
andTestingAndLegacyOptions:@[ENVIRONMENT_LEGACY_OPTION_RTP_PADDING_BIT_IMPLIES_EXTENSION_BIT_AND_TWELVE_EXTRA_ZERO_BYTES_IN_HEADER]
|
||||
andZrtpClientId:RELEASE_ZRTP_CLIENT_ID
|
||||
andZrtpVersionId:RELEASE_ZRTP_VERSION_ID
|
||||
andContactsManager:[[ContactsManager alloc] init]
|
||||
andContactsManager:[ContactsManager new]
|
||||
andPhoneDirectoryManager:[PhoneNumberDirectoryFilterManager new]];
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
NSDictionary *dict = [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListImmutable format:&format error:&error];
|
||||
|
||||
NSArray *entries = [dict allKeys];
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
|
||||
|
||||
for (NSUInteger i = 0; i < entries.count; i++) {
|
||||
NSString *key = entries[i];
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
static PushManager *sharedManager = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedManager = [[self alloc] init];
|
||||
sharedManager = [self new];
|
||||
});
|
||||
return sharedManager;
|
||||
}
|
||||
|
@ -50,11 +50,11 @@
|
|||
}
|
||||
|
||||
if (needsPushSettingChangeAlert) {
|
||||
[[Environment preferences] setRevokedPushPermission:YES];
|
||||
[Environment.preferences setRevokedPushPermission:YES];
|
||||
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"ACTION_REQUIRED_TITLE", @"") message:NSLocalizedString(@"PUSH_SETTINGS_MESSAGE", @"") delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:nil, nil];
|
||||
[alertView show];
|
||||
} else if (!needsPushSettingChangeAlert){
|
||||
if ([[Environment preferences] encounteredRevokedPushPermission]) {
|
||||
if (Environment.preferences.encounteredRevokedPushPermission) {
|
||||
[self askForPushRegistration];
|
||||
}
|
||||
}
|
||||
|
@ -73,21 +73,21 @@
|
|||
[UIApplication.sharedApplication registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge)];
|
||||
} else{
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1
|
||||
UIMutableUserNotificationAction *action_accept = [[UIMutableUserNotificationAction alloc]init];
|
||||
UIMutableUserNotificationAction *action_accept = [UIMutableUserNotificationAction new];
|
||||
action_accept.identifier = @"Signal_Call_Accept";
|
||||
action_accept.title = @"Pick up";
|
||||
action_accept.activationMode = UIUserNotificationActivationModeForeground;
|
||||
action_accept.destructive = YES;
|
||||
action_accept.authenticationRequired = NO;
|
||||
|
||||
UIMutableUserNotificationAction *action_decline = [[UIMutableUserNotificationAction alloc]init];
|
||||
UIMutableUserNotificationAction *action_decline = [UIMutableUserNotificationAction new];
|
||||
action_decline.identifier = @"Signal_Call_Decline";
|
||||
action_decline.title = @"Pick up";
|
||||
action_decline.activationMode = UIUserNotificationActivationModeForeground;
|
||||
action_decline.destructive = YES;
|
||||
action_decline.authenticationRequired = NO;
|
||||
|
||||
UIMutableUserNotificationCategory *callCategory = [[UIMutableUserNotificationCategory alloc] init];
|
||||
UIMutableUserNotificationCategory *callCategory = [UIMutableUserNotificationCategory new];
|
||||
callCategory.identifier = @"Signal_IncomingCall";
|
||||
[callCategory setActions:@[action_accept, action_decline] forContext:UIUserNotificationActionContextDefault];
|
||||
|
||||
|
@ -105,11 +105,11 @@
|
|||
|
||||
- (void)registerForPushWithToken:(NSData*)token{
|
||||
[CallServerRequestsManager.sharedInstance registerPushToken:token success:^(NSURLSessionDataTask *task, id responseObject) {
|
||||
if ([task.response isKindOfClass: [NSHTTPURLResponse class]]){
|
||||
if ([task.response isKindOfClass: NSHTTPURLResponse.class]){
|
||||
NSInteger statusCode = [(NSHTTPURLResponse*) task.response statusCode];
|
||||
if (statusCode == 200) {
|
||||
DDLogInfo(@"Device sent push ID to server");
|
||||
[[Environment preferences] setRevokedPushPermission:NO];
|
||||
[Environment.preferences setRevokedPushPermission:NO];
|
||||
if (self.PushRegisteringSuccessBlock) {
|
||||
self.PushRegisteringSuccessBlock();
|
||||
self.PushRegisteringSuccessBlock = nil;
|
||||
|
@ -139,7 +139,7 @@
|
|||
self.PushRegisteringFailureBlock();
|
||||
self.PushRegisteringFailureBlock = nil;
|
||||
}
|
||||
[[Environment preferences] setRevokedPushPermission:YES];
|
||||
[Environment.preferences setRevokedPushPermission:YES];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ void handleDnsCompleted(CFHostRef hostRef, CFHostInfoType typeInfo, const CFStre
|
|||
checkOperationDescribe(addressDatas != nil, @"No addresses for host");
|
||||
|
||||
NSArray* ips = [addressDatas map:^(id addressData) {
|
||||
checkOperation([addressData isKindOfClass:[NSData class]]);
|
||||
checkOperation([addressData isKindOfClass:NSData.class]);
|
||||
|
||||
return [[IpEndPoint ipEndPointFromSockaddrData:addressData] address];
|
||||
}];
|
||||
|
|
|
@ -29,13 +29,13 @@ MacrosSingletonImplemention
|
|||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
HostNameEndPoint *endpoint = [[[Environment getCurrent]masterServerSecureEndPoint] hostNameEndPoint];
|
||||
HostNameEndPoint *endpoint = Environment.getCurrent.masterServerSecureEndPoint.hostNameEndPoint;
|
||||
NSURL *endPointURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://%@:%hu", endpoint.hostname, endpoint.port]];
|
||||
NSURLSessionConfiguration *sessionConf = [NSURLSessionConfiguration ephemeralSessionConfiguration];
|
||||
NSURLSessionConfiguration *sessionConf = NSURLSessionConfiguration.ephemeralSessionConfiguration;
|
||||
self.operationManager = [[AFHTTPSessionManager alloc] initWithBaseURL:endPointURL sessionConfiguration:sessionConf];
|
||||
self.operationManager.responseSerializer = [AFJSONResponseSerializer serializer];
|
||||
self.operationManager.securityPolicy.allowInvalidCertificates = YES;
|
||||
NSString *certPath = [[NSBundle mainBundle] pathForResource:@"whisperReal" ofType:@"cer"];
|
||||
NSString *certPath = [NSBundle.mainBundle pathForResource:@"whisperReal" ofType:@"cer"];
|
||||
NSData *certData = [NSData dataWithContentsOfFile:certPath];
|
||||
SecCertificateRef cert = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)(certData));
|
||||
self.operationManager.securityPolicy.pinnedCertificates = @[(__bridge_transfer NSData *)SecCertificateCopyData(cert)];
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
@try {
|
||||
TOCFutureSource* ev = [TOCFutureSource futureSourceUntil:unlessCancelledToken];
|
||||
@synchronized (self) {
|
||||
if ([lifetime.token isAlreadyCancelled]) {
|
||||
if (lifetime.token.isAlreadyCancelled) {
|
||||
return [TOCFuture futureWithFailure:@"terminated"];
|
||||
}
|
||||
[eventualResponseQueue enqueue:ev];
|
||||
|
@ -53,7 +53,7 @@
|
|||
require(request != nil);
|
||||
require(errorHandler != nil);
|
||||
|
||||
HttpManager* manager = [HttpManager startWithEndPoint:[Environment getMasterServerSecureEndPoint]
|
||||
HttpManager* manager = [HttpManager startWithEndPoint:Environment.getMasterServerSecureEndPoint
|
||||
untilCancelled:unlessCancelledToken];
|
||||
|
||||
[manager startWithRejectingRequestHandlerAndErrorHandler:errorHandler
|
||||
|
@ -112,7 +112,7 @@
|
|||
|
||||
PacketHandlerBlock httpHandler = ^(HttpRequestOrResponse* requestOrResponse) {
|
||||
require(requestOrResponse != nil);
|
||||
require([requestOrResponse isKindOfClass:[HttpRequestOrResponse class]]);
|
||||
require([requestOrResponse isKindOfClass:HttpRequestOrResponse.class]);
|
||||
@synchronized (self) {
|
||||
if (requestOrResponse.isRequest) {
|
||||
HttpResponse* response = requestHandler([requestOrResponse request]);
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
return h;
|
||||
}
|
||||
-(bool) isRequest {
|
||||
return [requestOrResponse isKindOfClass:[HttpRequest class]];
|
||||
return [requestOrResponse isKindOfClass:HttpRequest.class];
|
||||
}
|
||||
-(bool) isResponse {
|
||||
return [requestOrResponse isKindOfClass:[HttpResponse class]];
|
||||
return [requestOrResponse isKindOfClass:HttpResponse.class];
|
||||
}
|
||||
-(HttpRequest*) request {
|
||||
requireState(self.isRequest);
|
||||
|
@ -62,8 +62,8 @@
|
|||
|
||||
NSArray* headerLineParts = [headerLine componentsSeparatedByString:@":"];
|
||||
checkOperation(headerLineParts.count >= 2);
|
||||
NSString* headerKey = [headerLineParts[0] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||
NSString* headerValue = [[headerLine substringFromIndex:[(NSString *)headerLineParts[0] length]+1] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||
NSString* headerKey = [headerLineParts[0] stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet];
|
||||
NSString* headerValue = [[headerLine substringFromIndex:[(NSString *)headerLineParts[0] length]+1] stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet];
|
||||
headers[headerKey] = headerValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
andLocation:location
|
||||
andOptionalBody:optionalBody
|
||||
andLocalNumber:SGNKeychainUtil.localNumber
|
||||
andPassword:[SGNKeychainUtil serverAuthPassword]];
|
||||
andPassword:SGNKeychainUtil.serverAuthPassword];
|
||||
}
|
||||
+(HttpRequest*)httpRequestWithOtpAuthenticationAndMethod:(NSString*)method
|
||||
andLocation:(NSString*)location {
|
||||
|
@ -34,7 +34,7 @@
|
|||
andLocation:location
|
||||
andOptionalBody:optionalBody
|
||||
andLocalNumber:SGNKeychainUtil.localNumber
|
||||
andPassword:[SGNKeychainUtil serverAuthPassword]
|
||||
andPassword:SGNKeychainUtil.serverAuthPassword
|
||||
andCounter:[SGNKeychainUtil getAndIncrementOneTimeCounter]];
|
||||
}
|
||||
+(HttpRequest*)httpRequestUnauthenticatedWithMethod:(NSString*)method
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
[r addObject:statusText];
|
||||
[r addObject:@"\r\n"];
|
||||
|
||||
NSString* body = [self getOptionalBodyText];
|
||||
NSString* body = self.getOptionalBodyText;
|
||||
if (body != nil) {
|
||||
[r addObject:@"Content-Length: "];
|
||||
[r addObject:[@(body.length) stringValue]];
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
HttpSocket* h = [HttpSocket new];
|
||||
h->rawDataChannelTcp = rawDataChannel;
|
||||
h->partialDataBuffer = [NSMutableData data];
|
||||
h->sentPacketsLogger = [[Environment logging] getOccurrenceLoggerForSender:self withKey:@"sent"];
|
||||
h->receivedPacketsLogger = [[Environment logging] getOccurrenceLoggerForSender:self withKey:@"received"];
|
||||
h->sentPacketsLogger = [Environment.logging getOccurrenceLoggerForSender:self withKey:@"sent"];
|
||||
h->receivedPacketsLogger = [Environment.logging getOccurrenceLoggerForSender:self withKey:@"received"];
|
||||
return h;
|
||||
}
|
||||
+(HttpSocket*) httpSocketOverUdp:(UdpSocket*)rawDataChannel {
|
||||
|
@ -21,8 +21,8 @@
|
|||
HttpSocket* h = [HttpSocket new];
|
||||
h->rawDataChannelUdp = rawDataChannel;
|
||||
h->partialDataBuffer = [NSMutableData data];
|
||||
h->sentPacketsLogger = [[Environment logging] getOccurrenceLoggerForSender:self withKey:@"sent"];
|
||||
h->receivedPacketsLogger = [[Environment logging] getOccurrenceLoggerForSender:self withKey:@"received"];
|
||||
h->sentPacketsLogger = [Environment.logging getOccurrenceLoggerForSender:self withKey:@"sent"];
|
||||
h->receivedPacketsLogger = [Environment.logging getOccurrenceLoggerForSender:self withKey:@"received"];
|
||||
return h;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@
|
|||
|
||||
PacketHandler* packetHandler = [PacketHandler packetHandler:^(id packet) {
|
||||
require(packet != nil);
|
||||
require([packet isKindOfClass:[NSData class]]);
|
||||
require([packet isKindOfClass:NSData.class]);
|
||||
NSData* data = packet;
|
||||
|
||||
[partialDataBuffer replaceBytesInRange:NSMakeRange(partialDataBuffer.length, data.length) withBytes:[data bytes]];
|
||||
|
@ -82,7 +82,7 @@
|
|||
[receivedPacketsLogger markOccurrence:s];
|
||||
[handler handlePacket:s];
|
||||
}
|
||||
} withErrorHandler:[handler errorHandler]];
|
||||
} withErrorHandler:handler.errorHandler];
|
||||
|
||||
if (rawDataChannelTcp != nil) {
|
||||
[rawDataChannelTcp startWithHandler:packetHandler];
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
PacketHandlerBlock valueHandler = ^(id packet) {
|
||||
require(packet != nil);
|
||||
require([packet isKindOfClass:[NSData class]]);
|
||||
require([packet isKindOfClass:NSData.class]);
|
||||
NSData* data = packet;
|
||||
RtpPacket* rtpPacket = [RtpPacket rtpPacketParsedFromPacketData:data];
|
||||
|
||||
|
@ -51,7 +51,7 @@
|
|||
}
|
||||
-(void) handleRtpPacket:(RtpPacket*)rtpPacket {
|
||||
@synchronized(self) {
|
||||
if ([ThreadManager lowLatencyThread] == [NSThread currentThread]) {
|
||||
if ([ThreadManager lowLatencyThread] == NSThread.currentThread) {
|
||||
[currentHandler handlePacket:rtpPacket];
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
s->incomingContext = [SrtpStream srtpStreamWithCipherKey:incomingCipherKey andMacKey:incomingMacKey andCipherIvSalt:incomingSalt];
|
||||
s->outgoingContext = [SrtpStream srtpStreamWithCipherKey:outgoingCipherKey andMacKey:outgoingMacKey andCipherIvSalt:outgoingSalt];
|
||||
s->rtpSocket = rtpSocket;
|
||||
s->badPacketLogger = [[Environment logging] getOccurrenceLoggerForSender:self withKey:@"Bad Packet"];
|
||||
s->badPacketLogger = [Environment.logging getOccurrenceLoggerForSender:self withKey:@"Bad Packet"];
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
|||
|
||||
PacketHandlerBlock packetHandler = ^(id packet) {
|
||||
require(packet != nil);
|
||||
require([packet isKindOfClass:[RtpPacket class]]);
|
||||
require([packet isKindOfClass:RtpPacket.class]);
|
||||
|
||||
RtpPacket* decryptedPacket;
|
||||
@try {
|
||||
|
|
|
@ -79,8 +79,8 @@
|
|||
counter,
|
||||
dhResult,
|
||||
@"ZRTP-HMAC-KDF".encodedAsUtf8,
|
||||
[initiatorZid getData],
|
||||
[responderZid getData],
|
||||
initiatorZid.getData,
|
||||
responderZid.getData,
|
||||
totalHash,
|
||||
s1Length,
|
||||
s2Length,
|
||||
|
@ -144,17 +144,17 @@
|
|||
}
|
||||
|
||||
-(NSData*) deriveKeyWithLabel:(NSString*)label andTruncatedLength:(uint16_t)truncatedLength {
|
||||
NSData* input = [@[
|
||||
NSData* input = @[
|
||||
|
||||
counter,
|
||||
label.encodedAsUtf8,
|
||||
[@[@0] toUint8Data],
|
||||
[initiatorZid getData],
|
||||
[responderZid getData],
|
||||
initiatorZid.getData,
|
||||
responderZid.getData,
|
||||
totalHash,
|
||||
[NSData dataWithBigEndianBytesOfUInt32:truncatedLength]
|
||||
|
||||
] concatDatas];
|
||||
].concatDatas;
|
||||
|
||||
NSData* digest = [input hmacWithSha256WithKey:sharedSecret];
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
ZrtpHandshakeSocket* z = [ZrtpHandshakeSocket new];
|
||||
z->rtpSocket = rtpSocket;
|
||||
z->sentPacketsLogger = [[Environment logging] getOccurrenceLoggerForSender:self withKey:@"sent"];
|
||||
z->receivedPacketsLogger = [[Environment logging] getOccurrenceLoggerForSender:self withKey:@"received"];
|
||||
z->sentPacketsLogger = [Environment.logging getOccurrenceLoggerForSender:self withKey:@"sent"];
|
||||
z->receivedPacketsLogger = [Environment.logging getOccurrenceLoggerForSender:self withKey:@"received"];
|
||||
return z;
|
||||
}
|
||||
-(void) send:(HandshakePacket*)packet {
|
||||
|
@ -27,7 +27,7 @@
|
|||
|
||||
PacketHandlerBlock packetHandler = ^(id packet) {
|
||||
require(packet != nil);
|
||||
require([packet isKindOfClass:[RtpPacket class]]);
|
||||
require([packet isKindOfClass:RtpPacket.class]);
|
||||
RtpPacket* rtpPacket = packet;
|
||||
|
||||
HandshakePacket* handshakePacket = nil;
|
||||
|
@ -43,7 +43,7 @@
|
|||
};
|
||||
|
||||
[rtpSocket startWithHandler:[PacketHandler packetHandler:packetHandler
|
||||
withErrorHandler:[handler errorHandler]]
|
||||
withErrorHandler:handler.errorHandler]
|
||||
untilCancelled:untilCancelledToken];
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
|
||||
ZrtpInitiator* s = [ZrtpInitiator new];
|
||||
|
||||
s->allowedKeyAgreementProtocols = [[Environment getCurrent] keyAgreementProtocolsInDescendingPriority];
|
||||
s->allowedKeyAgreementProtocols = Environment.getCurrent.keyAgreementProtocolsInDescendingPriority;
|
||||
s->dhSharedSecretHashes = [DhPacketSharedSecretHashes dhPacketSharedSecretHashesRandomized];
|
||||
s->zid = [SGNKeychainUtil zid];
|
||||
s->confirmIv = [CryptoTools generateSecureRandomData:IV_LENGTH];
|
||||
s->hashChain = [HashChain hashChainWithSecureGeneratedData];
|
||||
s->badPacketLogger = [[Environment logging] getOccurrenceLoggerForSender:self withKey:@"Bad Packet"];
|
||||
s->badPacketLogger = [Environment.logging getOccurrenceLoggerForSender:self withKey:@"Bad Packet"];
|
||||
s->packetExpectation = EXPECTING_HELLO;
|
||||
s->callController = callController;
|
||||
|
||||
|
@ -89,7 +89,7 @@
|
|||
andSharedSecretHashes:dhSharedSecretHashes
|
||||
andKeyAgreer:keyAgreementParticipant];
|
||||
|
||||
commitPacket = [CommitPacket commitPacketWithDefaultSpecsAndKeyAgreementProtocol:[keyAgreementParticipant getProtocol]
|
||||
commitPacket = [CommitPacket commitPacketWithDefaultSpecsAndKeyAgreementProtocol:keyAgreementParticipant.getProtocol
|
||||
andHashChain:hashChain
|
||||
andZid:zid
|
||||
andCommitmentToHello:foreignHello
|
||||
|
@ -141,7 +141,7 @@
|
|||
|
||||
-(bool) isAuthenticatedAudioDataImplyingConf2Ack:(id)packet {
|
||||
if (packetExpectation != EXPECTING_CONFIRM_ACK) return false;
|
||||
if (![packet isKindOfClass:[RtpPacket class]]) return false;
|
||||
if (![packet isKindOfClass:RtpPacket.class]) return false;
|
||||
|
||||
@try {
|
||||
SrtpStream* incomingContext = [SrtpStream srtpStreamWithCipherKey:[masterSecret responderSrtpKey]
|
||||
|
@ -158,7 +158,7 @@
|
|||
NSArray* idsOfProtocolsAllowedByPeer = [foreignHello agreeIdsIncludingImplied];
|
||||
|
||||
id<KeyAgreementProtocol> bestCommonKeyAgreementProtocol = [allowedKeyAgreementProtocols firstMatchingElseNil:^int(id<KeyAgreementProtocol> locallyAllowedProtocol) {
|
||||
return [idsOfProtocolsAllowedByPeer containsObject:[locallyAllowedProtocol getId]];
|
||||
return [idsOfProtocolsAllowedByPeer containsObject:locallyAllowedProtocol.getId];
|
||||
}];
|
||||
|
||||
// Note: should never fail to find a common protocol because DH3k support is required and implied
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
-(TOCFuture*) asyncPerformHandshake {
|
||||
PacketHandlerBlock packetHandler = ^(id packet) {
|
||||
require(packet != nil);
|
||||
require([packet isKindOfClass:[HandshakePacket class]]);
|
||||
require([packet isKindOfClass:HandshakePacket.class]);
|
||||
[self handleHandshakePacket:(HandshakePacket*)packet];
|
||||
};
|
||||
|
||||
|
@ -178,7 +178,7 @@
|
|||
handshakeCompletedSuccesfully = true;
|
||||
|
||||
SrtpSocket* secureChannel = [zrtpRole useKeysToSecureRtpSocket:rtpSocketToSecure];
|
||||
MasterSecret* masterSecret = [zrtpRole getMasterSecret];
|
||||
MasterSecret* masterSecret = zrtpRole.getMasterSecret;
|
||||
|
||||
ZrtpHandshakeResult* result = [ZrtpHandshakeResult zrtpHandshakeResultWithSecureChannel:secureChannel andMasterSecret:masterSecret];
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
|
||||
s->confirmIv = [CryptoTools generateSecureRandomData:IV_LENGTH];
|
||||
s->dhSharedSecretHashes = [DhPacketSharedSecretHashes dhPacketSharedSecretHashesRandomized];
|
||||
s->allowedKeyAgreementProtocols = [[Environment getCurrent] keyAgreementProtocolsInDescendingPriority];
|
||||
s->allowedKeyAgreementProtocols = Environment.getCurrent.keyAgreementProtocolsInDescendingPriority;
|
||||
s->hashChain = [HashChain hashChainWithSecureGeneratedData];
|
||||
s->badPacketLogger = [[Environment logging] getOccurrenceLoggerForSender:self withKey:@"Bad Packet"];
|
||||
s->badPacketLogger = [Environment.logging getOccurrenceLoggerForSender:self withKey:@"Bad Packet"];
|
||||
|
||||
s->localHello = [HelloPacket helloPacketWithDefaultsAndHashChain:s->hashChain
|
||||
andZid:[SGNKeychainUtil zid]
|
||||
|
@ -140,7 +140,7 @@
|
|||
|
||||
-(id<KeyAgreementParticipant>) retrieveKeyAgreementParticipant{
|
||||
id<KeyAgreementProtocol> matchingKeyAgreeProtocol = [allowedKeyAgreementProtocols firstMatchingElseNil:^int(id<KeyAgreementProtocol> a) {
|
||||
return [[foreignCommit agreementSpecId] isEqualToData:[a getId]];
|
||||
return [[foreignCommit agreementSpecId] isEqualToData:a.getId];
|
||||
}];
|
||||
|
||||
checkOperation(matchingKeyAgreeProtocol != nil);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
DH3KKeyAgreementParticipant* participant = [DH3KKeyAgreementParticipant new];
|
||||
|
||||
participant->protocol = protocol;
|
||||
participant->evpKeyAgreement = [EvpKeyAgreement evpDh3kKeyAgreementWithModulus:[protocol getModulus] andGenerator:[protocol getGenerator]];
|
||||
participant->evpKeyAgreement = [EvpKeyAgreement evpDh3kKeyAgreementWithModulus:protocol.getModulus andGenerator:protocol.getGenerator];
|
||||
return participant;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
|||
}
|
||||
|
||||
-(NSData*) getPublicKeyData{
|
||||
return [self->evpKeyAgreement getPublicKey];
|
||||
return self->evpKeyAgreement.getPublicKey;
|
||||
}
|
||||
|
||||
-(NSData*) calculateKeyAgreementAgainstRemotePublicKey:(NSData*)remotePublicKey{
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
}
|
||||
|
||||
-(NSData*) getPublicKeyData{
|
||||
return [evpKeyAgreement getPublicKey];
|
||||
return evpKeyAgreement.getPublicKey;
|
||||
}
|
||||
|
||||
-(NSData*) calculateKeyAgreementAgainstRemotePublicKey:(NSData*)remotePublicKey{
|
||||
|
|
|
@ -37,15 +37,15 @@
|
|||
|
||||
NSData* dhPart2Data = [[dhPart2 embeddedIntoHandshakePacket] dataUsedForAuthentication];
|
||||
NSData* helloData = [[hello embeddedIntoHandshakePacket] dataUsedForAuthentication];
|
||||
return [CommitPacket commitPacketWithHashChainH2:[hashChain h2]
|
||||
return [CommitPacket commitPacketWithHashChainH2:hashChain.h2
|
||||
andZid:zid
|
||||
andHashSpecId:COMMIT_DEFAULT_HASH_SPEC_ID
|
||||
andCipherSpecId:COMMIT_DEFAULT_CIPHER_SPEC_ID
|
||||
andAuthSpecId:COMMIT_DEFAULT_AUTH_SPEC_ID
|
||||
andAgreeSpecId:[keyAgreementProtocol getId]
|
||||
andAgreeSpecId:keyAgreementProtocol.getId
|
||||
andSasSpecId:COMMIT_DEFAULT_SAS_SPEC_ID
|
||||
andDhPart2HelloCommitment:[[@[dhPart2Data, helloData] concatDatas] hashWithSha256]
|
||||
andHmacKey:[hashChain h1]];
|
||||
andDhPart2HelloCommitment:@[dhPart2Data, helloData].concatDatas.hashWithSha256
|
||||
andHmacKey:hashChain.h1];
|
||||
}
|
||||
|
||||
+(CommitPacket*) commitPacketWithHashChainH2:(NSData*)h2
|
||||
|
@ -100,16 +100,16 @@
|
|||
requireState(agreementSpecId.length == AGREE_SPEC_LENGTH);
|
||||
requireState(sasSpecId.length == SAS_SPEC_LENGTH);
|
||||
|
||||
NSData* payload = [@[
|
||||
NSData* payload = @[
|
||||
h2,
|
||||
[zid getData],
|
||||
zid.getData,
|
||||
hashSpecId,
|
||||
cipherSpecId,
|
||||
authSpecId,
|
||||
agreementSpecId,
|
||||
sasSpecId,
|
||||
dhPart2HelloCommitment
|
||||
] concatDatas];
|
||||
].concatDatas;
|
||||
|
||||
return [[HandshakePacket handshakePacketWithTypeId:HANDSHAKE_TYPE_COMMIT andPayload:payload] withHmacAppended:hmacKey];
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
return [self dhPacketWithHashChainH0:[hashChain h0]
|
||||
andSharedSecretHashes:sharedSecretHashes
|
||||
andPublicKeyData:[agreer getPublicKeyData]
|
||||
andPublicKeyData:agreer.getPublicKeyData
|
||||
andIsPart1:true];
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
|||
|
||||
return [self dhPacketWithHashChainH0:[hashChain h0]
|
||||
andSharedSecretHashes:sharedSecretHashes
|
||||
andPublicKeyData:[agreer getPublicKeyData]
|
||||
andPublicKeyData:agreer.getPublicKeyData
|
||||
andIsPart1:false];
|
||||
}
|
||||
|
||||
|
|
|
@ -42,10 +42,10 @@
|
|||
bool hasDH3k = false;
|
||||
|
||||
for (id<KeyAgreementProtocol> e in keyAgreementProtocols) {
|
||||
if ([[e getId] isEqualToData:COMMIT_DEFAULT_AGREE_SPEC_ID]) {
|
||||
if ([e.getId isEqualToData:COMMIT_DEFAULT_AGREE_SPEC_ID]) {
|
||||
hasDH3k = true;
|
||||
} else {
|
||||
[agreeSpecIds addObject:[e getId]];
|
||||
[agreeSpecIds addObject:e.getId];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,8 @@
|
|||
require(zid != nil);
|
||||
require(keyAgreementProtocols != nil);
|
||||
|
||||
return [HelloPacket helloPacketWithVersion:[Environment getCurrent].zrtpVersionId
|
||||
andClientId:[Environment getCurrent].zrtpClientId
|
||||
return [HelloPacket helloPacketWithVersion:Environment.getCurrent.zrtpVersionId
|
||||
andClientId:Environment.getCurrent.zrtpClientId
|
||||
andHashChainH3:[hashChain h3]
|
||||
andZid:zid
|
||||
andFlags0SMP:0
|
||||
|
@ -155,7 +155,7 @@
|
|||
versionId,
|
||||
clientId,
|
||||
hashChainH3,
|
||||
[zid getData],
|
||||
zid.getData,
|
||||
[self generateFlags],
|
||||
[[@[hashIds, cipherIds, authIds, agreeIds, sasIds] concatArrays] concatDatas]
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
require(resourcePath != nil);
|
||||
require(resourceType != nil);
|
||||
|
||||
NSString *certPath = [[NSBundle mainBundle] pathForResource:resourcePath ofType:resourceType];
|
||||
NSString *certPath = [NSBundle.mainBundle pathForResource:resourcePath ofType:resourceType];
|
||||
NSData *certData = [[NSData alloc] initWithContentsOfFile:certPath];
|
||||
checkOperation(certData != nil);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
require(remoteEndPoint != nil);
|
||||
|
||||
// all connections must be secure, unless testing
|
||||
bool isSecureEndPoint = [remoteEndPoint isKindOfClass:[SecureEndPoint class]];
|
||||
bool isSecureEndPoint = [remoteEndPoint isKindOfClass:SecureEndPoint.class];
|
||||
bool allowTestNonSecure = [Environment hasEnabledTestingOrLegacyOption:ENVIRONMENT_TESTING_OPTION_ALLOW_NETWORK_STREAM_TO_NON_SECURE_END_POINTS];
|
||||
require(allowTestNonSecure || isSecureEndPoint);
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ void onReceivedData(CFSocketRef socket, CFSocketCallBackType type, CFDataRef add
|
|||
[self setupRemoteEndPoint];
|
||||
|
||||
NSRunLoop* runLoop = [ThreadManager lowLatencyThreadRunLoop];
|
||||
CFRunLoopAddSource([runLoop getCFRunLoop], CFSocketCreateRunLoopSource(NULL, socket, 0), kCFRunLoopCommonModes);
|
||||
CFRunLoopAddSource(runLoop.getCFRunLoop, CFSocketCreateRunLoopSource(NULL, socket, 0), kCFRunLoopCommonModes);
|
||||
|
||||
[untilCancelledToken whenCancelledDo:^{
|
||||
@synchronized(self) {
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
m->currentCallStateObservable = [ObservableValueController observableValueControllerWithInitialValue:nil];
|
||||
|
||||
[m->currentCallControllerObservable watchLatestValue:^(CallController* latestValue) {
|
||||
[m->currentCallStateObservable updateValue:[latestValue callState]];
|
||||
} onThread:[NSThread currentThread] untilCancelled:nil];
|
||||
[m->currentCallStateObservable updateValue:latestValue.callState];
|
||||
} onThread:NSThread.currentThread untilCancelled:nil];
|
||||
|
||||
return m;
|
||||
}
|
||||
|
@ -65,14 +65,14 @@
|
|||
TOCFuture* futureCalling = [futureConnected thenTry:^id(CallConnectResult* connectResult) {
|
||||
[callController advanceCallProgressToConversingWithShortAuthenticationString:connectResult.shortAuthenticationString];
|
||||
CallAudioManager *cam = [CallAudioManager callAudioManagerStartedWithAudioSocket:connectResult.audioSocket
|
||||
andErrorHandler:[callController errorHandler]
|
||||
andErrorHandler:callController.errorHandler
|
||||
untilCancelled:lifetime];
|
||||
[callController setCallAudioManager:cam];
|
||||
return nil;
|
||||
}];
|
||||
|
||||
[futureCalling catchDo:^(id error) {
|
||||
[callController errorHandler](error, nil, true);
|
||||
callController.errorHandler(error, nil, true);
|
||||
}];
|
||||
}
|
||||
|
||||
|
@ -82,21 +82,21 @@
|
|||
int64_t prevSession = lastIncomingSessionId;
|
||||
lastIncomingSessionId = session.sessionId;
|
||||
|
||||
if ([[[[currentCallControllerObservable currentValue] callState] futureTermination] isIncomplete]) {
|
||||
if (currentCallControllerObservable.currentValue.callState.futureTermination.isIncomplete) {
|
||||
if (session.sessionId == prevSession) {
|
||||
[Environment errorNoter](@"Ignoring duplicate incoming call signal.", session, false);
|
||||
Environment.errorNoter(@"Ignoring duplicate incoming call signal.", session, false);
|
||||
return;
|
||||
}
|
||||
|
||||
[[[Environment getCurrent] recentCallManager] addMissedCallDueToBusy:session];
|
||||
[Environment.getCurrent.recentCallManager addMissedCallDueToBusy:session];
|
||||
|
||||
[[CallConnectUtil asyncSignalTooBusyToAnswerCallWithSessionDescriptor:session] catchDo:^(id error) {
|
||||
[Environment errorNoter](error, @"Failed to signal busy.", false);
|
||||
Environment.errorNoter(error, @"Failed to signal busy.", false);
|
||||
}];
|
||||
return;
|
||||
}
|
||||
|
||||
Contact* callingContact = [[[Environment getCurrent] contactsManager] latestContactForPhoneNumber:session.initiatorNumber];
|
||||
Contact* callingContact = [Environment.getCurrent.contactsManager latestContactForPhoneNumber:session.initiatorNumber];
|
||||
CallController* callController = [self cancelExistingCallAndInitNewCallWork:false
|
||||
remote:session.initiatorNumber
|
||||
optionalContact:callingContact];
|
||||
|
@ -109,18 +109,18 @@
|
|||
TOCFuture* futureStarted = [futureConnected thenTry:^id(CallConnectResult* connectResult) {
|
||||
[callController advanceCallProgressToConversingWithShortAuthenticationString:connectResult.shortAuthenticationString];
|
||||
CallAudioManager* cam = [CallAudioManager callAudioManagerStartedWithAudioSocket:connectResult.audioSocket
|
||||
andErrorHandler:[callController errorHandler]
|
||||
andErrorHandler:callController.errorHandler
|
||||
untilCancelled:lifetime];
|
||||
[callController setCallAudioManager:cam];
|
||||
return nil;
|
||||
}];
|
||||
|
||||
[futureStarted catchDo:^(id error) {
|
||||
[callController errorHandler](error, nil, true);
|
||||
callController.errorHandler(error, nil, true);
|
||||
}];
|
||||
}
|
||||
-(CallController*) curCallController {
|
||||
return [currentCallControllerObservable currentValue];
|
||||
return currentCallControllerObservable.currentValue;
|
||||
}
|
||||
-(void) answerCall {
|
||||
[[self curCallController] acceptCall];
|
||||
|
|
|
@ -38,7 +38,7 @@ static NSString *const RPDefaultsKeyPhoneNumberCanonical = @"RPDefaultsKeyPhoneN
|
|||
require(text != nil);
|
||||
|
||||
return [PhoneNumber phoneNumberFromText:text
|
||||
andRegion:[Environment currentRegionCodeForPhoneNumbers]];
|
||||
andRegion:Environment.currentRegionCodeForPhoneNumbers];
|
||||
}
|
||||
|
||||
+(PhoneNumber*) phoneNumberFromE164:(NSString*)text {
|
||||
|
@ -53,7 +53,7 @@ static NSString *const RPDefaultsKeyPhoneNumberCanonical = @"RPDefaultsKeyPhoneN
|
|||
|
||||
+(NSString*) bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:(NSString*)input {
|
||||
return [PhoneNumber bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:input
|
||||
withSpecifiedRegionCode:[Environment currentRegionCodeForPhoneNumbers]];
|
||||
withSpecifiedRegionCode:Environment.currentRegionCodeForPhoneNumbers];
|
||||
}
|
||||
|
||||
+(NSString*) bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:(NSString*)input withSpecifiedCountryCodeString:(NSString *)countryCodeString{
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
-(ErrorHandlerBlock) errorHandler {
|
||||
return ^(id error, id relatedInfo, bool causedTermination) {
|
||||
if (causedTermination) {
|
||||
if ([error isKindOfClass:[CallTermination class]]) {
|
||||
if ([error isKindOfClass:CallTermination.class]) {
|
||||
CallTermination* t = error;
|
||||
[self terminateWithReason:t.type
|
||||
withFailureInfo:t.failure
|
||||
|
@ -56,7 +56,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
[Environment errorNoter](error, relatedInfo, causedTermination);
|
||||
Environment.errorNoter(error, relatedInfo, causedTermination);
|
||||
};
|
||||
}
|
||||
-(TOCCancelToken*) untilCancelledToken {
|
||||
|
@ -111,7 +111,7 @@
|
|||
}
|
||||
|
||||
-(void)terminateWithRejectionOrRemoteHangupAndFailureInfo:(id)failureInfo andRelatedInfo:(id)relatedInfo {
|
||||
enum CallProgressType progressType = ((CallProgress*)[progress currentValue]).type;
|
||||
enum CallProgressType progressType = ((CallProgress*)progress.currentValue).type;
|
||||
bool hasAcceptedAlready = progressType > CallProgressType_Ringing;
|
||||
enum CallTerminationType terminationType = hasAcceptedAlready
|
||||
? CallTerminationType_HangupRemote
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
}
|
||||
|
||||
-(BOOL)isEqual:(id)object {
|
||||
return [object isKindOfClass:[CallProgress class]] && ((CallProgress*)object).type == type;
|
||||
return [object isKindOfClass:CallProgress.class] && ((CallProgress*)object).type == type;
|
||||
}
|
||||
-(NSUInteger)hash {
|
||||
return type;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
}
|
||||
|
||||
-(BOOL)isEqual:(id)object {
|
||||
return [object isKindOfClass:[CallTermination class]] && ((CallTermination*)object).type == type;
|
||||
return [object isKindOfClass:CallTermination.class] && ((CallTermination*)object).type == type;
|
||||
}
|
||||
-(NSUInteger)hash {
|
||||
return type;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
TOCFuture* futureSignalConnection = [CallConnectUtil_Server asyncConnectToDefaultSignalingServerUntilCancelled:callController.untilCancelledToken];
|
||||
|
||||
return [futureSignalConnection thenTry:^(HttpManager* httpManager) {
|
||||
requireState([httpManager isKindOfClass:[HttpManager class]]);
|
||||
requireState([httpManager isKindOfClass:HttpManager.class]);
|
||||
|
||||
TOCFutureSource* predeclaredFutureSession = [TOCFutureSource new];
|
||||
|
||||
|
@ -43,14 +43,14 @@
|
|||
};
|
||||
|
||||
[httpManager startWithRequestHandler:serverRequestHandler
|
||||
andErrorHandler:[callController errorHandler]
|
||||
andErrorHandler:callController.errorHandler
|
||||
untilCancelled:[callController untilCancelledToken]];
|
||||
|
||||
HttpRequest* initiateRequest = [HttpRequest httpRequestToInitiateToRemoteNumber:[callController callState].remoteNumber];
|
||||
HttpRequest* initiateRequest = [HttpRequest httpRequestToInitiateToRemoteNumber:callController.callState.remoteNumber];
|
||||
TOCFuture* futureResponseToInitiate = [httpManager asyncOkResponseForRequest:initiateRequest
|
||||
unlessCancelled:[callController untilCancelledToken]];
|
||||
TOCFuture* futureResponseToInitiateWithInterpretedFailures = [futureResponseToInitiate catchTry:^(id error) {
|
||||
if ([error isKindOfClass:[HttpResponse class]]) {
|
||||
if ([error isKindOfClass:HttpResponse.class]) {
|
||||
HttpResponse* badResponse = error;
|
||||
return [TOCFuture futureWithFailure:[self callTerminationForBadResponse:badResponse
|
||||
toInitiateRequest:initiateRequest]];
|
||||
|
@ -60,7 +60,7 @@
|
|||
}];
|
||||
|
||||
TOCFuture* futureSession = [futureResponseToInitiateWithInterpretedFailures thenTry:^(HttpResponse* response) {
|
||||
return [InitiatorSessionDescriptor initiatorSessionDescriptorFromJson:[response getOptionalBodyText]];
|
||||
return [InitiatorSessionDescriptor initiatorSessionDescriptorFromJson:response.getOptionalBodyText];
|
||||
}];
|
||||
[predeclaredFutureSession trySetResult:futureSession];
|
||||
|
||||
|
@ -73,7 +73,7 @@
|
|||
require(badResponse != nil);
|
||||
require(initiateRequest != nil);
|
||||
|
||||
switch ([badResponse getStatusCode]) {
|
||||
switch (badResponse.getStatusCode) {
|
||||
case SIGNAL_STATUS_CODE_NO_SUCH_USER:
|
||||
return [CallTermination callTerminationOfType:CallTerminationType_NoSuchUser
|
||||
withFailure:badResponse
|
||||
|
@ -81,7 +81,7 @@
|
|||
case SIGNAL_STATUS_CODE_SERVER_MESSAGE:
|
||||
return [CallTermination callTerminationOfType:CallTerminationType_ServerMessage
|
||||
withFailure:badResponse
|
||||
andMessageInfo:[badResponse getOptionalBodyText]];
|
||||
andMessageInfo:badResponse.getOptionalBodyText];
|
||||
case SIGNAL_STATUS_CODE_LOGIN_FAILED:
|
||||
return [CallTermination callTerminationOfType:CallTerminationType_LoginFailed
|
||||
withFailure:badResponse
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
untilCancelled:[callController untilCancelledToken]];
|
||||
|
||||
return [futureSignalConnection thenTry:^id(HttpManager* httpManager) {
|
||||
require([httpManager isKindOfClass:[httpManager class]]);
|
||||
require([httpManager isKindOfClass:httpManager.class]);
|
||||
|
||||
HttpResponse*(^serverRequestHandler)(HttpRequest*) = ^(HttpRequest* remoteRequest) {
|
||||
return [self respondToServerRequest:remoteRequest
|
||||
|
@ -49,14 +49,14 @@
|
|||
};
|
||||
|
||||
[httpManager startWithRequestHandler:serverRequestHandler
|
||||
andErrorHandler:[Environment errorNoter]
|
||||
andErrorHandler:Environment.errorNoter
|
||||
untilCancelled:[callController untilCancelledToken]];
|
||||
|
||||
HttpRequest* ringRequest = [HttpRequest httpRequestToRingWithSessionId:sessionDescriptor.sessionId];
|
||||
TOCFuture* futureResponseToRing = [httpManager asyncOkResponseForRequest:ringRequest
|
||||
unlessCancelled:[callController untilCancelledToken]];
|
||||
TOCFuture* futureResponseToRingWithInterpretedFailures = [futureResponseToRing catchTry:^(id error) {
|
||||
if ([error isKindOfClass:[HttpResponse class]]) {
|
||||
if ([error isKindOfClass:HttpResponse.class]) {
|
||||
HttpResponse* badResponse = error;
|
||||
return [TOCFuture futureWithFailure:[self callTerminationForBadResponse:badResponse
|
||||
toRingRequest:ringRequest]];
|
||||
|
@ -74,7 +74,7 @@
|
|||
require(badResponse != nil);
|
||||
require(ringRequest != nil);
|
||||
|
||||
switch ([badResponse getStatusCode]) {
|
||||
switch (badResponse.getStatusCode) {
|
||||
case SIGNAL_STATUS_CODE_STALE_SESSION:
|
||||
return [CallTermination callTerminationOfType:CallTerminationType_StaleSession
|
||||
withFailure:badResponse
|
||||
|
@ -124,7 +124,7 @@
|
|||
return [self asyncOkResponseFor:busyRequest
|
||||
fromSignalingServerNamed:sessionDescriptor.relayServerName
|
||||
unlessCancelled:nil
|
||||
andErrorHandler:[Environment errorNoter]];
|
||||
andErrorHandler:Environment.errorNoter];
|
||||
}
|
||||
|
||||
+(TOCFuture*) asyncOkResponseFor:(HttpRequest*)request
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
@implementation CallConnectUtil_Server
|
||||
|
||||
+(TOCFuture*) asyncConnectToDefaultSignalingServerUntilCancelled:(TOCCancelToken*)untilCancelledToken {
|
||||
return [self asyncConnectToSignalingServerAt:[Environment getSecureEndPointToDefaultRelayServer]
|
||||
return [self asyncConnectToSignalingServerAt:Environment.getSecureEndPointToDefaultRelayServer
|
||||
untilCancelled:untilCancelledToken];
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@
|
|||
NSArray* interopOptions = session.interopVersion == 0
|
||||
? @[ENVIRONMENT_LEGACY_OPTION_RTP_PADDING_BIT_IMPLIES_EXTENSION_BIT_AND_TWELVE_EXTRA_ZERO_BYTES_IN_HEADER]
|
||||
: @[];
|
||||
if (session.interopVersion > 1) [Environment errorNoter](@"Newer-than-code interop version specified.", session, false);
|
||||
if (session.interopVersion > 1) Environment.errorNoter(@"Newer-than-code interop version specified.", session, false);
|
||||
|
||||
return [self asyncConnectCallOverRelayDescribedInInitiatorSessionDescriptor:equivalentSession
|
||||
withCallController:callController
|
||||
|
@ -95,7 +95,7 @@
|
|||
TOCUntilOperation operation = ^(TOCCancelToken* internalUntilCancelledToken) {
|
||||
return [self asyncAttemptResolveThenConnectToUdpRelayDescribedBy:sessionDescriptor
|
||||
untilCancelled:internalUntilCancelledToken
|
||||
withErrorHandler:[callController errorHandler]];
|
||||
withErrorHandler:callController.errorHandler];
|
||||
};
|
||||
|
||||
TOCFuture* futureRelayedUdpSocket = [TOCFuture retry:[TOCFuture operationTry:operation]
|
||||
|
@ -118,7 +118,7 @@
|
|||
require(sessionDescriptor != nil);
|
||||
require(errorHandler != nil);
|
||||
|
||||
NSString* domain = [Environment relayServerNameToHostName:[sessionDescriptor relayServerName]];
|
||||
NSString* domain = [Environment relayServerNameToHostName:sessionDescriptor.relayServerName];
|
||||
|
||||
TOCFuture* futureDnsResult = [DnsManager asyncQueryAddressesForDomainName:domain
|
||||
unlessCancelled:untilCancelledToken];
|
||||
|
@ -149,7 +149,7 @@
|
|||
|
||||
UdpSocket* udpSocket = [UdpSocket udpSocketTo:remoteEndPoint];
|
||||
|
||||
id<OccurrenceLogger> logger = [[Environment logging] getOccurrenceLoggerForSender:self withKey:@"relay setup"];
|
||||
id<OccurrenceLogger> logger = [Environment.logging getOccurrenceLoggerForSender:self withKey:@"relay setup"];
|
||||
|
||||
TOCFuture* futureFirstResponseData = [self asyncFirstPacketReceivedAfterStartingSocket:udpSocket
|
||||
untilCancelled:untilCancelledToken
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
id jsonSessionId = fields[SessionIdKey];
|
||||
id jsonRelayPort = fields[RelayPortKey];
|
||||
id jsonRelayName = fields[RelayHostKey];
|
||||
checkOperationDescribe([jsonSessionId isKindOfClass:[NSNumber class]], @"Unexpected json data");
|
||||
checkOperationDescribe([jsonRelayPort isKindOfClass:[NSNumber class]], @"Unexpected json data");
|
||||
checkOperationDescribe([jsonRelayName isKindOfClass:[NSString class]], @"Unexpected json data");
|
||||
checkOperationDescribe([jsonSessionId isKindOfClass:NSNumber.class], @"Unexpected json data");
|
||||
checkOperationDescribe([jsonRelayPort isKindOfClass:NSNumber.class], @"Unexpected json data");
|
||||
checkOperationDescribe([jsonRelayName isKindOfClass:NSString.class], @"Unexpected json data");
|
||||
checkOperationDescribe([jsonRelayPort unsignedShortValue] > 0, @"Unexpected json data");
|
||||
|
||||
int64_t sessionId = [[jsonSessionId description] longLongValue]; // workaround: asking for longLongValue directly causes rounding-through-double
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
checkOperation(data.length >= HMAC_TRUNCATED_SIZE);
|
||||
NSData* includedMac = [data takeLast:HMAC_TRUNCATED_SIZE];
|
||||
NSData* payload = [data skipLast:HMAC_TRUNCATED_SIZE];
|
||||
NSData* signalingMacKey = [SGNKeychainUtil signalingMacKey];
|
||||
NSData* signalingMacKey = SGNKeychainUtil.signalingMacKey;
|
||||
require(signalingMacKey != nil);
|
||||
NSData* computedMac = [[payload hmacWithSha1WithKey:signalingMacKey] takeLast:HMAC_TRUNCATED_SIZE];
|
||||
checkOperation([includedMac isEqualToData_TimingSafe:computedMac]);
|
||||
|
@ -98,7 +98,7 @@
|
|||
+(NSData*) decryptRemoteNotificationData:(NSData*)data {
|
||||
require(data != nil);
|
||||
checkOperation(data.length >= VERSION_SIZE + IV_SIZE);
|
||||
NSData* cipherKey = [SGNKeychainUtil signalingCipherKey];
|
||||
NSData* cipherKey = SGNKeychainUtil.signalingCipherKey;
|
||||
require(cipherKey != nil);
|
||||
NSData* iv = [data subdataWithRange:NSMakeRange(VERSION_SIZE, IV_SIZE)];
|
||||
NSData* cipherText = [data skip:VERSION_SIZE+IV_SIZE];
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
if (![self.location hasPrefix:@"/session/"]) return nil;
|
||||
|
||||
NSString* sessionIdText = [self.location substringFromIndex:@"/session/".length];
|
||||
sessionIdText = [sessionIdText stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||
sessionIdText = [sessionIdText stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet];
|
||||
NSNumber* sessionIdNumber = [sessionIdText tryParseAsDecimalNumber];
|
||||
|
||||
if (sessionIdNumber.hasLongLongValue) return sessionIdNumber;
|
||||
|
@ -32,15 +32,15 @@
|
|||
}
|
||||
|
||||
-(bool) isRingingForSession:(int64_t)targetSessionId {
|
||||
return [self.method isEqualToString:@"RING"] && [@(targetSessionId) isEqualToNumber:[self tryGetSessionId]];
|
||||
return [self.method isEqualToString:@"RING"] && [@(targetSessionId) isEqualToNumber:self.tryGetSessionId];
|
||||
}
|
||||
|
||||
-(bool) isHangupForSession:(int64_t)targetSessionId {
|
||||
return [self.method isEqualToString:@"DELETE"] && [@(targetSessionId) isEqualToNumber:[self tryGetSessionId]];
|
||||
return [self.method isEqualToString:@"DELETE"] && [@(targetSessionId) isEqualToNumber:self.tryGetSessionId];
|
||||
}
|
||||
|
||||
-(bool) isBusyForSession:(int64_t)targetSessionId {
|
||||
return [self.method isEqualToString:@"BUSY"] && [@(targetSessionId) isEqualToNumber:[self tryGetSessionId]];
|
||||
return [self.method isEqualToString:@"BUSY"] && [@(targetSessionId) isEqualToNumber:self.tryGetSessionId];
|
||||
}
|
||||
|
||||
+(HttpRequest*) httpRequestToOpenPortWithSessionId:(int64_t)sessionId {
|
||||
|
@ -84,11 +84,11 @@
|
|||
NSString* query = [NSString stringWithFormat:@"/users/verification/%@", localPhoneNumber.toE164];
|
||||
[SGNKeychainUtil generateSignaling];
|
||||
|
||||
NSData* signalingCipherKey = [SGNKeychainUtil signalingCipherKey];
|
||||
NSData* signalingMacKey = [SGNKeychainUtil signalingMacKey];
|
||||
NSData* signalingExtraKeyData = [SGNKeychainUtil signalingCipherKey];
|
||||
NSString* encodedSignalingKey = [[@[signalingCipherKey, signalingMacKey, signalingExtraKeyData] concatDatas] encodedAsBase64];
|
||||
NSString* body = [@{@"key" : encodedSignalingKey, @"challenge" : challenge} encodedAsJson];
|
||||
NSData* signalingCipherKey = SGNKeychainUtil.signalingCipherKey;
|
||||
NSData* signalingMacKey = SGNKeychainUtil.signalingMacKey;
|
||||
NSData* signalingExtraKeyData = SGNKeychainUtil.signalingCipherKey;
|
||||
NSString* encodedSignalingKey = @[signalingCipherKey, signalingMacKey, signalingExtraKeyData].concatDatas.encodedAsBase64;
|
||||
NSString* body = @{@"key" : encodedSignalingKey, @"challenge" : challenge}.encodedAsJson;
|
||||
|
||||
return [HttpRequest httpRequestWithBasicAuthenticationAndMethod:@"PUT"
|
||||
andLocation:query
|
||||
|
|
|
@ -37,13 +37,13 @@
|
|||
|
||||
checkOperation(response.isOkResponse);
|
||||
|
||||
NSString* hashCountHeader = [response getHeaders][HASH_COUNT_HEADER_KEY];
|
||||
NSString* hashCountHeader = response.getHeaders[HASH_COUNT_HEADER_KEY];
|
||||
checkOperation(hashCountHeader != nil);
|
||||
|
||||
int hashCountValue = [hashCountHeader intValue];
|
||||
checkOperation(hashCountValue > 0);
|
||||
|
||||
NSData* responseBody = [response getOptionalBodyData];
|
||||
NSData* responseBody = response.getOptionalBodyData;
|
||||
checkOperation(responseBody.length > 0);
|
||||
|
||||
BloomFilter* bloomFilter = [BloomFilter bloomFilterWithHashCount:(NSUInteger)hashCountValue
|
||||
|
|
|
@ -19,16 +19,16 @@
|
|||
|
||||
-(id) init {
|
||||
if (self = [super init]) {
|
||||
phoneNumberDirectoryFilter = [PhoneNumberDirectoryFilter phoneNumberDirectoryFilterDefault];
|
||||
phoneNumberDirectoryFilter = PhoneNumberDirectoryFilter.phoneNumberDirectoryFilterDefault;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void) startUntilCancelled:(TOCCancelToken*)cancelToken {
|
||||
lifetimeToken = cancelToken;
|
||||
|
||||
phoneNumberDirectoryFilter = [[Environment preferences] tryGetSavedPhoneNumberDirectory];
|
||||
phoneNumberDirectoryFilter = [Environment.preferences tryGetSavedPhoneNumberDirectory];
|
||||
if (phoneNumberDirectoryFilter == nil) {
|
||||
phoneNumberDirectoryFilter = [PhoneNumberDirectoryFilter phoneNumberDirectoryFilterDefault];
|
||||
phoneNumberDirectoryFilter = PhoneNumberDirectoryFilter.phoneNumberDirectoryFilterDefault;
|
||||
}
|
||||
|
||||
[self scheduleUpdate];
|
||||
|
@ -65,7 +65,7 @@
|
|||
|
||||
TOCFuture* futureDirectoryResponse = [HttpManager asyncOkResponseFromMasterServer:directoryRequest
|
||||
unlessCancelled:untilCancelledToken
|
||||
andErrorHandler:[Environment errorNoter]];
|
||||
andErrorHandler:Environment.errorNoter];
|
||||
|
||||
return [futureDirectoryResponse thenTry:^(HttpResponse* response) {
|
||||
return [PhoneNumberDirectoryFilter phoneNumberDirectoryFilterFromHttpResponse:response];
|
||||
|
@ -87,7 +87,7 @@
|
|||
-(void) signalDirectoryQueryFailed:(id)failure {
|
||||
NSString* desc = [NSString stringWithFormat:@"Failed to retrieve directory. Retrying in %f hours.",
|
||||
DIRECTORY_UPDATE_RETRY_PERIOD/HOUR];
|
||||
[Environment errorNoter](desc, failure, false);
|
||||
Environment.errorNoter(desc, failure, false);
|
||||
}
|
||||
-(TOCFuture*) asyncQueryCurrentDirectoryWithDefaultOnFail {
|
||||
TOCFuture* futureDirectory = [self asyncQueryCurrentDirectory];
|
||||
|
@ -105,7 +105,7 @@
|
|||
@synchronized(self) {
|
||||
phoneNumberDirectoryFilter = directory;
|
||||
}
|
||||
[[Environment preferences] setSavedPhoneNumberDirectory:directory];
|
||||
[Environment.preferences setSavedPhoneNumberDirectory:directory];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_DIRECTORY_WAS_UPDATED object:nil];
|
||||
[self scheduleUpdate];
|
||||
}];
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
id<ValueLogger> norm = [logging getValueLoggerForValue:valueIdentity from:sender];
|
||||
return [AnonymousValueLogger anonymousValueLogger:^(double value) {
|
||||
[estimator updateWithNextSample:value];
|
||||
[norm logValue:[estimator currentEstimate]];
|
||||
[norm logValue:estimator.currentEstimate];
|
||||
}];
|
||||
}
|
||||
+(id<ValueLogger>) getMagnitudeDecayingToZeroValueLoggerTo:(id<Logging>)logging named:(id)valueIdentity from:(id)sender withDecayFactor:(double)decayFactorPerSample {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
-(NSData*) concatDatas {
|
||||
NSUInteger t = 0;
|
||||
for (id d in self) {
|
||||
require([d isKindOfClass:[NSData class]]);
|
||||
require([d isKindOfClass:NSData.class]);
|
||||
t += [(NSData*)d length];
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
|||
-(NSArray*) concatArrays {
|
||||
NSMutableArray* r = [NSMutableArray array];
|
||||
for (id e in self) {
|
||||
require([e isKindOfClass:[NSArray class]]);
|
||||
require([e isKindOfClass:NSArray.class]);
|
||||
[r addObjectsFromArray:e];
|
||||
}
|
||||
return r;
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
@try {
|
||||
action();
|
||||
} @catch (id ex) {
|
||||
[[[Environment logging] getConditionLoggerForSender:self]
|
||||
[[Environment.logging getConditionLoggerForSender:self]
|
||||
logError:@"A queued action failed and may have stalled an ObservableValue."];
|
||||
@synchronized(self) {
|
||||
isRunningActions = false;
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
-(void) performOnThread:(NSThread*)thread {
|
||||
require(thread != nil);
|
||||
[self performSelector:@selector(run) onThread:thread withObject:nil waitUntilDone:thread == [NSThread currentThread]];
|
||||
[self performSelector:@selector(run) onThread:thread withObject:nil waitUntilDone:thread == NSThread.currentThread];
|
||||
}
|
||||
|
||||
-(void) performOnThreadAndWaitUntilDone:(NSThread*)thread {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
+ (NSString *)countryNameFromCountryCode:(NSString *)code {
|
||||
NSDictionary *countryCodeComponent = @{NSLocaleCountryCode: code};
|
||||
NSString *identifier = [NSLocale localeIdentifierFromComponents:countryCodeComponent];
|
||||
NSString *country = [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier
|
||||
NSString *country = [NSLocale.currentLocale displayNameForKey:NSLocaleIdentifier
|
||||
value:identifier];
|
||||
return country;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
}
|
||||
|
||||
- (void)sendSMSInviteToNumber:(PhoneNumber *)number{
|
||||
if ([MFMessageComposeViewController canSendText] && [[UIDevice currentDevice].model isEqualToString:@"iPhone"]){
|
||||
if (MFMessageComposeViewController.canSendText && [UIDevice.currentDevice.model isEqualToString:@"iPhone"]){
|
||||
MFMessageComposeViewController *messageController = [MFMessageComposeViewController new];
|
||||
|
||||
NSString *inviteMessage = INVITE_USERS_MESSAGE;
|
||||
|
|
|
@ -68,14 +68,14 @@
|
|||
NSError* jsonParseError = nil;
|
||||
id parsedJson = [NSJSONSerialization dataWithJSONObject:self.encodedAsUtf8 options:0 error:&jsonParseError];
|
||||
checkOperationDescribe(jsonParseError == nil, ([NSString stringWithFormat:@"Invalid json: %@", self]));
|
||||
checkOperationDescribe([parsedJson isKindOfClass:[NSData class]], @"Unexpected json data");
|
||||
checkOperationDescribe([parsedJson isKindOfClass:NSData.class], @"Unexpected json data");
|
||||
return parsedJson;
|
||||
}
|
||||
-(NSDictionary*) decodedAsJsonIntoDictionary {
|
||||
NSError* jsonParseError = nil;
|
||||
id parsedJson = [NSJSONSerialization JSONObjectWithData:self.encodedAsUtf8 options:0 error:&jsonParseError];
|
||||
checkOperationDescribe(jsonParseError == nil, ([NSString stringWithFormat:@"Json parse error: %@, on json: %@", jsonParseError, self]));
|
||||
checkOperationDescribe([parsedJson isKindOfClass:[NSDictionary class]], @"Unexpected json data");
|
||||
checkOperationDescribe([parsedJson isKindOfClass:NSDictionary.class], @"Unexpected json data");
|
||||
return parsedJson;
|
||||
}
|
||||
-(NSData*) decodedAsBase64Data {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
[instance->thread start];
|
||||
|
||||
[Operation asyncRunAndWaitUntilDone:^{
|
||||
instance->runLoop = [NSRunLoop currentRunLoop];
|
||||
instance->runLoop = NSRunLoop.currentRunLoop;
|
||||
} onThread:instance->thread];
|
||||
|
||||
return instance;
|
||||
|
@ -27,8 +27,8 @@
|
|||
[thread cancel];
|
||||
}
|
||||
-(void) runLoopUntilCancelled {
|
||||
NSThread* curThread = [NSThread currentThread];
|
||||
NSRunLoop* curRunLoop = [NSRunLoop currentRunLoop];
|
||||
NSThread* curThread = NSThread.currentThread;
|
||||
NSRunLoop* curRunLoop = NSRunLoop.currentRunLoop;
|
||||
while (!curThread.isCancelled) {
|
||||
[curRunLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:5]];
|
||||
}
|
||||
|
|
|
@ -55,11 +55,11 @@ typedef NSComparisonResult (^CallComparator)(RecentCall*, RecentCall*);
|
|||
}
|
||||
|
||||
- (void)observeRecentCalls {
|
||||
ObservableValue *observableRecents = [[[Environment getCurrent] recentCallManager] getObservableRecentCalls];
|
||||
ObservableValue *observableRecents = Environment.getCurrent.recentCallManager.getObservableRecentCalls;
|
||||
|
||||
[observableRecents watchLatestValue:^(NSArray *latestRecents) {
|
||||
if (_searchTerm) {
|
||||
_recents = [[[Environment getCurrent] recentCallManager] recentsForSearchString:_searchTerm
|
||||
_recents = [Environment.getCurrent.recentCallManager recentsForSearchString:_searchTerm
|
||||
andExcludeArchived:NO];
|
||||
} else {
|
||||
_recents = latestRecents;
|
||||
|
@ -68,7 +68,7 @@ typedef NSComparisonResult (^CallComparator)(RecentCall*, RecentCall*);
|
|||
if (!_tableViewContentMutating) {
|
||||
[_recentCallsTableView reloadData];
|
||||
}
|
||||
} onThread:[NSThread mainThread] untilCancelled:nil];
|
||||
} onThread:NSThread.mainThread untilCancelled:nil];
|
||||
}
|
||||
|
||||
- (void)deleteRecentCallAtIndexPath:(NSIndexPath *)indexPath {
|
||||
|
@ -79,7 +79,7 @@ typedef NSComparisonResult (^CallComparator)(RecentCall*, RecentCall*);
|
|||
RecentCall *recent;
|
||||
|
||||
|
||||
[[[Environment getCurrent] recentCallManager] removeRecentCall:recent];
|
||||
[Environment.getCurrent.recentCallManager removeRecentCall:recent];
|
||||
|
||||
[_recentCallsTableView endUpdates];
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ typedef NSComparisonResult (^CallComparator)(RecentCall*, RecentCall*);
|
|||
withRowAnimation:UITableViewRowAnimationLeft];
|
||||
|
||||
RecentCall *recent = _recents[(NSUInteger)indexPath.row];
|
||||
[[[Environment getCurrent] recentCallManager] removeRecentCall:recent];
|
||||
[Environment.getCurrent.recentCallManager removeRecentCall:recent];
|
||||
|
||||
[_recentCallsTableView endUpdates];
|
||||
_tableViewContentMutating = NO;
|
||||
|
@ -134,7 +134,7 @@ typedef NSComparisonResult (^CallComparator)(RecentCall*, RecentCall*);
|
|||
|
||||
- (void)searchBarTitleView:(SearchBarTitleView *)view didSearchForTerm:(NSString *)term {
|
||||
_searchTerm = term;
|
||||
_recents = [[[Environment getCurrent] recentCallManager] recentsForSearchString:term
|
||||
_recents = [Environment.getCurrent.recentCallManager recentsForSearchString:term
|
||||
andExcludeArchived:NO];
|
||||
[_recentCallsTableView reloadData];
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ typedef NSComparisonResult (^CallComparator)(RecentCall*, RecentCall*);
|
|||
|
||||
- (void)searchBarTitleViewDidEndSearching:(SearchBarTitleView *)view {
|
||||
_searchTerm = nil;
|
||||
_recents = [[[Environment getCurrent] recentCallManager] recentsForSearchString:nil
|
||||
_recents = [Environment.getCurrent.recentCallManager recentsForSearchString:nil
|
||||
andExcludeArchived:NO];
|
||||
[_recentCallsTableView reloadData];
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
|
|||
[self.navigationController setNavigationBarHidden:YES animated:NO];
|
||||
[_contactTableView reloadData];
|
||||
[_searchBarTitleView updateAutoCorrectionType];
|
||||
[[Environment getCurrent].contactsManager enableNewUserNotifications];
|
||||
[Environment.getCurrent.contactsManager enableNewUserNotifications];
|
||||
|
||||
BOOL showNotificationView = _newWhisperUsers != nil;
|
||||
if (showNotificationView) {
|
||||
|
@ -152,12 +152,12 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
|
|||
#pragma mark - Contact functions
|
||||
|
||||
- (void)setupContacts {
|
||||
ObservableValue *observableContacts = [[[Environment getCurrent] contactsManager] getObservableWhisperUsers];
|
||||
ObservableValue *observableContacts = Environment.getCurrent.contactsManager.getObservableWhisperUsers;
|
||||
|
||||
[observableContacts watchLatestValue:^(NSArray *latestContacts) {
|
||||
_latestContacts = latestContacts;
|
||||
[self onSearchOrContactChange:nil];
|
||||
} onThread:[NSThread mainThread] untilCancelled:nil];
|
||||
} onThread:NSThread.mainThread untilCancelled:nil];
|
||||
}
|
||||
|
||||
- (NSArray *)contactsForSectionIndex:(NSUInteger)index {
|
||||
|
@ -251,7 +251,7 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
|
|||
#pragma mark - Refresh controls
|
||||
|
||||
- (void)refreshContacts{
|
||||
[[[Environment getCurrent] phoneDirectoryManager] forceUpdate];
|
||||
[Environment.getCurrent.phoneDirectoryManager forceUpdate];
|
||||
self.refreshTimer = [NSTimer scheduledTimerWithTimeInterval:REFRESH_TIMEOUT target:self selector:@selector(contactRefreshDidTimeout) userInfo:nil repeats:NO];
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ static NSString *const FAVOURITE_FALSE_ICON_NAME = @"favourite_false_icon";
|
|||
|
||||
if (_contact) {
|
||||
self.navigationController.navigationBar.barTintColor = [UIUtil darkBackgroundColor];
|
||||
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
|
||||
self.navigationController.navigationBar.tintColor = UIColor.whiteColor;
|
||||
self.navigationController.navigationBar.translucent = NO;
|
||||
_contactNameLabel.text = _contact.fullName;
|
||||
if (_contact.image) {
|
||||
|
@ -68,7 +68,7 @@ static NSString *const FAVOURITE_FALSE_ICON_NAME = @"favourite_false_icon";
|
|||
if ((NSUInteger)indexPath.row < _contact.userTextPhoneNumbers.count) {
|
||||
|
||||
PhoneNumber *phoneNumber = [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:_contact.userTextPhoneNumbers[(NSUInteger)indexPath.row]];
|
||||
BOOL isSecure = [[[[Environment getCurrent] phoneDirectoryManager] getCurrentFilter] containsPhoneNumber:phoneNumber];
|
||||
BOOL isSecure = [Environment.getCurrent.phoneDirectoryManager.getCurrentFilter containsPhoneNumber:phoneNumber];
|
||||
[cell configureWithPhoneNumber:phoneNumber isSecure:isSecure];
|
||||
|
||||
} else if ((NSUInteger)indexPath.row < _contact.userTextPhoneNumbers.count + _contact.emails.count) {
|
||||
|
@ -118,7 +118,7 @@ static NSString *const FAVOURITE_FALSE_ICON_NAME = @"favourite_false_icon";
|
|||
}
|
||||
|
||||
- (void)favouriteButtonTapped {
|
||||
[[[Environment getCurrent] contactsManager] toggleFavourite:_contact];
|
||||
[Environment.getCurrent.contactsManager toggleFavourite:_contact];
|
||||
[self configureFavouritesButton];
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ static NSString *const FAVOURITE_FALSE_ICON_NAME = @"favourite_false_icon";
|
|||
style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(favouriteButtonTapped)];
|
||||
self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
|
||||
self.navigationItem.rightBarButtonItem.tintColor = UIColor.whiteColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,11 +152,11 @@ static NSString *const FAVOURITE_FALSE_ICON_NAME = @"favourite_false_icon";
|
|||
}
|
||||
|
||||
- (void)startSecureCallWithNumber:(PhoneNumber *)number {
|
||||
[[Environment phoneManager] initiateOutgoingCallToContact:_contact atRemoteNumber:number];
|
||||
[Environment.phoneManager initiateOutgoingCallToContact:_contact atRemoteNumber:number];
|
||||
}
|
||||
|
||||
- (BOOL)phoneNumberIsSecure:(PhoneNumber *)phoneNumber {
|
||||
PhoneNumberDirectoryFilter* directory = [[[Environment getCurrent] phoneDirectoryManager] getCurrentFilter];
|
||||
PhoneNumberDirectoryFilter* directory = Environment.getCurrent.phoneDirectoryManager.getCurrentFilter;
|
||||
return phoneNumber != nil && [directory containsPhoneNumber:phoneNumber];
|
||||
}
|
||||
|
||||
|
|
|
@ -111,9 +111,9 @@
|
|||
}
|
||||
|
||||
- (void)callButtonTapped {
|
||||
PhoneNumber *phoneNumber = [self phoneNumberForCurrentInput];
|
||||
PhoneNumber *phoneNumber = self.phoneNumberForCurrentInput;
|
||||
|
||||
BOOL shouldTryCall = [[[[Environment getCurrent] phoneDirectoryManager] getCurrentFilter] containsPhoneNumber:phoneNumber] || [[Environment getCurrent].recentCallManager isPhoneNumberPresentInRecentCalls:phoneNumber];
|
||||
BOOL shouldTryCall = [Environment.getCurrent.phoneDirectoryManager.getCurrentFilter containsPhoneNumber:phoneNumber] || [Environment.getCurrent.recentCallManager isPhoneNumberPresentInRecentCalls:phoneNumber];
|
||||
|
||||
if( shouldTryCall){
|
||||
[self initiateCallToPhoneNumber:phoneNumber];
|
||||
|
@ -124,10 +124,10 @@
|
|||
|
||||
-(void) initiateCallToPhoneNumber:(PhoneNumber*) phoneNumber {
|
||||
if (_contact) {
|
||||
[[Environment phoneManager] initiateOutgoingCallToContact:_contact
|
||||
[Environment.phoneManager initiateOutgoingCallToContact:_contact
|
||||
atRemoteNumber:phoneNumber];
|
||||
} else {
|
||||
[[Environment phoneManager] initiateOutgoingCallToRemoteNumber:phoneNumber];
|
||||
[Environment.phoneManager initiateOutgoingCallToRemoteNumber:phoneNumber];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@
|
|||
|
||||
- (void)tryUpdateContactForNumber:(PhoneNumber *)number {
|
||||
if (number) {
|
||||
_contact = [[[Environment getCurrent] contactsManager] latestContactForPhoneNumber:number];
|
||||
_contact = [Environment.getCurrent.contactsManager latestContactForPhoneNumber:number];
|
||||
} else {
|
||||
_contact = nil;
|
||||
}
|
||||
|
|
|
@ -43,13 +43,13 @@ static NSString *const CONTACT_TABLE_VIEW_CELL_IDENTIFIER = @"ContactTableViewCe
|
|||
}
|
||||
|
||||
- (void)observeLatestFavourites {
|
||||
ObservableValue *observableFavourites = [[[Environment getCurrent] contactsManager] getObservableFavourites];
|
||||
ObservableValue *observableFavourites = Environment.getCurrent.contactsManager.getObservableFavourites;
|
||||
|
||||
[observableFavourites watchLatestValue:^(NSArray *latestFavourites) {
|
||||
_favourites = latestFavourites;
|
||||
[_favouriteTableView reloadData];
|
||||
[self hideTableViewIfNoFavourites];
|
||||
} onThread:[NSThread mainThread] untilCancelled:nil];
|
||||
} onThread:NSThread.mainThread untilCancelled:nil];
|
||||
}
|
||||
|
||||
- (void)hideTableViewIfNoFavourites {
|
||||
|
@ -80,7 +80,7 @@ static NSString *const CONTACT_TABLE_VIEW_CELL_IDENTIFIER = @"ContactTableViewCe
|
|||
|
||||
- (void)favouriteTapped:(Contact *)contact {
|
||||
|
||||
PhoneNumberDirectoryFilter *filter = [[[Environment getCurrent] phoneDirectoryManager] getCurrentFilter];
|
||||
PhoneNumberDirectoryFilter *filter = Environment.getCurrent.phoneDirectoryManager.getCurrentFilter;
|
||||
|
||||
for (PhoneNumber *number in contact.parsedPhoneNumbers) {
|
||||
if ([filter containsPhoneNumber:number]) {
|
||||
|
|
|
@ -50,7 +50,7 @@ static NSInteger connectingFlashCounter = 0;
|
|||
[self pauseMusicIfPlaying];
|
||||
[self setupButtonBorders];
|
||||
[self localizeButtons];
|
||||
[[UIDevice currentDevice] setProximityMonitoringEnabled:YES];
|
||||
[UIDevice.currentDevice setProximityMonitoringEnabled:YES];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
|
@ -66,7 +66,7 @@ static NSInteger connectingFlashCounter = 0;
|
|||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[[UIDevice currentDevice] setProximityMonitoringEnabled:NO];
|
||||
[UIDevice.currentDevice setProximityMonitoringEnabled:NO];
|
||||
}
|
||||
|
||||
-(void) showCallState {
|
||||
|
@ -192,7 +192,7 @@ static NSInteger connectingFlashCounter = 0;
|
|||
}
|
||||
}
|
||||
-(void) handleIncomingDetails {
|
||||
[[_callState futureShortAuthenticationString] thenDo:^(NSString* sas) {
|
||||
[_callState.futureShortAuthenticationString thenDo:^(NSString* sas) {
|
||||
_authenicationStringLabel.hidden = NO;
|
||||
_authenicationStringLabel.text = sas;
|
||||
[self performCallInSessionAnimation];
|
||||
|
@ -200,7 +200,7 @@ static NSInteger connectingFlashCounter = 0;
|
|||
|
||||
[[_callState observableProgress] watchLatestValue:^(CallProgress* latestProgress) {
|
||||
[self onCallProgressed:latestProgress];
|
||||
} onThread:[NSThread mainThread] untilCancelled:nil];
|
||||
} onThread:NSThread.mainThread untilCancelled:nil];
|
||||
}
|
||||
|
||||
-(void) onCallProgressed:(CallProgress*)latestProgress {
|
||||
|
@ -214,7 +214,7 @@ static NSInteger connectingFlashCounter = 0;
|
|||
}
|
||||
|
||||
if ([latestProgress type] == CallProgressType_Terminated) {
|
||||
[[_callState futureTermination] thenDo:^(CallTermination* termination) {
|
||||
[_callState.futureTermination thenDo:^(CallTermination* termination) {
|
||||
[self onCallEnded:termination];
|
||||
[AppAudioManager.sharedInstance respondToTerminationType:[termination type]];
|
||||
}];
|
||||
|
@ -225,7 +225,7 @@ static NSInteger connectingFlashCounter = 0;
|
|||
|
||||
-(void) onCallEnded:(CallTermination*)termination {
|
||||
[self updateViewForTermination:termination];
|
||||
[[Environment phoneManager] hangupOrDenyCall];
|
||||
[Environment.phoneManager hangupOrDenyCall];
|
||||
|
||||
[self dismissViewWithOptionalDelay: [termination type] != CallTerminationType_ReplacedByNext ];
|
||||
|
||||
|
@ -235,12 +235,12 @@ static NSInteger connectingFlashCounter = 0;
|
|||
}
|
||||
|
||||
- (void)endCallTapped {
|
||||
[[Environment phoneManager] hangupOrDenyCall];
|
||||
[Environment.phoneManager hangupOrDenyCall];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)muteButtonTapped {
|
||||
_muteButton.selected = [[Environment phoneManager] toggleMute];
|
||||
_muteButton.selected = [Environment.phoneManager toggleMute];
|
||||
}
|
||||
|
||||
- (void)speakerButtonTapped {
|
||||
|
@ -249,12 +249,12 @@ static NSInteger connectingFlashCounter = 0;
|
|||
|
||||
- (void)answerButtonTapped {
|
||||
[self displayAcceptRejectButtons:NO];
|
||||
[[Environment phoneManager] answerCall];
|
||||
[Environment.phoneManager answerCall];
|
||||
}
|
||||
|
||||
- (void)rejectButtonTapped {
|
||||
[self displayAcceptRejectButtons:NO];
|
||||
[[Environment phoneManager] hangupOrDenyCall];
|
||||
[Environment.phoneManager hangupOrDenyCall];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
|
|
|
@ -79,14 +79,14 @@ static NSString *const FOOTER_TABLE_CELL_IDENTIFIER = @"InboxFeedFooterCell";
|
|||
}
|
||||
|
||||
- (void)observeRecentCalls {
|
||||
ObservableValue *observableContacts = [[[Environment getCurrent] contactsManager] getObservableContacts];
|
||||
ObservableValue *observableContacts = Environment.getCurrent.contactsManager.getObservableContacts;
|
||||
|
||||
[observableContacts watchLatestValue:^(id latestValue) {
|
||||
|
||||
ObservableValue *observableRecents = [[[Environment getCurrent] recentCallManager] getObservableRecentCalls];
|
||||
ObservableValue *observableRecents = Environment.getCurrent.recentCallManager.getObservableRecentCalls;
|
||||
|
||||
[observableRecents watchLatestValue:^(NSArray *latestRecents) {
|
||||
_inboxFeed = [[[Environment getCurrent] recentCallManager] recentsForSearchString:nil
|
||||
_inboxFeed = [Environment.getCurrent.recentCallManager recentsForSearchString:nil
|
||||
andExcludeArchived:YES];
|
||||
[self updateTutorialVisibility];
|
||||
if (!_tableViewContentMutating) {
|
||||
|
@ -97,10 +97,10 @@ static NSString *const FOOTER_TABLE_CELL_IDENTIFIER = @"InboxFeedFooterCell";
|
|||
shouldChangeCharactersInRange:NSMakeRange(0, 0)
|
||||
replacementString:SEARCH_BAR_DEFAULT_EMPTY_STRING];
|
||||
}
|
||||
} onThread:[NSThread mainThread] untilCancelled:nil];
|
||||
} onThread:NSThread.mainThread untilCancelled:nil];
|
||||
|
||||
|
||||
} onThread:[NSThread mainThread] untilCancelled:nil];
|
||||
} onThread:NSThread.mainThread untilCancelled:nil];
|
||||
}
|
||||
|
||||
- (void)observeKeyboardNotifications {
|
||||
|
@ -132,7 +132,7 @@ static NSString *const FOOTER_TABLE_CELL_IDENTIFIER = @"InboxFeedFooterCell";
|
|||
}
|
||||
}
|
||||
if (needsSave) {
|
||||
[[[Environment getCurrent] recentCallManager] saveContactsToDefaults];
|
||||
[Environment.getCurrent.recentCallManager saveContactsToDefaults];
|
||||
[(TabBarParentViewController *)self.mm_drawerController.centerViewController updateMissedCallCountLabel];
|
||||
[_inboxFeedTableView reloadData];
|
||||
}
|
||||
|
@ -169,10 +169,10 @@ static NSString *const FOOTER_TABLE_CELL_IDENTIFIER = @"InboxFeedFooterCell";
|
|||
|
||||
if (delete) {
|
||||
animation = UITableViewRowAnimationLeft;
|
||||
[[[Environment getCurrent] recentCallManager] removeRecentCall:recent];
|
||||
[Environment.getCurrent.recentCallManager removeRecentCall:recent];
|
||||
} else {
|
||||
animation = UITableViewRowAnimationRight;
|
||||
[[[Environment getCurrent] recentCallManager] archiveRecentCall:recent];
|
||||
[Environment.getCurrent.recentCallManager archiveRecentCall:recent];
|
||||
}
|
||||
|
||||
[_inboxFeedTableView deleteRowsAtIndexPaths:@[indexPath]
|
||||
|
@ -183,7 +183,7 @@ static NSString *const FOOTER_TABLE_CELL_IDENTIFIER = @"InboxFeedFooterCell";
|
|||
}
|
||||
|
||||
- (void)updateTutorialVisibility {
|
||||
_freshInboxView.hidden = ![[Environment preferences] getFreshInstallTutorialsEnabled];
|
||||
_freshInboxView.hidden = !Environment.preferences.getFreshInstallTutorialsEnabled;
|
||||
_inboxFeedTableView.hidden = !_freshInboxView.hidden;
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ static NSString *const FOOTER_TABLE_CELL_IDENTIFIER = @"InboxFeedFooterCell";
|
|||
if (searching) {
|
||||
_freshInboxView.hidden = YES;
|
||||
_inboxFeedTableView.hidden = NO;
|
||||
_searchInboxFeed = [[[Environment getCurrent] recentCallManager] recentsForSearchString:term
|
||||
_searchInboxFeed = [Environment.getCurrent.recentCallManager recentsForSearchString:term
|
||||
andExcludeArchived:YES];
|
||||
|
||||
[self reloadSearchContactsForTerm:term];
|
||||
|
@ -372,7 +372,7 @@ static NSString *const FOOTER_TABLE_CELL_IDENTIFIER = @"InboxFeedFooterCell";
|
|||
|
||||
- (void)reloadSearchContactsForTerm:(NSString *)term {
|
||||
|
||||
NSArray *contacts = [[[Environment getCurrent] contactsManager] latestContactsWithSearchString:term];
|
||||
NSArray *contacts = [Environment.getCurrent.contactsManager latestContactsWithSearchString:term];
|
||||
|
||||
NSMutableArray *registeredContacts = [NSMutableArray array];
|
||||
NSMutableArray *unregisteredContacts = [NSMutableArray array];
|
||||
|
@ -381,7 +381,7 @@ static NSString *const FOOTER_TABLE_CELL_IDENTIFIER = @"InboxFeedFooterCell";
|
|||
BOOL registeredContact = NO;
|
||||
|
||||
for (PhoneNumber *phoneNumber in contact.parsedPhoneNumbers) {
|
||||
if ([[[[Environment getCurrent] phoneDirectoryManager] getCurrentFilter] containsPhoneNumber:phoneNumber]) {
|
||||
if ([Environment.getCurrent.phoneDirectoryManager.getCurrentFilter containsPhoneNumber:phoneNumber]) {
|
||||
registeredContact = YES;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,17 +71,17 @@ static NSString *const INVITE_CONTACTS_TABLE_CELL_IDENTIFIER = @"ContactTableVie
|
|||
}
|
||||
|
||||
- (void)setupContacts {
|
||||
ObservableValue *observableContacts = [[[Environment getCurrent] contactsManager] getObservableContacts];
|
||||
ObservableValue *observableContacts = Environment.getCurrent.contactsManager.getObservableContacts;
|
||||
|
||||
[observableContacts watchLatestValue:^(NSArray *latestContacts) {
|
||||
_latestContacts = [self getUnregisteredUsersFromAllUsers:latestContacts searchTerm:nil];
|
||||
_displayedContacts = _latestContacts;
|
||||
[_contactTableView reloadData];
|
||||
} onThread:[NSThread mainThread] untilCancelled:nil];
|
||||
} onThread:NSThread.mainThread untilCancelled:nil];
|
||||
}
|
||||
|
||||
- (NSArray *)getUnregisteredUsersFromAllUsers:(NSArray *)users searchTerm:(NSString *)searchTerm {
|
||||
ContactsManager *contactsManager = [[Environment getCurrent] contactsManager];
|
||||
ContactsManager *contactsManager = Environment.getCurrent.contactsManager;
|
||||
|
||||
return [users filter:^int(Contact *contact) {
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
}
|
||||
|
||||
- (void)populateDefaultCountryNameAndCode {
|
||||
NSLocale *locale = [NSLocale currentLocale];
|
||||
NSLocale *locale = NSLocale.currentLocale;
|
||||
NSString *countryCode = [locale objectForKey:NSLocaleCountryCode];
|
||||
NSNumber *cc = [NBPhoneNumberUtil.sharedInstance getCountryCodeForRegion:countryCode];
|
||||
|
||||
|
@ -123,7 +123,7 @@
|
|||
|
||||
return [HttpManager asyncOkResponseFromMasterServer:registerRequest
|
||||
unlessCancelled:internalUntilCancelledToken
|
||||
andErrorHandler:[Environment errorNoter]];
|
||||
andErrorHandler:Environment.errorNoter];
|
||||
};
|
||||
TOCFuture *futurePhoneRegistrationStarted = [TOCFuture futureFromUntilOperation:[TOCFuture operationTry:regStarter]
|
||||
withOperationTimeout:SERVER_TIMEOUT_SECONDS
|
||||
|
@ -176,12 +176,12 @@
|
|||
HttpRequest *verifyRequest = [HttpRequest httpRequestToVerifyAccessToPhoneNumberWithChallenge:_challengeTextField.text];
|
||||
TOCFuture *futureDone = [HttpManager asyncOkResponseFromMasterServer:verifyRequest
|
||||
unlessCancelled:nil
|
||||
andErrorHandler:[Environment errorNoter]];
|
||||
andErrorHandler:Environment.errorNoter];
|
||||
|
||||
[futureDone catchDo:^(id error) {
|
||||
if ([error isKindOfClass:[HttpResponse class]]) {
|
||||
if ([error isKindOfClass:HttpResponse.class]) {
|
||||
HttpResponse* badResponse = error;
|
||||
if ([badResponse getStatusCode] == 401) {
|
||||
if (badResponse.getStatusCode == 401) {
|
||||
UIAlertView *incorrectChallengeCodeAV = [[UIAlertView alloc]initWithTitle:REGISTER_CHALLENGE_ALERT_VIEW_TITLE message:REGISTER_CHALLENGE_ALERT_VIEW_BODY delegate:nil cancelButtonTitle:REGISTER_CHALLENGE_ALERT_DISMISS otherButtonTitles:nil, nil];
|
||||
[incorrectChallengeCodeAV show];
|
||||
_challengeButton.enabled = YES;
|
||||
|
@ -191,7 +191,7 @@
|
|||
}
|
||||
_challengeButton.enabled = YES;
|
||||
[_challengeActivityIndicator stopAnimating];
|
||||
[Environment errorNoter](error, @"While Verifying Challenge.", NO);
|
||||
Environment.errorNoter(error, @"While Verifying Challenge.", NO);
|
||||
}];
|
||||
|
||||
[futureDone thenDo:^(id result) {
|
||||
|
@ -202,7 +202,7 @@
|
|||
[PushManager.sharedManager askForPushRegistrationWithSuccess:^{
|
||||
[Environment setRegistered:YES];
|
||||
[registered trySetResult:@YES];
|
||||
[[[Environment getCurrent] phoneDirectoryManager] forceUpdate];
|
||||
[Environment.getCurrent.phoneDirectoryManager forceUpdate];
|
||||
[self dismissView];
|
||||
} failure:^{
|
||||
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:REGISTER_ERROR_ALERT_VIEW_TITLE message:REGISTER_ERROR_ALERT_VIEW_BODY delegate:nil cancelButtonTitle:REGISTER_ERROR_ALERT_VIEW_DISMISS otherButtonTitles:nil, nil];
|
||||
|
@ -241,7 +241,7 @@
|
|||
|
||||
NSTimeInterval smsTimeoutTimeInterval = SMS_VERIFICATION_TIMEOUT_SECONDS;
|
||||
|
||||
NSDate *now = [[NSDate alloc] init];
|
||||
NSDate *now = [NSDate new];
|
||||
timeoutDate = [[NSDate alloc] initWithTimeInterval:smsTimeoutTimeInterval sinceDate:now];
|
||||
|
||||
countdownTimer = [NSTimer scheduledTimerWithTimeInterval:1
|
||||
|
@ -255,9 +255,9 @@
|
|||
}
|
||||
|
||||
- (void) countdowntimerFired {
|
||||
NSDate *now = [[NSDate alloc] init];
|
||||
NSDate *now = [NSDate new];
|
||||
|
||||
NSCalendar *sysCalendar = [NSCalendar currentCalendar];
|
||||
NSCalendar *sysCalendar = NSCalendar.currentCalendar;
|
||||
unsigned int unitFlags = NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
|
||||
NSDateComponents *conversionInfo = [sysCalendar components:unitFlags fromDate:now toDate:timeoutDate options:0];
|
||||
NSString* timeLeft = [NSString stringWithFormat:@"%ld:%02ld",(long)[conversionInfo minute],(long)[conversionInfo second]];
|
||||
|
@ -278,14 +278,14 @@
|
|||
[self.voiceChallengeTextLabel setText:NSLocalizedString(@"REGISTER_CALL_CALLING", @"")];
|
||||
return [HttpManager asyncOkResponseFromMasterServer:voiceVerifyReq
|
||||
unlessCancelled:internalUntilCancelledToken
|
||||
andErrorHandler:[Environment errorNoter]];
|
||||
andErrorHandler:Environment.errorNoter];
|
||||
};
|
||||
TOCFuture *futureVoiceVerificationStarted = [TOCFuture futureFromUntilOperation:[TOCFuture operationTry:callStarter]
|
||||
withOperationTimeout:SERVER_TIMEOUT_SECONDS
|
||||
until:life.token];
|
||||
[futureVoiceVerificationStarted catchDo:^(id errorId) {
|
||||
HttpResponse* error = (HttpResponse*)errorId;
|
||||
[self.voiceChallengeTextLabel setText:[error getStatusText]];
|
||||
[self.voiceChallengeTextLabel setText:error.getStatusText];
|
||||
}];
|
||||
|
||||
[futureVoiceVerificationStarted finallyTry:^(id _id) {
|
||||
|
|
|
@ -109,12 +109,12 @@ static NSString *const CHECKBOX_EMPTY_IMAGE_NAME = @"checkbox_empty";
|
|||
[button setImage:[UIImage imageNamed:CHECKBOX_CHECKMARK_IMAGE_NAME]
|
||||
forState:UIControlStateSelected];
|
||||
}
|
||||
PropertyListPreferences *prefs = [Environment preferences];
|
||||
_hideContactImagesButton.selected = ![prefs getContactImagesEnabled];
|
||||
_enableScreenSecurityButton.selected = [prefs screenSecurityIsEnabled];
|
||||
_disableAutocorrectButton.selected = ![prefs getAutocorrectEnabled];
|
||||
_disableHistoryButton.selected = ![prefs getHistoryLogEnabled];
|
||||
_disableLogsCell.selected = ![prefs loggingIsEnabled];
|
||||
PropertyListPreferences *prefs = Environment.preferences;
|
||||
_hideContactImagesButton.selected = !prefs.getContactImagesEnabled;
|
||||
_enableScreenSecurityButton.selected = prefs.screenSecurityIsEnabled;
|
||||
_disableAutocorrectButton.selected = !prefs.getAutocorrectEnabled;
|
||||
_disableHistoryButton.selected = !prefs.getHistoryLogEnabled;
|
||||
_disableLogsCell.selected = !prefs.loggingIsEnabled;
|
||||
}
|
||||
|
||||
- (void)configureAllCells {
|
||||
|
@ -146,7 +146,7 @@ static NSString *const CHECKBOX_EMPTY_IMAGE_NAME = @"checkbox_empty";
|
|||
|
||||
NSMutableArray *cells = [@[_disableLogsCell] mutableCopy];
|
||||
|
||||
if ([[Environment preferences] loggingIsEnabled]) {
|
||||
if (Environment.preferences.loggingIsEnabled) {
|
||||
[cells addObject:_sendDebugLog];
|
||||
}
|
||||
|
||||
|
@ -207,22 +207,22 @@ static NSString *const CHECKBOX_EMPTY_IMAGE_NAME = @"checkbox_empty";
|
|||
|
||||
- (IBAction)hideContactImagesButtonTapped {
|
||||
_hideContactImagesButton.selected = !_hideContactImagesButton.selected;
|
||||
[[Environment preferences] setContactImagesEnabled:!_hideContactImagesButton.selected];
|
||||
[Environment.preferences setContactImagesEnabled:!_hideContactImagesButton.selected];
|
||||
}
|
||||
|
||||
- (IBAction)disableAutocorrectButtonTapped {
|
||||
_disableAutocorrectButton.selected = !_disableAutocorrectButton.selected;
|
||||
[[Environment preferences] setAutocorrectEnabled:!_disableAutocorrectButton.selected];
|
||||
[Environment.preferences setAutocorrectEnabled:!_disableAutocorrectButton.selected];
|
||||
}
|
||||
|
||||
- (IBAction)disableHistoryButtonTapped {
|
||||
_disableHistoryButton.selected = !_disableHistoryButton.selected;
|
||||
[[Environment preferences] setHistoryLogEnabled:!_disableHistoryButton.selected];
|
||||
[Environment.preferences setHistoryLogEnabled:!_disableHistoryButton.selected];
|
||||
}
|
||||
|
||||
- (IBAction)enableScreenSecurityTapped:(id)sender{
|
||||
_enableScreenSecurityButton.selected = !_enableScreenSecurityButton.selected;
|
||||
[[Environment preferences] setScreenSecurity:_enableScreenSecurityButton.selected];
|
||||
[Environment.preferences setScreenSecurity:_enableScreenSecurityButton.selected];
|
||||
}
|
||||
|
||||
- (IBAction)disableLogTapped:(id)sender{
|
||||
|
@ -237,13 +237,13 @@ static NSString *const CHECKBOX_EMPTY_IMAGE_NAME = @"checkbox_empty";
|
|||
[DebugLogger.sharedInstance enableFileLogging];
|
||||
}
|
||||
|
||||
[[Environment preferences] setLoggingEnabled:loggingEnabled];
|
||||
[Environment.preferences setLoggingEnabled:loggingEnabled];
|
||||
_debuggingTableViewCells = [self debugCells];
|
||||
[_settingsTableView reloadData];
|
||||
}
|
||||
|
||||
- (void)clearHistory {
|
||||
[[[Environment getCurrent] recentCallManager] clearRecentCalls];
|
||||
[Environment.getCurrent.recentCallManager clearRecentCalls];
|
||||
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:SETTINGS_LOG_CLEAR_TITLE
|
||||
message:SETTINGS_LOG_CLEAR_MESSAGE
|
||||
delegate:nil
|
||||
|
|
|
@ -55,10 +55,10 @@
|
|||
}
|
||||
_whisperUserUpdateImageView.hidden = [self hideUserUpdateNotification];
|
||||
|
||||
ObservableValue *recentCallObservable = [[[Environment getCurrent] recentCallManager] getObservableRecentCalls];
|
||||
ObservableValue *recentCallObservable = Environment.getCurrent.recentCallManager.getObservableRecentCalls;
|
||||
[recentCallObservable watchLatestValue:^(NSArray *latestRecents) {
|
||||
[self updateMissedCallCountLabel];
|
||||
} onThread:[NSThread mainThread] untilCancelled:nil];
|
||||
} onThread:NSThread.mainThread untilCancelled:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(newUsersDetected:)
|
||||
|
@ -166,7 +166,7 @@
|
|||
}
|
||||
|
||||
- (void)updateMissedCallCountLabel {
|
||||
NSUInteger missedCallCount = [[[Environment getCurrent] recentCallManager] missedCallCount];
|
||||
NSUInteger missedCallCount = Environment.getCurrent.recentCallManager.missedCallCount;
|
||||
if (missedCallCount > 0) {
|
||||
_tabBarInboxButton.frame = CGRectMake(CGRectGetMinX(_tabBarInboxButton.frame),
|
||||
CGRectGetMinY(_tabBarInboxButton.frame),
|
||||
|
@ -199,12 +199,12 @@
|
|||
}
|
||||
|
||||
- (void)setNewWhisperUsersAsSeen:(NSArray *)users {
|
||||
[[[Environment getCurrent] contactsManager] addContactsToKnownWhisperUsers:users];
|
||||
[Environment.getCurrent.contactsManager addContactsToKnownWhisperUsers:users];
|
||||
[_contactsViewController showNotificationForNewWhisperUsers:nil];
|
||||
_whisperUserUpdateImageView.hidden = [self hideUserUpdateNotification];
|
||||
}
|
||||
|
||||
-(BOOL) hideUserUpdateNotification {
|
||||
return (0 == [[[Environment getCurrent] contactsManager] getNumberOfUnacknowledgedCurrentUsers]);
|
||||
return (0 == Environment.getCurrent.contactsManager.getNumberOfUnacknowledgedCurrentUsers);
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
|
||||
self = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
|
||||
self = [NSBundle.mainBundle loadNibNamed:NSStringFromClass(self.class)
|
||||
owner:self
|
||||
options:nil][0];
|
||||
if (self) {
|
||||
|
@ -23,7 +23,7 @@
|
|||
}
|
||||
|
||||
- (NSString *)reuseIdentifier {
|
||||
return NSStringFromClass([self class]);
|
||||
return NSStringFromClass(self.class);
|
||||
}
|
||||
|
||||
- (void)prepareForReuse {
|
||||
|
@ -32,7 +32,7 @@
|
|||
}
|
||||
|
||||
- (void)configureWithRecentCall:(RecentCall *)recentCall {
|
||||
Contact *contact = [[[Environment getCurrent] contactsManager] latestContactWithRecordId:recentCall.contactRecordID];
|
||||
Contact *contact = [Environment.getCurrent.contactsManager latestContactWithRecordId:recentCall.contactRecordID];
|
||||
if (contact) {
|
||||
_contactNameLabel.text = contact.fullName;
|
||||
} else {
|
||||
|
@ -74,7 +74,7 @@
|
|||
_deleteImageView.bounds.origin.y,
|
||||
(CGFloat)newWidth,
|
||||
_deleteImageView.bounds.size.height);
|
||||
_deleteImageView.tintColor = [UIColor whiteColor];
|
||||
_deleteImageView.tintColor = UIColor.whiteColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
@implementation ContactDetailTableViewCell
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil][0];
|
||||
self = [NSBundle.mainBundle loadNibNamed:NSStringFromClass(self.class) owner:self options:nil][0];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)reuseIdentifier {
|
||||
return NSStringFromClass([self class]);
|
||||
return NSStringFromClass(self.class);
|
||||
}
|
||||
|
||||
- (void)configureWithPhoneNumber:(PhoneNumber *)phoneNumber isSecure:(BOOL)isSecure {
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
@implementation ContactTableViewCell
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil][0];
|
||||
self = [NSBundle.mainBundle loadNibNamed:NSStringFromClass(self.class) owner:self options:nil][0];
|
||||
_contactPictureView.layer.borderColor = [[UIColor lightGrayColor] CGColor];
|
||||
_contactPictureView.layer.masksToBounds = YES;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)reuseIdentifier {
|
||||
return NSStringFromClass([self class]);
|
||||
return NSStringFromClass(self.class);
|
||||
}
|
||||
|
||||
- (void)configureWithContact:(Contact *)contact {
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
@implementation CountryCodeTableViewCell
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
|
||||
self = [[NSBundle.mainBundle loadNibNamed:NSStringFromClass(self.class)
|
||||
owner:self
|
||||
options:nil] firstObject];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)reuseIdentifier {
|
||||
return NSStringFromClass([self class]);
|
||||
return NSStringFromClass(self.class);
|
||||
}
|
||||
|
||||
- (void)configureWithCountryCode:(NSString *)code andCountryName:(NSString *)name {
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
@implementation FavouriteTableViewCell
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil][0];
|
||||
self = [NSBundle.mainBundle loadNibNamed:NSStringFromClass(self.class) owner:self options:nil][0];
|
||||
_contactPictureView.layer.borderColor = [[UIColor lightGrayColor] CGColor];
|
||||
_contactPictureView.layer.masksToBounds = YES;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)reuseIdentifier {
|
||||
return NSStringFromClass([self class]);
|
||||
return NSStringFromClass(self.class);
|
||||
}
|
||||
|
||||
- (void)configureWithContact:(Contact *)contact {
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
@implementation InboxFeedFooterCell
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil][0];
|
||||
self = [NSBundle.mainBundle loadNibNamed:NSStringFromClass(self.class) owner:self options:nil][0];
|
||||
if (self) {
|
||||
ObservableValue *recentCallObserver = [[[Environment getCurrent] recentCallManager] getObservableRecentCalls];
|
||||
ObservableValue *recentCallObserver = Environment.getCurrent.recentCallManager.getObservableRecentCalls;
|
||||
[recentCallObserver watchLatestValue:^(id latestValue) {
|
||||
NSUInteger inboxCount = [[[[Environment getCurrent] recentCallManager] recentsForSearchString:nil andExcludeArchived:YES] count];
|
||||
NSUInteger inboxCount = [[Environment.getCurrent.recentCallManager recentsForSearchString:nil andExcludeArchived:YES] count];
|
||||
if (inboxCount == 0) {
|
||||
_inboxCountLabel.text = @"";
|
||||
_inboxMessageLabelFirst.text = HOME_FOOTER_FIRST_MESSAGE_CALLS_NIL;
|
||||
|
@ -19,13 +19,13 @@
|
|||
_inboxMessageLabelFirst.text = HOME_FOOTER_FIRST_MESSAGE_CALLS_UNSORTED;
|
||||
_inboxMessageLabelSecond.text = inboxCount == 1 ? HOME_FOOTER_SECOND_MESSAGE_CALL_UNSORTED : HOME_FOOTER_SECOND_MESSAGE_CALLS_UNSORTED;
|
||||
}
|
||||
} onThread:[NSThread mainThread] untilCancelled:nil];
|
||||
} onThread:NSThread.mainThread untilCancelled:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)reuseIdentifier {
|
||||
return NSStringFromClass([self class]);
|
||||
return NSStringFromClass(self.class);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
@implementation InboxFeedTableViewCell
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
|
||||
self = [NSBundle.mainBundle loadNibNamed:NSStringFromClass(self.class)
|
||||
owner:self
|
||||
options:nil][0];
|
||||
|
||||
|
@ -33,11 +33,11 @@
|
|||
}
|
||||
|
||||
- (NSString *)reuseIdentifier {
|
||||
return NSStringFromClass([self class]);
|
||||
return NSStringFromClass(self.class);
|
||||
}
|
||||
|
||||
- (void)configureWithRecentCall:(RecentCall *)recentCall {
|
||||
Contact *contact = [[[Environment getCurrent] contactsManager] latestContactWithRecordId:recentCall.contactRecordID];
|
||||
Contact *contact = [Environment.getCurrent.contactsManager latestContactWithRecordId:recentCall.contactRecordID];
|
||||
|
||||
if (contact) {
|
||||
_nameLabel.text = contact.fullName;
|
||||
|
@ -115,7 +115,7 @@
|
|||
_archiveImageView.bounds.origin.y,
|
||||
(CGFloat)newWidth,
|
||||
_archiveImageView.bounds.size.height);
|
||||
_archiveImageView.tintColor = [UIColor whiteColor];
|
||||
_archiveImageView.tintColor = UIColor.whiteColor;
|
||||
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@
|
|||
_deleteImageView.bounds.origin.y,
|
||||
(CGFloat)newWidth,
|
||||
_deleteImageView.bounds.size.height);
|
||||
_deleteImageView.tintColor = [UIColor whiteColor];
|
||||
_deleteImageView.tintColor = UIColor.whiteColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
@implementation LeftSideMenuCell
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
|
||||
self = [[NSBundle.mainBundle loadNibNamed:NSStringFromClass(self.class)
|
||||
owner:self
|
||||
options:nil] firstObject];
|
||||
return self;
|
||||
|
@ -15,12 +15,12 @@
|
|||
if (highlighted) {
|
||||
_menuTitleLabel.textColor = [UIUtil darkBackgroundColor];
|
||||
} else {
|
||||
_menuTitleLabel.textColor = [UIUtil whiteColor];
|
||||
_menuTitleLabel.textColor = UIUtil.whiteColor;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)reuseIdentifier {
|
||||
return NSStringFromClass([self class]);
|
||||
return NSStringFromClass(self.class);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
@implementation PreferenceListTableViewCell
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil] firstObject];
|
||||
return [[NSBundle.mainBundle loadNibNamed:NSStringFromClass(self.class) owner:self options:nil] firstObject];
|
||||
}
|
||||
|
||||
- (NSString *)reuseIdentifier {
|
||||
return NSStringFromClass([self class]);
|
||||
return NSStringFromClass(self.class);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
}
|
||||
|
||||
- (void)updateAutoCorrectionType {
|
||||
BOOL autoCorrectEnabled = [[Environment preferences] getAutocorrectEnabled];
|
||||
BOOL autoCorrectEnabled = Environment.preferences.getAutocorrectEnabled;
|
||||
_searchTextField.autocorrectionType = autoCorrectEnabled ? UITextAutocorrectionTypeYes : UITextAutocorrectionTypeNo;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,18 +6,18 @@
|
|||
@implementation UnseenWhisperUserCell
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil] firstObject];
|
||||
self = [[NSBundle.mainBundle loadNibNamed:NSStringFromClass(self.class) owner:self options:nil] firstObject];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)restorationIdentifier {
|
||||
return NSStringFromClass([self class]);
|
||||
return NSStringFromClass(self.class);
|
||||
}
|
||||
|
||||
- (void)configureWithContact:(Contact *)contact {
|
||||
_nameLabel.text = contact.fullName;
|
||||
|
||||
PhoneNumberDirectoryFilter *filter = [[[Environment getCurrent] phoneDirectoryManager] getCurrentFilter];
|
||||
PhoneNumberDirectoryFilter *filter = Environment.getCurrent.phoneDirectoryManager.getCurrentFilter;
|
||||
BOOL foundPhoneNumber = NO;
|
||||
|
||||
for (PhoneNumber *number in contact.parsedPhoneNumbers) {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
wave[i] = (int16_t)(sin(t)*INT16_MAX);
|
||||
double curFrequency = (sin(t/400)+1)/2*500+200;
|
||||
@synchronized(a) {
|
||||
t += 2*3.14159*curFrequency/[a getSampleRateInHertz];
|
||||
t += 2*3.14159*curFrequency/a.getSampleRateInHertz;
|
||||
}
|
||||
}
|
||||
[a populatePlaybackQueueWithData:[NSData dataWithBytesNoCopy:wave length:sizeof(wave) freeWhenDone:NO]];
|
||||
|
|
|
@ -224,27 +224,27 @@
|
|||
[q tryEnqueue:[EncodedAudioPacket encodedAudioPacketWithAudioData:increasingData(20)
|
||||
andTimeStamp:1*TICK
|
||||
andSequenceNumber:1]];
|
||||
test([q currentBufferDepth] == 0);
|
||||
test(q.currentBufferDepth == 0);
|
||||
[q tryEnqueue:[EncodedAudioPacket encodedAudioPacketWithAudioData:increasingData(20)
|
||||
andTimeStamp:2*TICK
|
||||
andSequenceNumber:2]];
|
||||
test([q currentBufferDepth] == 1);
|
||||
test(q.currentBufferDepth == 1);
|
||||
[q tryEnqueue:[EncodedAudioPacket encodedAudioPacketWithAudioData:increasingData(20)
|
||||
andTimeStamp:4*TICK
|
||||
andSequenceNumber:4]];
|
||||
test([q currentBufferDepth] == 3);
|
||||
test(q.currentBufferDepth == 3);
|
||||
[q tryDequeue];
|
||||
test([q currentBufferDepth] == 2);
|
||||
test(q.currentBufferDepth == 2);
|
||||
[q tryDequeue];
|
||||
test([q currentBufferDepth] == 1);
|
||||
test(q.currentBufferDepth == 1);
|
||||
[q tryDequeue];
|
||||
test([q currentBufferDepth] == 0);
|
||||
test(q.currentBufferDepth == 0);
|
||||
[q tryDequeue];
|
||||
test([q currentBufferDepth] == -1);
|
||||
test(q.currentBufferDepth == -1);
|
||||
[q tryEnqueue:[EncodedAudioPacket encodedAudioPacketWithAudioData:increasingData(20)
|
||||
andTimeStamp:8*TICK
|
||||
andSequenceNumber:8]];
|
||||
test([q currentBufferDepth] == 3);
|
||||
test(q.currentBufferDepth == 3);
|
||||
|
||||
// resyncs to 0
|
||||
for (int i = 0; i < 500; i++) {
|
||||
|
@ -253,6 +253,6 @@
|
|||
[q tryEnqueue:[EncodedAudioPacket encodedAudioPacketWithAudioData:increasingData(20)
|
||||
andTimeStamp:9000*TICK
|
||||
andSequenceNumber:9000]];
|
||||
test([q currentBufferDepth] == 0);
|
||||
test(q.currentBufferDepth == 0);
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
// [Environment setCurrent:testEnv];
|
||||
// [SGNKeychainUtil setLocalNumberTo:[PhoneNumber phoneNumberFromE164:@"+12211231235"]];
|
||||
// [UICKeyChainStore setString:@"shall_not_password" forKey:@"Password"];
|
||||
// [[Environment preferences] setValueForKey:@"PasswordCounter" toValue:@2357];
|
||||
// [Environment.preferences setValueForKey:@"PasswordCounter" toValue:@2357];
|
||||
// HttpRequest* h = [HttpRequest httpRequestToInitiateToRemoteNumber:[PhoneNumber phoneNumberFromE164:@"+19023334444"]];
|
||||
// test([[h method] isEqualToString:@"GET"]);
|
||||
// test([[h location] isEqualToString:@"/session/1/+19023334444"]);
|
||||
|
@ -73,24 +73,24 @@
|
|||
}
|
||||
-(void) testResponseOk {
|
||||
HttpResponse* h = [HttpResponse httpResponse200Ok];
|
||||
test([h getStatusCode] == 200);
|
||||
test([h getOptionalBodyText] == nil);
|
||||
test([[h getHeaders] count] == 0);
|
||||
test(h.getStatusCode == 200);
|
||||
test(h.getOptionalBodyText == nil);
|
||||
test([h.getHeaders count] == 0);
|
||||
}
|
||||
-(void) testResponseFromData {
|
||||
HttpResponse* h = [HttpResponse httpResponseFromData:@"HTTP/1.1 200 OK\r\n\r\n".encodedAsUtf8];
|
||||
test(h.isOkResponse);
|
||||
test([h getStatusCode] == 200);
|
||||
test([[h getStatusText] isEqualToString: @"OK"]);
|
||||
test([h getOptionalBodyText] == nil);
|
||||
test([[h getHeaders] count] == 0);
|
||||
test(h.getStatusCode == 200);
|
||||
test([h.getStatusText isEqualToString: @"OK"]);
|
||||
test(h.getOptionalBodyText == nil);
|
||||
test([h.getHeaders count] == 0);
|
||||
|
||||
HttpResponse* h2 = [HttpResponse httpResponseFromData:@"HTTP/1.1 404 Not Found\r\n\r\n".encodedAsUtf8];
|
||||
test(!h2.isOkResponse);
|
||||
test([h2 getStatusCode] == 404);
|
||||
test([[h2 getStatusText] isEqualToString:@"Not Found"]);
|
||||
test([h2 getOptionalBodyText] == nil);
|
||||
test([[h2 getHeaders] count] == 0);
|
||||
test(h2.getStatusCode == 404);
|
||||
test([h2.getStatusText isEqualToString:@"Not Found"]);
|
||||
test(h2.getOptionalBodyText == nil);
|
||||
test([h2.getHeaders count] == 0);
|
||||
|
||||
testThrows([HttpResponse httpResponseFromData:@"HTTP/1.1 200 OK\r\n".encodedAsUtf8]);
|
||||
testThrows([HttpResponse httpResponseFromData:@"HTTP/1.1 200\r\n\r\n".encodedAsUtf8]);
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
id<KeyAgreementParticipant> ec2 = [protocol generateParticipantWithNewKeys];
|
||||
id<KeyAgreementParticipant> ec3 = [protocol generateParticipantWithNewKeys];
|
||||
|
||||
NSData* pub_1 = [ec1 getPublicKeyData];
|
||||
NSData* pub_2 = [ec2 getPublicKeyData];
|
||||
NSData* pub_1 = ec1.getPublicKeyData;
|
||||
NSData* pub_2 = ec2.getPublicKeyData;
|
||||
|
||||
NSData* shared_1 = [ec1 calculateKeyAgreementAgainstRemotePublicKey:pub_2];
|
||||
NSData* shared_2 = [ec2 calculateKeyAgreementAgainstRemotePublicKey:pub_1];
|
||||
|
@ -34,8 +34,8 @@
|
|||
id<KeyAgreementParticipant> ec1 = [protocol generateParticipantWithNewKeys];
|
||||
id<KeyAgreementParticipant> ec2 = [protocol generateParticipantWithNewKeys];
|
||||
|
||||
NSData* pub_1 = [ec1 getPublicKeyData];
|
||||
NSData* pub_2 = [ec2 getPublicKeyData];
|
||||
NSData* pub_1 = ec1.getPublicKeyData;
|
||||
NSData* pub_2 = ec2.getPublicKeyData;
|
||||
|
||||
NSData* shared_1 = [ec1 calculateKeyAgreementAgainstRemotePublicKey:pub_2];
|
||||
NSData* shared_2 = [ec2 calculateKeyAgreementAgainstRemotePublicKey:pub_1];
|
||||
|
|
|
@ -16,7 +16,7 @@ bool pm(HandshakePacket* p1, HandshakePacket* p2);
|
|||
bool pm(HandshakePacket* p1, HandshakePacket* p2) {
|
||||
return p1 != nil
|
||||
&& p2 != nil
|
||||
&& [p1 class] == [p2 class]
|
||||
&& p1.class == p2.class
|
||||
&& [[p1 embeddedIntoRtpPacketWithSequenceNumber:0 usingInteropOptions:@[]] isEqualToRtpPacket:[p2 embeddedIntoRtpPacketWithSequenceNumber:0 usingInteropOptions:@[]]];
|
||||
}
|
||||
#define AssertPacketsMatch(p1, p2) STAssertTrue(pm(p1, p2), @"")
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
return participant;
|
||||
}
|
||||
-(NSData*) getId {
|
||||
return [[participant getProtocol] getId];
|
||||
return participant.getProtocol.getId;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
-(void) testAuthenticationFail_WrongCert {
|
||||
[Environment setCurrent:testEnv];
|
||||
|
||||
NSString *certPath = [[[NSBundle bundleForClass:[NetworkStream class]] resourcePath] stringByAppendingPathComponent:@"whisperFake.cer"];
|
||||
NSString *certPath = [[[NSBundle bundleForClass:NetworkStream.class] resourcePath] stringByAppendingPathComponent:@"whisperFake.cer"];
|
||||
NSData *certData = [[NSData alloc] initWithContentsOfFile:certPath];
|
||||
checkOperation(certData != nil);
|
||||
|
||||
|
|
|
@ -17,19 +17,19 @@
|
|||
andRelayPort:6];
|
||||
test([d sessionId] == 5);
|
||||
test([d relayUdpPort] == 6);
|
||||
test([[d relayServerName] isEqualToString:@"example.com"]);
|
||||
test([d.relayServerName isEqualToString:@"example.com"]);
|
||||
|
||||
// roundtrip
|
||||
InitiatorSessionDescriptor* d2 = [InitiatorSessionDescriptor initiatorSessionDescriptorFromJson:d.toJson];
|
||||
test([d2 sessionId] == 5);
|
||||
test([d2 relayUdpPort] == 6);
|
||||
test([[d2 relayServerName] isEqualToString:@"example.com"]);
|
||||
test([d2.relayServerName isEqualToString:@"example.com"]);
|
||||
|
||||
// constant
|
||||
InitiatorSessionDescriptor* d3 = [InitiatorSessionDescriptor initiatorSessionDescriptorFromJson:@"{\"sessionId\":5,\"serverName\":\"example.com\",\"relayPort\":6}"];
|
||||
test([d3 sessionId] == 5);
|
||||
test([d3 relayUdpPort] == 6);
|
||||
test([[d3 relayServerName] isEqualToString:@"example.com"]);
|
||||
test([d3.relayServerName isEqualToString:@"example.com"]);
|
||||
}
|
||||
|
||||
-(void) testResponderSessionDescriptorFromEncryptedRemoteNotification2 {
|
||||
|
|
|
@ -9,36 +9,36 @@
|
|||
@implementation DecayingSampleEstimatorTest
|
||||
-(void) testDecayingSampleEstimator {
|
||||
DecayingSampleEstimator* e = [DecayingSampleEstimator decayingSampleEstimatorWithInitialEstimate:1.0 andDecayPerUnitSample:0.5];
|
||||
test([e currentEstimate] == 1.0);
|
||||
test(e.currentEstimate == 1.0);
|
||||
test([e decayRatePerUnitSample] == 0.5);
|
||||
|
||||
[e updateWithNextSample:2.0];
|
||||
test([e currentEstimate] == 1.5);
|
||||
test(e.currentEstimate == 1.5);
|
||||
test([e decayRatePerUnitSample] == 0.5);
|
||||
|
||||
[e updateWithNextSample:2.0];
|
||||
test([e currentEstimate] == 1.75);
|
||||
test(e.currentEstimate == 1.75);
|
||||
test([e decayRatePerUnitSample] == 0.5);
|
||||
|
||||
[e updateWithNextSample:1.75];
|
||||
test([e currentEstimate] == 1.75);
|
||||
test(e.currentEstimate == 1.75);
|
||||
|
||||
[e updateWithNextSample:1.75];
|
||||
test([e currentEstimate] == 1.75);
|
||||
test(e.currentEstimate == 1.75);
|
||||
}
|
||||
-(void) testDecayingSampleEstimatorForce {
|
||||
DecayingSampleEstimator* e = [DecayingSampleEstimator decayingSampleEstimatorWithInitialEstimate:1.0 andDecayPerUnitSample:0.5];
|
||||
test([e currentEstimate] == 1.0);
|
||||
test(e.currentEstimate == 1.0);
|
||||
[e forceEstimateTo:5];
|
||||
test([e currentEstimate] == 5);
|
||||
test(e.currentEstimate == 5);
|
||||
test([e decayRatePerUnitSample] == 0.5);
|
||||
}
|
||||
-(void) testDecayingSampleEstimatorQuarter {
|
||||
DecayingSampleEstimator* e = [DecayingSampleEstimator decayingSampleEstimatorWithInitialEstimate:1.0 andDecayPerUnitSample:0.75];
|
||||
test([e currentEstimate] == 1.0);
|
||||
test(e.currentEstimate == 1.0);
|
||||
test([e decayRatePerUnitSample] == 0.75);
|
||||
[e updateWithNextSample:2.0];
|
||||
test([e currentEstimate] == 1.75);
|
||||
test(e.currentEstimate == 1.75);
|
||||
}
|
||||
-(void) testDecayingSampleEstimatorCustomDecayPeriod {
|
||||
DecayingSampleEstimator* e = [DecayingSampleEstimator decayingSampleEstimatorWithInitialEstimate:0 andDecayFactor:0.75 perNSamples:2];
|
||||
|
@ -46,7 +46,7 @@
|
|||
|
||||
[e updateWithNextSample:4];
|
||||
[e updateWithNextSample:4];
|
||||
test([e currentEstimate] == 3);
|
||||
test(e.currentEstimate == 3);
|
||||
}
|
||||
-(void) testDecayingSampleEstimatorWeighted {
|
||||
DecayingSampleEstimator* e1 = [DecayingSampleEstimator decayingSampleEstimatorWithInitialEstimate:0.0 andDecayPerUnitSample:0.25];
|
||||
|
@ -55,60 +55,60 @@
|
|||
[e1 updateWithNextSample:2.0 withSampleWeight:0.5];
|
||||
[e1 updateWithNextSample:2.0 withSampleWeight:0.5];
|
||||
[e2 updateWithNextSample:2.0];
|
||||
test(ABS([e1 currentEstimate] - [e2 currentEstimate]) < 0.00001);
|
||||
test(ABS(e1.currentEstimate - e2.currentEstimate) < 0.00001);
|
||||
|
||||
[e1 updateWithNextSample:-1.0 withSampleWeight:2.0];
|
||||
[e2 updateWithNextSample:-1.0];
|
||||
[e2 updateWithNextSample:-1.0];
|
||||
test(ABS([e1 currentEstimate] - [e2 currentEstimate]) < 0.00001);
|
||||
test(ABS(e1.currentEstimate - e2.currentEstimate) < 0.00001);
|
||||
}
|
||||
-(void) testDecayingSampleEstimatorCornerCase0 {
|
||||
DecayingSampleEstimator* e = [DecayingSampleEstimator decayingSampleEstimatorWithInitialEstimate:1.0 andDecayPerUnitSample:0];
|
||||
test([e decayRatePerUnitSample] == 0);
|
||||
test([e currentEstimate] == 1.0);
|
||||
test(e.currentEstimate == 1.0);
|
||||
|
||||
[e updateWithNextSample:5.0];
|
||||
test([e currentEstimate] == 1.0);
|
||||
test(e.currentEstimate == 1.0);
|
||||
|
||||
[e updateWithNextSample:535325.0];
|
||||
test([e currentEstimate] == 1.0);
|
||||
test(e.currentEstimate == 1.0);
|
||||
|
||||
[e updateWithNextSample:-535325.0];
|
||||
test([e currentEstimate] == 1.0);
|
||||
test(e.currentEstimate == 1.0);
|
||||
|
||||
[e updateWithNextSample:100.0 withSampleWeight:0];
|
||||
test([e currentEstimate] == 1.0);
|
||||
test(e.currentEstimate == 1.0);
|
||||
|
||||
[e updateWithNextSample:200.0 withSampleWeight:100];
|
||||
test([e currentEstimate] == 1.0);
|
||||
test(e.currentEstimate == 1.0);
|
||||
|
||||
[e updateWithNextSample:300.0 withSampleWeight:1];
|
||||
test([e currentEstimate] == 1.0);
|
||||
test(e.currentEstimate == 1.0);
|
||||
}
|
||||
-(void) testDecayingSampleEstimatorCornerCase1 {
|
||||
DecayingSampleEstimator* e = [DecayingSampleEstimator decayingSampleEstimatorWithInitialEstimate:1.0 andDecayPerUnitSample:1];
|
||||
test([e decayRatePerUnitSample] == 1);
|
||||
test([e currentEstimate] == 1.0);
|
||||
test(e.currentEstimate == 1.0);
|
||||
|
||||
[e updateWithNextSample:5.0];
|
||||
test([e currentEstimate] == 5.0);
|
||||
test(e.currentEstimate == 5.0);
|
||||
|
||||
[e updateWithNextSample:535325.0];
|
||||
test([e currentEstimate] == 535325.0);
|
||||
test(e.currentEstimate == 535325.0);
|
||||
|
||||
[e updateWithNextSample:-535325.0];
|
||||
test([e currentEstimate] == -535325.0);
|
||||
test(e.currentEstimate == -535325.0);
|
||||
|
||||
[e updateWithNextSample:100.0 withSampleWeight:0.0001];
|
||||
test([e currentEstimate] == 100.0);
|
||||
test(e.currentEstimate == 100.0);
|
||||
|
||||
[e updateWithNextSample:200.0 withSampleWeight:100];
|
||||
test([e currentEstimate] == 200.0);
|
||||
test(e.currentEstimate == 200.0);
|
||||
|
||||
[e updateWithNextSample:300.0 withSampleWeight:1];
|
||||
test([e currentEstimate] == 300.0);
|
||||
test(e.currentEstimate == 300.0);
|
||||
|
||||
[e updateWithNextSample:400.0 withSampleWeight:0];
|
||||
test([e currentEstimate] == 300.0);
|
||||
test(e.currentEstimate == 300.0);
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue