Browse Source

Ditch unused Signal code

pull/313/head
nielsandriesse 2 years ago committed by Niels Andriesse
parent
commit
f36f447bec
  1. 23
      Session/Components/ConversationTitleView.swift
  2. 31
      Session/Meta/Signal-Bridging-Header.h
  3. 1
      Session/Meta/Signal-Prefix.pch
  4. 28
      Session/Signal/AccountManager.swift
  5. 145
      Session/Signal/AddContactShareToExistingContactViewController.swift
  6. 15
      Session/Signal/AddToBlockListViewController.m
  7. 48
      Session/Signal/AddToGroupViewController.m
  8. 9
      Session/Signal/AdvancedSettingsTableViewController.h
  9. 312
      Session/Signal/AdvancedSettingsTableViewController.m
  10. 93
      Session/Signal/AppDelegate.m
  11. 6
      Session/Signal/AppEnvironment.swift
  12. 237
      Session/Signal/AppNotifications.swift
  13. 12
      Session/Signal/AvatarTableViewCell.swift
  14. 4
      Session/Signal/AvatarViewHelper.m
  15. 13
      Session/Signal/BlockListViewController.h
  16. 175
      Session/Signal/BlockListViewController.m
  17. 532
      Session/Signal/ColorPickerViewController.swift
  18. 162
      Session/Signal/ContactCell.swift
  19. 215
      Session/Signal/ContactShareViewHelper.swift
  20. 679
      Session/Signal/ContactViewController.swift
  21. 404
      Session/Signal/ContactsPicker.swift
  22. 97
      Session/Signal/ConversationConfigurationSyncOperation.swift
  23. 18
      Session/Signal/ConversationView/Cells/ConversationViewCell.h
  24. 19
      Session/Signal/ConversationView/Cells/OWSContactOffersCell.h
  25. 263
      Session/Signal/ConversationView/Cells/OWSContactOffersCell.m
  26. 33
      Session/Signal/ConversationView/Cells/OWSContactShareButtonsView.h
  27. 169
      Session/Signal/ConversationView/Cells/OWSContactShareButtonsView.m
  28. 22
      Session/Signal/ConversationView/Cells/OWSContactShareView.h
  29. 165
      Session/Signal/ConversationView/Cells/OWSContactShareView.m
  30. 4
      Session/Signal/ConversationView/Cells/OWSGenericAttachmentView.m
  31. 9
      Session/Signal/ConversationView/Cells/OWSMessageBubbleView.h
  32. 200
      Session/Signal/ConversationView/Cells/OWSMessageBubbleView.m
  33. 3
      Session/Signal/ConversationView/Cells/OWSMessageCell.m
  34. 3
      Session/Signal/ConversationView/Cells/OWSMessageFooterView.m
  35. 2
      Session/Signal/ConversationView/Cells/OWSMessageTimerView.m
  36. 5
      Session/Signal/ConversationView/Cells/OWSQuotedMessageView.m
  37. 67
      Session/Signal/ConversationView/Cells/OWSSystemMessageCell.m
  38. 49
      Session/Signal/ConversationView/Cells/TypingIndicatorCell.swift
  39. 131
      Session/Signal/ConversationView/ConversationHeaderView.swift
  40. 3
      Session/Signal/ConversationView/ConversationInputToolbar.m
  41. 1041
      Session/Signal/ConversationView/ConversationViewController.m
  42. 3
      Session/Signal/ConversationView/ConversationViewItem.h
  43. 103
      Session/Signal/ConversationView/ConversationViewItem.m
  44. 2
      Session/Signal/ConversationView/ConversationViewModel.h
  45. 56
      Session/Signal/ConversationView/ConversationViewModel.m
  46. 13
      Session/Signal/DomainFrontingCountryViewController.h
  47. 98
      Session/Signal/DomainFrontingCountryViewController.m
  48. 15
      Session/Signal/FingerprintViewController.h
  49. 558
      Session/Signal/FingerprintViewController.m
  50. 27
      Session/Signal/FingerprintViewScanController.h
  51. 258
      Session/Signal/FingerprintViewScanController.m
  52. 4
      Session/Signal/GifPickerViewController.swift
  53. 18
      Session/Signal/GroupTableViewCell.swift
  54. 271
      Session/Signal/InviteFlow.swift
  55. 2
      Session/Signal/LegacyNotificationsAdaptee.swift
  56. 5
      Session/Signal/MediaPageViewController.swift
  57. 13
      Session/Signal/MessageActions.swift
  58. 31
      Session/Signal/MessageDetailViewController.swift
  59. 175
      Session/Signal/MessageFetcherJob.swift
  60. 4
      Session/Signal/MessageRecipientStatusUtils.swift
  61. 15
      Session/Signal/OWSAddToContactViewController.h
  62. 212
      Session/Signal/OWSAddToContactViewController.m
  63. 22
      Session/Signal/OWSAnalytics.swift
  64. 20
      Session/Signal/OWSBackupExportJob.m
  65. 2
      Session/Signal/OWSBackupSettingsViewController.m
  66. 333
      Session/Signal/OWSConversationSettingsViewController.m
  67. 20
      Session/Signal/OWSDeviceTableViewCell.h
  68. 85
      Session/Signal/OWSDeviceTableViewCell.m
  69. 2
      Session/Signal/OWSOrphanDataCleaner.m
  70. 18
      Session/Signal/Pastelog.h
  71. 647
      Session/Signal/Pastelog.m
  72. 32
      Session/Signal/PinEntryView.h
  73. 227
      Session/Signal/PinEntryView.m
  74. 220
      Session/Signal/PrivacySettingsTableViewController.m
  75. 83
      Session/Signal/PushRegistrationManager.swift
  76. 117
      Session/Signal/SafetyNumberConfirmationAlert.swift
  77. 19
      Session/Signal/SessionResetJob.swift
  78. 13
      Session/Signal/ShowGroupMembersViewController.h
  79. 478
      Session/Signal/ShowGroupMembersViewController.m
  80. 4
      Session/Signal/SignalApp.m
  81. 9
      Session/Signal/SignalsNavigationController.h
  82. 123
      Session/Signal/SignalsNavigationController.m
  83. 29
      Session/Signal/UpdateGroupViewController.h
  84. 558
      Session/Signal/UpdateGroupViewController.m
  85. 2
      Session/Signal/UserNotificationsAdaptee.swift
  86. 53
      Session/Signal/WebRTCCallMessageHandler.swift
  87. 3
      Session/Utilities/BackgroundPoller.swift
  88. 10
      Session/View Controllers/BaseVC.swift
  89. 256
      Session/View Controllers/DeviceLinkingModal.swift
  90. 12
      Session/View Controllers/DeviceLinkingModalDelegate.swift
  91. 234
      Session/View Controllers/DeviceLinksVC.swift
  92. 103
      Session/View Controllers/DeviceNameModal.swift
  93. 5
      Session/View Controllers/DeviceNameModalDelegate.swift
  94. 18
      Session/View Controllers/HomeVC.swift
  95. 4
      Session/View Controllers/JoinPublicChatVC.swift
  96. 73
      Session/View Controllers/LandingVC.swift
  97. 74
      Session/View Controllers/NewClosedGroupVC.swift
  98. 14
      Session/View Controllers/NewPrivateChatVC.swift
  99. 12
      Session/View Controllers/QRCodeVC.swift
  100. 47
      Session/View Controllers/SettingsVC.swift
  101. Some files were not shown because too many files have changed in this diff Show More

