summaryrefslogtreecommitdiffstats
path: root/win/C#/Functions
diff options
context:
space:
mode:
Diffstat (limited to 'win/C#/Functions')
-rw-r--r--win/C#/Functions/AppcastReader.cs (renamed from win/C#/Functions/RssReader.cs)55
-rw-r--r--win/C#/Functions/Common.cs6
2 files changed, 41 insertions, 20 deletions
diff --git a/win/C#/Functions/RssReader.cs b/win/C#/Functions/AppcastReader.cs
index 28acf8aa8..6e9d97ea7 100644
--- a/win/C#/Functions/RssReader.cs
+++ b/win/C#/Functions/AppcastReader.cs
@@ -17,21 +17,21 @@ using System.Text.RegularExpressions;
namespace Handbrake.Functions
{
- class RssReader
+ 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()
+ private void readRss(XmlTextReader rssReader)
{
- if (Properties.Settings.Default.hb_build.ToString().EndsWith("1"))
- rssReader = new XmlTextReader(Properties.Settings.Default.appcast_unstable);
- else
- rssReader = new XmlTextReader(Properties.Settings.Default.appcast);
rssDoc = new XmlDocument();
rssDoc.Load(rssReader);
@@ -54,27 +54,48 @@ namespace Handbrake.Functions
}
}
- // Some varibles.
- private string hb_versionInfo;
- private string hb_version;
- private string hb_build;
- private string hb_file;
-
+
// Get's the information required out the RSS file.
private void getInfo()
{
- readRss();
+ 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
- Match ver;
- string input = nodeItem.InnerXml;
- ver = Regex.Match(input, @"sparkle:shortVersionString=""([0-9].[0-9].[0-9]*)\""");
+ 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(input, @"sparkle:version=""([0-9]*)\""");
+ ver = Regex.Match(inputNode, @"sparkle:version=""([0-9]*)\""");
hb_build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");
// Get the update file
diff --git a/win/C#/Functions/Common.cs b/win/C#/Functions/Common.cs
index 87256dc55..3f68b6346 100644
--- a/win/C#/Functions/Common.cs
+++ b/win/C#/Functions/Common.cs
@@ -27,7 +27,7 @@ namespace Handbrake.Functions
{
try
{
- Functions.RssReader rssRead = new Functions.RssReader();
+ Functions.AppcastReader rssRead = new Functions.AppcastReader();
string build = rssRead.build();
int latest = int.Parse(build);
@@ -76,10 +76,10 @@ namespace Handbrake.Functions
while (!cliProcess.HasExited)
{
line = stdOutput.ReadLine();
- Match m = Regex.Match(line, @"HandBrake svn[0-9]*[M]* \([0-9]*\)");
+ Match m = Regex.Match(line, @"HandBrake [0-9\.]*svn[0-9]*[M]* \([0-9]*\)");
if (m.Success != false)
{
- string data = line.Replace("(", "").Replace(")","").Replace("HandBrake ","");
+ string data = line.Replace("(", "").Replace(")", "").Replace("HandBrake ", "");
string[] arr = data.Split(' ');
cliVersionData.Add(arr[0]);
cliVersionData.Add(arr[1]);