forked from iMediaSandboxing/iMedia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIMBAccessRightsViewController.m
740 lines (560 loc) · 24.7 KB
/
IMBAccessRightsViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
/*
iMedia Browser Framework <http://karelia.com/imedia/>
Copyright (c) 2005-2012 by Karelia Software et al.
iMedia Browser is based on code originally developed by Jason Terhorst,
further developed for Sandvox by Greg Hulands, Dan Wood, and Terrence Talbot.
The new architecture for version 2.0 was developed by Peter Baumgartner.
Contributions have also been made by Matt Gough, Martin Wennerberg and others
as indicated in source files.
The iMedia Browser Framework is licensed under the following terms:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in all or substantial portions of the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following
conditions:
Redistributions of source code must retain the original terms stated here,
including this list of conditions, the disclaimer noted below, and the
following copyright notice: Copyright (c) 2005-2012 by Karelia Software et al.
Redistributions in binary form must include, in an end-user-visible manner,
e.g., About window, Acknowledgments window, or similar, either a) the original
terms stated here, including this list of conditions, the disclaimer noted
below, and the aforementioned copyright notice, or b) the aforementioned
copyright notice and a link to karelia.com/imedia.
Neither the name of Karelia Software, nor Sandvox, nor the names of
contributors to iMedia Browser may be used to endorse or promote products
derived from the Software without prior and express written permission from
Karelia Software or individual contributors, as appropriate.
Disclaimer: THE SOFTWARE IS PROVIDED BY THE COPYRIGHT OWNER AND CONTRIBUTORS
"AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH, THE
SOFTWARE OR THE USE OF, OR OTHER DEALINGS IN, THE SOFTWARE.
*/
//----------------------------------------------------------------------------------------------------------------------
// Author: Peter Baumgartner, Jörg Jacobsen
//----------------------------------------------------------------------------------------------------------------------
#pragma mark HEADERS
#import "IMBAccessRightsViewController.h"
#import "IMBAccessRightsController.h"
#import "IMBLibraryController.h"
#import "IMBParserMessenger.h"
#import "NSFileManager+iMedia.h"
#import "IMBNode.h"
#import "IMBObject.h"
#import "IMBConfig.h"
#import "SBUtilities.h"
#import "IMBFileSystemObserver.h"
#import "IMBAlertPopover.h"
#import "NSImage+iMedia.h"
#import "NSURL+iMedia.h"
#import "NSString+iMedia.h"
#import "NSFileManager+iMedia.h"
#import "NSObject+iMedia.h"
//----------------------------------------------------------------------------------------------------------------------
#pragma mark TYPES
typedef void (^IMBOpenPanelCompletionHandler)(NSURL* inURL);
//----------------------------------------------------------------------------------------------------------------------
#pragma mark
@interface IMBAccessRightsViewController ()
@end
//----------------------------------------------------------------------------------------------------------------------
#pragma mark
@implementation IMBAccessRightsViewController
//----------------------------------------------------------------------------------------------------------------------
#pragma mark
#pragma mark Lifetime
+ (NSBundle*) bundle
{
return [NSBundle bundleForClass:[self class]];
}
+ (NSString*) nibName
{
return @"IMBAccessRightsViewController";
}
//----------------------------------------------------------------------------------------------------------------------
// Returns a singleton instance of the IMBEntitlementsController...
+ (IMBAccessRightsViewController*) sharedViewController;
{
static IMBAccessRightsViewController* sSharedViewController = nil;
static dispatch_once_t sOnceToken = 0;
dispatch_once(&sOnceToken,
^{
sSharedViewController = [[IMBAccessRightsViewController alloc] init];
});
return sSharedViewController;
}
- (id) init
{
if (self = [super initWithNibName:[[self class] nibName] bundle:[[self class] bundle]])
{
}
return self;
}
- (void) dealloc
{
[self imb_cancelAllCoalescedSelectors];
[super dealloc];
}
//----------------------------------------------------------------------------------------------------------------------
#pragma mark
#pragma mark User Interface
- (void) _showForSuggestedURL:(NSURL*)inSuggestedURL name:(NSString*)inName completionHandler:(IMBOpenPanelCompletionHandler)inCompletionBlock;
{
// Customize an NSOpenPanel so that it explains why the user needs to allow access...
NSOpenPanel* panel = [NSOpenPanel openPanel];
panel.canChooseDirectories = YES;
panel.allowsMultipleSelection = NO;
panel.canCreateDirectories = NO;
panel.accessoryView = self.view;
[panel setDirectoryURL:inSuggestedURL];
NSString* title = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.openPanel.title",
nil,
IMBBundle(),
@"Allow Access to Media Files",
@"NSOpenPanel title");
if (inName)
{
title = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.openPanel.titleWithName",
nil,
IMBBundle(),
@"Allow Access to %@",
@"NSOpenPanel title");
title = [NSString stringWithFormat:title,inName];
}
panel.title = title;
panel.message = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.openPanel.message",
nil,
IMBBundle(),
@"Click the \"Allow\" button to grant access to your media files.",
@"NSOpenPanel message");
panel.prompt = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.openPanel.prompt",
nil,
IMBBundle(),
@"Allow",
@"NSOpenPanel button");
_warningTitle.stringValue = title;
NSString* appName = [[NSProcessInfo processInfo] processName];
NSString* format = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.openPanel.description",
nil,
IMBBundle(),
@"Due to system security features that protect your data from malicious attacks, %@ does not have the necessary rights to access your media files. To give %@ access to your media files click the \"Allow\" button.",
@"NSOpenPanel description");
_warningMessage.stringValue = [NSString stringWithFormat:format,appName,appName];
// Run the NSOpenPanel. Please note the special saving and restoring of keyWindow. This is essential here, or
// the Powerbox will become unresponsive the second time we try to call it. Then call the completion block...
NSWindow* keyWindow = [NSApp keyWindow];
NSInteger button = [panel runModal];
if (button == NSFileHandlingPanelOKButton)
{
NSURL* url = [panel URL];
inCompletionBlock(url);
}
else
{
inCompletionBlock(nil);
}
[keyWindow makeKeyWindow];
}
//----------------------------------------------------------------------------------------------------------------------
// Note that this is an empty operation if not sandboxed.
- (void) grantAccessRightsForObjectsOfNode:(IMBNode*)inNode
{
if (SBIsSandboxed() && inNode.objects.count > 0 && inNode.badgeTypeNormal != kIMBBadgeTypeLoading)
{
IMBLibraryController* libraryController = [IMBLibraryController sharedLibraryControllerWithMediaType:inNode.mediaType];
// Get ancestor folder that encloses all objects for this node (usually the selected node)...
NSMutableArray* urls = [NSMutableArray arrayWithCapacity:inNode.objects.count];
for (IMBObject* object in inNode.objects)
{
if (object.accessibility == kIMBResourceNoPermission)
{
[urls addObject:object.location];
}
}
NSURL* proposedURL = [IMBAccessRightsController commonAncestorForURLs:urls];
// Show an NSOpenPanel to grant access to this folder...
[self _showForSuggestedURL:proposedURL name:inNode.name completionHandler:^(NSURL* inGrantedURL)
{
if (inGrantedURL)
{
NSData* bookmark = [IMBAccessRightsController bookmarkForURL:inGrantedURL];
inNode.badgeTypeNormal = kIMBBadgeTypeLoading;
inNode.accessibility = kIMBResourceIsAccessible; // Temporarily, so that loading wheel shows again
IMBParserMessenger* messenger = inNode.parserMessenger;
SBPerformSelectorAsync(messenger.connection,
messenger,
@selector(addAccessRightsBookmark:error:),
bookmark,
dispatch_get_main_queue(),
^(NSURL* inReceivedURL,NSError* inError)
{
if (inError == nil)
{
[libraryController reloadNodeTree:inNode];
}
});
}
}];
}
}
//----------------------------------------------------------------------------------------------------------------------
// Note that this is an empty operation (except for completion handler) if not sandboxed.
// In that case only completion handler will be called (synchronously)
+ (void) grantAccessRightsForFolder:(IMBParserMessenger*)inFolderParserMessenger completionHandler:(void(^)(void))inCompletionHandler
{
if (SBIsSandboxed())
{
IMBParserMessenger* messenger = inFolderParserMessenger;
void(^completionHandler)(void) = [inCompletionHandler copy];
// Create bookmark...
NSURL* url = messenger.mediaSource;
NSData* bookmark = [IMBAccessRightsController bookmarkForURL:url];
// Send it to the XPC service, so it has access to the folder...
SBPerformSelectorAsync(messenger.connection,
messenger,
@selector(addAccessRightsBookmark:error:),
bookmark,
dispatch_get_main_queue(),
^(NSURL* inReceivedURL,NSError* inError)
{
if (inError) {
NSLog(@"%s url=%@ error=%@",__FUNCTION__,inReceivedURL,inError);
}
completionHandler();
[completionHandler release];
});
// Also send it to the FSEvents service, so that it can do its job...
[[IMBFileSystemObserver sharedObserver] addAccessRights:bookmark];
} else {
inCompletionHandler();
}
}
//----------------------------------------------------------------------------------------------------------------------
+ (void) showMissingResourceAlertForNode:(IMBNode*)inNode view:(NSView*)inView relativeToRect:(NSRect)inRect
{
NSString* name = inNode.name;
NSString* volume = [inNode.libraryRootURL imb_externalVolumeName];
BOOL mounted = [[NSFileManager defaultManager] imb_isVolumeMounted:volume];
// For missing libraries alert the user that we cannot use this node...
if (volume == nil || mounted)
{
NSString* title = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.missingLibraryTitle",
nil,
IMBBundle(),
@"Library is Missing",
@"Alert title");
NSString* format = inNode.error.localizedDescription;
if (format == nil) {
format = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.missingLibraryMessage",
nil,
IMBBundle(),
@"The %@ library cannot be used because it is missing. It may have been deleted, moved, or renamed.",
@"Alert message");
}
NSString* ok = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.missingLibraryButton",
nil,
IMBBundle(),
@" OK ",
@"Alert button");
NSString* message = [NSString stringWithFormat:format,name];
if (IMBRunningOnLionOrNewer() && inView.window != nil)
{
IMBAlertPopover* alert = [IMBAlertPopover warningPopoverWithHeader:title body:message footer:nil];
alert.icon = [NSImage imb_imageNamed:@"IMBStopIcon.icns"];
[alert addButtonWithTitle:ok block:^()
{
[alert close];
}];
[alert showRelativeToRect:inRect ofView:inView preferredEdge:NSMaxYEdge];
}
else
{
NSAlert* alert = [NSAlert
alertWithMessageText:title
defaultButton:ok
alternateButton:nil
otherButton:nil
informativeTextWithFormat:@"%@",message];
[alert runModal];
}
}
// For libraries on an unmounted volume, ask the user to mount the volume and reload...
else
{
NSString* title = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.offlineLibraryTitle",
nil,
IMBBundle(),
@"Library is Offline",
@"Alert title");
NSString* format = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.offlineLibraryMessage",
nil,
IMBBundle(),
@"The %@ library cannot be used because it is located on a volume that is currently not mounted.\n\nMount the volume %@ and then click on the \"Reload\" button.",
@"Alert message");
NSString* ok = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.offlineLibraryButton",
nil,
IMBBundle(),
@"Reload",
@"Alert button");
// NSString* cancel = NSLocalizedStringWithDefaultValue(
// @"IMBAccessRightsViewController.cancel",
// nil,
// IMBBundle(),
// @"Cancel",
// @"Alert button");
NSString* message = [NSString stringWithFormat:format,name,volume];
if (IMBRunningOnLionOrNewer() && inView.window != nil)
{
IMBAlertPopover* alert = [IMBAlertPopover warningPopoverWithHeader:title body:message footer:nil];
alert.icon = [NSImage imb_imageNamed:@"IMBStopIcon.icns"];
//+ alert.behavior = NSPopoverBehaviorApplicationDefined;
// [alert addButtonWithTitle:cancel block:^()
// {
// [alert close];
// }];
[alert addButtonWithTitle:ok block:^()
{
[[IMBLibraryController sharedLibraryControllerWithMediaType:inNode.mediaType] reload];
[alert close];
}];
[alert showRelativeToRect:inRect ofView:inView preferredEdge:NSMaxYEdge];
}
else
{
NSAlert* alert = [NSAlert
alertWithMessageText:title
defaultButton:ok
alternateButton:nil
otherButton:nil
informativeTextWithFormat:@"%@",message];
NSInteger button = [alert runModal];
if (button == NSOKButton)
{
[[IMBLibraryController sharedLibraryControllerWithMediaType:inNode.mediaType] reload];
}
}
}
}
//----------------------------------------------------------------------------------------------------------------------
+ (void) showMissingResourceAlertForObject:(IMBObject*)inObject view:(NSView*)inView relativeToRect:(NSRect)inRect
{
NSString* name = inObject.name;
NSString* volume = [inObject.location imb_externalVolumeName];
BOOL mounted = [[NSFileManager defaultManager] imb_isVolumeMounted:volume];
// For missing objects alert the user that we cannot use this object...
if (volume == nil || mounted)
{
NSString* title = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.missingObjectTitle",
nil,
IMBBundle(),
@"Media File is Missing",
@"Alert title");
NSString* ok = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.missingObjectButton",
nil,
IMBBundle(),
@" OK ",
@"Alert button");
NSError* error = inObject.error;
NSString* message;
if (error)
{
message = [error localizedDescription];
if ([[error userInfo] valueForKey:@"title"]) {
title = [[error userInfo] valueForKey:@"title"];
}
} else {
NSString* format = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.missingObjectMessage",
nil,
IMBBundle(),
@"The file %@ cannot be used because it is missing. It may have been deleted, moved, or renamed.",
@"Alert message");
message = [NSString stringWithFormat:format,name];
}
if (IMBRunningOnLionOrNewer() && inView.window != nil)
{
IMBAlertPopover* alert = [IMBAlertPopover warningPopoverWithHeader:title body:message footer:nil];
alert.icon = [NSImage imb_imageNamed:@"IMBStopIcon.icns"];
[alert addButtonWithTitle:ok block:^()
{
[alert close];
}];
[alert showRelativeToRect:inRect ofView:inView preferredEdge:NSMaxYEdge];
}
else
{
NSAlert* alert = [NSAlert
alertWithMessageText:title
defaultButton:ok
alternateButton:nil
otherButton:nil
informativeTextWithFormat:@"%@",message];
[alert runModal];
}
}
// For objects on an unmounted volume, ask the user to mount the volume and reload...
else
{
NSString* title = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.IMBAccessRightsViewController.offlineObjectTitle",
nil,
IMBBundle(),
@"Media File is Offline",
@"Alert title");
NSString* format = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.offlineObjectMessage",
nil,
IMBBundle(),
@"The file \"%@\" cannot be used because it is located on a volume that is currently not mounted.\n\nMount the volume %@ and then click on the \"Reload\" button.",
@"Alert message");
NSString* ok = NSLocalizedStringWithDefaultValue(
@"IMBAccessRightsViewController.offlineObjectButton",
nil,
IMBBundle(),
@"Reload",
@"Alert button");
// NSString* cancel = NSLocalizedStringWithDefaultValue(
// @"IMBAccessRightsViewController.cancel",
// nil,
// IMBBundle(),
// @"Cancel",
// @"Alert button");
NSString* message = [NSString stringWithFormat:format,name,volume];
if (IMBRunningOnLionOrNewer() && inView.window != nil)
{
IMBAlertPopover* alert = [IMBAlertPopover warningPopoverWithHeader:title body:message footer:nil];
alert.icon = [NSImage imb_imageNamed:@"IMBStopIcon.icns"];
// alert.behavior = NSPopoverBehaviorApplicationDefined;
// [alert addButtonWithTitle:cancel block:^()
// {
// [alert close];
// }];
[alert addButtonWithTitle:ok block:^()
{
[[IMBLibraryController sharedLibraryControllerWithMediaType:inObject.mediaType] reload];
[alert close];
}];
[alert showRelativeToRect:inRect ofView:inView preferredEdge:NSMaxYEdge];
}
else
{
NSAlert* alert = [NSAlert
alertWithMessageText:title
defaultButton:ok
alternateButton:nil
otherButton:nil
informativeTextWithFormat:@"%@",message];
NSInteger button = [alert runModal];
if (button == NSOKButton)
{
[[IMBLibraryController sharedLibraryControllerWithMediaType:inObject.mediaType] reload];
}
}
}
}
//----------------------------------------------------------------------------------------------------------------------
#pragma mark
#pragma mark IMBNodeAccessDelegate Protocol
// Show an NSOpenPanel and let the user select a folder. This punches a hole into the sandbox. Then create a
// bookmark for this folder and send it to as many XPC services as possible, thus transferring the access rights
// to the XPC service processes. The XPC service processes are then responsible for persisting these access rights...
// Note that this is an empty operation if not sandboxed.
-(void)nodeViewController:(IMBNodeViewController *)inNodeViewController
requestAccessToNode:(IMBNode *)inNode
completion:(IMBRequestAccessCompletionHandler)inCompletion
{
if (SBIsSandboxed())
{
// Calculate the best possible folder to select...
IMBLibraryController* libraryController = [IMBLibraryController sharedLibraryControllerWithMediaType:inNode.mediaType];
NSArray* nodes = [libraryController topLevelNodesWithoutAccessRights];
IMBNode* node = nodes.count==1 ? [nodes objectAtIndex:0] : nil;
NSArray* urls = [libraryController libraryRootURLsForNodes:nodes];
NSURL* proposedURL = [IMBAccessRightsController commonAncestorForURLs:urls];
// Show an NSOpenPanel with this folder...
[self _showForSuggestedURL:proposedURL name:node.name completionHandler:^(NSURL* inGrantedURL)
{
if (inGrantedURL)
{
// Create bookmark...
NSData* bookmark = [IMBAccessRightsController bookmarkForURL:inGrantedURL];
// Send it to XPC services of all nodes that do not have access rights (thus blessing the XPC services)...
NSArray* mediaTypes = [IMBLibraryController knownMediaTypes];
NSString* path = [inGrantedURL path];
// Collect all affected nodes for which bookmarks were provided. Since these bookmarks are sent
// to messengers asynchronously we must use a counter that tells us when the last bookmark
// was provided, so we can then call the completion handler with the list of granted nodes.
NSMutableArray *grantedNodes = [NSMutableArray array];
__block NSUInteger affectedNodesCount = 0;
for (NSString* mediaType in mediaTypes)
{
IMBLibraryController* libraryController = [IMBLibraryController sharedLibraryControllerWithMediaType:mediaType];
NSArray* nodes = [libraryController topLevelNodesWithoutAccessRights];
affectedNodesCount += [nodes count];
for (IMBNode* node in nodes)
{
if ([node.libraryRootURL.path hasPathPrefix:path])
{
node.badgeTypeNormal = kIMBBadgeTypeLoading;
node.accessibility = kIMBResourceIsAccessible; // Temporarily, so that loading wheel shows again
IMBParserMessenger* messenger = node.parserMessenger;
SBPerformSelectorAsync(messenger.connection,
messenger,
@selector(addAccessRightsBookmark:error:),
bookmark,
dispatch_get_main_queue(),
^(NSURL* inReceivedURL,NSError* inError)
{
BOOL granted = inError == nil;
@synchronized(grantedNodes) {
affectedNodesCount--;
}
if (granted) {
[grantedNodes addObject:node];
}
if (affectedNodesCount == 0) {
// The last affected node was provided with a bookmark.
// Now we can invoke the completion block with collected nodes.
inCompletion(NO, grantedNodes, nil);
}
});
} else {
affectedNodesCount--;
}
}
}
// Also send it to the FSEvents service, so that it can do its job...
[[IMBFileSystemObserver sharedObserver] addAccessRights:bookmark];
} else {
inCompletion(YES, nil, nil);
}
}];
}
}
// Doesn't do anything but invoke completion handler
- (void) revokeAccessToNode:(IMBNode *)inNode completion:(IMBRevokeAccessCompletionHandler) inCompletion
{
inCompletion(NO, nil);
}
//----------------------------------------------------------------------------------------------------------------------
#pragma mark
#pragma mark Helpers
//----------------------------------------------------------------------------------------------------------------------
@end