move NotificationsManager behind NotificationsAdapter

pull/1/head
Michael Kirk 6 years ago
parent ac3bbe26ba
commit 11afc967d2

@ -7,7 +7,6 @@
#import "DebugLogger.h" #import "DebugLogger.h"
#import "HomeViewController.h" #import "HomeViewController.h"
#import "MainAppContext.h" #import "MainAppContext.h"
#import "NotificationsManager.h"
#import "OWS2FASettingsViewController.h" #import "OWS2FASettingsViewController.h"
#import "OWSBackup.h" #import "OWSBackup.h"
#import "OWSOrphanDataCleaner.h" #import "OWSOrphanDataCleaner.h"

@ -4,24 +4,21 @@
import Foundation import Foundation
@objc
public protocol NotificationsAdaptee: NotificationsProtocol, OWSCallNotificationsAdaptee { }
extension NotificationsManager: NotificationsAdaptee { }
/** /**
* Present call related notifications to the user. * Present call related notifications to the user.
*/ */
@objc(OWSNotificationsAdapter) @objc(OWSNotificationsAdapter)
public class NotificationsAdapter: NSObject { public class NotificationsAdapter: NSObject, NotificationsProtocol {
private let adaptee: NotificationsAdaptee
var adaptee: OWSCallNotificationsAdaptee {
// TODO: We may eventually want to use UserNotificationsAdaptee instead.
//
// We can't mix UILocalNotification (NotificationManager) with the UNNotifications
// Because registering message categories in one, clobbers the registered categories from the other
// We have to first port *all* the existing UINotification categories to UNNotifications
// which is a good thing to do, but in trying to limit the scope of changes that's been
// left out for now.
return AppEnvironment.shared.notificationsManager
}
@objc public override init() { @objc public override init() {
self.adaptee = NotificationsManager()
super.init() super.init()
SwiftSingletons.register(self) SwiftSingletons.register(self)
@ -45,4 +42,20 @@ public class NotificationsAdapter: NSObject {
adaptee.presentMissedCallBecauseOfNewIdentity(call: call, callerName: callerName) adaptee.presentMissedCallBecauseOfNewIdentity(call: call, callerName: callerName)
} }
// MJK TODO DI contactsManager
public func notifyUser(for incomingMessage: TSIncomingMessage, in thread: TSThread, contactsManager: ContactsManagerProtocol, transaction: YapDatabaseReadTransaction) {
adaptee.notifyUser(for: incomingMessage, in: thread, contactsManager: contactsManager, transaction: transaction)
}
public func notifyUser(for error: TSErrorMessage, thread: TSThread, transaction: YapDatabaseReadWriteTransaction) {
adaptee.notifyUser(for: error, thread: thread, transaction: transaction)
}
public func notifyUser(forThreadlessErrorMessage error: TSErrorMessage, transaction: YapDatabaseReadWriteTransaction) {
adaptee.notifyUser(forThreadlessErrorMessage: error, transaction: transaction)
}
public func clearAllNotifications() {
adaptee.clearAllNotifications()
}
} }

@ -10,11 +10,8 @@ class DebugUINotifications: DebugUIPage {
// MARK: Dependencies // MARK: Dependencies
var notificationsManager: NotificationsManager {
return AppEnvironment.shared.notificationsManager
}
var notificationsAdapter: NotificationsAdapter { var notificationsAdapter: NotificationsAdapter {
return AppEnvironment.shared.NotificationsAdapter return AppEnvironment.shared.notificationsAdapter
} }
var messageSender: MessageSender { var messageSender: MessageSender {
return SSKEnvironment.shared.messageSender return SSKEnvironment.shared.messageSender
@ -60,7 +57,7 @@ class DebugUINotifications: DebugUIPage {
return return
} }
Logger.info("notifying user of incoming message") Logger.info("notifying user of incoming message")
strongSelf.notificationsManager.notifyUser(for: incomingMessage, in: thread, contactsManager: strongSelf.contactsManager, transaction: transaction) strongSelf.notificationsAdapter.notifyUser(for: incomingMessage, in: thread, contactsManager: strongSelf.contactsManager, transaction: transaction)
} }
} }
} }

@ -402,7 +402,7 @@ private class SignalCallData: NSObject {
} }
private var notificationsAdapter: NotificationsAdapter { private var notificationsAdapter: NotificationsAdapter {
return AppEnvironment.shared.NotificationsAdapter return AppEnvironment.shared.notificationsAdapter
} }
// MARK: - Notifications // MARK: - Notifications

@ -37,14 +37,11 @@ import SignalMessaging
@objc @objc
public var messageFetcherJob: MessageFetcherJob public var messageFetcherJob: MessageFetcherJob
@objc
public var notificationsManager: NotificationsManager
@objc @objc
public var accountManager: AccountManager public var accountManager: AccountManager
@objc @objc
public var NotificationsAdapter: NotificationsAdapter public var notificationsAdapter: NotificationsAdapter
@objc @objc
public var pushRegistrationManager: PushRegistrationManager public var pushRegistrationManager: PushRegistrationManager
@ -66,7 +63,6 @@ import SignalMessaging
self.callService = CallService() self.callService = CallService()
self.outboundCallInitiator = OutboundCallInitiator() self.outboundCallInitiator = OutboundCallInitiator()
self.messageFetcherJob = MessageFetcherJob() self.messageFetcherJob = MessageFetcherJob()
self.notificationsManager = NotificationsManager()
self.accountManager = AccountManager() self.accountManager = AccountManager()
self.notificationsAdapter = NotificationsAdapter() self.notificationsAdapter = NotificationsAdapter()
self.pushRegistrationManager = PushRegistrationManager() self.pushRegistrationManager = PushRegistrationManager()
@ -85,7 +81,7 @@ import SignalMessaging
callService.createCallUIAdapter() callService.createCallUIAdapter()
// Hang certain singletons on SSKEnvironment too. // Hang certain singletons on SSKEnvironment too.
SSKEnvironment.shared.notificationsManager = notificationsManager SSKEnvironment.shared.notificationsManager = notificationsAdapter
SSKEnvironment.shared.callMessageHandler = callMessageHandler SSKEnvironment.shared.callMessageHandler = callMessageHandler
} }
} }

@ -1,5 +1,5 @@
// //
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// //
#import "ConversationViewController.h" #import "ConversationViewController.h"
@ -10,7 +10,6 @@ NS_ASSUME_NONNULL_BEGIN
@class CallService; @class CallService;
@class CallUIAdapter; @class CallUIAdapter;
@class HomeViewController; @class HomeViewController;
@class NotificationsManager;
@class OWSMessageFetcherJob; @class OWSMessageFetcherJob;
@class OWSNavigationController; @class OWSNavigationController;
@class OWSWebRTCCallMessageHandler; @class OWSWebRTCCallMessageHandler;

@ -1,10 +1,9 @@
// //
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// //
#import "PushManager.h" #import "PushManager.h"
#import "AppDelegate.h" #import "AppDelegate.h"
#import "NotificationsManager.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import "SignalApp.h" #import "SignalApp.h"
#import "ThreadUtil.h" #import "ThreadUtil.h"

Loading…
Cancel
Save