public static bool updateAvailable(bool calledFromConfig)
{
try
{
string elementName = "";
string xmlURL = null;
patchList.Clear();
Version skinVersionIs = updateCheck.SkinVersion();
// Allow for testing
if (System.IO.File.Exists("C:\\SkinUpdate.xml"))
xmlURL = "C:\\SkinUpdate.xml";
else
xmlURL = "https://raw.github.com/ncoH/Avalon/master/skinUpdate/SkinUpdate.xml";
// Read the file
reader = new XmlTextReader(xmlURL);
reader.MoveToContent();
if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "Avalon"))
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "patch")
{
patches thisPatch = new patches();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
elementName = reader.Name;
else
{
if ((reader.NodeType == XmlNodeType.Text) && (reader.HasValue))
{
switch (elementName)
{
case "version":
thisPatch.patchVersion = new Version(reader.Value);
break;
case "minversion":
thisPatch.minSkinVersionForPatch = new Version(reader.Value);
break;
case "url":
thisPatch.patchURL = reader.Value;
break;
case "changelog":
if (System.IO.File.Exists("C:\\ChangeLog.rtf"))
thisPatch.patchChangeLog = "C:\\ChangeLog.rtf";
else
thisPatch.patchChangeLog = reader.Value;
break;
}
}
}
if (reader.NodeType == XmlNodeType.EndElement)
{
if (reader.Name == "patch")
{
//smcLog.WriteLog("Processing Patch V" + thisPatch.patchVersion.ToString(), LogLevel.Debug);
// Is this patch valid for the skin version we are running
if (skinVersionIs.CompareTo(thisPatch.minSkinVersionForPatch) >= 0)
{
//smcLog.WriteLog("Patch V" + thisPatch.patchVersion.ToString() + " is a valid patch for Skin Version", LogLevel.Debug);
// Only add patch if current skin version is less
if (skinVersionIs.CompareTo(thisPatch.patchVersion) < 0)
{
//smcLog.WriteLog("Patch V" + thisPatch.patchVersion.ToString() + " Added patch for installation", LogLevel.Debug);
patchList.Add(thisPatch);
}
}
break;
}
}
}
}
}
}
}
catch (Exception e)
{
if (calledFromConfig)
MessageBox.Show("Exception while attempting to read upgrade xml file\n\n" + e.Message, "Update Processing Failed");
//else
// smcLog.WriteLog("Exception while attempting to read upgrade xml file\n\n" + e.Message, LogLevel.Error);
}
finally
{
if (reader != null) reader.Close();
}
if (patchList.Count > 0)
{
AvalonGUIConfig.updateAvailable = true;
return true;
}
else
{
AvalonGUIConfig.updateAvailable = false;
return false;
}
}