2017-11-29 17:01:30 +01:00
|
|
|
//
|
2018-01-10 17:14:02 +01:00
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2017-11-29 17:01:30 +01:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "AppContext.h"
|
|
|
|
|
2017-11-30 16:10:30 +01:00
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
2018-01-10 17:14:02 +01:00
|
|
|
NSString *const OWSApplicationDidEnterBackgroundNotification = @"OWSApplicationDidEnterBackgroundNotification";
|
|
|
|
NSString *const OWSApplicationWillEnterForegroundNotification = @"OWSApplicationWillEnterForegroundNotification";
|
|
|
|
NSString *const OWSApplicationWillResignActiveNotification = @"OWSApplicationWillResignActiveNotification";
|
|
|
|
NSString *const OWSApplicationDidBecomeActiveNotification = @"OWSApplicationDidBecomeActiveNotification";
|
|
|
|
|
2018-04-19 17:45:13 +02:00
|
|
|
NSString *NSStringForUIApplicationState(UIApplicationState value)
|
|
|
|
{
|
|
|
|
switch (value) {
|
|
|
|
case UIApplicationStateActive:
|
|
|
|
return @"UIApplicationStateActive";
|
|
|
|
case UIApplicationStateInactive:
|
|
|
|
return @"UIApplicationStateInactive";
|
|
|
|
case UIApplicationStateBackground:
|
|
|
|
return @"UIApplicationStateBackground";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-29 17:01:30 +01:00
|
|
|
static id<AppContext> currentAppContext = nil;
|
|
|
|
|
2017-11-29 21:27:19 +01:00
|
|
|
id<AppContext> CurrentAppContext(void)
|
2017-11-29 17:01:30 +01:00
|
|
|
{
|
|
|
|
OWSCAssert(currentAppContext);
|
|
|
|
|
|
|
|
return currentAppContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetCurrentAppContext(id<AppContext> appContext)
|
|
|
|
{
|
2017-12-06 21:53:19 +01:00
|
|
|
// The main app context should only be set once.
|
|
|
|
//
|
|
|
|
// App extensions may be opened multiple times in the same process,
|
|
|
|
// so statics will persist.
|
|
|
|
OWSCAssert(!currentAppContext || !currentAppContext.isMainApp);
|
2017-11-29 17:01:30 +01:00
|
|
|
|
|
|
|
currentAppContext = appContext;
|
|
|
|
}
|
2017-11-30 16:10:30 +01:00
|
|
|
|
2018-02-15 00:06:20 +01:00
|
|
|
void ExitShareExtension(void)
|
|
|
|
{
|
|
|
|
DDLogInfo(@"ExitShareExtension");
|
|
|
|
[DDLog flushLog];
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2017-11-30 16:10:30 +01:00
|
|
|
NS_ASSUME_NONNULL_END
|