1

Initial Commit

This commit is contained in:
Kim Wittenburg
2012-08-15 18:33:03 +02:00
commit e715f08a85
7 changed files with 630 additions and 0 deletions

View File

@@ -0,0 +1,299 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
3B19AB2515DC06BF00A9737D /* QuickLook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B19AB2415DC06BF00A9737D /* QuickLook.framework */; };
3B19AB2715DC06BF00A9737D /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B19AB2615DC06BF00A9737D /* ApplicationServices.framework */; };
3B19AB2915DC06BF00A9737D /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B19AB2815DC06BF00A9737D /* CoreServices.framework */; };
3B19AB2B15DC06BF00A9737D /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B19AB2A15DC06BF00A9737D /* CoreFoundation.framework */; };
3B19AB3115DC06BF00A9737D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3B19AB2F15DC06BF00A9737D /* InfoPlist.strings */; };
3B19AB3315DC06BF00A9737D /* GenerateThumbnailForURL.c in Sources */ = {isa = PBXBuildFile; fileRef = 3B19AB3215DC06BF00A9737D /* GenerateThumbnailForURL.c */; };
3B19AB3515DC06BF00A9737D /* GeneratePreviewForURL.c in Sources */ = {isa = PBXBuildFile; fileRef = 3B19AB3415DC06BF00A9737D /* GeneratePreviewForURL.c */; };
3B19AB3715DC06BF00A9737D /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3B19AB3615DC06BF00A9737D /* main.c */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
3B19AB2115DC06BF00A9737D /* Kara Quick View.qlgenerator */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Kara Quick View.qlgenerator"; sourceTree = BUILT_PRODUCTS_DIR; };
3B19AB2415DC06BF00A9737D /* QuickLook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickLook.framework; path = System/Library/Frameworks/QuickLook.framework; sourceTree = SDKROOT; };
3B19AB2615DC06BF00A9737D /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; };
3B19AB2815DC06BF00A9737D /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; };
3B19AB2A15DC06BF00A9737D /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
3B19AB2E15DC06BF00A9737D /* Kara Quick View-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Kara Quick View-Info.plist"; sourceTree = "<group>"; };
3B19AB3015DC06BF00A9737D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
3B19AB3215DC06BF00A9737D /* GenerateThumbnailForURL.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = GenerateThumbnailForURL.c; sourceTree = "<group>"; };
3B19AB3415DC06BF00A9737D /* GeneratePreviewForURL.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = GeneratePreviewForURL.c; sourceTree = "<group>"; };
3B19AB3615DC06BF00A9737D /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
3B19AB3815DC06BF00A9737D /* Kara Quick View-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Kara Quick View-Prefix.pch"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
3B19AB1C15DC06BF00A9737D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3B19AB2515DC06BF00A9737D /* QuickLook.framework in Frameworks */,
3B19AB2715DC06BF00A9737D /* ApplicationServices.framework in Frameworks */,
3B19AB2915DC06BF00A9737D /* CoreServices.framework in Frameworks */,
3B19AB2B15DC06BF00A9737D /* CoreFoundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
3B19AB1415DC06BF00A9737D = {
isa = PBXGroup;
children = (
3B19AB2C15DC06BF00A9737D /* Kara Quick View */,
3B19AB2315DC06BF00A9737D /* Frameworks */,
3B19AB2215DC06BF00A9737D /* Products */,
);
sourceTree = "<group>";
};
3B19AB2215DC06BF00A9737D /* Products */ = {
isa = PBXGroup;
children = (
3B19AB2115DC06BF00A9737D /* Kara Quick View.qlgenerator */,
);
name = Products;
sourceTree = "<group>";
};
3B19AB2315DC06BF00A9737D /* Frameworks */ = {
isa = PBXGroup;
children = (
3B19AB2415DC06BF00A9737D /* QuickLook.framework */,
3B19AB2615DC06BF00A9737D /* ApplicationServices.framework */,
3B19AB2815DC06BF00A9737D /* CoreServices.framework */,
3B19AB2A15DC06BF00A9737D /* CoreFoundation.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
3B19AB2C15DC06BF00A9737D /* Kara Quick View */ = {
isa = PBXGroup;
children = (
3B19AB3215DC06BF00A9737D /* GenerateThumbnailForURL.c */,
3B19AB3415DC06BF00A9737D /* GeneratePreviewForURL.c */,
3B19AB3615DC06BF00A9737D /* main.c */,
3B19AB2D15DC06BF00A9737D /* Supporting Files */,
);
path = "Kara Quick View";
sourceTree = "<group>";
};
3B19AB2D15DC06BF00A9737D /* Supporting Files */ = {
isa = PBXGroup;
children = (
3B19AB2E15DC06BF00A9737D /* Kara Quick View-Info.plist */,
3B19AB2F15DC06BF00A9737D /* InfoPlist.strings */,
3B19AB3815DC06BF00A9737D /* Kara Quick View-Prefix.pch */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
3B19AB1D15DC06BF00A9737D /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
3B19AB2015DC06BF00A9737D /* Kara Quick View */ = {
isa = PBXNativeTarget;
buildConfigurationList = 3B19AB3B15DC06BF00A9737D /* Build configuration list for PBXNativeTarget "Kara Quick View" */;
buildPhases = (
3B19AB1B15DC06BF00A9737D /* Sources */,
3B19AB1C15DC06BF00A9737D /* Frameworks */,
3B19AB1D15DC06BF00A9737D /* Headers */,
3B19AB1E15DC06BF00A9737D /* Resources */,
3B19AB1F15DC06BF00A9737D /* Rez */,
);
buildRules = (
);
dependencies = (
);
name = "Kara Quick View";
productName = "Kara Quick View";
productReference = 3B19AB2115DC06BF00A9737D /* Kara Quick View.qlgenerator */;
productType = "com.apple.product-type.bundle";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
3B19AB1615DC06BF00A9737D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0440;
};
buildConfigurationList = 3B19AB1915DC06BF00A9737D /* Build configuration list for PBXProject "Kara Quick View" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 3B19AB1415DC06BF00A9737D;
productRefGroup = 3B19AB2215DC06BF00A9737D /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
3B19AB2015DC06BF00A9737D /* Kara Quick View */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
3B19AB1E15DC06BF00A9737D /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3B19AB3115DC06BF00A9737D /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXRezBuildPhase section */
3B19AB1F15DC06BF00A9737D /* Rez */ = {
isa = PBXRezBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXRezBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
3B19AB1B15DC06BF00A9737D /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3B19AB3315DC06BF00A9737D /* GenerateThumbnailForURL.c in Sources */,
3B19AB3515DC06BF00A9737D /* GeneratePreviewForURL.c in Sources */,
3B19AB3715DC06BF00A9737D /* main.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
3B19AB2F15DC06BF00A9737D /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
3B19AB3015DC06BF00A9737D /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
3B19AB3915DC06BF00A9737D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.8;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
3B19AB3A15DC06BF00A9737D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.8;
SDKROOT = macosx;
};
name = Release;
};
3B19AB3C15DC06BF00A9737D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Kara Quick View/Kara Quick View-Prefix.pch";
INFOPLIST_FILE = "Kara Quick View/Kara Quick View-Info.plist";
INSTALL_PATH = /Library/QuickLook;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = qlgenerator;
};
name = Debug;
};
3B19AB3D15DC06BF00A9737D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Kara Quick View/Kara Quick View-Prefix.pch";
INFOPLIST_FILE = "Kara Quick View/Kara Quick View-Info.plist";
INSTALL_PATH = /Library/QuickLook;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = qlgenerator;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
3B19AB1915DC06BF00A9737D /* Build configuration list for PBXProject "Kara Quick View" */ = {
isa = XCConfigurationList;
buildConfigurations = (
3B19AB3915DC06BF00A9737D /* Debug */,
3B19AB3A15DC06BF00A9737D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
3B19AB3B15DC06BF00A9737D /* Build configuration list for PBXNativeTarget "Kara Quick View" */ = {
isa = XCConfigurationList;
buildConfigurations = (
3B19AB3C15DC06BF00A9737D /* Debug */,
3B19AB3D15DC06BF00A9737D /* Release */,
);
defaultConfigurationIsVisible = 0;
};
/* End XCConfigurationList section */
};
rootObject = 3B19AB1615DC06BF00A9737D /* Project object */;
}

View File

@@ -0,0 +1,23 @@
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <QuickLook/QuickLook.h>
OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options);
void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview);
/* -----------------------------------------------------------------------------
Generate a preview for file
This function's job is to create preview for designated file
----------------------------------------------------------------------------- */
OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options)
{
// To complete your generator please implement the function GeneratePreviewForURL in GeneratePreviewForURL.c
return noErr;
}
void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview)
{
// Implement only if supported
}

View File

@@ -0,0 +1,23 @@
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <QuickLook/QuickLook.h>
OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize);
void CancelThumbnailGeneration(void *thisInterface, QLThumbnailRequestRef thumbnail);
/* -----------------------------------------------------------------------------
Generate a thumbnail for file
This function's job is to create thumbnail for designated file as fast as possible
----------------------------------------------------------------------------- */
OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize)
{
// To complete your generator please implement the function GenerateThumbnailForURL in GenerateThumbnailForURL.c
return noErr;
}
void CancelThumbnailGeneration(void *thisInterface, QLThumbnailRequestRef thumbnail)
{
// Implement only if supported
}

