Skip to content

Commit

Permalink
QuickLook Plug-in
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakey committed Nov 15, 2018
1 parent 16c42ba commit 06a5036
Show file tree
Hide file tree
Showing 38 changed files with 456 additions and 114 deletions.
10 changes: 4 additions & 6 deletions ProfilesManager.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
B80FCFC31E4AAE480044098D /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = B80FCFC51E4AAE480044098D /* Localizable.strings */; };
B81B6A782195470500A8580F /* ProfilesManagerWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B81B6A7A2195470500A8580F /* ProfilesManagerWindowController.xib */; };
B843F36E20897BAD00C1679C /* ProfilesManagerWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = B843F36C20897BAD00C1679C /* ProfilesManagerWindowController.m */; };
B8B8EE1B219C1BCA00F75DC4 /* DragOutlineRowView.m in Sources */ = {isa = PBXBuildFile; fileRef = B8B8EE1A219C1BCA00F75DC4 /* DragOutlineRowView.m */; };
B84700C9219D4B33007CDAE2 /* ProvisionQL.qlgenerator in Resources */ = {isa = PBXBuildFile; fileRef = B84700C8219D4B33007CDAE2 /* ProvisionQL.qlgenerator */; };
B8BCD2401E6CEFCB00ABD2A6 /* iAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = B8BCD23F1E6CEFCB00ABD2A6 /* iAlert.m */; };
B8C823BE1E0288D9004BEAEF /* NSData+JKBase64.m in Sources */ = {isa = PBXBuildFile; fileRef = B8C823BD1E0288D8004BEAEF /* NSData+JKBase64.m */; };
B8F694BB204D3ADF0048F3E6 /* PreviewViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B8F694B9204D3ADF0048F3E6 /* PreviewViewController.m */; };
Expand Down Expand Up @@ -108,9 +108,8 @@
B833BA571E4B1C5C003FF745 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/MainMenu.strings"; sourceTree = "<group>"; };
B843F36B20897BAD00C1679C /* ProfilesManagerWindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProfilesManagerWindowController.h; sourceTree = "<group>"; };
B843F36C20897BAD00C1679C /* ProfilesManagerWindowController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProfilesManagerWindowController.m; sourceTree = "<group>"; };
B84700C8219D4B33007CDAE2 /* ProvisionQL.qlgenerator */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = ProvisionQL.qlgenerator; sourceTree = "<group>"; };
B856B7801E25EDC800060107 /* ProfilesManager.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ProfilesManager.entitlements; sourceTree = "<group>"; };
B8B8EE19219C1BCA00F75DC4 /* DragOutlineRowView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DragOutlineRowView.h; sourceTree = "<group>"; };
B8B8EE1A219C1BCA00F75DC4 /* DragOutlineRowView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DragOutlineRowView.m; sourceTree = "<group>"; };
B8BCD23E1E6CEFCB00ABD2A6 /* iAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iAlert.h; sourceTree = "<group>"; };
B8BCD23F1E6CEFCB00ABD2A6 /* iAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iAlert.m; sourceTree = "<group>"; };
B8C823BC1E0288D8004BEAEF /* NSData+JKBase64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+JKBase64.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -156,6 +155,7 @@
A211931B1AF1CA5B0064CA7D /* ProfilesManager */ = {
isa = PBXGroup;
children = (
B84700C8219D4B33007CDAE2 /* ProvisionQL.qlgenerator */,
B856B7801E25EDC800060107 /* ProfilesManager.entitlements */,
B8FF31C021929EA40022C658 /* Manager */,
B8BCD23D1E6CEFC500ABD2A6 /* Vendor */,
Expand Down Expand Up @@ -233,8 +233,6 @@
children = (
A2A8FA881AFA43E10087DD68 /* DragOutlineView.m */,
A2A8FA891AFA43E10087DD68 /* DragOutlineView.h */,
B8B8EE19219C1BCA00F75DC4 /* DragOutlineRowView.h */,
B8B8EE1A219C1BCA00F75DC4 /* DragOutlineRowView.m */,
);
path = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -396,6 +394,7 @@
A244DCBB1AFA0A2E00EB7E61 /* ProfilesManagerViewController.xib in Resources */,
B804235D2192BD9100AD899F /* GitHubTemplate.pdf in Resources */,
B804235F2192BD9100AD899F /* GitHubInstallWindowController.xib in Resources */,
B84700C9219D4B33007CDAE2 /* ProvisionQL.qlgenerator in Resources */,
B804235E2192BD9100AD899F /* GitHubProgressWindowController.xib in Resources */,
B8F694BC204D3ADF0048F3E6 /* PreviewViewController.xib in Resources */,
B80FCFC31E4AAE480044098D /* Localizable.strings in Resources */,
Expand All @@ -422,7 +421,6 @@
A21193221AF1CA5B0064CA7D /* main.m in Sources */,
B8C823BE1E0288D9004BEAEF /* NSData+JKBase64.m in Sources */,
B804236A2192BD9100AD899F /* GitHubInstallWindowController.m in Sources */,
B8B8EE1B219C1BCA00F75DC4 /* DragOutlineRowView.m in Sources */,
B804235B2192BD9100AD899F /* GitHubReleaseAsset.m in Sources */,
B8BCD2401E6CEFCB00ABD2A6 /* iAlert.m in Sources */,
A21193201AF1CA5B0064CA7D /* AppDelegate.m in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion ProfilesManager/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// AppDelegate.h
// ProfilesTool
// ProfilesManager
//
// Created by Jakey on 15/4/30.
// Copyright (c) 2015年 Jakey. All rights reserved.
Expand Down
12 changes: 10 additions & 2 deletions ProfilesManager/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// AppDelegate.m
// ProfilesTool
// ProfilesManager
//
// Created by Jakey on 15/4/30.
// Copyright (c) 2015年 Jakey. All rights reserved.
Expand All @@ -22,6 +22,11 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
_window = [[ProfilesManagerWindowController alloc] initWithWindowNibName:@"ProfilesManagerWindowController"];
_window.contentViewController = [[ProfilesManagerViewController alloc] initWithNibName:@"ProfilesManagerViewController" bundle:[NSBundle bundleForClass:[self class]]];
[_window.window orderFront:nil];

NSMenuItem *helpMenu = [_window.window.menu itemWithTag:666];
NSMenuItem *submenuItem = [helpMenu.submenu itemAtIndex:0];;
submenuItem.action = @selector(showHelp:);
submenuItem.target = self;
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
{
Expand All @@ -31,5 +36,8 @@ - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisible
}
return YES;
}

- (void)showHelp:(id)sender
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://github.com/shaojiankui/ProfilesManager"]];
}
@end
13 changes: 13 additions & 0 deletions ProfilesManager/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@
"Are you sure move selected items to trash?" = "Are you sure move selected items to trash?"
"Export" = "Export";
"Beautify Filename" = "Beautify Filename";
"Provision QuickLook Plug-in is already Installed" = "Provision QuickLook Plug-in is already Installed";
"What opration do you want?" = "What opration do you want?";
"Back" = "Back";
"Uninstall" = "Uninstall";
"Uninstall Success" = "Uninstall Success";
"Uninstall Failure" = "Uninstall Failure";
"the plug-in can view the .ipa/.xcarchive/.appex/.mobileprovision/.provisionprofile files directly use the the blank space key." = "the plug-in can view the .ipa/.xcarchive/.appex/.mobileprovision/.provisionprofile files directly use the the blank space key.";
"the plug-in sourcecode can view at" = "the plug-in sourcecode can view at";
"Install Provision QuickLook Plug-in" = "Install Provision QuickLook Plug-in";
"Install" = "Install";
"Install Success" = "Install Success";
"Install Failure" = "Install Failure";

6 changes: 3 additions & 3 deletions ProfilesManager/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.18"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand Down Expand Up @@ -649,7 +649,7 @@
</items>
</menu>
</menuItem>
<menuItem title="Help" id="wpr-3q-Mcd">
<menuItem title="Help" tag="666" id="wpr-3q-Mcd">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Help" systemMenu="help" id="F2S-fz-NVQ">
<items>
Expand Down
3 changes: 2 additions & 1 deletion ProfilesManager/Category/NSFileManager+Trash.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@

- (NSString *)mr_uniqueFileNameWithPath:(NSString *)aPath;
- (BOOL)mr_moveFileAtPathToTrash:(NSString *)aPath error:(NSError **)outError;

//获取sandbox之外的路径
- (NSString *)realHomeDirectory;
@end
15 changes: 14 additions & 1 deletion ProfilesManager/Category/NSFileManager+Trash.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ @implementation NSFileManager (Trash)
// 3. This notice may not be removed or altered from any source
// distribution.
//

//获取sandbox之外的路径
- (NSString *)realHomeDirectory{
// struct passwd *pw = getpwuid(getuid());
// assert(pw);
// return [NSString stringWithUTF8String:pw->pw_dir];
//
NSString *home = NSHomeDirectory();
NSArray *pathArray = [home componentsSeparatedByString:@"/"];
NSString *absolutePath;
if ([pathArray count] > 2) {
absolutePath = [NSString stringWithFormat:@"/%@/%@", [pathArray objectAtIndex:1], [pathArray objectAtIndex:2]];
}
return absolutePath;
}
// Adapted from UliKit by Uli Kusterer (thanks):
// http://github.com/uliwitness/UliKit/blob/master/NSFileManager+NameForTempFile.m
NSString *Trash_RealHomeDirectory() {
Expand Down
2 changes: 1 addition & 1 deletion ProfilesManager/Category/NSOutlineView+Menu.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// NSOutlineView+Menu.h
// ProfilesTool
// ProfilesManager
//
// Created by Jakey on 15/5/6.
// Copyright (c) 2015年 Jakey. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion ProfilesManager/Category/NSOutlineView+Menu.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// NSOutlineView+Menu.m
// ProfilesTool
// ProfilesManager
//
// Created by Jakey on 15/5/6.
// Copyright (c) 2015年 Jakey. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@
<action selector="resetButtonTouched:" target="-2" id="Uy0-gz-nl2"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="7433B6B3-69C5-49F7-90E0-1EAD36365A2B" label="QuickLook" paletteLabel="QuickLook" tag="-1" image="NSQuickLookTemplate" sizingBehavior="auto" id="OYD-Cz-Amx">
<connections>
<action selector="quickLookTouched:" target="-2" id="vZr-Wc-hDl"/>
</connections>
</toolbarItem>
</allowedToolbarItems>
<defaultToolbarItems>
<toolbarItem reference="RbJ-X4-SVv"/>
<toolbarItem reference="YQD-l5-tAa"/>
<toolbarItem reference="OYD-Cz-Amx"/>
<toolbarItem reference="rz2-bg-kUw"/>
<toolbarItem reference="RdP-pm-wWl"/>
<toolbarItem reference="TqD-HL-i0O"/>
Expand All @@ -83,11 +89,12 @@
<connections>
<outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
</connections>
<point key="canvasLocation" x="-38" y="50"/>
<point key="canvasLocation" x="-62" y="41"/>
</window>
</objects>
<resources>
<image name="NSActionTemplate" width="14" height="14"/>
<image name="NSQuickLookTemplate" width="19" height="12"/>
<image name="NSRefreshFreestandingTemplate" width="14" height="14"/>
</resources>
</document>
2 changes: 1 addition & 1 deletion ProfilesManager/Controller/PreviewViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// PreviewViewController.h
// ProfilesManager
//
// Created by runlin on 2018/3/5.
// Created by Jakey on 2018/3/5.
// Copyright © 2018年 Jakey. All rights reserved.
//

Expand Down
2 changes: 1 addition & 1 deletion ProfilesManager/Controller/PreviewViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// PreviewViewController.m
// ProfilesManager
//
// Created by runlin on 2018/3/5.
// Created by Jakey on 2018/3/5.
// Copyright © 2018年 Jakey. All rights reserved.
//

Expand Down
2 changes: 1 addition & 1 deletion ProfilesManager/Controller/ProfilesManagerViewController.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// ProfilesToolViewController.h
// ProfilesTool
// ProfilesManager
//
// Created by Jakey on 15/4/30.
// Copyright (c) 2015年 Jakey. All rights reserved.
Expand Down
58 changes: 13 additions & 45 deletions ProfilesManager/Controller/ProfilesManagerViewController.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// ProfilesToolViewController.m
// ProfilesTool
// ProfilesManager
//
// Created by Jakey on 15/4/30.
// Copyright (c) 2015年 Jakey. All rights reserved.
Expand All @@ -13,7 +13,7 @@
#import "iAlert.h"
#import "PreviewViewController.h"
#import "PlistManager.h"
#import "DragOutlineRowView.h"

//#include <unistd.h>
//#include <sys/types.h>
//#include <pwd.h>
Expand All @@ -27,26 +27,12 @@
static NSString *kColumnIdentifierCreateDate = @"creationDate";

@implementation ProfilesManagerViewController
//获取sandbox之外的路径
NSString *RealHomeDirectory() {
// struct passwd *pw = getpwuid(getuid());
// assert(pw);
// return [NSString stringWithUTF8String:pw->pw_dir];
//
NSString *home = NSHomeDirectory();
NSArray *pathArray = [home componentsSeparatedByString:@"/"];
NSString *absolutePath;
if ([pathArray count] > 2) {
absolutePath = [NSString stringWithFormat:@"/%@/%@", [pathArray objectAtIndex:1], [pathArray objectAtIndex:2]];
}
return absolutePath;
}


- (void)viewDidLoad {
[super viewDidLoad];
// Do view setup here.
_profileDir = [NSString stringWithFormat:@"%@/Library/MobileDevice/Provisioning Profiles/", RealHomeDirectory()];
_profileDir = [NSString stringWithFormat:@"%@/Library/MobileDevice/Provisioning Profiles/", [[NSFileManager defaultManager] realHomeDirectory]];

//当拖拽窗口大小,NSOutlineView frame自动更改时,Column宽等比增减
[self.treeView setColumnAutoresizingStyle:NSTableViewUniformColumnAutoresizingStyle];
Expand All @@ -65,7 +51,8 @@ - (void)viewDidLoad {
[[NSFileManager defaultManager]copyItemAtPath:result toPath:[_profileDir stringByAppendingString:[result lastPathComponent]?:@""] error:&error];
if(error)
{
[self showMessage:[error localizedDescription] completionHandler:^(NSModalResponse returnCode) {
[iAlert showMessage:[error localizedDescription]
window:self.view.window completionHandler:^(NSModalResponse returnCode) {

}];
}
Expand Down Expand Up @@ -118,11 +105,7 @@ - (void)loadProfileFilesWithSearchWord:(NSString*)searchWord {


#pragma mark - Outline
- (nullable NSTableRowView *)outlineView:(NSOutlineView *)outlineView rowViewForItem:(id)item{
DragOutlineRowView *row = [[DragOutlineRowView alloc] init];
row.identifier = @"row";
return row;
}

- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item{
ProfilesNode *realItem = item ?: _rootNode;
return [realItem.childrenNodes count];
Expand Down Expand Up @@ -470,7 +453,9 @@ - (void)exportItemClick:(id)sender {

NSSavePanel *savePanel = [NSSavePanel savePanel];
savePanel.allowedFileTypes = @[@"mobileprovision",@"provisionprofile"];
savePanel.nameFieldStringValue = node.key;
savePanel.nameFieldStringValue = node.type?:node.key;
savePanel.extensionHidden = NO;

[savePanel beginSheetModalForWindow:self.view.window completionHandler:^(NSInteger result) {
NSString *savePath = savePanel.URL.path;
if (result == NSFileHandlingPanelOKButton) {
Expand All @@ -495,14 +480,14 @@ - (void)importItemClick:(id)sender{
[oPanel setDirectoryURL:[NSURL URLWithString:NSHomeDirectory()]];
[oPanel setAllowedFileTypes:@[@"mobileprovision", @"MOBILEPROVISION"]];

if ([oPanel runModal] == NSOKButton) {
if ([oPanel runModal] == NSModalResponseOK) {
NSString *path =[[[oPanel URLs] objectAtIndex:0] path];

[[NSFileManager defaultManager]copyItemAtPath:path toPath:[_profileDir stringByAppendingString:[path lastPathComponent]?:@""] error:&error];
}
if(error)
{
[self showMessage:[error localizedDescription] completionHandler:^(NSModalResponse returnCode) {
[iAlert showMessage:[error localizedDescription] window:self.view.window completionHandler:^(NSModalResponse returnCode) {

}];
}
Expand All @@ -521,7 +506,7 @@ - (void)exportCerItemClick:(id)sender
[oPanel setCanChooseDirectories:YES];
[oPanel setCanChooseFiles:NO];
[oPanel setDirectoryURL:[NSURL URLWithString:NSHomeDirectory()]];
if ([oPanel runModal] == NSOKButton) {
if ([oPanel runModal] == NSModalResponseOK) {
NSString *path =[[[oPanel URLs] objectAtIndex:0] path];
NSString *savePath = [[path stringByAppendingPathComponent:[node.extra objectForKey:@"summary"] ]stringByAppendingPathExtension:@"cer"];

Expand All @@ -548,7 +533,7 @@ - (BOOL)deleteProfile:(NSString*)filePath option:(BOOL)completely {
}
if(error)
{
[self showMessage:[error localizedDescription] completionHandler:^(NSModalResponse returnCode) {
[iAlert showMessage:[error localizedDescription] window:self.view.window completionHandler:^(NSModalResponse returnCode) {

}];
}
Expand All @@ -575,22 +560,5 @@ - (BOOL)deleteProfile:(NSString*)filePath option:(BOOL)completely {
// }
// return result;
//}
#pragma mark --alert
- (void)showMessage:(NSString*)message completionHandler:(void (^)(NSModalResponse returnCode))handler{
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:message];
[alert beginSheetModalForWindow:self.view.window completionHandler:^(NSModalResponse returnCode) {
handler(returnCode);
}];

}

- (void)showAlert:(NSAlertStyle)style title:(NSString *)title message:(NSString *)message {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
[alert setMessageText:title];
[alert setInformativeText:message];
[alert setAlertStyle:style];
[alert runModal];
}
@end
Loading

0 comments on commit 06a5036

Please sign in to comment.