diff --git a/Audio/Plugin.h b/Audio/Plugin.h index 524820c11..1139da8cf 100644 --- a/Audio/Plugin.h +++ b/Audio/Plugin.h @@ -15,6 +15,10 @@ - (void)dealloc; @end +@protocol CogVersionCheck ++ (BOOL)shouldLoadForOSVersion:(NSOperatingSystemVersion)version; +@end + @protocol CogContainer + (NSArray *)fileTypes; //mp3, ogg, etc + (NSArray *)mimeTypes; diff --git a/Audio/PluginController.m b/Audio/PluginController.m index 80ff426b4..543f03d5c 100644 --- a/Audio/PluginController.m +++ b/Audio/PluginController.m @@ -67,6 +67,18 @@ static PluginController *sharedPluginController = nil; - (void)bundleDidLoad:(NSNotification *)notification { NSArray *classNames = [[notification userInfo] objectForKey:@"NSLoadedClasses"]; + for (NSString *className in classNames) + { + Class bundleClass = NSClassFromString(className); + if ([bundleClass conformsToProtocol:@protocol(CogVersionCheck)]) { + DLog(@"Component has version check: %@", className); + if (![bundleClass shouldLoadForOSVersion:[[NSProcessInfo processInfo] operatingSystemVersion]]) + { + DLog(@"Plugin fails OS version check, ignoring"); + return; + } + } + } for (NSString *className in classNames) { DLog(@"Class loaded: %@", className); diff --git a/Plugins/OpenMPT.old/OpenMPT/OMPTVersionCheck.h b/Plugins/OpenMPT.old/OpenMPT/OMPTVersionCheck.h new file mode 100644 index 000000000..295da717a --- /dev/null +++ b/Plugins/OpenMPT.old/OpenMPT/OMPTVersionCheck.h @@ -0,0 +1,18 @@ +// +// OMPTVersionCheck.h +// OpenMPT +// +// Created by Christopher Snowhill on 12/27/21. +// Copyright © 2021 Christopher Snowhill. All rights reserved. +// + +#ifndef OMPTVersionCheck_h +#define OMPTVersionCheck_h + +#import "Plugin.h" + +@interface OMPTOldVersionCheck : NSObject ++ (BOOL)shouldLoadForOSVersion:(NSOperatingSystemVersion)version; +@end + +#endif /* OMPTVersionCheck_h */ diff --git a/Plugins/OpenMPT.old/OpenMPT/OMPTVersionCheck.m b/Plugins/OpenMPT.old/OpenMPT/OMPTVersionCheck.m new file mode 100644 index 000000000..f5f52bd04 --- /dev/null +++ b/Plugins/OpenMPT.old/OpenMPT/OMPTVersionCheck.m @@ -0,0 +1,20 @@ +// +// OMPTVersionCheck.m +// OpenMPT +// +// Created by Christopher Snowhill on 12/27/21. +// Copyright © 2021 Christopher Snowhill. All rights reserved. +// + +#import +#import "OMPTVersionCheck.h" + +@implementation OMPTOldVersionCheck ++ (BOOL)shouldLoadForOSVersion:(NSOperatingSystemVersion)version { + if (version.majorVersion < 10 || + (version.majorVersion == 10 && version.minorVersion < 15)) + return YES; + else + return NO; +} +@end diff --git a/Plugins/OpenMPT.old/OpenMPTOld.xcodeproj/project.pbxproj b/Plugins/OpenMPT.old/OpenMPTOld.xcodeproj/project.pbxproj index e46c03ba1..07c71595a 100644 --- a/Plugins/OpenMPT.old/OpenMPTOld.xcodeproj/project.pbxproj +++ b/Plugins/OpenMPT.old/OpenMPTOld.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 83187C7120E4EAB700DED293 /* libOpenMPTOld.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8308151E20E4EA96003ACEDA /* libOpenMPTOld.framework */; }; 83187C7220E4EAC400DED293 /* libOpenMPTOld.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8308151E20E4EA96003ACEDA /* libOpenMPTOld.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 8372349F277AA34000CD0A77 /* OMPTVersionCheck.m in Sources */ = {isa = PBXBuildFile; fileRef = 8372349D277AA34000CD0A77 /* OMPTVersionCheck.m */; }; 83E5FE731FFF010C00659F0F /* OMPTDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83E5FE6D1FFF010B00659F0F /* OMPTDecoder.mm */; }; 83E5FE741FFF010C00659F0F /* OMPTContainer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83E5FE6F1FFF010B00659F0F /* OMPTContainer.mm */; }; 83E5FE751FFF010C00659F0F /* OMPTMetadataReader.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83E5FE701FFF010C00659F0F /* OMPTMetadataReader.mm */; }; @@ -45,6 +46,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 8372349D277AA34000CD0A77 /* OMPTVersionCheck.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OMPTVersionCheck.m; path = OpenMPT/OMPTVersionCheck.m; sourceTree = ""; }; + 8372349E277AA34000CD0A77 /* OMPTVersionCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OMPTVersionCheck.h; path = OpenMPT/OMPTVersionCheck.h; sourceTree = ""; }; 83E5EFA31FFEF78100659F0F /* OpenMPTOld.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OpenMPTOld.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 83E5EFA61FFEF78100659F0F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 83E5EFC81FFEF7CC00659F0F /* libOpenMPTOld.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = libOpenMPTOld.xcodeproj; path = ../../Frameworks/OpenMPT.old/libOpenMPTOld.xcodeproj; sourceTree = ""; }; @@ -125,6 +128,8 @@ 83E5FE6D1FFF010B00659F0F /* OMPTDecoder.mm */, 83E5FE721FFF010C00659F0F /* OMPTMetadataReader.h */, 83E5FE701FFF010C00659F0F /* OMPTMetadataReader.mm */, + 8372349E277AA34000CD0A77 /* OMPTVersionCheck.h */, + 8372349D277AA34000CD0A77 /* OMPTVersionCheck.m */, ); name = Classes; sourceTree = ""; @@ -216,6 +221,7 @@ buildActionMask = 2147483647; files = ( 83E5FE751FFF010C00659F0F /* OMPTMetadataReader.mm in Sources */, + 8372349F277AA34000CD0A77 /* OMPTVersionCheck.m in Sources */, 83E5FE731FFF010C00659F0F /* OMPTDecoder.mm in Sources */, 83E5FE741FFF010C00659F0F /* OMPTContainer.mm in Sources */, ); diff --git a/Plugins/OpenMPT/OpenMPT.xcodeproj/project.pbxproj b/Plugins/OpenMPT/OpenMPT.xcodeproj/project.pbxproj index e4922af03..86cba753c 100644 --- a/Plugins/OpenMPT/OpenMPT.xcodeproj/project.pbxproj +++ b/Plugins/OpenMPT/OpenMPT.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 83187C7120E4EAB700DED293 /* libOpenMPT.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8308151E20E4EA96003ACEDA /* libOpenMPT.framework */; }; 83187C7220E4EAC400DED293 /* libOpenMPT.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8308151E20E4EA96003ACEDA /* libOpenMPT.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 8372349C277AA23F00CD0A77 /* OMPTVersionCheck.m in Sources */ = {isa = PBXBuildFile; fileRef = 8372349B277AA23F00CD0A77 /* OMPTVersionCheck.m */; }; 83E5FE731FFF010C00659F0F /* OMPTDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83E5FE6D1FFF010B00659F0F /* OMPTDecoder.mm */; }; 83E5FE741FFF010C00659F0F /* OMPTContainer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83E5FE6F1FFF010B00659F0F /* OMPTContainer.mm */; }; 83E5FE751FFF010C00659F0F /* OMPTMetadataReader.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83E5FE701FFF010C00659F0F /* OMPTMetadataReader.mm */; }; @@ -45,6 +46,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 8372349A277AA1F600CD0A77 /* OMPTVersionCheck.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OMPTVersionCheck.h; path = OpenMPT/OMPTVersionCheck.h; sourceTree = ""; }; + 8372349B277AA23F00CD0A77 /* OMPTVersionCheck.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = OMPTVersionCheck.m; path = OpenMPT/OMPTVersionCheck.m; sourceTree = ""; }; 83E5EFA31FFEF78100659F0F /* OpenMPT.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OpenMPT.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 83E5EFA61FFEF78100659F0F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 83E5EFC81FFEF7CC00659F0F /* libOpenMPT.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = libOpenMPT.xcodeproj; path = ../../Frameworks/OpenMPT/libOpenMPT.xcodeproj; sourceTree = ""; }; @@ -125,6 +128,8 @@ 83E5FE6D1FFF010B00659F0F /* OMPTDecoder.mm */, 83E5FE721FFF010C00659F0F /* OMPTMetadataReader.h */, 83E5FE701FFF010C00659F0F /* OMPTMetadataReader.mm */, + 8372349A277AA1F600CD0A77 /* OMPTVersionCheck.h */, + 8372349B277AA23F00CD0A77 /* OMPTVersionCheck.m */, ); name = Classes; sourceTree = ""; @@ -216,6 +221,7 @@ buildActionMask = 2147483647; files = ( 83E5FE751FFF010C00659F0F /* OMPTMetadataReader.mm in Sources */, + 8372349C277AA23F00CD0A77 /* OMPTVersionCheck.m in Sources */, 83E5FE731FFF010C00659F0F /* OMPTDecoder.mm in Sources */, 83E5FE741FFF010C00659F0F /* OMPTContainer.mm in Sources */, ); diff --git a/Plugins/OpenMPT/OpenMPT/OMPTVersionCheck.h b/Plugins/OpenMPT/OpenMPT/OMPTVersionCheck.h new file mode 100644 index 000000000..6f9161e1e --- /dev/null +++ b/Plugins/OpenMPT/OpenMPT/OMPTVersionCheck.h @@ -0,0 +1,18 @@ +// +// OMPTVersionCheck.h +// OpenMPT +// +// Created by Christopher Snowhill on 12/27/21. +// Copyright © 2021 Christopher Snowhill. All rights reserved. +// + +#ifndef OMPTVersionCheck_h +#define OMPTVersionCheck_h + +#import "Plugin.h" + +@interface OMPTVersionCheck : NSObject ++ (BOOL)shouldLoadForOSVersion:(NSOperatingSystemVersion)version; +@end + +#endif /* OMPTVersionCheck_h */ diff --git a/Plugins/OpenMPT/OpenMPT/OMPTVersionCheck.m b/Plugins/OpenMPT/OpenMPT/OMPTVersionCheck.m new file mode 100644 index 000000000..b67f558f2 --- /dev/null +++ b/Plugins/OpenMPT/OpenMPT/OMPTVersionCheck.m @@ -0,0 +1,20 @@ +// +// OMPTVersionCheck.m +// OpenMPT +// +// Created by Christopher Snowhill on 12/27/21. +// Copyright © 2021 Christopher Snowhill. All rights reserved. +// + +#import +#import "OMPTVersionCheck.h" + +@implementation OMPTVersionCheck ++ (BOOL)shouldLoadForOSVersion:(NSOperatingSystemVersion)version { + if (version.majorVersion < 10 || + (version.majorVersion == 10 && version.minorVersion < 15)) + return NO; + else + return YES; +} +@end