Merge branch 'charlesmchen/unifyTag'
This commit is contained in:
commit
a635a5d1ca
@ -14,8 +14,6 @@ import SignalMessaging
|
||||
*/
|
||||
@objc public class MultiDeviceProfileKeyUpdateJob: NSObject {
|
||||
|
||||
let TAG = "[MultiDeviceProfileKeyUpdateJob]"
|
||||
|
||||
private let profileKey: OWSAES256Key
|
||||
private let identityManager: OWSIdentityManager
|
||||
private let messageSender: MessageSender
|
||||
@ -38,7 +36,7 @@ import SignalMessaging
|
||||
|
||||
func run(retryDelay: TimeInterval = 1) {
|
||||
guard let localNumber = TSAccountManager.localNumber() else {
|
||||
owsFail("\(self.TAG) localNumber was unexpectedly nil")
|
||||
owsFail("\(self.logTag) localNumber was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
@ -66,10 +64,10 @@ import SignalMessaging
|
||||
contentType: OWSMimeTypeApplicationOctetStream,
|
||||
in: syncContactsMessage,
|
||||
success: {
|
||||
Logger.info("\(self.TAG) Successfully synced profile key")
|
||||
Logger.info("\(self.logTag) Successfully synced profile key")
|
||||
},
|
||||
failure: { error in
|
||||
Logger.error("\(self.TAG) in \(#function) failed with error: \(error) retrying in \(retryDelay)s.")
|
||||
Logger.error("\(self.logTag) in \(#function) failed with error: \(error) retrying in \(retryDelay)s.")
|
||||
after(interval: retryDelay).then {
|
||||
self.run(retryDelay: retryDelay * 2)
|
||||
}.retainUntilComplete()
|
||||
|
||||
@ -9,8 +9,6 @@ import SignalServiceKit
|
||||
@objc(OWSSessionResetJob)
|
||||
public class SessionResetJob: NSObject {
|
||||
|
||||
let TAG = "SessionResetJob"
|
||||
|
||||
let recipientId: String
|
||||
let thread: TSThread
|
||||
let primaryStorage: OWSPrimaryStorage
|
||||
@ -24,11 +22,11 @@ public class SessionResetJob: NSObject {
|
||||
}
|
||||
|
||||
func run() {
|
||||
Logger.info("\(TAG) Local user reset session.")
|
||||
Logger.info("\(logTag) Local user reset session.")
|
||||
|
||||
let dbConnection = OWSPrimaryStorage.shared().newDatabaseConnection()
|
||||
dbConnection.asyncReadWrite { (transaction) in
|
||||
Logger.info("\(self.TAG) deleting sessions for recipient: \(self.recipientId)")
|
||||
Logger.info("\(self.logTag) deleting sessions for recipient: \(self.recipientId)")
|
||||
self.primaryStorage.deleteAllSessions(forContact: self.recipientId, protocolContext: transaction)
|
||||
|
||||
DispatchQueue.main.async {
|
||||
@ -41,7 +39,7 @@ public class SessionResetJob: NSObject {
|
||||
// Otherwise if we send another message before them, they wont have the session to decrypt it.
|
||||
self.primaryStorage.archiveAllSessions(forContact: self.recipientId, protocolContext: transaction)
|
||||
}
|
||||
Logger.info("\(self.TAG) successfully sent EndSessionMessage.")
|
||||
Logger.info("\(self.logTag) successfully sent EndSessionMessage.")
|
||||
let message = TSInfoMessage(timestamp: NSDate.ows_millisecondTimeStamp(),
|
||||
in: self.thread,
|
||||
messageType: TSInfoMessageType.typeSessionDidEnd)
|
||||
@ -58,7 +56,7 @@ public class SessionResetJob: NSObject {
|
||||
// Otherwise if we send another message before them, they wont have the session to decrypt it.
|
||||
self.primaryStorage.archiveAllSessions(forContact: self.recipientId, protocolContext: transaction)
|
||||
}
|
||||
Logger.error("\(self.TAG) failed to send EndSessionMessage with error: \(error.localizedDescription)")
|
||||
Logger.error("\(self.logTag) failed to send EndSessionMessage with error: \(error.localizedDescription)")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ import SignalServiceKit
|
||||
|
||||
@objc(OWSSyncPushTokensJob)
|
||||
class SyncPushTokensJob: NSObject {
|
||||
let TAG = "[SyncPushTokensJob]"
|
||||
|
||||
@objc public static let PushTokensDidChange = Notification.Name("PushTokensDidChange")
|
||||
|
||||
@ -32,7 +31,7 @@ class SyncPushTokensJob: NSObject {
|
||||
}
|
||||
|
||||
func run() -> Promise<Void> {
|
||||
Logger.info("\(TAG) Starting.")
|
||||
Logger.info("\(logTag) Starting.")
|
||||
|
||||
let runPromise: Promise<Void> = DispatchQueue.main.promise {
|
||||
// HACK: no-op dispatch to work around a bug in PromiseKit/Swift which won't compile
|
||||
@ -42,36 +41,36 @@ class SyncPushTokensJob: NSObject {
|
||||
}.then {
|
||||
return self.pushRegistrationManager.requestPushTokens()
|
||||
}.then { (pushToken: String, voipToken: String) in
|
||||
Logger.info("\(self.TAG) finished: requesting push tokens")
|
||||
Logger.info("\(self.logTag) finished: requesting push tokens")
|
||||
var shouldUploadTokens = false
|
||||
|
||||
if self.preferences.getPushToken() != pushToken || self.preferences.getVoipToken() != voipToken {
|
||||
Logger.debug("\(self.TAG) Push tokens changed.")
|
||||
Logger.debug("\(self.logTag) Push tokens changed.")
|
||||
shouldUploadTokens = true
|
||||
} else if !self.uploadOnlyIfStale {
|
||||
Logger.debug("\(self.TAG) Forced uploading, even though tokens didn't change.")
|
||||
Logger.debug("\(self.logTag) Forced uploading, even though tokens didn't change.")
|
||||
shouldUploadTokens = true
|
||||
}
|
||||
|
||||
if AppVersion.sharedInstance().lastAppVersion != AppVersion.sharedInstance().currentAppVersion {
|
||||
Logger.info("\(self.TAG) Uploading due to fresh install or app upgrade.")
|
||||
Logger.info("\(self.logTag) Uploading due to fresh install or app upgrade.")
|
||||
shouldUploadTokens = true
|
||||
}
|
||||
|
||||
guard shouldUploadTokens else {
|
||||
Logger.info("\(self.TAG) No reason to upload pushToken: \(pushToken), voipToken: \(voipToken)")
|
||||
Logger.info("\(self.logTag) No reason to upload pushToken: \(pushToken), voipToken: \(voipToken)")
|
||||
return Promise(value: ())
|
||||
}
|
||||
|
||||
Logger.warn("\(self.TAG) uploading tokens to account servers. pushToken: \(pushToken), voipToken: \(voipToken)")
|
||||
Logger.warn("\(self.logTag) uploading tokens to account servers. pushToken: \(pushToken), voipToken: \(voipToken)")
|
||||
return self.accountManager.updatePushTokens(pushToken: pushToken, voipToken: voipToken).then {
|
||||
Logger.info("\(self.TAG) successfully updated push tokens on server")
|
||||
Logger.info("\(self.logTag) successfully updated push tokens on server")
|
||||
return self.recordPushTokensLocally(pushToken: pushToken, voipToken: voipToken)
|
||||
}
|
||||
}.then {
|
||||
Logger.info("\(self.TAG) completed successfully.")
|
||||
Logger.info("\(self.logTag) completed successfully.")
|
||||
}.catch { error in
|
||||
Logger.error("\(self.TAG) in \(#function): Failed with error: \(error).")
|
||||
Logger.error("\(self.logTag) in \(#function): Failed with error: \(error).")
|
||||
}
|
||||
|
||||
runPromise.retainUntilComplete()
|
||||
@ -92,18 +91,18 @@ class SyncPushTokensJob: NSObject {
|
||||
}
|
||||
|
||||
private func recordPushTokensLocally(pushToken: String, voipToken: String) -> Promise<Void> {
|
||||
Logger.warn("\(TAG) Recording push tokens locally. pushToken: \(pushToken), voipToken: \(voipToken)")
|
||||
Logger.warn("\(logTag) Recording push tokens locally. pushToken: \(pushToken), voipToken: \(voipToken)")
|
||||
|
||||
var didTokensChange = false
|
||||
|
||||
if (pushToken != self.preferences.getPushToken()) {
|
||||
Logger.info("\(TAG) Recording new plain push token")
|
||||
Logger.info("\(logTag) Recording new plain push token")
|
||||
self.preferences.setPushToken(pushToken)
|
||||
didTokensChange = true
|
||||
}
|
||||
|
||||
if (voipToken != self.preferences.getVoipToken()) {
|
||||
Logger.info("\(TAG) Recording new voip token")
|
||||
Logger.info("\(logTag) Recording new voip token")
|
||||
self.preferences.setVoipToken(voipToken)
|
||||
didTokensChange = true
|
||||
}
|
||||
|
||||
@ -12,7 +12,6 @@ import SignalServiceKit
|
||||
*/
|
||||
@objc
|
||||
public class AccountManager: NSObject {
|
||||
let TAG = "[AccountManager]"
|
||||
|
||||
let textSecureAccountManager: TSAccountManager
|
||||
let networkManager: TSNetworkManager
|
||||
@ -50,7 +49,7 @@ public class AccountManager: NSObject {
|
||||
return Promise(error: error)
|
||||
}
|
||||
|
||||
Logger.debug("\(self.TAG) registering with signal server")
|
||||
Logger.debug("\(self.logTag) registering with signal server")
|
||||
let registrationPromise: Promise<Void> = firstly {
|
||||
return self.registerForTextSecure(verificationCode: verificationCode, pin: pin)
|
||||
}.then {
|
||||
@ -61,7 +60,7 @@ public class AccountManager: NSObject {
|
||||
// This can happen with:
|
||||
// - simulators, none of which support receiving push notifications
|
||||
// - on iOS11 devices which have disabled "Allow Notifications" and disabled "Enable Background Refresh" in the system settings.
|
||||
Logger.info("\(self.TAG) Recovered push registration error. Registering for manual message fetcher because push not supported: \(description)")
|
||||
Logger.info("\(self.logTag) Recovered push registration error. Registering for manual message fetcher because push not supported: \(description)")
|
||||
return self.registerForManualMessageFetching()
|
||||
default:
|
||||
throw error
|
||||
@ -86,14 +85,14 @@ public class AccountManager: NSObject {
|
||||
}
|
||||
|
||||
private func syncPushTokens() -> Promise<Void> {
|
||||
Logger.info("\(self.TAG) in \(#function)")
|
||||
Logger.info("\(self.logTag) in \(#function)")
|
||||
let job = SyncPushTokensJob(accountManager: self, preferences: self.preferences)
|
||||
job.uploadOnlyIfStale = false
|
||||
return job.run()
|
||||
}
|
||||
|
||||
private func completeRegistration() {
|
||||
Logger.info("\(self.TAG) in \(#function)")
|
||||
Logger.info("\(self.logTag) in \(#function)")
|
||||
self.textSecureAccountManager.didRegister()
|
||||
}
|
||||
|
||||
@ -128,7 +127,7 @@ public class AccountManager: NSObject {
|
||||
if let turnServerInfo = TurnServerInfo(attributes: responseDictionary) {
|
||||
return fulfill(turnServerInfo)
|
||||
}
|
||||
Logger.error("\(self.TAG) unexpected server response:\(responseDictionary)")
|
||||
Logger.error("\(self.logTag) unexpected server response:\(responseDictionary)")
|
||||
}
|
||||
return reject(OWSErrorMakeUnableToProcessServerResponseError())
|
||||
},
|
||||
|
||||
@ -16,7 +16,6 @@ protocol CompareSafetyNumbersActivityDelegate {
|
||||
@objc (OWSCompareSafetyNumbersActivity)
|
||||
class CompareSafetyNumbersActivity: UIActivity {
|
||||
|
||||
let TAG = "[CompareSafetyNumbersActivity]"
|
||||
var mySafetyNumbers: String?
|
||||
let delegate: CompareSafetyNumbersActivityDelegate
|
||||
|
||||
@ -62,7 +61,7 @@ class CompareSafetyNumbersActivity: UIActivity {
|
||||
|
||||
let pasteboardString = numericOnly(string: UIPasteboard.general.string)
|
||||
guard (pasteboardString != nil && pasteboardString!.count == 60) else {
|
||||
Logger.warn("\(TAG) no valid safety numbers found in pasteboard: \(String(describing: pasteboardString))")
|
||||
Logger.warn("\(logTag) no valid safety numbers found in pasteboard: \(String(describing: pasteboardString))")
|
||||
let error = OWSErrorWithCodeDescription(OWSErrorCode.userError,
|
||||
NSLocalizedString("PRIVACY_VERIFICATION_FAILED_NO_SAFETY_NUMBERS_IN_CLIPBOARD", comment: "Alert body for user error"))
|
||||
|
||||
@ -73,10 +72,10 @@ class CompareSafetyNumbersActivity: UIActivity {
|
||||
let pasteboardSafetyNumbers = pasteboardString!
|
||||
|
||||
if pasteboardSafetyNumbers == mySafetyNumbers {
|
||||
Logger.info("\(TAG) successfully matched safety numbers. local numbers: \(String(describing: mySafetyNumbers)) pasteboard:\(pasteboardSafetyNumbers)")
|
||||
Logger.info("\(logTag) successfully matched safety numbers. local numbers: \(String(describing: mySafetyNumbers)) pasteboard:\(pasteboardSafetyNumbers)")
|
||||
delegate.compareSafetyNumbersActivitySucceeded(activity: self)
|
||||
} else {
|
||||
Logger.warn("\(TAG) local numbers: \(String(describing: mySafetyNumbers)) didn't match pasteboard:\(pasteboardSafetyNumbers)")
|
||||
Logger.warn("\(logTag) local numbers: \(String(describing: mySafetyNumbers)) didn't match pasteboard:\(pasteboardSafetyNumbers)")
|
||||
let error = OWSErrorWithCodeDescription(OWSErrorCode.privacyVerificationFailure,
|
||||
NSLocalizedString("PRIVACY_VERIFICATION_FAILED_MISMATCHED_SAFETY_NUMBERS_IN_CLIPBOARD", comment: "Alert body"))
|
||||
delegate.compareSafetyNumbersActivity(self, failedWithError: error)
|
||||
|
||||
@ -10,7 +10,6 @@ import Foundation
|
||||
@objc(OWSCallNotificationsAdapter)
|
||||
public class CallNotificationsAdapter: NSObject {
|
||||
|
||||
let TAG = "[CallNotificationsAdapter]"
|
||||
let adaptee: OWSCallNotificationsAdaptee
|
||||
|
||||
override init() {
|
||||
@ -31,12 +30,12 @@ public class CallNotificationsAdapter: NSObject {
|
||||
}
|
||||
|
||||
func presentIncomingCall(_ call: SignalCall, callerName: String) {
|
||||
Logger.debug("\(TAG) in \(#function)")
|
||||
Logger.debug("\(logTag) in \(#function)")
|
||||
adaptee.presentIncomingCall(call, callerName: callerName)
|
||||
}
|
||||
|
||||
func presentMissedCall(_ call: SignalCall, callerName: String) {
|
||||
Logger.debug("\(TAG) in \(#function)")
|
||||
Logger.debug("\(logTag) in \(#function)")
|
||||
adaptee.presentMissedCall(call, callerName: callerName)
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
/**
|
||||
@ -62,7 +62,6 @@ struct AppNotifications {
|
||||
|
||||
@available(iOS 10.0, *)
|
||||
class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNotificationCenterDelegate {
|
||||
let TAG = "[UserNotificationsAdaptee]"
|
||||
|
||||
private let center: UNUserNotificationCenter
|
||||
|
||||
@ -89,11 +88,11 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot
|
||||
func requestAuthorization() {
|
||||
center.requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in
|
||||
if granted {
|
||||
Logger.debug("\(self.TAG) \(#function) succeeded.")
|
||||
Logger.debug("\(self.logTag) \(#function) succeeded.")
|
||||
} else if error != nil {
|
||||
Logger.error("\(self.TAG) \(#function) failed with error: \(error!)")
|
||||
Logger.error("\(self.logTag) \(#function) failed with error: \(error!)")
|
||||
} else {
|
||||
Logger.error("\(self.TAG) \(#function) failed without error.")
|
||||
Logger.error("\(self.logTag) \(#function) failed without error.")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -101,13 +100,13 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot
|
||||
// MARK: - OWSCallNotificationsAdaptee
|
||||
|
||||
public func presentIncomingCall(_ call: SignalCall, callerName: String) {
|
||||
Logger.debug("\(TAG) \(#function) is no-op, because it's handled with callkit.")
|
||||
Logger.debug("\(logTag) \(#function) is no-op, because it's handled with callkit.")
|
||||
// TODO since CallKit doesn't currently work on the simulator,
|
||||
// we could implement UNNotifications for simulator testing, or if people have opted out of callkit.
|
||||
}
|
||||
|
||||
public func presentMissedCall(_ call: SignalCall, callerName: String) {
|
||||
Logger.debug("\(TAG) \(#function)")
|
||||
Logger.debug("\(logTag) \(#function)")
|
||||
|
||||
let content = UNMutableNotificationContent()
|
||||
// TODO group by thread identifier
|
||||
@ -133,7 +132,7 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot
|
||||
}
|
||||
|
||||
public func presentMissedCallBecauseOfNoLongerVerifiedIdentity(call: SignalCall, callerName: String) {
|
||||
Logger.debug("\(TAG) \(#function)")
|
||||
Logger.debug("\(logTag) \(#function)")
|
||||
|
||||
let content = UNMutableNotificationContent()
|
||||
// TODO group by thread identifier
|
||||
@ -159,7 +158,7 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot
|
||||
}
|
||||
|
||||
public func presentMissedCallBecauseOfNewIdentity(call: SignalCall, callerName: String) {
|
||||
Logger.debug("\(TAG) \(#function)")
|
||||
Logger.debug("\(logTag) \(#function)")
|
||||
|
||||
let content = UNMutableNotificationContent()
|
||||
// TODO group by thread identifier
|
||||
|
||||
@ -12,8 +12,6 @@ import SignalMessaging
|
||||
// TODO: Ensure buttons enabled & disabled as necessary.
|
||||
class CallViewController: OWSViewController, CallObserver, CallServiceObserver, CallAudioServiceDelegate {
|
||||
|
||||
let TAG = "[CallViewController]"
|
||||
|
||||
// Dependencies
|
||||
var callUIAdapter: CallUIAdapter {
|
||||
return SignalApp.shared().callUIAdapter
|
||||
@ -104,7 +102,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
|
||||
// MARK: - Audio Source
|
||||
|
||||
var hasAlternateAudioSources: Bool {
|
||||
Logger.info("\(TAG) available audio sources: \(allAudioSources)")
|
||||
Logger.info("\(logTag) available audio sources: \(allAudioSources)")
|
||||
// internal mic and speakerphone will be the first two, any more than one indicates e.g. an attached bluetooth device.
|
||||
|
||||
// TODO is this sufficient? Are their devices w/ bluetooth but no external speaker? e.g. ipod?
|
||||
@ -203,7 +201,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
|
||||
updateAvatarImage()
|
||||
NotificationCenter.default.addObserver(forName: .OWSContactsManagerSignalAccountsDidChange, object: nil, queue: nil) { [weak self] _ in
|
||||
guard let strongSelf = self else { return }
|
||||
Logger.info("\(strongSelf.TAG) updating avatar image")
|
||||
Logger.info("\(strongSelf.logTag) updating avatar image")
|
||||
strongSelf.updateAvatarImage()
|
||||
}
|
||||
|
||||
@ -599,7 +597,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
|
||||
|
||||
func showCallFailed(error: Error) {
|
||||
// TODO Show something in UI.
|
||||
Logger.error("\(TAG) call failed with error: \(error)")
|
||||
Logger.error("\(logTag) call failed with error: \(error)")
|
||||
}
|
||||
|
||||
// MARK: - View State
|
||||
@ -781,10 +779,10 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
|
||||
// Dismiss Handling
|
||||
switch callState {
|
||||
case .remoteHangup, .remoteBusy, .localFailure:
|
||||
Logger.debug("\(TAG) dismissing after delay because new state is \(callState)")
|
||||
Logger.debug("\(logTag) dismissing after delay because new state is \(callState)")
|
||||
dismissIfPossible(shouldDelay: true)
|
||||
case .localHangup:
|
||||
Logger.debug("\(TAG) dismissing immediately from local hangup")
|
||||
Logger.debug("\(logTag) dismissing immediately from local hangup")
|
||||
dismissIfPossible(shouldDelay: false)
|
||||
default: break
|
||||
}
|
||||
@ -838,7 +836,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
|
||||
* Ends a connected call. Do not confuse with `didPressDeclineCall`.
|
||||
*/
|
||||
@objc func didPressHangup(sender: UIButton) {
|
||||
Logger.info("\(TAG) called \(#function)")
|
||||
Logger.info("\(logTag) called \(#function)")
|
||||
|
||||
callUIAdapter.localHangupCall(call)
|
||||
|
||||
@ -846,14 +844,14 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
|
||||
}
|
||||
|
||||
@objc func didPressMute(sender muteButton: UIButton) {
|
||||
Logger.info("\(TAG) called \(#function)")
|
||||
Logger.info("\(logTag) called \(#function)")
|
||||
muteButton.isSelected = !muteButton.isSelected
|
||||
|
||||
callUIAdapter.setIsMuted(call: call, isMuted: muteButton.isSelected)
|
||||
}
|
||||
|
||||
@objc func didPressAudioSource(sender button: UIButton) {
|
||||
Logger.info("\(TAG) called \(#function)")
|
||||
Logger.info("\(logTag) called \(#function)")
|
||||
|
||||
if self.hasAlternateAudioSources {
|
||||
presentAudioSourcePicker()
|
||||
@ -863,26 +861,26 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
|
||||
}
|
||||
|
||||
func didPressSpeakerphone(sender button: UIButton) {
|
||||
Logger.info("\(TAG) called \(#function)")
|
||||
Logger.info("\(logTag) called \(#function)")
|
||||
|
||||
button.isSelected = !button.isSelected
|
||||
callUIAdapter.audioService.requestSpeakerphone(isEnabled: button.isSelected)
|
||||
}
|
||||
|
||||
func didPressTextMessage(sender button: UIButton) {
|
||||
Logger.info("\(TAG) called \(#function)")
|
||||
Logger.info("\(logTag) called \(#function)")
|
||||
|
||||
dismissIfPossible(shouldDelay: false)
|
||||
}
|
||||
|
||||
@objc func didPressAnswerCall(sender: UIButton) {
|
||||
Logger.info("\(TAG) called \(#function)")
|
||||
Logger.info("\(logTag) called \(#function)")
|
||||
|
||||
callUIAdapter.answerCall(call)
|
||||
}
|
||||
|
||||
@objc func didPressVideo(sender: UIButton) {
|
||||
Logger.info("\(TAG) called \(#function)")
|
||||
Logger.info("\(logTag) called \(#function)")
|
||||
let hasLocalVideo = !sender.isSelected
|
||||
|
||||
callUIAdapter.setHasLocalVideo(call: call, hasLocalVideo: hasLocalVideo)
|
||||
@ -892,7 +890,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
|
||||
sender.isSelected = !sender.isSelected
|
||||
|
||||
let isUsingFrontCamera = !sender.isSelected
|
||||
Logger.info("\(TAG) in \(#function) with isUsingFrontCamera: \(isUsingFrontCamera)")
|
||||
Logger.info("\(logTag) in \(#function) with isUsingFrontCamera: \(isUsingFrontCamera)")
|
||||
|
||||
callUIAdapter.setCameraSource(call: call, isUsingFrontCamera: isUsingFrontCamera)
|
||||
}
|
||||
@ -901,7 +899,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
|
||||
* Denies an incoming not-yet-connected call, Do not confuse with `didPressHangup`.
|
||||
*/
|
||||
@objc func didPressDeclineCall(sender: UIButton) {
|
||||
Logger.info("\(TAG) called \(#function)")
|
||||
Logger.info("\(logTag) called \(#function)")
|
||||
|
||||
callUIAdapter.declineCall(call)
|
||||
|
||||
@ -909,7 +907,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
|
||||
}
|
||||
|
||||
@objc func didPressShowCallSettings(sender: UIButton) {
|
||||
Logger.info("\(TAG) called \(#function)")
|
||||
Logger.info("\(logTag) called \(#function)")
|
||||
|
||||
markSettingsNagAsComplete()
|
||||
|
||||
@ -928,7 +926,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
|
||||
}
|
||||
|
||||
@objc func didPressDismissNag(sender: UIButton) {
|
||||
Logger.info("\(TAG) called \(#function)")
|
||||
Logger.info("\(logTag) called \(#function)")
|
||||
|
||||
markSettingsNagAsComplete()
|
||||
|
||||
@ -942,7 +940,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
|
||||
// settings to their default values to indicate that the user has reviewed
|
||||
// them.
|
||||
private func markSettingsNagAsComplete() {
|
||||
Logger.info("\(TAG) called \(#function)")
|
||||
Logger.info("\(logTag) called \(#function)")
|
||||
|
||||
let preferences = Environment.current().preferences!
|
||||
|
||||
@ -958,7 +956,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
|
||||
|
||||
internal func stateDidChange(call: SignalCall, state: CallState) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.info("\(self.TAG) new call status: \(state)")
|
||||
Logger.info("\(self.logTag) new call status: \(state)")
|
||||
self.updateCallUI(callState: state)
|
||||
}
|
||||
|
||||
@ -1014,7 +1012,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
|
||||
localVideoView.captureSession = captureSession
|
||||
let isHidden = captureSession == nil
|
||||
|
||||
Logger.info("\(TAG) \(#function) isHidden: \(isHidden)")
|
||||
Logger.info("\(logTag) \(#function) isHidden: \(isHidden)")
|
||||
localVideoView.isHidden = isHidden
|
||||
|
||||
updateLocalVideoLayout()
|
||||
|
||||
@ -573,7 +573,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
guard let url = NSURL(string: "tel:\(phoneNumber.phoneNumber)") else {
|
||||
owsFail("\(ContactViewController.logTag) could not open phone number.")
|
||||
owsFail("\(ContactViewController.logTag()) could not open phone number.")
|
||||
return
|
||||
}
|
||||
UIApplication.shared.openURL(url as URL)
|
||||
@ -601,7 +601,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
guard let url = NSURL(string: "mailto:\(email.email)") else {
|
||||
owsFail("\(ContactViewController.logTag) could not open email.")
|
||||
owsFail("\(ContactViewController.logTag()) could not open email.")
|
||||
return
|
||||
}
|
||||
UIApplication.shared.openURL(url as URL)
|
||||
@ -632,13 +632,13 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
|
||||
|
||||
let mapAddress = formatAddressForQuery(address: address)
|
||||
guard let escapedMapAddress = mapAddress.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {
|
||||
owsFail("\(ContactViewController.logTag) could not open address.")
|
||||
owsFail("\(ContactViewController.logTag()) could not open address.")
|
||||
return
|
||||
}
|
||||
// Note that we use "q" (i.e. query) rather than "address" since we can't assume
|
||||
// this is a well-formed address.
|
||||
guard let url = URL(string: "http://maps.apple.com/?q=\(escapedMapAddress)") else {
|
||||
owsFail("\(ContactViewController.logTag) could not open address.")
|
||||
owsFail("\(ContactViewController.logTag()) could not open address.")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -27,8 +27,6 @@ import SignalMessaging
|
||||
// appropriate cropping.
|
||||
@objc class CropScaleImageViewController: OWSViewController {
|
||||
|
||||
let TAG = "[CropScaleImageViewController]"
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
let srcImage: UIImage
|
||||
@ -501,7 +499,7 @@ import SignalMessaging
|
||||
|
||||
let scaledImage = UIGraphicsGetImageFromCurrentImageContext()
|
||||
if scaledImage == nil {
|
||||
owsFail("\(TAG) could not generate dst image.")
|
||||
owsFail("\(logTag) could not generate dst image.")
|
||||
}
|
||||
UIGraphicsEndImageContext()
|
||||
return scaledImage
|
||||
|
||||
@ -8,8 +8,6 @@ import SignalMessaging
|
||||
|
||||
class DebugUIProfile: DebugUIPage {
|
||||
|
||||
let TAG = "[DebugUIProfile]"
|
||||
|
||||
// MARK: Dependencies
|
||||
|
||||
var messageSender: MessageSender {
|
||||
|
||||
@ -104,10 +104,10 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController:
|
||||
}
|
||||
|
||||
@objc func didTapButton(sender: UIButton) {
|
||||
Logger.debug("\(TAG) in \(#function)")
|
||||
Logger.debug("\(logTag) in \(#function)")
|
||||
|
||||
guard let buttonAction = self.buttonAction else {
|
||||
owsFail("\(TAG) button action was nil")
|
||||
owsFail("\(logTag) button action was nil")
|
||||
return
|
||||
}
|
||||
|
||||
@ -214,10 +214,10 @@ private class IntroductingReadReceiptsExperienceUpgradeViewController: Experienc
|
||||
}
|
||||
|
||||
@objc func didTapButton(sender: UIButton) {
|
||||
Logger.debug("\(TAG) in \(#function)")
|
||||
Logger.debug("\(logTag) in \(#function)")
|
||||
|
||||
guard let buttonAction = self.buttonAction else {
|
||||
owsFail("\(TAG) button action was nil")
|
||||
owsFail("\(logTag) button action was nil")
|
||||
return
|
||||
}
|
||||
|
||||
@ -344,7 +344,7 @@ private class IntroductingProfilesExperienceUpgradeViewController: ExperienceUpg
|
||||
// MARK: - Actions
|
||||
|
||||
@objc func didTapButton(sender: UIButton) {
|
||||
Logger.debug("\(TAG) in \(#function)")
|
||||
Logger.debug("\(logTag) in \(#function)")
|
||||
|
||||
// dismiss the modally presented view controller, then proceed.
|
||||
experienceUpgradesPageViewController.dismiss(animated: true) {
|
||||
@ -383,7 +383,7 @@ private class CallKitExperienceUpgradeViewController: ExperienceUpgradeViewContr
|
||||
// MARK: - Actions
|
||||
|
||||
@objc func didTapPrivacySettingsButton(sender: UIButton) {
|
||||
Logger.debug("\(TAG) in \(#function)")
|
||||
Logger.debug("\(logTag) in \(#function)")
|
||||
|
||||
// dismiss the modally presented view controller, then proceed.
|
||||
experienceUpgradesPageViewController.dismiss(animated: true) {
|
||||
@ -400,7 +400,6 @@ private class CallKitExperienceUpgradeViewController: ExperienceUpgradeViewContr
|
||||
}
|
||||
|
||||
private class ExperienceUpgradeViewController: OWSViewController {
|
||||
let TAG = "[ExperienceUpgradeViewController]"
|
||||
|
||||
let header: String
|
||||
let body: String
|
||||
@ -483,8 +482,6 @@ func setPageControlAppearance() {
|
||||
@objc
|
||||
public class ExperienceUpgradesPageViewController: OWSViewController, UIPageViewControllerDataSource {
|
||||
|
||||
let TAG = "[ExperienceUpgradeViewController]"
|
||||
|
||||
private let experienceUpgrades: [ExperienceUpgrade]
|
||||
private var allViewControllers = [UIViewController]()
|
||||
private var viewControllerIndexes = [UIViewController: Int]()
|
||||
@ -518,7 +515,7 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
|
||||
|
||||
@objc public override func viewDidLoad() {
|
||||
guard let firstViewController = allViewControllers.first else {
|
||||
owsFail("\(TAG) no pages to show.")
|
||||
owsFail("\(logTag) no pages to show.")
|
||||
dismiss(animated: true)
|
||||
return
|
||||
}
|
||||
@ -554,7 +551,7 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
|
||||
dismissButton.contentEdgeInsets = UIEdgeInsets(top: dismissInsetValue, left: dismissInsetValue, bottom: dismissInsetValue, right: dismissInsetValue)
|
||||
|
||||
guard let carouselView = self.pageViewController.view else {
|
||||
Logger.error("\(TAG) carousel view was unexpectedly nil")
|
||||
Logger.error("\(logTag) carousel view was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
@ -602,9 +599,9 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
|
||||
// MARK: - UIPageViewControllerDataSource
|
||||
|
||||
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
|
||||
Logger.debug("\(TAG) in \(#function)")
|
||||
Logger.debug("\(logTag) in \(#function)")
|
||||
guard let currentIndex = self.viewControllerIndexes[viewController] else {
|
||||
owsFail("\(TAG) unknown view controller: \(viewController)")
|
||||
owsFail("\(logTag) unknown view controller: \(viewController)")
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -617,9 +614,9 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
|
||||
}
|
||||
|
||||
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
|
||||
Logger.debug("\(TAG) in \(#function)")
|
||||
Logger.debug("\(logTag) in \(#function)")
|
||||
guard let currentIndex = self.viewControllerIndexes[viewController] else {
|
||||
owsFail("\(TAG) unknown view controller: \(viewController)")
|
||||
owsFail("\(logTag) unknown view controller: \(viewController)")
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -638,12 +635,12 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
|
||||
|
||||
public func presentationIndex(for pageViewController: UIPageViewController) -> Int {
|
||||
guard let currentViewController = pageViewController.viewControllers?.first else {
|
||||
Logger.error("\(TAG) unexpectedly empty view controllers.")
|
||||
Logger.error("\(logTag) unexpectedly empty view controllers.")
|
||||
return 0
|
||||
}
|
||||
|
||||
guard let currentIndex = self.viewControllerIndexes[currentViewController] else {
|
||||
Logger.error("\(TAG) unknown view controller: \(currentViewController)")
|
||||
Logger.error("\(logTag) unknown view controller: \(currentViewController)")
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -652,11 +649,11 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
|
||||
|
||||
public func addViewController(experienceUpgrade: ExperienceUpgrade) {
|
||||
guard let uniqueId = experienceUpgrade.uniqueId else {
|
||||
Logger.error("\(self.TAG) experienceUpgrade is missing uniqueId.")
|
||||
Logger.error("\(self.logTag) experienceUpgrade is missing uniqueId.")
|
||||
return
|
||||
}
|
||||
guard let identifier = ExperienceUpgradeId(rawValue: uniqueId) else {
|
||||
owsFail("\(TAG) unknown experience upgrade. skipping")
|
||||
owsFail("\(logTag) unknown experience upgrade. skipping")
|
||||
return
|
||||
}
|
||||
|
||||
@ -691,12 +688,12 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
|
||||
}
|
||||
|
||||
@objc func didTapDismissButton(sender: UIButton) {
|
||||
Logger.debug("\(TAG) in \(#function)")
|
||||
Logger.debug("\(logTag) in \(#function)")
|
||||
self.dismiss(animated: true)
|
||||
}
|
||||
|
||||
@objc func handleDismissGesture(sender: AnyObject) {
|
||||
Logger.debug("\(TAG) in \(#function)")
|
||||
Logger.debug("\(logTag) in \(#function)")
|
||||
self.dismiss(animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,6 @@ import SignalMessaging
|
||||
import YYImage
|
||||
|
||||
class GifPickerCell: UICollectionViewCell {
|
||||
let TAG = "[GifPickerCell]"
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@ -114,7 +113,7 @@ class GifPickerCell: UICollectionViewCell {
|
||||
// Record high quality animated rendition, but to save bandwidth, don't start downloading
|
||||
// until it's selected.
|
||||
guard let highQualityAnimatedRendition = imageInfo.pickSendingRendition() else {
|
||||
Logger.warn("\(TAG) could not pick gif rendition: \(imageInfo.giphyId)")
|
||||
Logger.warn("\(logTag) could not pick gif rendition: \(imageInfo.giphyId)")
|
||||
clearAssetRequests()
|
||||
return
|
||||
}
|
||||
@ -123,12 +122,12 @@ class GifPickerCell: UICollectionViewCell {
|
||||
// The Giphy API returns a slew of "renditions" for a given image.
|
||||
// It's critical that we carefully "pick" the best rendition to use.
|
||||
guard let animatedRendition = imageInfo.pickPreviewRendition() else {
|
||||
Logger.warn("\(TAG) could not pick gif rendition: \(imageInfo.giphyId)")
|
||||
Logger.warn("\(logTag) could not pick gif rendition: \(imageInfo.giphyId)")
|
||||
clearAssetRequests()
|
||||
return
|
||||
}
|
||||
guard let stillRendition = imageInfo.pickStillRendition() else {
|
||||
Logger.warn("\(TAG) could not pick still rendition: \(imageInfo.giphyId)")
|
||||
Logger.warn("\(logTag) could not pick still rendition: \(imageInfo.giphyId)")
|
||||
clearAssetRequests()
|
||||
return
|
||||
}
|
||||
@ -198,7 +197,7 @@ class GifPickerCell: UICollectionViewCell {
|
||||
return
|
||||
}
|
||||
guard let image = YYImage(contentsOfFile: asset.filePath) else {
|
||||
owsFail("\(TAG) could not load asset.")
|
||||
owsFail("\(logTag) could not load asset.")
|
||||
clearViewState()
|
||||
return
|
||||
}
|
||||
@ -209,7 +208,7 @@ class GifPickerCell: UICollectionViewCell {
|
||||
imageView.ows_autoPinToSuperviewEdges()
|
||||
}
|
||||
guard let imageView = imageView else {
|
||||
owsFail("\(TAG) missing imageview.")
|
||||
owsFail("\(logTag) missing imageview.")
|
||||
clearViewState()
|
||||
return
|
||||
}
|
||||
@ -241,7 +240,7 @@ class GifPickerCell: UICollectionViewCell {
|
||||
|
||||
public func requestRenditionForSending() -> Promise<GiphyAsset> {
|
||||
guard let renditionForSending = self.renditionForSending else {
|
||||
owsFail("\(TAG) renditionForSending was unexpectedly nil")
|
||||
owsFail("\(logTag) renditionForSending was unexpectedly nil")
|
||||
return Promise(error: GiphyError.assertionError(description: "renditionForSending was unexpectedly nil"))
|
||||
}
|
||||
|
||||
@ -258,7 +257,7 @@ class GifPickerCell: UICollectionViewCell {
|
||||
failure: { _ in
|
||||
// TODO GiphyDownloader API should pass through a useful failing error
|
||||
// so we can pass it through here
|
||||
Logger.error("\(self.TAG) request failed")
|
||||
Logger.error("\(self.logTag) request failed")
|
||||
reject(GiphyError.fetchFailure)
|
||||
})
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@ -10,7 +10,6 @@ protocol GifPickerLayoutDelegate: class {
|
||||
|
||||
// A Pinterest-style waterfall layout.
|
||||
class GifPickerLayout: UICollectionViewLayout {
|
||||
let TAG = "[GifPickerLayout]"
|
||||
|
||||
public weak var delegate: GifPickerLayoutDelegate?
|
||||
|
||||
@ -38,7 +37,7 @@ class GifPickerLayout: UICollectionViewLayout {
|
||||
}
|
||||
|
||||
override func invalidateLayout(with context: UICollectionViewLayoutInvalidationContext) {
|
||||
super.invalidateLayout(with:context)
|
||||
super.invalidateLayout(with: context)
|
||||
|
||||
itemAttributesMap.removeAll()
|
||||
}
|
||||
@ -108,8 +107,8 @@ class GifPickerLayout: UICollectionViewLayout {
|
||||
let cellHeight = UInt(columnWidth * imageInfo.originalRendition.height / imageInfo.originalRendition.width)
|
||||
|
||||
let indexPath = NSIndexPath(row: cellIndex, section: 0)
|
||||
let itemAttributes = UICollectionViewLayoutAttributes(forCellWith:indexPath as IndexPath)
|
||||
let itemFrame = CGRect(x:CGFloat(cellX), y:CGFloat(cellY), width:CGFloat(cellWidth), height:CGFloat(cellHeight))
|
||||
let itemAttributes = UICollectionViewLayoutAttributes(forCellWith: indexPath as IndexPath)
|
||||
let itemFrame = CGRect(x: CGFloat(cellX), y: CGFloat(cellY), width: CGFloat(cellWidth), height: CGFloat(cellHeight))
|
||||
itemAttributes.frame = itemFrame
|
||||
itemAttributesMap[UInt(cellIndex)] = itemAttributes
|
||||
|
||||
@ -119,7 +118,7 @@ class GifPickerLayout: UICollectionViewLayout {
|
||||
|
||||
// Add bottom margin.
|
||||
let contentHeight = contentBottom + vInset
|
||||
contentSize = CGSize(width:CGFloat(totalViewWidth), height:CGFloat(contentHeight))
|
||||
contentSize = CGSize(width: CGFloat(totalViewWidth), height: CGFloat(contentHeight))
|
||||
}
|
||||
|
||||
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
|
||||
|
||||
@ -14,9 +14,6 @@ protocol GifPickerViewControllerDelegate: class {
|
||||
|
||||
class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollectionViewDataSource, UICollectionViewDelegate, GifPickerLayoutDelegate {
|
||||
|
||||
static let TAG = "[GifPickerViewController]"
|
||||
let TAG = "[GifPickerViewController]"
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
enum ViewMode {
|
||||
@ -25,7 +22,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
|
||||
|
||||
private var viewMode = ViewMode.idle {
|
||||
didSet {
|
||||
Logger.info("\(TAG) viewMode: \(viewMode)")
|
||||
Logger.info("\(logTag) viewMode: \(viewMode)")
|
||||
|
||||
updateContents()
|
||||
}
|
||||
@ -84,7 +81,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
|
||||
@objc func didBecomeActive() {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.info("\(self.TAG) \(#function)")
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
// Prod cells to try to load when app becomes active.
|
||||
ensureCellState()
|
||||
@ -93,7 +90,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
|
||||
@objc func reachabilityChanged() {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.info("\(self.TAG) \(#function)")
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
// Prod cells to try to load when connectivity changes.
|
||||
ensureCellState()
|
||||
@ -102,7 +99,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
|
||||
func ensureCellState() {
|
||||
for cell in self.collectionView.visibleCells {
|
||||
guard let cell = cell as? GifPickerCell else {
|
||||
owsFail("\(TAG) unexpected cell.")
|
||||
owsFail("\(logTag) unexpected cell.")
|
||||
return
|
||||
}
|
||||
cell.ensureCellState()
|
||||
@ -309,13 +306,13 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
|
||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCellReuseIdentifier, for: indexPath)
|
||||
|
||||
guard indexPath.row < imageInfos.count else {
|
||||
Logger.warn("\(TAG) indexPath: \(indexPath.row) out of range for imageInfo count: \(imageInfos.count) ")
|
||||
Logger.warn("\(logTag) indexPath: \(indexPath.row) out of range for imageInfo count: \(imageInfos.count) ")
|
||||
return cell
|
||||
}
|
||||
let imageInfo = imageInfos[indexPath.row]
|
||||
|
||||
guard let gifCell = cell as? GifPickerCell else {
|
||||
owsFail("\(TAG) Unexpected cell type.")
|
||||
owsFail("\(logTag) Unexpected cell type.")
|
||||
return cell
|
||||
}
|
||||
gifCell.imageInfo = imageInfo
|
||||
@ -327,18 +324,18 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
|
||||
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
|
||||
guard let cell = collectionView.cellForItem(at: indexPath) as? GifPickerCell else {
|
||||
owsFail("\(TAG) unexpected cell.")
|
||||
owsFail("\(logTag) unexpected cell.")
|
||||
return
|
||||
}
|
||||
|
||||
guard cell.stillAsset != nil || cell.animatedAsset != nil else {
|
||||
// we don't want to let the user blindly select a gray cell
|
||||
Logger.debug("\(TAG) ignoring selection of cell with no preview")
|
||||
Logger.debug("\(logTag) ignoring selection of cell with no preview")
|
||||
return
|
||||
}
|
||||
|
||||
guard self.hasSelectedCell == false else {
|
||||
owsFail("\(TAG) Already selected cell")
|
||||
owsFail("\(logTag) Already selected cell")
|
||||
return
|
||||
}
|
||||
self.hasSelectedCell = true
|
||||
@ -371,14 +368,14 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
|
||||
GiphyDownloader.sharedInstance.cancelAllRequests()
|
||||
cell.requestRenditionForSending().then { [weak self] (asset: GiphyAsset) -> Void in
|
||||
guard let strongSelf = self else {
|
||||
Logger.info("\(GifPickerViewController.TAG) ignoring send, since VC was dismissed before fetching finished.")
|
||||
Logger.info("\(GifPickerViewController.logTag()) ignoring send, since VC was dismissed before fetching finished.")
|
||||
return
|
||||
}
|
||||
|
||||
let filePath = asset.filePath
|
||||
guard let dataSource = DataSourcePath.dataSource(withFilePath: filePath,
|
||||
shouldDeleteOnDeallocation: false) else {
|
||||
owsFail("\(strongSelf.TAG) couldn't load asset.")
|
||||
owsFail("\(strongSelf.logTag) couldn't load asset.")
|
||||
return
|
||||
}
|
||||
let attachment = SignalAttachment.attachment(dataSource: dataSource, dataUTI: asset.rendition.utiType, imageQuality: .original)
|
||||
@ -389,7 +386,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
|
||||
}
|
||||
}.catch { [weak self] error in
|
||||
guard let strongSelf = self else {
|
||||
Logger.info("\(GifPickerViewController.TAG) ignoring failure, since VC was dismissed before fetching finished.")
|
||||
Logger.info("\(GifPickerViewController.logTag()) ignoring failure, since VC was dismissed before fetching finished.")
|
||||
return
|
||||
}
|
||||
|
||||
@ -410,7 +407,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
|
||||
|
||||
public func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
||||
guard let cell = cell as? GifPickerCell else {
|
||||
owsFail("\(TAG) unexpected cell.")
|
||||
owsFail("\(logTag) unexpected cell.")
|
||||
return
|
||||
}
|
||||
// We only want to load the cells which are on-screen.
|
||||
@ -419,7 +416,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
|
||||
|
||||
public func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
||||
guard let cell = cell as? GifPickerCell else {
|
||||
owsFail("\(TAG) unexpected cell.")
|
||||
owsFail("\(logTag) unexpected cell.")
|
||||
return
|
||||
}
|
||||
cell.isCellVisible = false
|
||||
@ -471,7 +468,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
|
||||
let query = (text as String).trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
|
||||
|
||||
if (viewMode == .searching || viewMode == .results) && lastQuery == query {
|
||||
Logger.info("\(TAG) ignoring duplicate search: \(query)")
|
||||
Logger.info("\(logTag) ignoring duplicate search: \(query)")
|
||||
return
|
||||
}
|
||||
|
||||
@ -479,7 +476,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
|
||||
}
|
||||
|
||||
private func search(query: String) {
|
||||
Logger.info("\(TAG) searching: \(query)")
|
||||
Logger.info("\(logTag) searching: \(query)")
|
||||
|
||||
progressiveSearchTimer?.invalidate()
|
||||
progressiveSearchTimer = nil
|
||||
@ -490,7 +487,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
|
||||
|
||||
GiphyAPI.sharedInstance.search(query: query, success: { [weak self] imageInfos in
|
||||
guard let strongSelf = self else { return }
|
||||
Logger.info("\(strongSelf.TAG) search complete")
|
||||
Logger.info("\(strongSelf.logTag) search complete")
|
||||
strongSelf.imageInfos = imageInfos
|
||||
if imageInfos.count > 0 {
|
||||
strongSelf.viewMode = .results
|
||||
@ -500,7 +497,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
|
||||
},
|
||||
failure: { [weak self] _ in
|
||||
guard let strongSelf = self else { return }
|
||||
Logger.info("\(strongSelf.TAG) search failed.")
|
||||
Logger.info("\(strongSelf.logTag) search failed.")
|
||||
// TODO: Present this error to the user.
|
||||
strongSelf.viewMode = .error
|
||||
})
|
||||
|
||||
@ -245,7 +245,7 @@ class ConversationSearchViewController: UITableViewController {
|
||||
if let messageDate = searchResult.messageDate {
|
||||
overrideDate = messageDate
|
||||
} else {
|
||||
owsFail("\(ConversationSearchViewController.logTag) message search result is missing message timestamp")
|
||||
owsFail("\(ConversationSearchViewController.logTag()) message search result is missing message timestamp")
|
||||
}
|
||||
|
||||
// Note that we only use the snippet for message results,
|
||||
@ -258,7 +258,7 @@ class ConversationSearchViewController: UITableViewController {
|
||||
NSAttributedStringKey.foregroundColor: Theme.primaryColor
|
||||
])
|
||||
} else {
|
||||
owsFail("\(ConversationSearchViewController.logTag) message search result is missing message snippet")
|
||||
owsFail("\(ConversationSearchViewController.logTag()) message search result is missing message snippet")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -14,8 +14,6 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
|
||||
case message, mail, twitter
|
||||
}
|
||||
|
||||
let TAG = "[ShareActions]"
|
||||
|
||||
let installUrl = "https://signal.org/install/"
|
||||
let homepageUrl = "https://signal.org"
|
||||
|
||||
@ -62,12 +60,12 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
|
||||
|
||||
func tweetAction() -> UIAlertAction? {
|
||||
guard canTweet() else {
|
||||
Logger.info("\(TAG) Twitter not supported.")
|
||||
Logger.info("\(logTag) Twitter not supported.")
|
||||
return nil
|
||||
}
|
||||
|
||||
guard let twitterViewController = SLComposeViewController(forServiceType: SLServiceTypeTwitter) else {
|
||||
Logger.error("\(TAG) unable to build twitter controller.")
|
||||
Logger.error("\(logTag) unable to build twitter controller.")
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -80,7 +78,7 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
|
||||
|
||||
let tweetTitle = NSLocalizedString("SHARE_ACTION_TWEET", comment: "action sheet item")
|
||||
return UIAlertAction(title: tweetTitle, style: .default) { _ in
|
||||
Logger.debug("\(self.TAG) Chose tweet")
|
||||
Logger.debug("\(self.logTag) Chose tweet")
|
||||
|
||||
self.presentingViewController.present(twitterViewController, animated: true, completion: nil)
|
||||
}
|
||||
@ -93,10 +91,10 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
|
||||
// MARK: ContactsPickerDelegate
|
||||
|
||||
func contactsPicker(_: ContactsPicker, didSelectMultipleContacts contacts: [Contact]) {
|
||||
Logger.debug("\(TAG) didSelectContacts:\(contacts)")
|
||||
Logger.debug("\(logTag) didSelectContacts:\(contacts)")
|
||||
|
||||
guard let inviteChannel = channel else {
|
||||
Logger.error("\(TAG) unexpected nil channel after returning from contact picker.")
|
||||
Logger.error("\(logTag) unexpected nil channel after returning from contact picker.")
|
||||
self.presentingViewController.dismiss(animated: true)
|
||||
return
|
||||
}
|
||||
@ -109,13 +107,13 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
|
||||
let recipients: [String] = contacts.map { $0.emails.first }.filter { $0 != nil }.map { $0! }
|
||||
sendMailTo(emails: recipients)
|
||||
default:
|
||||
Logger.error("\(TAG) unexpected channel after returning from contact picker: \(inviteChannel)")
|
||||
Logger.error("\(logTag) unexpected channel after returning from contact picker: \(inviteChannel)")
|
||||
}
|
||||
}
|
||||
|
||||
func contactsPicker(_: ContactsPicker, shouldSelectContact contact: Contact) -> Bool {
|
||||
guard let inviteChannel = channel else {
|
||||
Logger.error("\(TAG) unexpected nil channel in contact picker.")
|
||||
Logger.error("\(logTag) unexpected nil channel in contact picker.")
|
||||
return true
|
||||
}
|
||||
|
||||
@ -125,7 +123,7 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
|
||||
case .mail:
|
||||
return contact.emails.count > 0
|
||||
default:
|
||||
Logger.error("\(TAG) unexpected channel after returning from contact picker: \(inviteChannel)")
|
||||
Logger.error("\(logTag) unexpected channel after returning from contact picker: \(inviteChannel)")
|
||||
}
|
||||
return true
|
||||
}
|
||||
@ -151,13 +149,13 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
|
||||
|
||||
func messageAction() -> UIAlertAction? {
|
||||
guard MFMessageComposeViewController.canSendText() else {
|
||||
Logger.info("\(TAG) Device cannot send text")
|
||||
Logger.info("\(logTag) Device cannot send text")
|
||||
return nil
|
||||
}
|
||||
|
||||
let messageTitle = NSLocalizedString("SHARE_ACTION_MESSAGE", comment: "action sheet item to open native messages app")
|
||||
return UIAlertAction(title: messageTitle, style: .default) { _ in
|
||||
Logger.debug("\(self.TAG) Chose message.")
|
||||
Logger.debug("\(self.logTag) Chose message.")
|
||||
self.channel = .message
|
||||
let picker = ContactsPicker(allowsMultipleSelection: true, subtitleCellType: .phoneNumber)
|
||||
picker.contactsPickerDelegate = self
|
||||
@ -208,9 +206,9 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
|
||||
warning.addAction(UIAlertAction(title: CommonStrings.dismissButton, style: .default, handler: nil))
|
||||
self.presentingViewController.present(warning, animated: true, completion: nil)
|
||||
case .sent:
|
||||
Logger.debug("\(self.TAG) user successfully invited their friends via SMS.")
|
||||
Logger.debug("\(self.logTag) user successfully invited their friends via SMS.")
|
||||
case .cancelled:
|
||||
Logger.debug("\(self.TAG) user cancelled message invite")
|
||||
Logger.debug("\(self.logTag) user cancelled message invite")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -219,13 +217,13 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
|
||||
|
||||
func mailAction() -> UIAlertAction? {
|
||||
guard MFMailComposeViewController.canSendMail() else {
|
||||
Logger.info("\(TAG) Device cannot send mail")
|
||||
Logger.info("\(logTag) Device cannot send mail")
|
||||
return nil
|
||||
}
|
||||
|
||||
let mailActionTitle = NSLocalizedString("SHARE_ACTION_MAIL", comment: "action sheet item to open native mail app")
|
||||
return UIAlertAction(title: mailActionTitle, style: .default) { _ in
|
||||
Logger.debug("\(self.TAG) Chose mail.")
|
||||
Logger.debug("\(self.logTag) Chose mail.")
|
||||
self.channel = .mail
|
||||
|
||||
let picker = ContactsPicker(allowsMultipleSelection: true, subtitleCellType: .email)
|
||||
@ -262,11 +260,11 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
|
||||
warning.addAction(UIAlertAction(title: CommonStrings.dismissButton, style: .default, handler: nil))
|
||||
self.presentingViewController.present(warning, animated: true, completion: nil)
|
||||
case .sent:
|
||||
Logger.debug("\(self.TAG) user successfully invited their friends via mail.")
|
||||
Logger.debug("\(self.logTag) user successfully invited their friends via mail.")
|
||||
case .saved:
|
||||
Logger.debug("\(self.TAG) user saved mail invite.")
|
||||
Logger.debug("\(self.logTag) user saved mail invite.")
|
||||
case .cancelled:
|
||||
Logger.debug("\(self.TAG) user cancelled mail invite.")
|
||||
Logger.debug("\(self.logTag) user cancelled mail invite.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +62,6 @@ public struct MediaGalleryItem: Equatable, Hashable {
|
||||
public var hashValue: Int {
|
||||
return message.hashValue
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public struct GalleryDate: Hashable, Comparable, Equatable {
|
||||
|
||||
@ -8,8 +8,6 @@ import SignalServiceKit
|
||||
@objc
|
||||
public class SafetyNumberConfirmationAlert: NSObject {
|
||||
|
||||
let TAG = "[SafetyNumberConfirmationAlert]"
|
||||
|
||||
private let contactsManager: OWSContactsManager
|
||||
private let primaryStorage: OWSPrimaryStorage
|
||||
|
||||
@ -67,7 +65,7 @@ public class SafetyNumberConfirmationAlert: NSObject {
|
||||
let actionSheetController = UIAlertController(title: title, message: body, preferredStyle: .actionSheet)
|
||||
|
||||
let confirmAction = UIAlertAction(title: confirmationText, style: .default) { _ in
|
||||
Logger.info("\(self.TAG) Confirmed identity: \(untrustedIdentity)")
|
||||
Logger.info("\(self.logTag) Confirmed identity: \(untrustedIdentity)")
|
||||
|
||||
self.primaryStorage.newDatabaseConnection().asyncReadWrite { (transaction) in
|
||||
OWSIdentityManager.shared().setVerificationState(.default, identityKey: untrustedIdentity.identityKey, recipientId: untrustedIdentity.recipientId, isUserInitiatedChange: true, transaction: transaction)
|
||||
@ -79,7 +77,7 @@ public class SafetyNumberConfirmationAlert: NSObject {
|
||||
actionSheetController.addAction(confirmAction)
|
||||
|
||||
let showSafetyNumberAction = UIAlertAction(title: NSLocalizedString("VERIFY_PRIVACY", comment: "Label for button or row which allows users to verify the safety number of another user."), style: .default) { _ in
|
||||
Logger.info("\(self.TAG) Opted to show Safety Number for identity: \(untrustedIdentity)")
|
||||
Logger.info("\(self.logTag) Opted to show Safety Number for identity: \(untrustedIdentity)")
|
||||
|
||||
self.presentSafetyNumberViewController(theirIdentityKey: untrustedIdentity.identityKey,
|
||||
theirRecipientId: untrustedIdentity.recipientId,
|
||||
@ -105,7 +103,7 @@ public class SafetyNumberConfirmationAlert: NSObject {
|
||||
|
||||
public func presentSafetyNumberViewController(theirIdentityKey: Data, theirRecipientId: String, theirDisplayName: String, completion: (() -> Void)? = nil) {
|
||||
guard let fromViewController = UIApplication.shared.frontmostViewController else {
|
||||
Logger.info("\(self.TAG) Missing frontmostViewController")
|
||||
Logger.info("\(self.logTag) Missing frontmostViewController")
|
||||
return
|
||||
}
|
||||
FingerprintViewController.present(from: fromViewController, recipientId: theirRecipientId)
|
||||
|
||||
@ -11,8 +11,6 @@ import SignalMessaging
|
||||
*/
|
||||
class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
|
||||
|
||||
let TAG = "[NonCallKitCallUIAdaptee]"
|
||||
|
||||
let notificationsAdapter: CallNotificationsAdapter
|
||||
let callService: CallService
|
||||
|
||||
@ -37,9 +35,9 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
|
||||
OWSAudioSession.shared.startAudioActivity(call.audioActivity)
|
||||
|
||||
self.callService.handleOutgoingCall(call).then {
|
||||
Logger.debug("\(self.TAG) handleOutgoingCall succeeded")
|
||||
Logger.debug("\(self.logTag) handleOutgoingCall succeeded")
|
||||
}.catch { error in
|
||||
Logger.error("\(self.TAG) handleOutgoingCall failed with error: \(error)")
|
||||
Logger.error("\(self.logTag) handleOutgoingCall failed with error: \(error)")
|
||||
}.retainUntilComplete()
|
||||
|
||||
return call
|
||||
@ -48,13 +46,13 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
|
||||
func reportIncomingCall(_ call: SignalCall, callerName: String) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.debug("\(TAG) \(#function)")
|
||||
Logger.debug("\(logTag) \(#function)")
|
||||
|
||||
self.showCall(call)
|
||||
|
||||
// present lock screen notification
|
||||
if UIApplication.shared.applicationState == .active {
|
||||
Logger.debug("\(TAG) skipping notification since app is already active.")
|
||||
Logger.debug("\(logTag) skipping notification since app is already active.")
|
||||
} else {
|
||||
notificationsAdapter.presentIncomingCall(call, callerName: callerName)
|
||||
}
|
||||
@ -70,12 +68,12 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
guard let call = self.callService.call else {
|
||||
owsFail("\(self.TAG) in \(#function) No current call.")
|
||||
owsFail("\(self.logTag) in \(#function) No current call.")
|
||||
return
|
||||
}
|
||||
|
||||
guard call.localId == localId else {
|
||||
owsFail("\(self.TAG) in \(#function) localId does not match current call")
|
||||
owsFail("\(self.logTag) in \(#function) localId does not match current call")
|
||||
return
|
||||
}
|
||||
|
||||
@ -86,7 +84,7 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
guard call.localId == self.callService.call?.localId else {
|
||||
owsFail("\(self.TAG) in \(#function) localId does not match current call")
|
||||
owsFail("\(self.logTag) in \(#function) localId does not match current call")
|
||||
return
|
||||
}
|
||||
|
||||
@ -98,12 +96,12 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
guard let call = self.callService.call else {
|
||||
owsFail("\(self.TAG) in \(#function) No current call.")
|
||||
owsFail("\(self.logTag) in \(#function) No current call.")
|
||||
return
|
||||
}
|
||||
|
||||
guard call.localId == localId else {
|
||||
owsFail("\(self.TAG) in \(#function) localId does not match current call")
|
||||
owsFail("\(self.logTag) in \(#function) localId does not match current call")
|
||||
return
|
||||
}
|
||||
|
||||
@ -114,7 +112,7 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
guard call.localId == self.callService.call?.localId else {
|
||||
owsFail("\(self.TAG) in \(#function) localId does not match current call")
|
||||
owsFail("\(self.logTag) in \(#function) localId does not match current call")
|
||||
return
|
||||
}
|
||||
|
||||
@ -133,7 +131,7 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
|
||||
// If both parties hang up at the same moment,
|
||||
// call might already be nil.
|
||||
guard self.callService.call == nil || call.localId == self.callService.call?.localId else {
|
||||
owsFail("\(self.TAG) in \(#function) localId does not match current call")
|
||||
owsFail("\(self.logTag) in \(#function) localId does not match current call")
|
||||
return
|
||||
}
|
||||
|
||||
@ -143,26 +141,26 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
|
||||
internal func remoteDidHangupCall(_ call: SignalCall) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.debug("\(TAG) in \(#function) is no-op")
|
||||
Logger.debug("\(logTag) in \(#function) is no-op")
|
||||
}
|
||||
|
||||
internal func remoteBusy(_ call: SignalCall) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.debug("\(TAG) in \(#function) is no-op")
|
||||
Logger.debug("\(logTag) in \(#function) is no-op")
|
||||
}
|
||||
|
||||
internal func failCall(_ call: SignalCall, error: CallError) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.debug("\(TAG) in \(#function) is no-op")
|
||||
Logger.debug("\(logTag) in \(#function) is no-op")
|
||||
}
|
||||
|
||||
func setIsMuted(call: SignalCall, isMuted: Bool) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
guard call.localId == self.callService.call?.localId else {
|
||||
owsFail("\(self.TAG) in \(#function) localId does not match current call")
|
||||
owsFail("\(self.logTag) in \(#function) localId does not match current call")
|
||||
return
|
||||
}
|
||||
|
||||
@ -173,7 +171,7 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
guard call.localId == self.callService.call?.localId else {
|
||||
owsFail("\(self.TAG) in \(#function) localId does not match current call")
|
||||
owsFail("\(self.logTag) in \(#function) localId does not match current call")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ import SignalMessaging
|
||||
* Creates an outbound call via WebRTC.
|
||||
*/
|
||||
@objc public class OutboundCallInitiator: NSObject {
|
||||
let TAG = "[OutboundCallInitiator]"
|
||||
|
||||
let contactsManager: OWSContactsManager
|
||||
let contactsUpdater: ContactsUpdater
|
||||
@ -28,10 +27,10 @@ import SignalMessaging
|
||||
* |handle| is a user formatted phone number, e.g. from a system contacts entry
|
||||
*/
|
||||
@discardableResult @objc public func initiateCall(handle: String) -> Bool {
|
||||
Logger.info("\(TAG) in \(#function) with handle: \(handle)")
|
||||
Logger.info("\(logTag) in \(#function) with handle: \(handle)")
|
||||
|
||||
guard let recipientId = PhoneNumber(fromE164: handle)?.toE164() else {
|
||||
Logger.warn("\(TAG) unable to parse signalId from phone number: \(handle)")
|
||||
Logger.warn("\(logTag) unable to parse signalId from phone number: \(handle)")
|
||||
return false
|
||||
}
|
||||
|
||||
@ -47,7 +46,7 @@ import SignalMessaging
|
||||
// because it can change after app launch due to user settings
|
||||
let callUIAdapter = SignalApp.shared().callUIAdapter
|
||||
guard let frontmostViewController = UIApplication.shared.frontmostViewController else {
|
||||
owsFail("\(TAG) could not identify frontmostViewController in \(#function)")
|
||||
owsFail("\(logTag) could not identify frontmostViewController in \(#function)")
|
||||
return false
|
||||
}
|
||||
|
||||
@ -75,7 +74,7 @@ import SignalMessaging
|
||||
|
||||
// Here the permissions are either granted or denied
|
||||
guard granted == true else {
|
||||
Logger.warn("\(strongSelf.TAG) aborting due to missing microphone permissions.")
|
||||
Logger.warn("\(strongSelf.logTag) aborting due to missing microphone permissions.")
|
||||
OWSAlerts.showNoMicrophonePermissionAlert()
|
||||
return
|
||||
}
|
||||
|
||||
@ -259,10 +259,10 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
|
||||
configuration.bundlePolicy = .maxBundle
|
||||
configuration.rtcpMuxPolicy = .require
|
||||
if useTurnOnly {
|
||||
Logger.debug("\(PeerConnectionClient.logTag) using iceTransportPolicy: relay")
|
||||
Logger.debug("\(PeerConnectionClient.logTag()) using iceTransportPolicy: relay")
|
||||
configuration.iceTransportPolicy = .relay
|
||||
} else {
|
||||
Logger.debug("\(PeerConnectionClient.logTag) using iceTransportPolicy: default")
|
||||
Logger.debug("\(PeerConnectionClient.logTag()) using iceTransportPolicy: default")
|
||||
}
|
||||
|
||||
let connectionConstraintsDict = ["DtlsSrtpKeyAgreement": "true"]
|
||||
@ -1053,7 +1053,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
|
||||
internal func peerConnectionForTests() -> RTCPeerConnection {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
var result: RTCPeerConnection? = nil
|
||||
var result: RTCPeerConnection?
|
||||
PeerConnectionClient.signalingQueue.sync {
|
||||
result = peerConnection
|
||||
Logger.info("\(self.logTag) called \(#function)")
|
||||
@ -1064,7 +1064,7 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
|
||||
internal func dataChannelForTests() -> RTCDataChannel {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
var result: RTCDataChannel? = nil
|
||||
var result: RTCDataChannel?
|
||||
PeerConnectionClient.signalingQueue.sync {
|
||||
result = dataChannel
|
||||
Logger.info("\(self.logTag) called \(#function)")
|
||||
|
||||
@ -39,8 +39,6 @@ protocol CallObserver: class {
|
||||
*/
|
||||
@objc public class SignalCall: NSObject {
|
||||
|
||||
let TAG = "[SignalCall]"
|
||||
|
||||
var observers = [Weak<CallObserver>]()
|
||||
|
||||
@objc
|
||||
@ -88,7 +86,7 @@ protocol CallObserver: class {
|
||||
var state: CallState {
|
||||
didSet {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.debug("\(TAG) state changed: \(oldValue) -> \(self.state) for call: \(self.identifiersForLogs)")
|
||||
Logger.debug("\(logTag) state changed: \(oldValue) -> \(self.state) for call: \(self.identifiersForLogs)")
|
||||
|
||||
// Update connectedDate
|
||||
if case .connected = self.state {
|
||||
@ -110,7 +108,7 @@ protocol CallObserver: class {
|
||||
didSet {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.debug("\(TAG) muted changed: \(oldValue) -> \(self.isMuted)")
|
||||
Logger.debug("\(logTag) muted changed: \(oldValue) -> \(self.isMuted)")
|
||||
|
||||
for observer in observers {
|
||||
observer.value?.muteDidChange(call: self, isMuted: isMuted)
|
||||
@ -123,7 +121,7 @@ protocol CallObserver: class {
|
||||
var audioSource: AudioSource? = nil {
|
||||
didSet {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.debug("\(TAG) audioSource changed: \(String(describing: oldValue)) -> \(String(describing: audioSource))")
|
||||
Logger.debug("\(logTag) audioSource changed: \(String(describing: oldValue)) -> \(String(describing: audioSource))")
|
||||
|
||||
for observer in observers {
|
||||
observer.value?.audioSourceDidChange(call: self, audioSource: audioSource)
|
||||
@ -142,7 +140,7 @@ protocol CallObserver: class {
|
||||
var isOnHold = false {
|
||||
didSet {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.debug("\(TAG) isOnHold changed: \(oldValue) -> \(self.isOnHold)")
|
||||
Logger.debug("\(logTag) isOnHold changed: \(oldValue) -> \(self.isOnHold)")
|
||||
|
||||
for observer in observers {
|
||||
observer.value?.holdDidChange(call: self, isOnHold: isOnHold)
|
||||
|
||||
@ -18,8 +18,6 @@ import SignalMessaging
|
||||
@available(iOS 10.0, *)
|
||||
final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
|
||||
let TAG = "[CallKitCallUIAdaptee]"
|
||||
|
||||
private let callManager: CallKitCallManager
|
||||
internal let callService: CallService
|
||||
internal let notificationsAdapter: CallNotificationsAdapter
|
||||
@ -81,7 +79,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
init(callService: CallService, contactsManager: OWSContactsManager, notificationsAdapter: CallNotificationsAdapter, showNamesOnCallScreen: Bool, useSystemCallLog: Bool) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.debug("\(self.TAG) \(#function)")
|
||||
Logger.debug("\(CallKitCallUIAdaptee.logTag()) \(#function)")
|
||||
|
||||
self.callManager = CallKitCallManager(showNamesOnCallScreen: showNamesOnCallScreen)
|
||||
self.callService = callService
|
||||
@ -104,7 +102,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
|
||||
func startOutgoingCall(handle: String) -> SignalCall {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.info("\(self.TAG) \(#function)")
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
let call = SignalCall.outgoingCall(localId: UUID(), remotePhoneNumber: handle)
|
||||
|
||||
@ -122,7 +120,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
// Called from CallService after call has ended to clean up any remaining CallKit call state.
|
||||
func failCall(_ call: SignalCall, error: CallError) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.info("\(self.TAG) \(#function)")
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
switch error {
|
||||
case .timeout(description: _):
|
||||
@ -136,7 +134,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
|
||||
func reportIncomingCall(_ call: SignalCall, callerName: String) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.info("\(self.TAG) \(#function)")
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
// Construct a CXCallUpdate describing the incoming call, including the caller.
|
||||
let update = CXCallUpdate()
|
||||
@ -162,7 +160,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
since calls may be "denied" for various legitimate reasons. See CXErrorCodeIncomingCallError.
|
||||
*/
|
||||
guard error == nil else {
|
||||
Logger.error("\(self.TAG) failed to report new incoming call")
|
||||
Logger.error("\(self.logTag) failed to report new incoming call")
|
||||
return
|
||||
}
|
||||
|
||||
@ -172,14 +170,14 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
|
||||
func answerCall(localId: UUID) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.info("\(self.TAG) \(#function)")
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
owsFail("\(self.TAG) \(#function) CallKit should answer calls via system call screen, not via notifications.")
|
||||
owsFail("\(self.logTag) \(#function) CallKit should answer calls via system call screen, not via notifications.")
|
||||
}
|
||||
|
||||
func answerCall(_ call: SignalCall) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.info("\(self.TAG) \(#function)")
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
callManager.answer(call: call)
|
||||
}
|
||||
@ -187,19 +185,19 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
func declineCall(localId: UUID) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
owsFail("\(self.TAG) \(#function) CallKit should decline calls via system call screen, not via notifications.")
|
||||
owsFail("\(self.logTag) \(#function) CallKit should decline calls via system call screen, not via notifications.")
|
||||
}
|
||||
|
||||
func declineCall(_ call: SignalCall) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.info("\(self.TAG) \(#function)")
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
callManager.localHangup(call: call)
|
||||
}
|
||||
|
||||
func recipientAcceptedCall(_ call: SignalCall) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.info("\(self.TAG) \(#function)")
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
self.provider.reportOutgoingCall(with: call.localId, connectedAt: nil)
|
||||
|
||||
@ -211,35 +209,35 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
|
||||
func localHangupCall(_ call: SignalCall) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.info("\(self.TAG) \(#function)")
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
callManager.localHangup(call: call)
|
||||
}
|
||||
|
||||
func remoteDidHangupCall(_ call: SignalCall) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.info("\(self.TAG) \(#function)")
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
provider.reportCall(with: call.localId, endedAt: nil, reason: CXCallEndedReason.remoteEnded)
|
||||
}
|
||||
|
||||
func remoteBusy(_ call: SignalCall) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.info("\(self.TAG) \(#function)")
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
provider.reportCall(with: call.localId, endedAt: nil, reason: CXCallEndedReason.unanswered)
|
||||
}
|
||||
|
||||
func setIsMuted(call: SignalCall, isMuted: Bool) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.info("\(self.TAG) \(#function)")
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
callManager.setIsMuted(call: call, isMuted: isMuted)
|
||||
}
|
||||
|
||||
func setHasLocalVideo(call: SignalCall, hasLocalVideo: Bool) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.debug("\(self.TAG) \(#function)")
|
||||
Logger.debug("\(self.logTag) \(#function)")
|
||||
|
||||
let update = CXCallUpdate()
|
||||
update.hasVideo = hasLocalVideo
|
||||
@ -254,7 +252,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
|
||||
func providerDidReset(_ provider: CXProvider) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
Logger.info("\(self.TAG) \(#function)")
|
||||
Logger.info("\(self.logTag) \(#function)")
|
||||
|
||||
// End any ongoing calls if the provider resets, and remove them from the app's list of calls,
|
||||
// since they are no longer valid.
|
||||
@ -267,10 +265,10 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.info("\(TAG) in \(#function) CXStartCallAction")
|
||||
Logger.info("\(logTag) in \(#function) CXStartCallAction")
|
||||
|
||||
guard let call = callManager.callWithLocalId(action.callUUID) else {
|
||||
Logger.error("\(TAG) unable to find call in \(#function)")
|
||||
Logger.error("\(logTag) unable to find call in \(#function)")
|
||||
return
|
||||
}
|
||||
|
||||
@ -296,7 +294,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.info("\(TAG) Received \(#function) CXAnswerCallAction")
|
||||
Logger.info("\(logTag) Received \(#function) CXAnswerCallAction")
|
||||
// Retrieve the instance corresponding to the action's call UUID
|
||||
guard let call = callManager.callWithLocalId(action.callUUID) else {
|
||||
action.fail()
|
||||
@ -311,9 +309,9 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
public func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.info("\(TAG) Received \(#function) CXEndCallAction")
|
||||
Logger.info("\(logTag) Received \(#function) CXEndCallAction")
|
||||
guard let call = callManager.callWithLocalId(action.callUUID) else {
|
||||
Logger.error("\(self.TAG) in \(#function) trying to end unknown call with localId: \(action.callUUID)")
|
||||
Logger.error("\(self.logTag) in \(#function) trying to end unknown call with localId: \(action.callUUID)")
|
||||
action.fail()
|
||||
return
|
||||
}
|
||||
@ -330,7 +328,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
public func provider(_ provider: CXProvider, perform action: CXSetHeldCallAction) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.info("\(TAG) Received \(#function) CXSetHeldCallAction")
|
||||
Logger.info("\(logTag) Received \(#function) CXSetHeldCallAction")
|
||||
guard let call = callManager.callWithLocalId(action.callUUID) else {
|
||||
action.fail()
|
||||
return
|
||||
@ -346,9 +344,9 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
public func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.info("\(TAG) Received \(#function) CXSetMutedCallAction")
|
||||
Logger.info("\(logTag) Received \(#function) CXSetMutedCallAction")
|
||||
guard let call = callManager.callWithLocalId(action.callUUID) else {
|
||||
Logger.error("\(TAG) Failing CXSetMutedCallAction for unknown call: \(action.callUUID)")
|
||||
Logger.error("\(logTag) Failing CXSetMutedCallAction for unknown call: \(action.callUUID)")
|
||||
action.fail()
|
||||
return
|
||||
}
|
||||
@ -360,19 +358,19 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
public func provider(_ provider: CXProvider, perform action: CXSetGroupCallAction) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.warn("\(TAG) unimplemented \(#function) for CXSetGroupCallAction")
|
||||
Logger.warn("\(logTag) unimplemented \(#function) for CXSetGroupCallAction")
|
||||
}
|
||||
|
||||
public func provider(_ provider: CXProvider, perform action: CXPlayDTMFCallAction) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.warn("\(TAG) unimplemented \(#function) for CXPlayDTMFCallAction")
|
||||
Logger.warn("\(logTag) unimplemented \(#function) for CXPlayDTMFCallAction")
|
||||
}
|
||||
|
||||
func provider(_ provider: CXProvider, timedOutPerforming action: CXAction) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
owsFail("\(TAG) Timed out \(#function) while performing \(action)")
|
||||
owsFail("\(logTag) Timed out \(#function) while performing \(action)")
|
||||
|
||||
// React to the action timeout if necessary, such as showing an error UI.
|
||||
}
|
||||
@ -380,7 +378,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.debug("\(TAG) Received \(#function)")
|
||||
Logger.debug("\(logTag) Received \(#function)")
|
||||
|
||||
OWSAudioSession.shared.startAudioActivity(self.audioActivity)
|
||||
OWSAudioSession.shared.isRTCAudioEnabled = true
|
||||
@ -389,7 +387,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.debug("\(TAG) Received \(#function)")
|
||||
Logger.debug("\(logTag) Received \(#function)")
|
||||
OWSAudioSession.shared.isRTCAudioEnabled = false
|
||||
OWSAudioSession.shared.endAudioActivity(self.audioActivity)
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
// Created by Michael Kirk on 12/18/16.
|
||||
// Copyright © 2016 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct TurnServerInfo {
|
||||
|
||||
let TAG = "[TurnServerInfo]"
|
||||
let password: String
|
||||
let username: String
|
||||
let urls: [String]
|
||||
|
||||
@ -83,7 +83,6 @@ extension CallUIAdaptee {
|
||||
*/
|
||||
@objc public class CallUIAdapter: NSObject, CallServiceObserver {
|
||||
|
||||
let TAG = "[CallUIAdapter]"
|
||||
private let adaptee: CallUIAdaptee
|
||||
private let contactsManager: OWSContactsManager
|
||||
internal let audioService: CallAudioService
|
||||
@ -99,16 +98,16 @@ extension CallUIAdaptee {
|
||||
// CallKit doesn't seem entirely supported in simulator.
|
||||
// e.g. you can't receive calls in the call screen.
|
||||
// So we use the non-CallKit call UI.
|
||||
Logger.info("\(TAG) choosing non-callkit adaptee for simulator.")
|
||||
Logger.info("\(CallUIAdapter.logTag()) choosing non-callkit adaptee for simulator.")
|
||||
adaptee = NonCallKitCallUIAdaptee(callService: callService, notificationsAdapter: notificationsAdapter)
|
||||
} else if #available(iOS 11, *) {
|
||||
Logger.info("\(TAG) choosing callkit adaptee for iOS11+")
|
||||
Logger.info("\(CallUIAdapter.logTag()) choosing callkit adaptee for iOS11+")
|
||||
let showNames = Environment.preferences().notificationPreviewType() != .noNameNoPreview
|
||||
let useSystemCallLog = Environment.preferences().isSystemCallLogEnabled()
|
||||
|
||||
adaptee = CallKitCallUIAdaptee(callService: callService, contactsManager: contactsManager, notificationsAdapter: notificationsAdapter, showNamesOnCallScreen: showNames, useSystemCallLog: useSystemCallLog)
|
||||
} else if #available(iOS 10.0, *), Environment.current().preferences.isCallKitEnabled() {
|
||||
Logger.info("\(TAG) choosing callkit adaptee for iOS10")
|
||||
Logger.info("\(CallUIAdapter.logTag()) choosing callkit adaptee for iOS10")
|
||||
let hideNames = Environment.preferences().isCallKitPrivacyEnabled() || Environment.preferences().notificationPreviewType() == .noNameNoPreview
|
||||
let showNames = !hideNames
|
||||
|
||||
@ -117,7 +116,7 @@ extension CallUIAdaptee {
|
||||
|
||||
adaptee = CallKitCallUIAdaptee(callService: callService, contactsManager: contactsManager, notificationsAdapter: notificationsAdapter, showNamesOnCallScreen: showNames, useSystemCallLog: useSystemCallLog)
|
||||
} else {
|
||||
Logger.info("\(TAG) choosing non-callkit adaptee")
|
||||
Logger.info("\(CallUIAdapter.logTag()) choosing non-callkit adaptee")
|
||||
adaptee = NonCallKitCallUIAdaptee(callService: callService, notificationsAdapter: notificationsAdapter)
|
||||
}
|
||||
|
||||
|
||||
@ -11,8 +11,6 @@ public class WebRTCCallMessageHandler: NSObject, OWSCallMessageHandler {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
let TAG = "[WebRTCCallMessageHandler]"
|
||||
|
||||
// MARK: Dependencies
|
||||
|
||||
let accountManager: AccountManager
|
||||
|
||||
@ -265,9 +265,6 @@ extension GiphyError: LocalizedError {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
static let TAG = "[GiphyAPI]"
|
||||
let TAG = "[GiphyAPI]"
|
||||
|
||||
static let sharedInstance = GiphyAPI()
|
||||
|
||||
// Force usage as a singleton
|
||||
@ -300,7 +297,7 @@ extension GiphyError: LocalizedError {
|
||||
|
||||
private func giphyAPISessionManager() -> AFHTTPSessionManager? {
|
||||
guard let baseUrl = NSURL(string: kGiphyBaseURL) else {
|
||||
Logger.error("\(TAG) Invalid base URL.")
|
||||
Logger.error("\(logTag) Invalid base URL.")
|
||||
return nil
|
||||
}
|
||||
let sessionManager = AFHTTPSessionManager(baseURL: baseUrl as URL,
|
||||
@ -315,12 +312,12 @@ extension GiphyError: LocalizedError {
|
||||
|
||||
public func search(query: String, success: @escaping (([GiphyImageInfo]) -> Void), failure: @escaping ((NSError?) -> Void)) {
|
||||
guard let sessionManager = giphyAPISessionManager() else {
|
||||
Logger.error("\(TAG) Couldn't create session manager.")
|
||||
Logger.error("\(logTag) Couldn't create session manager.")
|
||||
failure(nil)
|
||||
return
|
||||
}
|
||||
guard NSURL(string: kGiphyBaseURL) != nil else {
|
||||
Logger.error("\(TAG) Invalid base URL.")
|
||||
Logger.error("\(logTag) Invalid base URL.")
|
||||
failure(nil)
|
||||
return
|
||||
}
|
||||
@ -330,7 +327,7 @@ extension GiphyError: LocalizedError {
|
||||
let kGiphyPageSize = 100
|
||||
let kGiphyPageOffset = 0
|
||||
guard let queryEncoded = query.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else {
|
||||
Logger.error("\(TAG) Could not URL encode query: \(query).")
|
||||
Logger.error("\(logTag) Could not URL encode query: \(query).")
|
||||
failure(nil)
|
||||
return
|
||||
}
|
||||
@ -340,7 +337,7 @@ extension GiphyError: LocalizedError {
|
||||
parameters: {},
|
||||
progress: nil,
|
||||
success: { _, value in
|
||||
Logger.error("\(GiphyAPI.TAG) search request succeeded")
|
||||
Logger.error("\(GiphyAPI.logTag()) search request succeeded")
|
||||
guard let imageInfos = self.parseGiphyImages(responseJson: value) else {
|
||||
failure(nil)
|
||||
return
|
||||
@ -348,7 +345,7 @@ extension GiphyError: LocalizedError {
|
||||
success(imageInfos)
|
||||
},
|
||||
failure: { _, error in
|
||||
Logger.error("\(GiphyAPI.TAG) search request failed: \(error)")
|
||||
Logger.error("\(GiphyAPI.logTag()) search request failed: \(error)")
|
||||
failure(error as NSError)
|
||||
})
|
||||
}
|
||||
@ -357,15 +354,15 @@ extension GiphyError: LocalizedError {
|
||||
|
||||
private func parseGiphyImages(responseJson: Any?) -> [GiphyImageInfo]? {
|
||||
guard let responseJson = responseJson else {
|
||||
Logger.error("\(TAG) Missing response.")
|
||||
Logger.error("\(logTag) Missing response.")
|
||||
return nil
|
||||
}
|
||||
guard let responseDict = responseJson as? [String: Any] else {
|
||||
Logger.error("\(TAG) Invalid response.")
|
||||
Logger.error("\(logTag) Invalid response.")
|
||||
return nil
|
||||
}
|
||||
guard let imageDicts = responseDict["data"] as? [[String: Any]] else {
|
||||
Logger.error("\(TAG) Invalid response data.")
|
||||
Logger.error("\(logTag) Invalid response data.")
|
||||
return nil
|
||||
}
|
||||
return imageDicts.compactMap { imageDict in
|
||||
@ -376,21 +373,21 @@ extension GiphyError: LocalizedError {
|
||||
// Giphy API results are often incomplete or malformed, so we need to be defensive.
|
||||
private func parseGiphyImage(imageDict: [String: Any]) -> GiphyImageInfo? {
|
||||
guard let giphyId = imageDict["id"] as? String else {
|
||||
Logger.warn("\(TAG) Image dict missing id.")
|
||||
Logger.warn("\(logTag) Image dict missing id.")
|
||||
return nil
|
||||
}
|
||||
guard giphyId.count > 0 else {
|
||||
Logger.warn("\(TAG) Image dict has invalid id.")
|
||||
Logger.warn("\(logTag) Image dict has invalid id.")
|
||||
return nil
|
||||
}
|
||||
guard let renditionDicts = imageDict["images"] as? [String: Any] else {
|
||||
Logger.warn("\(TAG) Image dict missing renditions.")
|
||||
Logger.warn("\(logTag) Image dict missing renditions.")
|
||||
return nil
|
||||
}
|
||||
var renditions = [GiphyRendition]()
|
||||
for (renditionName, renditionDict) in renditionDicts {
|
||||
guard let renditionDict = renditionDict as? [String: Any] else {
|
||||
Logger.warn("\(TAG) Invalid rendition dict.")
|
||||
Logger.warn("\(logTag) Invalid rendition dict.")
|
||||
continue
|
||||
}
|
||||
guard let rendition = parseGiphyRendition(renditionName: renditionName,
|
||||
@ -400,12 +397,12 @@ extension GiphyError: LocalizedError {
|
||||
renditions.append(rendition)
|
||||
}
|
||||
guard renditions.count > 0 else {
|
||||
Logger.warn("\(TAG) Image has no valid renditions.")
|
||||
Logger.warn("\(logTag) Image has no valid renditions.")
|
||||
return nil
|
||||
}
|
||||
|
||||
guard let originalRendition = findOriginalRendition(renditions: renditions) else {
|
||||
Logger.warn("\(TAG) Image has no original rendition.")
|
||||
Logger.warn("\(logTag) Image has no original rendition.")
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -438,15 +435,15 @@ extension GiphyError: LocalizedError {
|
||||
return nil
|
||||
}
|
||||
guard urlString.count > 0 else {
|
||||
Logger.warn("\(TAG) Rendition has invalid url.")
|
||||
Logger.warn("\(logTag) Rendition has invalid url.")
|
||||
return nil
|
||||
}
|
||||
guard let url = NSURL(string: urlString) else {
|
||||
Logger.warn("\(TAG) Rendition url could not be parsed.")
|
||||
Logger.warn("\(logTag) Rendition url could not be parsed.")
|
||||
return nil
|
||||
}
|
||||
guard let fileExtension = url.pathExtension?.lowercased() else {
|
||||
Logger.warn("\(TAG) Rendition url missing file extension.")
|
||||
Logger.warn("\(logTag) Rendition url missing file extension.")
|
||||
return nil
|
||||
}
|
||||
var format = GiphyFormat.gif
|
||||
@ -459,7 +456,7 @@ extension GiphyError: LocalizedError {
|
||||
} else if fileExtension == "webp" {
|
||||
return nil
|
||||
} else {
|
||||
Logger.warn("\(TAG) Invalid file extension: \(fileExtension).")
|
||||
Logger.warn("\(logTag) Invalid file extension: \(fileExtension).")
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -484,7 +481,7 @@ extension GiphyError: LocalizedError {
|
||||
return nil
|
||||
}
|
||||
guard parsedValue > 0 else {
|
||||
Logger.verbose("\(TAG) \(typeName) has non-positive \(key): \(parsedValue).")
|
||||
Logger.verbose("\(logTag) \(typeName) has non-positive \(key): \(parsedValue).")
|
||||
return nil
|
||||
}
|
||||
return parsedValue
|
||||
|
||||
@ -19,8 +19,7 @@ enum GiphyAssetSegmentState: UInt {
|
||||
case failed
|
||||
}
|
||||
|
||||
class GiphyAssetSegment {
|
||||
let TAG = "[GiphyAssetSegment]"
|
||||
class GiphyAssetSegment: NSObject {
|
||||
|
||||
public let index: UInt
|
||||
public let segmentStart: UInt
|
||||
@ -61,7 +60,7 @@ class GiphyAssetSegment {
|
||||
|
||||
public func append(data: Data) {
|
||||
guard state == .downloading else {
|
||||
owsFail("\(TAG) appending data in invalid state: \(state)")
|
||||
owsFail("\(logTag) appending data in invalid state: \(state)")
|
||||
return
|
||||
}
|
||||
|
||||
@ -70,11 +69,11 @@ class GiphyAssetSegment {
|
||||
|
||||
public func mergeData(assetData: inout Data) -> Bool {
|
||||
guard state == .complete else {
|
||||
owsFail("\(TAG) merging data in invalid state: \(state)")
|
||||
owsFail("\(logTag) merging data in invalid state: \(state)")
|
||||
return false
|
||||
}
|
||||
guard UInt(segmentData.count) == segmentLength else {
|
||||
owsFail("\(TAG) segment data length: \(segmentData.count) doesn't match expected length: \(segmentLength)")
|
||||
owsFail("\(logTag) segment data length: \(segmentData.count) doesn't match expected length: \(segmentLength)")
|
||||
return false
|
||||
}
|
||||
|
||||
@ -109,8 +108,6 @@ enum GiphyAssetRequestState: UInt {
|
||||
//
|
||||
// Should be cancelled if no longer necessary.
|
||||
@objc class GiphyAssetRequest: NSObject {
|
||||
static let TAG = "[GiphyAssetRequest]"
|
||||
let TAG = "[GiphyAssetRequest]"
|
||||
|
||||
let rendition: GiphyRendition
|
||||
let priority: GiphyRequestPriority
|
||||
@ -155,7 +152,7 @@ enum GiphyAssetRequestState: UInt {
|
||||
|
||||
let contentLength = UInt(self.contentLength)
|
||||
guard contentLength > 0 else {
|
||||
owsFail("\(TAG) rendition missing contentLength")
|
||||
owsFail("\(logTag) rendition missing contentLength")
|
||||
requestDidFail()
|
||||
return 0
|
||||
}
|
||||
@ -209,7 +206,7 @@ enum GiphyAssetRequestState: UInt {
|
||||
|
||||
for segment in segments {
|
||||
guard segment.state != .failed else {
|
||||
owsFail("\(TAG) unexpected failed segment.")
|
||||
owsFail("\(logTag) unexpected failed segment.")
|
||||
continue
|
||||
}
|
||||
if segment.state == state {
|
||||
@ -231,7 +228,7 @@ enum GiphyAssetRequestState: UInt {
|
||||
var result: UInt = 0
|
||||
for segment in segments {
|
||||
guard segment.state != .failed else {
|
||||
owsFail("\(TAG) unexpected failed segment.")
|
||||
owsFail("\(logTag) unexpected failed segment.")
|
||||
continue
|
||||
}
|
||||
if segment.state == .downloading {
|
||||
@ -257,26 +254,26 @@ enum GiphyAssetRequestState: UInt {
|
||||
var assetData = Data()
|
||||
for segment in segments {
|
||||
guard segment.state == .complete else {
|
||||
owsFail("\(TAG) unexpected incomplete segment.")
|
||||
owsFail("\(logTag) unexpected incomplete segment.")
|
||||
return nil
|
||||
}
|
||||
guard segment.totalDataSize() > 0 else {
|
||||
owsFail("\(TAG) could not merge empty segment.")
|
||||
owsFail("\(logTag) could not merge empty segment.")
|
||||
return nil
|
||||
}
|
||||
guard segment.mergeData(assetData: &assetData) else {
|
||||
owsFail("\(TAG) failed to merge segment data.")
|
||||
owsFail("\(logTag) failed to merge segment data.")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
guard assetData.count == contentLength else {
|
||||
owsFail("\(TAG) asset data has unexpected length.")
|
||||
owsFail("\(logTag) asset data has unexpected length.")
|
||||
return nil
|
||||
}
|
||||
|
||||
guard assetData.count > 0 else {
|
||||
owsFail("\(TAG) could not write empty asset to disk.")
|
||||
owsFail("\(logTag) could not write empty asset to disk.")
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -284,14 +281,14 @@ enum GiphyAssetRequestState: UInt {
|
||||
let fileName = (NSUUID().uuidString as NSString).appendingPathExtension(fileExtension)!
|
||||
let filePath = (gifFolderPath as NSString).appendingPathComponent(fileName)
|
||||
|
||||
Logger.verbose("\(TAG) filePath: \(filePath).")
|
||||
Logger.verbose("\(logTag) filePath: \(filePath).")
|
||||
|
||||
do {
|
||||
try assetData.write(to: NSURL.fileURL(withPath: filePath), options: .atomicWrite)
|
||||
let asset = GiphyAsset(rendition: rendition, filePath: filePath)
|
||||
return asset
|
||||
} catch let error as NSError {
|
||||
owsFail("\(GiphyAsset.TAG) file write failed: \(filePath), \(error)")
|
||||
owsFail("\(GiphyAsset.logTag()) file write failed: \(filePath), \(error)")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -343,7 +340,6 @@ enum GiphyAssetRequestState: UInt {
|
||||
// so consumers of this resource should retain a strong reference to
|
||||
// this instance as long as they are using the asset.
|
||||
@objc class GiphyAsset: NSObject {
|
||||
static let TAG = "[GiphyAsset]"
|
||||
|
||||
let rendition: GiphyRendition
|
||||
let filePath: String
|
||||
@ -362,7 +358,7 @@ enum GiphyAssetRequestState: UInt {
|
||||
let fileManager = FileManager.default
|
||||
try fileManager.removeItem(atPath: filePathCopy)
|
||||
} catch let error as NSError {
|
||||
owsFail("\(GiphyAsset.TAG) file cleanup failed: \(filePathCopy), \(error)")
|
||||
owsFail("\(GiphyAsset.logTag()) file cleanup failed: \(filePathCopy), \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -395,8 +391,6 @@ extension URLSessionTask {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
let TAG = "[GiphyDownloader]"
|
||||
|
||||
static let sharedInstance = GiphyDownloader()
|
||||
|
||||
var gifFolderPath = ""
|
||||
@ -455,7 +449,7 @@ extension URLSessionTask {
|
||||
|
||||
if let asset = assetMap.get(key: rendition.url) {
|
||||
// Synchronous cache hit.
|
||||
Logger.verbose("\(self.TAG) asset cache hit: \(rendition.url)")
|
||||
Logger.verbose("\(self.logTag) asset cache hit: \(rendition.url)")
|
||||
success(nil, asset)
|
||||
return nil
|
||||
}
|
||||
@ -463,7 +457,7 @@ extension URLSessionTask {
|
||||
// Cache miss.
|
||||
//
|
||||
// Asset requests are done queued and performed asynchronously.
|
||||
Logger.verbose("\(self.TAG) asset cache miss: \(rendition.url)")
|
||||
Logger.verbose("\(self.logTag) asset cache miss: \(rendition.url)")
|
||||
let assetRequest = GiphyAssetRequest(rendition: rendition,
|
||||
priority: priority,
|
||||
success: success,
|
||||
@ -480,7 +474,7 @@ extension URLSessionTask {
|
||||
public func cancelAllRequests() {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
Logger.verbose("\(self.TAG) cancelAllRequests")
|
||||
Logger.verbose("\(self.logTag) cancelAllRequests")
|
||||
|
||||
self.assetRequestQueue.forEach { $0.cancel() }
|
||||
self.assetRequestQueue = []
|
||||
@ -540,7 +534,7 @@ extension URLSessionTask {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
guard assetRequestQueue.contains(assetRequest) else {
|
||||
Logger.warn("\(TAG) could not remove asset request from queue: \(assetRequest.rendition.url)")
|
||||
Logger.warn("\(logTag) could not remove asset request from queue: \(assetRequest.rendition.url)")
|
||||
return
|
||||
}
|
||||
|
||||
@ -598,7 +592,7 @@ extension URLSessionTask {
|
||||
|
||||
let task = giphyDownloadSession.dataTask(with: request, completionHandler: { data, response, error -> Void in
|
||||
if let data = data, data.count > 0 {
|
||||
owsFail("\(self.TAG) HEAD request has unexpected body: \(data.count).")
|
||||
owsFail("\(self.logTag) HEAD request has unexpected body: \(data.count).")
|
||||
}
|
||||
self.handleAssetSizeResponse(assetRequest: assetRequest, response: response, error: error)
|
||||
})
|
||||
@ -608,7 +602,7 @@ extension URLSessionTask {
|
||||
// Start a download task.
|
||||
|
||||
guard let assetSegment = assetRequest.firstWaitingSegment() else {
|
||||
owsFail("\(TAG) queued asset request does not have a waiting segment.")
|
||||
owsFail("\(logTag) queued asset request does not have a waiting segment.")
|
||||
return
|
||||
}
|
||||
assetSegment.state = .downloading
|
||||
@ -635,25 +629,25 @@ extension URLSessionTask {
|
||||
return
|
||||
}
|
||||
guard let httpResponse = response as? HTTPURLResponse else {
|
||||
owsFail("\(self.TAG) Asset size response is invalid.")
|
||||
owsFail("\(self.logTag) Asset size response is invalid.")
|
||||
assetRequest.state = .failed
|
||||
self.assetRequestDidFail(assetRequest: assetRequest)
|
||||
return
|
||||
}
|
||||
guard let contentLengthString = httpResponse.allHeaderFields["Content-Length"] as? String else {
|
||||
owsFail("\(self.TAG) Asset size response is missing content length.")
|
||||
owsFail("\(self.logTag) Asset size response is missing content length.")
|
||||
assetRequest.state = .failed
|
||||
self.assetRequestDidFail(assetRequest: assetRequest)
|
||||
return
|
||||
}
|
||||
guard let contentLength = Int(contentLengthString) else {
|
||||
owsFail("\(self.TAG) Asset size response has unparsable content length.")
|
||||
owsFail("\(self.logTag) Asset size response has unparsable content length.")
|
||||
assetRequest.state = .failed
|
||||
self.assetRequestDidFail(assetRequest: assetRequest)
|
||||
return
|
||||
}
|
||||
guard contentLength > 0 else {
|
||||
owsFail("\(self.TAG) Asset size response has invalid content length.")
|
||||
owsFail("\(self.logTag) Asset size response has invalid content length.")
|
||||
assetRequest.state = .failed
|
||||
self.assetRequestDidFail(assetRequest: assetRequest)
|
||||
return
|
||||
@ -756,23 +750,23 @@ extension URLSessionTask {
|
||||
return
|
||||
}
|
||||
if let error = error {
|
||||
Logger.error("\(TAG) download failed with error: \(error)")
|
||||
Logger.error("\(logTag) download failed with error: \(error)")
|
||||
segmentRequestDidFail(assetRequest: assetRequest, assetSegment: assetSegment)
|
||||
return
|
||||
}
|
||||
guard let httpResponse = task.response as? HTTPURLResponse else {
|
||||
Logger.error("\(TAG) missing or unexpected response: \(String(describing: task.response))")
|
||||
Logger.error("\(logTag) missing or unexpected response: \(String(describing: task.response))")
|
||||
segmentRequestDidFail(assetRequest: assetRequest, assetSegment: assetSegment)
|
||||
return
|
||||
}
|
||||
let statusCode = httpResponse.statusCode
|
||||
guard statusCode >= 200 && statusCode < 400 else {
|
||||
Logger.error("\(TAG) response has invalid status code: \(statusCode)")
|
||||
Logger.error("\(logTag) response has invalid status code: \(statusCode)")
|
||||
segmentRequestDidFail(assetRequest: assetRequest, assetSegment: assetSegment)
|
||||
return
|
||||
}
|
||||
guard assetSegment.totalDataSize() == assetSegment.segmentLength else {
|
||||
Logger.error("\(TAG) segment is missing data: \(statusCode)")
|
||||
Logger.error("\(logTag) segment is missing data: \(statusCode)")
|
||||
segmentRequestDidFail(assetRequest: assetRequest, assetSegment: assetSegment)
|
||||
return
|
||||
}
|
||||
@ -807,7 +801,7 @@ extension URLSessionTask {
|
||||
// Don't back up Giphy downloads.
|
||||
OWSFileSystem.protectFileOrFolder(atPath: dirPath)
|
||||
} catch let error as NSError {
|
||||
owsFail("\(GiphyAsset.TAG) ensureTempFolder failed: \(dirPath), \(error)")
|
||||
owsFail("\(GiphyAsset.logTag()) ensureTempFolder failed: \(dirPath), \(error)")
|
||||
gifFolderPath = tempDirPath
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,8 +8,6 @@ import SignalMessaging
|
||||
|
||||
class AttachmentPointerView: UIStackView {
|
||||
|
||||
let TAG = "[AttachmentPointerView]"
|
||||
|
||||
let isIncoming: Bool
|
||||
let attachmentPointer: TSAttachmentPointer
|
||||
let conversationStyle: ConversationStyle
|
||||
|
||||
@ -7,14 +7,12 @@ import SignalServiceKit
|
||||
|
||||
@objc class GroupTableViewCell: UITableViewCell {
|
||||
|
||||
let TAG = "[GroupTableViewCell]"
|
||||
|
||||
private let avatarView = AvatarImageView()
|
||||
private let nameLabel = UILabel()
|
||||
private let subtitleLabel = UILabel()
|
||||
|
||||
init() {
|
||||
super.init(style: .default, reuseIdentifier: TAG)
|
||||
super.init(style: .default, reuseIdentifier: GroupTableViewCell.logTag())
|
||||
|
||||
// Font config
|
||||
nameLabel.font = .ows_dynamicTypeBody
|
||||
|
||||
@ -6,7 +6,6 @@ import Foundation
|
||||
|
||||
class ReminderView: UIView {
|
||||
|
||||
let TAG = "[ReminderView]"
|
||||
let label = UILabel()
|
||||
|
||||
typealias Action = () -> Void
|
||||
|
||||
@ -15,7 +15,6 @@ public protocol AttachmentApprovalViewControllerDelegate: class {
|
||||
@objc
|
||||
public class AttachmentApprovalViewController: OWSViewController, CaptioningToolbarDelegate, PlayerProgressBarDelegate, OWSVideoPlayerDelegate {
|
||||
|
||||
let TAG = "[AttachmentApprovalViewController]"
|
||||
weak var delegate: AttachmentApprovalViewControllerDelegate?
|
||||
|
||||
// We sometimes shrink the attachment view so that it remains somewhat visible
|
||||
@ -271,15 +270,15 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
|
||||
// MARK: Video
|
||||
|
||||
private func playVideo() {
|
||||
Logger.info("\(TAG) in \(#function)")
|
||||
Logger.info("\(logTag) in \(#function)")
|
||||
|
||||
guard let videoPlayer = self.videoPlayer else {
|
||||
owsFail("\(TAG) video player was unexpectedly nil")
|
||||
owsFail("\(logTag) video player was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let playVideoButton = self.playVideoButton else {
|
||||
owsFail("\(TAG) playVideoButton was unexpectedly nil")
|
||||
owsFail("\(logTag) playVideoButton was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
UIView.animate(withDuration: 0.1) {
|
||||
@ -290,13 +289,13 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
|
||||
|
||||
private func pauseVideo() {
|
||||
guard let videoPlayer = self.videoPlayer else {
|
||||
owsFail("\(TAG) video player was unexpectedly nil")
|
||||
owsFail("\(logTag) video player was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
videoPlayer.pause()
|
||||
guard let playVideoButton = self.playVideoButton else {
|
||||
owsFail("\(TAG) playVideoButton was unexpectedly nil")
|
||||
owsFail("\(logTag) playVideoButton was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
UIView.animate(withDuration: 0.1) {
|
||||
@ -307,7 +306,7 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
|
||||
@objc
|
||||
public func videoPlayerDidPlayToCompletion(_ videoPlayer: OWSVideoPlayer) {
|
||||
guard let playVideoButton = self.playVideoButton else {
|
||||
owsFail("\(TAG) playVideoButton was unexpectedly nil")
|
||||
owsFail("\(logTag) playVideoButton was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
@ -318,7 +317,7 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
|
||||
|
||||
public func playerProgressBarDidStartScrubbing(_ playerProgressBar: PlayerProgressBar) {
|
||||
guard let videoPlayer = self.videoPlayer else {
|
||||
owsFail("\(TAG) video player was unexpectedly nil")
|
||||
owsFail("\(logTag) video player was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
videoPlayer.pause()
|
||||
@ -326,7 +325,7 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
|
||||
|
||||
public func playerProgressBar(_ playerProgressBar: PlayerProgressBar, scrubbedToTime time: CMTime) {
|
||||
guard let videoPlayer = self.videoPlayer else {
|
||||
owsFail("\(TAG) video player was unexpectedly nil")
|
||||
owsFail("\(logTag) video player was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
@ -335,7 +334,7 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
|
||||
|
||||
public func playerProgressBar(_ playerProgressBar: PlayerProgressBar, didFinishScrubbingAtTime time: CMTime, shouldResumePlayback: Bool) {
|
||||
guard let videoPlayer = self.videoPlayer else {
|
||||
owsFail("\(TAG) video player was unexpectedly nil")
|
||||
owsFail("\(logTag) video player was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -17,8 +17,6 @@ public enum MediaMessageViewMode: UInt {
|
||||
@objc
|
||||
public class MediaMessageView: UIView, OWSAudioPlayerDelegate {
|
||||
|
||||
let TAG = "[MediaMessageView]"
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@objc
|
||||
|
||||
@ -13,7 +13,6 @@ public protocol MessageApprovalViewControllerDelegate: class {
|
||||
@objc
|
||||
public class MessageApprovalViewController: OWSViewController, UITextViewDelegate {
|
||||
|
||||
let TAG = "[MessageApprovalViewController]"
|
||||
weak var delegate: MessageApprovalViewControllerDelegate?
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@ -11,8 +11,6 @@ import SignalServiceKit
|
||||
@objc
|
||||
public class ModalActivityIndicatorViewController: OWSViewController {
|
||||
|
||||
let TAG = "[ModalActivityIndicatorViewController]"
|
||||
|
||||
let canCancel: Bool
|
||||
|
||||
@objc
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
import Foundation
|
||||
|
||||
@objc public class OWSAlerts: NSObject {
|
||||
let TAG = "[OWSAlerts]"
|
||||
|
||||
/// Cleanup and present alert for no permissions
|
||||
@objc
|
||||
|
||||
@ -7,7 +7,6 @@ import SignalServiceKit
|
||||
|
||||
@objc
|
||||
public class OWSFlatButton: UIView {
|
||||
let TAG = "[OWSFlatButton]"
|
||||
|
||||
private let button: UIButton
|
||||
|
||||
|
||||
@ -53,7 +53,6 @@ class TrackingSlider: UISlider {
|
||||
|
||||
@objc
|
||||
public class PlayerProgressBar: UIView {
|
||||
public let TAG = "[PlayerProgressBar]"
|
||||
|
||||
@objc
|
||||
public weak var delegate: PlayerProgressBarDelegate?
|
||||
@ -185,12 +184,12 @@ public class PlayerProgressBar: UIView {
|
||||
|
||||
private func updateState() {
|
||||
guard let player = player else {
|
||||
owsFail("\(TAG) player isn't set.")
|
||||
owsFail("\(logTag) player isn't set.")
|
||||
return
|
||||
}
|
||||
|
||||
guard let item = player.currentItem else {
|
||||
owsFail("\(TAG) player has no item.")
|
||||
owsFail("\(logTag) player has no item.")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -9,8 +9,6 @@ import SignalServiceKit
|
||||
@objc
|
||||
public class OWS106EnsureProfileComplete: OWSDatabaseMigration {
|
||||
|
||||
let TAG = "[OWS106EnsureProfileComplete]"
|
||||
|
||||
private static var sharedCompleteRegistrationFixerJob: CompleteRegistrationFixerJob?
|
||||
|
||||
// increment a similar constant for each migration.
|
||||
@ -25,10 +23,10 @@ public class OWS106EnsureProfileComplete: OWSDatabaseMigration {
|
||||
let job = CompleteRegistrationFixerJob(completionHandler: { (didSucceed) in
|
||||
|
||||
if (didSucceed) {
|
||||
Logger.info("\(self.TAG) Completed. Saving.")
|
||||
Logger.info("\(self.logTag) Completed. Saving.")
|
||||
self.save()
|
||||
} else {
|
||||
Logger.error("\(self.TAG) Failed.")
|
||||
Logger.error("\(self.logTag) Failed.")
|
||||
}
|
||||
|
||||
completion()
|
||||
@ -44,9 +42,7 @@ public class OWS106EnsureProfileComplete: OWSDatabaseMigration {
|
||||
* but never upload new pre-keys. The symptom is that there will be accounts with no uploaded
|
||||
* identity key. We detect that here and fix the situation
|
||||
*/
|
||||
private class CompleteRegistrationFixerJob {
|
||||
|
||||
let TAG = "[CompleteRegistrationFixerJob]"
|
||||
private class CompleteRegistrationFixerJob: NSObject {
|
||||
|
||||
// Duration between retries if update fails.
|
||||
let kRetryInterval: TimeInterval = 5
|
||||
@ -64,7 +60,7 @@ public class OWS106EnsureProfileComplete: OWSDatabaseMigration {
|
||||
}
|
||||
|
||||
self.ensureProfileComplete().then { _ -> Void in
|
||||
Logger.info("\(self.TAG) complete. Canceling timer and saving.")
|
||||
Logger.info("\(self.logTag) complete. Canceling timer and saving.")
|
||||
self.completionHandler(true)
|
||||
}.catch { error in
|
||||
let nserror = error as NSError
|
||||
@ -73,13 +69,13 @@ public class OWS106EnsureProfileComplete: OWSDatabaseMigration {
|
||||
// In particular, 401 (invalid auth) is unrecoverable.
|
||||
let isUnrecoverableError = nserror.code == 401
|
||||
if isUnrecoverableError {
|
||||
Logger.error("\(self.TAG) failed due to unrecoverable error: \(error). Aborting.")
|
||||
Logger.error("\(self.logTag) failed due to unrecoverable error: \(error). Aborting.")
|
||||
self.completionHandler(true)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Logger.error("\(self.TAG) failed with \(error).")
|
||||
Logger.error("\(self.logTag) failed with \(error).")
|
||||
self.completionHandler(false)
|
||||
}.retainUntilComplete()
|
||||
}
|
||||
@ -93,25 +89,25 @@ public class OWS106EnsureProfileComplete: OWSDatabaseMigration {
|
||||
let (promise, fulfill, reject) = Promise<Void>.pending()
|
||||
|
||||
guard let networkManager = Environment.current().networkManager else {
|
||||
return Promise(error: OWSErrorMakeAssertionError("\(TAG) network manager was unexpectedly not set"))
|
||||
return Promise(error: OWSErrorMakeAssertionError("\(logTag) network manager was unexpectedly not set"))
|
||||
}
|
||||
|
||||
ProfileFetcherJob(networkManager: networkManager).getProfile(recipientId: localRecipientId).then { _ -> Void in
|
||||
Logger.info("\(self.TAG) verified recipient profile is in good shape: \(localRecipientId)")
|
||||
Logger.info("\(self.logTag) verified recipient profile is in good shape: \(localRecipientId)")
|
||||
|
||||
fulfill(())
|
||||
}.catch { error in
|
||||
switch error {
|
||||
case SignalServiceProfile.ValidationError.invalidIdentityKey(let description):
|
||||
Logger.warn("\(self.TAG) detected incomplete profile for \(localRecipientId) error: \(description)")
|
||||
Logger.warn("\(self.logTag) detected incomplete profile for \(localRecipientId) error: \(description)")
|
||||
// This is the error condition we're looking for. Update prekeys to properly set the identity key, completing registration.
|
||||
TSPreKeyManager.registerPreKeys(with: .signedAndOneTime,
|
||||
success: {
|
||||
Logger.info("\(self.TAG) successfully uploaded pre-keys. Profile should be fixed.")
|
||||
Logger.info("\(self.logTag) successfully uploaded pre-keys. Profile should be fixed.")
|
||||
fulfill(())
|
||||
},
|
||||
failure: { _ in
|
||||
reject(OWSErrorWithCodeDescription(.signalServiceFailure, "\(self.TAG) Unknown error in \(#function)"))
|
||||
reject(OWSErrorWithCodeDescription(.signalServiceFailure, "\(self.logTag) Unknown error in \(#function)"))
|
||||
})
|
||||
default:
|
||||
reject(error)
|
||||
|
||||
@ -9,8 +9,6 @@ import SignalServiceKit
|
||||
@objc
|
||||
public class ProfileFetcherJob: NSObject {
|
||||
|
||||
let TAG = "[ProfileFetcherJob]"
|
||||
|
||||
let networkManager: TSNetworkManager
|
||||
let socketManager: TSSocketManager
|
||||
let primaryStorage: OWSPrimaryStorage
|
||||
@ -79,14 +77,14 @@ public class ProfileFetcherJob: NSObject {
|
||||
}.catch { error in
|
||||
switch error {
|
||||
case ProfileFetcherJobError.throttled(let lastTimeInterval):
|
||||
Logger.info("\(self.TAG) skipping updateProfile: \(recipientId), lastTimeInterval: \(lastTimeInterval)")
|
||||
Logger.info("\(self.logTag) skipping updateProfile: \(recipientId), lastTimeInterval: \(lastTimeInterval)")
|
||||
case let error as SignalServiceProfile.ValidationError:
|
||||
Logger.warn("\(self.TAG) skipping updateProfile retry. Invalid profile for: \(recipientId) error: \(error)")
|
||||
Logger.warn("\(self.logTag) skipping updateProfile retry. Invalid profile for: \(recipientId) error: \(error)")
|
||||
default:
|
||||
if remainingRetries > 0 {
|
||||
self.updateProfile(recipientId: recipientId, remainingRetries: remainingRetries - 1)
|
||||
} else {
|
||||
Logger.error("\(self.TAG) in \(#function) failed to get profile with error: \(error)")
|
||||
Logger.error("\(self.logTag) in \(#function) failed to get profile with error: \(error)")
|
||||
}
|
||||
}
|
||||
}.retainUntilComplete()
|
||||
@ -109,7 +107,7 @@ public class ProfileFetcherJob: NSObject {
|
||||
}
|
||||
ProfileFetcherJob.fetchDateMap[recipientId] = Date()
|
||||
|
||||
Logger.error("\(self.TAG) getProfile: \(recipientId)")
|
||||
Logger.error("\(self.logTag) getProfile: \(recipientId)")
|
||||
|
||||
let request = OWSRequestFactory.getProfileRequest(withRecipientId: recipientId)
|
||||
|
||||
@ -162,7 +160,7 @@ public class ProfileFetcherJob: NSObject {
|
||||
private func verifyIdentityUpToDateAsync(recipientId: String, latestIdentityKey: Data) {
|
||||
primaryStorage.newDatabaseConnection().asyncReadWrite { (transaction) in
|
||||
if OWSIdentityManager.shared().saveRemoteIdentity(latestIdentityKey, recipientId: recipientId, protocolContext: transaction) {
|
||||
Logger.info("\(self.TAG) updated identity key with fetched profile for recipient: \(recipientId)")
|
||||
Logger.info("\(self.logTag) updated identity key with fetched profile for recipient: \(recipientId)")
|
||||
self.primaryStorage.archiveAllSessions(forContact: recipientId, protocolContext: transaction)
|
||||
} else {
|
||||
// no change in identity.
|
||||
@ -173,7 +171,6 @@ public class ProfileFetcherJob: NSObject {
|
||||
|
||||
@objc
|
||||
public class SignalServiceProfile: NSObject {
|
||||
let TAG = "[SignalServiceProfile]"
|
||||
|
||||
public enum ValidationError: Error {
|
||||
case invalid(description: String)
|
||||
@ -190,23 +187,23 @@ public class SignalServiceProfile: NSObject {
|
||||
self.recipientId = recipientId
|
||||
|
||||
guard let responseDict = rawResponse as? [String: Any?] else {
|
||||
throw ValidationError.invalid(description: "\(TAG) unexpected type: \(String(describing: rawResponse))")
|
||||
throw ValidationError.invalid(description: "\(SignalServiceProfile.logTag()) unexpected type: \(String(describing: rawResponse))")
|
||||
}
|
||||
|
||||
guard let identityKeyString = responseDict["identityKey"] as? String else {
|
||||
throw ValidationError.invalidIdentityKey(description: "\(TAG) missing identity key: \(String(describing: rawResponse))")
|
||||
throw ValidationError.invalidIdentityKey(description: "\(SignalServiceProfile.logTag()) missing identity key: \(String(describing: rawResponse))")
|
||||
}
|
||||
guard let identityKeyWithType = Data(base64Encoded: identityKeyString) else {
|
||||
throw ValidationError.invalidIdentityKey(description: "\(TAG) unable to parse identity key: \(identityKeyString)")
|
||||
throw ValidationError.invalidIdentityKey(description: "\(SignalServiceProfile.logTag()) unable to parse identity key: \(identityKeyString)")
|
||||
}
|
||||
let kIdentityKeyLength = 33
|
||||
guard identityKeyWithType.count == kIdentityKeyLength else {
|
||||
throw ValidationError.invalidIdentityKey(description: "\(TAG) malformed key \(identityKeyString) with decoded length: \(identityKeyWithType.count)")
|
||||
throw ValidationError.invalidIdentityKey(description: "\(SignalServiceProfile.logTag()) malformed key \(identityKeyString) with decoded length: \(identityKeyWithType.count)")
|
||||
}
|
||||
|
||||
if let profileNameString = responseDict["name"] as? String {
|
||||
guard let data = Data(base64Encoded: profileNameString) else {
|
||||
throw ValidationError.invalidProfileName(description: "\(TAG) unable to parse profile name: \(profileNameString)")
|
||||
throw ValidationError.invalidProfileName(description: "\(SignalServiceProfile.logTag()) unable to parse profile name: \(profileNameString)")
|
||||
}
|
||||
self.profileNameEncrypted = data
|
||||
} else {
|
||||
|
||||
@ -18,8 +18,6 @@ import SignalServiceKit
|
||||
@objc
|
||||
public class DeviceSleepManager: NSObject {
|
||||
|
||||
let TAG = "[DeviceSleepManager]"
|
||||
|
||||
@objc
|
||||
public static let sharedInstance = DeviceSleepManager()
|
||||
|
||||
|
||||
@ -150,8 +150,6 @@ extension String {
|
||||
|
||||
@objc public class DisplayableText: NSObject {
|
||||
|
||||
static let TAG = "[DisplayableText]"
|
||||
|
||||
@objc public let fullText: String
|
||||
@objc public let displayText: String
|
||||
@objc public let isTextTruncated: Bool
|
||||
|
||||
@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@property (nonatomic, readonly) NSString *logTag;
|
||||
|
||||
+ (NSString *)logTag;
|
||||
@property (class, nonatomic, readonly) NSString *logTag;
|
||||
|
||||
+ (BOOL)isNullableObject:(nullable NSObject *)left equalTo:(nullable NSObject *)right;
|
||||
|
||||
|
||||
@ -911,9 +911,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
|
||||
}
|
||||
|
||||
// Exposes a Progress object, whose progress is updated by polling the return of a given block
|
||||
private class ProgressPoller {
|
||||
|
||||
let TAG = "[ProgressPoller]"
|
||||
private class ProgressPoller: NSObject {
|
||||
|
||||
let progress: Progress
|
||||
private(set) var timer: Timer?
|
||||
@ -948,7 +946,7 @@ private class ProgressPoller {
|
||||
strongSelf.progress.completedUnitCount = completedUnitCount
|
||||
|
||||
if completedUnitCount == strongSelf.progressTotalUnitCount {
|
||||
Logger.debug("\(strongSelf.TAG) progress complete")
|
||||
Logger.debug("\(strongSelf.logTag) progress complete")
|
||||
timer.invalidate()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user