Retain changes from session database branch.

This commit is contained in:
Matthew Chen 2018-01-10 10:54:17 -05:00
parent b8c6d29170
commit e77c3e6717
27 changed files with 354 additions and 334 deletions

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import <Availability.h> #import <Availability.h>
@ -15,7 +15,7 @@
static const NSUInteger ddLogLevel = DDLogLevelInfo; static const NSUInteger ddLogLevel = DDLogLevelInfo;
#endif #endif
#import <SignalServiceKit/Asserts.h> #import <SignalServiceKit/OWSAsserts.h>
#import <SignalServiceKit/Constraints.h> #import <SignalServiceKit/Constraints.h>
#import <SignalServiceKit/OWSAnalytics.h> #import <SignalServiceKit/OWSAnalytics.h>
#import <SignalServiceKit/OWSDispatch.h> #import <SignalServiceKit/OWSDispatch.h>

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@ -58,7 +58,6 @@
#import <SignalMessaging/UIView+OWS.h> #import <SignalMessaging/UIView+OWS.h>
#import <SignalMessaging/UIViewController+OWS.h> #import <SignalMessaging/UIViewController+OWS.h>
#import <SignalServiceKit/AppVersion.h> #import <SignalServiceKit/AppVersion.h>
#import <SignalServiceKit/Asserts.h>
#import <SignalServiceKit/Contact.h> #import <SignalServiceKit/Contact.h>
#import <SignalServiceKit/ContactsUpdater.h> #import <SignalServiceKit/ContactsUpdater.h>
#import <SignalServiceKit/Cryptography.h> #import <SignalServiceKit/Cryptography.h>
@ -72,6 +71,7 @@
#import <SignalServiceKit/OWSAcknowledgeMessageDeliveryRequest.h> #import <SignalServiceKit/OWSAcknowledgeMessageDeliveryRequest.h>
#import <SignalServiceKit/OWSAnalytics.h> #import <SignalServiceKit/OWSAnalytics.h>
#import <SignalServiceKit/OWSAnalyticsEvents.h> #import <SignalServiceKit/OWSAnalyticsEvents.h>
#import <SignalServiceKit/OWSAsserts.h>
#import <SignalServiceKit/OWSAttachmentsProcessor.h> #import <SignalServiceKit/OWSAttachmentsProcessor.h>
#import <SignalServiceKit/OWSBackgroundTask.h> #import <SignalServiceKit/OWSBackgroundTask.h>
#import <SignalServiceKit/OWSCallAnswerMessage.h> #import <SignalServiceKit/OWSCallAnswerMessage.h>

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "AboutTableViewController.h" #import "AboutTableViewController.h"
@ -75,11 +75,14 @@
threadCount = [[transaction ext:TSThreadDatabaseViewExtensionName] numberOfItemsInAllGroups]; threadCount = [[transaction ext:TSThreadDatabaseViewExtensionName] numberOfItemsInAllGroups];
messageCount = [[transaction ext:TSMessageDatabaseViewExtensionName] numberOfItemsInAllGroups]; messageCount = [[transaction ext:TSMessageDatabaseViewExtensionName] numberOfItemsInAllGroups];
}]; }];
unsigned long long databaseFileSize = [TSStorageManager.sharedManager databaseFileSize];
OWSTableSection *debugSection = [OWSTableSection new]; OWSTableSection *debugSection = [OWSTableSection new];
debugSection.headerTitle = @"Debug"; debugSection.headerTitle = @"Debug";
[debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Threads: %zd", threadCount]]]; [debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Threads: %zd", threadCount]]];
[debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Messages: %zd", messageCount]]]; [debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Messages: %zd", messageCount]]];
[debugSection
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Database size: %llu", databaseFileSize]]];
[contents addSection:debugSection]; [contents addSection:debugSection];
OWSPreferences *preferences = [Environment preferences]; OWSPreferences *preferences = [Environment preferences];

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
import Foundation import Foundation
@ -146,7 +146,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver {
func observeNotifications() { func observeNotifications() {
NotificationCenter.default.addObserver(self, NotificationCenter.default.addObserver(self,
selector:#selector(didBecomeActive), selector:#selector(didBecomeActive),
name:NSNotification.Name.UIApplicationDidBecomeActive, name:NSNotification.Name.OWSApplicationDidBecomeActive,
object:nil) object:nil)
NotificationCenter.default.addObserver(forName: CallAudioServiceSessionChanged, object: nil, queue: nil) { [weak self] _ in NotificationCenter.default.addObserver(forName: CallAudioServiceSessionChanged, object: nil, queue: nil) { [weak self] _ in

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "ConversationViewController.h" #import "ConversationViewController.h"
@ -302,19 +302,19 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillEnterForeground:) selector:@selector(applicationWillEnterForeground:)
name:UIApplicationWillEnterForegroundNotification name:OWSApplicationWillEnterForegroundNotification
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidEnterBackground:) selector:@selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification name:OWSApplicationDidEnterBackgroundNotification
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillResignActive:) selector:@selector(applicationWillResignActive:)
name:UIApplicationWillResignActiveNotification name:OWSApplicationWillResignActiveNotification
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(cancelReadTimer) selector:@selector(cancelReadTimer)
name:UIApplicationDidEnterBackgroundNotification name:OWSApplicationDidEnterBackgroundNotification
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(otherUsersProfileDidChange:) selector:@selector(otherUsersProfileDidChange:)

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
import Foundation import Foundation
@ -127,7 +127,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
object: nil) object: nil)
NotificationCenter.default.addObserver(self, NotificationCenter.default.addObserver(self,
selector: #selector(didBecomeActive), selector: #selector(didBecomeActive),
name: NSNotification.Name.UIApplicationDidBecomeActive, name: NSNotification.Name.OWSApplicationDidBecomeActive,
object: nil) object: nil)
} }

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "HomeViewController.h" #import "HomeViewController.h"
@ -124,24 +124,24 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillEnterForeground:) selector:@selector(applicationWillEnterForeground:)
name:UIApplicationWillEnterForegroundNotification name:OWSApplicationWillEnterForegroundNotification
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidEnterBackground:) selector:@selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification name:OWSApplicationDidEnterBackgroundNotification
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidBecomeActive:) selector:@selector(applicationDidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification name:OWSApplicationDidBecomeActiveNotification
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(yapDatabaseModified:) selector:@selector(yapDatabaseModified:)
name:YapDatabaseModifiedNotification name:YapDatabaseModifiedNotification
object:nil]; object:TSStorageManager.sharedManager.dbNotificationObject];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(yapDatabaseModifiedExternally:) selector:@selector(yapDatabaseModifiedExternally:)
name:YapDatabaseModifiedExternallyNotification name:YapDatabaseModifiedExternallyNotification
object:nil]; object:TSStorageManager.sharedManager.dbNotificationObject];
} }
- (void)dealloc - (void)dealloc

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
import Foundation import Foundation
@ -230,11 +230,11 @@ protocol CallServiceObserver: class {
NotificationCenter.default.addObserver(self, NotificationCenter.default.addObserver(self,
selector: #selector(didEnterBackground), selector: #selector(didEnterBackground),
name: NSNotification.Name.UIApplicationDidEnterBackground, name: NSNotification.Name.OWSApplicationDidEnterBackground,
object: nil) object: nil)
NotificationCenter.default.addObserver(self, NotificationCenter.default.addObserver(self,
selector: #selector(didBecomeActive), selector: #selector(didBecomeActive),
name: NSNotification.Name.UIApplicationDidBecomeActive, name: NSNotification.Name.OWSApplicationDidBecomeActive,
object: nil) object: nil)
} }

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
import Foundation import Foundation
@ -848,7 +848,7 @@ extension URLSessionTask {
} }
// Don't back up Giphy downloads. // Don't back up Giphy downloads.
OWSFileSystem.protectFolder(atPath:dirPath) OWSFileSystem.protectFileOrFolder(atPath:dirPath)
} catch let error as NSError { } catch let error as NSError {
owsFail("\(GiphyAsset.TAG) ensureTempFolder failed: \(dirPath), \(error)") owsFail("\(GiphyAsset.TAG) ensureTempFolder failed: \(dirPath), \(error)")
gifFolderPath = tempDirPath gifFolderPath = tempDirPath

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "MainAppContext.h" #import "MainAppContext.h"
@ -53,28 +53,46 @@ NS_ASSUME_NONNULL_BEGIN
- (void)applicationWillEnterForeground:(NSNotification *)notification - (void)applicationWillEnterForeground:(NSNotification *)notification
{ {
AssertIsOnMainThread();
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__); DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
[NSNotificationCenter.defaultCenter postNotificationName:OWSApplicationWillEnterForegroundNotification object:nil];
} }
- (void)applicationDidEnterBackground:(NSNotification *)notification - (void)applicationDidEnterBackground:(NSNotification *)notification
{ {
AssertIsOnMainThread();
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__); DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
[DDLog flushLog]; [DDLog flushLog];
[NSNotificationCenter.defaultCenter postNotificationName:OWSApplicationDidEnterBackgroundNotification object:nil];
} }
- (void)applicationWillResignActive:(NSNotification *)notification - (void)applicationWillResignActive:(NSNotification *)notification
{ {
AssertIsOnMainThread();
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__); DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
[DDLog flushLog]; [DDLog flushLog];
[NSNotificationCenter.defaultCenter postNotificationName:OWSApplicationWillResignActiveNotification object:nil];
} }
- (void)applicationDidBecomeActive:(NSNotification *)notification - (void)applicationDidBecomeActive:(NSNotification *)notification
{ {
AssertIsOnMainThread();
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__); DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
[NSNotificationCenter.defaultCenter postNotificationName:OWSApplicationDidBecomeActiveNotification object:nil];
} }
- (void)applicationWillTerminate:(NSNotification *)notification - (void)applicationWillTerminate:(NSNotification *)notification
{ {
AssertIsOnMainThread();
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__); DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
[DDLog flushLog]; [DDLog flushLog];
} }

