Skip to content

Commit fe4d163

Browse files
committed
Env in dev and launchd should be similar for testing. Using app group container.
1 parent 53359e3 commit fe4d163

29 files changed

Lines changed: 361 additions & 120 deletions

‎osx/Extensions/Action/Action.entitlements‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>com.apple.security.app-sandbox</key>
6-
<true/>
7-
<key>com.apple.security.files.user-selected.read-only</key>
8-
<true/>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.application-groups</key>
8+
<array>
9+
<string>Keybase</string>
10+
</array>
11+
<key>com.apple.security.files.user-selected.read-only</key>
12+
<true/>
913
</dict>
1014
</plist>

‎osx/Extensions/Share/Share.entitlements‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<true/>
77
<key>com.apple.security.application-groups</key>
88
<array>
9-
<string>group.keybase.Keybase</string>
9+
<string>Keybase</string>
1010
</array>
1111
<key>com.apple.security.files.user-selected.read-only</key>
1212
<true/>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.files.user-selected.read-only</key>
8+
<true/>
9+
</dict>
10+
</plist>

‎osx/FinderSync/FinderSync.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// FinderSync.h
3+
// FinderSync
4+
//
5+
// Created by Gabriel on 6/10/15.
6+
// Copyright (c) 2015 Keybase. All rights reserved.
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
#import <FinderSync/FinderSync.h>
11+
12+
@interface FinderSync : FIFinderSync
13+
14+
@end

‎osx/FinderSync/FinderSync.m‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
//
2+
// FinderSync.m
3+
// FinderSync
4+
//
5+
// Created by Gabriel on 6/10/15.
6+
// Copyright (c) 2015 Keybase. All rights reserved.
7+
//
8+
9+
#import "FinderSync.h"
10+
11+
@interface FinderSync ()
12+
13+
@property NSURL *myFolderURL;
14+
15+
@end
16+
17+
@implementation FinderSync
18+
19+
- (instancetype)init {
20+
self = [super init];
21+
22+
NSLog(@"%s launched from %@ ; compiled at %s", __PRETTY_FUNCTION__, [[NSBundle mainBundle] bundlePath], __TIME__);
23+
24+
// Set up the directory we are syncing.
25+
self.myFolderURL = [NSURL fileURLWithPath:@"/Users/Shared/MySyncExtension Documents"];
26+
[FIFinderSyncController defaultController].directoryURLs = [NSSet setWithObject:self.myFolderURL];
27+
28+
// Set up images for our badge identifiers. For demonstration purposes, this uses off-the-shelf images.
29+
[[FIFinderSyncController defaultController] setBadgeImage:[NSImage imageNamed: NSImageNameColorPanel] label:@"Status One" forBadgeIdentifier:@"One"];
30+
[[FIFinderSyncController defaultController] setBadgeImage:[NSImage imageNamed: NSImageNameCaution] label:@"Status Two" forBadgeIdentifier:@"Two"];
31+
32+
return self;
33+
}
34+
35+
#pragma mark - Primary Finder Sync protocol methods
36+
37+
- (void)beginObservingDirectoryAtURL:(NSURL *)url {
38+
// The user is now seeing the container's contents.
39+
// If they see it in more than one view at a time, we're only told once.
40+
NSLog(@"beginObservingDirectoryAtURL:%@", url.filePathURL);
41+
}
42+
43+
44+
- (void)endObservingDirectoryAtURL:(NSURL *)url {
45+
// The user is no longer seeing the container's contents.
46+
NSLog(@"endObservingDirectoryAtURL:%@", url.filePathURL);
47+
}
48+
49+
- (void)requestBadgeIdentifierForURL:(NSURL *)url {
50+
NSLog(@"requestBadgeIdentifierForURL:%@", url.filePathURL);
51+
52+
// For demonstration purposes, this picks one of our two badges, or no badge at all, based on the filename.
53+
NSInteger whichBadge = [url.filePathURL hash] % 3;
54+
NSString* badgeIdentifier = @[@"", @"One", @"Two"][whichBadge];
55+
[[FIFinderSyncController defaultController] setBadgeIdentifier:badgeIdentifier forURL:url];
56+
}
57+
58+
#pragma mark - Menu and toolbar item support
59+
60+
- (NSString *)toolbarItemName {
61+
return @"FinderSync";
62+
}
63+
64+
- (NSString *)toolbarItemToolTip {
65+
return @"FinderSync: Click the toolbar item for a menu.";
66+
}
67+
68+
- (NSImage *)toolbarItemImage {
69+
return [NSImage imageNamed:NSImageNameCaution];
70+
}
71+
72+
- (NSMenu *)menuForMenuKind:(FIMenuKind)whichMenu {
73+
// Produce a menu for the extension.
74+
NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
75+
[menu addItemWithTitle:@"Example Menu Item" action:@selector(sampleAction:) keyEquivalent:@""];
76+
77+
return menu;
78+
}
79+
80+
- (IBAction)sampleAction:(id)sender {
81+
NSURL* target = [[FIFinderSyncController defaultController] targetedURL];
82+
NSArray* items = [[FIFinderSyncController defaultController] selectedItemURLs];
83+
84+
NSLog(@"sampleAction: menu item: %@, target = %@, items = ", [sender title], [target filePathURL]);
85+
[items enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) {
86+
NSLog(@" %@", [obj filePathURL]);
87+
}];
88+
}
89+
90+
@end
91+