23
Session/Components/ConversationTitleView.swift

@ -50,11 +50,11 @@ final class ConversationTitleView : UIView {
updateSubtitleForCurrentStatus()
let notificationCenter = NotificationCenter.default
notificationCenter.addObserver(self, selector: #selector(handleProfileChangedNotification(_:)), name: NSNotification.Name(rawValue: kNSNotificationName_OtherUsersProfileDidChange), object: nil)
notificationCenter.addObserver(self, selector: #selector(handleCalculatingPoWNotification(_:)), name: .calculatingPoW, object: nil)
notificationCenter.addObserver(self, selector: #selector(handleRoutingNotification(_:)), name: .routing, object: nil)
notificationCenter.addObserver(self, selector: #selector(handleCalculatingMessagePoWNotification(_:)), name: .calculatingMessagePoW, object: nil)
notificationCenter.addObserver(self, selector: #selector(handleEncryptingMessageNotification(_:)), name: .encryptingMessage, object: nil)
notificationCenter.addObserver(self, selector: #selector(handleMessageSendingNotification(_:)), name: .messageSending, object: nil)
notificationCenter.addObserver(self, selector: #selector(handleMessageSentNotification(_:)), name: .messageSent, object: nil)
notificationCenter.addObserver(self, selector: #selector(handleMessageFailedNotification(_:)), name: .messageFailed, object: nil)
notificationCenter.addObserver(self, selector: #selector(handleMessageSendingFailedNotification(_:)), name: .messageSendingFailed, object: nil)
}
override init(frame: CGRect) {
@ -112,12 +112,12 @@ final class ConversationTitleView : UIView {
updateProfilePicture()
}
@objc private func handleCalculatingPoWNotification(_ notification: Notification) {
@objc private func handleCalculatingMessagePoWNotification(_ notification: Notification) {
guard let timestamp = notification.object as? NSNumber else { return }
setStatusIfNeeded(to: .calculatingPoW, forMessageWithTimestamp: timestamp)
}
@objc private func handleRoutingNotification(_ notification: Notification) {
@objc private func handleEncryptingMessageNotification(_ notification: Notification) {
guard let timestamp = notification.object as? NSNumber else { return }
setStatusIfNeeded(to: .routing, forMessageWithTimestamp: timestamp)
}
@ -136,7 +136,7 @@ final class ConversationTitleView : UIView {
}
}
@objc private func handleMessageFailedNotification(_ notification: Notification) {
@objc private func handleMessageSendingFailedNotification(_ notification: Notification) {
guard let timestamp = notification.object as? NSNumber else { return }
clearStatusIfNeededForMessageWithTimestamp(timestamp)
}
@ -149,14 +149,7 @@ final class ConversationTitleView : UIView {
uncheckedTargetInteraction = interaction
}
guard let targetInteraction = uncheckedTargetInteraction, targetInteraction.interactionType() == .outgoingMessage,
status.rawValue > (currentStatus?.rawValue ?? 0), let hexEncodedPublicKey = targetInteraction.thread.contactIdentifier() else { return }
var masterHexEncodedPublicKey: String!
let storage = OWSPrimaryStorage.shared()
storage.dbReadConnection.read { transaction in
masterHexEncodedPublicKey = storage.getMasterHexEncodedPublicKey(for: hexEncodedPublicKey, in: transaction) ?? hexEncodedPublicKey
}
let isSlaveDevice = masterHexEncodedPublicKey != hexEncodedPublicKey
guard !isSlaveDevice else { return }
status.rawValue > (currentStatus?.rawValue ?? 0) else { return }
currentStatus = status
}
@ -184,7 +177,7 @@ final class ConversationTitleView : UIView {
dateFormatter.timeStyle = .medium
dateFormatter.dateStyle = .medium
subtitle.append(NSAttributedString(string: "Muted until " + dateFormatter.string(from: muteEndDate)))
} else if let thread = self.thread as? TSGroupThread, !thread.isRSSFeed {
} else if let thread = self.thread as? TSGroupThread {
let storage = OWSPrimaryStorage.shared()
var userCount: Int?
if thread.groupModel.groupType == .closedGroup {

31
Session/Meta/Signal-Bridging-Header.h

@ -16,10 +16,10 @@
#import "ConversationViewCell.h"
#import "ConversationViewItem.h"
#import "DateUtil.h"
#import "FingerprintViewController.h"
#import "MediaDetailViewController.h"
#import "NotificationSettingsViewController.h"
#import "OWSAddToContactViewController.h"
#import "OWSAnyTouchGestureRecognizer.h"
#import "OWSAudioPlayer.h"
#import "OWSBackup.h"
@ -35,13 +35,12 @@
#import "OWSQuotedMessageView.h"
#import "OWSSessionResetJobRecord.h"
#import "OWSWindowManager.h"
#import "PinEntryView.h"
#import "PrivacySettingsTableViewController.h"
#import "RemoteVideoView.h"
#import "OWSQRCodeScanningViewController.h"
#import "SignalApp.h"
#import "UIViewController+Permissions.h"
#import "ViewControllerUtils.h"
#import <SessionProtocolKit/NSData+keyVersionByte.h>
#import <PureLayout/PureLayout.h>
#import <Reachability/Reachability.h>
@ -55,52 +54,36 @@
#import <SignalUtilitiesKit/ContactTableViewCell.h>
#import <SignalUtilitiesKit/Environment.h>
#import <SignalUtilitiesKit/OWSAudioPlayer.h>
#import <SignalUtilitiesKit/OWSContactAvatarBuilder.h>
#import <SignalUtilitiesKit/OWSContactsManager.h>
#import <SignalUtilitiesKit/OWSFormat.h>
#import <SignalUtilitiesKit/OWSPreferences.h>
#import <SignalUtilitiesKit/OWSProfileManager.h>
#import <SignalUtilitiesKit/OWSQuotedReplyModel.h>
#import <SignalUtilitiesKit/OWSSounds.h>
#import <SignalUtilitiesKit/OWSViewController.h>
#import <SignalUtilitiesKit/ThreadUtil.h>
#import <SignalUtilitiesKit/UIColor+OWS.h>
#import <SignalUtilitiesKit/UIFont+OWS.h>
#import <SignalUtilitiesKit/UIUtil.h>
#import <SignalUtilitiesKit/UIView+OWS.h>
#import <SignalUtilitiesKit/UIViewController+OWS.h>
#import <SignalUtilitiesKit/AppVersion.h>
#import <SignalUtilitiesKit/Contact.h>
#import <SignalUtilitiesKit/ContactsUpdater.h>
#import <SignalUtilitiesKit/DataSource.h>
#import <SignalUtilitiesKit/MIMETypeUtil.h>
#import <SignalUtilitiesKit/NSData+Image.h>
#import <SignalUtilitiesKit/NSNotificationCenter+OWS.h>
#import <SignalUtilitiesKit/NSString+SSK.h>
#import <SignalUtilitiesKit/NSTimer+OWS.h>
#import <SignalUtilitiesKit/OWSAnalytics.h>
#import <SignalUtilitiesKit/OWSAnalyticsEvents.h>
#import <SignalUtilitiesKit/OWSBackgroundTask.h>
#import <SignalUtilitiesKit/OWSCallMessageHandler.h>
#import <SignalUtilitiesKit/OWSContactsOutputStream.h>
#import <SignalUtilitiesKit/OWSDispatch.h>
#import <SignalUtilitiesKit/OWSEndSessionMessage.h>
#import <SignalUtilitiesKit/LKDeviceLinkMessage.h>
#import <SignalUtilitiesKit/OWSError.h>
#import <SignalUtilitiesKit/OWSFileSystem.h>
#import <SignalUtilitiesKit/OWSIdentityManager.h>
#import <SignalUtilitiesKit/OWSMediaGalleryFinder.h>
#import <SignalUtilitiesKit/OWSMessageManager.h>
#import <SignalUtilitiesKit/OWSMessageReceiver.h>
#import <SignalUtilitiesKit/OWSMessageSender.h>
#import <SignalUtilitiesKit/OWSOutgoingCallMessage.h>
#import <SignalUtilitiesKit/OWSPrimaryStorage+Calling.h>
#import <SignalUtilitiesKit/OWSPrimaryStorage+SessionStore.h>
#import <SignalUtilitiesKit/OWSProfileKeyMessage.h>
#import <SignalUtilitiesKit/OWSRecipientIdentity.h>
#import <SignalUtilitiesKit/OWSRequestFactory.h>
#import <SignalUtilitiesKit/OWSSignalService.h>
#import <SignalUtilitiesKit/PhoneNumber.h>
#import <SignalUtilitiesKit/SignalAccount.h>
#import <SignalUtilitiesKit/SignalRecipient.h>
#import <SignalUtilitiesKit/TSAccountManager.h>
@ -113,10 +96,10 @@
#import <SignalUtilitiesKit/TSGroupThread.h>
#import <SignalUtilitiesKit/TSIncomingMessage.h>
#import <SignalUtilitiesKit/TSInfoMessage.h>
#import <SignalUtilitiesKit/TSNetworkManager.h>
#import <SignalUtilitiesKit/TSOutgoingMessage.h>
#import <SignalUtilitiesKit/TSPreKeyManager.h>
#import <SignalUtilitiesKit/TSSocketManager.h>
#import <SignalUtilitiesKit/TSThread.h>
#import <SignalUtilitiesKit/LKGroupUtilities.h>
#import <SignalUtilitiesKit/UIImage+OWS.h>

1
Session/Meta/Signal-Prefix.pch

@ -18,7 +18,6 @@
#import <SignalCoreKit/NSObject+OWS.h>
#import <SignalCoreKit/OWSAsserts.h>
#import <SignalUtilitiesKit/SSKAsserts.h>
#import <SignalUtilitiesKit/OWSAnalytics.h>
#import <SignalUtilitiesKit/NSArray+Functional.h>
#import <SignalUtilitiesKit/NSSet+Functional.h>
#import <SignalUtilitiesKit/NSObject+Casting.h>

28
Session/Signal/AccountManager.swift

@ -19,10 +19,6 @@ public class AccountManager: NSObject {
return OWSProfileManager.shared()
}
private var networkManager: TSNetworkManager {
return SSKEnvironment.shared.networkManager
}
private var preferences: OWSPreferences {
return Environment.shared.preferences
}
@ -119,28 +115,4 @@ public class AccountManager: NSObject {
let anyPromise = tsAccountManager.setIsManualMessageFetchEnabled(true)
return Promise(anyPromise).asVoid()
}
// MARK: Turn Server
func getTurnServerInfo() -> Promise<TurnServerInfo> {
return Promise { resolver in
self.networkManager.makeRequest(OWSRequestFactory.turnServerInfoRequest(),
success: { (_: URLSessionDataTask, responseObject: Any?) in
guard responseObject != nil else {
return resolver.reject(OWSErrorMakeUnableToProcessServerResponseError())
}
if let responseDictionary = responseObject as? [String: AnyObject] {
if let turnServerInfo = TurnServerInfo(attributes: responseDictionary) {
return resolver.fulfill(turnServerInfo)
}
Logger.error("unexpected server response:\(responseDictionary)")
}
return resolver.reject(OWSErrorMakeUnableToProcessServerResponseError())
},
failure: { (_: URLSessionDataTask, error: Error) in
return resolver.reject(error)
})
}
}
}

145
Session/Signal/AddContactShareToExistingContactViewController.swift

@ -1,145 +0,0 @@
//
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
import Foundation
import UIKit
import ContactsUI
class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPickerDelegate, CNContactViewControllerDelegate {
// TODO - there are some hard coded assumptions in this VC that assume we are *pushed* onto a
// navigation controller. That seems fine for now, but if we need to be presented as a modal,
// or need to notify our presenter about our dismisall or other contact actions, a delegate
// would be helpful. It seems like this would require some broad changes to the ContactShareViewHelper,
// so I've left it as is for now, since it happens to work.
// weak var addToExistingContactDelegate: AddContactShareToExistingContactViewControllerDelegate?
let contactShare: ContactShareViewModel
required init(contactShare: ContactShareViewModel) {
self.contactShare = contactShare
super.init(allowsMultipleSelection: false, subtitleCellType: .none)
self.contactsPickerDelegate = self
}
required public init?(coder aDecoder: NSCoder) {
notImplemented()
}
@objc required public init(allowsMultipleSelection: Bool, subtitleCellType: SubtitleCellValue) {
notImplemented()
}
// MARK: - ContactsPickerDelegate
func contactsPicker(_: ContactsPicker, contactFetchDidFail error: NSError) {
owsFailDebug("with error: \(error)")
guard let navigationController = self.navigationController else {
owsFailDebug("navigationController was unexpectedly nil")
return
}
navigationController.popViewController(animated: true)
}
func contactsPickerDidCancel(_: ContactsPicker) {
Logger.debug("")
guard let navigationController = self.navigationController else {
owsFailDebug("navigationController was unexpectedly nil")
return
}
navigationController.popViewController(animated: true)
}
func contactsPicker(_: ContactsPicker, didSelectContact oldContact: Contact) {
Logger.debug("")
let contactsManager = Environment.shared.contactsManager
guard let oldCNContact = contactsManager?.cnContact(withId: oldContact.cnContactId) else {
owsFailDebug("could not load old CNContact.")
return
}
guard let newCNContact = OWSContacts.systemContact(for: self.contactShare.dbRecord, imageData: self.contactShare.avatarImageData) else {
owsFailDebug("could not load new CNContact.")
return
}
merge(oldCNContact: oldCNContact, newCNContact: newCNContact)
}
func merge(oldCNContact: CNContact, newCNContact: CNContact) {
Logger.debug("")
let mergedCNContact: CNContact = Contact.merge(cnContact: oldCNContact, newCNContact: newCNContact)
// Not actually a "new" contact, but this brings up the edit form rather than the "Read" form
// saving our users a tap in some cases when we already know they want to edit.
let contactViewController: CNContactViewController = CNContactViewController(forNewContact: mergedCNContact)
// Default title is "New Contact". We could give a more descriptive title, but anything
// seems redundant - the context is sufficiently clear.
contactViewController.title = ""
contactViewController.allowsActions = false
contactViewController.allowsEditing = true
contactViewController.delegate = self
let modal = OWSNavigationController(rootViewController: contactViewController)
self.present(modal, animated: true)
}
func contactsPicker(_: ContactsPicker, didSelectMultipleContacts contacts: [Contact]) {
Logger.debug("")
owsFailDebug("only supports single contact select")
guard let navigationController = self.navigationController else {
owsFailDebug("navigationController was unexpectedly nil")
return
}
navigationController.popViewController(animated: true)
}
func contactsPicker(_: ContactsPicker, shouldSelectContact contact: Contact) -> Bool {
return true
}
// MARK: - CNContactViewControllerDelegate
public func contactViewController(_ viewController: CNContactViewController, didCompleteWith contact: CNContact?) {
Logger.debug("")
guard let navigationController = self.navigationController else {
owsFailDebug("navigationController was unexpectedly nil")
return
}
// TODO this is weird - ideally we'd do something like
// self.delegate?.didFinishAddingContact
// and the delegate, which knows about our presentation context could do the right thing.
//
// As it is, we happen to always be *pushing* this view controller onto a navcontroller, so the
// following works in all current cases.
//
// If we ever wanted to do something different, like present this in a modal, we'd have to rethink.
// We want to pop *this* view *and* the still presented CNContactViewController in a single animation.
// Note this happens for *cancel* and for *done*. Unfortunately, I don't know of a way to detect the difference
// between the two, since both just call this method.
guard let myIndex = navigationController.viewControllers.firstIndex(of: self) else {
owsFailDebug("myIndex was unexpectedly nil")
navigationController.popViewController(animated: true)
navigationController.popViewController(animated: true)
return
}
let previousViewControllerIndex = navigationController.viewControllers.index(before: myIndex)
let previousViewController = navigationController.viewControllers[previousViewControllerIndex]
self.dismiss(animated: false) {
navigationController.popToViewController(previousViewController, animated: true)
}
}
}

15
Session/Signal/AddToBlockListViewController.m

@ -4,8 +4,8 @@
#import "AddToBlockListViewController.h"
#import "BlockListUIUtils.h"
#import "ContactsViewHelper.h"
#import <SignalUtilitiesKit/OWSContactsManager.h>
#import <SignalUtilitiesKit/SSKEnvironment.h>
#import <SignalUtilitiesKit/OWSBlockingManager.h>
#import <SignalUtilitiesKit/SignalAccount.h>
NS_ASSUME_NONNULL_BEGIN
@ -51,8 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
__weak AddToBlockListViewController *weakSelf = self;
[BlockListUIUtils showBlockPhoneNumberActionSheet:phoneNumber
fromViewController:self
blockingManager:self.contactsViewHelper.blockingManager
contactsManager:self.contactsViewHelper.contactsManager
blockingManager:SSKEnvironment.shared.blockingManager
completionBlock:^(BOOL isBlocked) {
if (isBlocked) {
[weakSelf.navigationController popViewControllerAnimated:YES];
@ -65,7 +64,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssertDebug(signalAccount);
ContactsViewHelper *helper = self.contactsViewHelper;
return ![helper isRecipientIdBlocked:signalAccount.recipientId];
return ![SSKEnvironment.shared.blockingManager isRecipientIdBlocked:signalAccount.recipientId];
}
- (void)signalAccountWasSelected:(SignalAccount *)signalAccount
@ -73,15 +72,13 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssertDebug(signalAccount);
__weak AddToBlockListViewController *weakSelf = self;
ContactsViewHelper *helper = self.contactsViewHelper;
if ([helper isRecipientIdBlocked:signalAccount.recipientId]) {
if ([SSKEnvironment.shared.blockingManager isRecipientIdBlocked:signalAccount.recipientId]) {
OWSFailDebug(@"Cannot add already blocked user to block list.");
return;
}
[BlockListUIUtils showBlockSignalAccountActionSheet:signalAccount
fromViewController:self
blockingManager:helper.blockingManager
contactsManager:helper.contactsManager
blockingManager:SSKEnvironment.shared.blockingManager
completionBlock:^(BOOL isBlocked) {
if (isBlocked) {
[weakSelf.navigationController popViewControllerAnimated:YES];

48
Session/Signal/AddToGroupViewController.m

@ -4,9 +4,9 @@
#import "AddToGroupViewController.h"
#import "BlockListUIUtils.h"
#import "ContactsViewHelper.h"
#import "Session-Swift.h"
#import <SignalUtilitiesKit/OWSContactsManager.h>
#import <SignalUtilitiesKit/SignalAccount.h>
NS_ASSUME_NONNULL_BEGIN
@ -52,12 +52,10 @@ NS_ASSUME_NONNULL_BEGIN
__weak AddToGroupViewController *weakSelf = self;
ContactsViewHelper *helper = self.contactsViewHelper;
if ([helper isRecipientIdBlocked:phoneNumber]) {
if ([SSKEnvironment.shared.blockingManager isRecipientIdBlocked:phoneNumber]) {
[BlockListUIUtils showUnblockPhoneNumberActionSheet:phoneNumber
fromViewController:self
blockingManager:helper.blockingManager
contactsManager:helper.contactsManager
blockingManager:SSKEnvironment.shared.blockingManager
completionBlock:^(BOOL isBlocked) {
if (!isBlocked) {
[weakSelf addToGroup:phoneNumber];
@ -66,22 +64,6 @@ NS_ASSUME_NONNULL_BEGIN
return;
}
BOOL didShowSNAlert = [SafetyNumberConfirmationAlert
presentAlertIfNecessaryWithRecipientId:phoneNumber
confirmationText:
NSLocalizedString(@"SAFETY_NUMBER_CHANGED_CONFIRM_ADD_TO_GROUP_ACTION",
@"button title to confirm adding a recipient to a group when their safety "
@"number has recently changed")
contactsManager:helper.contactsManager
completion:^(BOOL didConfirmIdentity) {
if (didConfirmIdentity) {
[weakSelf addToGroup:phoneNumber];
}
}];
if (didShowSNAlert) {
return;
}
[self addToGroup:phoneNumber];
}
@ -97,17 +79,15 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssertDebug(signalAccount);
__weak AddToGroupViewController *weakSelf = self;
ContactsViewHelper *helper = self.contactsViewHelper;
if ([self.addToGroupDelegate isRecipientGroupMember:signalAccount.recipientId]) {
OWSFailDebug(@"Cannot add user to group member if already a member.");
return;
}
if ([helper isRecipientIdBlocked:signalAccount.recipientId]) {
if ([SSKEnvironment.shared.blockingManager isRecipientIdBlocked:signalAccount.recipientId]) {
[BlockListUIUtils showUnblockSignalAccountActionSheet:signalAccount
fromViewController:self
blockingManager:helper.blockingManager
contactsManager:helper.contactsManager
blockingManager:SSKEnvironment.shared.blockingManager
completionBlock:^(BOOL isBlocked) {
if (!isBlocked) {
[weakSelf addToGroup:signalAccount.recipientId];
@ -116,22 +96,6 @@ NS_ASSUME_NONNULL_BEGIN
return;
}
BOOL didShowSNAlert = [SafetyNumberConfirmationAlert
presentAlertIfNecessaryWithRecipientId:signalAccount.recipientId
confirmationText:
NSLocalizedString(@"SAFETY_NUMBER_CHANGED_CONFIRM_ADD_TO_GROUP_ACTION",
@"button title to confirm adding a recipient to a group when their safety "
@"number has recently changed")
contactsManager:helper.contactsManager
completion:^(BOOL didConfirmIdentity) {
if (didConfirmIdentity) {
[weakSelf addToGroup:signalAccount.recipientId];
}
}];
if (didShowSNAlert) {
return;
}
[self addToGroup:signalAccount.recipientId];
}

9
Session/Signal/AdvancedSettingsTableViewController.h

@ -1,9 +0,0 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSTableViewController.h"
@interface AdvancedSettingsTableViewController : OWSTableViewController
@end

312
Session/Signal/AdvancedSettingsTableViewController.m

@ -1,312 +0,0 @@
//
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "AdvancedSettingsTableViewController.h"
#import "DebugLogger.h"
#import "DomainFrontingCountryViewController.h"
#import "OWSCountryMetadata.h"
#import "Pastelog.h"
#import "Session-Swift.h"
#import "TSAccountManager.h"
#import <PromiseKit/AnyPromise.h>
#import <Reachability/Reachability.h>
#import <SignalUtilitiesKit/Environment.h>
#import <SignalUtilitiesKit/OWSPreferences.h>
#import <SignalUtilitiesKit/OWSSignalService.h>
NS_ASSUME_NONNULL_BEGIN
@interface AdvancedSettingsTableViewController ()
@property (nonatomic) Reachability *reachability;
@end
#pragma mark -
@implementation AdvancedSettingsTableViewController
- (void)loadView
{
[super loadView];
self.title = NSLocalizedString(@"SETTINGS_ADVANCED_TITLE", @"");
self.reachability = [Reachability reachabilityForInternetConnection];
[self observeNotifications];
[self updateTableContents];
}
- (void)observeNotifications
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(socketStateDidChange)
name:kNSNotification_OWSWebSocketStateDidChange
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reachabilityChanged)
name:kReachabilityChangedNotification
object:nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)socketStateDidChange
{
OWSAssertIsOnMainThread();
[self updateTableContents];
}
- (void)reachabilityChanged
{
OWSAssertIsOnMainThread();
[self updateTableContents];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self updateTableContents];
}
#pragma mark - Table Contents
- (void)updateTableContents
{
OWSTableContents *contents = [OWSTableContents new];
__weak AdvancedSettingsTableViewController *weakSelf = self;
OWSTableSection *loggingSection = [OWSTableSection new];
loggingSection.headerTitle = NSLocalizedString(@"LOGGING_SECTION", nil);
[loggingSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_DEBUGLOG", @"")
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"enable_debug_log")
isOnBlock:^{
return [OWSPreferences isLoggingEnabled];
}
isEnabledBlock:^{
return YES;
}
target:weakSelf
selector:@selector(didToggleEnableLogSwitch:)]];
if ([OWSPreferences isLoggingEnabled]) {
[loggingSection
addItem:[OWSTableItem actionItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_SUBMIT_DEBUGLOG", @"")
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"submit_debug_log")
actionBlock:^{
OWSLogInfo(@"Submitting debug logs");
[DDLog flushLog];
[Pastelog submitLogs];
}]];
}
[contents addSection:loggingSection];
OWSTableSection *pushNotificationsSection = [OWSTableSection new];
pushNotificationsSection.headerTitle
= NSLocalizedString(@"PUSH_REGISTER_TITLE", @"Used in table section header and alert view title contexts");
[pushNotificationsSection addItem:[OWSTableItem actionItemWithText:NSLocalizedString(@"REREGISTER_FOR_PUSH", nil)
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(
self, @"reregister_push_notifications")
actionBlock:^{
[weakSelf syncPushTokens];
}]];
[contents addSection:pushNotificationsSection];
// Censorship circumvention has certain disadvantages so it should only be
// used if necessary. Therefore:
//
// * We disable this setting if the user has a phone number from a censored region -
// censorship circumvention will be auto-activated for this user.
// * We disable this setting if the user is already connected; they're not being
// censored.
// * We continue to show this setting so long as it is set to allow users to disable
// it, for example when they leave a censored region.
OWSTableSection *censorshipSection = [OWSTableSection new];
censorshipSection.headerTitle = NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_HEADER",
@"Table header for the 'censorship circumvention' section.");
BOOL isAnySocketOpen = TSSocketManager.shared.highestSocketState == OWSWebSocketStateOpen;
if (OWSSignalService.sharedInstance.hasCensoredPhoneNumber) {
if (OWSSignalService.sharedInstance.isCensorshipCircumventionManuallyDisabled) {
censorshipSection.footerTitle
= NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER_MANUALLY_DISABLED",
@"Table footer for the 'censorship circumvention' section shown when censorship circumvention has "
@"been manually disabled.");
} else {
censorshipSection.footerTitle = NSLocalizedString(
@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER_AUTO_ENABLED",
@"Table footer for the 'censorship circumvention' section shown when censorship circumvention has been "
@"auto-enabled based on local phone number.");
}
} else if (isAnySocketOpen) {
censorshipSection.footerTitle
= NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER_WEBSOCKET_CONNECTED",
@"Table footer for the 'censorship circumvention' section shown when the app is connected to the "
@"Signal service.");
} else if (!self.reachability.isReachable) {
censorshipSection.footerTitle
= NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER_NO_CONNECTION",
@"Table footer for the 'censorship circumvention' section shown when the app is not connected to the "
@"internet.");
} else {
censorshipSection.footerTitle = NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER",
@"Table footer for the 'censorship circumvention' section when censorship circumvention can be manually "
@"enabled.");
}
// Do enable if :
//
// * ...Censorship circumvention is already manually enabled (to allow users to disable it).
//
// Otherwise, don't enable if:
//
// * ...Censorship circumvention is already enabled based on the local phone number.
// * ...The websocket is connected, since that demonstrates that no censorship is in effect.
// * ...The internet is not reachable, since we don't want to let users to activate
// censorship circumvention unnecessarily, e.g. if they just don't have a valid
// internet connection.
OWSTableSwitchBlock isCensorshipCircumventionOnBlock = ^{
return OWSSignalService.sharedInstance.isCensorshipCircumventionActive;
};
Reachability *reachability = self.reachability;
OWSTableSwitchBlock isManualCensorshipCircumventionOnEnabledBlock = ^{
OWSSignalService *service = OWSSignalService.sharedInstance;
if (service.isCensorshipCircumventionActive) {
return YES;
} else if (service.hasCensoredPhoneNumber && service.isCensorshipCircumventionManuallyDisabled) {
return YES;
} else if (TSSocketManager.shared.highestSocketState == OWSWebSocketStateOpen) {
return NO;
} else {
return reachability.isReachable;
}
};
[censorshipSection
addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION",
@"Label for the 'manual censorship circumvention' switch.")
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"censorship_circumvention")
isOnBlock:isCensorshipCircumventionOnBlock
isEnabledBlock:isManualCensorshipCircumventionOnEnabledBlock
target:weakSelf
selector:@selector(didToggleEnableCensorshipCircumventionSwitch:)]];
if (OWSSignalService.sharedInstance.isCensorshipCircumventionManuallyActivated) {
OWSCountryMetadata *manualCensorshipCircumventionCountry =
[weakSelf ensureManualCensorshipCircumventionCountry];
OWSAssertDebug(manualCensorshipCircumventionCountry);
NSString *text = [NSString
stringWithFormat:NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_COUNTRY_FORMAT",
@"Label for the 'manual censorship circumvention' country. Embeds {{the manual "
@"censorship circumvention country}}."),
manualCensorshipCircumventionCountry.localizedCountryName];
[censorshipSection addItem:[OWSTableItem disclosureItemWithText:text
actionBlock:^{
[weakSelf showDomainFrontingCountryView];
}]];
}
[contents addSection:censorshipSection];
self.contents = contents;
}
- (void)showDomainFrontingCountryView
{
DomainFrontingCountryViewController *vc = [DomainFrontingCountryViewController new];
[self.navigationController pushViewController:vc animated:YES];
}
- (OWSCountryMetadata *)ensureManualCensorshipCircumventionCountry
{
OWSAssertIsOnMainThread();
OWSCountryMetadata *countryMetadata = nil;
NSString *countryCode = OWSSignalService.sharedInstance.manualCensorshipCircumventionCountryCode;
if (countryCode) {
countryMetadata = [OWSCountryMetadata countryMetadataForCountryCode:countryCode];
}
if (!countryMetadata) {
countryCode = [PhoneNumber defaultCountryCode];
if (countryCode) {
countryMetadata = [OWSCountryMetadata countryMetadataForCountryCode:countryCode];
}
}
if (!countryMetadata) {
countryCode = @"US";
countryMetadata = [OWSCountryMetadata countryMetadataForCountryCode:countryCode];
OWSAssertDebug(countryMetadata);
}
if (countryMetadata) {
// Ensure the "manual censorship circumvention" country state is in sync.
OWSSignalService.sharedInstance.manualCensorshipCircumventionCountryCode = countryCode;
}
return countryMetadata;
}
#pragma mark - Actions
- (void)syncPushTokens
{
OWSSyncPushTokensJob *job =
[[OWSSyncPushTokensJob alloc] initWithAccountManager:AppEnvironment.shared.accountManager
preferences:Environment.shared.preferences];
job.uploadOnlyIfStale = NO;
[job run]
.then(^{
[OWSAlerts showAlertWithTitle:NSLocalizedString(@"PUSH_REGISTER_SUCCESS",
@"Title of alert shown when push tokens sync job succeeds.")];
})
.catch(^(NSError *error) {
[OWSAlerts showAlertWithTitle:NSLocalizedString(@"REGISTRATION_BODY",
@"Title of alert shown when push tokens sync job fails.")];
});
}
- (void)didToggleEnableLogSwitch:(UISwitch *)sender
{
if (!sender.isOn) {
OWSLogInfo(@"disabling logging.");
[[DebugLogger sharedLogger] wipeLogs];
[[DebugLogger sharedLogger] disableFileLogging];
} else {
[[DebugLogger sharedLogger] enableFileLogging];
OWSLogInfo(@"enabling logging.");
}
[OWSPreferences setIsLoggingEnabled:sender.isOn];
[self updateTableContents];
}
- (void)didToggleEnableCensorshipCircumventionSwitch:(UISwitch *)sender
{
OWSSignalService *service = OWSSignalService.sharedInstance;
if (sender.isOn) {
service.isCensorshipCircumventionManuallyDisabled = NO;
service.isCensorshipCircumventionManuallyActivated = YES;
} else {
service.isCensorshipCircumventionManuallyDisabled = YES;
service.isCensorshipCircumventionManuallyActivated = NO;
}
[self updateTableContents];
}
@end
NS_ASSUME_NONNULL_END

93
Session/Signal/AppDelegate.m

@ -8,31 +8,24 @@
#import "OWSBackup.h"
#import "OWSOrphanDataCleaner.h"
#import "OWSScreenLockUI.h"
#import "Pastelog.h"
#import "Session-Swift.h"
#import "SignalApp.h"
#import "SignalsNavigationController.h"
#import "ViewControllerUtils.h"
#import <PromiseKit/AnyPromise.h>
#import <SignalCoreKit/iOSVersions.h>
#import <SignalUtilitiesKit/AppSetup.h>
#import <SignalUtilitiesKit/Environment.h>
#import <SignalUtilitiesKit/OWSContactsManager.h>
#import <SignalUtilitiesKit/OWSNavigationController.h>
#import <SignalUtilitiesKit/OWSPreferences.h>
#import <SignalUtilitiesKit/OWSProfileManager.h>
#import <SignalUtilitiesKit/VersionMigrations.h>
#import <SignalUtilitiesKit/AppReadiness.h>
#import <SignalUtilitiesKit/NSUserDefaults+OWS.h>
#import <SignalUtilitiesKit/OWS2FAManager.h>
#import <SignalUtilitiesKit/OWSBatchMessageProcessor.h>
#import <SignalUtilitiesKit/OWSDisappearingMessagesJob.h>
#import <SignalUtilitiesKit/OWSFailedAttachmentDownloadsJob.h>
#import <SignalUtilitiesKit/OWSFailedMessagesJob.h>
#import <SignalUtilitiesKit/OWSIncompleteCallsJob.h>
#import <SignalUtilitiesKit/OWSMath.h>
#import <SignalUtilitiesKit/OWSMessageManager.h>
#import <SignalUtilitiesKit/OWSMessageSender.h>
#import <SignalUtilitiesKit/OWSPrimaryStorage+Calling.h>
#import <SignalUtilitiesKit/OWSReadReceiptManager.h>
#import <SignalUtilitiesKit/SSKEnvironment.h>
@ -40,7 +33,7 @@
#import <SignalUtilitiesKit/TSAccountManager.h>
#import <SignalUtilitiesKit/TSDatabaseView.h>
#import <SignalUtilitiesKit/TSPreKeyManager.h>
#import <SignalUtilitiesKit/TSSocketManager.h>
#import <YapDatabase/YapDatabaseCryptoUtils.h>
#import <sys/utsname.h>
@ -118,20 +111,6 @@ static NSTimeInterval launchStartedAt;
return SSKEnvironment.shared.disappearingMessagesJob;
}
- (TSSocketManager *)socketManager
{
OWSAssertDebug(SSKEnvironment.shared.socketManager);
return SSKEnvironment.shared.socketManager;
}
- (OWSMessageManager *)messageManager
{
OWSAssertDebug(SSKEnvironment.shared.messageManager);
return SSKEnvironment.shared.messageManager;
}
- (OWSWindowManager *)windowManager
{
return Environment.shared.windowManager;
@ -279,18 +258,12 @@ static NSTimeInterval launchStartedAt;
selector:@selector(registrationStateDidChange)
name:RegistrationStateDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(registrationLockDidChange:)
name:NSNotificationName_2FAStateDidChange
object:nil];
// Loki - Observe data nuke request notifications
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(handleDataNukeRequested:) name:NSNotification.dataNukeRequested object:nil];
OWSLogInfo(@"application: didFinishLaunchingWithOptions completed.");
[OWSAnalytics appLaunchDidBegin];
return YES;
}
@ -394,41 +367,6 @@ static NSTimeInterval launchStartedAt;
}
}
- (void)showLaunchFailureUI:(NSError *)error
{
// Disable normal functioning of app.
self.didAppLaunchFail = YES;
// We perform a subset of the [application:didFinishLaunchingWithOptions:].
[AppVersion sharedInstance];
[self startupLogging];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Show the launch screen
self.window.rootViewController =
[[UIStoryboard storyboardWithName:@"Launch Screen" bundle:nil] instantiateInitialViewController];
[self.window makeKeyAndVisible];
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:NSLocalizedString(@"APP_LAUNCH_FAILURE_ALERT_TITLE",
@"Title for the 'app launch failed' alert.")
message:NSLocalizedString(@"APP_LAUNCH_FAILURE_ALERT_MESSAGE",
@"Message for the 'app launch failed' alert.")
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"SETTINGS_ADVANCED_SUBMIT_DEBUGLOG", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[Pastelog submitLogsWithCompletion:^{
OWSFail(@"Exiting after sharing debug logs.");
}];
}]];
UIViewController *fromViewController = [[UIApplication sharedApplication] frontmostViewController];
[fromViewController presentAlert:alert];
}
- (void)startupLogging
{
OWSLogInfo(@"iOS Version: %@", [UIDevice currentDevice].systemVersion);
@ -498,16 +436,6 @@ static NSTimeInterval launchStartedAt;
[[[OWSFailedMessagesJob alloc] initWithPrimaryStorage:self.primaryStorage] run];
[[[OWSFailedAttachmentDownloadsJob alloc] initWithPrimaryStorage:self.primaryStorage] run];
});
} else {
OWSLogInfo(@"Running post launch block for unregistered user.");
// Unregistered user should have no unread messages. e.g. if you delete your account.
[AppEnvironment.shared.notificationPresenter clearAllNotifications];
UITapGestureRecognizer *gesture =
[[UITapGestureRecognizer alloc] initWithTarget:[Pastelog class] action:@selector(submitLogs)];
gesture.numberOfTapsRequired = 8;
[self.window addGestureRecognizer:gesture];
}
}); // end dispatchOnce for first time we become active
@ -640,8 +568,6 @@ static NSTimeInterval launchStartedAt;
[self ensureRootViewController];
[self.messageManager startObserving];
[self.udManager setup];
[self preheatDatabaseViews];
@ -657,8 +583,6 @@ static NSTimeInterval launchStartedAt;
if (appVersion.lastAppVersion.length > 0
&& ![appVersion.lastAppVersion isEqualToString:appVersion.currentAppVersion]) {
[[self.tsAccountManager updateAccountAttributes] retainUntilComplete];
[SSKEnvironment.shared.syncManager sendConfigurationSyncMessage];
}
}
}
@ -734,18 +658,6 @@ static NSTimeInterval launchStartedAt;
[UIViewController attemptRotationToDeviceOrientation];
}
#pragma mark - Status Bar Interaction
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
CGPoint location = [[[event allTouches] anyObject] locationInView:[self window]];
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
if (CGRectContainsPoint(statusBarFrame, location)) {
[[NSNotificationCenter defaultCenter] postNotificationName:TappedStatusBarNotification object:nil];
}
}
#pragma mark - Notifications
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
@ -953,7 +865,6 @@ static NSTimeInterval launchStartedAt;
[[LKPushNotificationManager unregisterWithToken:deviceToken isForcedUpdate:YES] retainUntilComplete];
}
[ThreadUtil deleteAllContent];
[SSKEnvironment.shared.messageSenderJobQueue clearAllJobs];
[SSKEnvironment.shared.identityManager clearIdentityKey];
[SNSnodeAPI clearSnodePool];
[self stopPoller];