View file

@ -1,10 +1,5 @@
// Grabbed from: https://github.com/cbpowell/MarqueeLabel-Swift/blob/cd331f3cfc3f9d7114ffa5aa4f243f1d5eda9d0d/Classes/MarqueeLabel.swift
// License: MIT License
// //
// MarqueeLabel.swift // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
// Created by Charles Powell on 8/6/14.
// Copyright (c) 2015 Charles Powell. All rights reserved.
// //
import UIKit import UIKit
@ -332,13 +327,11 @@ open class MarqueeLabel: UILabel, CAAnimationDelegate {
} }
} }
/** /**
The length of delay in seconds that the label pauses at the completion of a scroll. The length of delay in seconds that the label pauses at the completion of a scroll.
*/ */
@IBInspectable open var animationDelay: CGFloat = 1.0 @IBInspectable open var animationDelay: CGFloat = 1.0
/** The read-only duration of the scroll animation (not including delay). /** The read-only duration of the scroll animation (not including delay).
The value of this property is calculated from the value set to the `speed` property. If a .duration value is The value of this property is calculated from the value set to the `speed` property. If a .duration value is
@ -419,7 +412,6 @@ open class MarqueeLabel: UILabel, CAAnimationDelegate {
MarqueeLabel.notifyController(controller, message: .Animate) MarqueeLabel.notifyController(controller, message: .Animate)
} }
// //
// MARK: - Initialization // MARK: - Initialization
// //
@ -492,8 +484,8 @@ open class MarqueeLabel: UILabel, CAAnimationDelegate {
NotificationCenter.default.addObserver(self, selector: #selector(MarqueeLabel.labelizeForController(_:)), name: NSNotification.Name(rawValue: MarqueeKeys.Labelize.rawValue), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(MarqueeLabel.labelizeForController(_:)), name: NSNotification.Name(rawValue: MarqueeKeys.Labelize.rawValue), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(MarqueeLabel.animateForController(_:)), name: NSNotification.Name(rawValue: MarqueeKeys.Animate.rawValue), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(MarqueeLabel.animateForController(_:)), name: NSNotification.Name(rawValue: MarqueeKeys.Animate.rawValue), object: nil)
// UIApplication state notifications // UIApplication state notifications
NotificationCenter.default.addObserver(self, selector: #selector(MarqueeLabel.restartLabel), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(MarqueeLabel.restartLabel), name: NSNotification.Name.OWSApplicationDidBecomeActive, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(MarqueeLabel.shutdownLabel), name: NSNotification.Name.UIApplicationDidEnterBackground, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(MarqueeLabel.shutdownLabel), name: NSNotification.Name.OWSApplicationDidEnterBackground, object: nil)
} }
override open func awakeFromNib() { override open func awakeFromNib() {
@ -596,7 +588,7 @@ open class MarqueeLabel: UILabel, CAAnimationDelegate {
awayOffset = 0.0 awayOffset = 0.0
// Remove an additional sublabels (for continuous types) // Remove an additional sublabels (for continuous types)
repliLayer?.instanceCount = 1; repliLayer?.instanceCount = 1
// Set the sublabel frame to calculated labelFrame // Set the sublabel frame to calculated labelFrame
sublabel.frame = labelFrame sublabel.frame = labelFrame
@ -701,13 +693,11 @@ open class MarqueeLabel: UILabel, CAAnimationDelegate {
ScrollStep(timeStep: animationDuration, timingFunction: animationCurve, // Away position, using animationCurve transition, with only leading edge faded in ScrollStep(timeStep: animationDuration, timingFunction: animationCurve, // Away position, using animationCurve transition, with only leading edge faded in
position: .away, edgeFades: .leading), position: .away, edgeFades: .leading),
ScrollStep(timeStep: 60*60*24*365.0, // "Delay" at away, for huge time to effectie stay at away permanently ScrollStep(timeStep: 60*60*24*365.0, // "Delay" at away, for huge time to effectie stay at away permanently
position: .away, edgeFades: .leading), position: .away, edgeFades: .leading)
] ]
} }
} }
// Configure gradient for current condition // Configure gradient for current condition
applyGradientMask(fadeLength, animated: !self.labelize) applyGradientMask(fadeLength, animated: !self.labelize)
@ -842,10 +832,10 @@ open class MarqueeLabel: UILabel, CAAnimationDelegate {
fader = nil fader = nil
} }
#else #else
fader = nil; fader = nil
#endif #endif
scrollCompletionBlock = { [weak self] (finished: Bool) -> () in scrollCompletionBlock = { [weak self] (finished: Bool) -> Void in
guard finished else { guard finished else {
// Do not continue into the next loop // Do not continue into the next loop
return return
@ -1003,7 +993,7 @@ open class MarqueeLabel: UILabel, CAAnimationDelegate {
animation.keyTimes = fadeKeyTimes animation.keyTimes = fadeKeyTimes
animation.timingFunctions = fadeTimingFunctions animation.timingFunctions = fadeTimingFunctions
return (anim: animation, duration: max(totalTime,totalDuration)) return (anim: animation, duration: max(totalTime, totalDuration))
} }
private func applyGradientMask(_ fadeLength: CGFloat, animated: Bool, firstStep: MarqueeStep? = nil) { private func applyGradientMask(_ fadeLength: CGFloat, animated: Bool, firstStep: MarqueeStep? = nil) {
@ -1132,7 +1122,6 @@ open class MarqueeLabel: UILabel, CAAnimationDelegate {
} }
} }
// //
// MARK: - Private details // MARK: - Private details
// //
@ -1162,8 +1151,8 @@ open class MarqueeLabel: UILabel, CAAnimationDelegate {
// Draw only background color // Draw only background color
if let bgColor = backgroundColor { if let bgColor = backgroundColor {
ctx.setFillColor(bgColor.cgColor); ctx.setFillColor(bgColor.cgColor)
ctx.fill(layer.bounds); ctx.fill(layer.bounds)
} }
} }
@ -1202,7 +1191,6 @@ open class MarqueeLabel: UILabel, CAAnimationDelegate {
} }
} }
// //
// MARK: - Label Control // MARK: - Label Control
// //
@ -1573,7 +1561,6 @@ open class MarqueeLabel: UILabel, CAAnimationDelegate {
} }
} }
// //
// MARK: - Support // MARK: - Support
// //
@ -1592,7 +1579,6 @@ open class MarqueeLabel: UILabel, CAAnimationDelegate {
} }
// //
// MARK: - Support // MARK: - Support
// //
@ -1602,7 +1588,6 @@ public protocol MarqueeStep {
var edgeFades: EdgeFade { get } var edgeFades: EdgeFade { get }
} }
/** /**
`ScrollStep` types define the label position at a specified time delta since the last `ScrollStep` step, as well as `ScrollStep` types define the label position at a specified time delta since the last `ScrollStep` step, as well as
the animation curve to that position and edge fade state at the position the animation curve to that position and edge fade state at the position
@ -1661,7 +1646,6 @@ public struct ScrollStep: MarqueeStep {
} }
} }
/** /**
`FadeStep` types allow additional edge fade state definitions, around the states defined by the `ScrollStep` steps of `FadeStep` types allow additional edge fade state definitions, around the states defined by the `ScrollStep` steps of
a sequence. `FadeStep` steps are defined by the time delta to the preceding or subsequent `ScrollStep` step and the timing a sequence. `FadeStep` steps are defined by the time delta to the preceding or subsequent `ScrollStep` step and the timing
@ -1706,21 +1690,21 @@ public struct FadeStep: MarqueeStep {
} }
} }
public struct EdgeFade : OptionSet { public struct EdgeFade: OptionSet {
public let rawValue: Int public let rawValue: Int
public static let leading = EdgeFade(rawValue: 1 << 0) public static let leading = EdgeFade(rawValue: 1 << 0)
public static let trailing = EdgeFade(rawValue: 1 << 1) public static let trailing = EdgeFade(rawValue: 1 << 1)
public init(rawValue: Int) { public init(rawValue: Int) {
self.rawValue = rawValue; self.rawValue = rawValue
} }
} }
// Define helpful typealiases // Define helpful typealiases
fileprivate typealias MLAnimationCompletionBlock = (_ finished: Bool) -> () fileprivate typealias MLAnimationCompletionBlock = (_ finished: Bool) -> Void
fileprivate typealias MLAnimation = (anim: CAKeyframeAnimation, duration: CGFloat) fileprivate typealias MLAnimation = (anim: CAKeyframeAnimation, duration: CGFloat)
fileprivate class GradientSetupAnimation: CABasicAnimation { private class GradientSetupAnimation: CABasicAnimation {
} }
fileprivate extension UIResponder { fileprivate extension UIResponder {
@ -1796,14 +1780,14 @@ fileprivate extension CAMediaTimingFunction {
return t0 return t0
} }
func YforCurveAt(_ t: CGFloat, controlPoints:[CGPoint]) -> CGFloat { func YforCurveAt(_ t: CGFloat, controlPoints: [CGPoint]) -> CGFloat {
let P0 = controlPoints[0] let P0 = controlPoints[0]
let P1 = controlPoints[1] let P1 = controlPoints[1]
let P2 = controlPoints[2] let P2 = controlPoints[2]
let P3 = controlPoints[3] let P3 = controlPoints[3]
// Per http://en.wikipedia.org/wiki/Bezier_curve#Cubic_B.C3.A9zier_curves // Per http://en.wikipedia.org/wiki/Bezier_curve#Cubic_B.C3.A9zier_curves
let y0 = (pow((1.0 - t),3.0) * P0.y) let y0 = (pow((1.0 - t), 3.0) * P0.y)
let y1 = (3.0 * pow(1.0 - t, 2.0) * t * P1.y) let y1 = (3.0 * pow(1.0 - t, 2.0) * t * P1.y)
let y2 = (3.0 * (1.0 - t) * pow(t, 2.0) * P2.y) let y2 = (3.0 * (1.0 - t) * pow(t, 2.0) * P2.y)
let y3 = (pow(t, 3.0) * P3.y) let y3 = (pow(t, 3.0) * P3.y)
@ -1819,7 +1803,7 @@ fileprivate extension CAMediaTimingFunction {
// Per http://en.wikipedia.org/wiki/Bezier_curve#Cubic_B.C3.A9zier_curves // Per http://en.wikipedia.org/wiki/Bezier_curve#Cubic_B.C3.A9zier_curves
let x0 = (pow((1.0 - t),3.0) * P0.x) let x0 = (pow((1.0 - t), 3.0) * P0.x)
let x1 = (3.0 * pow(1.0 - t, 2.0) * t * P1.x) let x1 = (3.0 * pow(1.0 - t, 2.0) * t * P1.x)
let x2 = (3.0 * (1.0 - t) * pow(t, 2.0) * P2.x) let x2 = (3.0 * (1.0 - t) * pow(t, 2.0) * P2.x)
let x3 = (pow(t, 3.0) * P3.x) let x3 = (pow(t, 3.0) * P3.x)
@ -1852,4 +1836,3 @@ fileprivate extension CAMediaTimingFunction {
return pointArray return pointArray
} }
} }

View file

@ -656,7 +656,7 @@
"FINGERPRINT_SCAN_VERIFY_BUTTON" = "Mark as Verified"; "FINGERPRINT_SCAN_VERIFY_BUTTON" = "Mark as Verified";
/* No comment provided by engineer. */ /* No comment provided by engineer. */
"FINGERPRINT_SHRED_KEYMATERIAL_BUTTON" = "Reset this session."; "FINGERPRINT_SHRED_KEYMATERIAL_BUTTON" = "Reset this session";
/* Accessibilty label for finishing new group */ /* Accessibilty label for finishing new group */
"FINISH_GROUP_CREATION_LABEL" = "Finish creating group"; "FINISH_GROUP_CREATION_LABEL" = "Finish creating group";

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import <Availability.h> #import <Availability.h>
@ -15,7 +15,7 @@
static const NSUInteger ddLogLevel = DDLogLevelInfo; static const NSUInteger ddLogLevel = DDLogLevelInfo;
#endif #endif
#import <SignalServiceKit/Asserts.h> #import <SignalServiceKit/OWSAsserts.h>
#import <SignalServiceKit/Constraints.h> #import <SignalServiceKit/Constraints.h>
#import <SignalServiceKit/OWSAnalytics.h> #import <SignalServiceKit/OWSAnalytics.h>
#import <SignalServiceKit/OWSDispatch.h> #import <SignalServiceKit/OWSDispatch.h>

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "ThreadViewHelper.h" #import "ThreadViewHelper.h"
@ -57,11 +57,11 @@ NS_ASSUME_NONNULL_BEGIN
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillEnterForeground:) selector:@selector(applicationWillEnterForeground:)
name:UIApplicationWillEnterForegroundNotification name:OWSApplicationWillEnterForegroundNotification
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidEnterBackground:) selector:@selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification name:OWSApplicationDidEnterBackgroundNotification
object:nil]; object:nil];
self.shouldObserveDBModifications self.shouldObserveDBModifications

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "OWSAudioAttachmentPlayer.h" #import "OWSAudioAttachmentPlayer.h"
@ -48,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidEnterBackground:) selector:@selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification name:OWSApplicationDidEnterBackgroundNotification
object:nil]; object:nil];
return self; return self;

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
import Foundation import Foundation
@ -57,7 +57,7 @@ class ContactsFrameworkContactStoreAdaptee: ContactStoreAdaptee {
self.changeHandler = changeHandler self.changeHandler = changeHandler
self.lastSortOrder = CNContactsUserDefaults.shared().sortOrder self.lastSortOrder = CNContactsUserDefaults.shared().sortOrder
NotificationCenter.default.addObserver(self, selector: #selector(runChangeHandler), name: .CNContactStoreDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(runChangeHandler), name: .CNContactStoreDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(didBecomeActive), name: .UIApplicationDidBecomeActive, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(didBecomeActive), name: .OWSApplicationDidBecomeActive, object: nil)
} }
@objc @objc

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "AppSetup.h" #import "AppSetup.h"
@ -7,6 +7,7 @@
#import "Release.h" #import "Release.h"
#import "VersionMigrations.h" #import "VersionMigrations.h"
#import <AxolotlKit/SessionCipher.h> #import <AxolotlKit/SessionCipher.h>
#import <SignalMessaging/OWSDatabaseMigration.h>
#import <SignalMessaging/OWSProfileManager.h> #import <SignalMessaging/OWSProfileManager.h>
#import <SignalMessaging/SignalMessaging-Swift.h> #import <SignalMessaging/SignalMessaging-Swift.h>
#import <SignalServiceKit/OWSStorage.h> #import <SignalServiceKit/OWSStorage.h>
@ -40,6 +41,10 @@ NS_ASSUME_NONNULL_BEGIN
profileManager:OWSProfileManager.sharedManager]; profileManager:OWSProfileManager.sharedManager];
[TextSecureKitEnv setSharedEnv:sharedEnv]; [TextSecureKitEnv setSharedEnv:sharedEnv];
// Register renamed classes.
[NSKeyedUnarchiver setClass:[OWSUserProfile class] forClassName:[OWSUserProfile collection]];
[NSKeyedUnarchiver setClass:[OWSDatabaseMigration class] forClassName:[OWSDatabaseMigration collection]];
[OWSStorage setupWithSafeBlockingMigrations:^{ [OWSStorage setupWithSafeBlockingMigrations:^{
[VersionMigrations runSafeBlockingMigrations]; [VersionMigrations runSafeBlockingMigrations];
}]; }];

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "OWSProfileManager.h" #import "OWSProfileManager.h"
@ -124,7 +124,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
{ {
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidBecomeActive:) selector:@selector(applicationDidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification name:OWSApplicationDidBecomeActiveNotification
object:nil]; object:nil];
} }
@ -1129,7 +1129,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
[OWSFileSystem ensureDirectoryExists:profileAvatarsDirPath]; [OWSFileSystem ensureDirectoryExists:profileAvatarsDirPath];
[OWSFileSystem protectFolderAtPath:profileAvatarsDirPath]; [OWSFileSystem protectFileOrFolderAtPath:profileAvatarsDirPath];
}); });
return profileAvatarsDirPath; return profileAvatarsDirPath;
} }

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "OWSUserProfile.h" #import "OWSUserProfile.h"
@ -112,7 +112,7 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
__block BOOL didChange = YES; __block BOOL didChange = YES;
[dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
NSString *collection = [[self class] collection]; NSString *collection = [[self class] collection];
OWSUserProfile *latestInstance = [transaction objectForKey:self.uniqueId inCollection:collection]; OWSUserProfile *_Nullable latestInstance = [transaction objectForKey:self.uniqueId inCollection:collection];
if (latestInstance) { if (latestInstance) {
changeBlock(latestInstance); changeBlock(latestInstance);

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "DebugLogger.h" #import "DebugLogger.h"
@ -35,7 +35,7 @@
{ {
NSString *dirPath = [[OWSFileSystem cachesDirectoryPath] stringByAppendingPathComponent:@"Logs"]; NSString *dirPath = [[OWSFileSystem cachesDirectoryPath] stringByAppendingPathComponent:@"Logs"];
[OWSFileSystem ensureDirectoryExists:dirPath]; [OWSFileSystem ensureDirectoryExists:dirPath];
[OWSFileSystem protectFolderAtPath:dirPath]; [OWSFileSystem protectFileOrFolderAtPath:dirPath];
return dirPath; return dirPath;
} }
@ -44,7 +44,7 @@
NSString *dirPath = NSString *dirPath =
[[OWSFileSystem appSharedDataDirectoryPath] stringByAppendingPathComponent:@"ShareExtensionLogs"]; [[OWSFileSystem appSharedDataDirectoryPath] stringByAppendingPathComponent:@"ShareExtensionLogs"];
[OWSFileSystem ensureDirectoryExists:dirPath]; [OWSFileSystem ensureDirectoryExists:dirPath];
[OWSFileSystem protectFolderAtPath:dirPath]; [OWSFileSystem protectFileOrFolderAtPath:dirPath];
return dirPath; return dirPath;
} }

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
import Foundation import Foundation
@ -42,7 +42,7 @@ public class DeviceSleepManager: NSObject {
NotificationCenter.default.addObserver(self, NotificationCenter.default.addObserver(self,
selector:#selector(didEnterBackground), selector:#selector(didEnterBackground),
name:NSNotification.Name.UIApplicationDidEnterBackground, name:NSNotification.Name.OWSApplicationDidEnterBackground,
object:nil) object:nil)
} }

