Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1bcaea8851 | |||
| 6e26f0151c | |||
| 4855d7df6f | |||
| 07971c18f3 | |||
| 8c3d8a3dec | |||
| cdba616572 |
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2020, OpenEmu Team
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of the OpenEmu Team nor the
|
||||
// names of its contributors may be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY OpenEmu Team ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL OpenEmu Team BE LIABLE FOR ANY
|
||||
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Configuration settings file format documentation can be found at:
|
||||
// https://help.apple.com/xcode/#/dev745c5c974
|
||||
|
||||
OE_API_VERSION=2
|
||||
@@ -107,6 +107,8 @@
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
0544B67E23D1347600F63D61 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
|
||||
05E6959E24CC77EA00ACFB35 /* OpenEmuXPCCommunicatorAgent-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "OpenEmuXPCCommunicatorAgent-Info.plist"; sourceTree = "<group>"; };
|
||||
05E695A224CC86F100ACFB35 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
|
||||
05F6380722DFFB3700FC49FF /* OEXPCDebugSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OEXPCDebugSupport.h; sourceTree = "<group>"; };
|
||||
05F6380822DFFB3700FC49FF /* OEXPCDebugSupport.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OEXPCDebugSupport.m; sourceTree = "<group>"; };
|
||||
C643AC5117935A9A00456656 /* OpenEmuXPCCommunicator.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OpenEmuXPCCommunicator.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@@ -115,7 +117,7 @@
|
||||
C643AC5817935A9B00456656 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
|
||||
C643AC5917935A9B00456656 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
C643AC5C17935A9B00456656 /* OpenEmuXPCCommunicator-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "OpenEmuXPCCommunicator-Info.plist"; sourceTree = "<group>"; };
|
||||
C643AC5E17935A9B00456656 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
C643AC5E17935A9B00456656 /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
C643AC6017935A9B00456656 /* OpenEmuXPCCommunicator-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OpenEmuXPCCommunicator-Prefix.pch"; sourceTree = "<group>"; };
|
||||
C643AC6D17935C1200456656 /* OpenEmuXPCCommunicatorAgent */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = OpenEmuXPCCommunicatorAgent; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C643AC6E17935C1200456656 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
@@ -132,7 +134,7 @@
|
||||
C643AC8D1793916E00456656 /* OpenEmuXPCCommunicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenEmuXPCCommunicator.h; sourceTree = "<group>"; };
|
||||
C643AC93179392C000456656 /* OEXPCCTestApplication.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OEXPCCTestApplication.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C643AC97179392C000456656 /* OEXPCCTestApplication-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "OEXPCCTestApplication-Info.plist"; sourceTree = "<group>"; };
|
||||
C643AC99179392C000456656 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
C643AC99179392C000456656 /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
C643AC9B179392C000456656 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
C643AC9D179392C000456656 /* OEXPCCTestApplication-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OEXPCCTestApplication-Prefix.pch"; sourceTree = "<group>"; };
|
||||
C643AC9F179392C000456656 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = "<group>"; };
|
||||
@@ -190,6 +192,7 @@
|
||||
C643AC4717935A9A00456656 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
05E695A224CC86F100ACFB35 /* Config.xcconfig */,
|
||||
C643AC5A17935A9B00456656 /* OpenEmuXPCCommunicator */,
|
||||
C643AC7017935C1200456656 /* OpenEmuXPCCommunicatorAgent */,
|
||||
C643AC95179392C000456656 /* OEXPCCTestApplication */,
|
||||
@@ -197,7 +200,9 @@
|
||||
C643AC5317935A9A00456656 /* Frameworks */,
|
||||
C643AC5217935A9A00456656 /* Products */,
|
||||
);
|
||||
indentWidth = 4;
|
||||
sourceTree = "<group>";
|
||||
tabWidth = 4;
|
||||
usesTabs = 0;
|
||||
};
|
||||
C643AC5217935A9A00456656 /* Products */ = {
|
||||
@@ -273,6 +278,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C643AC7417935C1200456656 /* OpenEmuXPCCommunicatorAgent-Prefix.pch */,
|
||||
05E6959E24CC77EA00ACFB35 /* OpenEmuXPCCommunicatorAgent-Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
@@ -577,6 +583,7 @@
|
||||
/* Begin XCBuildConfiguration section */
|
||||
C643AC6417935A9B00456656 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 05E695A224CC86F100ACFB35 /* Config.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
@@ -601,6 +608,7 @@
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 2;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
@@ -620,6 +628,7 @@
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14.4;
|
||||
MARKETING_VERSION = 2.0;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
@@ -627,6 +636,7 @@
|
||||
};
|
||||
C643AC6517935A9B00456656 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 05E695A224CC86F100ACFB35 /* Config.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
@@ -651,6 +661,7 @@
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
CURRENT_PROJECT_VERSION = 2;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
@@ -663,6 +674,7 @@
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14.4;
|
||||
MARKETING_VERSION = 2.0;
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
name = Release;
|
||||
@@ -714,8 +726,11 @@
|
||||
buildSettings = {
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CREATE_INFOPLIST_SECTION_IN_BINARY = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "OpenEmuXPCCommunicatorAgent/OpenEmuXPCCommunicatorAgent-Prefix.pch";
|
||||
INFOPLIST_FILE = "$(SRCROOT)/OpenEmuXPCCommunicatorAgent/OpenEmuXPCCommunicatorAgent-Info.plist";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.openemu.${PRODUCT_NAME:rfc1034identifier}";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
@@ -726,8 +741,11 @@
|
||||
buildSettings = {
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CREATE_INFOPLIST_SECTION_IN_BINARY = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "OpenEmuXPCCommunicatorAgent/OpenEmuXPCCommunicatorAgent-Prefix.pch";
|
||||
INFOPLIST_FILE = "$(SRCROOT)/OpenEmuXPCCommunicatorAgent/OpenEmuXPCCommunicatorAgent-Info.plist";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.openemu.${PRODUCT_NAME:rfc1034identifier}";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
|
||||
@@ -33,9 +33,9 @@
|
||||
+ (OEXPCCAgentConfiguration *)defaultConfiguration;
|
||||
- (void)tearDownAgent;
|
||||
|
||||
// Directory containing the agent binaries (Application Support).
|
||||
// If for any reason -tearDownAgent hasn't been called on app termination, you may use this method
|
||||
// to cleanup the folder.
|
||||
/** Temporary directory containing the agent binaries.
|
||||
* Randomly generated and created as soon as an agent is initialized, and
|
||||
* deleted as soon as all agents in the current process are torn down. */
|
||||
+ (NSString *)agentsDirectory;
|
||||
|
||||
@property(readonly) NSString *serviceName;
|
||||
|
||||
@@ -31,6 +31,12 @@ NSString *const _OEXPCCAgentServiceNameArgumentPrefix = @"--org.openemu.OEXPCCAg
|
||||
NSString *const _OEXPCCAgentProcessIdentifierArgumentPrefix = @"--org.openemu.OEXPCCAgent.ProcessIdentifier=";
|
||||
NSString *const _OEXPCCAgentServiceNamePrefix = @"org.openemu.OEXPCCAgent.";
|
||||
|
||||
/* Number of agents currently set up
|
||||
* Used to delete the agents directory when the number of agents reaches zero*/
|
||||
static NSInteger liveAgents = 0;
|
||||
/* Directory where the agent launchd plists and binaries are located */
|
||||
static NSString *agentsDirectory = nil;
|
||||
|
||||
@implementation OEXPCCAgentConfiguration
|
||||
{
|
||||
NSString *_serviceNameArgument;
|
||||
@@ -65,7 +71,7 @@ NSString *const _OEXPCCAgentServiceNamePrefix = @"org.openemu.OEXPCCAgent.";
|
||||
_serviceName = [@[ _OEXPCCAgentServiceNamePrefix, [[NSUUID UUID] UUIDString] ] componentsJoinedByString:@""];
|
||||
_serviceNameArgument = [@[ _OEXPCCAgentServiceNameArgumentPrefix, _serviceName ] componentsJoinedByString:@""];
|
||||
|
||||
_agentProcessPath = [[[self class] OEXPCC_agentsApplicationSupportFolderPath] stringByAppendingPathComponent:_serviceName];
|
||||
_agentProcessPath = [[[self class] agentsDirectory] stringByAppendingPathComponent:_serviceName];
|
||||
_agentPlistPath = [_agentProcessPath stringByAppendingPathExtension:@"plist"];
|
||||
|
||||
[self OEXPCC_setUpAgent];
|
||||
@@ -75,6 +81,7 @@ NSString *const _OEXPCCAgentServiceNamePrefix = @"org.openemu.OEXPCCAgent.";
|
||||
|
||||
- (void)OEXPCC_setUpAgent
|
||||
{
|
||||
[[self class] OEXPCC_incrementAgentCount];
|
||||
[[self OEXPCC_propertyListForAgent] writeToFile:_agentPlistPath atomically:YES];
|
||||
[[NSFileManager defaultManager] copyItemAtPath:[self OEXPCC_originalAgentProgramPath] toPath:_agentProcessPath error:NULL];
|
||||
|
||||
@@ -103,6 +110,7 @@ NSString *const _OEXPCCAgentServiceNamePrefix = @"org.openemu.OEXPCCAgent.";
|
||||
|
||||
[[NSFileManager defaultManager] removeItemAtPath:_agentPlistPath error:NULL];
|
||||
[[NSFileManager defaultManager] removeItemAtPath:_agentProcessPath error:NULL];
|
||||
[[self class] OEXPCC_decrementAgentCount];
|
||||
}
|
||||
|
||||
- (NSString *)agentServiceNameProcessArgument
|
||||
@@ -135,25 +143,40 @@ NSString *const _OEXPCCAgentServiceNamePrefix = @"org.openemu.OEXPCCAgent.";
|
||||
};
|
||||
}
|
||||
|
||||
+ (NSString *)OEXPCC_agentsApplicationSupportFolderPath
|
||||
{
|
||||
static NSString *agentsApplicationSupportFolderPath = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
||||
if([paths count] == 0) @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Could not find Application Support directory." userInfo:nil];
|
||||
|
||||
agentsApplicationSupportFolderPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"org.openemu.OEXPCCAgent.Agents"];
|
||||
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:agentsApplicationSupportFolderPath withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||
});
|
||||
|
||||
return agentsApplicationSupportFolderPath;
|
||||
}
|
||||
|
||||
+ (NSString *)agentsDirectory
|
||||
{
|
||||
return [self OEXPCC_agentsApplicationSupportFolderPath];
|
||||
@synchronized ([self class]) {
|
||||
if (agentsDirectory)
|
||||
return agentsDirectory;
|
||||
|
||||
char *tempDirectoryTemplate = NULL;
|
||||
asprintf(&tempDirectoryTemplate, "%s/org.openemu.OEXPCCAgent.Agents.XXXXXXXX", [NSTemporaryDirectory() fileSystemRepresentation]);
|
||||
if (!mkdtemp(tempDirectoryTemplate)) {
|
||||
[NSException exceptionWithName:NSInternalInconsistencyException reason:@"Cannot create temporary agent plist directory." userInfo:nil];
|
||||
}
|
||||
agentsDirectory = [[NSURL fileURLWithFileSystemRepresentation:tempDirectoryTemplate isDirectory:YES relativeToURL:nil] path];
|
||||
return agentsDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)OEXPCC_incrementAgentCount
|
||||
{
|
||||
@synchronized ([self class]) {
|
||||
liveAgents++;
|
||||
if (liveAgents > 0) {
|
||||
[self agentsDirectory];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)OEXPCC_decrementAgentCount
|
||||
{
|
||||
@synchronized ([self class]) {
|
||||
liveAgents = MAX(liveAgents - 1, 0);
|
||||
if (liveAgents == 0 && agentsDirectory) {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:agentsDirectory error:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.openemu.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
@@ -17,14 +17,16 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2013 OpenEmu Team. All rights reserved.</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
<key>OEAPIVersion</key>
|
||||
<string>$(OE_API_VERSION)</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2020 OpenEmu. All rights reserved.</string>
|
||||
<key>OEAPIVersion</key>
|
||||
<string>$(OE_API_VERSION)</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Reference in New Issue
Block a user