using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;

namespace s3sr
{
    class Updater
    {
        // TODO: Implement BETA/Revision Detection ?

        /// <summary>
        /// Check Version reading a plain-text file on the web
        /// </summary>
        /// <param name="svn">URL</param>
        /// <returns>true, if new version available, otherwise, false.</returns>
        public static bool CheckVersion(string svn)
        {
            try
            {
                StreamReader svnPlainFile = new StreamReader(new WebClient().OpenRead(svn));
                string svnPlainText = svnPlainFile.ReadLine();
                svnPlainFile.Close();

                if (svnPlainText != Application.ProductVersion)
                    return true;
                else
                    return false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Exception while Checking Update", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ErrorReport.CreateExceptionReport(ex, "Exception @ \"VXBkYXRlci5jcw== 21\";");
                return false;
            }
        }
    }
}
