summaryrefslogtreecommitdiffstats
path: root/win/C#/Functions
diff options
context:
space:
mode:
Diffstat (limited to 'win/C#/Functions')
-rw-r--r--win/C#/Functions/AppcastReader.cs86
-rw-r--r--win/C#/Functions/Main.cs2
-rw-r--r--win/C#/Functions/PresetLoader.cs5
3 files changed, 35 insertions, 58 deletions
diff --git a/win/C#/Functions/AppcastReader.cs b/win/C#/Functions/AppcastReader.cs
index e86259ff7..944258597 100644
--- a/win/C#/Functions/AppcastReader.cs
+++ b/win/C#/Functions/AppcastReader.cs
@@ -12,50 +12,36 @@ namespace Handbrake.Functions
{
public class AppcastReader
{
- XmlDocument rssDoc;
- XmlNode nodeRss;
- XmlNode nodeChannel;
- XmlNode nodeItem;
- private Uri hb_description;
- private string hb_version;
- private string hb_build;
- private string hb_file;
-
/// <summary>
- /// Get the build information from the required appcasts.
- /// This must be run before calling any of the public return functions.
+ /// Get the build information from the required appcasts. Run before accessing the public vars.
/// </summary>
public void getInfo()
{
// Get the correct Appcast and set input.
- if (Properties.Settings.Default.hb_build.ToString().EndsWith("1"))
- readRss(new XmlTextReader(Properties.Settings.Default.appcast_unstable));
- else
- readRss(new XmlTextReader(Properties.Settings.Default.appcast));
-
+ XmlNode nodeItem = Properties.Settings.Default.hb_build.ToString().EndsWith("1") ? readRss(new XmlTextReader(Properties.Settings.Default.appcast_unstable)) : readRss(new XmlTextReader(Properties.Settings.Default.appcast));
string input = nodeItem.InnerXml;
// Regular Expressions
Match ver = Regex.Match(input, @"sparkle:version=""([0-9]*)\""");
Match verShort = Regex.Match(input, @"sparkle:shortVersionString=""([0-9].[0-9].[0-9]*)\""");
- if (nodeItem != null)
- {
- hb_build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");
- hb_version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");
- hb_file = nodeItem["windows"].InnerText;
- hb_description = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);
- }
-
+ build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");
+ version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");
+ downloadFile = nodeItem["windows"].InnerText;
+ descriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);
}
/// <summary>
/// Read the RSS file.
/// </summary>
/// <param name="rssReader"></param>
- private void readRss(XmlReader rssReader)
+ private static XmlNode readRss(XmlReader rssReader)
{
- rssDoc = new XmlDocument();
+ XmlNode nodeItem = null;
+ XmlNode nodeChannel = null;
+ XmlNode nodeRss = null;
+
+ XmlDocument rssDoc = new XmlDocument();
rssDoc.Load(rssReader);
for (int i = 0; i < rssDoc.ChildNodes.Count; i++)
@@ -64,53 +50,41 @@ namespace Handbrake.Functions
nodeRss = rssDoc.ChildNodes[i];
}
- for (int i = 0; i < nodeRss.ChildNodes.Count; i++)
- {
- if (nodeRss.ChildNodes[i].Name == "channel")
- nodeChannel = nodeRss.ChildNodes[i];
- }
+ if (nodeRss != null)
+ for (int i = 0; i < nodeRss.ChildNodes.Count; i++)
+ {
+ if (nodeRss.ChildNodes[i].Name == "channel")
+ nodeChannel = nodeRss.ChildNodes[i];
+ }
- for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
- {
- if (nodeChannel.ChildNodes[i].Name == "item")
- nodeItem = nodeChannel.ChildNodes[i];
- }
+ if (nodeChannel != null)
+ for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
+ {
+ if (nodeChannel.ChildNodes[i].Name == "item")
+ nodeItem = nodeChannel.ChildNodes[i];
+ }
+
+ return nodeItem;
}
/// <summary>
/// Get Information about an update to HandBrake
/// </summary>
- /// <returns></returns>
- public System.Uri descriptionUrl()
- {
- return hb_description;
- }
+ public Uri descriptionUrl { get; set; }
/// <summary>
/// Get HandBrake's version from the appcast.xml file.
/// </summary>
- /// <returns></returns>
- public string version()
- {
- return hb_version;
- }
+ public string version { get; set; }
/// <summary>
/// Get HandBrake's Build from the appcast.xml file.
/// </summary>
- /// <returns></returns>
- public string build()
- {
- return hb_build;
- }
+ public string build { get; set; }
/// <summary>
/// Get's the URL for update file.
/// </summary>
- /// <returns></returns>
- public string downloadFile()
- {
- return hb_file;
- }
+ public string downloadFile { get; set; }
}
} \ No newline at end of file
diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs
index f6c85b1cf..95a17cfb3 100644
--- a/win/C#/Functions/Main.cs
+++ b/win/C#/Functions/Main.cs
@@ -199,7 +199,7 @@ namespace Handbrake.Functions
{
AppcastReader rssRead = new AppcastReader();
rssRead.getInfo(); // Initializes the class.
- string build = rssRead.build();
+ string build = rssRead.build;
int latest = int.Parse(build);
int current = Properties.Settings.Default.hb_build;
diff --git a/win/C#/Functions/PresetLoader.cs b/win/C#/Functions/PresetLoader.cs
index 251735aec..4952e5d3d 100644
--- a/win/C#/Functions/PresetLoader.cs
+++ b/win/C#/Functions/PresetLoader.cs
@@ -243,7 +243,10 @@ namespace Handbrake.Functions
newTrack.SubItems.Add(track.Encoder);
newTrack.SubItems.Add(track.MixDown);
newTrack.SubItems.Add(track.SampleRate);
- newTrack.SubItems.Add(track.Bitrate);
+ if (track.Encoder.Contains("AC3"))
+ newTrack.SubItems.Add("Auto");
+ else
+ newTrack.SubItems.Add(track.Bitrate);
newTrack.SubItems.Add(track.DRC);
mainWindow.audioPanel.addTrackForPreset(newTrack);
}