Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for iCloud documents #1056

Merged
merged 4 commits into from
Sep 21, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Quicksilver/Code-QuickStepCore/QSDownloads.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
@interface QSDownloads : NSObject {
}
- (id)resolveProxyObject:(id)proxy;
+ (NSArray *)iCloudDocumentsForBundleID:(NSString *)bundleIdentifier;
@end
21 changes: 21 additions & 0 deletions Quicksilver/Code-QuickStepCore/QSDownloads.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,25 @@ - (id)resolveProxyObject:(id)proxy {
return nil;
}
}

+ (NSArray *)iCloudDocumentsForBundleID:(NSString *)bundleIdentifier
{
if (!bundleIdentifier) {
return nil;
}
NSString *bundleFolderName = [bundleIdentifier stringByReplacingOccurrencesOfString:@"." withString:@"~"];
NSString *documentsPath = [[pICloudDocumentsPrefix stringByAppendingPathComponent:bundleFolderName] stringByAppendingPathComponent:@"Documents"];
if ([[NSFileManager defaultManager] fileExistsAtPath:documentsPath]) {
// return a list of documents' paths
NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInteger:2], kItemFolderDepth, // iCloud only allows one level of nesting
[NSNumber numberWithBool:YES], kItemSkipItem, // don't include the parent folder
[NSArray arrayWithObject:@"public.folder"], kItemExcludeFiletypes, // ignore folders
nil];
id dirParser = [QSReg getClassInstance:@"QSDirectoryParser"];
return [dirParser objectsFromPath:documentsPath withSettings:settings];
}
return nil;
}

@end
12 changes: 10 additions & 2 deletions Quicksilver/Code-QuickStepCore/QSObject_FileHandling.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import "QSAction.h"
#import "QSObject_PropertyList.h"
#include "QSLocalization.h"
#import "QSDownloads.h"

#import "NSApplication_BLTRExtensions.h"

