Preview and Quicklook stubs

This commit is contained in:
michael starke
2014-03-18 21:42:56 +01:00
parent 6a28d03801
commit 34ba9f0575
8 changed files with 182 additions and 0 deletions

View 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

View 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

View 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

View 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

View 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

View 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
View 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>