‎osx/FinderSync/Info.plist‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>FinderSync</string>
9+
<key>CFBundleExecutable</key>
10+
<string>$(EXECUTABLE_NAME)</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>keybase.Keybase.$(PRODUCT_NAME:rfc1034identifier)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>XPC!</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleSignature</key>
22+
<string>????</string>
23+
<key>CFBundleVersion</key>
24+
<string>1</string>
25+
<key>LSMinimumSystemVersion</key>
26+
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
27+
<key>LSUIElement</key>
28+
<true/>
29+
<key>NSExtension</key>
30+
<dict>
31+
<key>NSExtensionAttributes</key>
32+
<dict/>
33+
<key>NSExtensionPointIdentifier</key>
34+
<string>com.apple.FinderSync</string>
35+
<key>NSExtensionPrincipalClass</key>
36+
<string>FinderSync</string>
37+
</dict>
38+
<key>NSHumanReadableCopyright</key>
39+
<string>Copyright © 2015 Keybase. All rights reserved.</string>
40+
<key>NSPrincipalClass</key>
41+
<string>NSApplication</string>
42+
</dict>
43+
</plist>

‎osx/KBKit/App/KBApp.m‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#import "KBWorkspace.h"
1616
#import "KBLogFormatter.h"
1717
#import "KBEnvSelectView.h"
18+
#import "KBUninstaller.h"
1819

1920
#import <AFNetworking/AFNetworking.h>
2021

@@ -69,6 +70,16 @@ - (void)open {
6970
}];
7071
[AFNetworkReachabilityManager.sharedManager startMonitoring];
7172

73+
// Cleanup old stuff
74+
if (![userDefaults objectForKey:@"InstallVersion"]) {
75+
DDLogInfo(@"Removing old services and files");
76+
[KBUninstaller uninstall:@"keybase" completion:^(NSError *error) {}];
77+
}
78+
// Save installed version in case a later upgrade needs this info
79+
NSString *version = NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"];
80+
[userDefaults setObject:version forKey:@"InstallVersion"];
81+
[userDefaults synchronize];
82+
7283
KBEnvSelectView *envSelectView = [[KBEnvSelectView alloc] init];
7384
KBNavigationView *navigation = [[KBNavigationView alloc] initWithView:envSelectView title:@"Keybase"];
7485
KBWindow *window = [KBWindow windowWithContentView:navigation size:CGSizeMake(900, 600) retain:YES];

‎osx/KBKit/Component/KBFSService.m‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ - (void)componentDidUpdate {
3838

3939
if (self.config.installEnabled) {
4040
info[@"Launchd Plist"] = KBPath([self plistDestination], YES, NO);
41+
info[@"Program"] = [self.config commandLineForKBFS:YES escape:NO tilde:NO];
4142
}
4243

43-
info[@"Program"] = [self.config commandLineForKBFS:NO escape:YES tilde:YES];
44-
4544
if (!_infoView) _infoView = [[KBInfoView alloc] init];
4645
[_infoView setProperties:info];
4746
}

‎osx/KBKit/Component/KBInstaller.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ - (void)install:(dispatch_block_t)completion {
3636
NSArray *installActionsNeeded = [_environment installActionsNeeded];
3737

3838
KBRunOver *rover = [[KBRunOver alloc] init];
39-
rover.objects = installActionsNeeded;
39+
rover.enumerator = [installActionsNeeded objectEnumerator];
4040
rover.runBlock = ^(KBInstallAction *installAction, KBRunCompletion runCompletion) {
4141
DDLogDebug(@"Install: %@", installAction.name);
4242
[installAction.installable install:^(NSError *error) {

‎osx/KBKit/Component/KBService.m‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,9 @@ - (void)componentDidUpdate {
5757

5858
if (self.config.installEnabled) {
5959
info[@"Launchd Plist"] = KBPath([self plistDestination], YES, NO);
60+
info[@"Program"] = [self.config commandLineForService:YES escape:NO tilde:NO];
6061
}
6162

62-
info[@"Program"] = [self.config commandLineForService:NO escape:YES tilde:NO];
63-
6463
if (!_infoView) _infoView = [[KBInfoView alloc] init];
6564
[_infoView setProperties:info];
6665
}

0 commit comments

Comments
 (0)