mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-22 19:59:29 +00:00
Preview and Quicklook stubs
This commit is contained in:
15
MacPass/KPKBinary+Quickook.h
Normal file
15
MacPass/KPKBinary+Quickook.h
Normal file
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// KPKBinary+Quickook.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 18/03/14.
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "KPKBinary.h"
|
||||
|
||||
@interface KPKBinary (Quickook)
|
||||
|
||||
- (void)quicklock;
|
||||
|
||||
@end
|
||||
17
MacPass/KPKBinary+Quickook.m
Normal file
17
MacPass/KPKBinary+Quickook.m
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// KPKBinary+Quickook.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 18/03/14.
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "KPKBinary+Quickook.h"
|
||||
#import "MPTemporaryFileStorage.h"
|
||||
@implementation KPKBinary (Quickook)
|
||||
|
||||
- (void)quicklock {
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
13
MacPass/MPPreviewViewController.h
Normal file
13
MacPass/MPPreviewViewController.h
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// MPPreviewViewController.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 18/03/14.
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPViewController.h"
|
||||
|
||||
@interface MPPreviewViewController : MPViewController
|
||||
|
||||
@end
|
||||
22
MacPass/MPPreviewViewController.m
Normal file
22
MacPass/MPPreviewViewController.m
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// MPPreviewViewController.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 18/03/14.
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPPreviewViewController.h"
|
||||
|
||||
@interface MPPreviewViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPPreviewViewController
|
||||
|
||||
- (instancetype)init {
|
||||
self = [self initWithNibName:@"PreviewView" bundle:nil];
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
23
MacPass/MPTemporaryFileStorage.h
Normal file
23
MacPass/MPTemporaryFileStorage.h
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// MPTemporaryFileStorage.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 18/03/14.
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
/**
|
||||
* Instance to handle a temporary file storage. Quicklook support uses this as a means to vent attachments to the system
|
||||
* After using the file, the storage is removed.
|
||||
*/
|
||||
|
||||
@class KPKBinary;
|
||||
|
||||
@interface MPTemporaryFileStorage : NSObject
|
||||
|
||||
- (instancetype)initWithBinary:(KPKBinary *)binary;
|
||||
|
||||
- (void)quicklook;
|
||||
|
||||
@end
|
||||
50
MacPass/MPTemporaryFileStorage.m
Normal file
50
MacPass/MPTemporaryFileStorage.m
Normal file
@@ -0,0 +1,50 @@
|
||||
;//
|
||||
// MPTemporaryFileStorage.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 18/03/14.
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPTemporaryFileStorage.h"
|
||||
#import "KPKBinary.h"
|
||||
|
||||
#import <QuickLook/QuickLook.h>
|
||||
|
||||
@interface MPTemporaryFileStorage ()
|
||||
|
||||
@property (strong) KPKBinary *binary;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPTemporaryFileStorage
|
||||
|
||||
- (instancetype)initWithBinary:(KPKBinary *)binary {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
_binary = binary;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)quicklook {
|
||||
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@_%@", [[NSProcessInfo processInfo] globallyUniqueString], self.binary.name];
|
||||
NSURL *fileURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:fileName]];
|
||||
|
||||
NSError *error;
|
||||
BOOL success = [self.binary.data writeToURL:fileURL options:0 error:&error];
|
||||
if(!success) {
|
||||
if(error) {
|
||||
[NSApp presentError:error];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
[task setLaunchPath:@"srm"];
|
||||
[task setArguments:@[@"-m", fileName]];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
20
MacPass/PreviewView.xib
Normal file
20
MacPass/PreviewView.xib
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5053" systemVersion="13C64" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment defaultVersion="1080" identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5053"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MPPreviewViewController">
|
||||
<connections>
|
||||
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application"/>
|
||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="Hz6-mo-xeY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="401" height="368"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
</customView>
|
||||
</objects>
|
||||
</document>
|
||||
Reference in New Issue
Block a user