View File

@@ -0,0 +1,61 @@
<?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>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>QLGenerator</string>
<key>LSItemContentTypes</key>
<array>
<string>SUPPORTED_UTI_TYPE</string>
</array>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>wittenburg.kim.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleShortVersionString</key>
<string>1</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFPlugInDynamicRegisterFunction</key>
<string></string>
<key>CFPlugInDynamicRegistration</key>
<string>NO</string>
<key>CFPlugInFactories</key>
<dict>
<key>1380FD98-3552-484E-BE36-0C32123CFB52</key>
<string>QuickLookGeneratorPluginFactory</string>
</dict>
<key>CFPlugInTypes</key>
<dict>
<key>5E2D9680-5022-40FA-B806-43349622E5B9</key>
<array>
<string>1380FD98-3552-484E-BE36-0C32123CFB52</string>
</array>
</dict>
<key>CFPlugInUnloadFunction</key>
<string></string>
<key>QLNeedsToBeRunInMainThread</key>
<false/>
<key>QLPreviewHeight</key>
<real>600</real>
<key>QLPreviewWidth</key>
<real>800</real>
<key>QLSupportsConcurrentRequests</key>
<false/>
<key>QLThumbnailMinimumSize</key>
<real>17</real>
</dict>
</plist>

View File

@@ -0,0 +1,4 @@
//
// Prefix header for all source files of the 'Kara Quick View' target in the 'Kara Quick View' project
//

