From 654bdb1a85c7fbf98b8babfc8125983777f979ac Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 12 Jan 2017 15:37:37 -0500 Subject: [PATCH] Add WebRTC setting. // FREEBIE --- Podfile | 2 +- Podfile.lock | 8 +- Signal/src/Models/AccountManager.swift | 19 ++-- Signal/src/Storyboard/Main.storyboard | 68 +++++++------- .../src/environment/PropertyListPreferences.h | 7 ++ .../src/environment/PropertyListPreferences.m | 17 ++++ Signal/src/environment/VersionMigrations.m | 10 +-- .../AdvancedSettingsTableViewController.m | 89 +++++++++++++++---- .../SettingsTableViewController.m | 8 +- .../translations/en.lproj/Localizable.strings | 25 ++++-- 10 files changed, 170 insertions(+), 83 deletions(-) diff --git a/Podfile b/Podfile index eb9383309..051fcf56a 100644 --- a/Podfile +++ b/Podfile @@ -4,7 +4,7 @@ source 'https://github.com/CocoaPods/Specs.git' target 'Signal' do pod 'SocketRocket', :git => 'https://github.com/facebook/SocketRocket.git' pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git' - pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git', branch: 'mkirk/webrtc' + pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git', branch: 'charlesmchen/webrtcSetting2' #pod 'SignalServiceKit', path: '../SignalServiceKit' pod 'OpenSSL' pod 'PastelogKit', '~> 1.3' diff --git a/Podfile.lock b/Podfile.lock index 945985c31..9d1e48793 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -123,7 +123,7 @@ DEPENDENCIES: - PastelogKit (~> 1.3) - PureLayout - SCWaveformView (~> 1.0) - - SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`, branch `mkirk/webrtc`) + - SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`, branch `charlesmchen/webrtcSetting2`) - SocketRocket (from `https://github.com/facebook/SocketRocket.git`) - ZXingObjC @@ -131,7 +131,7 @@ EXTERNAL SOURCES: AxolotlKit: :git: https://github.com/WhisperSystems/SignalProtocolKit.git SignalServiceKit: - :branch: mkirk/webrtc + :branch: charlesmchen/webrtcSetting2 :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :git: https://github.com/facebook/SocketRocket.git @@ -141,7 +141,7 @@ CHECKOUT OPTIONS: :commit: 714f5ebe199ecc999b33c6f97a4bb57e2db90e75 :git: https://github.com/WhisperSystems/SignalProtocolKit.git SignalServiceKit: - :commit: d1aa253f87d28ddd47ae4612a654de021d865877 + :commit: 08ba42c5635e10205daa3930e3a8550f9048730d :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :commit: 41b57bb2fc292a814f758441a05243eb38457027 @@ -173,6 +173,6 @@ SPEC CHECKSUMS: YapDatabase: b1e43555a34a5298e23a045be96817a5ef0da58f ZXingObjC: bf15b3814f7a105b6d99f47da2333c93a063650a -PODFILE CHECKSUM: 2ae77bac38b8d23b14175ac42d09dd8fce65bb5b +PODFILE CHECKSUM: 00f591b97e32f22474fd96dc29e9ae2fbf9a3075 COCOAPODS: 1.0.1 diff --git a/Signal/src/Models/AccountManager.swift b/Signal/src/Models/AccountManager.swift index a568036f1..97f31458e 100644 --- a/Signal/src/Models/AccountManager.swift +++ b/Signal/src/Models/AccountManager.swift @@ -1,5 +1,6 @@ -// Created by Michael Kirk on 10/25/16. -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// import Foundation import PromiseKit @@ -8,13 +9,13 @@ import PromiseKit * Signal is actually two services - textSecure for messages and red phone (for calls). * AccountManager delegates to both. */ -class AccountManager : NSObject { +class AccountManager: NSObject { let TAG = "[AccountManager]" let textSecureAccountManager: TSAccountManager let networkManager: TSNetworkManager let redPhoneAccountManager: RPAccountManager - required init(textSecureAccountManager:TSAccountManager, redPhoneAccountManager:RPAccountManager) { + required init(textSecureAccountManager: TSAccountManager, redPhoneAccountManager: RPAccountManager) { self.networkManager = textSecureAccountManager.networkManager self.textSecureAccountManager = textSecureAccountManager self.redPhoneAccountManager = redPhoneAccountManager @@ -23,7 +24,7 @@ class AccountManager : NSObject { // MARK: registration @objc func register(verificationCode: String) -> AnyPromise { - return AnyPromise(register(verificationCode: verificationCode)); + return AnyPromise(register(verificationCode: verificationCode)) } func register(verificationCode: String) -> Promise { @@ -38,7 +39,7 @@ class AccountManager : NSObject { fulfill() } }.then { - Logger.debug("\(self.TAG) verification code looks well formed."); + Logger.debug("\(self.TAG) verification code looks well formed.") return self.registerForTextSecure(verificationCode: verificationCode) }.then { Logger.debug("\(self.TAG) successfully registered for TextSecure") @@ -53,7 +54,9 @@ class AccountManager : NSObject { private func registerForTextSecure(verificationCode: String) -> Promise { return Promise { fulfill, reject in + let isWebRTCEnabled = Environment.preferences().isWebRTCEnabled() self.textSecureAccountManager.verifyAccount(withCode:verificationCode, + isWebRTCEnabled:isWebRTCEnabled, success:fulfill, failure:reject) } @@ -87,8 +90,8 @@ class AccountManager : NSObject { }.then { Logger.info("\(self.TAG) Successfully updated red phone push tokens.") // TODO code cleanup - convert to `return Promise(value: nil)` and test - return Promise { fulfill, reject in - fulfill(); + return Promise { fulfill, _ in + fulfill() } } } diff --git a/Signal/src/Storyboard/Main.storyboard b/Signal/src/Storyboard/Main.storyboard index ae9ff956b..f3bdf6918 100644 --- a/Signal/src/Storyboard/Main.storyboard +++ b/Signal/src/Storyboard/Main.storyboard @@ -1,11 +1,11 @@ - + - + @@ -431,7 +431,7 @@ - +