-
Notifications
You must be signed in to change notification settings - Fork 5
/
GeneratePreviewForURL.m
28 lines (23 loc) · 1010 Bytes
/
GeneratePreviewForURL.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <QuickLook/QuickLook.h>
#include <Cocoa/Cocoa.h>
#include <torrent.h>
/* -----------------------------------------------------------------------------
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)
{
NSLog(@"Quicklook torrent thingy going!");
CFDataRef data = (CFDataRef) getTorrentPreview((NSURL*) url);
if(data){
CFDictionaryRef props = (CFDictionaryRef) [NSDictionary dictionary];
QLPreviewRequestSetDataRepresentation(preview, data, kUTTypeHTML, props);
}
return noErr;
}
void CancelPreviewGeneration(void* thisInterface, QLPreviewRequestRef preview)
{
// implement only if supported
}