mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
(ZIP): query password for encrypted archives.
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
15
ArcFormats/PkWare/WidgetZIP.xaml
Normal file
15
ArcFormats/PkWare/WidgetZIP.xaml
Normal 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>
|
||||
17
ArcFormats/PkWare/WidgetZIP.xaml.cs
Normal file
17
ArcFormats/PkWare/WidgetZIP.xaml.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user