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
8 using System.Collections.Generic;
\r
9 using System.ComponentModel;
\r
11 using System.Drawing;
\r
13 using System.Windows.Forms;
\r
16 using System.Text.RegularExpressions;
\r
18 namespace Handbrake.Functions
\r
22 XmlTextReader rssReader;
\r
25 XmlNode nodeChannel;
\r
27 private string hb_versionInfo;
\r
28 private string hb_version;
\r
29 private string hb_build;
\r
30 private string hb_file;
\r
32 // Rss Reading Code.
\r
33 private void readRss(XmlTextReader rssReader)
\r
35 rssDoc = new XmlDocument();
\r
36 rssDoc.Load(rssReader);
\r
38 for (int i = 0; i < rssDoc.ChildNodes.Count; i++)
\r
40 if (rssDoc.ChildNodes[i].Name == "rss")
\r
41 nodeRss = rssDoc.ChildNodes[i];
\r
44 for (int i = 0; i < nodeRss.ChildNodes.Count; i++)
\r
46 if (nodeRss.ChildNodes[i].Name == "channel")
\r
47 nodeChannel = nodeRss.ChildNodes[i];
\r
50 for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
\r
52 if (nodeChannel.ChildNodes[i].Name == "item")
\r
53 nodeItem = nodeChannel.ChildNodes[i];
\r
58 // Get's the information required out the RSS file.
\r
59 private void getInfo()
\r
62 int unstable_build = 0;
\r
65 // Check the stable appcast and get the build nuber
\r
66 rssReader = new XmlTextReader(Properties.Settings.Default.appcast);
\r
68 input = nodeItem.InnerXml;
\r
69 ver = Regex.Match(input, @"sparkle:version=""([0-9]*)\""");
\r
70 int stable_build = int.Parse(ver.ToString().Replace("sparkle:version=", "").Replace("\"", ""));
\r
72 // If the pref to enable unstable appcast checking is enabled OR
\r
73 // this is a snapshot release,
\r
74 // then check the unstable appcast.
\r
75 if (Properties.Settings.Default.checkSnapshot == "Checked" || Properties.Settings.Default.hb_build.ToString().EndsWith("1"))
\r
77 // Get the stable build
\r
78 rssReader = new XmlTextReader(Properties.Settings.Default.appcast_unstable);
\r
80 input = nodeItem.InnerXml;
\r
81 ver = Regex.Match(input, @"sparkle:version=""([0-9]*)\""");
\r
82 unstable_build = int.Parse(ver.ToString().Replace("sparkle:version=", "").Replace("\"", ""));
\r
85 if (stable_build >= unstable_build)
\r
86 rssReader = new XmlTextReader(Properties.Settings.Default.appcast);
\r
88 rssReader = new XmlTextReader(Properties.Settings.Default.appcast_unstable);
\r
90 // Get the Version Information
\r
91 hb_versionInfo = nodeItem["description"].InnerText;
\r
94 string inputNode = nodeItem.InnerXml;
\r
95 ver = Regex.Match(inputNode, @"sparkle:shortVersionString=""([0-9].[0-9].[0-9]*)\""");
\r
96 hb_version = ver.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");
\r
98 ver = Regex.Match(inputNode, @"sparkle:version=""([0-9]*)\""");
\r
99 hb_build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");
\r
101 // Get the update file
\r
102 hb_file = nodeItem["windows"].InnerText;
\r
106 /// Get Information about an update to HandBrake
\r
108 /// <returns></returns>
\r
109 public string versionInfo()
\r
112 return hb_versionInfo;
\r
116 /// Get HandBrake's version from the appcast.xml file.
\r
118 /// <returns></returns>
\r
119 public string version()
\r
126 /// Get HandBrake's Build from the appcast.xml file.
\r
128 /// <returns></returns>
\r
129 public string build()
\r
136 /// Get's the URL for update file.
\r
138 /// <returns></returns>
\r
139 public string downloadFile()
\r