├── docs └── readme-example.png ├── java-class-quick-look.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── louisdhauwe.xcuserdatad │ └── xcschemes │ ├── java-class-quick-look.xcscheme │ └── xcschememanagement.plist ├── java-class-quick-look ├── GeneratePreviewForURL.m ├── GenerateThumbnailForURL.c ├── Info.plist └── main.c └── readme.md /docs/readme-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisdh/java-class-quick-look/a3558cd35b67f0c4d69b213d24748490b14af373/docs/readme-example.png -------------------------------------------------------------------------------- /java-class-quick-look.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | BEC300461F50873600263200 /* GenerateThumbnailForURL.c in Sources */ = {isa = PBXBuildFile; fileRef = BEC300451F50873600263200 /* GenerateThumbnailForURL.c */; }; 11 | BEC300481F50873600263200 /* GeneratePreviewForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = BEC300471F50873600263200 /* GeneratePreviewForURL.m */; }; 12 | BEC3004A1F50873600263200 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = BEC300491F50873600263200 /* main.c */; }; 13 | BEC300551F50888D00263200 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC300541F50888D00263200 /* CoreFoundation.framework */; }; 14 | BEC300571F5088C500263200 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC300561F5088C500263200 /* AppKit.framework */; }; 15 | BEC300591F5088D100263200 /* QuickLook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC300581F5088D100263200 /* QuickLook.framework */; }; 16 | BEC3005B1F5088D500263200 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC3005A1F5088D500263200 /* ApplicationServices.framework */; }; 17 | BEC3005D1F5088DB00263200 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC3005C1F5088DB00263200 /* CoreServices.framework */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | BEC300421F50873600263200 /* java-class-quick-look.qlgenerator */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "java-class-quick-look.qlgenerator"; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | BEC300451F50873600263200 /* GenerateThumbnailForURL.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = GenerateThumbnailForURL.c; sourceTree = ""; }; 23 | BEC300471F50873600263200 /* GeneratePreviewForURL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GeneratePreviewForURL.m; sourceTree = ""; }; 24 | BEC300491F50873600263200 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; }; 25 | BEC3004B1F50873600263200 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | BEC300521F50887A00263200 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 27 | BEC300541F50888D00263200 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; 28 | BEC300561F5088C500263200 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 29 | BEC300581F5088D100263200 /* QuickLook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickLook.framework; path = System/Library/Frameworks/QuickLook.framework; sourceTree = SDKROOT; }; 30 | BEC3005A1F5088D500263200 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; }; 31 | BEC3005C1F5088DB00263200 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; }; 32 | /* End PBXFileReference section */ 33 | 34 | /* Begin PBXFrameworksBuildPhase section */ 35 | BEC3003E1F50873600263200 /* Frameworks */ = { 36 | isa = PBXFrameworksBuildPhase; 37 | buildActionMask = 2147483647; 38 | files = ( 39 | BEC3005D1F5088DB00263200 /* CoreServices.framework in Frameworks */, 40 | BEC3005B1F5088D500263200 /* ApplicationServices.framework in Frameworks */, 41 | BEC300591F5088D100263200 /* QuickLook.framework in Frameworks */, 42 | BEC300571F5088C500263200 /* AppKit.framework in Frameworks */, 43 | BEC300551F50888D00263200 /* CoreFoundation.framework in Frameworks */, 44 | ); 45 | runOnlyForDeploymentPostprocessing = 0; 46 | }; 47 | /* End PBXFrameworksBuildPhase section */ 48 | 49 | /* Begin PBXGroup section */ 50 | BEC300381F50873600263200 = { 51 | isa = PBXGroup; 52 | children = ( 53 | BEC300441F50873600263200 /* java-class-quick-look */, 54 | BEC300431F50873600263200 /* Products */, 55 | BEC300511F50887A00263200 /* Frameworks */, 56 | ); 57 | sourceTree = ""; 58 | }; 59 | BEC300431F50873600263200 /* Products */ = { 60 | isa = PBXGroup; 61 | children = ( 62 | BEC300421F50873600263200 /* java-class-quick-look.qlgenerator */, 63 | ); 64 | name = Products; 65 | sourceTree = ""; 66 | }; 67 | BEC300441F50873600263200 /* java-class-quick-look */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | BEC300451F50873600263200 /* GenerateThumbnailForURL.c */, 71 | BEC300471F50873600263200 /* GeneratePreviewForURL.m */, 72 | BEC300491F50873600263200 /* main.c */, 73 | BEC3004B1F50873600263200 /* Info.plist */, 74 | ); 75 | path = "java-class-quick-look"; 76 | sourceTree = ""; 77 | }; 78 | BEC300511F50887A00263200 /* Frameworks */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | BEC3005C1F5088DB00263200 /* CoreServices.framework */, 82 | BEC3005A1F5088D500263200 /* ApplicationServices.framework */, 83 | BEC300581F5088D100263200 /* QuickLook.framework */, 84 | BEC300561F5088C500263200 /* AppKit.framework */, 85 | BEC300541F50888D00263200 /* CoreFoundation.framework */, 86 | BEC300521F50887A00263200 /* Foundation.framework */, 87 | ); 88 | name = Frameworks; 89 | sourceTree = ""; 90 | }; 91 | /* End PBXGroup section */ 92 | 93 | /* Begin PBXHeadersBuildPhase section */ 94 | BEC3003F1F50873600263200 /* Headers */ = { 95 | isa = PBXHeadersBuildPhase; 96 | buildActionMask = 2147483647; 97 | files = ( 98 | ); 99 | runOnlyForDeploymentPostprocessing = 0; 100 | }; 101 | /* End PBXHeadersBuildPhase section */ 102 | 103 | /* Begin PBXNativeTarget section */ 104 | BEC300411F50873600263200 /* java-class-quick-look */ = { 105 | isa = PBXNativeTarget; 106 | buildConfigurationList = BEC3004E1F50873600263200 /* Build configuration list for PBXNativeTarget "java-class-quick-look" */; 107 | buildPhases = ( 108 | BEC3003D1F50873600263200 /* Sources */, 109 | BEC3003E1F50873600263200 /* Frameworks */, 110 | BEC3003F1F50873600263200 /* Headers */, 111 | BEC300401F50873600263200 /* Resources */, 112 | ); 113 | buildRules = ( 114 | ); 115 | dependencies = ( 116 | ); 117 | name = "java-class-quick-look"; 118 | productName = "java-class-quick-look"; 119 | productReference = BEC300421F50873600263200 /* java-class-quick-look.qlgenerator */; 120 | productType = "com.apple.product-type.bundle"; 121 | }; 122 | /* End PBXNativeTarget section */ 123 | 124 | /* Begin PBXProject section */ 125 | BEC300391F50873600263200 /* Project object */ = { 126 | isa = PBXProject; 127 | attributes = { 128 | LastUpgradeCheck = 0830; 129 | ORGANIZATIONNAME = "Silver Fox"; 130 | TargetAttributes = { 131 | BEC300411F50873600263200 = { 132 | CreatedOnToolsVersion = 8.3.3; 133 | DevelopmentTeam = 6G5LMQ72D8; 134 | ProvisioningStyle = Automatic; 135 | }; 136 | }; 137 | }; 138 | buildConfigurationList = BEC3003C1F50873600263200 /* Build configuration list for PBXProject "java-class-quick-look" */; 139 | compatibilityVersion = "Xcode 3.2"; 140 | developmentRegion = English; 141 | hasScannedForEncodings = 0; 142 | knownRegions = ( 143 | en, 144 | ); 145 | mainGroup = BEC300381F50873600263200; 146 | productRefGroup = BEC300431F50873600263200 /* Products */; 147 | projectDirPath = ""; 148 | projectRoot = ""; 149 | targets = ( 150 | BEC300411F50873600263200 /* java-class-quick-look */, 151 | ); 152 | }; 153 | /* End PBXProject section */ 154 | 155 | /* Begin PBXResourcesBuildPhase section */ 156 | BEC300401F50873600263200 /* Resources */ = { 157 | isa = PBXResourcesBuildPhase; 158 | buildActionMask = 2147483647; 159 | files = ( 160 | ); 161 | runOnlyForDeploymentPostprocessing = 0; 162 | }; 163 | /* End PBXResourcesBuildPhase section */ 164 | 165 | /* Begin PBXSourcesBuildPhase section */ 166 | BEC3003D1F50873600263200 /* Sources */ = { 167 | isa = PBXSourcesBuildPhase; 168 | buildActionMask = 2147483647; 169 | files = ( 170 | BEC300461F50873600263200 /* GenerateThumbnailForURL.c in Sources */, 171 | BEC300481F50873600263200 /* GeneratePreviewForURL.m in Sources */, 172 | BEC3004A1F50873600263200 /* main.c in Sources */, 173 | ); 174 | runOnlyForDeploymentPostprocessing = 0; 175 | }; 176 | /* End PBXSourcesBuildPhase section */ 177 | 178 | /* Begin XCBuildConfiguration section */ 179 | BEC3004C1F50873600263200 /* Debug */ = { 180 | isa = XCBuildConfiguration; 181 | buildSettings = { 182 | ALWAYS_SEARCH_USER_PATHS = NO; 183 | CLANG_ANALYZER_NONNULL = YES; 184 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 185 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 186 | CLANG_CXX_LIBRARY = "libc++"; 187 | CLANG_ENABLE_MODULES = YES; 188 | CLANG_ENABLE_OBJC_ARC = YES; 189 | CLANG_WARN_BOOL_CONVERSION = YES; 190 | CLANG_WARN_CONSTANT_CONVERSION = YES; 191 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 192 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 193 | CLANG_WARN_EMPTY_BODY = YES; 194 | CLANG_WARN_ENUM_CONVERSION = YES; 195 | CLANG_WARN_INFINITE_RECURSION = YES; 196 | CLANG_WARN_INT_CONVERSION = YES; 197 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 198 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 199 | CLANG_WARN_UNREACHABLE_CODE = YES; 200 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 201 | CODE_SIGN_IDENTITY = "-"; 202 | COPY_PHASE_STRIP = NO; 203 | DEBUG_INFORMATION_FORMAT = dwarf; 204 | ENABLE_STRICT_OBJC_MSGSEND = YES; 205 | ENABLE_TESTABILITY = YES; 206 | GCC_C_LANGUAGE_STANDARD = gnu99; 207 | GCC_DYNAMIC_NO_PIC = NO; 208 | GCC_NO_COMMON_BLOCKS = YES; 209 | GCC_OPTIMIZATION_LEVEL = 0; 210 | GCC_PREPROCESSOR_DEFINITIONS = ( 211 | "DEBUG=1", 212 | "$(inherited)", 213 | ); 214 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 215 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 216 | GCC_WARN_UNDECLARED_SELECTOR = YES; 217 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 218 | GCC_WARN_UNUSED_FUNCTION = YES; 219 | GCC_WARN_UNUSED_VARIABLE = YES; 220 | MACOSX_DEPLOYMENT_TARGET = 10.12; 221 | MTL_ENABLE_DEBUG_INFO = YES; 222 | ONLY_ACTIVE_ARCH = YES; 223 | SDKROOT = macosx; 224 | }; 225 | name = Debug; 226 | }; 227 | BEC3004D1F50873600263200 /* Release */ = { 228 | isa = XCBuildConfiguration; 229 | buildSettings = { 230 | ALWAYS_SEARCH_USER_PATHS = NO; 231 | CLANG_ANALYZER_NONNULL = YES; 232 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 233 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 234 | CLANG_CXX_LIBRARY = "libc++"; 235 | CLANG_ENABLE_MODULES = YES; 236 | CLANG_ENABLE_OBJC_ARC = YES; 237 | CLANG_WARN_BOOL_CONVERSION = YES; 238 | CLANG_WARN_CONSTANT_CONVERSION = YES; 239 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 240 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 241 | CLANG_WARN_EMPTY_BODY = YES; 242 | CLANG_WARN_ENUM_CONVERSION = YES; 243 | CLANG_WARN_INFINITE_RECURSION = YES; 244 | CLANG_WARN_INT_CONVERSION = YES; 245 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 246 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 247 | CLANG_WARN_UNREACHABLE_CODE = YES; 248 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 249 | CODE_SIGN_IDENTITY = "-"; 250 | COPY_PHASE_STRIP = NO; 251 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 252 | ENABLE_NS_ASSERTIONS = NO; 253 | ENABLE_STRICT_OBJC_MSGSEND = YES; 254 | GCC_C_LANGUAGE_STANDARD = gnu99; 255 | GCC_NO_COMMON_BLOCKS = YES; 256 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 257 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 258 | GCC_WARN_UNDECLARED_SELECTOR = YES; 259 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 260 | GCC_WARN_UNUSED_FUNCTION = YES; 261 | GCC_WARN_UNUSED_VARIABLE = YES; 262 | MACOSX_DEPLOYMENT_TARGET = 10.12; 263 | MTL_ENABLE_DEBUG_INFO = NO; 264 | SDKROOT = macosx; 265 | }; 266 | name = Release; 267 | }; 268 | BEC3004F1F50873600263200 /* Debug */ = { 269 | isa = XCBuildConfiguration; 270 | buildSettings = { 271 | CODE_SIGN_IDENTITY = "Mac Developer"; 272 | COMBINE_HIDPI_IMAGES = YES; 273 | DEVELOPMENT_TEAM = 6G5LMQ72D8; 274 | INFOPLIST_FILE = "java-class-quick-look/Info.plist"; 275 | INSTALL_PATH = /Library/QuickLook; 276 | PRODUCT_BUNDLE_IDENTIFIER = "be.silverfox.java-class-quick-look"; 277 | PRODUCT_NAME = "$(TARGET_NAME)"; 278 | PROVISIONING_PROFILE_SPECIFIER = ""; 279 | WRAPPER_EXTENSION = qlgenerator; 280 | }; 281 | name = Debug; 282 | }; 283 | BEC300501F50873600263200 /* Release */ = { 284 | isa = XCBuildConfiguration; 285 | buildSettings = { 286 | CODE_SIGN_IDENTITY = "Mac Developer"; 287 | COMBINE_HIDPI_IMAGES = YES; 288 | DEVELOPMENT_TEAM = 6G5LMQ72D8; 289 | INFOPLIST_FILE = "java-class-quick-look/Info.plist"; 290 | INSTALL_PATH = /Library/QuickLook; 291 | PRODUCT_BUNDLE_IDENTIFIER = "be.silverfox.java-class-quick-look"; 292 | PRODUCT_NAME = "$(TARGET_NAME)"; 293 | PROVISIONING_PROFILE_SPECIFIER = ""; 294 | WRAPPER_EXTENSION = qlgenerator; 295 | }; 296 | name = Release; 297 | }; 298 | /* End XCBuildConfiguration section */ 299 | 300 | /* Begin XCConfigurationList section */ 301 | BEC3003C1F50873600263200 /* Build configuration list for PBXProject "java-class-quick-look" */ = { 302 | isa = XCConfigurationList; 303 | buildConfigurations = ( 304 | BEC3004C1F50873600263200 /* Debug */, 305 | BEC3004D1F50873600263200 /* Release */, 306 | ); 307 | defaultConfigurationIsVisible = 0; 308 | defaultConfigurationName = Release; 309 | }; 310 | BEC3004E1F50873600263200 /* Build configuration list for PBXNativeTarget "java-class-quick-look" */ = { 311 | isa = XCConfigurationList; 312 | buildConfigurations = ( 313 | BEC3004F1F50873600263200 /* Debug */, 314 | BEC300501F50873600263200 /* Release */, 315 | ); 316 | defaultConfigurationIsVisible = 0; 317 | }; 318 | /* End XCConfigurationList section */ 319 | }; 320 | rootObject = BEC300391F50873600263200 /* Project object */; 321 | } 322 | -------------------------------------------------------------------------------- /java-class-quick-look.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /java-class-quick-look.xcodeproj/xcuserdata/louisdhauwe.xcuserdatad/xcschemes/java-class-quick-look.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /java-class-quick-look.xcodeproj/xcuserdata/louisdhauwe.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | java-class-quick-look.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | BEC300411F50873600263200 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /java-class-quick-look/GeneratePreviewForURL.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #import 6 | #import 7 | 8 | OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options); 9 | void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview); 10 | 11 | /* ----------------------------------------------------------------------------- 12 | Generate a preview for file 13 | 14 | This function's job is to create preview for designated file 15 | ----------------------------------------------------------------------------- */ 16 | 17 | OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options) { 18 | 19 | @autoreleasepool { 20 | 21 | if (QLPreviewRequestIsCancelled(preview)) { 22 | return noErr; 23 | } 24 | 25 | NSString *fileName = (__bridge NSString *)CFURLGetString(url); 26 | 27 | NSPipe *pipe = [NSPipe pipe]; 28 | NSFileHandle *file = pipe.fileHandleForReading; 29 | 30 | NSTask *task = [[NSTask alloc] init]; 31 | task.launchPath = @"/usr/bin/javap"; 32 | task.arguments = @[@"-c", fileName]; 33 | task.standardOutput = pipe; 34 | 35 | [task launch]; 36 | 37 | NSData *data = [file readDataToEndOfFile]; 38 | [file closeFile]; 39 | 40 | NSString *grepOutput = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 41 | 42 | NSMutableString *text = [[NSMutableString alloc] initWithString:grepOutput]; 43 | 44 | NSDictionary *properties = @{ 45 | (__bridge NSString *)kQLPreviewPropertyTextEncodingNameKey : @"UTF-8", 46 | (__bridge NSString *)kQLPreviewPropertyMIMETypeKey : @"text/plain" }; 47 | 48 | QLPreviewRequestSetDataRepresentation(preview, (__bridge CFDataRef)[text dataUsingEncoding:NSUTF8StringEncoding], kUTTypePlainText, (__bridge CFDictionaryRef)properties); 49 | 50 | return noErr; 51 | } 52 | 53 | return noErr; 54 | } 55 | 56 | void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview) { 57 | 58 | // Implement only if supported 59 | } 60 | -------------------------------------------------------------------------------- /java-class-quick-look/GenerateThumbnailForURL.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize); 6 | void CancelThumbnailGeneration(void *thisInterface, QLThumbnailRequestRef thumbnail); 7 | 8 | /* ----------------------------------------------------------------------------- 9 | Generate a thumbnail for file 10 | 11 | This function's job is to create thumbnail for designated file as fast as possible 12 | ----------------------------------------------------------------------------- */ 13 | 14 | OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize) 15 | { 16 | // To complete your generator please implement the function GenerateThumbnailForURL in GenerateThumbnailForURL.c 17 | return noErr; 18 | } 19 | 20 | void CancelThumbnailGeneration(void *thisInterface, QLThumbnailRequestRef thumbnail) 21 | { 22 | // Implement only if supported 23 | } 24 | -------------------------------------------------------------------------------- /java-class-quick-look/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDocumentTypes 8 | 9 | 10 | CFBundleTypeRole 11 | QLGenerator 12 | LSItemContentTypes 13 | 14 | com.sun.java-class 15 | 16 | 17 | 18 | CFBundleExecutable 19 | $(EXECUTABLE_NAME) 20 | CFBundleIdentifier 21 | $(PRODUCT_BUNDLE_IDENTIFIER) 22 | CFBundleInfoDictionaryVersion 23 | 6.0 24 | CFBundleName 25 | $(PRODUCT_NAME) 26 | CFBundleShortVersionString 27 | 1.0 28 | CFBundleVersion 29 | 1 30 | CFPlugInDynamicRegisterFunction 31 | 32 | CFPlugInDynamicRegistration 33 | NO 34 | CFPlugInFactories 35 | 36 | 4CCAD7B6-F74F-4BDB-A0A1-46414DE26A03 37 | QuickLookGeneratorPluginFactory 38 | 39 | CFPlugInTypes 40 | 41 | 5E2D9680-5022-40FA-B806-43349622E5B9 42 | 43 | 4CCAD7B6-F74F-4BDB-A0A1-46414DE26A03 44 | 45 | 46 | CFPlugInUnloadFunction 47 | 48 | NSHumanReadableCopyright 49 | Copyright © 2017 Silver Fox. All rights reserved. 50 | QLNeedsToBeRunInMainThread 51 | 52 | QLPreviewHeight 53 | 600 54 | QLPreviewWidth 55 | 800 56 | QLSupportsConcurrentRequests 57 | 58 | QLThumbnailMinimumSize 59 | 17 60 | 61 | 62 | -------------------------------------------------------------------------------- /java-class-quick-look/main.c: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // 3 | // DO NO MODIFY THE CONTENT OF THIS FILE 4 | // 5 | // This file contains the generic CFPlug-in code necessary for your generator 6 | // To complete your generator implement the function in GenerateThumbnailForURL/GeneratePreviewForURL.c 7 | // 8 | //============================================================================== 9 | 10 | 11 | 12 | 13 | 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | // ----------------------------------------------------------------------------- 21 | // constants 22 | // ----------------------------------------------------------------------------- 23 | 24 | // Don't modify this line 25 | #define PLUGIN_ID "4CCAD7B6-F74F-4BDB-A0A1-46414DE26A03" 26 | 27 | // 28 | // Below is the generic glue code for all plug-ins. 29 | // 30 | // You should not have to modify this code aside from changing 31 | // names if you decide to change the names defined in the Info.plist 32 | // 33 | 34 | 35 | // ----------------------------------------------------------------------------- 36 | // typedefs 37 | // ----------------------------------------------------------------------------- 38 | 39 | // The thumbnail generation function to be implemented in GenerateThumbnailForURL.c 40 | OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize); 41 | void CancelThumbnailGeneration(void* thisInterface, QLThumbnailRequestRef thumbnail); 42 | 43 | // The preview generation function to be implemented in GeneratePreviewForURL.c 44 | OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options); 45 | void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview); 46 | 47 | // The layout for an instance of QuickLookGeneratorPlugIn 48 | typedef struct __QuickLookGeneratorPluginType 49 | { 50 | void *conduitInterface; 51 | CFUUIDRef factoryID; 52 | UInt32 refCount; 53 | } QuickLookGeneratorPluginType; 54 | 55 | // ----------------------------------------------------------------------------- 56 | // prototypes 57 | // ----------------------------------------------------------------------------- 58 | // Forward declaration for the IUnknown implementation. 59 | // 60 | 61 | QuickLookGeneratorPluginType *AllocQuickLookGeneratorPluginType(CFUUIDRef inFactoryID); 62 | void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInstance); 63 | HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv); 64 | void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID); 65 | ULONG QuickLookGeneratorPluginAddRef(void *thisInstance); 66 | ULONG QuickLookGeneratorPluginRelease(void *thisInstance); 67 | 68 | // ----------------------------------------------------------------------------- 69 | // myInterfaceFtbl definition 70 | // ----------------------------------------------------------------------------- 71 | // The QLGeneratorInterfaceStruct function table. 72 | // 73 | static QLGeneratorInterfaceStruct myInterfaceFtbl = { 74 | NULL, 75 | QuickLookGeneratorQueryInterface, 76 | QuickLookGeneratorPluginAddRef, 77 | QuickLookGeneratorPluginRelease, 78 | NULL, 79 | NULL, 80 | NULL, 81 | NULL 82 | }; 83 | 84 | 85 | // ----------------------------------------------------------------------------- 86 | // AllocQuickLookGeneratorPluginType 87 | // ----------------------------------------------------------------------------- 88 | // Utility function that allocates a new instance. 89 | // You can do some initial setup for the generator here if you wish 90 | // like allocating globals etc... 91 | // 92 | QuickLookGeneratorPluginType *AllocQuickLookGeneratorPluginType(CFUUIDRef inFactoryID) 93 | { 94 | QuickLookGeneratorPluginType *theNewInstance; 95 | 96 | theNewInstance = (QuickLookGeneratorPluginType *)malloc(sizeof(QuickLookGeneratorPluginType)); 97 | memset(theNewInstance,0,sizeof(QuickLookGeneratorPluginType)); 98 | 99 | /* Point to the function table Malloc enough to store the stuff and copy the filler from myInterfaceFtbl over */ 100 | theNewInstance->conduitInterface = malloc(sizeof(QLGeneratorInterfaceStruct)); 101 | memcpy(theNewInstance->conduitInterface,&myInterfaceFtbl,sizeof(QLGeneratorInterfaceStruct)); 102 | 103 | /* Retain and keep an open instance refcount for each factory. */ 104 | theNewInstance->factoryID = CFRetain(inFactoryID); 105 | CFPlugInAddInstanceForFactory(inFactoryID); 106 | 107 | /* This function returns the IUnknown interface so set the refCount to one. */ 108 | theNewInstance->refCount = 1; 109 | return theNewInstance; 110 | } 111 | 112 | // ----------------------------------------------------------------------------- 113 | // DeallocQuickLookGeneratorPluginType 114 | // ----------------------------------------------------------------------------- 115 | // Utility function that deallocates the instance when 116 | // the refCount goes to zero. 117 | // In the current implementation generator interfaces are never deallocated 118 | // but implement this as this might change in the future 119 | // 120 | void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInstance) 121 | { 122 | CFUUIDRef theFactoryID; 123 | 124 | theFactoryID = thisInstance->factoryID; 125 | /* Free the conduitInterface table up */ 126 | free(thisInstance->conduitInterface); 127 | 128 | /* Free the instance structure */ 129 | free(thisInstance); 130 | if (theFactoryID){ 131 | CFPlugInRemoveInstanceForFactory(theFactoryID); 132 | CFRelease(theFactoryID); 133 | } 134 | } 135 | 136 | // ----------------------------------------------------------------------------- 137 | // QuickLookGeneratorQueryInterface 138 | // ----------------------------------------------------------------------------- 139 | // Implementation of the IUnknown QueryInterface function. 140 | // 141 | HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv) 142 | { 143 | CFUUIDRef interfaceID; 144 | 145 | interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault,iid); 146 | 147 | if (CFEqual(interfaceID,kQLGeneratorCallbacksInterfaceID)){ 148 | /* If the Right interface was requested, bump the ref count, 149 | * set the ppv parameter equal to the instance, and 150 | * return good status. 151 | */ 152 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->GenerateThumbnailForURL = GenerateThumbnailForURL; 153 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->CancelThumbnailGeneration = CancelThumbnailGeneration; 154 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->GeneratePreviewForURL = GeneratePreviewForURL; 155 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->CancelPreviewGeneration = CancelPreviewGeneration; 156 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType*)thisInstance)->conduitInterface)->AddRef(thisInstance); 157 | *ppv = thisInstance; 158 | CFRelease(interfaceID); 159 | return S_OK; 160 | }else{ 161 | /* Requested interface unknown, bail with error. */ 162 | *ppv = NULL; 163 | CFRelease(interfaceID); 164 | return E_NOINTERFACE; 165 | } 166 | } 167 | 168 | // ----------------------------------------------------------------------------- 169 | // QuickLookGeneratorPluginAddRef 170 | // ----------------------------------------------------------------------------- 171 | // Implementation of reference counting for this type. Whenever an interface 172 | // is requested, bump the refCount for the instance. NOTE: returning the 173 | // refcount is a convention but is not required so don't rely on it. 174 | // 175 | ULONG QuickLookGeneratorPluginAddRef(void *thisInstance) 176 | { 177 | ((QuickLookGeneratorPluginType *)thisInstance )->refCount += 1; 178 | return ((QuickLookGeneratorPluginType*) thisInstance)->refCount; 179 | } 180 | 181 | // ----------------------------------------------------------------------------- 182 | // QuickLookGeneratorPluginRelease 183 | // ----------------------------------------------------------------------------- 184 | // When an interface is released, decrement the refCount. 185 | // If the refCount goes to zero, deallocate the instance. 186 | // 187 | ULONG QuickLookGeneratorPluginRelease(void *thisInstance) 188 | { 189 | ((QuickLookGeneratorPluginType*)thisInstance)->refCount -= 1; 190 | if (((QuickLookGeneratorPluginType*)thisInstance)->refCount == 0){ 191 | DeallocQuickLookGeneratorPluginType((QuickLookGeneratorPluginType*)thisInstance ); 192 | return 0; 193 | }else{ 194 | return ((QuickLookGeneratorPluginType*) thisInstance )->refCount; 195 | } 196 | } 197 | 198 | // ----------------------------------------------------------------------------- 199 | // QuickLookGeneratorPluginFactory 200 | // ----------------------------------------------------------------------------- 201 | void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID) 202 | { 203 | QuickLookGeneratorPluginType *result; 204 | CFUUIDRef uuid; 205 | 206 | /* If correct type is being requested, allocate an 207 | * instance of kQLGeneratorTypeID and return the IUnknown interface. 208 | */ 209 | if (CFEqual(typeID,kQLGeneratorTypeID)){ 210 | uuid = CFUUIDCreateFromString(kCFAllocatorDefault,CFSTR(PLUGIN_ID)); 211 | result = AllocQuickLookGeneratorPluginType(uuid); 212 | CFRelease(uuid); 213 | return result; 214 | } 215 | /* If the requested type is incorrect, return NULL. */ 216 | return NULL; 217 | } 218 | 219 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Java Class Quick Look 2 | This is a Quick Look plugin that lets you preview Java `.class` files as bytecode. It uses the `javap -c` command. 3 | 4 | ![](docs/readme-example.png) 5 | 6 | ## Requirements 7 | * macOS 8 | * Java installed 9 | 10 | ## Install 11 | Compile the target and copy the binary to either `/Library/QuickLook` or `~/Library/QuickLook`. 12 | --------------------------------------------------------------------------------