6
Session/Signal/AppEnvironment.swift

@ -34,9 +34,6 @@ import SignalUtilitiesKit
// @objc
// public var outboundCallInitiator: OutboundCallInitiator
@objc
public var messageFetcherJob: MessageFetcherJob
@objc
public var accountManager: AccountManager
@ -81,9 +78,6 @@ import SignalUtilitiesKit
private override init() {
self.callMessageHandler = WebRTCCallMessageHandler()
// self.callService = CallService()
// self.outboundCallInitiator = OutboundCallInitiator()
self.messageFetcherJob = MessageFetcherJob()
self.accountManager = AccountManager()
self.notificationPresenter = NotificationPresenter()
self.pushRegistrationManager = PushRegistrationManager()

237
Session/Signal/AppNotifications.swift

@ -120,14 +120,6 @@ protocol NotificationPresenterAdaptee: class {
func cancelNotifications(threadId: String)
func clearAllNotifications()
var hasReceivedSyncMessageRecently: Bool { get }
}
extension NotificationPresenterAdaptee {
var hasReceivedSyncMessageRecently: Bool {
return OWSDeviceManager.shared().hasReceivedSyncMessage(inLastSeconds: 60)
}
}
@objc(OWSNotificationPresenter)
@ -153,10 +145,6 @@ public class NotificationPresenter: NSObject, NotificationsProtocol {
// MARK: - Dependencies
var contactsManager: OWSContactsManager {
return Environment.shared.contactsManager
}
var identityManager: OWSIdentityManager {
return OWSIdentityManager.shared()
}
@ -209,140 +197,6 @@ public class NotificationPresenter: NSObject, NotificationsProtocol {
return adaptee.registerNotificationSettings()
}
// func presentIncomingCall(_ call: SignalCall, callerName: String) {
//
// let notificationTitle: String?
// switch previewType {
// case .noNameNoPreview:
// notificationTitle = nil
// case .nameNoPreview, .namePreview:
// notificationTitle = callerName
// }
// let notificationBody = NotificationStrings.incomingCallBody
//
// let remotePhoneNumber = call.remotePhoneNumber
// let thread = TSContactThread.getOrCreateThread(contactId: remotePhoneNumber)
//
// guard let threadId = thread.uniqueId else {
// owsFailDebug("threadId was unexpectedly nil")
// return
// }
//
// let userInfo = [
// AppNotificationUserInfoKey.threadId: threadId,
// AppNotificationUserInfoKey.localCallId: call.localId.uuidString
// ]
//
// DispatchQueue.main.async {
// self.adaptee.notify(category: .incomingCall,
// title: notificationTitle,
// body: notificationBody,
// userInfo: userInfo,
// sound: .defaultiOSIncomingRingtone,
// replacingIdentifier: call.localId.uuidString)
// }
// }
//
// func presentMissedCall(_ call: SignalCall, callerName: String) {
// let notificationTitle: String?
// switch previewType {
// case .noNameNoPreview:
// notificationTitle = nil
// case .nameNoPreview, .namePreview:
// notificationTitle = callerName
// }
// let notificationBody = NotificationStrings.missedCallBody
//
// let remotePhoneNumber = call.remotePhoneNumber
// let thread = TSContactThread.getOrCreateThread(contactId: remotePhoneNumber)
//
// guard let threadId = thread.uniqueId else {
// owsFailDebug("threadId was unexpectedly nil")
// return
// }
//
// let userInfo = [
// AppNotificat