/* RssReader.cs $\r
- \r
- This file is part of the HandBrake source code.\r
- Homepage: <http://handbrake.fr>.\r
- It may be used under the terms of the GNU General Public License. */\r
-\r
-using System;\r
-using System.Xml;\r
-using System.Text.RegularExpressions;\r
-using System.IO;\r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.fr>.\r
+ It may be used under the terms of the GNU General Public License. */\r
\r
namespace Handbrake.Functions\r
{\r
+ using System;\r
+ using System.IO;\r
+ using System.Text.RegularExpressions;\r
+ using System.Xml;\r
+\r
+ /// <summary>\r
+ /// Appcast Reader - Used for parsing HandBrakes update file\r
+ /// </summary>\r
public class AppcastReader\r
{\r
/// <summary>\r
+ /// Gets Information about an update to HandBrake\r
+ /// </summary>\r
+ public Uri DescriptionUrl { get; private set; }\r
+\r
+ /// <summary>\r
+ /// Gets HandBrake's version from the appcast.xml file.\r
+ /// </summary>\r
+ public string Version { get; private set; }\r
+\r
+ /// <summary>\r
+ /// Gets HandBrake's Build from the appcast.xml file.\r
+ /// </summary>\r
+ public string Build { get; private set; }\r
+\r
+ /// <summary>\r
+ /// Gets the URL for update file.\r
+ /// </summary>\r
+ public string DownloadFile { get; private set; }\r
+\r
+ /// <summary>\r
/// Get the build information from the required appcasts. Run before accessing the public vars.\r
/// </summary>\r
+ /// <param name="input">\r
+ /// The input.\r
+ /// </param>\r
public void GetInfo(string input)\r
{\r
try\r
{\r
// Get the correct Appcast and set input.\r
- XmlNode nodeItem = readRss(new XmlTextReader(new StringReader(input)));\r
+ XmlNode nodeItem = ReadRss(new XmlTextReader(new StringReader(input)));\r
string result = nodeItem.InnerXml;\r
\r
// Regular Expressions\r
Match ver = Regex.Match(result, @"sparkle:version=""([0-9]*)\""");\r
Match verShort = Regex.Match(result, @"sparkle:shortVersionString=""(([svn]*)([0-9.\s]*))\""");\r
\r
- Build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");\r
- Version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");\r
- DownloadFile = nodeItem["windows"].InnerText;\r
- DescriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);\r
- } \r
- catch( Exception)\r
+ this.Build = ver.ToString().Replace("sparkle:version=", string.Empty).Replace("\"", string.Empty);\r
+ this.Version = verShort.ToString().Replace("sparkle:shortVersionString=", string.Empty).Replace("\"", \r
+ string.\r
+ Empty);\r
+ this.DownloadFile = nodeItem["windows"].InnerText;\r
+ this.DescriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);\r
+ }\r
+ catch (Exception)\r
{\r
return;\r
}\r
/// <summary>\r
/// Read the RSS file.\r
/// </summary>\r
- /// <param name="rssReader"></param>\r
- private static XmlNode readRss(XmlReader rssReader)\r
+ /// <param name="rssReader">\r
+ /// The RSS reader\r
+ /// </param>\r
+ /// <returns>\r
+ /// The read rss.\r
+ /// </returns>\r
+ private static XmlNode ReadRss(XmlReader rssReader)\r
{\r
XmlNode nodeItem = null;\r
XmlNode nodeChannel = null;\r
foreach (XmlNode t in rssDoc.ChildNodes)\r
{\r
if (t.Name == "rss")\r
+ {\r
nodeRss = t;\r
+ }\r
}\r
\r
if (nodeRss != null)\r
+ {\r
foreach (XmlNode t in nodeRss.ChildNodes)\r
{\r
if (t.Name == "channel")\r
+ {\r
nodeChannel = t;\r
+ }\r
}\r
+ }\r
\r
if (nodeChannel != null)\r
+ {\r
foreach (XmlNode t in nodeChannel.ChildNodes)\r
{\r
if (t.Name == "item")\r
+ {\r
nodeItem = t;\r
+ }\r
}\r
+ }\r
\r
return nodeItem;\r
}\r
-\r
- /// <summary>\r
- /// Get Information about an update to HandBrake\r
- /// </summary>\r
- public Uri DescriptionUrl { get; set; }\r
-\r
- /// <summary>\r
- /// Get HandBrake's version from the appcast.xml file.\r
- /// </summary>\r
- public string Version { get; set; }\r
-\r
- /// <summary>\r
- /// Get HandBrake's Build from the appcast.xml file.\r
- /// </summary>\r
- public string Build { get; set; }\r
-\r
- /// <summary>\r
- /// Get's the URL for update file.\r
- /// </summary>\r
- public string DownloadFile { get; set; }\r
}\r
}
\ No newline at end of file