View file

@ -1,8 +1,9 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "OWSPreferences.h" #import "OWSPreferences.h"
#import <SignalServiceKit/AppContext.h>
#import <SignalServiceKit/NSUserDefaults+OWS.h> #import <SignalServiceKit/NSUserDefaults+OWS.h>
#import <SignalServiceKit/TSStorageHeaders.h> #import <SignalServiceKit/TSStorageHeaders.h>
#import <SignalServiceKit/YapDatabaseConnection+OWS.h> #import <SignalServiceKit/YapDatabaseConnection+OWS.h>
@ -24,7 +25,7 @@ NSString *const OWSPreferencesKeyCallKitPrivacyEnabled = @"CallKitPrivacyEnabled
NSString *const OWSPreferencesKeyCallsHideIPAddress = @"CallsHideIPAddress"; NSString *const OWSPreferencesKeyCallsHideIPAddress = @"CallsHideIPAddress";
NSString *const OWSPreferencesKeyHasDeclinedNoContactsView = @"hasDeclinedNoContactsView"; NSString *const OWSPreferencesKeyHasDeclinedNoContactsView = @"hasDeclinedNoContactsView";
NSString *const OWSPreferencesKeyIOSUpgradeNagVersion = @"iOSUpgradeNagVersion"; NSString *const OWSPreferencesKeyIOSUpgradeNagVersion = @"iOSUpgradeNagVersion";
NSString *const OWSPreferencesKey_IsReadyForAppExtensions = @"isReadyForAppExtensions2"; NSString *const OWSPreferencesKey_IsReadyForAppExtensions = @"isReadyForAppExtensions_5";
NSString *const OWSPreferencesKey_IsRegistered = @"OWSPreferencesKey_IsRegistered"; NSString *const OWSPreferencesKey_IsRegistered = @"OWSPreferencesKey_IsRegistered";
@implementation OWSPreferences @implementation OWSPreferences
@ -78,6 +79,8 @@ NSString *const OWSPreferencesKey_IsRegistered = @"OWSPreferencesKey_IsRegistere
+ (void)setIsReadyForAppExtensions + (void)setIsReadyForAppExtensions
{ {
OWSAssert(CurrentAppContext().isMainApp);
[NSUserDefaults.appUserDefaults setObject:@(YES) forKey:OWSPreferencesKey_IsReadyForAppExtensions]; [NSUserDefaults.appUserDefaults setObject:@(YES) forKey:OWSPreferencesKey_IsReadyForAppExtensions];
[NSUserDefaults.appUserDefaults synchronize]; [NSUserDefaults.appUserDefaults synchronize];
} }
@ -95,6 +98,8 @@ NSString *const OWSPreferencesKey_IsRegistered = @"OWSPreferencesKey_IsRegistere
+ (void)setIsRegistered:(BOOL)value + (void)setIsRegistered:(BOOL)value
{ {
OWSAssert(CurrentAppContext().isMainApp);
[NSUserDefaults.appUserDefaults setObject:@(value) forKey:OWSPreferencesKey_IsRegistered]; [NSUserDefaults.appUserDefaults setObject:@(value) forKey:OWSPreferencesKey_IsRegistered];
[NSUserDefaults.appUserDefaults synchronize]; [NSUserDefaults.appUserDefaults synchronize];
} }
@ -143,6 +148,8 @@ NSString *const OWSPreferencesKey_IsRegistered = @"OWSPreferencesKey_IsRegistere
+ (void)setIsLoggingEnabled:(BOOL)flag + (void)setIsLoggingEnabled:(BOOL)flag
{ {
OWSAssert(CurrentAppContext().isMainApp);
// Logging preferences are stored in UserDefaults instead of the database, so that we can (optionally) start // Logging preferences are stored in UserDefaults instead of the database, so that we can (optionally) start
// logging before the database is initialized. This is important because sometimes there are problems *with* the // logging before the database is initialized. This is important because sometimes there are problems *with* the
// database initialization, and without logging it would be hard to track down. // database initialization, and without logging it would be hard to track down.

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "TSPreKeyManager.h" #import "TSPreKeyManager.h"
@ -91,9 +91,10 @@ static const NSTimeInterval kSignedPreKeyUpdateFailureMaxFailureDuration = 10 *
+ (void)checkPreKeysIfNecessary + (void)checkPreKeysIfNecessary
{ {
if (CurrentAppContext().isMainApp) { if (!CurrentAppContext().isMainApp) {
OWSAssert(CurrentAppContext().isMainAppAndActive); return;
} }
OWSAssert(CurrentAppContext().isMainAppAndActive);
// Update the prekey check timestamp. // Update the prekey check timestamp.
dispatch_async(TSPreKeyManager.prekeyQueue, ^{ dispatch_async(TSPreKeyManager.prekeyQueue, ^{
@ -214,6 +215,10 @@ static const NSTimeInterval kSignedPreKeyUpdateFailureMaxFailureDuration = 10 *
+ (void)checkPreKeys + (void)checkPreKeys
{ {
if (!CurrentAppContext().isMainApp) {
return;
}
// Optimistically mark the prekeys as checked. This // Optimistically mark the prekeys as checked. This
// de-bounces prekey checks. // de-bounces prekey checks.
// //

View file

@ -1,8 +1,9 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "OWSBlockingManager.h" #import "OWSBlockingManager.h"
#import "AppContext.h"
#import "NSNotificationCenter+OWS.h" #import "NSNotificationCenter+OWS.h"
#import "OWSBlockedPhoneNumbersMessage.h" #import "OWSBlockedPhoneNumbersMessage.h"
#import "OWSMessageSender.h" #import "OWSMessageSender.h"
@ -86,7 +87,7 @@ NSString *const kOWSBlockingManager_SyncedBlockedPhoneNumbersKey = @"kOWSBlockin
{ {
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidBecomeActive:) selector:@selector(applicationDidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification name:OWSApplicationDidBecomeActiveNotification
object:nil]; object:nil];
} }

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "OWSDisappearingMessagesJob.h" #import "OWSDisappearingMessagesJob.h"
@ -57,11 +57,11 @@ NS_ASSUME_NONNULL_BEGIN
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidBecomeActive:) selector:@selector(applicationDidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification name:OWSApplicationDidBecomeActiveNotification
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillResignActive:) selector:@selector(applicationWillResignActive:)
name:UIApplicationWillResignActiveNotification name:OWSApplicationWillResignActiveNotification
object:nil]; object:nil];
return self; return self;

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "OWSFailedAttachmentDownloadsJob.h" #import "OWSFailedAttachmentDownloadsJob.h"
@ -82,7 +82,6 @@ static NSString *const OWSFailedAttachmentDownloadsJobAttachmentStateIndex = @"i
[self enumerateAttemptingOutAttachmentsWithBlock:^(TSAttachmentPointer *attachment) { [self enumerateAttemptingOutAttachmentsWithBlock:^(TSAttachmentPointer *attachment) {
// sanity check // sanity check
if (attachment.state != TSAttachmentPointerStateFailed) { if (attachment.state != TSAttachmentPointerStateFailed) {
DDLogDebug(@"%@ marking attachment as failed", self.logTag);
attachment.state = TSAttachmentPointerStateFailed; attachment.state = TSAttachmentPointerStateFailed;
[attachment saveWithTransaction:transaction]; [attachment saveWithTransaction:transaction];
count++; count++;

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@ -11,11 +11,10 @@ static const NSUInteger ddLogLevel = DDLogLevelAll;
#else #else
static const NSUInteger ddLogLevel = DDLogLevelInfo; static const NSUInteger ddLogLevel = DDLogLevelInfo;
#endif #endif
#import "Asserts.h"
#import "Constraints.h" #import "Constraints.h"
#import "NSObject+OWS.h" #import "NSObject+OWS.h"
#import "OWSAnalytics.h" #import "OWSAnalytics.h"
#import "OWSAsserts.h"
#import "OWSDispatch.h" #import "OWSDispatch.h"
#import "iOSVersions.h" #import "iOSVersions.h"