(ZIP): query password for encrypted archives.

This commit is contained in:
morkt 2018-01-30 06:34:24 +04:00
parent 98e42a1f66
commit 07c69a4866
13 changed files with 137 additions and 1 deletions

View File

@ -192,6 +192,9 @@
<Compile Include="Morning\ArcPAK.cs" />
<Compile Include="PackedStream.cs" />
<Compile Include="PalmTree\ArcAR.cs" />
<Compile Include="PkWare\WidgetZIP.xaml.cs">
<DependentUpon>WidgetZIP.xaml</DependentUpon>
</Compile>
<Compile Include="Qlie\DelphiDeserializer.cs" />
<Compile Include="Qlie\Encryption.cs" />
<Compile Include="RealLive\ArcKOE.cs" />
@ -944,6 +947,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="PkWare\WidgetZIP.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Qlie\WidgetQLIE.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -83,6 +83,12 @@ namespace GameRes.Formats.PkWare
#endregion
}
[Serializable]
public class ZipScheme : ResourceScheme
{
public Dictionary<string, string> KnownKeys;
}
[Export(typeof(ArchiveFormat))]
public class ZipOpener : ArchiveFormat
{
@ -167,7 +173,8 @@ namespace GameRes.Formats.PkWare
string QueryPassword (ArcView file)
{
return ""; // TODO
var options = Query<ZipOptions> (arcStrings.ZIPEncryptedNotice);
return options.Password;
}
public override ResourceOptions GetDefaultOptions ()
@ -184,9 +191,22 @@ namespace GameRes.Formats.PkWare
return new ZipOptions {
CompressionLevel = Properties.Settings.Default.ZIPCompression,
FileNameEncoding = enc,
Password = Properties.Settings.Default.ZIPPassword,
};
}
public override ResourceOptions GetOptions (object widget)
{
if (widget is GUI.WidgetZIP)
Properties.Settings.Default.ZIPPassword = ((GUI.WidgetZIP)widget).Password.Text;
return GetDefaultOptions();
}
public override object GetAccessWidget ()
{
return new GUI.WidgetZIP (DefaultScheme.KnownKeys);
}
// TODO: GUI widget for options
public override void Create (Stream output, IEnumerable<Entry> list, ResourceOptions options,
@ -209,11 +229,20 @@ namespace GameRes.Formats.PkWare
}
}
}
ZipScheme DefaultScheme = new ZipScheme { KnownKeys = new Dictionary<string, string>() };
public override ResourceScheme Scheme
{
get { return DefaultScheme; }
set { DefaultScheme = (ZipScheme)value; }
}
}
public class ZipOptions : ResourceOptions
{
public CompressionLevel CompressionLevel { get; set; }
public Encoding FileNameEncoding { get; set; }
public string Password { get; set; }
}
}

View File

@ -0,0 +1,15 @@
<StackPanel x:Class="GameRes.Formats.GUI.WidgetZIP"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:GameRes.Formats.Strings"
xmlns:p="clr-namespace:GameRes.Formats.Properties"
xmlns:zip="clr-namespace:GameRes.Formats.PkWare"
Orientation="Vertical">
<Label Content="{x:Static s:arcStrings.ZIPChoose}" HorizontalAlignment="Left"/>
<ComboBox Name="Title" Width="200" HorizontalAlignment="Left"
ItemsSource="{Binding RelativeSource={RelativeSource Self}, Path=DataContext}"
SelectedValue="{Binding ElementName=Password, Path=Text, Mode=TwoWay}" SelectedValuePath="Value"
DisplayMemberPath="Key"/>
<TextBox x:Name="Password" Width="200" HorizontalAlignment="Left" Margin="0,5,0,0"
Text="{Binding Source={x:Static p:Settings.Default}, Path=ZIPPassword, Mode=OneWay}"/>
</StackPanel>

View File

@ -0,0 +1,17 @@
using System.Collections;
using System.Windows.Controls;
namespace GameRes.Formats.GUI
{
/// <summary>
/// Interaction logic for WidgetZIP.xaml
/// </summary>
public partial class WidgetZIP : StackPanel
{
public WidgetZIP (IEnumerable titles)
{
InitializeComponent();
this.DataContext = titles;
}
}
}

View File

@ -717,5 +717,17 @@ namespace GameRes.Formats.Properties {
this["UpgradeRequired"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ZIPPassword {
get {
return ((string)(this["ZIPPassword"]));
}
set {
this["ZIPPassword"] = value;
}
}
}
}

View File

@ -176,5 +176,8 @@
<Setting Name="UpgradeRequired" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="ZIPPassword" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

View File

@ -862,5 +862,23 @@ namespace GameRes.Formats.Strings {
return ResourceManager.GetString("YPFTryGuess", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Choose title or enter a password.
/// </summary>
public static string ZIPChoose {
get {
return ResourceManager.GetString("ZIPChoose", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Archive content is encrypted..
/// </summary>
public static string ZIPEncryptedNotice {
get {
return ResourceManager.GetString("ZIPEncryptedNotice", resourceCulture);
}
}
}
}

View File

@ -491,4 +491,12 @@ Choose encryption scheme or enter a passphrase.</comment>
<value>増分フレームを自動的に結合する</value>
<comment>Automatically combine incremental frames</comment>
</data>
<data name="ZIPChoose" xml:space="preserve">
<value>タイトルを選択するか、パスワードを入力してください。</value>
<comment>Choose title or enter a password</comment>
</data>
<data name="ZIPEncryptedNotice" xml:space="preserve">
<value>アーカイブコンテンツは暗号化されています。</value>
<comment>Archive content is encrypted.</comment>
</data>
</root>

View File

@ -391,4 +391,10 @@
<value>Automatically combine incremental frames</value>
<comment>translation pending</comment>
</data>
<data name="ZIPChoose" xml:space="preserve">
<value>제목을 선택하거나 암호를 입력하세요</value>
</data>
<data name="ZIPEncryptedNotice" xml:space="preserve">
<value>아카이브 내용이 암호화됨.</value>
</data>
</root>

View File

@ -392,4 +392,10 @@ Choose encryption scheme or enter a passphrase.</value>
<data name="RCTOverlayFrames" xml:space="preserve">
<value>Automatically combine incremental frames</value>
</data>
<data name="ZIPChoose" xml:space="preserve">
<value>Choose title or enter a password</value>
</data>
<data name="ZIPEncryptedNotice" xml:space="preserve">
<value>Archive content is encrypted.</value>
</data>
</root>

View File

@ -347,4 +347,10 @@
<data name="YPFTryGuess" xml:space="preserve">
<value>Попытаться подобрать</value>
</data>
<data name="ZIPChoose" xml:space="preserve">
<value>Выберите наименование или введите пароль</value>
</data>
<data name="ZIPEncryptedNotice" xml:space="preserve">
<value>Содержимое архива зашифровано.</value>
</data>
</root>

View File

@ -392,4 +392,10 @@
<value>Automatically combine incremental frames</value>
<comment>translation pending</comment>
</data>
<data name="ZIPEncryptedNotice" xml:space="preserve">
<value>压缩文件的内容已被加密。</value>
</data>
<data name="ZIPChoose" xml:space="preserve">
<value>请选择游戏名称或输入密码</value>
</data>
</root>

View File

@ -178,6 +178,9 @@
<setting name="UpgradeRequired" serializeAs="String">
<value>True</value>
</setting>
<setting name="ZIPPassword" serializeAs="String">
<value />
</setting>
</GameRes.Formats.Properties.Settings>
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /></startup>