session-ios/SignalServiceKit/src/Util/AppContext.m

54 lines
1.5 KiB
Mathematica
Raw Normal View History

2017-11-29 17:01:30 +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
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;
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