Expand Down Expand Up @@ -191,7 +192,8 @@ - (NSString *)detailsOfObject:(QSObject *)object {
NSString *path = [theFiles lastObject];
if ([path hasPrefix:NSTemporaryDirectory()]) {
return [@"(Quicksilver) " stringByAppendingPathComponent:[path lastPathComponent]];
} else if ([path hasPrefix:[@"~/Library/Mobile Documents/" stringByStandardizingPath]]) {
} else if ([path hasPrefix:pICloudDocumentsPrefix]) {
// when 10.6 is dropped, test ([[NSFileManager defaultManager] isUbiquitousItemAtURL:[NSURL fileURLWithPath:path]]) instead
return @"iCloud";
} else {
return [path stringByAbbreviatingWithTildeInPath];
Expand Down Expand Up @@ -544,7 +546,13 @@ - (BOOL)loadChildrenForObject:(QSObject *)object {
newChildren = [theEntry contentsScanIfNeeded:YES];
} else {
NSArray *recentDocuments = recentDocumentsForBundle(bundleIdentifier);
newChildren = [QSObject fileObjectsWithPathArray:recentDocuments];
NSArray *iCloudDocuments = [QSDownloads iCloudDocumentsForBundleID:bundleIdentifier];
// combine recent and iCloud documents, removing duplicates
NSMutableSet *childPaths = [NSMutableSet setWithArray:recentDocuments];
for (QSObject *icdoc in iCloudDocuments) {
[childPaths addObject:[icdoc objectForType:QSFilePathType]];
}
newChildren = [QSObject fileObjectsWithPathArray:[childPaths allObjects]];

for(QSObject * child in newChildren) {
[child setObject:bundleIdentifier forMeta:@"QSPreferredApplication"];
Expand Down
1 change: 1 addition & 0 deletions Quicksilver/Code-QuickStepCore/QSPaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define pStateLocation [@"~/Library/Caches/Quicksilver/QuicksilverState.plist" stringByStandardizingPath]
#define pCrashReporterFolder [@"~/Library/Logs/DiagnosticReports" stringByStandardizingPath]
#define pShelfLocation QSApplicationSupportSubPath(@"Shelves/", NO)
#define pICloudDocumentsPrefix [@"~/Library/Mobile Documents/" stringByStandardizingPath]

#define psMainPlugInsLocation QSApplicationSupportSubPath(@"PlugIns/", NO)
#define psMainPlugInsToInstallLocation QSApplicationSupportSubPath(@"PlugIns/Incoming/", NO)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// QSICloudDocumentSource.h
// Quicksilver
//
// Created by Rob McBroom on 2012/08/20.
//
//

#import <QSCore/QSCore.h>

@interface QSICloudDocumentSource : QSObjectSource
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// QSICloudDocumentSource.m
// Quicksilver
//
// Created by Rob McBroom on 2012/08/20.
//
//

#import "QSICloudDocumentSource.h"
#import "QSDownloads.h"

@implementation QSICloudDocumentSource

- (NSArray *)objectsForEntry:(NSDictionary *)theEntry
{
NSMutableArray *objects = [NSMutableArray array];
NSArray *ICloudEnabledApplications = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:pICloudDocumentsPrefix error:nil];
for (NSString *appBundleID in ICloudEnabledApplications) {
// technically, these aren't bundle IDs (they already use ~ instead of .)
// but they'll work with the iCloudDocumentsForBundleID method
[objects addObjectsFromArray:[QSDownloads iCloudDocumentsForBundleID:appBundleID]];
}
return objects;
}

@end
14 changes: 13 additions & 1 deletion Quicksilver/PlugIns-Main/QSCorePlugIn/QSCorePlugIn-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,16 @@
<key>ID</key>
<string>QSPresetDocuments</string>
</dict>
<dict>
<key>source</key>
<string>QSICloudDocumentSource</string>
<key>icon</key>
<string>iDiskGenericIcon</string>
<key>ID</key>
<string>QSPresetICloudDocuments</string>
<key>requiresPath</key>
<string>~/Library/Mobile Documents</string>
</dict>
<dict>
<key>source</key>
<string>QSFileSystemObjectSource</string>
Expand Down Expand Up @@ -702,7 +712,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>98</string>
<string>99</string>
<key>QSTriggerAdditions</key>
<array>
<dict>
Expand Down Expand Up @@ -1913,6 +1923,8 @@
<string>QSVolumesObjectSource</string>
<key>QSGroupObjectSource</key>
<string>QSGroupObjectSource</string>
<key>QSICloudDocumentSource</key>
<string>QSICloudDocumentSource</string>
</dict>
<key>QSFileActionCreators</key>
<dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<string>Downloads</string>
<key>QSPresetDocuments</key>
<string>Documents</string>
<key>QSPresetICloudDocuments</key>
<string>iCloud Documents</string>
<key>QSPresetAccounts</key>
<string>User Accounts</string>
<key>QSPresetProxies</key>
Expand Down
6 changes: 6 additions & 0 deletions Quicksilver/Quicksilver.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@
CDE6C624157E39AE006E66BD /* QSFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE6C623157E39AE006E66BD /* QSFoundation.h */; settings = {ATTRIBUTES = (Public, ); }; };
CDE8ADBB15824E3E0099CC83 /* NDKeyboardLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE8ADB915824E3E0099CC83 /* NDKeyboardLayout.h */; settings = {ATTRIBUTES = (Public, ); }; };
CDE8ADBC15824E3E0099CC83 /* NDKeyboardLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE8ADBA15824E3E0099CC83 /* NDKeyboardLayout.m */; };
D439387E15E2C4CF008F6548 /* QSICloudDocumentSource.m in Sources */ = {isa = PBXBuildFile; fileRef = D439387D15E2C4CF008F6548 /* QSICloudDocumentSource.m */; };
D493990D1350078E00B908C6 /* QSDownloads.h in Headers */ = {isa = PBXBuildFile; fileRef = D49399091350078E00B908C6 /* QSDownloads.h */; };
D493990E1350078E00B908C6 /* QSDownloads.m in Sources */ = {isa = PBXBuildFile; fileRef = D493990A1350078E00B908C6 /* QSDownloads.m */; };
D4A43887137CCF0300F15F7F /* QSURLExtractor.py in Resources */ = {isa = PBXBuildFile; fileRef = D4A4383B137CCCF500F15F7F /* QSURLExtractor.py */; };
Expand Down Expand Up @@ -1413,6 +1414,8 @@
CDE6C623157E39AE006E66BD /* QSFoundation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QSFoundation.h; sourceTree = "<group>"; };
CDE8ADB915824E3E0099CC83 /* NDKeyboardLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NDKeyboardLayout.h; sourceTree = "<group>"; };
CDE8ADBA15824E3E0099CC83 /* NDKeyboardLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NDKeyboardLayout.m; sourceTree = "<group>"; };
D439387C15E2C4CF008F6548 /* QSICloudDocumentSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QSICloudDocumentSource.h; sourceTree = "<group>"; };
D439387D15E2C4CF008F6548 /* QSICloudDocumentSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QSICloudDocumentSource.m; sourceTree = "<group>"; };
D49399091350078E00B908C6 /* QSDownloads.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QSDownloads.h; sourceTree = "<group>"; };
D493990A1350078E00B908C6 /* QSDownloads.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QSDownloads.m; sourceTree = "<group>"; };
D4A4383B137CCCF500F15F7F /* QSURLExtractor.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = QSURLExtractor.py; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2409,6 +2412,8 @@
7FADDCE008B4D805004559C1 /* QSHistoryObjectSource.m */,
E180010907B2B48900010DB0 /* QSHTMLLinkParser.h */,
E180010A07B2B48900010DB0 /* QSHTMLLinkParser.m */,
D439387C15E2C4CF008F6548 /* QSICloudDocumentSource.h */,
D439387D15E2C4CF008F6548 /* QSICloudDocumentSource.m */,
E180010F07B2B48900010DB0 /* QSObject+ColorHandling.h */,
E180011007B2B48900010DB0 /* QSObject+ColorHandling.m */,
7FDF328707F7B11800594789 /* QSObjectActions.h */,
Expand Down Expand Up @@ -4277,6 +4282,7 @@
E180013E07B2B48900010DB0 /* QSTextSource.m in Sources */,
7F9441E80803ABB1007EDC31 /* QSVolumesObjectSource.m in Sources */,
E180014007B2B48900010DB0 /* QSWebSource.m in Sources */,
D439387E15E2C4CF008F6548 /* QSICloudDocumentSource.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down