summaryrefslogtreecommitdiffstats
path: root/win/C#/Functions/AppcastReader.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2008-08-04 17:36:06 +0000
committersr55 <[email protected]>2008-08-04 17:36:06 +0000
commit1cf6953b3af6e6ff36697e712c77a9c98cdb2c41 (patch)
tree37223cf17e74fe1f42b4aac7013b97df7aa69205 /win/C#/Functions/AppcastReader.cs
parenta407a9c74cc0eb283d6a5182cb2dafb37c8e603f (diff)
WinGui:
- Activity log - Added CPU description, temp dir, install dir and data dir to the WinGUI log header. - Renamed rssReader to appcast reader - Added option for stable builds to check unstable appcast. - Unstable builds check both appcasts so will always show the latest release - Added some containers to frmMain. - Fixed (I think) an issue with a regex which prases the CLI version information. It may not detect public release build information up correctly. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1606 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Functions/AppcastReader.cs')
-rw-r--r--win/C#/Functions/AppcastReader.cs145
1 files changed, 145 insertions, 0 deletions
diff --git a/win/C#/Functions/AppcastReader.cs b/win/C#/Functions/AppcastReader.cs
new file mode 100644
index 000000000..6e9d97ea7
--- /dev/null
+++ b/win/C#/Functions/AppcastReader.cs
@@ -0,0 +1,145 @@
+/* RssReader.cs $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr>.
+ It may be used under the terms of the GNU General Public License. */
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using System.IO;
+using System.Xml;
+using System.Text.RegularExpressions;
+
+namespace Handbrake.Functions
+{
+ class AppcastReader
+ {
+ XmlTextReader rssReader;
+ XmlDocument rssDoc;
+ XmlNode nodeRss;
+ XmlNode nodeChannel;
+ XmlNode nodeItem;
+ private string hb_versionInfo;
+ private string hb_version;
+ private string hb_build;
+ private string hb_file;
+
+ // Rss Reading Code.
+ private void readRss(XmlTextReader rssReader)
+ {
+ rssDoc = new XmlDocument();
+ rssDoc.Load(rssReader);
+
+ for (int i = 0; i < rssDoc.ChildNodes.Count; i++)
+ {
+ if (rssDoc.ChildNodes[i].Name == "rss")
+ nodeRss = rssDoc.ChildNodes[i];
+ }
+
+ 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];
+ }
+ }
+
+
+ // Get's the information required out the RSS file.
+ private void getInfo()
+ {
+ Match ver;
+ int unstable_build = 0;
+ string input;
+
+ // Check the stable appcast and get the build nuber
+ rssReader = new XmlTextReader(Properties.Settings.Default.appcast);
+ readRss(rssReader);
+ input = nodeItem.InnerXml;
+ ver = Regex.Match(input, @"sparkle:version=""([0-9]*)\""");
+ int stable_build = int.Parse(ver.ToString().Replace("sparkle:version=", "").Replace("\"", ""));
+
+ // If the pref to enable unstable appcast checking is enabled OR
+ // this is a snapshot release,
+ // then check the unstable appcast.
+ if (Properties.Settings.Default.checkSnapshot == "Checked" || Properties.Settings.Default.hb_build.ToString().EndsWith("1"))
+ {
+ // Get the stable build
+ rssReader = new XmlTextReader(Properties.Settings.Default.appcast_unstable);
+ readRss(rssReader);
+ input = nodeItem.InnerXml;
+ ver = Regex.Match(input, @"sparkle:version=""([0-9]*)\""");
+ unstable_build = int.Parse(ver.ToString().Replace("sparkle:version=", "").Replace("\"", ""));
+ }
+
+ if (stable_build >= unstable_build)
+ rssReader = new XmlTextReader(Properties.Settings.Default.appcast);
+ else
+ rssReader = new XmlTextReader(Properties.Settings.Default.appcast_unstable);
+
+ // Get the Version Information
+ hb_versionInfo = nodeItem["description"].InnerText;
+
+ // Get the version
+ string inputNode = nodeItem.InnerXml;
+ ver = Regex.Match(inputNode, @"sparkle:shortVersionString=""([0-9].[0-9].[0-9]*)\""");
+ hb_version = ver.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");
+
+ ver = Regex.Match(inputNode, @"sparkle:version=""([0-9]*)\""");
+ hb_build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");
+
+ // Get the update file
+ hb_file = nodeItem["windows"].InnerText;
+ }
+
+ /// <summary>
+ /// Get Information about an update to HandBrake
+ /// </summary>
+ /// <returns></returns>
+ public string versionInfo()
+ {
+ getInfo();
+ return hb_versionInfo;
+ }
+
+ /// <summary>
+ /// Get HandBrake's version from the appcast.xml file.
+ /// </summary>
+ /// <returns></returns>
+ public string version()
+ {
+ getInfo();
+ return hb_version;
+ }
+
+ /// <summary>
+ /// Get HandBrake's Build from the appcast.xml file.
+ /// </summary>
+ /// <returns></returns>
+ public string build()
+ {
+ getInfo();
+ return hb_build;
+ }
+
+ /// <summary>
+ /// Get's the URL for update file.
+ /// </summary>
+ /// <returns></returns>
+ public string downloadFile()
+ {
+ getInfo();
+ return hb_file;
+ }
+ }
+} \ No newline at end of file