diff --git a/Podfile.lock b/Podfile.lock index 676549ac9..e84f55de4 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -81,7 +81,7 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: JSQMessagesViewController: - :commit: 9dffc05aa72ad701ecb038a2833cdf53df4b16d7 + :commit: ed9858bd6df609bba83b21a029701cbf13682981 :git: https://github.com/dtsbourg/JSQMessagesViewController SocketRocket: :commit: d0585af165 diff --git a/Pods b/Pods index 4104112c4..94599a456 160000 --- a/Pods +++ b/Pods @@ -1 +1 @@ -Subproject commit 4104112c445b2a0fa19fd15f2b97d7be7d46d3c4 +Subproject commit 94599a4564daeec5315e99bfae427f798925b0b2 diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 00e4e5d41..f569a8520 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -64,7 +64,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { BOOL loggingIsEnabled; - + #ifdef DEBUG // Specified at Product -> Scheme -> Edit Scheme -> Test -> Arguments -> Environment to avoid things like // the phone directory being looked up during tests. @@ -78,7 +78,7 @@ #elif RELEASE loggingIsEnabled = Environment.preferences.loggingIsEnabled; #endif - + if (loggingIsEnabled) { [DebugLogger.sharedInstance enableFileLogging]; } @@ -100,7 +100,7 @@ NSDictionary *remoteNotif = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]; if (remoteNotif) { DDLogInfo(@"Application was launched by tapping a push notification."); - [self application:application didReceiveRemoteNotification:remoteNotif]; + [self application:application didReceiveRemoteNotification:remoteNotif ]; } UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:[NSBundle mainBundle]]; @@ -117,10 +117,10 @@ if (latestCall == nil){ return; } - + InCallViewController *callViewController = [InCallViewController inCallViewControllerWithCallState:latestCall andOptionallyKnownContact:latestCall.potentiallySpecifiedContact]; - + if (latestCall.initiatedLocally == false){ [self.callPickUpFuture.future thenDo:^(NSNumber *accept) { if ([accept isEqualToNumber:@YES]) { @@ -177,9 +177,15 @@ -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { ResponderSessionDescriptor* call; + + if (![self.notificationTracker shouldProcessNotification:userInfo]){ + return; + } + @try { call = [ResponderSessionDescriptor responderSessionDescriptorFromEncryptedRemoteNotification:userInfo]; DDLogDebug(@"Received remote notification. Parsed session descriptor: %@.", call); + self.callPickUpFuture = [TOCFutureSource new]; } @catch (OperationFailed* ex) { DDLogError(@"Error parsing remote notification. Error: %@.", ex); return; @@ -189,26 +195,21 @@ DDLogError(@"Decryption of session descriptor failed"); return; } - self.callPickUpFuture = [TOCFutureSource new]; + [Environment.phoneManager incomingCallWithSession:call]; } --(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { - +- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { + if ([self isRedPhonePush:userInfo]) { - if ([self.notificationTracker shouldProcessNotification:userInfo]){ - [self application:application didReceiveRemoteNotification:userInfo]; - } else{ - DDLogDebug(@"Push already processed. Skipping."); - completionHandler(UIBackgroundFetchResultNewData); - } + [self application:application didReceiveRemoteNotification:userInfo]; } else { [TSSocketManager becomeActive]; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 20 * NSEC_PER_SEC), - dispatch_get_main_queue(), ^{ - completionHandler(UIBackgroundFetchResultNewData); - }); } + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 20 * NSEC_PER_SEC), + dispatch_get_main_queue(), ^{ + completionHandler(UIBackgroundFetchResultNewData); + }); } - (BOOL)isRedPhonePush:(NSDictionary*)pushDict { @@ -243,15 +244,23 @@ } - (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler{ + + [self application:application didReceiveRemoteNotification:userInfo]; if ([identifier isEqualToString:Signal_Call_Accept_Identifier]) { [self.callPickUpFuture trySetResult:@YES]; + completionHandler(); } else if ([identifier isEqualToString:Signal_Call_Decline_Identifier]){ [self.callPickUpFuture trySetResult:@NO]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC), + dispatch_get_main_queue(), ^{ + completionHandler(); + }); } else if ([identifier isEqualToString:Signal_Message_MarkAsRead_Identifier]){ //TODO } else if ([identifier isEqualToString:Signal_Message_View_Identifier]){ //TODO } + completionHandler(); } diff --git a/Signal/src/contact/ContactsManager.m b/Signal/src/contact/ContactsManager.m index 02d53430b..406971337 100644 --- a/Signal/src/contact/ContactsManager.m +++ b/Signal/src/contact/ContactsManager.m @@ -112,11 +112,11 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in #pragma mark - Observables --(ObservableValue *) getObservableContacts { +-(ObservableValue *)getObservableContacts { return observableContactsController; } --(ObservableValue *) getObservableRedPhoneUsers { +-(ObservableValue *)getObservableRedPhoneUsers { return observableRedPhoneUsersController; } diff --git a/Signal/src/phone/signaling/SignalUtil.m b/Signal/src/phone/signaling/SignalUtil.m index cad644fb8..cb00c6bc0 100644 --- a/Signal/src/phone/signaling/SignalUtil.m +++ b/Signal/src/phone/signaling/SignalUtil.m @@ -36,7 +36,7 @@ } -(bool) isHangupForSession:(int64_t)targetSessionId { - return [self.method isEqualToString:@"DELETE"] && [@(targetSessionId) isEqualToNumber:self.tryGetSessionId]; + return [self.method isEqualToString:@"DELETE"] && self.tryGetSessionId?[@(targetSessionId) isEqualToNumber:self.tryGetSessionId]:YES; } -(bool) isBusyForSession:(int64_t)targetSessionId { diff --git a/Signal/src/view controllers/InCallViewController.m b/Signal/src/view controllers/InCallViewController.m index a5f5ad026..dccfdb030 100644 --- a/Signal/src/view controllers/InCallViewController.m +++ b/Signal/src/view controllers/InCallViewController.m @@ -50,9 +50,12 @@ static NSInteger connectingFlashCounter = 0; - (void)viewDidLoad { [super viewDidLoad]; [self showCallState]; - [self setupButtonBorders]; + [self setPotentiallyKnownContact:_potentiallyKnownContact]; [self localizeButtons]; [self linkActions]; + [[[[Environment getCurrent] contactsManager] getObservableContacts] watchLatestValue:^(NSArray *latestContacts) { + [self setPotentiallyKnownContact:[[[Environment getCurrent] contactsManager] latestContactForPhoneNumber:_callState.remoteNumber]]; + } onThread:[NSThread mainThread] untilCancelled:nil]; [UIDevice.currentDevice setProximityMonitoringEnabled:YES]; } @@ -172,7 +175,8 @@ static NSInteger connectingFlashCounter = 0; [_rejectButton setTitle:REJECT_CALL_BUTTON_TITLE forState:UIControlStateNormal]; } -- (void)setupButtonBorders { +- (void)setPotentiallyKnownContact:(Contact *)potentiallyKnownContact { + _potentiallyKnownContact = potentiallyKnownContact; if (_potentiallyKnownContact) { diff --git a/Signal/src/view controllers/MessagesViewController.m b/Signal/src/view controllers/MessagesViewController.m index 2d91a46d6..d0ef17461 100644 --- a/Signal/src/view controllers/MessagesViewController.m +++ b/Signal/src/view controllers/MessagesViewController.m @@ -498,7 +498,7 @@ typedef enum : NSUInteger { return 16.0f; } } - else if ([self shouldShowMessageStatusAtIndexPath:indexPath]) { + else if (msg.messageType == TSOutgoingMessageAdapter) { return 16.0f; }