get { return queue.Count; }\r
}\r
\r
-\r
/// <summary>\r
/// Adds an item to the queue.\r
/// </summary>\r
/// <param name="query">The query that will be passed to the HandBrake CLI.</param>\r
/// <param name="source">The location of the source video.</param>\r
/// <param name="destination">The location where the encoded video will be.</param>\r
- public void AddJob(string query, string source, string destination)\r
+ /// <param name="customJob"></param>\r
+ public void AddJob(string query, string source, string destination, bool customJob)\r
{\r
- Job newJob = new Job { Id = nextJobId++, Query = query, Source = source, Destination = destination };\r
+ Job newJob = new Job { Id = nextJobId++, Query = query, Source = source, Destination = destination, CustomQuery = customJob };\r
\r
queue.Add(newJob);\r
WriteQueueStateToFile("hb_queue_recovery.xml");\r
/// </summary>\r
public void EndEncodeJob()\r
{\r
- closeCLI();\r
+ CloseCLI();\r
}\r
\r
private void startProcess(object state)\r
// Run through each item on the queue\r
while (this.Count != 0)\r
{\r
- string query = GetNextJob().Query;\r
+ Job encJob = GetNextJob();\r
+ string query = encJob.Query;\r
WriteQueueStateToFile("hb_queue_recovery.xml"); // Update the queue recovery file\r
\r
- runCli(query);\r
+ RunCli(query);\r
\r
if (NewJobStarted != null)\r
NewJobStarted(this, new EventArgs());\r
\r
hbProcess.WaitForExit();\r
\r
- addCLIQueryToLog(query);\r
- copyLog(LastEncode.Destination);\r
+ AddCLIQueryToLog(encJob);\r
+ CopyLog(LastEncode.Destination);\r
\r
hbProcess.Close();\r
hbProcess.Dispose();\r
-\r
+ \r
isEncoding = false;\r
\r
+ //Growl\r
+ if (Properties.Settings.Default.growlEncode)\r
+ GrowlCommunicator.Notify("Encode Completed", "Put down that cocktail...\nyour Handbrake encode is done.");\r
+\r
if (CurrentJobCompleted != null)\r
CurrentJobCompleted(this, new EventArgs());\r
\r
Thread.Sleep(5000);\r
}\r
}\r
+ LastEncode = new Job();\r
\r
if (QueueCompleted != null)\r
QueueCompleted(this, new EventArgs());\r
\r
// After the encode is done, we may want to shutdown, suspend etc.\r
- afterEncodeAction();\r
+ AfterEncodeAction();\r
}\r
\r
#endregion\r
/// Execute a HandBrakeCLI process.\r
/// </summary>\r
/// <param name="query">The CLI Query</param>\r
- public void runCli(string query)\r
+ public void RunCli(string query)\r
{\r
try\r
{\r
+ isEncoding = true;\r
+\r
string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");\r
string logPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs", "last_encode_log.txt");\r
string strCmdLine = String.Format(@" /C """"{0}"" {1} 2>""{2}"" """, handbrakeCLIPath, query, logPath);\r
\r
Process[] before = Process.GetProcesses(); // Get a list of running processes before starting.\r
hbProcess = Process.Start(cliStart);\r
- processID = Main.getCliProcess(before);\r
- isEncoding = true;\r
+ processID = Main.getCliProcess(before); \r
currentQuery = query;\r
if (hbProcess != null)\r
processHandle = hbProcess.MainWindowHandle; // Set the process Handle\r
{\r
MessageBox.Show("It would appear that HandBrakeCLI has not started correctly. You should take a look at the Activity log as it may indicate the reason why.\n\n Detailed Error Information: error occured in runCli()\n\n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
}\r
-\r
}\r
\r
/// <summary>\r
/// Kill the CLI process\r
/// </summary>\r
- public void closeCLI()\r
+ private void CloseCLI()\r
{\r
hbProcess.Kill();\r
isEncoding = false;\r
/// <summary>\r
/// Perform an action after an encode. e.g a shutdown, standby, restart etc.\r
/// </summary>\r
- public void afterEncodeAction()\r
+ private void AfterEncodeAction()\r
{\r
isEncoding = false;\r
currentQuery = String.Empty;\r
+\r
+ //Growl\r
+ if (Properties.Settings.Default.growlQueue)\r
+ GrowlCommunicator.Notify("Queue Completed", "Put down that cocktail...\nyour Handbrake queue is done.");\r
+\r
// Do something whent he encode ends.\r
switch (Properties.Settings.Default.CompletionOption)\r
{\r
case "Lock System":\r
Win32.LockWorkStation();\r
break;\r
- case "Growl Notification":\r
- GrowlCommunicator.Notify();\r
- break;\r
case "Quit HandBrake":\r
Application.Exit();\r
break;\r
/// Append the CLI query to the start of the log file.\r
/// </summary>\r
/// <param name="query"></param>\r
- public void addCLIQueryToLog(string query)\r
+ private static void AddCLIQueryToLog(Job encJob)\r
{\r
string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
string logPath = Path.Combine(logDir, "last_encode_log.txt");\r
\r
StreamWriter writer = new StreamWriter(File.Create(logPath));\r
\r
- writer.Write("### CLI Query: " + query + "\n\n");\r
+ writer.Write("### CLI Query: " + encJob.Query + "\n\n");\r
+ writer.Write("### User Query: " + encJob.CustomQuery + "\n\n");\r
writer.Write("#########################################\n\n");\r
writer.WriteLine(log);\r
writer.Flush();\r
/// if this feature is enabled in options.\r
/// </summary>\r
/// <param name="destination"></param>\r
- public void copyLog(string destination)\r
+ private static void CopyLog(string destination)\r
{\r
try\r
{\r