summaryrefslogtreecommitdiffstats
path: root/macosx/HBQueueController.m
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2017-01-20 18:52:22 +0100
committerDamiano Galassi <[email protected]>2017-01-20 18:52:22 +0100
commita3d00959f42f940e8d3c2b73fb92a951cbf94472 (patch)
tree7085331974860d7771a3f6adaf1694383a1f064a /macosx/HBQueueController.m
parent40ec4ebaa2958b2549125dd525b6fcb2bd595d69 (diff)
MacGui: initial sandbox support. Added two new scheme RELEASE-SANDBOX and DEBUG-SANDBOX to build HandBrake with sandbox enabled.
Diffstat (limited to 'macosx/HBQueueController.m')
-rw-r--r--macosx/HBQueueController.m34
1 files changed, 23 insertions, 11 deletions
diff --git a/macosx/HBQueueController.m b/macosx/HBQueueController.m
index 7fb42dad1..8ff546176 100644
--- a/macosx/HBQueueController.m
+++ b/macosx/HBQueueController.m
@@ -12,6 +12,7 @@
#import "HBQueueOutlineView.h"
#import "NSArray+HBAdditions.h"
+#import "HBUtilities.h"
#import "HBDockTile.h"
@@ -223,7 +224,7 @@
for (HBJob *item in self.jobs)
{
- if ([item.destURL isEqualTo:url])
+ if ([item.completeOutputURL isEqualTo:url])
{
return YES;
}
@@ -587,7 +588,7 @@
// Check to see if there are any more pending items in the queue
HBJob *nextJob = [self getNextPendingQueueItem];
- if (nextJob && [self _isDiskSpaceLowAtURL:nextJob.destURL])
+ if (nextJob && [self _isDiskSpaceLowAtURL:nextJob.outputURL])
{
// Disk space is low, show an alert
[HBUtilities writeToActivityLog:"Queue Stopped, low space on destination disk"];
@@ -648,7 +649,7 @@
if (result != HBCoreResultCancelled)
{
// Send to tagger
- [self sendToExternalApp:job.destURL];
+ [self sendToExternalApp:job];
}
// Mark the encode just finished
@@ -744,7 +745,7 @@
job.title = self.core.titles[0];
HBStateFormatter *formatter = [[HBStateFormatter alloc] init];
- formatter.title = job.destURL.lastPathComponent;
+ formatter.title = job.outputFileName;
self.core.stateFormatter = formatter;
// Progress handler
@@ -862,19 +863,23 @@
* Sends the URL to the external app
* selected in the preferences.
*
- * @param fileURL the URL of the file to send
+ * @param job the job of the file to send
*/
-- (void)sendToExternalApp:(NSURL *)fileURL
+- (void)sendToExternalApp:(HBJob *)job
{
// This end of encode action is called as each encode rolls off of the queue
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBSendToAppEnabled"] == YES)
{
+#ifdef __SANDBOX_ENABLED__
+ BOOL accessingSecurityScopedResource = [job.outputURL startAccessingSecurityScopedResource];
+#endif
+
NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
NSString *app = [workspace fullPathForApplication:[[NSUserDefaults standardUserDefaults] objectForKey:@"HBSendToApp"]];
if (app)
{
- if (![workspace openFile:fileURL.path withApplication:app])
+ if (![workspace openFile:job.completeOutputURL.path withApplication:app])
{
[HBUtilities writeToActivityLog:"Failed to send file to: %s", app];
}
@@ -883,6 +888,13 @@
{
[HBUtilities writeToActivityLog:"Send file to: app not found"];
}
+
+#ifdef __SANDBOX_ENABLED__
+ if (accessingSecurityScopedResource)
+ {
+ [job.outputURL stopAccessingSecurityScopedResource];
+ }
+#endif
}
}
@@ -907,19 +919,19 @@
{
title = NSLocalizedString(@"Put down that cocktail…", nil);
description = [NSString stringWithFormat:NSLocalizedString(@"your HandBrake encode %@ is done!", nil),
- job.destURL.lastPathComponent];
+ job.outputFileName];
}
else
{
title = NSLocalizedString(@"Encode failed", nil);
description = [NSString stringWithFormat:NSLocalizedString(@"your HandBrake encode %@ couldn't be completed.", nil),
- job.destURL.lastPathComponent];
+ job.outputFileName];
}
[self showNotificationWithTitle:title
description:description
- url:job.destURL];
+ url:job.completeOutputURL];
}
}
@@ -1069,7 +1081,7 @@
NSUInteger currentIndex = [targetedRows firstIndex];
while (currentIndex != NSNotFound) {
- NSURL *url = [[self.jobs objectAtIndex:currentIndex] destURL];
+ NSURL *url = [[self.jobs objectAtIndex:currentIndex] completeOutputURL];
[urls addObject:url];
currentIndex = [targetedRows indexGreaterThanIndex:currentIndex];
}