View File

@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

218
Kara Quick View/main.c Normal file
View File

@@ -0,0 +1,218 @@
//==============================================================================
//
// DO NO MODIFY THE CONTENT OF THIS FILE
//
// This file contains the generic CFPlug-in code necessary for your generator
// To complete your generator implement the function in GenerateThumbnailForURL/GeneratePreviewForURL.c
//
//==============================================================================
#include <CoreFoundation/CoreFoundation.h>
#include <CoreFoundation/CFPlugInCOM.h>
#include <CoreServices/CoreServices.h>
#include <QuickLook/QuickLook.h>
// -----------------------------------------------------------------------------
// constants
// -----------------------------------------------------------------------------
// Don't modify this line
#define PLUGIN_ID "1380FD98-3552-484E-BE36-0C32123CFB52"
//
// Below is the generic glue code for all plug-ins.
//
// You should not have to modify this code aside from changing
// names if you decide to change the names defined in the Info.plist
//
// -----------------------------------------------------------------------------
// typedefs
// -----------------------------------------------------------------------------
// The thumbnail generation function to be implemented in GenerateThumbnailForURL.c
OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize);
void CancelThumbnailGeneration(void* thisInterface, QLThumbnailRequestRef thumbnail);
// The preview generation function to be implemented in GeneratePreviewForURL.c
OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options);
void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview);
// The layout for an instance of QuickLookGeneratorPlugIn
typedef struct __QuickLookGeneratorPluginType
{
void *conduitInterface;
CFUUIDRef factoryID;
UInt32 refCount;
} QuickLookGeneratorPluginType;
// -----------------------------------------------------------------------------
// prototypes
// -----------------------------------------------------------------------------
// Forward declaration for the IUnknown implementation.
//
QuickLookGeneratorPluginType *AllocQuickLookGeneratorPluginType(CFUUIDRef inFactoryID);
void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInstance);
HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv);
void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID);
ULONG QuickLookGeneratorPluginAddRef(void *thisInstance);
ULONG QuickLookGeneratorPluginRelease(void *thisInstance);
// -----------------------------------------------------------------------------
// myInterfaceFtbl definition
// -----------------------------------------------------------------------------
// The QLGeneratorInterfaceStruct function table.
//
static QLGeneratorInterfaceStruct myInterfaceFtbl = {
NULL,
QuickLookGeneratorQueryInterface,
QuickLookGeneratorPluginAddRef,
QuickLookGeneratorPluginRelease,
NULL,
NULL,
NULL,
NULL
};
// -----------------------------------------------------------------------------
// AllocQuickLookGeneratorPluginType
// -----------------------------------------------------------------------------
// Utility function that allocates a new instance.
// You can do some initial setup for the generator here if you wish
// like allocating globals etc...
//
QuickLookGeneratorPluginType *AllocQuickLookGeneratorPluginType(CFUUIDRef inFactoryID)
{
QuickLookGeneratorPluginType *theNewInstance;
theNewInstance = (QuickLookGeneratorPluginType *)malloc(sizeof(QuickLookGeneratorPluginType));
memset(theNewInstance,0,sizeof(QuickLookGeneratorPluginType));
/* Point to the function table Malloc enough to store the stuff and copy the filler from myInterfaceFtbl over */
theNewInstance->conduitInterface = malloc(sizeof(QLGeneratorInterfaceStruct));
memcpy(theNewInstance->conduitInterface,&myInterfaceFtbl,sizeof(QLGeneratorInterfaceStruct));
/* Retain and keep an open instance refcount for each factory. */
theNewInstance->factoryID = CFRetain(inFactoryID);
CFPlugInAddInstanceForFactory(inFactoryID);
/* This function returns the IUnknown interface so set the refCount to one. */
theNewInstance->refCount = 1;
return theNewInstance;
}
// -----------------------------------------------------------------------------
// DeallocQuickLookGeneratorPluginType
// -----------------------------------------------------------------------------
// Utility function that deallocates the instance when
// the refCount goes to zero.
// In the current implementation generator interfaces are never deallocated
// but implement this as this might change in the future
//
void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInstance)
{
CFUUIDRef theFactoryID;
theFactoryID = thisInstance->factoryID;
/* Free the conduitInterface table up */
free(thisInstance->conduitInterface);
/* Free the instance structure */
free(thisInstance);
if (theFactoryID){
CFPlugInRemoveInstanceForFactory(theFactoryID);
CFRelease(theFactoryID);
}
}
// -----------------------------------------------------------------------------
// QuickLookGeneratorQueryInterface
// -----------------------------------------------------------------------------
// Implementation of the IUnknown QueryInterface function.
//
HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv)
{
CFUUIDRef interfaceID;
interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault,iid);
if (CFEqual(interfaceID,kQLGeneratorCallbacksInterfaceID)){
/* If the Right interface was requested, bump the ref count,
* set the ppv parameter equal to the instance, and
* return good status.
*/
((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->GenerateThumbnailForURL = GenerateThumbnailForURL;
((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->CancelThumbnailGeneration = CancelThumbnailGeneration;
((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->GeneratePreviewForURL = GeneratePreviewForURL;
((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->CancelPreviewGeneration = CancelPreviewGeneration;
((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType*)thisInstance)->conduitInterface)->AddRef(thisInstance);
*ppv = thisInstance;
CFRelease(interfaceID);
return S_OK;
}else{
/* Requested interface unknown, bail with error. */
*ppv = NULL;
CFRelease(interfaceID);
return E_NOINTERFACE;
}
}
// -----------------------------------------------------------------------------
// QuickLookGeneratorPluginAddRef
// -----------------------------------------------------------------------------
// Implementation of reference counting for this type. Whenever an interface
// is requested, bump the refCount for the instance. NOTE: returning the
// refcount is a convention but is not required so don't rely on it.
//
ULONG QuickLookGeneratorPluginAddRef(void *thisInstance)
{
((QuickLookGeneratorPluginType *)thisInstance )->refCount += 1;
return ((QuickLookGeneratorPluginType*) thisInstance)->refCount;
}
// -----------------------------------------------------------------------------
// QuickLookGeneratorPluginRelease
// -----------------------------------------------------------------------------
// When an interface is released, decrement the refCount.
// If the refCount goes to zero, deallocate the instance.
//
ULONG QuickLookGeneratorPluginRelease(void *thisInstance)
{
((QuickLookGeneratorPluginType*)thisInstance)->refCount -= 1;
if (((QuickLookGeneratorPluginType*)thisInstance)->refCount == 0){
DeallocQuickLookGeneratorPluginType((QuickLookGeneratorPluginType*)thisInstance );
return 0;
}else{
return ((QuickLookGeneratorPluginType*) thisInstance )->refCount;
}
}
// -----------------------------------------------------------------------------
// QuickLookGeneratorPluginFactory
// -----------------------------------------------------------------------------
void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID)
{
QuickLookGeneratorPluginType *result;
CFUUIDRef uuid;
/* If correct type is being requested, allocate an
* instance of kQLGeneratorTypeID and return the IUnknown interface.
*/
if (CFEqual(typeID,kQLGeneratorTypeID)){
uuid = CFUUIDCreateFromString(kCFAllocatorDefault,CFSTR(PLUGIN_ID));
result = AllocQuickLookGeneratorPluginType(uuid);
CFRelease(uuid);
return result;
}
/* If the requested type is incorrect, return NULL. */
return NULL;
}