summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2009-06-19 15:19:01 +0000
committersr55 <[email protected]>2009-06-19 15:19:01 +0000
commit17bd4de6ba10409ff2a218c3365aa8466c5457c2 (patch)
treeac005301a58d4b25975a7fedee4e6775a5d9ac1e /win
parenta7f2d2c478a8a2177d33fe5fb01e260d7dfd5cd4 (diff)
WinGui:
- Cleans up the appcast reader code a bit more, removing all globals. - Small fix to preset loader to make sure audio bit-rate is set to auto for AC3 tracks. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2576 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r--win/C#/Functions/AppcastReader.cs86
-rw-r--r--win/C#/Functions/Main.cs2
-rw-r--r--win/C#/Functions/PresetLoader.cs5
-rw-r--r--win/C#/frmUpdater.cs8
4 files changed, 39 insertions, 62 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);
}
diff --git a/win/C#/frmUpdater.cs b/win/C#/frmUpdater.cs
index 463ab5676..97a5c9a64 100644
--- a/win/C#/frmUpdater.cs
+++ b/win/C#/frmUpdater.cs
@@ -24,19 +24,19 @@ namespace Handbrake
private void getRss()
{
- wBrowser.Url = appcast.descriptionUrl();
+ wBrowser.Url = appcast.descriptionUrl;
}
private void setVersions()
{
string old = "(You have: " + Properties.Settings.Default.hb_version.Trim() + " / " + Properties.Settings.Default.hb_build.ToString().Trim() + ")";
- string newBuild = appcast.version().Trim() + " (" + appcast.build() + ")";
+ string newBuild = appcast.version.Trim() + " (" + appcast.build + ")";
lbl_update_text.Text = "HandBrake " + newBuild + " is now available. " + old;
}
private void btn_installUpdate_Click(object sender, EventArgs e)
{
- frmDownload download = new frmDownload(appcast.downloadFile());
+ frmDownload download = new frmDownload(appcast.downloadFile);
download.Show();
this.Close();
}
@@ -48,7 +48,7 @@ namespace Handbrake
private void btn_skip_Click(object sender, EventArgs e)
{
- Properties.Settings.Default.skipversion = int.Parse(appcast.build());
+ Properties.Settings.Default.skipversion = int.Parse(appcast.build);
Properties.Settings.Default.Save();
this.Close();