aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/UI/GUI/CompressDialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CPP/7zip/UI/GUI/CompressDialog.cpp724
1 files changed, 657 insertions, 67 deletions
diff --git a/CPP/7zip/UI/GUI/CompressDialog.cpp b/CPP/7zip/UI/GUI/CompressDialog.cpp
index 16a3585..25b9219 100644
--- a/CPP/7zip/UI/GUI/CompressDialog.cpp
+++ b/CPP/7zip/UI/GUI/CompressDialog.cpp
@@ -16,6 +16,7 @@
16#include "../FileManager/BrowseDialog.h" 16#include "../FileManager/BrowseDialog.h"
17#include "../FileManager/FormatUtils.h" 17#include "../FileManager/FormatUtils.h"
18#include "../FileManager/HelpUtils.h" 18#include "../FileManager/HelpUtils.h"
19#include "../FileManager/PropertyName.h"
19#include "../FileManager/SplitUtils.h" 20#include "../FileManager/SplitUtils.h"
20 21
21#include "../Explorer/MyMessages.h" 22#include "../Explorer/MyMessages.h"
@@ -36,6 +37,9 @@ extern bool g_IsNT;
36#include "ExtractRes.h" 37#include "ExtractRes.h"
37 38
38#ifdef LANG 39#ifdef LANG
40
41// #define IDS_OPTIONS 2100
42
39static const UInt32 kLangIDs[] = 43static const UInt32 kLangIDs[] =
40{ 44{
41 IDT_COMPRESS_ARCHIVE, 45 IDT_COMPRESS_ARCHIVE,
@@ -49,6 +53,8 @@ static const UInt32 kLangIDs[] =
49 IDT_COMPRESS_THREADS, 53 IDT_COMPRESS_THREADS,
50 IDT_COMPRESS_PARAMETERS, 54 IDT_COMPRESS_PARAMETERS,
51 55
56 IDB_COMPRESS_OPTIONS, // IDS_OPTIONS
57
52 IDG_COMPRESS_OPTIONS, 58 IDG_COMPRESS_OPTIONS,
53 IDX_COMPRESS_SFX, 59 IDX_COMPRESS_SFX,
54 IDX_COMPRESS_SHARED, 60 IDX_COMPRESS_SHARED,
@@ -57,11 +63,6 @@ static const UInt32 kLangIDs[] =
57 IDT_COMPRESS_MEMORY, 63 IDT_COMPRESS_MEMORY,
58 IDT_COMPRESS_MEMORY_DE, 64 IDT_COMPRESS_MEMORY_DE,
59 65
60 IDX_COMPRESS_NT_SYM_LINKS,
61 IDX_COMPRESS_NT_HARD_LINKS,
62 IDX_COMPRESS_NT_ALT_STREAMS,
63 IDX_COMPRESS_NT_SECUR,
64
65 IDG_COMPRESS_ENCRYPTION, 66 IDG_COMPRESS_ENCRYPTION,
66 IDT_COMPRESS_ENCRYPTION_METHOD, 67 IDT_COMPRESS_ENCRYPTION_METHOD,
67 IDX_COMPRESS_ENCRYPT_FILE_NAMES, 68 IDX_COMPRESS_ENCRYPT_FILE_NAMES,
@@ -71,7 +72,7 @@ static const UInt32 kLangIDs[] =
71 IDX_PASSWORD_SHOW, 72 IDX_PASSWORD_SHOW,
72 73
73 IDT_SPLIT_TO_VOLUMES, 74 IDT_SPLIT_TO_VOLUMES,
74 IDT_COMPRESS_PATH_MODE 75 IDT_COMPRESS_PATH_MODE,
75}; 76};
76#endif 77#endif
77 78
@@ -89,8 +90,6 @@ static const UInt32 kLzmaMaxDictSize = (UInt32)15 << 28;
89 90
90static LPCSTR const kExeExt = ".exe"; 91static LPCSTR const kExeExt = ".exe";
91 92
92#define k7zFormat "7z"
93
94static const UInt32 g_Levels[] = 93static const UInt32 g_Levels[] =
95{ 94{
96 IDS_METHOD_STORE, 95 IDS_METHOD_STORE,
@@ -119,6 +118,8 @@ enum EMethodID
119 kSha1, 118 kSha1,
120 kCrc32, 119 kCrc32,
121 kCrc64, 120 kCrc64,
121 kGnu,
122 kPosix
122}; 123};
123 124
124static LPCSTR const kMethodsNames[] = 125static LPCSTR const kMethodsNames[] =
@@ -135,6 +136,8 @@ static LPCSTR const kMethodsNames[] =
135 , "SHA1" 136 , "SHA1"
136 , "CRC32" 137 , "CRC32"
137 , "CRC64" 138 , "CRC64"
139 , "GNU"
140 , "POSIX"
138}; 141};
139 142
140static const EMethodID g_7zMethods[] = 143static const EMethodID g_7zMethods[] =
@@ -186,6 +189,12 @@ static const EMethodID g_SwfcMethods[] =
186 // kLZMA 189 // kLZMA
187}; 190};
188 191
192static const EMethodID g_TarMethods[] =
193{
194 kGnu,
195 kPosix
196};
197
189static const EMethodID g_HashMethods[] = 198static const EMethodID g_HashMethods[] =
190{ 199{
191 kSha256 200 kSha256
@@ -202,6 +211,13 @@ static const UInt32 kFF_EncryptFileNames = 1 << 4;
202static const UInt32 kFF_MemUse = 1 << 5; 211static const UInt32 kFF_MemUse = 1 << 5;
203static const UInt32 kFF_SFX = 1 << 6; 212static const UInt32 kFF_SFX = 1 << 6;
204 213
214/*
215static const UInt32 kFF_Time_Win = 1 << 10;
216static const UInt32 kFF_Time_Unix = 1 << 11;
217static const UInt32 kFF_Time_DOS = 1 << 12;
218static const UInt32 kFF_Time_1ns = 1 << 13;
219*/
220
205struct CFormatInfo 221struct CFormatInfo
206{ 222{
207 LPCSTR Name; 223 LPCSTR Name;
@@ -233,23 +249,26 @@ static const CFormatInfo g_Formats[] =
233 kFF_MultiThread | kFF_MemUse 249 kFF_MultiThread | kFF_MemUse
234 }, 250 },
235 { 251 {
236 k7zFormat, 252 "7z",
237 (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9), 253 (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
238 METHODS_PAIR(g_7zMethods), 254 METHODS_PAIR(g_7zMethods),
239 kFF_Filter | kFF_Solid | kFF_MultiThread | kFF_Encrypt | 255 kFF_Filter | kFF_Solid | kFF_MultiThread | kFF_Encrypt |
240 kFF_EncryptFileNames | kFF_MemUse | kFF_SFX 256 kFF_EncryptFileNames | kFF_MemUse | kFF_SFX
257 // | kFF_Time_Win
241 }, 258 },
242 { 259 {
243 "Zip", 260 "Zip",
244 (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9), 261 (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
245 METHODS_PAIR(g_ZipMethods), 262 METHODS_PAIR(g_ZipMethods),
246 kFF_MultiThread | kFF_Encrypt | kFF_MemUse 263 kFF_MultiThread | kFF_Encrypt | kFF_MemUse
264 // | kFF_Time_Win | kFF_Time_Unix | kFF_Time_DOS
247 }, 265 },
248 { 266 {
249 "GZip", 267 "GZip",
250 (1 << 1) | (1 << 5) | (1 << 7) | (1 << 9), 268 (1 << 1) | (1 << 5) | (1 << 7) | (1 << 9),
251 METHODS_PAIR(g_GZipMethods), 269 METHODS_PAIR(g_GZipMethods),
252 kFF_MemUse 270 kFF_MemUse
271 // | kFF_Time_Unix
253 }, 272 },
254 { 273 {
255 "BZip2", 274 "BZip2",
@@ -272,14 +291,15 @@ static const CFormatInfo g_Formats[] =
272 { 291 {
273 "Tar", 292 "Tar",
274 (1 << 0), 293 (1 << 0),
275 0, NULL, 294 METHODS_PAIR(g_TarMethods),
276 0 295 // kFF_Time_Unix | kFF_Time_Win // | kFF_Time_1ns
277 }, 296 },
278 { 297 {
279 "wim", 298 "wim",
280 (1 << 0), 299 (1 << 0),
281 0, NULL, 300 0, NULL,
282 0 301 0
302 // | kFF_Time_Win
283 }, 303 },
284 { 304 {
285 "Hash", 305 "Hash",
@@ -335,22 +355,6 @@ static const UInt32 k_PathMode_IDs[] =
335}; 355};
336 356
337void AddComboItems(NControl::CComboBox &combo, const UInt32 *langIDs, unsigned numItems, const int *values, int curVal); 357void AddComboItems(NControl::CComboBox &combo, const UInt32 *langIDs, unsigned numItems, const int *values, int curVal);
338bool GetBoolsVal(const CBoolPair &b1, const CBoolPair &b2);
339
340void CCompressDialog::CheckButton_TwoBools(UINT id, const CBoolPair &b1, const CBoolPair &b2)
341{
342 CheckButton(id, GetBoolsVal(b1, b2));
343}
344
345void CCompressDialog::GetButton_Bools(UINT id, CBoolPair &b1, CBoolPair &b2)
346{
347 bool val = IsButtonCheckedBool(id);
348 bool oldVal = GetBoolsVal(b1, b2);
349 if (val != oldVal)
350 b1.Def = b2.Def = true;
351 b1.Val = b2.Val = val;
352}
353
354 358
355void CCompressDialog::SetMethods(const CObjectVector<CCodecInfoUser> &userCodecs) 359void CCompressDialog::SetMethods(const CObjectVector<CCodecInfoUser> &userCodecs)
356{ 360{
@@ -375,12 +379,13 @@ void CCompressDialog::SetMethods(const CObjectVector<CCodecInfoUser> &userCodecs
375 } 379 }
376} 380}
377 381
378 382
379bool CCompressDialog::OnInit() 383bool CCompressDialog::OnInit()
380{ 384{
381 #ifdef LANG 385 #ifdef LANG
382 LangSetWindowText(*this, IDD_COMPRESS); 386 LangSetWindowText(*this, IDD_COMPRESS);
383 LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); 387 LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs));
388 // LangSetDlgItemText(*this, IDB_COMPRESS_OPTIONS, IDS_OPTIONS); // IDG_COMPRESS_OPTIONS
384 #endif 389 #endif
385 390
386 { 391 {
@@ -435,11 +440,6 @@ bool CCompressDialog::OnInit()
435 CheckButton(IDX_PASSWORD_SHOW, m_RegistryInfo.ShowPassword); 440 CheckButton(IDX_PASSWORD_SHOW, m_RegistryInfo.ShowPassword);
436 CheckButton(IDX_COMPRESS_ENCRYPT_FILE_NAMES, m_RegistryInfo.EncryptHeaders); 441 CheckButton(IDX_COMPRESS_ENCRYPT_FILE_NAMES, m_RegistryInfo.EncryptHeaders);
437 442
438 CheckButton_TwoBools(IDX_COMPRESS_NT_SYM_LINKS, Info.SymLinks, m_RegistryInfo.SymLinks);
439 CheckButton_TwoBools(IDX_COMPRESS_NT_HARD_LINKS, Info.HardLinks, m_RegistryInfo.HardLinks);
440 CheckButton_TwoBools(IDX_COMPRESS_NT_ALT_STREAMS, Info.AltStreams, m_RegistryInfo.AltStreams);
441 CheckButton_TwoBools(IDX_COMPRESS_NT_SECUR, Info.NtSecurity, m_RegistryInfo.NtSecurity);
442
443 UpdatePasswordControl(); 443 UpdatePasswordControl();
444 444
445 { 445 {
@@ -490,7 +490,7 @@ bool CCompressDialog::OnInit()
490 CheckButton(IDX_COMPRESS_SHARED, Info.OpenShareForWrite); 490 CheckButton(IDX_COMPRESS_SHARED, Info.OpenShareForWrite);
491 CheckButton(IDX_COMPRESS_DEL, Info.DeleteAfterCompressing); 491 CheckButton(IDX_COMPRESS_DEL, Info.DeleteAfterCompressing);
492 492
493 FormatChanged(); 493 FormatChanged(false); // isChanged
494 494
495 // OnButtonSFX(); 495 // OnButtonSFX();
496 496
@@ -552,6 +552,13 @@ bool CCompressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
552 UpdatePasswordControl(); 552 UpdatePasswordControl();
553 return true; 553 return true;
554 } 554 }
555 case IDB_COMPRESS_OPTIONS:
556 {
557 COptionsDialog dialog(this);
558 if (dialog.Create(*this) == IDOK)
559 ShowOptionsString();
560 return true;
561 }
555 } 562 }
556 return CModalDialog::OnButtonClicked(buttonID, buttonHWND); 563 return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
557} 564}
@@ -588,8 +595,44 @@ void CCompressDialog::EnableMultiCombo(unsigned id)
588 EnableItem(id, enable); 595 EnableItem(id, enable);
589} 596}
590 597
598static LRESULT ComboBox_AddStringAscii(NControl::CComboBox &cb, const char *s);
599static void FormatOptions_To_String(const NCompression::CFormatOptions &fo, AString &s);
591 600
592void CCompressDialog::FormatChanged() 601static void Combine_Two_BoolPairs(const CBoolPair &b1, const CBoolPair &b2, CBool1 &res)
602{
603 if (!b1.Def && b2.Def)
604 res.Val = b2.Val;
605 else
606 res.Val = b1.Val;
607}
608
609#define SET_GUI_BOOL(name) \
610 Combine_Two_BoolPairs(Info. ## name, m_RegistryInfo. ## name, name)
611
612
613static void Set_Final_BoolPairs(
614 const CBool1 &gui,
615 CBoolPair &cmd,
616 CBoolPair &reg)
617{
618 if (!cmd.Def)
619 {
620 reg.Val = gui.Val;
621 reg.Def = gui.Val;
622 }
623 if (gui.Supported)
624 {
625 cmd.Val = gui.Val;
626 cmd.Def = gui.Val;
627 }
628 else
629 cmd.Init();
630}
631
632#define SET_FINAL_BOOL_PAIRS(name) \
633 Set_Final_BoolPairs(name, Info. ## name, m_RegistryInfo. ## name)
634
635void CCompressDialog::FormatChanged(bool isChanged)
593{ 636{
594 SetLevel(); 637 SetLevel();
595 SetSolidBlockSize(); 638 SetSolidBlockSize();
@@ -615,18 +658,26 @@ void CCompressDialog::FormatChanged()
615 CheckSFXControlsEnable(); 658 CheckSFXControlsEnable();
616 659
617 { 660 {
618 const CArcInfoEx &ai = Get_ArcInfoEx(); 661 if (!isChanged)
619 662 {
620 ShowItem_Bool(IDX_COMPRESS_NT_SYM_LINKS, ai.Flags_SymLinks()); 663 SET_GUI_BOOL (SymLinks);
621 ShowItem_Bool(IDX_COMPRESS_NT_HARD_LINKS, ai.Flags_HardLinks()); 664 SET_GUI_BOOL (HardLinks);
622 ShowItem_Bool(IDX_COMPRESS_NT_ALT_STREAMS, ai.Flags_AltStreams()); 665 SET_GUI_BOOL (AltStreams);
623 ShowItem_Bool(IDX_COMPRESS_NT_SECUR, ai.Flags_NtSecure()); 666 SET_GUI_BOOL (NtSecurity);
667 SET_GUI_BOOL (PreserveATime);
668 }
624 669
625 ShowItem_Bool(IDG_COMPRESS_NTFS, 670 PreserveATime.Supported = true;
626 ai.Flags_SymLinks() 671
627 || ai.Flags_HardLinks() 672 {
628 || ai.Flags_AltStreams() 673 const CArcInfoEx &ai = Get_ArcInfoEx();
629 || ai.Flags_NtSecure()); 674 SymLinks.Supported = ai.Flags_SymLinks();
675 HardLinks.Supported = ai.Flags_HardLinks();
676 AltStreams.Supported = ai.Flags_AltStreams();
677 NtSecurity.Supported = ai.Flags_NtSecurity();
678 }
679
680 ShowOptionsString();
630 } 681 }
631 // CheckVolumeEnable(); 682 // CheckVolumeEnable();
632 683
@@ -821,7 +872,7 @@ void SetErrorMessage_MemUsage(UString &s, UInt64 reqSize, UInt64 ramSize, UInt64
821 872
822 s.Add_LF(); 873 s.Add_LF();
823 s.Add_LF(); 874 s.Add_LF();
824 s += LangString(IDS_MEM_ERROR); 875 AddLangString(s, IDS_MEM_ERROR);
825} 876}
826 877
827 878
@@ -933,17 +984,32 @@ void CCompressDialog::OnOK()
933 Info.EncryptHeaders = IsButtonCheckedBool(IDX_COMPRESS_ENCRYPT_FILE_NAMES); 984 Info.EncryptHeaders = IsButtonCheckedBool(IDX_COMPRESS_ENCRYPT_FILE_NAMES);
934 985
935 986
936 GetButton_Bools(IDX_COMPRESS_NT_SYM_LINKS, Info.SymLinks, m_RegistryInfo.SymLinks); 987 /* (Info) is for saving to registry:
937 GetButton_Bools(IDX_COMPRESS_NT_HARD_LINKS, Info.HardLinks, m_RegistryInfo.HardLinks); 988 (CBoolPair::Val) will be set as (false), if it was (false)
938 GetButton_Bools(IDX_COMPRESS_NT_ALT_STREAMS, Info.AltStreams, m_RegistryInfo.AltStreams); 989 in registry at dialog creation, and user didn't click checkbox.
939 GetButton_Bools(IDX_COMPRESS_NT_SECUR, Info.NtSecurity, m_RegistryInfo.NtSecurity); 990 in another case (CBoolPair::Val) will be set as (true) */
940 991
941 { 992 {
942 const CArcInfoEx &ai = Get_ArcInfoEx(); 993 /* Info properties could be for another archive types.
943 if (!ai.Flags_SymLinks()) Info.SymLinks.Val = false; 994 so we disable unsupported properties in Info */
944 if (!ai.Flags_HardLinks()) Info.HardLinks.Val = false; 995 // const CArcInfoEx &ai = Get_ArcInfoEx();
945 if (!ai.Flags_AltStreams()) Info.AltStreams.Val = false; 996
946 if (!ai.Flags_NtSecure()) Info.NtSecurity.Val = false; 997 SET_FINAL_BOOL_PAIRS (SymLinks);
998 SET_FINAL_BOOL_PAIRS (HardLinks);
999 SET_FINAL_BOOL_PAIRS (AltStreams);
1000 SET_FINAL_BOOL_PAIRS (NtSecurity);
1001
1002 SET_FINAL_BOOL_PAIRS (PreserveATime);
1003 }
1004
1005 {
1006 const NCompression::CFormatOptions &fo = Get_FormatOptions();
1007
1008 Info.TimePrec = fo.TimePrec;
1009 Info.MTime = fo.MTime;
1010 Info.CTime = fo.CTime;
1011 Info.ATime = fo.ATime;
1012 Info.SetArcMTime = fo.SetArcMTime;
947 } 1013 }
948 1014
949 m_Params.GetText(Info.Options); 1015 m_Params.GetText(Info.Options);
@@ -1031,7 +1097,7 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
1031 { 1097 {
1032 const bool isSFX = IsSFX(); 1098 const bool isSFX = IsSFX();
1033 SaveOptionsInMem(); 1099 SaveOptionsInMem();
1034 FormatChanged(); 1100 FormatChanged(true); // isChanged
1035 SetArchiveName2(isSFX); 1101 SetArchiveName2(isSFX);
1036 return true; 1102 return true;
1037 } 1103 }
@@ -1057,6 +1123,7 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
1057 SetMemoryUsage(); 1123 SetMemoryUsage();
1058 if (Get_ArcInfoEx().Flags_HashHandler()) 1124 if (Get_ArcInfoEx().Flags_HashHandler())
1059 SetArchiveName2(false); 1125 SetArchiveName2(false);
1126
1060 return true; 1127 return true;
1061 } 1128 }
1062 1129
@@ -1188,6 +1255,7 @@ void CCompressDialog::SetArchiveName(const UString &name)
1188 m_ArchivePath.SetText(fileName); 1255 m_ArchivePath.SetText(fileName);
1189} 1256}
1190 1257
1258
1191int CCompressDialog::FindRegistryFormat(const UString &name) 1259int CCompressDialog::FindRegistryFormat(const UString &name)
1192{ 1260{
1193 FOR_VECTOR (i, m_RegistryInfo.Formats) 1261 FOR_VECTOR (i, m_RegistryInfo.Formats)
@@ -1199,7 +1267,8 @@ int CCompressDialog::FindRegistryFormat(const UString &name)
1199 return -1; 1267 return -1;
1200} 1268}
1201 1269
1202int CCompressDialog::FindRegistryFormatAlways(const UString &name) 1270
1271unsigned CCompressDialog::FindRegistryFormat_Always(const UString &name)
1203{ 1272{
1204 int index = FindRegistryFormat(name); 1273 int index = FindRegistryFormat(name);
1205 if (index < 0) 1274 if (index < 0)
@@ -1211,6 +1280,14 @@ int CCompressDialog::FindRegistryFormatAlways(const UString &name)
1211 return index; 1280 return index;
1212} 1281}
1213 1282
1283
1284NCompression::CFormatOptions &CCompressDialog::Get_FormatOptions()
1285{
1286 const CArcInfoEx &ai = Get_ArcInfoEx();
1287 return m_RegistryInfo.Formats[FindRegistryFormat_Always(ai.Name)];
1288}
1289
1290
1214int CCompressDialog::GetStaticFormatIndex() 1291int CCompressDialog::GetStaticFormatIndex()
1215{ 1292{
1216 const CArcInfoEx &ai = Get_ArcInfoEx(); 1293 const CArcInfoEx &ai = Get_ArcInfoEx();
@@ -1293,8 +1370,11 @@ void CCompressDialog::SetMethod2(int keepMethodId)
1293 const CArcInfoEx &ai = Get_ArcInfoEx(); 1370 const CArcInfoEx &ai = Get_ArcInfoEx();
1294 if (GetLevel() == 0 && !ai.Flags_HashHandler()) 1371 if (GetLevel() == 0 && !ai.Flags_HashHandler())
1295 { 1372 {
1296 MethodChanged(); 1373 if (!ai.Is_Tar())
1297 return; 1374 {
1375 MethodChanged();
1376 return;
1377 }
1298 } 1378 }
1299 UString defaultMethod; 1379 UString defaultMethod;
1300 { 1380 {
@@ -1308,7 +1388,7 @@ void CCompressDialog::SetMethod2(int keepMethodId)
1308 const bool isSfx = IsSFX(); 1388 const bool isSfx = IsSFX();
1309 bool weUseSameMethod = false; 1389 bool weUseSameMethod = false;
1310 1390
1311 const bool is7z = ai.Name.IsEqualTo_Ascii_NoCase("7z"); 1391 const bool is7z = ai.Is_7z();
1312 1392
1313 for (unsigned m = 0;; m++) 1393 for (unsigned m = 0;; m++)
1314 { 1394 {
@@ -1367,12 +1447,12 @@ void CCompressDialog::SetMethod2(int keepMethodId)
1367 1447
1368bool CCompressDialog::IsZipFormat() 1448bool CCompressDialog::IsZipFormat()
1369{ 1449{
1370 return Get_ArcInfoEx().Name.IsEqualTo_Ascii_NoCase("zip"); 1450 return Get_ArcInfoEx().Is_Zip();
1371} 1451}
1372 1452
1373bool CCompressDialog::IsXzFormat() 1453bool CCompressDialog::IsXzFormat()
1374{ 1454{
1375 return Get_ArcInfoEx().Name.IsEqualTo_Ascii_NoCase("xz"); 1455 return Get_ArcInfoEx().Is_Xz();
1376} 1456}
1377 1457
1378void CCompressDialog::SetEncryptionMethod() 1458void CCompressDialog::SetEncryptionMethod()
@@ -1380,13 +1460,13 @@ void CCompressDialog::SetEncryptionMethod()
1380 _encryptionMethod.ResetContent(); 1460 _encryptionMethod.ResetContent();
1381 _default_encryptionMethod_Index = -1; 1461 _default_encryptionMethod_Index = -1;
1382 const CArcInfoEx &ai = Get_ArcInfoEx(); 1462 const CArcInfoEx &ai = Get_ArcInfoEx();
1383 if (ai.Name.IsEqualTo_Ascii_NoCase("7z")) 1463 if (ai.Is_7z())
1384 { 1464 {
1385 ComboBox_AddStringAscii(_encryptionMethod, "AES-256"); 1465 ComboBox_AddStringAscii(_encryptionMethod, "AES-256");
1386 _encryptionMethod.SetCurSel(0); 1466 _encryptionMethod.SetCurSel(0);
1387 _default_encryptionMethod_Index = 0; 1467 _default_encryptionMethod_Index = 0;
1388 } 1468 }
1389 else if (ai.Name.IsEqualTo_Ascii_NoCase("zip")) 1469 else if (ai.Is_Zip())
1390 { 1470 {
1391 int index = FindRegistryFormat(ai.Name); 1471 int index = FindRegistryFormat(ai.Name);
1392 UString encryptionMethod; 1472 UString encryptionMethod;
@@ -1929,7 +2009,7 @@ void CCompressDialog::SetSolidBlockSize2()
1929 } 2009 }
1930 } 2010 }
1931 2011
1932 const bool is7z = ai.Name.IsEqualTo_Ascii_NoCase("7z"); 2012 const bool is7z = ai.Is_7z();
1933 2013
1934 const UInt64 cs = Get_Lzma2_ChunkSize(dict); 2014 const UInt64 cs = Get_Lzma2_ChunkSize(dict);
1935 2015
@@ -2549,11 +2629,16 @@ void CCompressDialog::SetParams()
2549 2629
2550void CCompressDialog::SaveOptionsInMem() 2630void CCompressDialog::SaveOptionsInMem()
2551{ 2631{
2632 /* these options are for (Info.FormatIndex).
2633 If it's called just after format changing,
2634 then it's format that was selected before format changing
2635 So we store previous format properties */
2636
2552 m_Params.GetText(Info.Options); 2637 m_Params.GetText(Info.Options);
2553 Info.Options.Trim(); 2638 Info.Options.Trim();
2554 2639
2555 const CArcInfoEx &ai = (*ArcFormats)[Info.FormatIndex]; 2640 const CArcInfoEx &ai = (*ArcFormats)[Info.FormatIndex];
2556 const int index = FindRegistryFormatAlways(ai.Name); 2641 const unsigned index = FindRegistryFormat_Always(ai.Name);
2557 NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; 2642 NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
2558 fo.Options = Info.Options; 2643 fo.Options = Info.Options;
2559 fo.Level = GetLevelSpec(); 2644 fo.Level = GetLevelSpec();
@@ -2587,7 +2672,512 @@ void CCompressDialog::SaveOptionsInMem()
2587 fo.MemUse = Get_MemUse_Spec(); 2672 fo.MemUse = Get_MemUse_Spec();
2588} 2673}
2589 2674
2675
2590unsigned CCompressDialog::GetFormatIndex() 2676unsigned CCompressDialog::GetFormatIndex()
2591{ 2677{
2592 return (unsigned)m_Format.GetItemData_of_CurSel(); 2678 return (unsigned)m_Format.GetItemData_of_CurSel();
2593} 2679}
2680
2681
2682
2683static void AddText_from_BoolPair(AString &s, const char *name, const CBoolPair &bp)
2684{
2685 if (bp.Def)
2686 {
2687 s.Add_OptSpaced(name);
2688 if (!bp.Val)
2689 s += "-";
2690 }
2691 /*
2692 else if (bp.Val)
2693 {
2694 s.Add_OptSpaced("[");
2695 s += name;
2696 s += "]";
2697 }
2698 */
2699}
2700
2701
2702static void AddText_from_Bool1(AString &s, const char *name, const CBool1 &b)
2703{
2704 if (b.Supported && b.Val)
2705 s.Add_OptSpaced(name);
2706}
2707
2708
2709void CCompressDialog::ShowOptionsString()
2710{
2711 NCompression::CFormatOptions &fo = Get_FormatOptions();
2712
2713 AString s;
2714 if (fo.TimePrec != -1)
2715 {
2716 s.Add_OptSpaced("tp");
2717 s.Add_UInt32(fo.TimePrec);
2718 }
2719 AddText_from_BoolPair(s, "tm", fo.MTime);
2720 AddText_from_BoolPair(s, "tc", fo.CTime);
2721 AddText_from_BoolPair(s, "ta", fo.ATime);
2722 AddText_from_BoolPair(s, "-stl", fo.SetArcMTime);
2723
2724 // const CArcInfoEx &ai = Get_ArcInfoEx();
2725 AddText_from_Bool1(s, "SL", SymLinks);
2726 AddText_from_Bool1(s, "HL", HardLinks);
2727 AddText_from_Bool1(s, "AS", AltStreams);
2728 AddText_from_Bool1(s, "Sec", NtSecurity);
2729
2730 // AddText_from_Bool1(s, "Preserve", PreserveATime);
2731
2732 SetItemText(IDT_COMPRESS_OPTIONS, GetUnicodeString(s));
2733}
2734
2735
2736
2737
2738
2739// ---------- OPTIONS ----------
2740
2741
2742void COptionsDialog::CheckButton_Bool1(UINT id, const CBool1 &b1)
2743{
2744 CheckButton(id, b1.Val);
2745}
2746
2747void COptionsDialog::GetButton_Bool1(UINT id, CBool1 &b1)
2748{
2749 b1.Val = IsButtonCheckedBool(id);
2750}
2751
2752
2753void COptionsDialog::CheckButton_BoolBox(
2754 bool supported, const CBoolPair &b2, CBoolBox &bb)
2755{
2756 const bool isSet = b2.Def;
2757 const bool val = isSet ? b2.Val : bb.DefaultVal;
2758
2759 bb.IsSupported = supported;
2760
2761 CheckButton (bb.Set_Id, isSet);
2762 ShowItem_Bool (bb.Set_Id, supported);
2763 CheckButton (bb.Id, val);
2764 EnableItem (bb.Id, isSet);
2765 ShowItem_Bool (bb.Id, supported);
2766}
2767
2768void COptionsDialog::GetButton_BoolBox(CBoolBox &bb)
2769{
2770 // we save value for invisible buttons too
2771 bb.BoolPair.Val = IsButtonCheckedBool (bb.Id);
2772 bb.BoolPair.Def = IsButtonCheckedBool (bb.Set_Id);
2773}
2774
2775
2776void COptionsDialog::Store_TimeBoxes()
2777{
2778 TimePrec = GetPrecSpec();
2779 GetButton_BoolBox (MTime);
2780 GetButton_BoolBox (CTime);
2781 GetButton_BoolBox (ATime);
2782 GetButton_BoolBox (ZTime);
2783}
2784
2785
2786UInt32 COptionsDialog::GetComboValue(NWindows::NControl::CComboBox &c, int defMax)
2787{
2788 if (c.GetCount() <= defMax)
2789 return (UInt32)(Int32)-1;
2790 return (UInt32)c.GetItemData_of_CurSel();
2791}
2792
2793static const unsigned kTimePrec_Win = 0;
2794static const unsigned kTimePrec_Unix = 1;
2795static const unsigned kTimePrec_DOS = 2;
2796static const unsigned kTimePrec_1ns = 3;
2797
2798static void AddTimeOption(UString &s, UInt32 val, const UString &unit, const char *sys = NULL)
2799{
2800 // s += " : ";
2801 {
2802 AString s2;
2803 s2.Add_UInt32(val);
2804 s += s2;
2805 }
2806 s.Add_Space();
2807 s += unit;
2808 if (sys)
2809 {
2810 s += " : ";
2811 s += sys;
2812 }
2813}
2814
2815int COptionsDialog::AddPrec(unsigned prec, bool isDefault)
2816{
2817 UString s;
2818 UInt32 writePrec = prec;
2819 if (isDefault)
2820 {
2821 // s += "* ";
2822 // writePrec = (UInt32)(Int32)-1;
2823 }
2824 if (prec == kTimePrec_Win) AddTimeOption(s, 100, NsString, "Windows");
2825 else if (prec == kTimePrec_Unix) AddTimeOption(s, 1, SecString, "Unix");
2826 else if (prec == kTimePrec_DOS) AddTimeOption(s, 2, SecString, "DOS");
2827 else if (prec == kTimePrec_1ns) AddTimeOption(s, 1, NsString, "Linux");
2828 else if (prec == k_PropVar_TimePrec_Base) AddTimeOption(s, 1, SecString);
2829 else if (prec >= k_PropVar_TimePrec_Base)
2830 {
2831 UInt32 d = 1;
2832 for (unsigned i = prec; i < k_PropVar_TimePrec_Base + 9; i++)
2833 d *= 10;
2834 AddTimeOption(s, d, NsString);
2835 }
2836 else
2837 s.Add_UInt32(prec);
2838 const int index = (int)m_Prec.AddString(s);
2839 m_Prec.SetItemData(index, writePrec);
2840 return index;
2841}
2842
2843
2844void COptionsDialog::SetPrec()
2845{
2846 // const CFormatInfo &fi = g_Formats[cd->GetStaticFormatIndex()];
2847 const CArcInfoEx &ai = cd->Get_ArcInfoEx();
2848
2849 // UInt32 flags = fi.Flags;
2850
2851 UInt32 flags = ai.Get_TimePrecFlags();
2852 UInt32 defaultPrec = ai.Get_DefaultTimePrec();
2853 if (defaultPrec != 0)
2854 flags |= ((UInt32)1 << defaultPrec);
2855
2856 // const NCompression::CFormatOptions &fo = cd->Get_FormatOptions();
2857
2858 // unsigned defaultPrec = kTimePrec_Win;
2859
2860 if (ai.Is_GZip())
2861 defaultPrec = kTimePrec_Unix;
2862
2863 {
2864 UString s;
2865 s += GetNameOfProperty(kpidType, L"type");
2866 s += ": ";
2867 s += ai.Name;
2868 if (ai.Is_Tar())
2869 {
2870 const int methodID = cd->GetMethodID();
2871
2872 // for debug
2873 // defaultPrec = kTimePrec_Unix;
2874 // flags = (UInt32)1 << kTimePrec_Unix;
2875
2876 s += ":";
2877 if (methodID >= 0 && (unsigned)methodID < ARRAY_SIZE(kMethodsNames))
2878 s += kMethodsNames[methodID];
2879 if (methodID == kPosix)
2880 {
2881 // for debug
2882 // flags |= (UInt32)1 << kTimePrec_Win;
2883 // flags |= (UInt32)1 << kTimePrec_1ns;
2884 }
2885 }
2886 else
2887 {
2888 // if (is_for_MethodChanging) return;
2889 }
2890
2891 SetItemText(IDT_COMPRESS_TIME_INFO, s);
2892 }
2893
2894 m_Prec.ResetContent();
2895 _auto_Prec = defaultPrec;
2896
2897 unsigned selectedPrec = defaultPrec;
2898 {
2899 // if (TimePrec >= kTimePrec_Win && TimePrec <= kTimePrec_DOS)
2900 if ((Int32)TimePrec >= 0)
2901 selectedPrec = TimePrec;
2902 }
2903
2904 int curSel = -1;
2905 int defaultPrecIndex = -1;
2906 for (unsigned prec = 0;
2907 // prec <= k_PropVar_TimePrec_HighPrec;
2908 prec <= k_PropVar_TimePrec_1ns;
2909 prec++)
2910 {
2911 if (((flags >> prec) & 1) == 0)
2912 continue;
2913 const bool isDefault = (defaultPrec == prec);
2914 const int index = AddPrec(prec, isDefault);
2915 if (isDefault)
2916 defaultPrecIndex = index;
2917 if (selectedPrec == prec)
2918 curSel = index;
2919 }
2920
2921 if (curSel < 0 && selectedPrec > kTimePrec_DOS)
2922 curSel = AddPrec(selectedPrec, false); // isDefault
2923 if (curSel < 0)
2924 curSel = defaultPrecIndex;
2925 if (curSel >= 0)
2926 m_Prec.SetCurSel(curSel);
2927
2928 {
2929 const bool isSet = IsSet_TimePrec();
2930 const int count = m_Prec.GetCount();
2931 const bool showPrec = (count != 0);
2932 ShowItem_Bool(IDC_COMPRESS_TIME_PREC, showPrec);
2933 ShowItem_Bool(IDT_COMPRESS_TIME_PREC, showPrec);
2934 EnableItem(IDC_COMPRESS_TIME_PREC, isSet && (count > 1));
2935
2936 CheckButton(IDX_COMPRESS_PREC_SET, isSet);
2937 const bool setIsSupported = isSet || (count > 1);
2938 EnableItem(IDX_COMPRESS_PREC_SET, setIsSupported);
2939 ShowItem_Bool(IDX_COMPRESS_PREC_SET, setIsSupported);
2940 }
2941
2942 SetTimeMAC();
2943}
2944
2945
2946void COptionsDialog::SetTimeMAC()
2947{
2948 const CArcInfoEx &ai = cd->Get_ArcInfoEx();
2949
2950 const
2951 bool m_allow = ai.Flags_MTime();
2952 bool c_allow = ai.Flags_CTime();
2953 bool a_allow = ai.Flags_ATime();
2954
2955 if (ai.Is_Tar())
2956 {
2957 const int methodID = cd->GetMethodID();
2958 c_allow = false;
2959 a_allow = false;
2960 if (methodID == kPosix)
2961 {
2962 // c_allow = true; // do we need it as change time ?
2963 a_allow = true;
2964 }
2965 }
2966
2967 if (ai.Is_Zip())
2968 {
2969 // const int methodID = GetMethodID();
2970 UInt32 prec = GetPrec();
2971 if (prec == (UInt32)(Int32)-1)
2972 prec = _auto_Prec;
2973 if (prec != kTimePrec_Win)
2974 {
2975 c_allow = false;
2976 a_allow = false;
2977 }
2978 }
2979
2980
2981 /*
2982 MTime.DefaultVal = true;
2983 CTime.DefaultVal = false;
2984 ATime.DefaultVal = false;
2985 */
2986
2987 MTime.DefaultVal = ai.Flags_MTime_Default();
2988 CTime.DefaultVal = ai.Flags_CTime_Default();
2989 ATime.DefaultVal = ai.Flags_ATime_Default();
2990
2991 ZTime.DefaultVal = false;
2992
2993 const NCompression::CFormatOptions &fo = cd->Get_FormatOptions();
2994
2995 CheckButton_BoolBox (m_allow, fo.MTime, MTime );
2996 CheckButton_BoolBox (c_allow, fo.CTime, CTime );
2997 CheckButton_BoolBox (a_allow, fo.ATime, ATime );
2998 CheckButton_BoolBox (true, fo.SetArcMTime, ZTime);
2999
3000 if (m_allow && !fo.MTime.Def)
3001 {
3002 const bool isSingleFile = ai.Flags_KeepName();
3003 if (!isSingleFile)
3004 {
3005 // we can hide changing checkboxes for MTime here:
3006 ShowItem_Bool (MTime.Set_Id, false);
3007 EnableItem (MTime.Id, false);
3008 }
3009 }
3010 // On_CheckBoxSet_Prec_Clicked();
3011 // const bool isSingleFile = ai.Flags_KeepName();
3012 // mtime for Gz can be
3013}
3014
3015
3016
3017void COptionsDialog::On_CheckBoxSet_Prec_Clicked()
3018{
3019 const bool isSet = IsButtonCheckedBool(IDX_COMPRESS_PREC_SET);
3020 if (!isSet)
3021 {
3022 // We save current MAC boxes to memory before SetPrec()
3023 Store_TimeBoxes();
3024 Reset_TimePrec();
3025 SetPrec();
3026 }
3027 EnableItem(IDC_COMPRESS_TIME_PREC, isSet);
3028}
3029
3030void COptionsDialog::On_CheckBoxSet_Clicked(const CBoolBox &bb)
3031{
3032 const bool isSet = IsButtonCheckedBool(bb.Set_Id);
3033 if (!isSet)
3034 CheckButton(bb.Id, bb.DefaultVal);
3035 EnableItem(bb.Id, isSet);
3036}
3037
3038
3039
3040
3041#ifdef LANG
3042static const UInt32 kLangIDs_Options[] =
3043{
3044 IDX_COMPRESS_NT_SYM_LINKS,
3045 IDX_COMPRESS_NT_HARD_LINKS,
3046 IDX_COMPRESS_NT_ALT_STREAMS,
3047 IDX_COMPRESS_NT_SECUR,
3048
3049 IDG_COMPRESS_TIME,
3050 IDT_COMPRESS_TIME_PREC,
3051 IDX_COMPRESS_MTIME,
3052 IDX_COMPRESS_CTIME,
3053 IDX_COMPRESS_ATIME,
3054 IDX_COMPRESS_ZTIME,
3055 IDX_COMPRESS_PRESERVE_ATIME
3056};
3057#endif
3058
3059
3060bool COptionsDialog::OnInit()
3061{
3062 #ifdef LANG
3063 LangSetWindowText(*this, IDB_COMPRESS_OPTIONS); // IDS_OPTIONS
3064 LangSetDlgItems(*this, kLangIDs_Options, ARRAY_SIZE(kLangIDs_Options));
3065 // LangSetDlgItemText(*this, IDB_COMPRESS_TIME_DEFAULT, IDB_COMPRESS_TIME_DEFAULT);
3066 // LangSetDlgItemText(*this, IDX_COMPRESS_TIME_DEFAULT, IDX_COMPRESS_TIME_DEFAULT);
3067 #endif
3068
3069 LangString(IDS_COMPRESS_SEC, SecString);
3070 if (SecString.IsEmpty())
3071 SecString = "sec";
3072 LangString(IDS_COMPRESS_NS, NsString);
3073 if (NsString.IsEmpty())
3074 NsString = "ns";
3075
3076 {
3077 // const CArcInfoEx &ai = cd->Get_ArcInfoEx();
3078
3079 ShowItem_Bool ( IDX_COMPRESS_NT_SYM_LINKS, cd->SymLinks.Supported);
3080 ShowItem_Bool ( IDX_COMPRESS_NT_HARD_LINKS, cd->HardLinks.Supported);
3081 ShowItem_Bool ( IDX_COMPRESS_NT_ALT_STREAMS, cd->AltStreams.Supported);
3082 ShowItem_Bool ( IDX_COMPRESS_NT_SECUR, cd->NtSecurity.Supported);
3083
3084 ShowItem_Bool ( IDG_COMPRESS_NTFS,
3085 cd->SymLinks.Supported
3086 || cd->HardLinks.Supported
3087 || cd->AltStreams.Supported
3088 || cd->NtSecurity.Supported);
3089 }
3090
3091 /* we read property from two sources:
3092 1) command line : (Info)
3093 2) registry : (m_RegistryInfo)
3094 (Info) has priority, if both are no defined */
3095
3096 CheckButton_Bool1 ( IDX_COMPRESS_NT_SYM_LINKS, cd->SymLinks);
3097 CheckButton_Bool1 ( IDX_COMPRESS_NT_HARD_LINKS, cd->HardLinks);
3098 CheckButton_Bool1 ( IDX_COMPRESS_NT_ALT_STREAMS, cd->AltStreams);
3099 CheckButton_Bool1 ( IDX_COMPRESS_NT_SECUR, cd->NtSecurity);
3100
3101 CheckButton_Bool1 (IDX_COMPRESS_PRESERVE_ATIME, cd->PreserveATime);
3102
3103 m_Prec.Attach (GetItem(IDC_COMPRESS_TIME_PREC));
3104
3105 MTime.SetIDs ( IDX_COMPRESS_MTIME, IDX_COMPRESS_MTIME_SET);
3106 CTime.SetIDs ( IDX_COMPRESS_CTIME, IDX_COMPRESS_CTIME_SET);
3107 ATime.SetIDs ( IDX_COMPRESS_ATIME, IDX_COMPRESS_ATIME_SET);
3108 ZTime.SetIDs ( IDX_COMPRESS_ZTIME, IDX_COMPRESS_ZTIME_SET);
3109
3110 {
3111 const NCompression::CFormatOptions &fo = cd->Get_FormatOptions();
3112 TimePrec = fo.TimePrec;
3113 MTime.BoolPair = fo.MTime;
3114 CTime.BoolPair = fo.CTime;
3115 ATime.BoolPair = fo.ATime;
3116 ZTime.BoolPair = fo.SetArcMTime;
3117 }
3118
3119 SetPrec();
3120
3121 NormalizePosition();
3122
3123 return CModalDialog::OnInit();
3124}
3125
3126
3127bool COptionsDialog::OnCommand(int code, int itemID, LPARAM lParam)
3128{
3129 if (code == CBN_SELCHANGE)
3130 {
3131 switch (itemID)
3132 {
3133 case IDC_COMPRESS_TIME_PREC:
3134 {
3135 Store_TimeBoxes();
3136 SetTimeMAC(); // for zip/tar
3137 return true;
3138 }
3139 }
3140 }
3141 return CModalDialog::OnCommand(code, itemID, lParam);
3142}
3143
3144
3145bool COptionsDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
3146{
3147 switch (buttonID)
3148 {
3149 case IDX_COMPRESS_PREC_SET: { On_CheckBoxSet_Prec_Clicked(); return true; }
3150 case IDX_COMPRESS_MTIME_SET: { On_CheckBoxSet_Clicked (MTime); return true; }
3151 case IDX_COMPRESS_CTIME_SET: { On_CheckBoxSet_Clicked (CTime); return true; }
3152 case IDX_COMPRESS_ATIME_SET: { On_CheckBoxSet_Clicked (ATime); return true; }
3153 case IDX_COMPRESS_ZTIME_SET: { On_CheckBoxSet_Clicked (ZTime); return true; }
3154 }
3155 return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
3156}
3157
3158
3159void COptionsDialog::OnOK()
3160{
3161 GetButton_Bool1 (IDX_COMPRESS_NT_SYM_LINKS, cd->SymLinks);
3162 GetButton_Bool1 (IDX_COMPRESS_NT_HARD_LINKS, cd->HardLinks);
3163 GetButton_Bool1 (IDX_COMPRESS_NT_ALT_STREAMS, cd->AltStreams);
3164 GetButton_Bool1 (IDX_COMPRESS_NT_SECUR, cd->NtSecurity);
3165 GetButton_Bool1 (IDX_COMPRESS_PRESERVE_ATIME, cd->PreserveATime);
3166
3167 Store_TimeBoxes();
3168 {
3169 NCompression::CFormatOptions &fo = cd->Get_FormatOptions();
3170 fo.TimePrec = TimePrec;
3171 fo.MTime = MTime.BoolPair;
3172 fo.CTime = CTime.BoolPair;
3173 fo.ATime = ATime.BoolPair;
3174 fo.SetArcMTime = ZTime.BoolPair;
3175 }
3176
3177 CModalDialog::OnOK();
3178}
3179
3180void COptionsDialog::OnHelp()
3181{
3182 ShowHelpWindow(kHelpTopic);
3183}