2013-11-03 23:53:49 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2014-05-13 21:06:40 +12:00
|
|
|
|
Copyright (C) 2007-2014 ShareX Developers
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
using System;
|
2013-11-28 12:18:00 +13:00
|
|
|
|
using System.Web;
|
2014-07-04 01:48:35 +12:00
|
|
|
|
using System.Windows.Forms;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2013-11-14 23:50:25 +13:00
|
|
|
|
namespace HelpersLib
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
public class UpdateInfo
|
|
|
|
|
{
|
2013-11-15 18:30:54 +13:00
|
|
|
|
public UpdateStatus Status { get; set; }
|
2013-11-03 23:53:49 +13:00
|
|
|
|
public Version CurrentVersion { get; set; }
|
|
|
|
|
public Version LatestVersion { get; set; }
|
2013-11-28 12:18:00 +13:00
|
|
|
|
|
|
|
|
|
private string filename;
|
|
|
|
|
|
|
|
|
|
public string Filename
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(filename))
|
|
|
|
|
{
|
|
|
|
|
return HttpUtility.UrlDecode(DownloadURL.Substring(DownloadURL.LastIndexOf('/') + 1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return filename;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
filename = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-15 18:30:54 +13:00
|
|
|
|
public string DownloadURL { get; set; }
|
2013-11-03 23:53:49 +13:00
|
|
|
|
public ReleaseChannelType ReleaseChannel { get; set; }
|
|
|
|
|
|
2014-05-11 23:41:15 +12:00
|
|
|
|
private bool forceUpdate = false; // For testing purposes
|
|
|
|
|
|
2013-11-15 18:30:54 +13:00
|
|
|
|
public UpdateInfo()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2013-11-15 18:30:54 +13:00
|
|
|
|
ReleaseChannel = ReleaseChannelType.Stable;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-15 18:30:54 +13:00
|
|
|
|
public void RefreshStatus()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-07-04 01:48:35 +12:00
|
|
|
|
if (CurrentVersion == null)
|
|
|
|
|
{
|
|
|
|
|
CurrentVersion = Version.Parse(Application.ProductVersion);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Status != UpdateStatus.UpdateCheckFailed && CurrentVersion != null && LatestVersion != null && !string.IsNullOrEmpty(DownloadURL) &&
|
|
|
|
|
(forceUpdate || Helpers.CheckVersion(CurrentVersion, LatestVersion)))
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2013-11-15 18:30:54 +13:00
|
|
|
|
Status = UpdateStatus.UpdateAvailable;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Status = UpdateStatus.UpToDate;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|