mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.1 KiB
Objective-C
84 lines
2.1 KiB
Objective-C
//
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import "Environment.h"
|
|
#import "OWSPreferences.h"
|
|
#import <SignalServiceKit/AppContext.h>
|
|
#import <SignalServiceKit/SSKEnvironment.h>
|
|
|
|
static Environment *sharedEnvironment = nil;
|
|
|
|
@interface Environment ()
|
|
|
|
@property (nonatomic) OWSContactsManager *contactsManager;
|
|
@property (nonatomic) OWSPreferences *preferences;
|
|
@property (nonatomic) OWSContactsSyncing *contactsSyncing;
|
|
@property (nonatomic) OWSSounds *sounds;
|
|
@property (nonatomic) LockInteractionController *lockInteractionController;
|
|
@property (nonatomic) OWSWindowManager *windowManager;
|
|
|
|
@end
|
|
|
|
#pragma mark -
|
|
|
|
@implementation Environment
|
|
|
|
+ (Environment *)shared
|
|
{
|
|
OWSAssertDebug(sharedEnvironment);
|
|
|
|
return sharedEnvironment;
|
|
}
|
|
|
|
+ (void)setShared:(Environment *)environment
|
|
{
|
|
// The main app environment should only be set once.
|
|
//
|
|
// App extensions may be opened multiple times in the same process,
|
|
// so statics will persist.
|
|
OWSAssertDebug(!sharedEnvironment || !CurrentAppContext().isMainApp);
|
|
OWSAssertDebug(environment);
|
|
|
|
sharedEnvironment = environment;
|
|
}
|
|
|
|
+ (void)clearSharedForTests
|
|
{
|
|
sharedEnvironment = nil;
|
|
}
|
|
|
|
- (instancetype)initWithPreferences:(OWSPreferences *)preferences
|
|
contactsSyncing:(OWSContactsSyncing *)contactsSyncing
|
|
sounds:(OWSSounds *)sounds
|
|
lockInteractionController:(LockInteractionController *)lockInteractionController
|
|
windowManager:(OWSWindowManager *)windowManager {
|
|
self = [super init];
|
|
if (!self) {
|
|
return self;
|
|
}
|
|
|
|
OWSAssertDebug(preferences);
|
|
OWSAssertDebug(contactsSyncing);
|
|
OWSAssertDebug(sounds);
|
|
OWSAssertDebug(lockInteractionController);
|
|
OWSAssertDebug(windowManager);
|
|
|
|
_preferences = preferences;
|
|
_contactsSyncing = contactsSyncing;
|
|
_sounds = sounds;
|
|
_lockInteractionController = lockInteractionController;
|
|
_windowManager = windowManager;
|
|
|
|
OWSSingletonAssert();
|
|
|
|
return self;
|
|
}
|
|
|
|
- (OWSContactsManager *)contactsManager
|
|
{
|
|
return (OWSContactsManager *)SSKEnvironment.shared.contactsManager;
|
|
}
|
|
|
|
@end
|