summaryrefslogtreecommitdiffstats
path: root/win/C#/Functions/AppcastReader.cs
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/C#/Functions/AppcastReader.cs
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/C#/Functions/AppcastReader.cs')
-rw-r--r--win/C#/Functions/AppcastReader.cs86
1 files changed, 30 insertions, 56 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