Added new fields to UserConfig and AppConfig, and added some types relating to automatic updates.

This commit is contained in:
Ben Olden-Cooligan 2013-09-17 21:19:11 -04:00
parent 464c34f030
commit 50a9788244
9 changed files with 117 additions and 2 deletions

View File

@ -26,12 +26,13 @@ using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using NAPS2.Scan;
using NAPS2.Update;
namespace NAPS2.Config
{
public class AppConfig
{
public const int CURRENT_VERSION = 1;
public const int CURRENT_VERSION = 2;
public int Version { get; set; }
@ -44,5 +45,7 @@ namespace NAPS2.Config
public MessageBoxIcon StartupMessageIcon { get; set; }
public ExtendedScanSettings DefaultProfileSettings { get; set; }
public AutoUpdateStatus AutoUpdate { get; set; }
}
}

View File

@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NAPS2.Update;
namespace NAPS2.Config
{
@ -31,12 +32,16 @@ namespace NAPS2.Config
FormStates = new List<FormState>();
}
public const int CURRENT_VERSION = 1;
public const int CURRENT_VERSION = 2;
public int Version { get; set; }
public string Culture { get; set; }
public List<FormState> FormStates { get; set; }
public AutoUpdateStatus AutoUpdate { get; set; }
public DateTime? LastUpdateCheckDate { get; set; }
}
}

View File

@ -172,6 +172,12 @@
<Compile Include="StringWrapper.cs" />
<Compile Include="UnmanagedArray.cs" />
<Compile Include="UnmanagedBase.cs" />
<Compile Include="Update\AutoUpdater.cs" />
<Compile Include="Update\AutoUpdateStatus.cs" />
<Compile Include="Update\ICurrentVersionSource.cs" />
<Compile Include="Update\IUrlStreamReader.cs" />
<Compile Include="Update\IUrlTextReader.cs" />
<Compile Include="Update\ILatestVersionSource.cs" />
<Compile Include="WinForms\FormBase.cs">
<SubType>Form</SubType>
</Compile>

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NAPS2.Update
{
public enum AutoUpdateStatus
{
Unspecified,
Enabled,
Disabled
}
}

View File

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Deployment.Application;
using System.Linq;
using System.Text;
using NAPS2.Config;
namespace NAPS2.Update
{
public class AutoUpdater
{
private readonly UserConfigManager _userConfigManager;
private readonly AppConfigManager _appConfigManager;
public AutoUpdater(UserConfigManager userConfigManager, AppConfigManager appConfigManager)
{
_userConfigManager = userConfigManager;
_appConfigManager = appConfigManager;
}
public void OnApplicationStart()
{
PromptToEnableAutomaticUpdates();
CheckForUpdate();
}
private void PromptToEnableAutomaticUpdates()
{
throw new NotImplementedException();
}
private void CheckForUpdate()
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NAPS2.Update
{
public interface ICurrentVersionSource
{
string GetCurrentVersion();
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NAPS2.Update
{
public interface ILatestVersionSource
{
Task<string> GetLatestVersion();
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace NAPS2.Update
{
public interface IUrlStreamReader
{
Stream OpenStream(string url);
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NAPS2.Update
{
public interface IUrlTextReader
{
string DownloadText(string url);
}
}