NSString *versionStringFull = [[NSString stringWithFormat: @"Handbrake Version: %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]] stringByAppendingString: [NSString stringWithFormat: @" (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]];
[self writeToActivityLog: "%s", [versionStringFull UTF8String]];
- /* Get the PID number for this hb instance, used in multi instance encoding */
- //pidNum = [self getThisHBInstancePID];
- /* Report this pid to the activity log */
- //[self writeToActivityLog: "Pid for this instance:%d", pidNum];
-
return self;
}
pathOfFinishedEncode = [[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"DestinationPath"];
/* Both the Growl Alert and Sending to MetaX can be done as encodes roll off the queue */
- /* Growl alert */
- [self showGrowlDoneNotification:pathOfFinishedEncode];
- /* Send to MetaX */
- [self sendToMetaX:pathOfFinishedEncode];
-
- /* since we have successfully completed an encode, we increment the queue counter */
- [self incrementQueueItemDone:currentQueueEncodeIndex];
-
- /* all end of queue actions below need to be done after all queue encodes have finished
- * and there are no pending jobs left to process
- */
- if (fPendingCount == 0)
+ if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Growl Notification"] ||
+ [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"])
{
- /* If Alert Window or Window and Growl has been selected */
- if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window"] ||
- [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"] )
+ /* If Play System Alert has been selected in Preferences */
+ if( [[NSUserDefaults standardUserDefaults] boolForKey:@"AlertWhenDoneSound"] == YES )
{
- /*On Screen Notification*/
- int status;
NSBeep();
- status = NSRunAlertPanel(@"Put down that cocktail...",@"Your HandBrake queue is done!", @"OK", nil, nil);
- [NSApp requestUserAttention:NSCriticalRequest];
- }
-
- /* If sleep has been selected */
- if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Put Computer To Sleep"] )
- {
- /* Sleep */
- NSDictionary* errorDict;
- NSAppleEventDescriptor* returnDescriptor = nil;
- NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
- @"tell application \"Finder\" to sleep"];
- returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
- [scriptObject release];
- }
- /* If Shutdown has been selected */
- if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Shut Down Computer"] )
- {
- /* Shut Down */
- NSDictionary* errorDict;
- NSAppleEventDescriptor* returnDescriptor = nil;
- NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
- @"tell application \"Finder\" to shut down"];
- returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
- [scriptObject release];
}
+ [self showGrowlDoneNotification:pathOfFinishedEncode];
}
+
+ /* Send to MetaX */
+ [self sendToMetaX:pathOfFinishedEncode];
+
+ /* since we have successfully completed an encode, we increment the queue counter */
+ [self incrementQueueItemDone:currentQueueEncodeIndex];
+
}
break;
-(void)showGrowlDoneNotification:(NSString *) filePath
{
/* This end of encode action is called as each encode rolls off of the queue */
+ /* Setup the Growl stuff ... */
NSString * finishedEncode = filePath;
/* strip off the path to just show the file name */
finishedEncode = [finishedEncode lastPathComponent];
- if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Growl Notification"] ||
- [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"])
- {
- NSString * growlMssg = [NSString stringWithFormat: @"your HandBrake encode %@ is done!",finishedEncode];
- [GrowlApplicationBridge
- notifyWithTitle:@"Put down that cocktail..."
- description:growlMssg
- notificationName:SERVICE_NAME
- iconData:nil
- priority:0
- isSticky:1
- clickContext:nil];
- }
-
+ NSString * growlMssg = [NSString stringWithFormat: @"your HandBrake encode %@ is done!",finishedEncode];
+ [GrowlApplicationBridge
+ notifyWithTitle:@"Put down that cocktail..."
+ description:growlMssg
+ notificationName:SERVICE_NAME
+ iconData:nil
+ priority:0
+ isSticky:1
+ clickContext:nil];
}
-(void)sendToMetaX:(NSString *) filePath
{
}
}
+
+- (void) queueCompletedAlerts
+{
+ /* If Play System Alert has been selected in Preferences */
+ if( [[NSUserDefaults standardUserDefaults] boolForKey:@"AlertWhenDoneSound"] == YES )
+ {
+ NSBeep();
+ }
+
+ /* If Alert Window or Window and Growl has been selected */
+ if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window"] ||
+ [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"] )
+ {
+ /*On Screen Notification*/
+ int status;
+ status = NSRunAlertPanel(@"Put down that cocktail...",@"Your HandBrake queue is done!", @"OK", nil, nil);
+ [NSApp requestUserAttention:NSCriticalRequest];
+ }
+
+ /* If sleep has been selected */
+ if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Put Computer To Sleep"] )
+ {
+ /* Sleep */
+ NSDictionary* errorDict;
+ NSAppleEventDescriptor* returnDescriptor = nil;
+ NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
+ @"tell application \"Finder\" to sleep"];
+ returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
+ [scriptObject release];
+ }
+ /* If Shutdown has been selected */
+ if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Shut Down Computer"] )
+ {
+ /* Shut Down */
+ NSDictionary* errorDict;
+ NSAppleEventDescriptor* returnDescriptor = nil;
+ NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
+ @"tell application \"Finder\" to shut down"];
+ returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
+ [scriptObject release];
+ }
+}
+
#pragma mark -
#pragma mark Get New Source
else
{
[self writeToActivityLog: "incrementQueueItemDone there are no more pending encodes"];
+ /*Since there are no more items to encode, go to queueCompletedAlerts for user specified alerts after queue completed*/
+ [self queueCompletedAlerts];
}
}
[self doRip];
}
-
-
#pragma mark -
#pragma mark Queue Item Editing