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
Matlab
84 lines
2.1 KiB
Matlab
5 years ago
|
#import <Foundation/Foundation.h>
|
||
|
#import "SSKAsserts.h"
|
||
|
#import "OWSContactsManager.h"
|
||
|
#import "OWSWindowManager.h"
|
||
|
#import <SignalUtilitiesKit/SignalUtilitiesKit-Swift.h>
|
||
7 years ago
|
#import "OWSPreferences.h"
|
||
5 years ago
|
#import "OWSSounds.h"
|
||
8 years ago
|
|
||
8 years ago
|
static Environment *sharedEnvironment = nil;
|
||
8 years ago
|
|
||
7 years ago
|
@interface Environment ()
|
||
|
|
||
7 years ago
|
@property (nonatomic) OWSAudioSession *audioSession;
|
||
7 years ago
|
@property (nonatomic) OWSContactsManager *contactsManager;
|
||
|
@property (nonatomic) OWSPreferences *preferences;
|
||
7 years ago
|
@property (nonatomic) id<OWSProximityMonitoringManager> proximityMonitoringManager;
|
||
7 years ago
|
@property (nonatomic) OWSSounds *sounds;
|
||
|
@property (nonatomic) OWSWindowManager *windowManager;
|
||
|
|
||
|
@end
|
||
|
|
||
|
#pragma mark -
|
||
|
|
||
8 years ago
|
@implementation Environment
|
||
|
|
||
7 years ago
|
+ (Environment *)shared
|
||
8 years ago
|
{
|
||
7 years ago
|
OWSAssertDebug(sharedEnvironment);
|
||
8 years ago
|
|
||
|
return sharedEnvironment;
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
+ (void)setShared:(Environment *)environment
|
||
8 years ago
|
{
|
||
8 years ago
|
// The main app environment should only be set once.
|
||
|
//
|
||
|
// App extensions may be opened multiple times in the same process,
|
||
|
// so statics will persist.
|
||
7 years ago
|
OWSAssertDebug(!sharedEnvironment || !CurrentAppContext().isMainApp);
|
||
|
OWSAssertDebug(environment);
|
||
8 years ago
|
|
||
|
sharedEnvironment = environment;
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
+ (void)clearSharedForTests
|
||
8 years ago
|
{
|
||
|
sharedEnvironment = nil;
|
||
|
}
|
||
|
|
||
7 years ago
|
- (instancetype)initWithAudioSession:(OWSAudioSession *)audioSession
|
||
|
preferences:(OWSPreferences *)preferences
|
||
7 years ago
|
proximityMonitoringManager:(id<OWSProximityMonitoringManager>)proximityMonitoringManager
|
||
7 years ago
|
sounds:(OWSSounds *)sounds
|
||
|
windowManager:(OWSWindowManager *)windowManager
|
||
|
{
|
||
8 years ago
|
self = [super init];
|
||
|
if (!self) {
|
||
|
return self;
|
||
|
}
|
||
|
|
||
7 years ago
|
OWSAssertDebug(audioSession);
|
||
7 years ago
|
OWSAssertDebug(preferences);
|
||
7 years ago
|
OWSAssertDebug(proximityMonitoringManager);
|
||
7 years ago
|
OWSAssertDebug(sounds);
|
||
|
OWSAssertDebug(windowManager);
|
||
7 years ago
|
|
||
7 years ago
|
_audioSession = audioSession;
|
||
7 years ago
|
_preferences = preferences;
|
||
7 years ago
|
_proximityMonitoringManager = proximityMonitoringManager;
|
||
7 years ago
|
_sounds = sounds;
|
||
|
_windowManager = windowManager;
|
||
8 years ago
|
|
||
|
OWSSingletonAssert();
|
||
|
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
- (OWSContactsManager *)contactsManager
|
||
|
{
|
||
7 years ago
|
return (OWSContactsManager *)SSKEnvironment.shared.contactsManager;
|
||
8 years ago
|
}
|
||
|
|
||
|
@end
|