3 This file is part of the HandBrake source code.
\r
4 Homepage: <http://handbrake.fr>.
\r
5 It may be used under the terms of the GNU General Public License. */
\r
9 using System.Text.RegularExpressions;
\r
11 namespace Handbrake.Functions
\r
13 public class AppcastReader
\r
17 XmlNode nodeChannel;
\r
19 private Uri hb_description;
\r
20 private string hb_version;
\r
21 private string hb_build;
\r
22 private string hb_file;
\r
25 /// Get the build information from the required appcasts.
\r
26 /// This must be run before calling any of the public return functions.
\r
28 public void getInfo()
\r
30 // Get the correct Appcast and set input.
\r
31 if (Properties.Settings.Default.hb_build.ToString().EndsWith("1"))
\r
32 readRss(new XmlTextReader(Properties.Settings.Default.appcast_unstable));
\r
34 readRss(new XmlTextReader(Properties.Settings.Default.appcast));
\r
36 string input = nodeItem.InnerXml;
\r
38 // Regular Expressions
\r
39 Match ver = Regex.Match(input, @"sparkle:version=""([0-9]*)\""");
\r
40 Match verShort = Regex.Match(input, @"sparkle:shortVersionString=""([0-9].[0-9].[0-9]*)\""");
\r
42 if (nodeItem != null)
\r
44 hb_build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");
\r
45 hb_version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");
\r
46 hb_file = nodeItem["windows"].InnerText;
\r
47 hb_description = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);
\r
53 /// Read the RSS file.
\r
55 /// <param name="rssReader"></param>
\r
56 private void readRss(XmlReader rssReader)
\r
58 rssDoc = new XmlDocument();
\r
59 rssDoc.Load(rssReader);
\r
61 for (int i = 0; i < rssDoc.ChildNodes.Count; i++)
\r
63 if (rssDoc.ChildNodes[i].Name == "rss")
\r
64 nodeRss = rssDoc.ChildNodes[i];
\r
67 for (int i = 0; i < nodeRss.ChildNodes.Count; i++)
\r
69 if (nodeRss.ChildNodes[i].Name == "channel")
\r
70 nodeChannel = nodeRss.ChildNodes[i];
\r
73 for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
\r
75 if (nodeChannel.ChildNodes[i].Name == "item")
\r
76 nodeItem = nodeChannel.ChildNodes[i];
\r
81 /// Get Information about an update to HandBrake
\r
83 /// <returns></returns>
\r
84 public System.Uri descriptionUrl()
\r
86 return hb_description;
\r
90 /// Get HandBrake's version from the appcast.xml file.
\r
92 /// <returns></returns>
\r
93 public string version()
\r
99 /// Get HandBrake's Build from the appcast.xml file.
\r
101 /// <returns></returns>
\r
102 public string build()
\r
108 /// Get's the URL for update file.
\r
110 /// <returns></returns>
\r
111 public string downloadFile()
\r