diff options
Diffstat (limited to 'installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI')
22 files changed, 5513 insertions, 0 deletions
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog.cpp new file mode 100644 index 000000000..c7a1cc5be --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog.cpp @@ -0,0 +1,581 @@ +// BenchmarkDialog.cpp + +#include "StdAfx.h" + +#include "Common/IntToString.h" +#include "Common/StringToInt.h" +#include "Common/MyException.h" +#include "Windows/Thread.h" +#include "Windows/Error.h" +#include "Windows/System.h" +#include "../FileManager/HelpUtils.h" +// #include "BenchmarkDialogRes.h" +#include "BenchmarkDialog.h" + +using namespace NWindows; + +// const int kNumBenchDictionaryBitsStart = 21; + +static LPCWSTR kHelpTopic = L"fm/benchmark.htm"; + +static const UINT_PTR kTimerID = 4; +static const UINT kTimerElapse = 1000; + +#ifdef LANG +#include "../FileManager/LangUtils.h" +#endif + +using namespace NWindows; + +#ifdef LANG +static CIDLangPair kIDLangPairs[] = +{ + { IDC_BENCHMARK_DICTIONARY, 0x02000D0C }, + { IDC_BENCHMARK_MEMORY, 0x03080001 }, + { IDC_BENCHMARK_NUM_THREADS, 0x02000D12 }, + { IDC_BENCHMARK_SPEED_LABEL, 0x03080004 }, + { IDC_BENCHMARK_RATING_LABEL, 0x03080005 }, + { IDC_BENCHMARK_COMPRESSING, 0x03080002 }, + { IDC_BENCHMARK_DECOMPRESSING, 0x03080003 }, + { IDC_BENCHMARK_CURRENT, 0x03080007 }, + { IDC_BENCHMARK_RESULTING, 0x03080008 }, + { IDC_BENCHMARK_CURRENT2, 0x03080007 }, + { IDC_BENCHMARK_RESULTING2, 0x03080008 }, + { IDC_BENCHMARK_TOTAL_RATING, 0x03080006 }, + { IDC_BENCHMARK_ELAPSED, 0x02000C01 }, + { IDC_BENCHMARK_SIZE, 0x02000C03 }, + { IDC_BENCHMARK_PASSES, 0x03080009 }, + // { IDC_BENCHMARK_ERRORS, 0x0308000A }, + { IDC_BENCHMARK_USAGE_LABEL, 0x0308000B }, + { IDC_BENCHMARK_RPU_LABEL, 0x0308000C }, + { IDC_BENCHMARK_COMBO_NUM_THREADS, 0x02000D12}, + + { IDC_BUTTON_STOP, 0x02000714 }, + { IDC_BUTTON_RESTART, 0x02000715 }, + { IDHELP, 0x02000720 }, + { IDCANCEL, 0x02000710 } +}; +#endif + +static void MyMessageBoxError(HWND hwnd, LPCWSTR message) +{ + MessageBoxW(hwnd, message, L"7-Zip", MB_ICONERROR); +} + +const LPCTSTR kProcessingString = TEXT("..."); +const LPCTSTR kMB = TEXT(" MB"); +const LPCTSTR kMIPS = TEXT(" MIPS"); +const LPCTSTR kKBs = TEXT(" KB/s"); + +static const int kMinDicLogSize = 21; +static const UInt32 kMinDicSize = (1 << kMinDicLogSize); +static const UInt32 kMaxDicSize = + #ifdef _WIN64 + (1 << 30); + #else + (1 << 27); + #endif + +bool CBenchmarkDialog::OnInit() +{ + #ifdef LANG + LangSetWindowText(HWND(*this), 0x03080000); + LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + #endif + + _syncInfo.Init(); + + m_Dictionary.Attach(GetItem(IDC_BENCHMARK_COMBO_DICTIONARY)); + int cur = 0; + // _syncInfo.DictionarySize = (1 << kNumBenchDictionaryBitsStart); + + UInt32 numCPUs = NSystem::GetNumberOfProcessors(); + if (numCPUs < 1) + numCPUs = 1; + numCPUs = MyMin(numCPUs, (UInt32)(1 << 8)); + cur = 0; + bool setDefaultThreads = (_syncInfo.NumThreads == (UInt32)(-1)); + if (setDefaultThreads) + { + _syncInfo.NumThreads = numCPUs; + if (_syncInfo.NumThreads > 1) + _syncInfo.NumThreads &= ~1; + } + + UInt64 ramSize = NSystem::GetRamSize(); + bool setDefaultDictionary = (_syncInfo.DictionarySize == (UInt32)(-1)); + if (setDefaultDictionary) + { + int dicSizeLog; + for (dicSizeLog = 25; dicSizeLog >= kBenchMinDicLogSize; dicSizeLog--) + if (GetBenchMemoryUsage(_syncInfo.NumThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize) + break; + _syncInfo.DictionarySize = (1 << dicSizeLog); + } + if (_syncInfo.DictionarySize < kMinDicSize) + _syncInfo.DictionarySize = kMinDicSize; + if (_syncInfo.DictionarySize > kMaxDicSize) + _syncInfo.DictionarySize = kMaxDicSize; + + for (int i = kMinDicLogSize; i <= 30; i++) + for (int j = 0; j < 2; j++) + { + UInt32 dictionary = (1 << i) + (j << (i - 1)); + if (dictionary > kMaxDicSize) + continue; + TCHAR s[40]; + ConvertUInt64ToString((dictionary >> 20), s); + lstrcat(s, kMB); + int index = (int)m_Dictionary.AddString(s); + m_Dictionary.SetItemData(index, dictionary); + if (dictionary <= _syncInfo.DictionarySize) + cur = index; + } + m_Dictionary.SetCurSel(cur); + + m_NumThreads.Attach(GetItem(IDC_BENCHMARK_COMBO_NUM_THREADS)); + for (UInt32 num = 1; ;) + { + if (num > numCPUs * 2) + break; + TCHAR s[40]; + ConvertUInt64ToString(num, s); + int index = (int)m_NumThreads.AddString(s); + m_NumThreads.SetItemData(index, num); + if (num <= numCPUs && setDefaultThreads) + { + _syncInfo.NumThreads = num; + cur = index; + } + if (num > 1) + num++; + num++; + } + m_NumThreads.SetCurSel(cur); + + OnChangeSettings(); + + _syncInfo._startEvent.Set(); + _timer = SetTimer(kTimerID, kTimerElapse); + return CModalDialog::OnInit(); +} + +UInt32 CBenchmarkDialog::GetNumberOfThreads() +{ + return (UInt32)m_NumThreads.GetItemData(m_NumThreads.GetCurSel()); +} + +UInt32 CBenchmarkDialog::OnChangeDictionary() +{ + UInt32 dictionary = (UInt32)m_Dictionary.GetItemData(m_Dictionary.GetCurSel()); + UInt64 memUsage = GetBenchMemoryUsage(GetNumberOfThreads(), dictionary); + memUsage = (memUsage + (1 << 20) - 1) >> 20; + TCHAR s[40]; + ConvertUInt64ToString(memUsage, s); + lstrcat(s, kMB); + SetItemText(IDC_BENCHMARK_MEMORY_VALUE, s); + return dictionary; +} + +static const UInt32 g_IDs[] = +{ + IDC_BENCHMARK_COMPRESSING_USAGE, + IDC_BENCHMARK_COMPRESSING_USAGE2, + IDC_BENCHMARK_COMPRESSING_SPEED, + IDC_BENCHMARK_COMPRESSING_SPEED2, + IDC_BENCHMARK_COMPRESSING_RATING, + IDC_BENCHMARK_COMPRESSING_RATING2, + IDC_BENCHMARK_COMPRESSING_RPU, + IDC_BENCHMARK_COMPRESSING_RPU2, + + IDC_BENCHMARK_DECOMPRESSING_SPEED, + IDC_BENCHMARK_DECOMPRESSING_SPEED2, + IDC_BENCHMARK_DECOMPRESSING_RATING, + IDC_BENCHMARK_DECOMPRESSING_RATING2, + IDC_BENCHMARK_DECOMPRESSING_USAGE, + IDC_BENCHMARK_DECOMPRESSING_USAGE2, + IDC_BENCHMARK_DECOMPRESSING_RPU, + IDC_BENCHMARK_DECOMPRESSING_RPU2, + + IDC_BENCHMARK_TOTAL_USAGE_VALUE, + IDC_BENCHMARK_TOTAL_RATING_VALUE, + IDC_BENCHMARK_TOTAL_RPU_VALUE +}; + +void CBenchmarkDialog::OnChangeSettings() +{ + EnableItem(IDC_BUTTON_STOP, true); + UInt32 dictionary = OnChangeDictionary(); + TCHAR s[40] = { TEXT('/'), TEXT(' '), 0 }; + ConvertUInt64ToString(NSystem::GetNumberOfProcessors(), s + 2); + SetItemText(IDC_BENCHMARK_HARDWARE_THREADS, s); + for (int i = 0; i < sizeof(g_IDs) / sizeof(g_IDs[0]); i++) + SetItemText(g_IDs[i], kProcessingString); + _startTime = GetTickCount(); + PrintTime(); + NWindows::NSynchronization::CCriticalSectionLock lock(_syncInfo.CS); + _syncInfo.Init(); + _syncInfo.DictionarySize = dictionary; + _syncInfo.Changed = true; + _syncInfo.NumThreads = GetNumberOfThreads(); +} + +void CBenchmarkDialog::OnRestartButton() +{ + OnChangeSettings(); +} + +void CBenchmarkDialog::OnStopButton() +{ + EnableItem(IDC_BUTTON_STOP, false); + _syncInfo.Pause(); +} + +void CBenchmarkDialog::OnHelp() +{ + ShowHelpWindow(NULL, kHelpTopic); +} + +void CBenchmarkDialog::OnCancel() +{ + _syncInfo.Stop(); + KillTimer(_timer); + CModalDialog::OnCancel(); +} + +static void GetTimeString(UInt64 timeValue, TCHAR *s) +{ + wsprintf(s, TEXT("%02d:%02d:%02d"), + UInt32(timeValue / 3600), + UInt32((timeValue / 60) % 60), + UInt32(timeValue % 60)); +} + +void CBenchmarkDialog::PrintTime() +{ + UInt32 curTime = ::GetTickCount(); + UInt32 elapsedTime = (curTime - _startTime); + UInt32 elapsedSec = elapsedTime / 1000; + if (elapsedSec != 0 && _syncInfo.WasPaused()) + return; + TCHAR s[40]; + GetTimeString(elapsedSec, s); + SetItemText(IDC_BENCHMARK_ELAPSED_VALUE, s); +} + +void CBenchmarkDialog::PrintRating(UInt64 rating, UINT controlID) +{ + TCHAR s[40]; + ConvertUInt64ToString(rating / 1000000, s); + lstrcat(s, kMIPS); + SetItemText(controlID, s); +} + +void CBenchmarkDialog::PrintUsage(UInt64 usage, UINT controlID) +{ + TCHAR s[40]; + ConvertUInt64ToString((usage + 5000) / 10000, s); + lstrcat(s, TEXT("%")); + SetItemText(controlID, s); +} + +void CBenchmarkDialog::PrintResults( + UInt32 dictionarySize, + const CBenchInfo2 &info, + UINT usageID, UINT speedID, UINT rpuID, UINT ratingID, + bool decompressMode) +{ + if (info.GlobalTime == 0) + return; + + UInt64 size = info.UnpackSize; + TCHAR s[40]; + { + UInt64 speed = size * info.GlobalFreq / info.GlobalTime; + ConvertUInt64ToString(speed / 1024, s); + lstrcat(s, kKBs); + SetItemText(speedID, s); + } + UInt64 rating; + if (decompressMode) + rating = GetDecompressRating(info.GlobalTime, info.GlobalFreq, size, info.PackSize, 1); + else + rating = GetCompressRating(dictionarySize, info.GlobalTime, info.GlobalFreq, size * info.NumIterations); + + PrintRating(rating, ratingID); + PrintRating(GetRatingPerUsage(info, rating), rpuID); + PrintUsage(GetUsage(info), usageID); +} + +bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) +{ + PrintTime(); + NWindows::NSynchronization::CCriticalSectionLock lock(_syncInfo.CS); + + TCHAR s[40]; + ConvertUInt64ToString((_syncInfo.ProcessedSize >> 20), s); + lstrcat(s, kMB); + SetItemText(IDC_BENCHMARK_SIZE_VALUE, s); + + ConvertUInt64ToString(_syncInfo.NumPasses, s); + SetItemText(IDC_BENCHMARK_PASSES_VALUE, s); + + /* + ConvertUInt64ToString(_syncInfo.NumErrors, s); + SetItemText(IDC_BENCHMARK_ERRORS_VALUE, s); + */ + + { + UInt32 dicSizeTemp = (UInt32)MyMax(_syncInfo.ProcessedSize, UInt64(1) << 20); + dicSizeTemp = MyMin(dicSizeTemp, _syncInfo.DictionarySize), + PrintResults(dicSizeTemp, + _syncInfo.CompressingInfoTemp, + IDC_BENCHMARK_COMPRESSING_USAGE, + IDC_BENCHMARK_COMPRESSING_SPEED, + IDC_BENCHMARK_COMPRESSING_RPU, + IDC_BENCHMARK_COMPRESSING_RATING); + } + + { + PrintResults( + _syncInfo.DictionarySize, + _syncInfo.CompressingInfo, + IDC_BENCHMARK_COMPRESSING_USAGE2, + IDC_BENCHMARK_COMPRESSING_SPEED2, + IDC_BENCHMARK_COMPRESSING_RPU2, + IDC_BENCHMARK_COMPRESSING_RATING2); + } + + { + PrintResults( + _syncInfo.DictionarySize, + _syncInfo.DecompressingInfoTemp, + IDC_BENCHMARK_DECOMPRESSING_USAGE, + IDC_BENCHMARK_DECOMPRESSING_SPEED, + IDC_BENCHMARK_DECOMPRESSING_RPU, + IDC_BENCHMARK_DECOMPRESSING_RATING, + true); + } + { + PrintResults( + _syncInfo.DictionarySize, + _syncInfo.DecompressingInfo, + IDC_BENCHMARK_DECOMPRESSING_USAGE2, + IDC_BENCHMARK_DECOMPRESSING_SPEED2, + IDC_BENCHMARK_DECOMPRESSING_RPU2, + IDC_BENCHMARK_DECOMPRESSING_RATING2, + true); + if (_syncInfo.DecompressingInfo.GlobalTime > 0 && + _syncInfo.CompressingInfo.GlobalTime > 0) + { + UInt64 comprRating = GetCompressRating(_syncInfo.DictionarySize, + _syncInfo.CompressingInfo.GlobalTime, _syncInfo.CompressingInfo.GlobalFreq, _syncInfo.CompressingInfo.UnpackSize); + UInt64 decomprRating = GetDecompressRating(_syncInfo.DecompressingInfo.GlobalTime, + _syncInfo.DecompressingInfo.GlobalFreq, _syncInfo.DecompressingInfo.UnpackSize, + _syncInfo.DecompressingInfo.PackSize, 1); + PrintRating((comprRating + decomprRating) / 2, IDC_BENCHMARK_TOTAL_RATING_VALUE); + PrintRating(( + GetRatingPerUsage(_syncInfo.CompressingInfo, comprRating) + + GetRatingPerUsage(_syncInfo.DecompressingInfo, decomprRating)) / 2, IDC_BENCHMARK_TOTAL_RPU_VALUE); + PrintUsage((GetUsage(_syncInfo.CompressingInfo) + GetUsage(_syncInfo.DecompressingInfo)) / 2, IDC_BENCHMARK_TOTAL_USAGE_VALUE); + } + } + return true; +} + +bool CBenchmarkDialog::OnCommand(int code, int itemID, LPARAM lParam) +{ + if (code == CBN_SELCHANGE && + (itemID == IDC_BENCHMARK_COMBO_DICTIONARY || + itemID == IDC_BENCHMARK_COMBO_NUM_THREADS)) + { + OnChangeSettings(); + return true; + } + return CModalDialog::OnCommand(code, itemID, lParam); +} + +bool CBenchmarkDialog::OnButtonClicked(int buttonID, HWND buttonHWND) +{ + switch(buttonID) + { + case IDC_BUTTON_RESTART: + OnRestartButton(); + return true; + case IDC_BUTTON_STOP: + OnStopButton(); + return true; + } + return CModalDialog::OnButtonClicked(buttonID, buttonHWND); +} + +struct CThreadBenchmark +{ + CProgressSyncInfo *SyncInfo; + UInt64 _startTime; + #ifdef EXTERNAL_LZMA + CCodecs *codecs; + #endif + // UInt32 dictionarySize; + // UInt32 numThreads; + + HRESULT Process(); + HRESULT Result; + static THREAD_FUNC_DECL MyThreadFunction(void *param) + { + ((CThreadBenchmark *)param)->Result = ((CThreadBenchmark *)param)->Process(); + return 0; + } +}; + +struct CBenchCallback: public IBenchCallback +{ + UInt32 dictionarySize; + CProgressSyncInfo *SyncInfo; + HRESULT SetEncodeResult(const CBenchInfo &info, bool final); + HRESULT SetDecodeResult(const CBenchInfo &info, bool final); +}; + +HRESULT CBenchCallback::SetEncodeResult(const CBenchInfo &info, bool final) +{ + NSynchronization::CCriticalSectionLock lock(SyncInfo->CS); + if (SyncInfo->Changed || SyncInfo->Paused || SyncInfo->Stopped) + return E_ABORT; + SyncInfo->ProcessedSize = info.UnpackSize; + if (final && SyncInfo->CompressingInfo.GlobalTime == 0) + { + (CBenchInfo&)SyncInfo->CompressingInfo = info; + if (SyncInfo->CompressingInfo.GlobalTime == 0) + SyncInfo->CompressingInfo.GlobalTime = 1; + } + else + (CBenchInfo&)SyncInfo->CompressingInfoTemp = info; + + return S_OK; +} + +HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final) +{ + NSynchronization::CCriticalSectionLock lock(SyncInfo->CS); + if (SyncInfo->Changed || SyncInfo->Paused || SyncInfo->Stopped) + return E_ABORT; + CBenchInfo info2 = info; + if (info2.NumIterations == 0) + info2.NumIterations = 1; + + info2.UnpackSize *= info2.NumIterations; + info2.PackSize *= info2.NumIterations; + info2.NumIterations = 1; + + if (final && SyncInfo->DecompressingInfo.GlobalTime == 0) + { + (CBenchInfo&)SyncInfo->DecompressingInfo = info2; + if (SyncInfo->DecompressingInfo.GlobalTime == 0) + SyncInfo->DecompressingInfo.GlobalTime = 1; + } + else + (CBenchInfo&)SyncInfo->DecompressingInfoTemp = info2; + return S_OK; +} + +HRESULT CThreadBenchmark::Process() +{ + try + { + SyncInfo->WaitCreating(); + for (;;) + { + if (SyncInfo->WasStopped()) + return 0; + if (SyncInfo->WasPaused()) + { + Sleep(200); + continue; + } + UInt32 dictionarySize; + UInt32 numThreads; + { + NSynchronization::CCriticalSectionLock lock(SyncInfo->CS); + if (SyncInfo->Stopped || SyncInfo->Paused) + continue; + if (SyncInfo->Changed) + SyncInfo->Init(); + dictionarySize = SyncInfo->DictionarySize; + numThreads = SyncInfo->NumThreads; + } + + CBenchCallback callback; + callback.dictionarySize = dictionarySize; + callback.SyncInfo = SyncInfo; + HRESULT result; + try + { + result = LzmaBench( + #ifdef EXTERNAL_LZMA + codecs, + #endif + numThreads, dictionarySize, &callback); + } + catch(...) + { + result = E_FAIL; + } + + if (result != S_OK) + { + if (result != E_ABORT) + { + // SyncInfo->NumErrors++; + { + NSynchronization::CCriticalSectionLock lock(SyncInfo->CS); + SyncInfo->Pause(); + } + CSysString message; + if (result == S_FALSE) + message = TEXT("Decoding error"); + else + message = NError::MyFormatMessage(result); + MessageBox(0, message, TEXT("7-Zip"), MB_ICONERROR); + } + } + else + { + NSynchronization::CCriticalSectionLock lock(SyncInfo->CS); + SyncInfo->NumPasses++; + } + } + // return S_OK; + } + catch(CSystemException &e) + { + MessageBox(0, NError::MyFormatMessage(e.ErrorCode), TEXT("7-Zip"), MB_ICONERROR); + return E_FAIL; + } + catch(...) + { + MyMessageBoxError(0, L"Some error"); + return E_FAIL; + } +} + +HRESULT Benchmark( + #ifdef EXTERNAL_LZMA + CCodecs *codecs, + #endif + UInt32 numThreads, UInt32 dictionarySize) +{ + CThreadBenchmark benchmarker; + #ifdef EXTERNAL_LZMA + benchmarker.codecs = codecs; + #endif + + CBenchmarkDialog benchmarkDialog; + benchmarkDialog._syncInfo.DictionarySize = dictionarySize; + benchmarkDialog._syncInfo.NumThreads = numThreads; + + benchmarker.SyncInfo = &benchmarkDialog._syncInfo; + NWindows::CThread thread; + RINOK(thread.Create(CThreadBenchmark::MyThreadFunction, &benchmarker)); + benchmarkDialog.Create(0); + return thread.Wait(); +} diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog.h new file mode 100644 index 000000000..a57cdb399 --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog.h @@ -0,0 +1,131 @@ +// BenchmarkDialog.h + +#ifndef __BENCHMARKDIALOG_H +#define __BENCHMARKDIALOG_H + +#include "BenchmarkDialogRes.h" + +#include "Windows/Control/Dialog.h" +#include "Windows/Control/ComboBox.h" +#include "Windows/Synchronization.h" +#include "../../Compress/LZMA_Alone/LzmaBench.h" + +#ifdef EXTERNAL_LZMA +#include "../Common/LoadCodecs.h" +#endif + +struct CBenchInfo2 : public CBenchInfo +{ + void Init() { GlobalTime = UserTime = 0; } +}; + +class CProgressSyncInfo +{ +public: + bool Stopped; + bool Paused; + bool Changed; + UInt32 DictionarySize; + UInt32 NumThreads; + UInt64 NumPasses; + // UInt64 NumErrors; + NWindows::NSynchronization::CManualResetEvent _startEvent; + NWindows::NSynchronization::CCriticalSection CS; + + CBenchInfo2 CompressingInfoTemp; + CBenchInfo2 CompressingInfo; + UInt64 ProcessedSize; + + CBenchInfo2 DecompressingInfoTemp; + CBenchInfo2 DecompressingInfo; + + CProgressSyncInfo() + { + if (_startEvent.Create() != S_OK) + throw 3986437; + } + void Init() + { + Changed = false; + Stopped = false; + Paused = false; + CompressingInfoTemp.Init(); + CompressingInfo.Init(); + ProcessedSize = 0; + + DecompressingInfoTemp.Init(); + DecompressingInfo.Init(); + + NumPasses = 0; + // NumErrors = 0; + } + void Stop() + { + NWindows::NSynchronization::CCriticalSectionLock lock(CS); + Stopped = true; + } + bool WasStopped() + { + NWindows::NSynchronization::CCriticalSectionLock lock(CS); + return Stopped; + } + void Pause() + { + NWindows::NSynchronization::CCriticalSectionLock lock(CS); + Paused = true; + } + void Start() + { + NWindows::NSynchronization::CCriticalSectionLock lock(CS); + Paused = false; + } + bool WasPaused() + { + NWindows::NSynchronization::CCriticalSectionLock lock(CS); + return Paused; + } + void WaitCreating() { _startEvent.Lock(); } +}; + +class CBenchmarkDialog: + public NWindows::NControl::CModalDialog +{ + NWindows::NControl::CComboBox m_Dictionary; + NWindows::NControl::CComboBox m_NumThreads; + UINT_PTR _timer; + UINT32 _startTime; + + bool OnTimer(WPARAM timerID, LPARAM callback); + virtual bool OnInit(); + void OnRestartButton(); + void OnStopButton(); + void OnHelp(); + virtual void OnCancel(); + bool OnButtonClicked(int buttonID, HWND buttonHWND); + bool OnCommand(int code, int itemID, LPARAM lParam); + + void PrintTime(); + void PrintRating(UInt64 rating, UINT controlID); + void PrintUsage(UInt64 usage, UINT controlID); + void PrintResults( + UINT32 dictionarySize, + const CBenchInfo2 &info, UINT usageID, UINT speedID, UINT rpuID, UINT ratingID, + bool decompressMode = false); + + UInt32 GetNumberOfThreads(); + UInt32 OnChangeDictionary(); + void OnChangeSettings(); +public: + CProgressSyncInfo _syncInfo; + + CBenchmarkDialog(): _timer(0) {} + INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_BENCHMARK, wndParent); } +}; + +HRESULT Benchmark( + #ifdef EXTERNAL_LZMA + CCodecs *codecs, + #endif + UInt32 dictionarySize, UInt32 numThreads); + +#endif diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialogRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialogRes.h new file mode 100644 index 000000000..6ef521881 --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialogRes.h @@ -0,0 +1,54 @@ +#define IDD_DIALOG_BENCHMARK 800 +#define IDC_BUTTON_STOP 1001 +#define IDC_BUTTON_RESTART 1002 +#define IDC_BENCHMARK_DICTIONARY 1010 +#define IDC_BENCHMARK_COMBO_DICTIONARY 1011 +#define IDC_BENCHMARK_MEMORY 1012 +#define IDC_BENCHMARK_MEMORY_VALUE 1013 +#define IDC_BENCHMARK_NUM_THREADS 1014 +#define IDC_BENCHMARK_COMBO_NUM_THREADS 1015 +#define IDC_BENCHMARK_HARDWARE_THREADS 1016 + +#define IDC_BENCHMARK_SPEED_LABEL 1020 +#define IDC_BENCHMARK_RATING_LABEL 1021 +#define IDC_BENCHMARK_COMPRESSING 1022 +#define IDC_BENCHMARK_DECOMPRESSING 1023 +#define IDC_BENCHMARK_CURRENT 1024 +#define IDC_BENCHMARK_RESULTING 1025 +#define IDC_BENCHMARK_CURRENT2 1026 +#define IDC_BENCHMARK_RESULTING2 1027 +#define IDC_BENCHMARK_USAGE_LABEL 1028 +#define IDC_BENCHMARK_RPU_LABEL 1029 + +#define IDC_BENCHMARK_COMPRESSING_SPEED 1030 +#define IDC_BENCHMARK_COMPRESSING_SPEED2 1031 +#define IDC_BENCHMARK_COMPRESSING_RATING 1032 +#define IDC_BENCHMARK_COMPRESSING_RATING2 1033 +#define IDC_BENCHMARK_COMPRESSING_USAGE 1034 +#define IDC_BENCHMARK_COMPRESSING_USAGE2 1035 +#define IDC_BENCHMARK_COMPRESSING_RPU 1036 +#define IDC_BENCHMARK_COMPRESSING_RPU2 1037 + + +#define IDC_BENCHMARK_DECOMPRESSING_SPEED 1040 +#define IDC_BENCHMARK_DECOMPRESSING_SPEED2 1041 +#define IDC_BENCHMARK_DECOMPRESSING_RATING 1042 +#define IDC_BENCHMARK_DECOMPRESSING_RATING2 1043 +#define IDC_BENCHMARK_DECOMPRESSING_USAGE 1044 +#define IDC_BENCHMARK_DECOMPRESSING_USAGE2 1045 +#define IDC_BENCHMARK_DECOMPRESSING_RPU 1046 +#define IDC_BENCHMARK_DECOMPRESSING_RPU2 1047 + + +#define IDC_BENCHMARK_TOTAL_RATING 1050 + +#define IDC_BENCHMARK_TOTAL_RATING_VALUE 1051 +#define IDC_BENCHMARK_TOTAL_RPU_VALUE 1052 +#define IDC_BENCHMARK_TOTAL_USAGE_VALUE 1053 + +#define IDC_BENCHMARK_ELAPSED 1060 +#define IDC_BENCHMARK_ELAPSED_VALUE 1061 +#define IDC_BENCHMARK_SIZE 1062 +#define IDC_BENCHMARK_SIZE_VALUE 1063 +#define IDC_BENCHMARK_PASSES 1066 +#define IDC_BENCHMARK_PASSES_VALUE 1067 diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog_rc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog_rc.cpp new file mode 100644 index 000000000..ae6b26f2c --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/BenchmarkDialog_rc.cpp @@ -0,0 +1,245 @@ +// BenchmarkDialog.cpp + +#include "StdAfx.h" + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWidgets headers) +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include "Windows/Control/DialogImpl.h" +#include "BenchmarkDialogRes.h" + +#if 0 + + +IDD_DIALOG_BENCHMARK DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX +CAPTION "Benchmark" +MY_FONT +BEGIN +OK PUSHBUTTON "&Restart", IDC_BUTTON_RESTART, bXPos1, marg, bXSize, bYSize +OK PUSHBUTTON "&Stop", IDC_BUTTON_STOP, bXPos1, 27, bXSize, bYSize + + PUSHBUTTON "&Help", IDHELP, bXPos2, bYPos, bXSize,bYSize + PUSHBUTTON "Cancel", IDCANCEL, bXPos1, bYPos, bXSize, bYSize + +OK LTEXT "&Dictionary size:", IDC_BENCHMARK_DICTIONARY, marg, marg + 1, g0XSize, 8 +OK COMBOBOX IDC_BENCHMARK_COMBO_DICTIONARY, g1XPos, marg, g1XSize, 140, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + + LTEXT "&Number of CPU threads:", IDC_BENCHMARK_NUM_THREADS, marg, 24, g0XSize, 8 + COMBOBOX IDC_BENCHMARK_COMBO_NUM_THREADS, g1XPos, 23, g1XSize, 140, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + + LTEXT "Memory usage:", IDC_BENCHMARK_MEMORY, gc2XPos, marg + 1, gc2XSize, 8 + LTEXT "0 MB", IDC_BENCHMARK_MEMORY_VALUE, gc2XPos + gc2XSize, marg + 1, 40, 8 + LTEXT "1", IDC_BENCHMARK_HARDWARE_THREADS, gc2XPos, 24, 40, 8 + + RTEXT "CPU Usage", IDC_BENCHMARK_USAGE_LABEL, gUsagePos, 53, gUsageSize, 8 + RTEXT "Speed", IDC_BENCHMARK_SPEED_LABEL, gSpeedPos, 53, gSpeedSize, 8 + RTEXT "Rating / Usage", IDC_BENCHMARK_RPU_LABEL, gRpuPos, 53, gRpuSize, 8 + RTEXT "Rating", IDC_BENCHMARK_RATING_LABEL, gRatingPos, 53, gRatingSize, 8 + + GROUPBOX "Compressing", IDC_BENCHMARK_COMPRESSING, marg, 64, xSize2, 40 + + LTEXT "Current", IDC_BENCHMARK_CURRENT, g10XPos, 76, gLabelSize, 8 + RTEXT "100%", IDC_BENCHMARK_COMPRESSING_USAGE, gUsagePos, 76, gUsageSize, 8 + RTEXT "100 KB/s", IDC_BENCHMARK_COMPRESSING_SPEED, gSpeedPos, 76, gSpeedSize, 8 + RTEXT "0", IDC_BENCHMARK_COMPRESSING_RPU, gRpuPos, 76, gRpuSize, 8 + RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING, gRatingPos, 76, gRatingSize, 8 + + LTEXT "Resulting", IDC_BENCHMARK_RESULTING, g10XPos, 89, gLabelSize, 8 + RTEXT "100%", IDC_BENCHMARK_COMPRESSING_USAGE2, gUsagePos, 89, gUsageSize, 8 + RTEXT "100 KB/s", IDC_BENCHMARK_COMPRESSING_SPEED2, gSpeedPos, 89, gSpeedSize, 8 + RTEXT "0", IDC_BENCHMARK_COMPRESSING_RPU2, gRpuPos, 89, gRpuSize, 8 + RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING2, gRatingPos, 89, gRatingSize, 8 + + GROUPBOX "Decompressing", IDC_BENCHMARK_DECOMPRESSING, marg, 111, xSize2, 40 + + LTEXT "Current", IDC_BENCHMARK_CURRENT2, g10XPos, 123, gLabelSize, 8 + RTEXT "100%", IDC_BENCHMARK_DECOMPRESSING_USAGE, gUsagePos, 123, gUsageSize, 8 + RTEXT "100 KB/s", IDC_BENCHMARK_DECOMPRESSING_SPEED, gSpeedPos, 123, gSpeedSize, 8 + RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RPU, gRpuPos, 123, gRpuSize, 8 + RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING, gRatingPos, 123, gRatingSize, 8 + + LTEXT "Resulting", IDC_BENCHMARK_RESULTING2, g10XPos, 136, gLabelSize, 8 + RTEXT "100%", IDC_BENCHMARK_DECOMPRESSING_USAGE2, gUsagePos, 136, gUsageSize, 8 + RTEXT "100 KB/s", IDC_BENCHMARK_DECOMPRESSING_SPEED2, gSpeedPos, 136, gSpeedSize, 8 + RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RPU2, gRpuPos, 136, gRpuSize, 8 + RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING2, gRatingPos, 136, gRatingSize, 8 + + GROUPBOX "Total Rating", IDC_BENCHMARK_TOTAL_RATING, gTotalRatingPos, 163, gTotalRatingSize, 38 + RTEXT "0", IDC_BENCHMARK_TOTAL_USAGE_VALUE, gUsagePos, 181, gUsageSize, 8 + RTEXT "0", IDC_BENCHMARK_TOTAL_RPU_VALUE, gRpuPos, 181, gRpuSize, 8 + RTEXT "0", IDC_BENCHMARK_TOTAL_RATING_VALUE, gRatingPos, 181, gRatingSize, 8 + + LTEXT "Elapsed time:", IDC_BENCHMARK_ELAPSED, marg, 163, g2XSize, 8 + LTEXT "Size:", IDC_BENCHMARK_SIZE, marg, 176, g2XSize, 8 + LTEXT "Passes:", IDC_BENCHMARK_PASSES, marg, 189, g2XSize, 8 + RTEXT "00:00:00", IDC_BENCHMARK_ELAPSED_VALUE, g3XPos, 163, g3XSize, 8 + RTEXT "0", IDC_BENCHMARK_SIZE_VALUE, g3XPos, 176, g3XSize, 8 + RTEXT "0", IDC_BENCHMARK_PASSES_VALUE, g3XPos, 189, g3XSize, 8 +END +#endif // #if 0 + +class CBenchmarkDialogImpl : public NWindows::NControl::CModalDialogImpl +{ + public: + CBenchmarkDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent , int id) : CModalDialogImpl(dialog,parent, id, wxT("Benchmark")) + { + + wxSizer *topsizer = new wxBoxSizer(wxVERTICAL); + + wxSizer *sizerLine1 = new wxBoxSizer(wxHORIZONTAL); + + wxSizer *sizeLine1Btn = new wxBoxSizer(wxVERTICAL); + sizeLine1Btn->Add(new wxButton(this, IDC_BUTTON_RESTART, _T("&Restart")) , 0, wxALL|wxEXPAND, 5 ); + sizeLine1Btn->Add(new wxButton(this, IDC_BUTTON_STOP, _T("&Stop")) , 0, wxALL|wxEXPAND, 5 ); + + wxSizer *sizeLine1Combo = new wxBoxSizer(wxVERTICAL); + + wxComboBox * chcDicoSize = new wxComboBox(this, IDC_BENCHMARK_COMBO_DICTIONARY, + wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY); + + wxComboBox * chcThread = new wxComboBox(this, IDC_BENCHMARK_COMBO_NUM_THREADS, + wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY); + + sizeLine1Combo->Add(chcDicoSize , 0, wxALL, 5 ); + sizeLine1Combo->Add(chcThread , 0, wxALL, 5 ); + + wxSizer *sizeLine1ComboLabel = new wxBoxSizer(wxVERTICAL); + sizeLine1ComboLabel->Add(new wxStaticText(this, IDC_BENCHMARK_DICTIONARY, _T("&Dictionary size:")) , 1, wxALL|wxEXPAND, 5 ); + sizeLine1ComboLabel->Add(new wxStaticText(this, IDC_BENCHMARK_NUM_THREADS, _T("&Number of CPU threads:")) , 1, wxALL|wxEXPAND, 5 ); + + wxSizer *sizeLine1Col3 = new wxBoxSizer(wxVERTICAL); + sizeLine1Col3->Add(new wxStaticText(this, IDC_BENCHMARK_MEMORY, _T("Memory usage:")) , 1, wxALL|wxEXPAND, 5 ); + sizeLine1Col3->Add(new wxStaticText(this, IDC_BENCHMARK_HARDWARE_THREADS, _T("1")) , 1, wxALL|wxEXPAND, 5 ); + + wxSizer *sizeLine1Col4 = new wxBoxSizer(wxVERTICAL); + sizeLine1Col4->Add(new wxStaticText(this, IDC_BENCHMARK_MEMORY_VALUE, _T("0 MB")) , 0, wxALL|wxEXPAND, 5 ); + + sizerLine1->Add(sizeLine1ComboLabel,0, wxALL|wxEXPAND, 5); + sizerLine1->Add(sizeLine1Combo,0, wxALL|wxEXPAND, 5); + sizerLine1->Add(sizeLine1Col3,0, wxALL|wxEXPAND, 5); + sizerLine1->Add(sizeLine1Col4,0, wxALL|wxEXPAND, 5); + sizerLine1->Add(sizeLine1Btn,0, wxALL|wxEXPAND, 5); + + // LABEL (copy the structure of the compressing or decompressing group + + wxStaticBoxSizer * sizerLine2 = new wxStaticBoxSizer(new wxStaticBox(this,wxID_ANY,_T("")),wxVERTICAL); + wxSizer *sizerLabel = new wxBoxSizer(wxHORIZONTAL); + sizerLabel->Add(new wxStaticText(this, wxID_ANY, _T(" ")) , 1, wxALL|wxEXPAND, 5 ); + sizerLabel->Add(new wxStaticText(this, IDC_BENCHMARK_SPEED_LABEL, _T("Speed")) , 1, wxALL|wxEXPAND, 5 ); + sizerLabel->Add(new wxStaticText(this, IDC_BENCHMARK_USAGE_LABEL, _T("CPU Usage")) , 1, wxALL|wxEXPAND, 5 ); + sizerLabel->Add(new wxStaticText(this, IDC_BENCHMARK_RPU_LABEL, _T("Rating / Usage")), 1, wxALL|wxEXPAND, 5 ); + sizerLabel->Add(new wxStaticText(this, IDC_BENCHMARK_RATING_LABEL, _T("Rating")) , 1, wxALL|wxEXPAND, 5 ); + + sizerLine2->Add(sizerLabel, 0, wxALL|wxEXPAND, 5); + + // GROUP COMPRESSING + + wxStaticBoxSizer * grpCompress = new wxStaticBoxSizer(new wxStaticBox(this,IDC_BENCHMARK_COMPRESSING,_T("Compressing")),wxVERTICAL); + wxSizer *grpCompress1 = new wxBoxSizer(wxHORIZONTAL); + grpCompress1->Add(new wxStaticText(this, IDC_BENCHMARK_CURRENT, _T("Current")) , 1, wxALL|wxEXPAND, 5 ); + grpCompress1->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_SPEED, _T("100 KB/s")) , 1, wxALL|wxEXPAND, 5 ); + grpCompress1->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_USAGE, _T("100%")) , 1, wxALL|wxEXPAND, 5 ); + grpCompress1->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_RPU, _T("0")), 1, wxALL|wxEXPAND, 5 ); + grpCompress1->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_RATING, _T("0")) , 1, wxALL|wxEXPAND, 5 ); + + wxSizer *grpCompress2 = new wxBoxSizer(wxHORIZONTAL); + grpCompress2->Add(new wxStaticText(this, IDC_BENCHMARK_RESULTING, _T("Resulting")) , 1, wxALL|wxEXPAND, 5 ); + grpCompress2->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_SPEED2, _T("100 KB/s")) , 1, wxALL|wxEXPAND, 5 ); + grpCompress2->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_USAGE2, _T("100%")) , 1, wxALL|wxEXPAND, 5 ); + grpCompress2->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_RPU2, _T("0")) , 1, wxALL|wxEXPAND, 5); + grpCompress2->Add(new wxStaticText(this, IDC_BENCHMARK_COMPRESSING_RATING2, _T("0")) , 1, wxALL|wxEXPAND, 5 ); + + grpCompress->Add(grpCompress1, 0, wxALL|wxEXPAND, 5); + grpCompress->Add(grpCompress2, 0, wxALL|wxEXPAND, 5); + + // GROUP DECOMPRESSING + + wxStaticBoxSizer * grpDecompress = new wxStaticBoxSizer(new wxStaticBox(this,IDC_BENCHMARK_DECOMPRESSING,_T("Decompressing")),wxVERTICAL); + wxSizer *grpDecompress1 = new wxBoxSizer(wxHORIZONTAL); + grpDecompress1->Add(new wxStaticText(this, IDC_BENCHMARK_CURRENT2, _T("Current")) , 1, wxALL|wxEXPAND, 5 ); + grpDecompress1->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_SPEED, _T("100 KB/s")) , 1, wxALL|wxEXPAND, 5 ); + grpDecompress1->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_USAGE, _T("100%")) , 1, wxALL|wxEXPAND, 5 ); + grpDecompress1->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_RPU, _T("0")), 1, wxALL|wxEXPAND, 5 ); + grpDecompress1->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_RATING, _T("0")) , 1, wxALL|wxEXPAND, 5 ); + + wxSizer *grpDecompress2 = new wxBoxSizer(wxHORIZONTAL); + grpDecompress2->Add(new wxStaticText(this, IDC_BENCHMARK_RESULTING2, _T("Resulting")) , 1, wxALL|wxEXPAND, 5 ); + grpDecompress2->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_SPEED2, _T("100 KB/s")) , 1, wxALL|wxEXPAND, 5 ); + grpDecompress2->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_USAGE2, _T("100%")) , 1, wxALL|wxEXPAND, 5 ); + grpDecompress2->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_RPU2, _T("0")) , 1, wxALL|wxEXPAND, 5); + grpDecompress2->Add(new wxStaticText(this, IDC_BENCHMARK_DECOMPRESSING_RATING2, _T("0")) , 1, wxALL|wxEXPAND, 5 ); + + grpDecompress->Add(grpDecompress1, 0, wxALL|wxEXPAND, 5); + grpDecompress->Add(grpDecompress2, 0, wxALL|wxEXPAND, 5); + + // GROUPE TOTAL RATING + wxStaticBoxSizer * grpTotalRating = new wxStaticBoxSizer(new wxStaticBox(this,IDC_BENCHMARK_TOTAL_RATING,_T("Total Rating")),wxHORIZONTAL); + grpTotalRating->Add(new wxStaticText(this, wxID_ANY, _T("")) , 1, wxALL|wxEXPAND, 5 ); + grpTotalRating->Add(new wxStaticText(this, IDC_BENCHMARK_TOTAL_USAGE_VALUE, _T("0")) , 1, wxALL|wxEXPAND, 5 ); + grpTotalRating->Add(new wxStaticText(this, IDC_BENCHMARK_TOTAL_RPU_VALUE, _T("0")) , 1, wxALL|wxEXPAND, 5 ); + grpTotalRating->Add(new wxStaticText(this, IDC_BENCHMARK_TOTAL_RATING_VALUE, _T("0")) , 1, wxALL|wxEXPAND, 5 ); + + // GROUPE ELAPSED TIME + wxSizer * grpElapsedTime = new wxBoxSizer(wxHORIZONTAL); + + wxSizer * grpElapsedTime1 = new wxBoxSizer(wxVERTICAL); + grpElapsedTime1->Add(new wxStaticText(this, IDC_BENCHMARK_ELAPSED, _T("Elapsed time:")) , 0, wxALL|wxEXPAND, 5 ); + grpElapsedTime1->Add(new wxStaticText(this, IDC_BENCHMARK_SIZE, _T("Size:")) , 0, wxALL|wxEXPAND, 5 ); + grpElapsedTime1->Add(new wxStaticText(this, IDC_BENCHMARK_PASSES, _T("Passes:")) , 0, wxALL|wxEXPAND, 5 ); + + wxSizer * grpElapsedTime2 = new wxBoxSizer(wxVERTICAL); + grpElapsedTime2->Add(new wxStaticText(this, IDC_BENCHMARK_ELAPSED_VALUE, _T("00:00:00")) , 0, wxALL|wxEXPAND, 5 ); + grpElapsedTime2->Add(new wxStaticText(this, IDC_BENCHMARK_SIZE_VALUE, _T("0")) , 0, wxALL|wxEXPAND, 5 ); + grpElapsedTime2->Add(new wxStaticText(this, IDC_BENCHMARK_PASSES_VALUE, _T("0")) , 0, wxALL|wxEXPAND, 5 ); + + grpElapsedTime->Add(grpElapsedTime1,0, wxALL|wxEXPAND, 5); + grpElapsedTime->Add(grpElapsedTime2,0, wxALL|wxEXPAND, 5); + + wxSizer * grp_ElapsedTime_TotalRating = new wxBoxSizer(wxHORIZONTAL); + grp_ElapsedTime_TotalRating->Add(grpElapsedTime, 0, wxALL|wxEXPAND, 5); + grp_ElapsedTime_TotalRating->Add(grpTotalRating, 1, wxALL|wxEXPAND, 5); + + // TOP + topsizer->Add(sizerLine1,0, wxALL|wxEXPAND, 5); + topsizer->Add(sizerLine2,0, wxALL|wxEXPAND, 5); + topsizer->Add(grpCompress, 0, wxALL|wxEXPAND, 5); + topsizer->Add(grpDecompress, 0, wxALL|wxEXPAND, 5); + topsizer->Add(grp_ElapsedTime_TotalRating, 0, wxALL|wxEXPAND, 5); + + topsizer->Add(CreateButtonSizer(wxHELP|wxCANCEL), 0, wxALL|wxEXPAND, 5); + + this->OnInit(); + + SetSizer(topsizer); // use the sizer for layout + topsizer->SetSizeHints(this); // set size hints to honour minimum size + } +private: + // Any class wishing to process wxWindows events must use this macro + DECLARE_EVENT_TABLE() +}; + +REGISTER_DIALOG(IDD_DIALOG_BENCHMARK,CBenchmarkDialog,0) + +// ---------------------------------------------------------------------------- +// event tables and other macros for wxWidgets +// ---------------------------------------------------------------------------- + +// the event tables connect the wxWidgets events with the functions (event +// handlers) which process them. It can be also done at run-time, but for the +// simple menu events like this the static method is much simpler. +BEGIN_EVENT_TABLE(CBenchmarkDialogImpl, wxDialog) + EVT_TIMER(wxID_ANY, CModalDialogImpl::OnAnyTimer) + EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton) + EVT_COMBOBOX(wxID_ANY, CModalDialogImpl::OnAnyChoice) +END_EVENT_TABLE() + diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog.cpp new file mode 100644 index 000000000..04a40a437 --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog.cpp @@ -0,0 +1,1455 @@ +// CompressDialog.cpp + +#include "StdAfx.h" + +#include "Common/Defs.h" +#include "Common/IntToString.h" +#include "Common/StringConvert.h" + +#include "Windows/CommonDialog.h" +#include "Windows/FileDir.h" +#include "Windows/FileName.h" +#include "Windows/ResourceString.h" +#include "Windows/System.h" + +#include "../FileManager/FormatUtils.h" +#include "../FileManager/HelpUtils.h" +#include "../FileManager/SplitUtils.h" + +#include "../Explorer/MyMessages.h" + +#include "../Common/ZipRegistry.h" + +#include "CompressDialog.h" + +#include "resource.h" + +#ifndef _UNICODE +extern bool g_IsNT; +#endif + +#ifdef LANG +#include "../FileManager/LangUtils.h" +#endif + +#include "CompressDialogRes.h" + +#define MY_SIZE_OF_ARRAY(x) (sizeof(x) / sizeof(x[0])) + +#ifdef LANG +static CIDLangPair kIDLangPairs[] = +{ + { IDC_STATIC_COMPRESS_ARCHIVE, 0x02000D01 }, + { IDC_STATIC_COMPRESS_FORMAT, 0x02000D03 }, + { IDC_STATIC_COMPRESS_LEVEL, 0x02000D0B }, + { IDC_STATIC_COMPRESS_METHOD, 0x02000D04 }, + { IDC_STATIC_COMPRESS_DICTIONARY, 0x02000D0C }, + { IDC_STATIC_COMPRESS_ORDER, 0x02000D0D }, + { IDC_STATIC_COMPRESS_MEMORY, 0x02000D0E }, + { IDC_STATIC_COMPRESS_MEMORY_DE, 0x02000D0F }, + { IDC_STATIC_COMPRESS_THREADS, 0x02000D12 }, + { IDC_STATIC_COMPRESS_SOLID, 0x02000D13 }, + { IDC_STATIC_COMPRESS_VOLUME, 0x02000D40 }, + { IDC_STATIC_COMPRESS_PARAMETERS, 0x02000D06 }, + + { IDC_STATIC_COMPRESS_UPDATE_MODE, 0x02000D02 }, + { IDC_STATIC_COMPRESS_OPTIONS, 0x02000D07 }, + { IDC_COMPRESS_SFX, 0x02000D08 }, + { IDC_COMPRESS_SHARED, 0x02000D16 }, + + { IDC_COMPRESS_ENCRYPTION, 0x02000D10 }, + { IDC_STATIC_COMPRESS_PASSWORD1, 0x02000B01 }, + { IDC_STATIC_COMPRESS_PASSWORD2, 0x02000B03 }, + { IDC_COMPRESS_CHECK_SHOW_PASSWORD, 0x02000B02 }, + { IDC_STATIC_COMPRESS_ENCRYPTION_METHOD, 0x02000D11 }, + { IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, 0x02000D0A }, + + { IDOK, 0x02000702 }, + { IDCANCEL, 0x02000710 }, + { IDHELP, 0x02000720 } +}; +#endif + +using namespace NWindows; +using namespace NFile; +using namespace NName; +using namespace NDirectory; + +static const int kHistorySize = 20; + +static LPCWSTR kExeExt = L".exe"; +static LPCWSTR k7zFormat = L"7z"; + +struct CLevelInfo +{ + UInt32 ResourceID; + UInt32 LangID; +}; + +enum ELevel +{ + kStore = 0, + kFastest = 1, + kFast = 3, + kNormal = 5, + kMaximum = 7, + kUltra = 9 +}; + +static const CLevelInfo g_Levels[] = +{ + { IDS_METHOD_STORE, 0x02000D81 }, + { IDS_METHOD_FASTEST, 0x02000D85 }, + { 0, 0 }, + { IDS_METHOD_FAST, 0x02000D84 }, + { 0, 0 }, + { IDS_METHOD_NORMAL, 0x02000D82 }, + { 0, 0 }, + { IDS_METHOD_MAXIMUM, 0x02000D83 }, + { 0, 0 }, + { IDS_METHOD_ULTRA, 0x02000D86 } +}; + +enum EMethodID +{ + kCopy, + kLZMA, + kLZMA2, + kPPMd, + kBZip2, + kDeflate, + kDeflate64 +}; + +static const LPCWSTR kMethodsNames[] = +{ + L"Copy", + L"LZMA", + L"LZMA2", + L"PPMd", + L"BZip2", + L"Deflate", + L"Deflate64" +}; + +static const EMethodID g_7zMethods[] = +{ + kLZMA, + kLZMA2, + kPPMd, + kBZip2 +}; + +static const EMethodID g_7zSfxMethods[] = +{ + kCopy, + kLZMA, + kLZMA2, + kPPMd +}; + +static EMethodID g_ZipMethods[] = +{ + kDeflate, + kDeflate64, + kBZip2, + kLZMA +}; + +static EMethodID g_GZipMethods[] = +{ + kDeflate +}; + +static EMethodID g_BZip2Methods[] = +{ + kBZip2 +}; + +static EMethodID g_XzMethods[] = +{ + kLZMA2 +}; + +struct CFormatInfo +{ + LPCWSTR Name; + UInt32 LevelsMask; + const EMethodID *MathodIDs; + int NumMethods; + bool Filter; + bool Solid; + bool MultiThread; + bool SFX; + bool Encrypt; + bool EncryptFileNames; +}; + +#define METHODS_PAIR(x) x, MY_SIZE_OF_ARRAY(x) + +static const CFormatInfo g_Formats[] = +{ + { + L"", + (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9), + 0, 0, + false, false, false, false, false, false + }, + { + k7zFormat, + (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9), + METHODS_PAIR(g_7zMethods), + true, true, true, true, true, true + }, + { + L"Zip", + (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9), + METHODS_PAIR(g_ZipMethods), + false, false, true, false, true, false + }, + { + L"GZip", + (1 << 1) | (1 << 5) | (1 << 7) | (1 << 9), + METHODS_PAIR(g_GZipMethods), + false, false, false, false, false, false + }, + { + L"BZip2", + (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9), + METHODS_PAIR(g_BZip2Methods), + false, false, true, false, false, false + }, + { + L"xz", + (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9), + METHODS_PAIR(g_XzMethods), + false, false, true, false, false, false + }, + { + L"Tar", + (1 << 0), + 0, 0, + false, false, false, false, false, false + } +}; + +static bool IsMethodSupportedBySfx(int methodID) +{ + for (int i = 0; i < MY_SIZE_OF_ARRAY(g_7zSfxMethods); i++) + if (methodID == g_7zSfxMethods[i]) + return true; + return false; +}; + +static UInt64 GetMaxRamSizeForProgram() +{ + UInt64 physSize = NSystem::GetRamSize(); + const UInt64 kMinSysSize = (1 << 24); + if (physSize <= kMinSysSize) + physSize = 0; + else + physSize -= kMinSysSize; + const UInt64 kMinUseSize = (1 << 25); + if (physSize < kMinUseSize) + physSize = kMinUseSize; + return physSize; +} + +bool CCompressDialog::OnInit() +{ + #ifdef LANG + LangSetWindowText(HWND(*this), 0x02000D00); + LangSetDlgItemsText(HWND(*this), kIDLangPairs, MY_SIZE_OF_ARRAY(kIDLangPairs) ); + #endif + _password1Control.Attach(GetItem(IDC_COMPRESS_EDIT_PASSWORD1)); + _password2Control.Attach(GetItem(IDC_COMPRESS_EDIT_PASSWORD2)); + _password1Control.SetText(Info.Password); + _password2Control.SetText(Info.Password); + _encryptionMethod.Attach(GetItem(IDC_COMPRESS_COMBO_ENCRYPTION_METHOD)); + + m_ArchivePath.Attach(GetItem(IDC_COMPRESS_COMBO_ARCHIVE)); + m_Format.Attach(GetItem(IDC_COMPRESS_COMBO_FORMAT)); + m_Level.Attach(GetItem(IDC_COMPRESS_COMBO_LEVEL)); + m_Method.Attach(GetItem(IDC_COMPRESS_COMBO_METHOD)); + m_Dictionary.Attach(GetItem(IDC_COMPRESS_COMBO_DICTIONARY)); + m_Order.Attach(GetItem(IDC_COMPRESS_COMBO_ORDER)); + m_Solid.Attach(GetItem(IDC_COMPRESS_COMBO_SOLID)); + m_NumThreads.Attach(GetItem(IDC_COMPRESS_COMBO_THREADS)); + + m_UpdateMode.Attach(GetItem(IDC_COMPRESS_COMBO_UPDATE_MODE)); + m_Volume.Attach(GetItem(IDC_COMPRESS_COMBO_VOLUME)); + m_Params.Attach(GetItem(IDC_COMPRESS_EDIT_PARAMETERS)); + + AddVolumeItems(m_Volume); + + ReadCompressionInfo(m_RegistryInfo); + CheckButton(IDC_COMPRESS_CHECK_SHOW_PASSWORD, m_RegistryInfo.ShowPassword); + CheckButton(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, m_RegistryInfo.EncryptHeaders); + + UpdatePasswordControl(); + + Info.ArchiverInfoIndex = 0; + int i; + for (i = 0; i < m_ArchiverInfoList.Size(); i++) + { + const CArcInfoEx &ai = m_ArchiverInfoList[i]; + int index = (int)m_Format.AddString(ai.Name); + m_Format.SetItemData(index, i); + if (ai.Name.CompareNoCase(m_RegistryInfo.ArchiveType) == 0 || i == 0) + { + m_Format.SetCurSel(index); + Info.ArchiverInfoIndex = i; + } + } + + SetArchiveName(Info.ArchiveName); + SetLevel(); + SetParams(); + + for (i = 0; i < m_RegistryInfo.HistoryArchives.Size() && i < kHistorySize; i++) + m_ArchivePath.AddString(m_RegistryInfo.HistoryArchives[i]); + + m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_ADD, 0x02000DA1)); + m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_UPDATE, 0x02000DA2)); + m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_FRESH, 0x02000DA3)); + m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE, 0x02000DA4)); + + m_UpdateMode.SetCurSel(0); + + SetSolidBlockSize(); + SetNumThreads(); + + TCHAR s[40] = { TEXT('/'), TEXT(' '), 0 }; + ConvertUInt32ToString(NSystem::GetNumberOfProcessors(), s + 2); + SetItemText(IDC_COMPRESS_HARDWARE_THREADS, s); + + CheckButton(IDC_COMPRESS_SFX, Info.SFXMode); + CheckButton(IDC_COMPRESS_SHARED, Info.OpenShareForWrite); + + CheckControlsEnable(); + + OnButtonSFX(); + + SetEncryptionMethod(); + SetMemoryUsage(); + return CModalDialog::OnInit(); +} + +namespace NCompressDialog +{ + bool CInfo::GetFullPathName(UString &result) const + { + NDirectory::MySetCurrentDirectory(CurrentDirPrefix); + return MyGetFullPathName(ArchiveName, result); + } +} + +void CCompressDialog::UpdatePasswordControl() +{ + bool showPassword = IsShowPasswordChecked(); + TCHAR c = showPassword ? 0: TEXT('*'); + _password1Control.SetPasswordChar(c); + _password2Control.SetPasswordChar(c); + UString password; + _password1Control.GetText(password); + _password1Control.SetText(password); + _password2Control.GetText(password); + _password2Control.SetText(password); + + int cmdShow = showPassword ? SW_HIDE : SW_SHOW; + ShowItem(IDC_STATIC_COMPRESS_PASSWORD2, cmdShow); + _password2Control.Show(cmdShow); +} + +bool CCompressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) +{ + switch(buttonID) + { + case IDC_COMPRESS_BUTTON_SET_ARCHIVE: + { + OnButtonSetArchive(); + return true; + } + case IDC_COMPRESS_SFX: + { + OnButtonSFX(); + SetMemoryUsage(); + return true; + } + case IDC_COMPRESS_CHECK_SHOW_PASSWORD: + { + UpdatePasswordControl(); + return true; + } + } + return CModalDialog::OnButtonClicked(buttonID, buttonHWND); +} + +void CCompressDialog::CheckSFXControlsEnable() +{ + const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()]; + bool enable = fi.SFX; + if (enable) + { + int methodID = GetMethodID(); + enable = (methodID == -1 || IsMethodSupportedBySfx(methodID)); + } + if (!enable) + CheckButton(IDC_COMPRESS_SFX, false); + EnableItem(IDC_COMPRESS_SFX, enable); +} + +void CCompressDialog::CheckVolumeEnable() +{ + bool isSFX = IsSFX(); + m_Volume.Enable(!isSFX); + if (isSFX) + m_Volume.SetText(TEXT("")); +} + +void CCompressDialog::CheckControlsEnable() +{ + const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()]; + Info.SolidIsSpecified = fi.Solid; + bool multiThreadEnable = fi.MultiThread; + Info.MultiThreadIsAllowed = multiThreadEnable; + Info.EncryptHeadersIsAllowed = fi.EncryptFileNames; + + EnableItem(IDC_COMPRESS_COMBO_SOLID, fi.Solid); + EnableItem(IDC_COMPRESS_COMBO_THREADS, multiThreadEnable); + CheckSFXControlsEnable(); + CheckVolumeEnable(); + + EnableItem(IDC_COMPRESS_ENCRYPTION, fi.Encrypt); + + EnableItem(IDC_STATIC_COMPRESS_PASSWORD1, fi.Encrypt); + EnableItem(IDC_STATIC_COMPRESS_PASSWORD2, fi.Encrypt); + EnableItem(IDC_COMPRESS_EDIT_PASSWORD1, fi.Encrypt); + EnableItem(IDC_COMPRESS_EDIT_PASSWORD2, fi.Encrypt); + EnableItem(IDC_COMPRESS_CHECK_SHOW_PASSWORD, fi.Encrypt); + + EnableItem(IDC_STATIC_COMPRESS_ENCRYPTION_METHOD, fi.Encrypt); + EnableItem(IDC_COMPRESS_COMBO_ENCRYPTION_METHOD, fi.Encrypt); + EnableItem(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, fi.EncryptFileNames); + + ShowItem(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, fi.EncryptFileNames ? SW_SHOW : SW_HIDE); +} + +bool CCompressDialog::IsSFX() +{ + CWindow sfxButton = GetItem(IDC_COMPRESS_SFX); + return sfxButton.IsEnabled() && IsButtonCheckedBool(IDC_COMPRESS_SFX); +} + +void CCompressDialog::OnButtonSFX() +{ + SetMethod(GetMethodID()); + + UString fileName; + m_ArchivePath.GetText(fileName); + int dotPos = fileName.ReverseFind(L'.'); + int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR); + if (dotPos < 0 || dotPos <= slashPos) + dotPos = -1; + if (IsSFX()) + { + if (dotPos >= 0) + fileName = fileName.Left(dotPos); + fileName += kExeExt; + m_ArchivePath.SetText(fileName); + } + else + { + if (dotPos >= 0) + { + UString ext = fileName.Mid(dotPos); + if (ext.CompareNoCase(kExeExt) == 0) + { + fileName = fileName.Left(dotPos); + m_ArchivePath.SetText(fileName); + } + } + SetArchiveName2(false); // it's for OnInit + } + + CheckVolumeEnable(); +} + +void CCompressDialog::OnButtonSetArchive() +{ + UString fileName; + m_ArchivePath.GetText(fileName); + fileName.Trim(); + Info.ArchiveName = fileName; + UString fullFileName; + if (!Info.GetFullPathName(fullFileName)) + { + fullFileName = Info.ArchiveName; + return; + } + UString title = LangString(IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE, 0x02000D90); + UString s = LangString(IDS_OPEN_TYPE_ALL_FILES, 0x02000DB1); + s += L" (*.*)"; + UString resPath; + if (!MyGetOpenFileName(HWND(*this), title, fullFileName, s, resPath)) + return; + m_ArchivePath.SetText(resPath); +} + +// in ExtractDialog.cpp +extern void AddUniqueString(UStringVector &strings, const UString &srcString); + +static bool IsAsciiString(const UString &s) +{ + for (int i = 0; i < s.Length(); i++) + { + wchar_t c = s[i]; + if (c < 0x20 || c > 0x7F) + return false; + } + return true; +} + +void CCompressDialog::OnOK() +{ + _password1Control.GetText(Info.Password); + if (IsZipFormat()) + { + if (!IsAsciiString(Info.Password)) + { + ShowErrorMessageHwndRes(*this, IDS_PASSWORD_USE_ASCII, 0x02000B11); + return; + } + UString method = GetEncryptionMethodSpec(); + method.MakeUpper(); + if (method.Find(L"AES") == 0) + { + if (Info.Password.Length() > 99) + { + ShowErrorMessageHwndRes(*this, IDS_PASSWORD_IS_TOO_LONG, 0x02000B12); + return; + } + } + } + if (!IsShowPasswordChecked()) + { + UString password2; + _password2Control.GetText(password2); + if (password2 != Info.Password) + { + ShowErrorMessageHwndRes(*this, IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH, 0x02000B10); + return; + } + } + + SaveOptionsInMem(); + UString s; + m_ArchivePath.GetText(s); + s.Trim(); + m_RegistryInfo.HistoryArchives.Clear(); + AddUniqueString(m_RegistryInfo.HistoryArchives, s); + Info.ArchiveName = s; + Info.UpdateMode = NCompressDialog::NUpdateMode::EEnum(m_UpdateMode.GetCurSel()); + + Info.Level = GetLevelSpec(); + Info.Dictionary = GetDictionarySpec(); + Info.Order = GetOrderSpec(); + Info.OrderMode = GetOrderMode(); + Info.NumThreads = GetNumThreadsSpec(); + + UInt32 solidLogSize = GetBlockSizeSpec(); + Info.SolidBlockSize = 0; + if (solidLogSize > 0 && solidLogSize != (UInt32)-1) + Info.SolidBlockSize = (solidLogSize >= 64) ? (UInt64)(Int64)-1 : ((UInt64)1 << solidLogSize); + + Info.Method = GetMethodSpec(); + Info.EncryptionMethod = GetEncryptionMethodSpec(); + Info.ArchiverInfoIndex = GetFormatIndex(); + Info.SFXMode = IsSFX(); + Info.OpenShareForWrite = IsButtonCheckedBool(IDC_COMPRESS_SHARED); + + m_RegistryInfo.EncryptHeaders = Info.EncryptHeaders = IsButtonCheckedBool(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES); + + m_Params.GetText(Info.Options); + UString volumeString; + m_Volume.GetText(volumeString); + volumeString.Trim(); + Info.VolumeSizes.Clear(); + if (!volumeString.IsEmpty()) + { + if (!ParseVolumeSizes(volumeString, Info.VolumeSizes)) + { + ShowErrorMessageHwndRes(*this, IDS_COMPRESS_INCORRECT_VOLUME_SIZE, 0x02000D41); + return; + } + if (!Info.VolumeSizes.IsEmpty()) + { + const UInt64 volumeSize = Info.VolumeSizes.Back(); + if (volumeSize < (100 << 10)) + { + wchar_t s[32]; + ConvertUInt64ToString(volumeSize, s); + if (::MessageBoxW(*this, MyFormatNew(IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE, 0x02000D42, s), + L"7-Zip", MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL) != IDYES) + return; + } + } + } + + for (int i = 0; i < m_ArchivePath.GetCount(); i++) + { + UString sTemp; + m_ArchivePath.GetLBText(i, sTemp); + sTemp.Trim(); + AddUniqueString(m_RegistryInfo.HistoryArchives, sTemp); + } + if (m_RegistryInfo.HistoryArchives.Size() > kHistorySize) + m_RegistryInfo.HistoryArchives.DeleteBack(); + + m_RegistryInfo.ArchiveType = m_ArchiverInfoList[Info.ArchiverInfoIndex].Name; + m_RegistryInfo.ShowPassword = IsShowPasswordChecked(); + + SaveCompressionInfo(m_RegistryInfo); + + CModalDialog::OnOK(); +} + +static LPCWSTR kHelpTopic = L"fm/plugins/7-zip/add.htm"; + +void CCompressDialog::OnHelp() +{ + ShowHelpWindow(NULL, kHelpTopic); +} + +bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam) +{ + if (code == CBN_SELCHANGE) + { + switch(itemID) + { + case IDC_COMPRESS_COMBO_FORMAT: + { + bool isSFX = IsSFX(); + SaveOptionsInMem(); + SetLevel(); + SetSolidBlockSize(); + SetNumThreads(); + SetParams(); + CheckControlsEnable(); + SetArchiveName2(isSFX); + SetEncryptionMethod(); + SetMemoryUsage(); + return true; + } + case IDC_COMPRESS_COMBO_LEVEL: + { + const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + int index = FindRegistryFormatAlways(ai.Name); + NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + fo.ResetForLevelChange(); + SetMethod(); + SetSolidBlockSize(); + SetNumThreads(); + CheckSFXNameChange(); + SetMemoryUsage(); + return true; + } + case IDC_COMPRESS_COMBO_METHOD: + { + SetDictionary(); + SetOrder(); + SetSolidBlockSize(); + SetNumThreads(); + CheckSFXNameChange(); + SetMemoryUsage(); + return true; + } + case IDC_COMPRESS_COMBO_DICTIONARY: + case IDC_COMPRESS_COMBO_ORDER: + { + SetSolidBlockSize(); + SetMemoryUsage(); + return true; + } + case IDC_COMPRESS_COMBO_THREADS: + { + SetMemoryUsage(); + return true; + } + } + } + return CModalDialog::OnCommand(code, itemID, lParam); +} + +void CCompressDialog::CheckSFXNameChange() +{ + bool isSFX = IsSFX(); + CheckSFXControlsEnable(); + if (isSFX != IsSFX()) + SetArchiveName2(isSFX); +} + +void CCompressDialog::SetArchiveName2(bool prevWasSFX) +{ + UString fileName; + m_ArchivePath.GetText(fileName); + const CArcInfoEx &prevArchiverInfo = m_ArchiverInfoList[m_PrevFormat]; + if (prevArchiverInfo.KeepName || Info.KeepName) + { + UString prevExtension = prevArchiverInfo.GetMainExt(); + if (prevWasSFX) + prevExtension = kExeExt; + else + prevExtension = UString('.') + prevExtension; + const int prevExtensionLen = prevExtension.Length(); + if (fileName.Length() >= prevExtensionLen) + if (fileName.Right(prevExtensionLen).CompareNoCase(prevExtension) == 0) + fileName = fileName.Left(fileName.Length() - prevExtensionLen); + } + SetArchiveName(fileName); +} + +// if type.KeepName then use OriginalFileName +// else if !KeepName remove extension +// add new extension + +void CCompressDialog::SetArchiveName(const UString &name) +{ + UString fileName = name; + Info.ArchiverInfoIndex = GetFormatIndex(); + const CArcInfoEx &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex]; + m_PrevFormat = Info.ArchiverInfoIndex; + if (ai.KeepName) + { + fileName = OriginalFileName; + } + else + { + if (!Info.KeepName) + { + int dotPos = fileName.ReverseFind('.'); + int slashPos = MyMax(fileName.ReverseFind(WCHAR_PATH_SEPARATOR), fileName.ReverseFind('/')); + if (dotPos >= 0 && dotPos > slashPos + 1) + fileName = fileName.Left(dotPos); + } + } + + if (IsSFX()) + fileName += kExeExt; + else + { + fileName += L'.'; + fileName += ai.GetMainExt(); + } + m_ArchivePath.SetText(fileName); +} + +int CCompressDialog::FindRegistryFormat(const UString &name) +{ + for (int i = 0; i < m_RegistryInfo.FormatOptionsVector.Size(); i++) + { + const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[i]; + if (GetUnicodeString(fo.FormatID) == name) + return i; + } + return -1; +} + +int CCompressDialog::FindRegistryFormatAlways(const UString &name) +{ + int index = FindRegistryFormat(name); + if (index < 0) + { + NCompression::CFormatOptions fo; + fo.FormatID = GetSystemString(name); + index = m_RegistryInfo.FormatOptionsVector.Add(fo); + } + return index; +} + +int CCompressDialog::GetStaticFormatIndex() +{ + int formatIndex = GetFormatIndex(); + const CArcInfoEx &ai = m_ArchiverInfoList[formatIndex]; + for (int i = 0; i < MY_SIZE_OF_ARRAY(g_Formats); i++) + if (ai.Name.CompareNoCase(g_Formats[i].Name) == 0) + return i; + return 0; // -1; +} + +void CCompressDialog::SetNearestSelectComboBox(NControl::CComboBox &comboBox, UInt32 value) +{ + for (int i = comboBox.GetCount() - 1; i >= 0; i--) + if ((UInt32)comboBox.GetItemData(i) <= value) + { + comboBox.SetCurSel(i); + return; + } + if (comboBox.GetCount() > 0) + comboBox.SetCurSel(0); +} + +void CCompressDialog::SetLevel() +{ + m_Level.ResetContent(); + const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()]; + const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + int index = FindRegistryFormat(ai.Name); + UInt32 level = kNormal; + if (index >= 0) + { + const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + if (fo.Level <= kUltra) + level = fo.Level; + else + level = kUltra; + } + int i; + for (i = 0; i <= kUltra; i++) + { + if ((fi.LevelsMask & (1 << i)) != 0) + { + const CLevelInfo &levelInfo = g_Levels[i]; + int index = (int)m_Level.AddString(LangString(levelInfo.ResourceID, levelInfo.LangID)); + m_Level.SetItemData(index, i); + } + } + SetNearestSelectComboBox(m_Level, level); + SetMethod(); +} + +void CCompressDialog::SetMethod(int keepMethodId) +{ + m_Method.ResetContent(); + UInt32 level = GetLevel(); + if (level == 0) + { + SetDictionary(); + SetOrder(); + return; + } + const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()]; + const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + int index = FindRegistryFormat(ai.Name); + UString defaultMethod; + if (index >= 0) + { + const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + defaultMethod = fo.Method; + } + bool isSfx = IsSFX(); + bool weUseSameMethod = false; + for (int m = 0; m < fi.NumMethods; m++) + { + EMethodID methodID = fi.MathodIDs[m]; + if (isSfx) + if (!IsMethodSupportedBySfx(methodID)) + continue; + const LPCWSTR method = kMethodsNames[methodID]; + int itemIndex = (int)m_Method.AddString(GetSystemString(method)); + if (keepMethodId == methodID) + { + m_Method.SetCurSel(itemIndex); + weUseSameMethod = true; + continue; + } + if ((defaultMethod.CompareNoCase(method) == 0 || m == 0) && !weUseSameMethod) + m_Method.SetCurSel(itemIndex); + } + if (!weUseSameMethod) + { + SetDictionary(); + SetOrder(); + } +} + +bool CCompressDialog::IsZipFormat() +{ + const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + return (ai.Name.CompareNoCase(L"zip") == 0); +} + +void CCompressDialog::SetEncryptionMethod() +{ + _encryptionMethod.ResetContent(); + const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + if (ai.Name.CompareNoCase(L"7z") == 0) + { + _encryptionMethod.AddString(TEXT("AES-256")); + _encryptionMethod.SetCurSel(0); + } + else if (ai.Name.CompareNoCase(L"zip") == 0) + { + int index = FindRegistryFormat(ai.Name); + UString encryptionMethod; + if (index >= 0) + { + const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + encryptionMethod = fo.EncryptionMethod; + } + _encryptionMethod.AddString(TEXT("ZipCrypto")); + _encryptionMethod.AddString(TEXT("AES-256")); + _encryptionMethod.SetCurSel(encryptionMethod.Find(L"AES") == 0 ? 1 : 0); + } +} + +int CCompressDialog::GetMethodID() +{ + UString methodName; + m_Method.GetText(methodName); + for (int i = 0; i < MY_SIZE_OF_ARRAY(kMethodsNames); i++) + if (methodName.CompareNoCase(kMethodsNames[i]) == 0) + return i; + return -1; +} + +UString CCompressDialog::GetMethodSpec() +{ + if (m_Method.GetCount() <= 1) + return UString(); + UString result; + m_Method.GetText(result); + return result; +} + +UString CCompressDialog::GetEncryptionMethodSpec() +{ + if (_encryptionMethod.GetCount() <= 1) + return UString(); + if (_encryptionMethod.GetCurSel() <= 0) + return UString(); + UString result; + _encryptionMethod.GetText(result); + result.Replace(L"-", L""); + return result; +} + +int CCompressDialog::AddDictionarySize(UInt32 size, bool kilo, bool maga) +{ + UInt32 sizePrint = size; + if (kilo) + sizePrint >>= 10; + else if (maga) + sizePrint >>= 20; + TCHAR s[40]; + ConvertUInt32ToString(sizePrint, s); + if (kilo) + lstrcat(s, TEXT(" K")); + else if (maga) + lstrcat(s, TEXT(" M")); + else + lstrcat(s, TEXT(" ")); + lstrcat(s, TEXT("B")); + int index = (int)m_Dictionary.AddString(s); + m_Dictionary.SetItemData(index, size); + return index; +} + +int CCompressDialog::AddDictionarySize(UInt32 size) +{ + if (size > 0) + { + if ((size & 0xFFFFF) == 0) + return AddDictionarySize(size, false, true); + if ((size & 0x3FF) == 0) + return AddDictionarySize(size, true, false); + } + return AddDictionarySize(size, false, false); +} + +void CCompressDialog::SetDictionary() +{ + m_Dictionary.ResetContent(); + const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + int index = FindRegistryFormat(ai.Name); + UInt32 defaultDictionary = UInt32(-1); + if (index >= 0) + { + const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + if (fo.Method.CompareNoCase(GetMethodSpec()) == 0) + defaultDictionary = fo.Dictionary; + } + int methodID = GetMethodID(); + UInt32 level = GetLevel2(); + if (methodID < 0) + return; + const UInt64 maxRamSize = GetMaxRamSizeForProgram(); + switch (methodID) + { + case kLZMA: + case kLZMA2: + { + static const UInt32 kMinDicSize = (1 << 16); + if (defaultDictionary == UInt32(-1)) + { + if (level >= 9) defaultDictionary = (1 << 26); + else if (level >= 7) defaultDictionary = (1 << 25); + else if (level >= 5) defaultDictionary = (1 << 24); + else if (level >= 3) defaultDictionary = (1 << 20); + else defaultDictionary = (kMinDicSize); + } + int i; + AddDictionarySize(kMinDicSize); + m_Dictionary.SetCurSel(0); + for (i = 20; i <= 30; i++) + for (int j = 0; j < 2; j++) + { + if (i == 20 && j > 0) + continue; + UInt32 dictionary = (1 << i) + (j << (i - 1)); + if (dictionary > + #ifdef _WIN64 + (1 << 30) + #else + (1 << 26) + #endif + ) + continue; + AddDictionarySize(dictionary); + UInt64 decomprSize; + UInt64 requiredComprSize = GetMemoryUsage(dictionary, decomprSize); + if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize) + m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1); + } + + // SetNearestSelectComboBox(m_Dictionary, defaultDictionary); + break; + } + case kPPMd: + { + if (defaultDictionary == UInt32(-1)) + { + if (level >= 9) defaultDictionary = (192 << 20); + else if (level >= 7) defaultDictionary = ( 64 << 20); + else if (level >= 5) defaultDictionary = ( 16 << 20); + else defaultDictionary = ( 4 << 20); + } + int i; + for (i = 20; i < 31; i++) + for (int j = 0; j < 2; j++) + { + if (i == 20 && j > 0) + continue; + UInt32 dictionary = (1 << i) + (j << (i - 1)); + if (dictionary >= (1 << 31)) + continue; + AddDictionarySize(dictionary); + UInt64 decomprSize; + UInt64 requiredComprSize = GetMemoryUsage(dictionary, decomprSize); + if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize || m_Dictionary.GetCount() == 0) + m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1); + } + SetNearestSelectComboBox(m_Dictionary, defaultDictionary); + break; + } + case kDeflate: + { + AddDictionarySize(32 << 10); + m_Dictionary.SetCurSel(0); + break; + } + case kDeflate64: + { + AddDictionarySize(64 << 10); + m_Dictionary.SetCurSel(0); + break; + } + case kBZip2: + { + // UInt32 defaultDictionary; + if (defaultDictionary == UInt32(-1)) + { + if (level >= 5) + defaultDictionary = (900 << 10); + else if (level >= 3) + defaultDictionary = (500 << 10); + else + defaultDictionary = (100 << 10); + } + for (int i = 1; i <= 9; i++) + { + UInt32 dictionary = (i * 100) << 10; + AddDictionarySize(dictionary); + if (dictionary <= defaultDictionary || m_Dictionary.GetCount() == 0) + m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1); + } + break; + } + } +} + +UInt32 CCompressDialog::GetComboValue(NWindows::NControl::CComboBox &c, int defMax) +{ + if (c.GetCount() <= defMax) + return (UInt32)-1; + return (UInt32)c.GetItemData(c.GetCurSel()); +} + +UInt32 CCompressDialog::GetLevel2() +{ + UInt32 level = GetLevel(); + if (level == (UInt32)-1) + level = 5; + return level; +} + +int CCompressDialog::AddOrder(UInt32 size) +{ + TCHAR s[40]; + ConvertUInt32ToString(size, s); + int index = (int)m_Order.AddString(s); + m_Order.SetItemData(index, size); + return index; +} + +void CCompressDialog::SetOrder() +{ + m_Order.ResetContent(); + const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + int index = FindRegistryFormat(ai.Name); + UInt32 defaultOrder = UInt32(-1); + if (index >= 0) + { + const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + if (fo.Method.CompareNoCase(GetMethodSpec()) == 0) + defaultOrder = fo.Order; + } + int methodID = GetMethodID(); + UInt32 level = GetLevel2(); + if (methodID < 0) + return; + switch (methodID) + { + case kLZMA: + case kLZMA2: + { + if (defaultOrder == UInt32(-1)) + defaultOrder = (level >= 7) ? 64 : 32; + for (int i = 3; i <= 8; i++) + for (int j = 0; j < 2; j++) + { + UInt32 order = (1 << i) + (j << (i - 1)); + if (order <= 256) + AddOrder(order); + } + AddOrder(273); + SetNearestSelectComboBox(m_Order, defaultOrder); + break; + } + case kPPMd: + { + if (defaultOrder == UInt32(-1)) + { + if (level >= 9) + defaultOrder = 32; + else if (level >= 7) + defaultOrder = 16; + else if (level >= 5) + defaultOrder = 6; + else + defaultOrder = 4; + } + int i; + AddOrder(2); + AddOrder(3); + for (i = 2; i < 8; i++) + for (int j = 0; j < 4; j++) + { + UInt32 order = (1 << i) + (j << (i - 2)); + if (order < 32) + AddOrder(order); + } + AddOrder(32); + SetNearestSelectComboBox(m_Order, defaultOrder); + break; + } + case kDeflate: + case kDeflate64: + { + if (defaultOrder == UInt32(-1)) + { + if (level >= 9) + defaultOrder = 128; + else if (level >= 7) + defaultOrder = 64; + else + defaultOrder = 32; + } + int i; + for (i = 3; i <= 8; i++) + for (int j = 0; j < 2; j++) + { + UInt32 order = (1 << i) + (j << (i - 1)); + if (order <= 256) + AddOrder(order); + } + AddOrder(methodID == kDeflate64 ? 257 : 258); + SetNearestSelectComboBox(m_Order, defaultOrder); + break; + } + case kBZip2: + { + break; + } + } +} + +bool CCompressDialog::GetOrderMode() +{ + switch (GetMethodID()) + { + case kPPMd: + return true; + } + return false; +} + +static const UInt32 kNoSolidBlockSize = 0; +static const UInt32 kSolidBlockSize = 64; + +void CCompressDialog::SetSolidBlockSize() +{ + m_Solid.ResetContent(); + const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()]; + if (!fi.Solid) + return; + + UInt32 level = GetLevel2(); + if (level == 0) + return; + + UInt32 dictionary = GetDictionarySpec(); + if (dictionary == UInt32(-1)) + dictionary = 1; + + UInt32 defaultBlockSize = (UInt32)-1; + + const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + int index = FindRegistryFormat(ai.Name); + if (index >= 0) + { + const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + if (fo.Method.CompareNoCase(GetMethodSpec()) == 0) + defaultBlockSize = fo.BlockLogSize; + } + + index = (int)m_Solid.AddString(LangString(IDS_COMPRESS_NON_SOLID, 0x02000D14)); + m_Solid.SetItemData(index, (UInt32)kNoSolidBlockSize); + m_Solid.SetCurSel(0); + bool needSet = defaultBlockSize == (UInt32)-1; + for (int i = 20; i <= 36; i++) + { + if (needSet && dictionary >= (((UInt64)1 << (i - 7))) && i <= 32) + defaultBlockSize = i; + TCHAR s[40]; + ConvertUInt32ToString(1 << (i % 10), s); + if (i < 30) lstrcat(s, TEXT(" M")); + else lstrcat(s, TEXT(" G")); + lstrcat(s, TEXT("B")); + int index = (int)m_Solid.AddString(s); + m_Solid.SetItemData(index, (UInt32)i); + } + index = (int)m_Solid.AddString(LangString(IDS_COMPRESS_SOLID, 0x02000D15)); + m_Solid.SetItemData(index, kSolidBlockSize); + if (defaultBlockSize == (UInt32)-1) + defaultBlockSize = kSolidBlockSize; + if (defaultBlockSize != kNoSolidBlockSize) + SetNearestSelectComboBox(m_Solid, defaultBlockSize); +} + +void CCompressDialog::SetNumThreads() +{ + m_NumThreads.ResetContent(); + + const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()]; + if (!fi.MultiThread) + return; + + UInt32 numHardwareThreads = NSystem::GetNumberOfProcessors(); + UInt32 defaultValue = numHardwareThreads; + + const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + int index = FindRegistryFormat(ai.Name); + if (index >= 0) + { + const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + if (fo.Method.CompareNoCase(GetMethodSpec()) == 0) + defaultValue = fo.NumThreads; + } + + UInt32 numAlgoThreadsMax = 1; + int methodID = GetMethodID(); + switch (methodID) + { + case kLZMA: numAlgoThreadsMax = 2; break; + case kLZMA2: numAlgoThreadsMax = 32; break; + case kBZip2: numAlgoThreadsMax = 32; break; + } + if (IsZipFormat()) + numAlgoThreadsMax = 128; + for (UInt32 i = 1; i <= numHardwareThreads * 2 && i <= numAlgoThreadsMax; i++) + { + TCHAR s[40]; + ConvertUInt32ToString(i, s); + int index = (int)m_NumThreads.AddString(s); + m_NumThreads.SetItemData(index, (UInt32)i); + } + SetNearestSelectComboBox(m_NumThreads, defaultValue); +} + + +UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, UInt64 &decompressMemory) +{ + decompressMemory = UInt64(Int64(-1)); + UInt32 level = GetLevel2(); + if (level == 0) + { + decompressMemory = (1 << 20); + return decompressMemory; + } + UInt64 size = 0; + + const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()]; + if (fi.Filter && level >= 9) + size += (12 << 20) * 2 + (5 << 20); + UInt32 numThreads = GetNumThreads2(); + if (IsZipFormat()) + { + UInt32 numSubThreads = 1; + if (GetMethodID() == kLZMA && numThreads > 1 && level >= 5) + numSubThreads = 2; + UInt32 numMainThreads = numThreads / numSubThreads; + if (numMainThreads > 1) + size += (UInt64)numMainThreads << 25; + } + int methidId = GetMethodID(); + switch (methidId) + { + case kLZMA: + case kLZMA2: + { + UInt32 hs = dictionary - 1; + hs |= (hs >> 1); + hs |= (hs >> 2); + hs |= (hs >> 4); + hs |= (hs >> 8); + hs >>= 1; + hs |= 0xFFFF; + if (hs > (1 << 24)) + hs >>= 1; + hs++; + UInt64 size1 = (UInt64)hs * 4; + size1 += (UInt64)dictionary * 4; + if (level >= 5) + size1 += (UInt64)dictionary * 4; + size1 += (2 << 20); + + UInt32 numThreads1 = 1; + if (numThreads > 1 && level >= 5) + { + size1 += (2 << 20) + (4 << 20); + numThreads1 = 2; + } + UInt32 numBlockThreads = numThreads / numThreads1; + if (methidId == kLZMA || numBlockThreads == 1) + size1 += (UInt64)dictionary * 3 / 2; + else + { + UInt64 chunkSize = (UInt64)dictionary << 2; + chunkSize = MyMax(chunkSize, (UInt64)(1 << 20)); + chunkSize = MyMin(chunkSize, (UInt64)(1 << 28)); + chunkSize = MyMax(chunkSize, (UInt64)dictionary); + size1 += chunkSize * 2; + } + size += size1 * numBlockThreads; + + decompressMemory = dictionary + (2 << 20); + return size; + } + case kPPMd: + { + decompressMemory = dictionary + (2 << 20); + return size + decompressMemory; + } + case kDeflate: + case kDeflate64: + { + UInt32 order = GetOrder(); + if (order == UInt32(-1)) + order = 32; + if (level >= 7) + size += (1 << 20); + size += 3 << 20; + decompressMemory = (2 << 20); + return size; + } + case kBZip2: + { + decompressMemory = (7 << 20); + UInt64 memForOneThread = (10 << 20); + return size + memForOneThread * numThreads; + } + } + return UInt64(Int64(-1)); +} + +UInt64 CCompressDialog::GetMemoryUsage(UInt64 &decompressMemory) +{ + return GetMemoryUsage(GetDictionary(), decompressMemory); +} + +void CCompressDialog::PrintMemUsage(UINT res, UInt64 value) +{ + if (value == (UInt64)(Int64)-1) + { + SetItemText(res, TEXT("?")); + return; + } + value = (value + (1 << 20) - 1) >> 20; + TCHAR s[40]; + ConvertUInt64ToString(value, s); + lstrcat(s, TEXT(" MB")); + SetItemText(res, s); +} + +void CCompressDialog::SetMemoryUsage() +{ + UInt64 decompressMem; + UInt64 memUsage = GetMemoryUsage(decompressMem); + PrintMemUsage(IDC_STATIC_COMPRESS_MEMORY_VALUE, memUsage); + PrintMemUsage(IDC_STATIC_COMPRESS_MEMORY_DE_VALUE, decompressMem); +} + +void CCompressDialog::SetParams() +{ + const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + m_Params.SetText(TEXT("")); + int index = FindRegistryFormat(ai.Name); + if (index >= 0) + { + const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + m_Params.SetText(fo.Options); + } +} + +void CCompressDialog::SaveOptionsInMem() +{ + const CArcInfoEx &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex]; + int index = FindRegistryFormatAlways(ai.Name); + m_Params.GetText(Info.Options); + Info.Options.Trim(); + NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + fo.Options = Info.Options; + fo.Level = GetLevelSpec(); + fo.Dictionary = GetDictionarySpec(); + fo.Order = GetOrderSpec(); + fo.Method = GetMethodSpec(); + fo.EncryptionMethod = GetEncryptionMethodSpec(); + fo.NumThreads = GetNumThreadsSpec(); + fo.BlockLogSize = GetBlockSizeSpec(); +} + +int CCompressDialog::GetFormatIndex() +{ + return (int)m_Format.GetItemData(m_Format.GetCurSel()); +} diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog.h new file mode 100644 index 000000000..75eeeee82 --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog.h @@ -0,0 +1,184 @@ +// CompressDialog.h + +#ifndef __COMPRESS_DIALOG_H +#define __COMPRESS_DIALOG_H + +#include "Windows/Control/ComboBox.h" +#include "Windows/Control/Dialog.h" +#include "Windows/Control/Edit.h" + +#include "../Common/LoadCodecs.h" +#include "../Common/ZipRegistry.h" + +#include "CompressDialogRes.h" + +namespace NCompressDialog +{ + namespace NUpdateMode + { + enum EEnum + { + kAdd, + kUpdate, + kFresh, + kSynchronize, + }; + } + struct CInfo + { + NUpdateMode::EEnum UpdateMode; + bool SolidIsSpecified; + bool MultiThreadIsAllowed; + UInt64 SolidBlockSize; + UInt32 NumThreads; + + CRecordVector<UInt64> VolumeSizes; + + UInt32 Level; + UString Method; + UInt32 Dictionary; + bool OrderMode; + UInt32 Order; + UString Options; + + UString EncryptionMethod; + + bool SFXMode; + bool OpenShareForWrite; + + + UString ArchiveName; // in: Relative for ; out: abs + UString CurrentDirPrefix; + bool KeepName; + + bool GetFullPathName(UString &result) const; + + int ArchiverInfoIndex; + + UString Password; + bool EncryptHeadersIsAllowed; + bool EncryptHeaders; + + void Init() + { + Level = Dictionary = Order = UInt32(-1); + OrderMode = false; + Method.Empty(); + Options.Empty(); + EncryptionMethod.Empty(); + } + CInfo() + { + Init(); + } + }; +} + +class CCompressDialog: public NWindows::NControl::CModalDialog +{ + NWindows::NControl::CComboBox m_ArchivePath; + NWindows::NControl::CComboBox m_Format; + NWindows::NControl::CComboBox m_Level; + NWindows::NControl::CComboBox m_Method; + NWindows::NControl::CComboBox m_Dictionary; + NWindows::NControl::CComboBox m_Order; + NWindows::NControl::CComboBox m_Solid; + NWindows::NControl::CComboBox m_NumThreads; + NWindows::NControl::CComboBox m_UpdateMode; + NWindows::NControl::CComboBox m_Volume; + NWindows::NControl::CDialogChildControl m_Params; + + NWindows::NControl::CEdit _password1Control; + NWindows::NControl::CEdit _password2Control; + NWindows::NControl::CComboBox _encryptionMethod; + + NCompression::CInfo m_RegistryInfo; + + int m_PrevFormat; + void SetArchiveName(const UString &name); + int FindRegistryFormat(const UString &name); + int FindRegistryFormatAlways(const UString &name); + + void CheckSFXNameChange(); + void SetArchiveName2(bool prevWasSFX); + + int GetStaticFormatIndex(); + + void SetNearestSelectComboBox(NWindows::NControl::CComboBox &comboBox, UInt32 value); + + void SetLevel(); + + void SetMethod(int keepMethodId = -1); + int GetMethodID(); + UString GetMethodSpec(); + UString GetEncryptionMethodSpec(); + + bool IsZipFormat(); + + void SetEncryptionMethod(); + + int AddDictionarySize(UInt32 size, bool kilo, bool maga); + int AddDictionarySize(UInt32 size); + + void SetDictionary(); + + UInt32 GetComboValue(NWindows::NControl::CComboBox &c, int defMax = 0); + + UInt32 GetLevel() { return GetComboValue(m_Level); } + UInt32 GetLevelSpec() { return GetComboValue(m_Level, 1); } + UInt32 GetLevel2(); + UInt32 GetDictionary() { return GetComboValue(m_Dictionary); } + UInt32 GetDictionarySpec() { return GetComboValue(m_Dictionary, 1); } + UInt32 GetOrder() { return GetComboValue(m_Order); } + UInt32 GetOrderSpec() { return GetComboValue(m_Order, 1); } + UInt32 GetNumThreadsSpec() { return GetComboValue(m_NumThreads, 1); } + UInt32 GetNumThreads2() { UInt32 num = GetNumThreadsSpec(); if (num == UInt32(-1)) num = 1; return num; } + UInt32 GetBlockSizeSpec() { return GetComboValue(m_Solid, 1); } + + int AddOrder(UInt32 size); + void SetOrder(); + bool GetOrderMode(); + + void SetSolidBlockSize(); + void SetNumThreads(); + + UInt64 GetMemoryUsage(UInt32 dictionary, UInt64 &decompressMemory); + UInt64 GetMemoryUsage(UInt64 &decompressMemory); + void PrintMemUsage(UINT res, UInt64 value); + void SetMemoryUsage(); + void SetParams(); + void SaveOptionsInMem(); + + void UpdatePasswordControl(); + bool IsShowPasswordChecked() const + { return IsButtonChecked(IDC_COMPRESS_CHECK_SHOW_PASSWORD) == BST_CHECKED; } + + int GetFormatIndex(); +public: + CObjectVector<CArcInfoEx> m_ArchiverInfoList; + + NCompressDialog::CInfo Info; + UString OriginalFileName; // for bzip2, gzip2 + + INT_PTR Create(HWND wndParent = 0) + { return CModalDialog::Create(IDD_DIALOG_COMPRESS, wndParent); } + +protected: + + void CheckSFXControlsEnable(); + void CheckVolumeEnable(); + void CheckControlsEnable(); + + void OnButtonSetArchive(); + bool IsSFX(); + void OnButtonSFX(); + + virtual bool OnInit(); + virtual bool OnCommand(int code, int itemID, LPARAM lParam); + virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); + virtual void OnOK(); + virtual void OnHelp(); + +}; + +#endif diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialogRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialogRes.h new file mode 100644 index 000000000..beedde4ef --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialogRes.h @@ -0,0 +1,52 @@ +#define IDD_DIALOG_COMPRESS 152 +#define IDC_STATIC_COMPRESS_MEMORY 1022 +#define IDC_STATIC_COMPRESS_MEMORY_DE 1023 +#define IDC_STATIC_COMPRESS_MEMORY_VALUE 1027 +#define IDC_STATIC_COMPRESS_MEMORY_DE_VALUE 1028 +#define IDC_COMPRESS_COMBO_ARCHIVE 1072 +#define IDC_COMPRESS_BUTTON_SET_ARCHIVE 1073 +#define IDC_COMPRESS_COMBO_LEVEL 1074 +#define IDC_COMPRESS_COMBO_UPDATE_MODE 1075 +#define IDC_COMPRESS_COMBO_FORMAT 1076 +#define IDC_COMPRESS_COMBO_VOLUME 1077 +#define IDC_COMPRESS_COMBO_METHOD 1078 +#define IDC_COMPRESS_COMBO_DICTIONARY 1079 +#define IDC_COMPRESS_COMBO_ORDER 1080 + +#define IDC_COMPRESS_COMBO_SOLID 1081 +#define IDC_COMPRESS_COMBO_THREADS 1082 +#define IDC_COMPRESS_HARDWARE_THREADS 1083 + +#define IDC_COMPRESS_SFX 1090 +#define IDC_COMPRESS_EDIT_PARAMETERS 1091 + +// #define IDC_COMPRESS_SOLID 1092 +// #define IDC_COMPRESS_MULTI_THREAD 1093 + +#define IDC_STATIC_COMPRESS_ARCHIVE 1097 +#define IDC_STATIC_COMPRESS_FORMAT 1098 +#define IDC_STATIC_COMPRESS_LEVEL 1099 +#define IDC_STATIC_COMPRESS_PARAMETERS 1100 +#define IDC_STATIC_COMPRESS_UPDATE_MODE 1101 +#define IDC_STATIC_COMPRESS_OPTIONS 1102 +#define IDC_STATIC_COMPRESS_VOLUME 1103 +#define IDC_STATIC_COMPRESS_METHOD 1104 +#define IDC_STATIC_COMPRESS_DICTIONARY 1105 +#define IDC_STATIC_COMPRESS_ORDER 1106 + +#define IDC_STATIC_COMPRESS_SOLID 1107 +#define IDC_STATIC_COMPRESS_THREADS 1108 + +#define IDC_COMPRESS_ENCRYPTION 1110 +#define IDC_STATIC_COMPRESS_PASSWORD1 1111 +#define IDC_COMPRESS_EDIT_PASSWORD1 1112 +#define IDC_STATIC_COMPRESS_PASSWORD2 1113 +#define IDC_COMPRESS_EDIT_PASSWORD2 1114 +#define IDC_COMPRESS_CHECK_SHOW_PASSWORD 1115 + +#define IDC_STATIC_COMPRESS_ENCRYPTION_METHOD 1120 +#define IDC_COMPRESS_COMBO_ENCRYPTION_METHOD 1121 + +#define IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES 1122 + +#define IDC_COMPRESS_SHARED 1130 diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog_rc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog_rc.cpp new file mode 100644 index 000000000..b69ab8daf --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/CompressDialog_rc.cpp @@ -0,0 +1,283 @@ +// CompressDialog.cpp + +#include "StdAfx.h" + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWidgets headers) +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include "resource.h" +#include "Windows/Control/DialogImpl.h" + +#include "CompressDialogRes.h" + +class CCompressDialogImpl : public NWindows::NControl::CModalDialogImpl +{ + public: + CCompressDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent , int id) : CModalDialogImpl(dialog,parent, id, wxT("Add to Archive")) + { + wxStaticText *m_pStaticTextMemoryCompress; + wxStaticText *m_pStaticTextMemoryDecompress; + wxTextCtrl *m_pTextCtrlPassword; + wxTextCtrl *m_pTextCtrlRePassword; + wxTextCtrl *m_pTextCtrlParameters; + wxComboBox *m_pComboBoxArchiveName; + wxComboBox *m_pComboBoxArchiveFormat; + wxComboBox *m_pComboBoxCompressionLevel; + wxComboBox *m_pComboBoxCompressionMethod; + wxComboBox *m_pComboBoxDictionarySize; + wxComboBox *m_pComboBoxWordSize; + wxComboBox *m_pComboBoxUpdateMode; + wxComboBox *m_pComboBoxEncryptionMethod; + wxComboBox *m_pComboBoxSplitToVolumes; + wxCheckBox *m_pCheckBoxShowPassword; + wxCheckBox *m_pCheckBoxEncryptFileNames; + wxButton *m_pButtonBrowse; + + + ///Sizer for adding the controls created by users + wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL); + + wxStaticText *pStaticTextArchive = new wxStaticText(this, IDC_STATIC_COMPRESS_ARCHIVE, wxT("&Archive:")); + wxBoxSizer *pArchiveNameSizer = new wxBoxSizer(wxHORIZONTAL); + m_pComboBoxArchiveName = new wxComboBox(this, IDC_COMPRESS_COMBO_ARCHIVE, wxEmptyString, wxDefaultPosition, wxSize(600,-1), wxArrayString(), wxCB_DROPDOWN|wxCB_SORT); + m_pButtonBrowse = new wxButton(this, IDC_COMPRESS_BUTTON_SET_ARCHIVE, wxT("..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); + pArchiveNameSizer->Add(m_pComboBoxArchiveName, 1, wxALL|wxEXPAND, 5); + pArchiveNameSizer->Add(m_pButtonBrowse, 0, wxALL|wxEXPAND, 5); + wxBoxSizer *pControlSizer = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *pLeftSizer = new wxBoxSizer(wxVERTICAL); + + wxBoxSizer *pCompressionOptionsSizer = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *pCompressionStaticSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *pCompressionComboSizer = new wxBoxSizer(wxVERTICAL); + + wxStaticText *pStaticTextArchiveFormat = new wxStaticText(this, IDC_STATIC_COMPRESS_FORMAT, wxT("Archive &format:")); + /* + wxArrayString archiveFormatArray; + archiveFormatArray.Add(wxT("7z")); + archiveFormatArray.Add(wxT("Tar")); + archiveFormatArray.Add(wxT("Zip")); + m_pComboBoxArchiveFormat = new wxComboBox(this, IDC_COMPRESS_COMBO_FORMAT, archiveFormatArray.Item(0), wxDefaultPosition, wxDefaultSize, archiveFormatArray, wxCB_READONLY); + */ + + m_pComboBoxArchiveFormat = new wxComboBox(this, IDC_COMPRESS_COMBO_FORMAT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY); + + wxStaticText *pStaticTextCompressionLevel = new wxStaticText(this, IDC_STATIC_COMPRESS_LEVEL, wxT("Compression &level:")); + wxArrayString compressionLevelArray; + /* + compressionLevelArray.Add(wxT("Store")); + compressionLevelArray.Add(wxT("Fastest")); + compressionLevelArray.Add(wxT("Fast")); + compressionLevelArray.Add(wxT("Normal")); + compressionLevelArray.Add(wxT("Maximum")); + compressionLevelArray.Add(wxT("Ultra")); + m_pComboBoxCompressionLevel = new wxComboBox(this, IDC_COMPRESS_COMBO_LEVEL, compressionLevelArray.Item(0), wxDefaultPosition, wxDefaultSize, compressionLevelArray, wxCB_READONLY); + */ + m_pComboBoxCompressionLevel = new wxComboBox(this, IDC_COMPRESS_COMBO_LEVEL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY); + + wxStaticText *pStaticTextCompressionMethod = new wxStaticText(this, IDC_STATIC_COMPRESS_METHOD, wxT("Compression &method:")); +/* + wxArrayString compressionMethodArray; + compressionMethodArray.Add(wxT("LZMA")); + compressionMethodArray.Add(wxT("PPMd")); + compressionMethodArray.Add(wxT("BZip2")); + m_pComboBoxCompressionMethod = new wxComboBox(this, IDC_COMPRESS_COMBO_METHOD, compressionMethodArray.Item(0), wxDefaultPosition, wxDefaultSize, compressionMethodArray, wxCB_READONLY); +*/ + m_pComboBoxCompressionMethod = new wxComboBox(this, IDC_COMPRESS_COMBO_METHOD, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY); + + wxStaticText *pStaticTextDictionarySize = new wxStaticText(this, IDC_STATIC_COMPRESS_DICTIONARY, wxT("&Dictionary size:")); +/* + wxArrayString dictionarySizeArray; + dictionarySizeArray.Add(wxT("64 KB")); + dictionarySizeArray.Add(wxT("1 MB")); + dictionarySizeArray.Add(wxT("1 MB")); + dictionarySizeArray.Add(wxT("2 MB")); + dictionarySizeArray.Add(wxT("3 MB")); + dictionarySizeArray.Add(wxT("4 MB")); + dictionarySizeArray.Add(wxT("6 MB")); + dictionarySizeArray.Add(wxT("8 MB")); + dictionarySizeArray.Add(wxT("12 MB")); + dictionarySizeArray.Add(wxT("16 MB")); + dictionarySizeArray.Add(wxT("24 MB")); + dictionarySizeArray.Add(wxT("32 MB")); + dictionarySizeArray.Add(wxT("48 MB")); + dictionarySizeArray.Add(wxT("64 MB")); + dictionarySizeArray.Add(wxT("96 MB")); + dictionarySizeArray.Add(wxT("128 MB")); + m_pComboBoxDictionarySize = new wxComboBox(this, IDC_COMPRESS_COMBO_DICTIONARY, dictionarySizeArray.Item(0), wxDefaultPosition, wxDefaultSize, dictionarySizeArray, wxCB_READONLY); +*/ + m_pComboBoxDictionarySize = new wxComboBox(this, IDC_COMPRESS_COMBO_DICTIONARY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY); + + wxStaticText *pStaticTextNumberOfThreads = new wxStaticText(this, IDC_STATIC_COMPRESS_THREADS, wxT("&Number of CPU threads:")); +/* + wxArrayString numberOfThreadsArray; + numberOfThreadsArray.Add(wxT("1")); + numberOfThreadsArray.Add(wxT("2")); + wxComboBox *m_pComboBoxNumberOfThreads = new wxComboBox(this, IDC_COMPRESS_COMBO_THREADS, numberOfThreadsArray.Item(0), wxDefaultPosition, wxDefaultSize, numberOfThreadsArray, wxCB_READONLY); +*/ + wxComboBox *m_pComboBoxNumberOfThreads = new wxComboBox(this, IDC_COMPRESS_COMBO_THREADS, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY); + + + + + + + wxStaticText *pStaticTextWordSize = new wxStaticText(this, IDC_STATIC_COMPRESS_ORDER, wxT("&Word size:")); +/* + wxArrayString wordSizeArray; + wordSizeArray.Add(wxT("8")); + wordSizeArray.Add(wxT("12")); + wordSizeArray.Add(wxT("16")); + wordSizeArray.Add(wxT("24")); + wordSizeArray.Add(wxT("32")); + wordSizeArray.Add(wxT("48")); + wordSizeArray.Add(wxT("64")); + wordSizeArray.Add(wxT("96")); + wordSizeArray.Add(wxT("128")); + wordSizeArray.Add(wxT("192")); + wordSizeArray.Add(wxT("256")); + wordSizeArray.Add(wxT("273")); + m_pComboBoxWordSize = new wxComboBox(this, IDC_COMPRESS_COMBO_ORDER, wordSizeArray.Item(0), wxDefaultPosition, wxDefaultSize, wordSizeArray, wxCB_READONLY); +*/ + m_pComboBoxWordSize = new wxComboBox(this, IDC_COMPRESS_COMBO_ORDER, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY); + + + wxStaticText *pStaticTextBlockSize = new wxStaticText(this, IDC_STATIC_COMPRESS_SOLID, wxT("&Solid Block size:")); + + wxComboBox *m_pComboBoxBlockSize = new wxComboBox(this, IDC_COMPRESS_COMBO_SOLID, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY); + + pCompressionStaticSizer->Add(pStaticTextArchiveFormat, 1, wxALL|wxEXPAND, 5); + pCompressionStaticSizer->Add(pStaticTextCompressionLevel, 1, wxALL|wxEXPAND, 5); + pCompressionStaticSizer->Add(pStaticTextCompressionMethod, 1, wxALL|wxEXPAND, 5); + pCompressionStaticSizer->Add(pStaticTextDictionarySize, 1, wxALL|wxEXPAND, 5); + pCompressionStaticSizer->Add(pStaticTextWordSize, 1, wxALL|wxEXPAND, 5); + pCompressionStaticSizer->Add(pStaticTextBlockSize, 1, wxALL|wxEXPAND, 5); + pCompressionStaticSizer->Add(pStaticTextNumberOfThreads, 1, wxALL|wxEXPAND, 5); + pCompressionComboSizer->Add(m_pComboBoxArchiveFormat, 1, wxALL|wxEXPAND, 5); + pCompressionComboSizer->Add(m_pComboBoxCompressionLevel, 1, wxALL|wxEXPAND, 5); + pCompressionComboSizer->Add(m_pComboBoxCompressionMethod, 1, wxALL|wxEXPAND, 5); + pCompressionComboSizer->Add(m_pComboBoxDictionarySize, 1, wxALL|wxEXPAND, 5); + pCompressionComboSizer->Add(m_pComboBoxWordSize, 1, wxALL|wxEXPAND, 5); + pCompressionComboSizer->Add(m_pComboBoxBlockSize, 1, wxALL|wxEXPAND, 5); + pCompressionComboSizer->Add(m_pComboBoxNumberOfThreads, 1, wxALL|wxEXPAND, 5); + pCompressionOptionsSizer->Add(pCompressionStaticSizer, 1, wxALL|wxEXPAND, 0); + pCompressionOptionsSizer->Add(pCompressionComboSizer, 1, wxALL|wxEXPAND, 0); + + wxBoxSizer *pMemoryUsageSizer = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *pMemoryUsageLabelSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *pMemoryUsageInfoSizer = new wxBoxSizer(wxVERTICAL); + wxStaticText *pStaticTextCompressMemoryUsage = new wxStaticText(this, IDC_STATIC_COMPRESS_MEMORY, wxT("Memory usage for Compressing:")); + m_pStaticTextMemoryCompress = new wxStaticText(this, IDC_STATIC_COMPRESS_MEMORY_VALUE, wxT("709 MB"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); + wxStaticText *pStaticTextDecompressMemoryUsage = new wxStaticText(this, IDC_STATIC_COMPRESS_MEMORY_DE, wxT("Memory usage for Decompressing")); + m_pStaticTextMemoryDecompress = new wxStaticText(this, IDC_STATIC_COMPRESS_MEMORY_DE_VALUE, wxT("66 MB"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); + pMemoryUsageLabelSizer->Add(pStaticTextCompressMemoryUsage, 1, wxALL|wxEXPAND, 5); + pMemoryUsageLabelSizer->Add(pStaticTextDecompressMemoryUsage, 1, wxALL|wxEXPAND, 5); + pMemoryUsageInfoSizer->Add(m_pStaticTextMemoryCompress, 1, wxALL|wxEXPAND, 5); + pMemoryUsageInfoSizer->Add(m_pStaticTextMemoryDecompress, 1, wxALL|wxEXPAND, 5); + pMemoryUsageSizer->Add(pMemoryUsageLabelSizer, 1, wxALL|wxEXPAND, 0); + pMemoryUsageSizer->Add(pMemoryUsageInfoSizer, 0, wxALL|wxEXPAND, 0); + + wxStaticText *pStaticSplit2Volumes = new wxStaticText(this, IDC_STATIC_COMPRESS_VOLUME, wxT("Split to &volumes, bytes:")); +/* + wxArrayString split2VolumesArray; + split2VolumesArray.Add(wxT("1457664 - 3.5\" floppy")); + split2VolumesArray.Add(wxT("650M - CD")); + split2VolumesArray.Add(wxT("700M - CD")); + split2VolumesArray.Add(wxT("4480M - DVD")); + m_pComboBoxSplitToVolumes = new wxComboBox(this, IDC_COMPRESS_COMBO_VOLUME, wxEmptyString, wxDefaultPosition, wxDefaultSize, split2VolumesArray, wxCB_DROPDOWN); +*/ + m_pComboBoxSplitToVolumes = new wxComboBox(this, IDC_COMPRESS_COMBO_VOLUME, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_DROPDOWN); + + pLeftSizer->Add(pCompressionOptionsSizer, 0, wxALL|wxEXPAND, 0); + pLeftSizer->Add(pMemoryUsageSizer, 1, wxALL|wxEXPAND, 0); + pLeftSizer->Add(pStaticSplit2Volumes, 0, wxALL|wxEXPAND, 5); + pLeftSizer->Add(m_pComboBoxSplitToVolumes, 0, wxALL|wxEXPAND, 5); + + wxBoxSizer *pRightSizer = new wxBoxSizer(wxVERTICAL); + wxStaticText *pStaticTextUpdateMode = new wxStaticText(this, IDC_STATIC_COMPRESS_UPDATE_MODE, wxT("&Update mode:")); +/* + wxArrayString updateModeArray; + updateModeArray.Add(wxT("Add and replace files")); + updateModeArray.Add(wxT("Update and add files")); + updateModeArray.Add(wxT("Freshen existing files")); + updateModeArray.Add(wxT("Synchronize files")); + m_pComboBoxUpdateMode = new wxComboBox(this, IDC_COMPRESS_COMBO_UPDATE_MODE, updateModeArray.Item(0), wxDefaultPosition, wxDefaultSize, updateModeArray, wxCB_READONLY); +*/ + m_pComboBoxUpdateMode = new wxComboBox(this, IDC_COMPRESS_COMBO_UPDATE_MODE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY); + + wxStaticBoxSizer *pOptionsSizer = new wxStaticBoxSizer(new wxStaticBox(this,IDC_STATIC_COMPRESS_OPTIONS,_T("Options")),wxVERTICAL); + wxCheckBox *m_pCheckBoxSFXArchive = new wxCheckBox(this, IDC_COMPRESS_SFX, wxT("Create SF&X archive")); + pOptionsSizer->Add(m_pCheckBoxSFXArchive, 1, wxALL|wxEXPAND, 5); + wxCheckBox *m_pCheckBoxCompressSharedFiles = new wxCheckBox(this, IDC_COMPRESS_SHARED, wxT("Compress shared files")); + m_pCheckBoxCompressSharedFiles->Show(false); // this option is useless undex Unix ... + pOptionsSizer->Add(m_pCheckBoxCompressSharedFiles, 1, wxALL|wxEXPAND, 5); + + wxStaticBoxSizer * pEncryptSizer = new wxStaticBoxSizer(new wxStaticBox(this,IDC_COMPRESS_ENCRYPTION,_T("Encryption")),wxVERTICAL); + wxStaticText *pStaticTextPassword = new wxStaticText(this, IDC_STATIC_COMPRESS_PASSWORD1, wxT("Enter password:")); + m_pTextCtrlPassword = new wxTextCtrl(this, IDC_COMPRESS_EDIT_PASSWORD1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD); + wxStaticText *pStaticTextRePassword = new wxStaticText(this, IDC_STATIC_COMPRESS_PASSWORD2, wxT("Re-enter password:")); + m_pTextCtrlRePassword = new wxTextCtrl(this, IDC_COMPRESS_EDIT_PASSWORD2, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD); + m_pCheckBoxShowPassword = new wxCheckBox(this, IDC_COMPRESS_CHECK_SHOW_PASSWORD, wxT("Show Password")); + wxBoxSizer *pEncryptionMethodSizer = new wxBoxSizer(wxHORIZONTAL); + wxStaticText *pStaticTextEncryptionMethod = new wxStaticText(this, IDC_STATIC_COMPRESS_ENCRYPTION_METHOD, wxT("&Encryption method:")); +/* + wxArrayString encryptionMethodArray; + encryptionMethodArray.Add(wxT("AES-256")); + m_pComboBoxEncryptionMethod =new wxComboBox(this, IDC_COMPRESS_COMBO_ENCRYPTION_METHOD, encryptionMethodArray.Item(0), wxDefaultPosition, wxDefaultSize, encryptionMethodArray, wxCB_READONLY); +*/ + m_pComboBoxEncryptionMethod =new wxComboBox(this, IDC_COMPRESS_COMBO_ENCRYPTION_METHOD, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxArrayString(), wxCB_READONLY); + + pEncryptionMethodSizer->Add(pStaticTextEncryptionMethod, 1, wxALL|wxEXPAND, 5); + pEncryptionMethodSizer->Add(m_pComboBoxEncryptionMethod, 1, wxALL|wxEXPAND, 5); + m_pCheckBoxEncryptFileNames = new wxCheckBox(this, IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, wxT("Encrypt file &names")); + pEncryptSizer->Add(pStaticTextPassword, 0, wxALL|wxEXPAND, 5); + pEncryptSizer->Add(m_pTextCtrlPassword, 0, wxLEFT|wxRIGHT|wxEXPAND, 5); + pEncryptSizer->Add(pStaticTextRePassword, 0, wxALL|wxEXPAND, 5); + pEncryptSizer->Add(m_pTextCtrlRePassword, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 5); + pEncryptSizer->Add(m_pCheckBoxShowPassword, 0, wxALL|wxEXPAND, 5); + pEncryptSizer->Add(pEncryptionMethodSizer, 0, wxLEFT|wxRIGHT|wxEXPAND, 0); + pEncryptSizer->Add(m_pCheckBoxEncryptFileNames, 0, wxALL|wxEXPAND, 5); + + pRightSizer->Add(pStaticTextUpdateMode, 0, wxALL|wxEXPAND, 5); + pRightSizer->Add(m_pComboBoxUpdateMode, 0, wxALL|wxEXPAND, 5); + pRightSizer->Add(pOptionsSizer, 1, wxALL|wxEXPAND, 5); + pRightSizer->Add(pEncryptSizer, 0, wxALL|wxEXPAND, 5); + + pControlSizer->Add(pLeftSizer, 1, wxALL|wxEXPAND, 5); + pControlSizer->Add(pRightSizer, 1, wxALL|wxEXPAND, 5); + wxStaticText *pStaticTextParameters = new wxStaticText(this, IDC_STATIC_COMPRESS_PARAMETERS, wxT("&Parameters:")); + m_pTextCtrlParameters = new wxTextCtrl(this, IDC_COMPRESS_EDIT_PARAMETERS, wxEmptyString); + topsizer->Add(pStaticTextArchive, 0, wxLEFT | wxRIGHT | wxTOP |wxEXPAND, 10); + topsizer->Add(pArchiveNameSizer, 1, wxLEFT | wxRIGHT |wxEXPAND, 5); + topsizer->Add(pControlSizer, 0, wxALL|wxEXPAND, 5); + topsizer->Add(pStaticTextParameters, 0, wxLEFT | wxRIGHT | wxBOTTOM |wxEXPAND, 10); + topsizer->Add(m_pTextCtrlParameters, 0, wxLEFT | wxRIGHT |wxEXPAND, 10); + topsizer->Add(CreateButtonSizer(wxOK | wxCANCEL | wxHELP), 0, wxALL|wxEXPAND, 10); + + this->OnInit(); + + SetSizer(topsizer); // use the sizer for layout + topsizer->SetSizeHints(this); // set size hints to honour minimum size + } +private: + // Any class wishing to process wxWindows events must use this macro + DECLARE_EVENT_TABLE() +}; + +REGISTER_DIALOG(IDD_DIALOG_COMPRESS,CCompressDialog,0) + +BEGIN_EVENT_TABLE(CCompressDialogImpl, wxDialog) + EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton) + EVT_CHECKBOX(wxID_ANY, CModalDialogImpl::OnAnyButton) + EVT_COMBOBOX(wxID_ANY, CModalDialogImpl::OnAnyChoice) +END_EVENT_TABLE() + diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog.cpp new file mode 100644 index 000000000..6b3887006 --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog.cpp @@ -0,0 +1,374 @@ +// ExtractDialog.cpp + +#include "StdAfx.h" + +// #include <HtmlHelp.h> + +#include "ExtractDialog.h" + +#include "Common/StringConvert.h" +#include "Windows/Shell.h" +#include "Windows/FileName.h" +#include "Windows/FileDir.h" +#include "Windows/ResourceString.h" + +#ifndef NO_REGISTRY +#include "../FileManager/HelpUtils.h" +#endif + +#include "../Common/ZipRegistry.h" + +#include "../FileManager/LangUtils.h" + +#include "ExtractRes.h" +#include "ExtractDialogRes.h" + +// #include "Help/Context/Extract.h" + +using namespace NWindows; +using namespace NFile; +using namespace NName; + +static const int kPathModeButtons[] = +{ + IDC_EXTRACT_RADIO_FULL_PATHNAMES, + IDC_EXTRACT_RADIO_CURRENT_PATHNAMES, + IDC_EXTRACT_RADIO_NO_PATHNAMES +}; + +#ifndef _SFX + +static const NExtract::NPathMode::EEnum kPathModeButtonsVals[] = +{ + NExtract::NPathMode::kFullPathnames, + NExtract::NPathMode::kCurrentPathnames, + NExtract::NPathMode::kNoPathnames +}; + +static const int kNumPathnamesButtons = sizeof(kPathModeButtons) / sizeof(kPathModeButtons[0]); + +static const int kOverwriteButtons[] = +{ + IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE, + IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT, + IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES, + IDC_EXTRACT_RADIO_AUTO_RENAME, + IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING, +}; + +static const NExtract::NOverwriteMode::EEnum kOverwriteButtonsVals[] = +{ + NExtract::NOverwriteMode::kAskBefore, + NExtract::NOverwriteMode::kWithoutPrompt, + NExtract::NOverwriteMode::kSkipExisting, + NExtract::NOverwriteMode::kAutoRename, + NExtract::NOverwriteMode::kAutoRenameExisting +}; + +static const int kNumOverwriteButtons = sizeof(kOverwriteButtons) / sizeof(kOverwriteButtons[0]); + +/* +static const int kFilesButtons[] = +{ + IDC_EXTRACT_RADIO_SELECTED_FILES, + IDC_EXTRACT_RADIO_ALL_FILES +}; +static const int kNumFilesButtons = sizeof(kFilesButtons) / sizeof(kFilesButtons[0]); +*/ + +void CExtractDialog::GetPathMode() +{ + for (int i = 0; i < kNumPathnamesButtons; i++) + if(IsButtonCheckedBool(kPathModeButtons[i])) + { + PathMode = kPathModeButtonsVals[i]; + return; + } + throw 1; +} + +void CExtractDialog::SetPathMode() +{ + for (int j = 0; j < 2; j++) + { + for (int i = 0; i < kNumPathnamesButtons; i++) + if(PathMode == kPathModeButtonsVals[i]) + { + CheckRadioButton(kPathModeButtons[0], kPathModeButtons[kNumPathnamesButtons - 1], + kPathModeButtons[i]); + return; + } + PathMode = kPathModeButtonsVals[0]; + } + throw 1; +} + +void CExtractDialog::GetOverwriteMode() +{ + for (int i = 0; i < kNumOverwriteButtons; i++) + if(IsButtonCheckedBool(kOverwriteButtons[i])) + { + OverwriteMode = kOverwriteButtonsVals[i]; + return; + } + throw 0; +} + +void CExtractDialog::SetOverwriteMode() +{ + for (int j = 0; j < 2; j++) + { + for (int i = 0; i < kNumOverwriteButtons; i++) + if(OverwriteMode == kOverwriteButtonsVals[i]) + { + CheckRadioButton(kOverwriteButtons[0], kOverwriteButtons[kNumOverwriteButtons - 1], + kOverwriteButtons[i]); + return; + } + OverwriteMode = kOverwriteButtonsVals[0]; + } + throw 1; +} + +/* +int CExtractDialog::GetFilesMode() const +{ + for (int i = 0; i < kNumFilesButtons; i++) + if(IsButtonCheckedBool(kFilesButtons[i])) + return i; + throw 0; +} +*/ + +#endif + +#ifdef LANG +static CIDLangPair kIDLangPairs[] = +{ + { IDC_STATIC_EXTRACT_EXTRACT_TO, 0x02000801 }, + { IDC_EXTRACT_PATH_MODE, 0x02000810 }, + { IDC_EXTRACT_RADIO_FULL_PATHNAMES, 0x02000811 }, + { IDC_EXTRACT_RADIO_CURRENT_PATHNAMES, 0x02000812 }, + { IDC_EXTRACT_RADIO_NO_PATHNAMES, 0x02000813 }, + { IDC_EXTRACT_OVERWRITE_MODE, 0x02000820 }, + { IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE, 0x02000821 }, + { IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT, 0x02000822 }, + { IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES, 0x02000823 }, + { IDC_EXTRACT_RADIO_AUTO_RENAME, 0x02000824 }, + { IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING, 0x02000825 }, + { IDC_EXTRACT_FILES, 0x02000830 }, + { IDC_EXTRACT_RADIO_SELECTED_FILES, 0x02000831 }, + { IDC_EXTRACT_RADIO_ALL_FILES, 0x02000832 }, + { IDC_EXTRACT_PASSWORD, 0x02000802 }, + { IDC_EXTRACT_CHECK_SHOW_PASSWORD, 0x02000B02 }, + { IDOK, 0x02000702 }, + { IDCANCEL, 0x02000710 }, + { IDHELP, 0x02000720 } + +}; +#endif + +// static const int kWildcardsButtonIndex = 2; + +#ifndef NO_REGISTRY +static const int kHistorySize = 8; +#endif + +bool CExtractDialog::OnInit() +{ + #ifdef LANG + LangSetWindowText(HWND(*this), 0x02000800); + LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + #endif + #ifndef _SFX + _passwordControl.Attach(GetItem(IDC_EXTRACT_EDIT_PASSWORD)); + _passwordControl.SetText(Password); + _passwordControl.SetPasswordChar(TEXT('*')); + #endif + + NExtract::CInfo extractionInfo; + + #ifdef NO_REGISTRY + PathMode = NExtract::NPathMode::kFullPathnames; + OverwriteMode = NExtract::NOverwriteMode::kAskBefore; + // extractionInfo.Paths = NExtract::NPathMode::kFullPathnames; + #else + ReadExtractionInfo(extractionInfo); + CheckButton(IDC_EXTRACT_CHECK_SHOW_PASSWORD, extractionInfo.ShowPassword); + UpdatePasswordControl(); + PathMode = extractionInfo.PathMode; + OverwriteMode = extractionInfo.OverwriteMode; + #endif + + _path.Attach(GetItem(IDC_EXTRACT_COMBO_PATH)); + + _path.SetText(DirectoryPath); + + #ifndef NO_REGISTRY + for(int i = 0; i < extractionInfo.Paths.Size() && i < kHistorySize; i++) + _path.AddString(extractionInfo.Paths[i]); + #endif + + /* + if(extractionInfo.Paths.Size() > 0) + _path.SetCurSel(0); + else + _path.SetCurSel(-1); + */ + + + + #ifndef _SFX + SetPathMode(); + SetOverwriteMode(); + + /* + CheckRadioButton(kFilesButtons[0], kFilesButtons[kNumFilesButtons - 1], + kFilesButtons[_filesMode]); + */ + + // CWindow selectedFilesWindow = GetItem(IDC_EXTRACT_RADIO_SELECTED_FILES); + // selectedFilesWindow.Enable(_enableSelectedFilesButton); + + + #endif + + + // CWindow filesWindow = GetItem(IDC_EXTRACT_RADIO_FILES); + // filesWindow.Enable(_enableFilesButton); + + // UpdateWildCardState(); + return CModalDialog::OnInit(); +} + +#ifndef _SFX +void CExtractDialog::UpdatePasswordControl() +{ + _passwordControl.SetPasswordChar((IsButtonChecked( + IDC_EXTRACT_CHECK_SHOW_PASSWORD) == BST_CHECKED) ? 0: TEXT('*')); + UString password; + _passwordControl.GetText(password); + _passwordControl.SetText(password); +} +#endif + +bool CExtractDialog::OnButtonClicked(int buttonID, HWND buttonHWND) +{ + /* + for (int i = 0; i < kNumFilesButtons; i++) + if (buttonID == kFilesButtons[i]) + { + UpdateWildCardState(); + return true; + } + */ + switch(buttonID) + { + case IDC_EXTRACT_BUTTON_SET_PATH: + OnButtonSetPath(); + return true; + #ifndef _SFX + case IDC_EXTRACT_CHECK_SHOW_PASSWORD: + { + UpdatePasswordControl(); + return true; + } + #endif + } + return CModalDialog::OnButtonClicked(buttonID, buttonHWND); +} + +void CExtractDialog::OnButtonSetPath() +{ + UString currentPath; + _path.GetText(currentPath); + UString title = LangStringSpec(IDS_EXTRACT_SET_FOLDER, 0x02000881); + UString resultPath; + if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath)) + return; + #ifndef NO_REGISTRY + _path.SetCurSel(-1); + #endif + _path.SetText(resultPath); +} + +void AddUniqueString(UStringVector &list, const UString &s) +{ + for(int i = 0; i < list.Size(); i++) + if (s.CompareNoCase(list[i]) == 0) + return; + list.Add(s); +} + +void CExtractDialog::OnOK() +{ + #ifndef _SFX + GetPathMode(); + GetOverwriteMode(); + // _filesMode = (NExtractionDialog::NFilesMode::EEnum)GetFilesMode(); + + _passwordControl.GetText(Password); + #endif + + NExtract::CInfo extractionInfo; + extractionInfo.PathMode = PathMode; + extractionInfo.OverwriteMode = OverwriteMode; + extractionInfo.ShowPassword = (IsButtonChecked( + IDC_EXTRACT_CHECK_SHOW_PASSWORD) == BST_CHECKED); + + UString s; + + #ifdef NO_REGISTRY + + _path.GetText(s); + + #else + + int currentItem = _path.GetCurSel(); + if(currentItem == CB_ERR) + { + _path.GetText(s); + if(_path.GetCount() >= kHistorySize) + currentItem = _path.GetCount() - 1; + } + else + _path.GetLBText(currentItem, s); + + #endif + + s.Trim(); + #ifndef _SFX + AddUniqueString(extractionInfo.Paths, s); + #endif + DirectoryPath = s; + #ifndef NO_REGISTRY + for(int i = 0; i < _path.GetCount(); i++) + if(i != currentItem) + { + UString sTemp; + _path.GetLBText(i, sTemp); + sTemp.Trim(); + AddUniqueString(extractionInfo.Paths, sTemp); + } + SaveExtractionInfo(extractionInfo); + #endif + CModalDialog::OnOK(); +} + +/* +void CExtractDialog::UpdateWildCardState() +{ + // UpdateData(TRUE); + // m_Wildcards.EnableWindow(BoolToBOOL(m_Files == kWildcardsButtonIndex)); +} +*/ + +#ifndef NO_REGISTRY +static LPCWSTR kHelpTopic = L"fm/plugins/7-zip/extract.htm"; +void CExtractDialog::OnHelp() +{ + ShowHelpWindow(NULL, kHelpTopic); + CModalDialog::OnHelp(); +} +#endif + diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog.h new file mode 100644 index 000000000..6ac82f740 --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog.h @@ -0,0 +1,77 @@ +// ExtractDialog.h + +#ifndef __EXTRACTDIALOG_H +#define __EXTRACTDIALOG_H + +#include "ExtractDialogRes.h" + +#include "Windows/Control/Dialog.h" +#include "Windows/Control/Edit.h" +#include "Windows/Control/ComboBox.h" + +#ifndef NO_REGISTRY +#include "../Common/ZipRegistry.h" +#endif +#include "../Common/ExtractMode.h" + +namespace NExtractionDialog +{ + /* + namespace NFilesMode + { + enum EEnum + { + kSelected, + kAll, + kSpecified + }; + } + */ +} + +class CExtractDialog: public NWindows::NControl::CModalDialog +{ + #ifdef NO_REGISTRY + NWindows::NControl::CDialogChildControl _path; + #else + NWindows::NControl::CComboBox _path; + #endif + + #ifndef _SFX + NWindows::NControl::CEdit _passwordControl; + #endif + + #ifndef _SFX + void GetPathMode(); + void SetPathMode(); + void GetOverwriteMode(); + void SetOverwriteMode(); + // int GetFilesMode() const; + void UpdatePasswordControl(); + #endif + + void OnButtonSetPath(); + + virtual bool OnInit(); + virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); + virtual void OnOK(); + #ifndef NO_REGISTRY + virtual void OnHelp(); + #endif +public: + // bool _enableSelectedFilesButton; + // bool _enableFilesButton; + // NExtractionDialog::NFilesMode::EEnum FilesMode; + + UString DirectoryPath; + #ifndef _SFX + UString Password; + #endif + NExtract::NPathMode::EEnum PathMode; + NExtract::NOverwriteMode::EEnum OverwriteMode; + + INT_PTR Create(HWND aWndParent = 0) + { return CModalDialog::Create(IDD_DIALOG_EXTRACT, aWndParent); } +}; + +#endif diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialogRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialogRes.h new file mode 100644 index 000000000..bc45ed239 --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialogRes.h @@ -0,0 +1,28 @@ +#define IDD_DIALOG_EXTRACT 137 + +#define IDC_STATIC_EXTRACT_EXTRACT_TO 1020 +#define IDC_EXTRACT_COMBO_PATH 1021 +#define IDC_EXTRACT_BUTTON_SET_PATH 1022 + + +#define IDC_EXTRACT_PATH_MODE 1040 +#define IDC_EXTRACT_RADIO_FULL_PATHNAMES 1041 +#define IDC_EXTRACT_RADIO_CURRENT_PATHNAMES 1042 +#define IDC_EXTRACT_RADIO_NO_PATHNAMES 1043 + +#define IDC_EXTRACT_OVERWRITE_MODE 1050 +#define IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE 1051 +#define IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT 1052 +#define IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES 1053 +#define IDC_EXTRACT_RADIO_SELECTED_FILES 1054 +#define IDC_EXTRACT_RADIO_ALL_FILES 1055 +#define IDC_EXTRACT_RADIO_AUTO_RENAME 1056 +#define IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING 1057 + + +#define IDC_EXTRACT_FILES 1060 + +#define IDC_EXTRACT_PASSWORD 1100 +#define IDC_EXTRACT_EDIT_PASSWORD 1101 +#define IDC_EXTRACT_CHECK_SHOW_PASSWORD 1102 + diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog_rc.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog_rc.cpp new file mode 100644 index 000000000..3e3b1c166 --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractDialog_rc.cpp @@ -0,0 +1,145 @@ +// ExtractDialog.cpp + +#include "StdAfx.h" + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWidgets headers) +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include "Windows/Control/DialogImpl.h" + +#include "ExtractRes.h" +#include "ExtractDialogRes.h" + +/* +IDD_DIALOG_EXTRACT DIALOG DISCARDABLE 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +CAPTION "Extract" +MY_FONT +BEGIN + LTEXT "E&xtract to:", IDC_STATIC_EXTRACT_EXTRACT_TO, marg, marg, xSize2, 8 + + COMBOBOX IDC_EXTRACT_COMBO_PATH, marg, 21, xSize2 - bDotsSize - 13, 126, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP + + PUSHBUTTON "...", IDC_EXTRACT_BUTTON_SET_PATH, xSize - marg - bDotsSize, 20, bDotsSize, bYSize, WS_GROUP + + GROUPBOX "Path mode",IDC_EXTRACT_PATH_MODE, marg, 44, g1XSize, 57 + CONTROL "Full pathnames", IDC_EXTRACT_RADIO_FULL_PATHNAMES,"Button", BS_AUTORADIOBUTTON | WS_GROUP, + g1XPos2, 57, g1XSize2, 10 + CONTROL "Current pathnames",IDC_EXTRACT_RADIO_CURRENT_PATHNAMES, "Button", BS_AUTORADIOBUTTON, + g1XPos2, 71, g1XSize2, 10 + CONTROL "No pathnames", IDC_EXTRACT_RADIO_NO_PATHNAMES, "Button", BS_AUTORADIOBUTTON, + g1XPos2, 85, g1XSize2, 10 + + GROUPBOX "Overwrite mode",IDC_EXTRACT_OVERWRITE_MODE, g2XPos, 44, g2XSize, 88, WS_GROUP + CONTROL "Ask before overwrite", IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE, "Button", BS_AUTORADIOBUTTON | WS_GROUP, + g2XPos2, 57, g2XSize2, 10 + CONTROL "Overwrite without prompt", IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT, "Button", BS_AUTORADIOBUTTON, + g2XPos2, 71, g2XSize2, 10 + CONTROL "Skip existing files", IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES, "Button", BS_AUTORADIOBUTTON, + g2XPos2, 85, g2XSize2, 10 + CONTROL "Auto rename", IDC_EXTRACT_RADIO_AUTO_RENAME, "Button", BS_AUTORADIOBUTTON, + g2XPos2, 99, g2XSize2, 10 + CONTROL "Auto rename existing files", IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING, "Button", BS_AUTORADIOBUTTON, + g2XPos2,113, g2XSize2, 10 + + GROUPBOX "Files",IDC_EXTRACT_FILES, marg, 140, 127, 48, NOT WS_VISIBLE | WS_DISABLED | WS_GROUP + CONTROL "&Selected files",IDC_EXTRACT_RADIO_SELECTED_FILES, "Button", BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | WS_GROUP, + g1XPos2, 153, g1XSize2, 10 + CONTROL "&All files",IDC_EXTRACT_RADIO_ALL_FILES, "Button", BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED, + g1XPos2, 166, g1XSize2, 10 + + GROUPBOX "Password",IDC_EXTRACT_PASSWORD, g2XPos, 142, g2XSize, 46 + EDITTEXT IDC_EXTRACT_EDIT_PASSWORD,154,153,130,14, ES_PASSWORD | ES_AUTOHSCROLL + CONTROL "Show Password",IDC_EXTRACT_CHECK_SHOW_PASSWORD,"Button", BS_AUTOCHECKBOX | WS_TABSTOP, + g2XPos2, 172, g2XSize2, 10 + + DEFPUSHBUTTON "OK", IDOK, bXPos3, bYPos, bXSize, bYSize, WS_GROUP + PUSHBUTTON "Cancel", IDCANCEL, bXPos2, bYPos, bXSize, bYSize + PUSHBUTTON "Help", IDHELP, bXPos1, bYPos, bXSize, bYSize +END +*/ + + +class CExtractDialogImpl : public NWindows::NControl::CModalDialogImpl +{ + public: + CExtractDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent , int id) : CModalDialogImpl(dialog,parent, id, wxT("Extract")) + { + wxStaticText *m_pStaticTextExtractTo; + wxTextCtrl *m_pTextCtrlPassword; + wxButton *m_pButtonBrowse; + wxComboBox *m_pComboBoxExtractTo; + wxCheckBox *m_pCheckBoxShowPassword; + + + ///Sizer for adding the controls created by users + wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL); + + wxArrayString pathArray; + m_pStaticTextExtractTo = new wxStaticText(this, IDC_STATIC_EXTRACT_EXTRACT_TO, wxT("E&xtract To:")); + wxBoxSizer *pPathSizer = new wxBoxSizer(wxHORIZONTAL); + m_pComboBoxExtractTo = new wxComboBox(this, IDC_EXTRACT_COMBO_PATH, wxEmptyString, wxDefaultPosition, wxDefaultSize, pathArray, wxCB_DROPDOWN|wxCB_SORT); + m_pButtonBrowse = new wxButton(this, IDC_EXTRACT_BUTTON_SET_PATH, wxT("..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); + pPathSizer->Add(m_pComboBoxExtractTo, 1, wxLEFT|wxRIGHT|wxEXPAND, 5); + pPathSizer->Add(m_pButtonBrowse, 0, wxLEFT|wxRIGHT|wxEXPAND, 5); + + wxBoxSizer *pControlSizer = new wxBoxSizer(wxHORIZONTAL); + + wxStaticBoxSizer * grpPathMode = new wxStaticBoxSizer(new wxStaticBox(this,IDC_EXTRACT_PATH_MODE,_T("Path mode")),wxVERTICAL); + grpPathMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_FULL_PATHNAMES, wxT("Full pathnames"),wxDefaultPosition, wxDefaultSize, wxRB_GROUP ) , 0 ); + grpPathMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_CURRENT_PATHNAMES, wxT("Current pathnames"),wxDefaultPosition, wxDefaultSize) , 0 ); + grpPathMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_NO_PATHNAMES, wxT("no pathnames"),wxDefaultPosition, wxDefaultSize) , 0 ); + + wxBoxSizer *pRightSizer = new wxBoxSizer(wxVERTICAL); + + wxStaticBoxSizer * grpOverWriteMode = new wxStaticBoxSizer(new wxStaticBox(this,IDC_EXTRACT_OVERWRITE_MODE,wxT("Overwrite mode")),wxVERTICAL); + grpOverWriteMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE, wxT("Ask before overwrite"),wxDefaultPosition, wxDefaultSize, wxRB_GROUP) , 1 ); + grpOverWriteMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT, wxT("Overwrite without prompt"),wxDefaultPosition, wxDefaultSize) , 1 ); + grpOverWriteMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES, wxT("Skip existing files"),wxDefaultPosition, wxDefaultSize) , 1 ); + grpOverWriteMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_AUTO_RENAME, wxT("Auto rename"),wxDefaultPosition, wxDefaultSize) , 1 ); + grpOverWriteMode->Add(new wxRadioButton(this, IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING, wxT("Auto rename existing files"),wxDefaultPosition, wxDefaultSize) , 1 ); + + wxStaticBoxSizer *pPasswordSizer = new wxStaticBoxSizer(new wxStaticBox(this,IDC_EXTRACT_PASSWORD,wxT("Password mode")),wxVERTICAL); + + m_pTextCtrlPassword = new wxTextCtrl(this, IDC_EXTRACT_EDIT_PASSWORD, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD); + m_pCheckBoxShowPassword = new wxCheckBox(this, IDC_EXTRACT_CHECK_SHOW_PASSWORD, wxT("Show Password")); + pPasswordSizer->Add(m_pTextCtrlPassword, 0, wxALL|wxEXPAND, 5); + pPasswordSizer->Add(m_pCheckBoxShowPassword, 0, wxALL|wxEXPAND, 5); + + pRightSizer->Add(grpOverWriteMode, 1, wxALL|wxEXPAND, 5); + pRightSizer->Add(pPasswordSizer, 0, wxALL|wxEXPAND, 5); + + pControlSizer->Add(grpPathMode, 1, wxALL|wxEXPAND, 5); + pControlSizer->Add(pRightSizer, 1, wxLEFT | wxRIGHT | wxEXPAND, 5); + + topsizer->Add(m_pStaticTextExtractTo, 0, wxALL | wxEXPAND , 10); + topsizer->Add(pPathSizer, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND , 5); + topsizer->Add(pControlSizer, 1, wxALL | wxEXPAND , 5); + topsizer->Add(CreateButtonSizer(wxOK | wxCANCEL | wxHELP), 0, wxALL | wxEXPAND , 5); + + this->OnInit(); + + SetSizer(topsizer); // use the sizer for layout + topsizer->SetSizeHints(this); // set size hints to honour minimum size + } +private: + // Any class wishing to process wxWindows events must use this macro + DECLARE_EVENT_TABLE() +}; + +REGISTER_DIALOG(IDD_DIALOG_EXTRACT,CExtractDialog,0) + +BEGIN_EVENT_TABLE(CExtractDialogImpl, wxDialog) + EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton) + EVT_CHECKBOX(wxID_ANY, CModalDialogImpl::OnAnyButton) +END_EVENT_TABLE() + diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractGUI.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractGUI.cpp new file mode 100644 index 000000000..2f3663b0d --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractGUI.cpp @@ -0,0 +1,230 @@ +// ExtractGUI.cpp + +#include "StdAfx.h" + +#include "Common/IntToString.h" +#include "Common/StringConvert.h" + +#include "Windows/Error.h" +#include "Windows/FileDir.h" +#include "Windows/FileFind.h" +#include "Windows/Thread.h" + +#include "../FileManager/ExtractCallback.h" +#include "../FileManager/FormatUtils.h" +#include "../FileManager/LangUtils.h" + +#include "../Common/ArchiveExtractCallback.h" +#include "../Common/PropIDUtils.h" + +#include "../Explorer/MyMessages.h" + +#include "resource.h" +#include "ExtractRes.h" +#include "ExtractDialog.h" +#include "ExtractGUI.h" + +using namespace NWindows; + +static const wchar_t *kIncorrectOutDir = L"Incorrect output directory path"; + +struct CThreadExtracting +{ + CCodecs *codecs; + CExtractCallbackImp *ExtractCallbackSpec; + CIntVector FormatIndices; + + UStringVector *ArchivePaths; + UStringVector *ArchivePathsFull; + const NWildcard::CCensorNode *WildcardCensor; + const CExtractOptions *Options; + CMyComPtr<IExtractCallbackUI> ExtractCallback; + CDecompressStat Stat; + UString ErrorMessage; + HRESULT Result; + + DWORD Process() + { + ExtractCallbackSpec->ProgressDialog.WaitCreating(); + try + { + Result = DecompressArchives( + codecs, FormatIndices, + *ArchivePaths, *ArchivePathsFull, + *WildcardCensor, *Options, ExtractCallbackSpec, ExtractCallback, ErrorMessage, Stat); + } + catch(const UString &s) + { + ErrorMessage = s; + Result = E_FAIL; + } + catch(const wchar_t *s) + { + ErrorMessage = s; + Result = E_FAIL; + } + catch(const char *s) + { + ErrorMessage = GetUnicodeString(s); + Result = E_FAIL; + } + catch(...) + { + Result = E_FAIL; + } + ExtractCallbackSpec->ProgressDialog.MyClose(); + return 0; + } + static THREAD_FUNC_DECL MyThreadFunction(void *param) + { + return ((CThreadExtracting *)param)->Process(); + } +}; + +#ifndef _SFX + +static void AddValuePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s) +{ + wchar_t sz[32]; + s += LangString(resourceID, langID); + s += L" "; + ConvertUInt64ToString(value, sz); + s += sz; + s += L"\n"; +} + +static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s) +{ + wchar_t sz[32]; + s += LangString(resourceID, langID); + s += L" "; + ConvertUInt64ToString(value, sz); + s += sz; + ConvertUInt64ToString(value >> 20, sz); + s += L" ("; + s += sz; + s += L" MB)"; + s += L"\n"; +} + +#endif + +HRESULT ExtractGUI( + CCodecs *codecs, + const CIntVector &formatIndices, + UStringVector &archivePaths, + UStringVector &archivePathsFull, + const NWildcard::CCensorNode &wildcardCensor, + CExtractOptions &options, + bool showDialog, + CExtractCallbackImp *extractCallback) +{ + CThreadExtracting extracter; + extracter.codecs = codecs; + extracter.FormatIndices = formatIndices; + + if (!options.TestMode) + { + UString outputDir = options.OutputDir; + if (outputDir.IsEmpty()) + NFile::NDirectory::MyGetCurrentDirectory(outputDir); + if (showDialog) + { + CExtractDialog dialog; + if (!NFile::NDirectory::MyGetFullPathName(outputDir, dialog.DirectoryPath)) + { + ShowErrorMessage(kIncorrectOutDir); + return E_FAIL; + } + NFile::NName::NormalizeDirPathPrefix(dialog.DirectoryPath); +#ifndef _WIN32 + { + extern const TCHAR * nameWindowToUnix(const TCHAR * lpFileName); + UString tmpDirectoryPath = dialog.DirectoryPath; + dialog.DirectoryPath = nameWindowToUnix(tmpDirectoryPath); + } +#endif + + + // dialog.OverwriteMode = options.OverwriteMode; + // dialog.PathMode = options.PathMode; + + if(dialog.Create(0) != IDOK) + return E_ABORT; + outputDir = dialog.DirectoryPath; + options.OverwriteMode = dialog.OverwriteMode; + options.PathMode = dialog.PathMode; + #ifndef _SFX + extractCallback->Password = dialog.Password; + extractCallback->PasswordIsDefined = !dialog.Password.IsEmpty(); + #endif + } + if (!NFile::NDirectory::MyGetFullPathName(outputDir, options.OutputDir)) + { + ShowErrorMessage(kIncorrectOutDir); + return E_FAIL; + } + NFile::NName::NormalizeDirPathPrefix(options.OutputDir); + + /* + if(!NFile::NDirectory::CreateComplexDirectory(options.OutputDir)) + { + UString s = GetUnicodeString(NError::MyFormatMessage(GetLastError())); + UString s2 = MyFormatNew(IDS_CANNOT_CREATE_FOLDER, + #ifdef LANG + 0x02000603, + #endif + options.OutputDir); + MyMessageBox(s2 + UString(L"\n") + s); + return E_FAIL; + } + */ + } + + UString title = LangStringSpec(options.TestMode ? IDS_PROGRESS_TESTING : IDS_PROGRESS_EXTRACTING, + options.TestMode ? 0x02000F90: 0x02000890); + + extracter.ExtractCallbackSpec = extractCallback; + extracter.ExtractCallback = extractCallback; + extracter.ExtractCallbackSpec->Init(); + + extracter.ArchivePaths = &archivePaths; + extracter.ArchivePathsFull = &archivePathsFull; + extracter.WildcardCensor = &wildcardCensor; + extracter.Options = &options; + + NWindows::CThread thread; + RINOK(thread.Create(CThreadExtracting::MyThreadFunction, &extracter)); + extracter.ExtractCallbackSpec->StartProgressDialog(title); + if (extracter.Result == S_OK && options.TestMode && + extracter.ExtractCallbackSpec->Messages.IsEmpty() && + extracter.ExtractCallbackSpec->NumArchiveErrors == 0) + { + #ifndef _SFX + UString s; + AddValuePair(IDS_ARCHIVES_COLON, 0x02000324, extracter.Stat.NumArchives, s); + AddValuePair(IDS_FOLDERS_COLON, 0x02000321, extracter.Stat.NumFolders, s); + AddValuePair(IDS_FILES_COLON, 0x02000320, extracter.Stat.NumFiles, s); + AddSizePair(IDS_SIZE_COLON, 0x02000322, extracter.Stat.UnpackSize, s); + AddSizePair(IDS_COMPRESSED_COLON, 0x02000323, extracter.Stat.PackSize, s); + + if (options.CalcCrc) + { + wchar_t temp[16]; + ConvertUInt32ToHex(extracter.Stat.CrcSum, temp); + s += L"CRC: "; + s += temp; + s += L"\n"; + } + + s += L"\n"; + s += LangString(IDS_MESSAGE_NO_ERRORS, 0x02000608); + + MessageBoxW(0, s, LangString(IDS_PROGRESS_TESTING, 0x02000F90), 0); + #endif + } + if (extracter.Result != S_OK) + if (!extracter.ErrorMessage.IsEmpty()) + throw extracter.ErrorMessage; + return extracter.Result; +} diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractGUI.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractGUI.h new file mode 100644 index 000000000..ffefabfe0 --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractGUI.h @@ -0,0 +1,20 @@ +// GUI/ExtractGUI.h + +#ifndef __EXTRACT_GUI_H +#define __EXTRACT_GUI_H + +#include "../Common/Extract.h" + +#include "../FileManager/ExtractCallback.h" + +HRESULT ExtractGUI( + CCodecs *codecs, + const CIntVector &formatIndices, + UStringVector &archivePaths, + UStringVector &archivePathsFull, + const NWildcard::CCensorNode &wildcardCensor, + CExtractOptions &options, + bool showDialog, + CExtractCallbackImp *extractCallback); + +#endif diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractRes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractRes.h new file mode 100644 index 000000000..084181ea4 --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/ExtractRes.h @@ -0,0 +1,19 @@ +#define IDS_UPDATE_NOT_SUPPORTED 199 +#define IDS_CANNOT_CREATE_FOLDER 200 +#define IDS_OPEN_IS_NOT_SUPORTED_ARCHIVE 201 + +#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC 202 +#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR 203 +#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_UNSUPPORTED_METHOD 204 +#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED 205 +#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED 206 + +#define IDS_EXTRACT_SET_FOLDER 207 +#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CANNOT_OPEN_FILE 208 +#define IDS_PROGRESS_EXTRACTING 209 + +#define IDS_CANT_OPEN_ARCHIVE 103 +#define IDS_CANT_OPEN_ENCRYPTED_ARCHIVE 104 +#define IDS_MEM_ERROR 105 +#define IDS_UNKNOWN_ERROR 106 +#define IDS_UNSUPPORTED_ARCHIVE_TYPE 107 diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/GUI.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/GUI.cpp new file mode 100644 index 000000000..d01e958b3 --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/GUI.cpp @@ -0,0 +1,294 @@ +// GUI.cpp + +#include "StdAfx.h" + +#include <initguid.h> + +#include "../../../../C/Alloc.h" + +#include "Common/CommandLineParser.h" +#include "Common/MyException.h" +#include "Common/NewHandler.h" +#include "Common/StringConvert.h" + +#include "Windows/Error.h" +#ifdef _WIN32 +#include "Windows/MemoryLock.h" +#endif + +#include "../Common/ArchiveCommandLine.h" +#include "../Common/ExitCode.h" + +#include "../FileManager/StringUtils.h" + +#include "BenchmarkDialog.h" +#include "ExtractGUI.h" +#include "UpdateGUI.h" + +#include "ExtractRes.h" + +using namespace NWindows; + +HINSTANCE g_hInstance; +#ifndef _UNICODE +bool g_IsNT = false; +#endif + +static void ErrorMessage(LPCWSTR message) +{ + MessageBoxW(NULL, message, L"7-Zip", MB_ICONERROR | MB_OK); +} + +static void ErrorLangMessage(UINT resourceID, UInt32 langID) +{ + ErrorMessage(LangString(resourceID, langID)); +} + +static const char *kNoFormats = "7-Zip cannot find the code that works with archives."; + +static int ShowMemErrorMessage() +{ + ErrorLangMessage(IDS_MEM_ERROR, 0x0200060B); + return NExitCode::kMemoryError; +} + +static int ShowSysErrorMessage(DWORD errorCode) +{ + if (errorCode == E_OUTOFMEMORY) + return ShowMemErrorMessage(); + ErrorMessage(NError::MyFormatMessageW(errorCode)); + return NExitCode::kFatalError; +} + +int Main2(int argc,TCHAR **argv) +{ + UStringVector commandStrings; + #ifdef _WIN32 + NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings); + #else + extern void mySplitCommandLineW(int numArguments,TCHAR **arguments,UStringVector &parts); + mySplitCommandLineW(argc,argv,commandStrings); + #endif + + if (commandStrings.Size() <= 1) + { + MessageBoxW(0, L"Specify command", L"7-Zip", 0); + return 0; + } + commandStrings.Delete(0); + + CArchiveCommandLineOptions options; + CArchiveCommandLineParser parser; + + parser.Parse1(commandStrings, options); + parser.Parse2(options); + + #ifdef _WIN32 + if (options.LargePages) + NSecurity::EnableLockMemoryPrivilege(); + #endif + + CCodecs *codecs = new CCodecs; + CMyComPtr<IUnknown> compressCodecsInfo = codecs; + HRESULT result = codecs->Load(); + if (result != S_OK) + throw CSystemException(result); + + bool isExtractGroupCommand = options.Command.IsFromExtractGroup(); + if (codecs->Formats.Size() == 0 && + (isExtractGroupCommand || + options.Command.IsFromUpdateGroup())) + throw kNoFormats; + + CIntVector formatIndices; + if (!codecs->FindFormatForArchiveType(options.ArcType, formatIndices)) + { + ErrorLangMessage(IDS_UNSUPPORTED_ARCHIVE_TYPE, 0x0200060D); + return NExitCode::kFatalError; + } + + if (options.Command.CommandType == NCommandType::kBenchmark) + { + HRESULT res = Benchmark( + #ifdef EXTERNAL_LZMA + codecs, + #endif + options.NumThreads, options.DictionarySize); + if (res != S_OK) + throw CSystemException(res); + } + else if (isExtractGroupCommand) + { + CExtractCallbackImp *ecs = new CExtractCallbackImp; + CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs; + ecs->ProgressDialog.CompressingMode = false; + + #ifndef _NO_CRYPTO + ecs->PasswordIsDefined = options.PasswordEnabled; + ecs->Password = options.Password; + #endif + + ecs->Init(); + + CExtractOptions eo; + eo.StdOutMode = options.StdOutMode; + eo.OutputDir = options.OutputDir; + eo.YesToAll = options.YesToAll; + eo.OverwriteMode = options.OverwriteMode; + eo.PathMode = options.Command.GetPathMode(); + eo.TestMode = options.Command.IsTestMode(); + eo.CalcCrc = options.CalcCrc; + #ifdef COMPRESS_MT + eo.Properties = options.ExtractProperties; + #endif + + HRESULT result = ExtractGUI(codecs, formatIndices, + options.ArchivePathsSorted, + options.ArchivePathsFullSorted, + options.WildcardCensor.Pairs.Front().Head, + eo, options.ShowDialog, ecs); + if (result != S_OK) + throw CSystemException(result); + if (ecs->Messages.Size() > 0 || ecs->NumArchiveErrors != 0) + return NExitCode::kFatalError; + } + else if (options.Command.IsFromUpdateGroup()) + { + #ifndef _NO_CRYPTO + bool passwordIsDefined = options.PasswordEnabled && !options.Password.IsEmpty(); + #endif + + CUpdateCallbackGUI callback; + // callback.EnablePercents = options.EnablePercents; + + #ifndef _NO_CRYPTO + callback.PasswordIsDefined = passwordIsDefined; + callback.AskPassword = options.PasswordEnabled && options.Password.IsEmpty(); + callback.Password = options.Password; + #endif + + // callback.StdOutMode = options.UpdateOptions.StdOutMode; + callback.Init(); + + CUpdateErrorInfo errorInfo; + + if (!options.UpdateOptions.Init(codecs, formatIndices, options.ArchiveName)) + { + ErrorLangMessage(IDS_UPDATE_NOT_SUPPORTED, 0x02000601); + return NExitCode::kFatalError; + } + HRESULT result = UpdateGUI( + codecs, + options.WildcardCensor, options.UpdateOptions, + options.ShowDialog, + errorInfo, &callback); + + if (result != S_OK) + { + if (!errorInfo.Message.IsEmpty()) + { + ErrorMessage(errorInfo.Message); + if (result == E_FAIL) + return NExitCode::kFatalError; + } + throw CSystemException(result); + } + if (callback.FailedFiles.Size() > 0) + return NExitCode::kWarning; + } + else + { + throw "Unsupported command"; + } + return 0; +} + +#ifdef _WIN32 +static bool inline IsItWindowsNT() +{ + OSVERSIONINFO versionInfo; + versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); + if (!::GetVersionEx(&versionInfo)) + return false; + return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); +} + +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */) +{ + g_hInstance = hInstance; + #ifdef _UNICODE + if (!IsItWindowsNT()) + { + ErrorMessage(L"This program requires Windows NT/2000/2003/2008/XP/Vista"); + return NExitCode::kFatalError; + } + #else + g_IsNT = IsItWindowsNT(); + #endif + + #ifdef _WIN32 + SetLargePageSize(); + #endif + + InitCommonControls(); + + ReloadLang(); + + // setlocale(LC_COLLATE, ".ACP"); + try + { + return Main2(); + } +#else +int Main1(int argc,TCHAR **argv) +{ + ReloadLangSmart(); // ReloadLang(); + + // setlocale(LC_COLLATE, ".ACP"); + try + { + return Main2(argc,argv); + } +#endif + catch(const CNewException &) + { + return ShowMemErrorMessage(); + } + catch(const CArchiveCommandLineException &e) + { + ErrorMessage(GetUnicodeString(e)); + return NExitCode::kUserError; + } + catch(const CSystemException &systemError) + { + if (systemError.ErrorCode == E_ABORT) + return NExitCode::kUserBreak; + return ShowSysErrorMessage(systemError.ErrorCode); + } + catch(const UString &s) + { + ErrorMessage(s); + return NExitCode::kFatalError; + } + catch(const AString &s) + { + ErrorMessage(GetUnicodeString(s)); + return NExitCode::kFatalError; + } + catch(const wchar_t *s) + { + ErrorMessage(s); + return NExitCode::kFatalError; + } + catch(const char *s) + { + ErrorMessage(GetUnicodeString(s)); + return NExitCode::kFatalError; + } + catch(...) + { + ErrorLangMessage(IDS_UNKNOWN_ERROR, 0x0200060C); + return NExitCode::kFatalError; + } +} + diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp new file mode 100644 index 000000000..07c74e9b5 --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp @@ -0,0 +1,256 @@ +// UpdateCallbackGUI.cpp + +#include "StdAfx.h" + +#include "Common/Defs.h" +#include "Common/IntToString.h" +#include "Common/StringConvert.h" + +#include "Windows/Error.h" +#include "Windows/PropVariant.h" + +#include "../FileManager/MessagesDialog.h" +#include "../FileManager/PasswordDialog.h" + +#include "UpdateCallbackGUI.h" + +using namespace NWindows; + +CUpdateCallbackGUI::~CUpdateCallbackGUI() +{ + if (!Messages.IsEmpty()) + { + CMessagesDialog messagesDialog; + messagesDialog.Messages = &Messages; + messagesDialog.Create(ParentWindow); + } +} + +void CUpdateCallbackGUI::Init() +{ + FailedFiles.Clear(); + Messages.Clear(); + NumArchiveErrors = 0; + NumFiles = 0; +} + +void CUpdateCallbackGUI::AddErrorMessage(LPCWSTR message) +{ + Messages.Add(message); +} + +void CUpdateCallbackGUI::AddErrorMessage(const wchar_t *name, DWORD systemError) +{ + AddErrorMessage( + UString(L"WARNING: ") + + NError::MyFormatMessageW(systemError) + + UString(L": ") + + UString(name)); +} + +HRESULT CUpdateCallbackGUI::OpenResult(const wchar_t *name, HRESULT result) +{ + if (result != S_OK) + { + AddErrorMessage (UString(L"Error: ") + name + + UString(L" is not supported archive")); + } + return S_OK; +} + +HRESULT CUpdateCallbackGUI::StartScanning() +{ + return S_OK; +} + +HRESULT CUpdateCallbackGUI::CanNotFindError(const wchar_t *name, DWORD systemError) +{ + FailedFiles.Add(name); + AddErrorMessage(name, systemError); + return S_OK; +} + +HRESULT CUpdateCallbackGUI::FinishScanning() +{ + return S_OK; +} + +HRESULT CUpdateCallbackGUI::StartArchive(const wchar_t *name, bool /* updating */) +{ + ProgressDialog.ProgressSynch.SetTitleFileName(name); + return S_OK; +} + +HRESULT CUpdateCallbackGUI::FinishArchive() +{ + return S_OK; +} + +HRESULT CUpdateCallbackGUI::CheckBreak() +{ + return ProgressDialog.ProgressSynch.ProcessStopAndPause(); +} + +HRESULT CUpdateCallbackGUI::ScanProgress(UInt64 /* numFolders */, UInt64 numFiles, const wchar_t *path) +{ + ProgressDialog.ProgressSynch.SetCurrentFileName(path); + ProgressDialog.ProgressSynch.SetNumFilesTotal(numFiles); + return ProgressDialog.ProgressSynch.ProcessStopAndPause(); +} + +HRESULT CUpdateCallbackGUI::Finilize() +{ + return S_OK; +} + +HRESULT CUpdateCallbackGUI::SetNumFiles(UInt64 numFiles) +{ + ProgressDialog.ProgressSynch.SetNumFilesTotal(numFiles); + return S_OK; +} + +HRESULT CUpdateCallbackGUI::SetTotal(UInt64 total) +{ + ProgressDialog.ProgressSynch.SetProgress(total, 0); + return S_OK; +} + +HRESULT CUpdateCallbackGUI::SetCompleted(const UInt64 *completeValue) +{ + RINOK(CheckBreak()); + if (completeValue != NULL) + ProgressDialog.ProgressSynch.SetPos(*completeValue); + return S_OK; +} + +HRESULT CUpdateCallbackGUI::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) +{ + RINOK(CheckBreak()); + ProgressDialog.ProgressSynch.SetRatioInfo(inSize, outSize); + return S_OK; +} + +HRESULT CUpdateCallbackGUI::GetStream(const wchar_t *name, bool /* isAnti */) +{ + ProgressDialog.ProgressSynch.SetCurrentFileName(name); + return S_OK; +} + +HRESULT CUpdateCallbackGUI::OpenFileError(const wchar_t *name, DWORD systemError) +{ + FailedFiles.Add(name); + // if (systemError == ERROR_SHARING_VIOLATION) + { + AddErrorMessage(name, systemError); + return S_FALSE; + } + // return systemError; +} + +HRESULT CUpdateCallbackGUI::SetOperationResult(Int32 /* operationResult */) +{ + NumFiles++; + ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles); + return S_OK; +} + +HRESULT CUpdateCallbackGUI::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) +{ + *password = NULL; + if (!PasswordIsDefined) + { + if (AskPassword) + { + CPasswordDialog dialog; + if (dialog.Create(ProgressDialog) == IDCANCEL) + return E_ABORT; + Password = dialog.Password; + PasswordIsDefined = true; + } + } + *passwordIsDefined = BoolToInt(PasswordIsDefined); + return StringToBstr(Password, password); +} + +HRESULT CUpdateCallbackGUI::CryptoGetTextPassword(BSTR *password) +{ + *password = NULL; + if (!PasswordIsDefined) + { + CPasswordDialog dialog; + if (dialog.Create(ProgressDialog) == IDCANCEL) + return E_ABORT; + Password = dialog.Password; + PasswordIsDefined = true; + } + return StringToBstr(Password, password); +} + +/* +It doesn't work, since main stream waits Dialog +HRESULT CUpdateCallbackGUI::CloseProgress() +{ + ProgressDialog.MyClose(); + return S_OK; +}; +*/ + + +HRESULT CUpdateCallbackGUI::Open_CheckBreak() +{ + return ProgressDialog.ProgressSynch.ProcessStopAndPause(); +} + +HRESULT CUpdateCallbackGUI::Open_SetTotal(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */) +{ + // if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesTotal(*numFiles); + return S_OK; +} + +HRESULT CUpdateCallbackGUI::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */) +{ + return ProgressDialog.ProgressSynch.ProcessStopAndPause(); +} + +#ifndef _NO_CRYPTO + +HRESULT CUpdateCallbackGUI::Open_CryptoGetTextPassword(BSTR *password) +{ + PasswordWasAsked = true; + if (!PasswordIsDefined) + { + CPasswordDialog dialog; + if (dialog.Create(ProgressDialog) == IDCANCEL) + return E_ABORT; + Password = dialog.Password; + PasswordIsDefined = true; + } + return StringToBstr(Password, password); +} + +HRESULT CUpdateCallbackGUI::Open_GetPasswordIfAny(UString &password) +{ + if (PasswordIsDefined) + password = Password; + return S_OK; +} + +bool CUpdateCallbackGUI::Open_WasPasswordAsked() +{ + return PasswordWasAsked; +} + +void CUpdateCallbackGUI::Open_ClearPasswordWasAskedFlag() +{ + PasswordWasAsked = false; +} + +/* +HRESULT CUpdateCallbackGUI::ShowDeleteFile(const wchar_t *name) +{ + ProgressDialog.ProgressSynch.SetCurrentFileName(name); + return S_OK; +} +*/ + +#endif diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateCallbackGUI.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateCallbackGUI.h new file mode 100644 index 000000000..1f8b70e09 --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateCallbackGUI.h @@ -0,0 +1,53 @@ +// UpdateCallbackGUI.h + +#ifndef __UPDATE_CALLBACK_GUI_H +#define __UPDATE_CALLBACK_GUI_H + +#include "../Common/Update.h" +#include "../Common/ArchiveOpenCallback.h" +#include "../FileManager/ProgressDialog2.h" + +class CUpdateCallbackGUI: + public IOpenCallbackUI, + public IUpdateCallbackUI2 +{ +public: + // bool StdOutMode; + bool PasswordIsDefined; + UString Password; + bool AskPassword; + bool PasswordWasAsked; + UInt64 NumFiles; + + CUpdateCallbackGUI(): + PasswordIsDefined(false), + PasswordWasAsked(false), + AskPassword(false), + // StdOutMode(false) + ParentWindow(0) + {} + + ~CUpdateCallbackGUI(); + void Init(); + + INTERFACE_IUpdateCallbackUI2(;) + INTERFACE_IOpenCallbackUI(;) + + // HRESULT CloseProgress(); + + UStringVector FailedFiles; + + CProgressDialog ProgressDialog; + HWND ParentWindow; + void StartProgressDialog(const UString &title) + { + ProgressDialog.Create(title, ParentWindow); + } + + UStringVector Messages; + int NumArchiveErrors; + void AddErrorMessage(LPCWSTR message); + void AddErrorMessage(const wchar_t *name, DWORD systemError); +}; + +#endif diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateGUI.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateGUI.cpp new file mode 100644 index 000000000..2d4dbbc2c --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateGUI.cpp @@ -0,0 +1,389 @@ +// UpdateGUI.cpp + +#include "StdAfx.h" + +#include "UpdateGUI.h" + +#include "Common/IntToString.h" +#include "Common/StringConvert.h" +#include "Common/StringToInt.h" + +#include "Windows/Error.h" +#include "Windows/FileDir.h" +#include "Windows/Thread.h" + +#include "../Common/WorkDir.h" + +#include "../Explorer/MyMessages.h" + +#include "../FileManager/StringUtils.h" + +#include "CompressDialog.h" +#include "UpdateGUI.h" + +#include "resource.h" + +using namespace NWindows; +using namespace NFile; + +static const wchar_t *kDefaultSfxModule = L"7z.sfx"; +static const wchar_t *kSFXExtension = L"exe"; + +struct CThreadUpdating +{ + CCodecs *codecs; + + CUpdateCallbackGUI *UpdateCallbackGUI; + const NWildcard::CCensor *WildcardCensor; + CUpdateOptions *Options; + + CUpdateErrorInfo *ErrorInfo; + HRESULT Result; + + DWORD Process() + { + UpdateCallbackGUI->ProgressDialog.WaitCreating(); + try + { + Result = UpdateArchive(codecs, *WildcardCensor, *Options, + *ErrorInfo, UpdateCallbackGUI, UpdateCallbackGUI); + } + catch(const UString &s) + { + ErrorInfo->Message = s; + Result = E_FAIL; + } + catch(const wchar_t *s) + { + ErrorInfo->Message = s; + Result = E_FAIL; + } + catch(const char *s) + { + ErrorInfo->Message = GetUnicodeString(s); + Result = E_FAIL; + } + catch(...) + { + Result = E_FAIL; + } + UpdateCallbackGUI->ProgressDialog.MyClose(); + return 0; + } + static THREAD_FUNC_DECL MyThreadFunction(void *param) + { + return ((CThreadUpdating *)param)->Process(); + } +}; + +static void AddProp(CObjectVector<CProperty> &properties, const UString &name, const UString &value) +{ + CProperty prop; + prop.Name = name; + prop.Value = value; + properties.Add(prop); +} + +static void AddProp(CObjectVector<CProperty> &properties, const UString &name, UInt32 value) +{ + wchar_t tmp[32]; + ConvertUInt64ToString(value, tmp); + AddProp(properties, name, tmp); +} + +static void AddProp(CObjectVector<CProperty> &properties, const UString &name, bool value) +{ + AddProp(properties, name, value ? UString(L"on"): UString(L"off")); +} + +static bool IsThereMethodOverride(bool is7z, const UString &propertiesString) +{ + UStringVector strings; + SplitString(propertiesString, strings); + for (int i = 0; i < strings.Size(); i++) + { + const UString &s = strings[i]; + if (is7z) + { + const wchar_t *end; + UInt64 n = ConvertStringToUInt64(s, &end); + if (n == 0 && *end == L'=') + return true; + } + else + { + if (s.Length() > 0) + if (s[0] == L'm' && s[1] == L'=') + return true; + } + } + return false; +} + +static void ParseAndAddPropertires(CObjectVector<CProperty> &properties, + const UString &propertiesString) +{ + UStringVector strings; + SplitString(propertiesString, strings); + for (int i = 0; i < strings.Size(); i++) + { + const UString &s = strings[i]; + CProperty property; + int index = s.Find(L'='); + if (index < 0) + property.Name = s; + else + { + property.Name = s.Left(index); + property.Value = s.Mid(index + 1); + } + properties.Add(property); + } +} + +static UString GetNumInBytesString(UInt64 v) +{ + wchar_t s[32]; + ConvertUInt64ToString(v, s); + size_t len = wcslen(s); + s[len++] = L'B'; + s[len] = L'\0'; + return s; +} + +static void SetOutProperties( + CObjectVector<CProperty> &properties, + bool is7z, + UInt32 level, + bool setMethod, + const UString &method, + UInt32 dictionary, + bool orderMode, + UInt32 order, + bool solidIsSpecified, UInt64 solidBlockSize, + bool multiThreadIsAllowed, UInt32 numThreads, + const UString &encryptionMethod, + bool encryptHeadersIsAllowed, bool encryptHeaders, + bool /* sfxMode */) +{ + if (level != (UInt32)(Int32)-1) + AddProp(properties, L"x", (UInt32)level); + if (setMethod) + { + if (!method.IsEmpty()) + AddProp(properties, is7z ? L"0": L"m", method); + if (dictionary != (UInt32)(Int32)-1) + { + UString name; + if (is7z) + name = L"0"; + if (orderMode) + name += L"mem"; + else + name += L"d"; + AddProp(properties, name, GetNumInBytesString(dictionary)); + } + if (order != (UInt32)(Int32)-1) + { + UString name; + if (is7z) + name = L"0"; + if (orderMode) + name += L"o"; + else + name += L"fb"; + AddProp(properties, name, (UInt32)order); + } + } + + if (!encryptionMethod.IsEmpty()) + AddProp(properties, L"em", encryptionMethod); + + if (encryptHeadersIsAllowed) + AddProp(properties, L"he", encryptHeaders); + if (solidIsSpecified) + AddProp(properties, L"s", GetNumInBytesString(solidBlockSize)); + if (multiThreadIsAllowed) + AddProp(properties, L"mt", numThreads); +} + +static HRESULT ShowDialog( + CCodecs *codecs, + const NWildcard::CCensor &censor, + CUpdateOptions &options, CUpdateCallbackGUI *callback) +{ + if (options.Commands.Size() != 1) + throw "It must be one command"; + UString currentDirPrefix; + { + if (!NDirectory::MyGetCurrentDirectory(currentDirPrefix)) + return E_FAIL; + NName::NormalizeDirPathPrefix(currentDirPrefix); + } + + bool oneFile = false; + NFind::CFileInfoW fileInfo; + if (censor.Pairs.Size() > 0) + { + const NWildcard::CPair &pair = censor.Pairs[0]; + if (pair.Head.IncludeItems.Size() > 0) + { + const NWildcard::CItem &item = pair.Head.IncludeItems[0]; + if (item.ForFile) + { + UString name = pair.Prefix; + for (int i = 0; i < item.PathParts.Size(); i++) + { + if (i > 0) + name += WCHAR_PATH_SEPARATOR; + name += item.PathParts[i]; + } + if (fileInfo.Find(name)) + { + if (censor.Pairs.Size() == 1 && pair.Head.IncludeItems.Size() == 1) + oneFile = !fileInfo.IsDir(); + } + } + } + } + + CCompressDialog dialog; + NCompressDialog::CInfo &di = dialog.Info; + for(int i = 0; i < codecs->Formats.Size(); i++) + { + const CArcInfoEx &ai = codecs->Formats[i]; + if (ai.UpdateEnabled && (oneFile || !ai.KeepName)) + dialog.m_ArchiverInfoList.Add(ai); + } + if(dialog.m_ArchiverInfoList.Size() == 0) + { + ShowErrorMessage(L"No Update Engines"); + return E_FAIL; + } + + // di.ArchiveName = options.ArchivePath.GetFinalPath(); + di.ArchiveName = options.ArchivePath.GetPathWithoutExt(); + dialog.OriginalFileName = fileInfo.Name; + + di.CurrentDirPrefix = currentDirPrefix; + di.SFXMode = options.SfxMode; + di.OpenShareForWrite = options.OpenShareForWrite; + + if (callback->PasswordIsDefined) + di.Password = callback->Password; + + di.KeepName = !oneFile; + + if(dialog.Create(0) != IDOK) + return E_ABORT; + + options.VolumesSizes = di.VolumeSizes; + /* + if (di.VolumeSizeIsDefined) + { + MyMessageBox(L"Splitting to volumes is not supported"); + return E_FAIL; + } + */ + + NUpdateArchive::CActionSet &actionSet = options.Commands.Front().ActionSet; + + switch(di.UpdateMode) + { + case NCompressDialog::NUpdateMode::kAdd: + actionSet = NUpdateArchive::kAddActionSet; + break; + case NCompressDialog::NUpdateMode::kUpdate: + actionSet = NUpdateArchive::kUpdateActionSet; + break; + case NCompressDialog::NUpdateMode::kFresh: + actionSet = NUpdateArchive::kFreshActionSet; + break; + case NCompressDialog::NUpdateMode::kSynchronize: + actionSet = NUpdateArchive::kSynchronizeActionSet; + break; + default: + throw 1091756; + } + const CArcInfoEx &archiverInfo = dialog.m_ArchiverInfoList[di.ArchiverInfoIndex]; + callback->PasswordIsDefined = (!di.Password.IsEmpty()); + if (callback->PasswordIsDefined) + callback->Password = di.Password; + + options.MethodMode.Properties.Clear(); + + bool is7z = archiverInfo.Name.CompareNoCase(L"7z") == 0; + bool methodOverride = IsThereMethodOverride(is7z, di.Options); + + SetOutProperties( + options.MethodMode.Properties, + is7z, + di.Level, + !methodOverride, + di.Method, + di.Dictionary, + di.OrderMode, di.Order, + di.SolidIsSpecified, di.SolidBlockSize, + di.MultiThreadIsAllowed, di.NumThreads, + di.EncryptionMethod, + di.EncryptHeadersIsAllowed, di.EncryptHeaders, + di.SFXMode); + + options.OpenShareForWrite = di.OpenShareForWrite; + ParseAndAddPropertires(options.MethodMode.Properties, di.Options); + + if (di.SFXMode) + options.SfxMode = true; + options.MethodMode.FormatIndex = archiverInfo.FormatIndex; + + options.ArchivePath.VolExtension = archiverInfo.GetMainExt(); + if(di.SFXMode) + options.ArchivePath.BaseExtension = kSFXExtension; + else + options.ArchivePath.BaseExtension = options.ArchivePath.VolExtension; + options.ArchivePath.ParseFromPath(di.ArchiveName); + + NWorkDir::CInfo workDirInfo; + ReadWorkDirInfo(workDirInfo); + options.WorkingDir.Empty(); + if (workDirInfo.Mode != NWorkDir::NMode::kCurrent) + { + UString fullPath; + NDirectory::MyGetFullPathName(di.ArchiveName, fullPath); + options.WorkingDir = GetWorkDir(workDirInfo, fullPath); + NDirectory::CreateComplexDirectory(options.WorkingDir); + } + return S_OK; +} + +HRESULT UpdateGUI( + CCodecs *codecs, + const NWildcard::CCensor &censor, + CUpdateOptions &options, + bool showDialog, + CUpdateErrorInfo &errorInfo, + CUpdateCallbackGUI *callback) +{ + if (showDialog) + { + RINOK(ShowDialog(codecs, censor, options, callback)); + } + if (options.SfxMode && options.SfxModule.IsEmpty()) + options.SfxModule = kDefaultSfxModule; + + CThreadUpdating tu; + + tu.codecs = codecs; + + tu.UpdateCallbackGUI = callback; + tu.UpdateCallbackGUI->Init(); + + tu.WildcardCensor = &censor; + tu.Options = &options; + tu.ErrorInfo = &errorInfo; + + NWindows::CThread thread; + RINOK(thread.Create(CThreadUpdating::MyThreadFunction, &tu)) + tu.UpdateCallbackGUI->StartProgressDialog(LangString(IDS_PROGRESS_COMPRESSING, 0x02000DC0)); + return tu.Result; +} diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateGUI.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateGUI.h new file mode 100644 index 000000000..112eff0ff --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/UpdateGUI.h @@ -0,0 +1,19 @@ +// GUI/UpdateGUI.h + +#ifndef __UPDATE_GUI_H +#define __UPDATE_GUI_H + +#include "../Common/Update.h" +#include "UpdateCallbackGUI.h" + +#include "../FileManager/UpdateCallback100.h" + +HRESULT UpdateGUI( + CCodecs *codecs, + const NWildcard::CCensor &censor, + CUpdateOptions &options, + bool showDialog, + CUpdateErrorInfo &errorInfo, + CUpdateCallbackGUI *callback); + +#endif diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/resource.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/resource.h new file mode 100644 index 000000000..e154e035f --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/resource.h @@ -0,0 +1,49 @@ +#define IDS_CONTEXT_EXTRACT 142 +#define IDS_CONTEXT_EXTRACT_HELP 143 +#define IDS_CONTEXT_COMPRESS 144 +#define IDS_CONTEXT_COMPRESS_HELP 145 +#define IDS_CONTEXT_OPEN 146 +#define IDS_CONTEXT_OPEN_HELP 147 +#define IDS_CONTEXT_TEST 148 +#define IDS_CONTEXT_TEST_HELP 149 +#define IDS_CONTEXT_CAPTION_HELP 150 +#define IDS_CONTEXT_POPUP_CAPTION 151 +#define IDS_OPEN_TYPE_ALL_FILES 80 + +#define IDS_METHOD_STORE 81 +#define IDS_METHOD_NORMAL 82 +#define IDS_METHOD_MAXIMUM 83 +#define IDS_METHOD_FAST 84 +#define IDS_METHOD_FASTEST 85 +#define IDS_METHOD_ULTRA 86 + +#define IDS_COMPRESS_NON_SOLID 88 +#define IDS_COMPRESS_SOLID 89 + +#define IDS_COMPRESS_UPDATE_MODE_ADD 90 +#define IDS_COMPRESS_UPDATE_MODE_UPDATE 91 +#define IDS_COMPRESS_UPDATE_MODE_FRESH 92 +#define IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE 93 + +#define IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE 94 +#define IDS_COMPRESS_INCORRECT_VOLUME_SIZE 95 + +#define IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE 96 +#define IDS_CANT_UPDATE_ARCHIVE 97 + +#define IDS_PROGRESS_COMPRESSING 98 +#define IDS_PROGRESS_TESTING 99 +#define IDS_ERROR 100 +#define IDS_MESSAGE_NO_ERRORS 101 +#define IDS_CONFIG_DIALOG_CAPTION 102 + +#define IDS_PASSWORD_USE_ASCII 110 +#define IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH 111 +#define IDS_PASSWORD_IS_TOO_LONG 112 + +#define IDS_FILES_COLON 2274 +#define IDS_FOLDERS_COLON 2275 +#define IDS_SIZE_COLON 2276 +#define IDS_COMPRESSED_COLON 2277 +#define IDS_ARCHIVES_COLON 2278 + diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/wxGUI.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/wxGUI.cpp new file mode 100644 index 000000000..366bd40c4 --- /dev/null +++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/GUI/wxGUI.cpp @@ -0,0 +1,575 @@ +// wxGUI.cpp + +#include "StdAfx.h" + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWidgets headers) +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#define static const +#include "../GUI/p7zip_32.xpm" +#undef static + +#undef ACTIVATE_DIALOG_TESTS + +int Main1(int argc,TCHAR **argv); + +#include "Windows/Registry.h" +using namespace NWindows; +using namespace NRegistry; + + +#include "Common/StringConvert.h" +#include "Windows/FileDir.h" +#include "Windows/Synchronization.h" + +#include "ExtractRes.h" +#include "../Explorer/MyMessages.h" + +#include "ExtractGUI.h" +#include "UpdateGUI.h" +#include "BenchmarkDialog.h" +#include "../FileManager/RegistryUtils.h" + +using namespace NWindows; +using namespace NFile; + +#include "../FileManager/ProgramLocation.h" + +static LPCWSTR kHelpFileName = L"help/"; + +void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile) +{ + UString path; + if (!::GetProgramFolderPath(path)) + return; + path += kHelpFileName; + path += topicFile; + printf("ShowHelpWindow(%p,%ls)=>%ls\n",hwnd,topicFile,(const wchar_t *)path); + // HtmlHelp(hwnd, GetSystemString(path), HH_DISPLAY_TOPIC, NULL); + wxString path2(path); + wxLaunchDefaultBrowser(path2); +} + +////////////////////////////// TRIES /////////////////////////////////// + +#ifdef ACTIVATE_DIALOG_TESTS +static void ErrorMessage(const wchar_t *message) +{ + MessageBox(0,message, wxT("7-Zip GUI"),wxICON_ERROR); +} + +#include "../FileManager/PasswordDialog.h" +#include "../FileManager/MessagesDialog.h" +#include "../FileManager/OverwriteDialog.h" +#include "Windows/Thread.h" + +void myErrorMsg(const wchar_t *message) +{ + MessageBox(0,message, wxT("Message"),wxICON_ERROR); +} + +void testCMessagesDialog() +{ + UStringVector Messages; + + Messages.Add(L"message 1"); + Messages.Add(L"message 2"); + Messages.Add(L"message 3"); + Messages.Add(L"message 4"); + Messages.Add(L"message 5"); + Messages.Add(L"message 6"); + Messages.Add(L"message 7"); + Messages.Add(L"message 8"); + Messages.Add(L"message 9"); + + CMessagesDialog messagesDialog; + messagesDialog.Messages = &Messages; + int ret = messagesDialog.Create( 0 ); // ParentWindow + + if (ret == IDOK) myErrorMsg(wxT("CMessagesDialog => IDOK")); + else if (ret == IDCANCEL) myErrorMsg(wxT("CMessagesDialog => IDCANCEL")); + else myErrorMsg(wxT("CMessagesDialog => ?")); + +} + +void testCOverwriteDialog() +{ +SYSTEMTIME systemTime; +GetSystemTime( &systemTime ); + + +const wchar_t *existName = L"existName"; +FILETIME data_existTime; +FILETIME *existTime = &data_existTime ; +UInt64 data_existSize = 1234; +UInt64 *existSize = &data_existSize; +const wchar_t *newName = L"newName"; +FILETIME data_newTime; +FILETIME *newTime = &data_newTime; +UInt64 data_newSize = 45678; +UInt64 *newSize = &data_newSize; +Int32 data_answer=0; +Int32 *answer = &data_answer; + +SystemTimeToFileTime( &systemTime , &data_existTime); +SystemTimeToFileTime( &systemTime , &data_newTime); + + COverwriteDialog dialog; + + dialog.OldFileInfo.Time = *existTime; + dialog.OldFileInfo.TimeIsDefined = true; // FIXME : look again at the sample ! + + dialog.OldFileInfo.SizeIsDefined = (existSize != NULL); + if (dialog.OldFileInfo.SizeIsDefined) + dialog.OldFileInfo.Size = *existSize; + dialog.OldFileInfo.Name = existName; + + if (newTime == 0) + dialog.NewFileInfo.TimeIsDefined = false; + else + { + dialog.NewFileInfo.TimeIsDefined = true; + dialog.NewFileInfo.Time = *newTime; + } + + dialog.NewFileInfo.SizeIsDefined = (newSize != NULL); + if (dialog.NewFileInfo.SizeIsDefined) + dialog.NewFileInfo.Size = *newSize; + dialog.NewFileInfo.Name = newName; + + /* + NOverwriteDialog::NResult::EEnum writeAnswer = + NOverwriteDialog::Execute(oldFileInfo, newFileInfo); + */ + INT_PTR writeAnswer = dialog.Create(NULL); // ParentWindow doesn't work with 7z + + switch(writeAnswer) + { + case IDCANCEL: myErrorMsg(wxT("COverwriteDialog => IDCANCEL")); break; + case IDNO: myErrorMsg(wxT("COverwriteDialog => IDNO")); break; + case IDC_BUTTON_OVERWRITE_NO_TO_ALL: myErrorMsg(wxT("COverwriteDialog => IDC_BUTTON_OVERWRITE_NO_TO_ALL")); break; + case IDC_BUTTON_OVERWRITE_YES_TO_ALL:myErrorMsg(wxT("COverwriteDialog => IDC_BUTTON_OVERWRITE_YES_TO_ALL")); break; + case IDC_BUTTON_OVERWRITE_AUTO_RENAME:myErrorMsg(wxT("COverwriteDialog => IDC_BUTTON_OVERWRITE_AUTO_RENAME")); break; + case IDYES: myErrorMsg(wxT("COverwriteDialog => IDYES")); break; + default: myErrorMsg(wxT("COverwriteDialog => default")); break; + } +} + +void testCPasswordDialog() +{ + CPasswordDialog dialog; + + int ret = dialog.Create(0); + if (ret == IDOK) { + UString Password = dialog.Password; + UString msg = wxT("CPasswordDialog => IDOK password=\""); + msg += Password; + msg += wxT("\""); + myErrorMsg(msg); + } + else if (ret == IDCANCEL) myErrorMsg(wxT("CPasswordDialog => IDCANCEL")); + else myErrorMsg(wxT("CPasswordDialog => ?")); + +} + +struct CThreadProgressDialog +{ + CProgressDialog * ProgressDialog; + static THREAD_FUNC_DECL MyThreadFunction(void *param) + { + ((CThreadProgressDialog *)param)->Result = ((CThreadProgressDialog *)param)->Process(); + return 0; + } + HRESULT Result; + HRESULT Process() + { + Sleep(1000); + int total = 1000; + + ProgressDialog->ProgressSynch.SetTitleFileName(L"SetTitleFileName"); + ProgressDialog->ProgressSynch.SetNumFilesTotal(100); + ProgressDialog->ProgressSynch.SetNumFilesCur(1); + ProgressDialog->ProgressSynch.SetProgress(total, 0); + // ProgressDialog.ProgressSynch.SetRatioInfo(inSize, outSize); + // ProgressDialog.ProgressSynch.SetCurrentFileName(name); + + ProgressDialog->ProgressSynch.SetPos(total/10); + ProgressDialog->ProgressSynch.SetCurrentFileName(L"File1"); + Sleep(1000); + ProgressDialog->ProgressSynch.SetPos(total/2); + ProgressDialog->ProgressSynch.SetCurrentFileName(L"File2"); + Sleep(1000); + ProgressDialog->ProgressSynch.SetPos(total); + ProgressDialog->ProgressSynch.SetCurrentFileName(L"File3"); + Sleep(1000); + ProgressDialog->MyClose(); + return 0; + } +}; + +void testCProgressDialog() +{ + CProgressDialog ProgressDialog; + + CThreadProgressDialog benchmarker; + benchmarker.ProgressDialog = &ProgressDialog; + NWindows::CThread thread; + thread.Create(CThreadProgressDialog::MyThreadFunction, &benchmarker); + + // void StartProgressDialog(const UString &title) + int ret = ProgressDialog.Create(L"testCProgressDialog", 0); + + if (ret == IDOK) myErrorMsg(wxT("CProgressDialog => IDOK")); + else if (ret == IDCANCEL) myErrorMsg(wxT("CProgressDialog => IDCANCEL")); + else myErrorMsg(wxT("CProgressDialog => ?")); + +} + +void testDialog(int num) +{ + NWindows::NControl::CModalDialog dialog; + + printf("Generic Dialog(%d)\n",num); + int ret = dialog.Create(num, 0); + if (ret == IDOK) myErrorMsg(wxT("Generic Dialog => IDOK")); + else if (ret == IDCANCEL) myErrorMsg(wxT("Generic Dialog => IDCANCEL")); + else myErrorMsg(wxT("Generic Dialog => ?")); +} + +void testMessageBox() +{ + int ret = MessageBoxW(0, L"test yes/no/cancel", + L"7-Zip", MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL); + if (ret == IDYES) myErrorMsg(wxT("MessageBoxW => IDYES")); + else if (ret == IDNO) myErrorMsg(wxT("MessageBoxW => IDNO")); + else if (ret == IDCANCEL) myErrorMsg(wxT("MessageBoxW => IDCANCEL")); + else myErrorMsg(wxT("MessageBoxW => ?")); +} + +static void testRegistry() +{ + SaveRegLang(L"fr"); + + UString langFile; + ReadRegLang(langFile); + + printf("testRegistry : -%ls-\n",(const wchar_t *)langFile); +} + + +int Main2(int argc,TCHAR **argv); + +int Main3(int argc,wxChar **argv) +{ + testRegistry(); + + int num = -1; + + if (argc >=2 ) + { + num = argv[1][0] - L'0'; + } + printf("num=%d\n",num); + + + switch(num) + { + case 0: + { + TCHAR **argv2 = (TCHAR **)calloc(argc,sizeof(*argv)); + + argv2[0] = argv[0]; + for(int i = 2; i < argc; i++) argv2[i-1] = argv[i]; + + return Main2(argc-1,argv2); + } + // TODO Benchmark + // TODO CCompressDialog + // TODO CExtractDialog ? + case 1 : testCMessagesDialog(); break; + case 2 : testCOverwriteDialog(); break; + case 3 : testCPasswordDialog(); break; + case 4 : testCProgressDialog(); break; + case 5 : testMessageBox(); break; + case 9 : + if (argc >= 3) + { + AString str = GetAnsiString(argv[2]); + int num = atoi((const char*)str); + testDialog(num); + } + else + { + printf("usage : 7zG 9 <windowID>\n"); + } + break; + default : + printf("usage : 7zG number\n"); + + }; + + return 0; +} + +#endif // ACTIVATE_DIALOG_TESTS + +static const TCHAR *kCUBasePath = TEXT("Software/7-ZIP"); +static const WCHAR *kLangValueName = L"Lang"; + +void SaveRegLang(const UString &langFile) +{ + CKey key; + key.Create(HKEY_CURRENT_USER, kCUBasePath); + key.SetValue(kLangValueName, langFile); +} + +void ReadRegLang(UString &langFile) +{ + langFile.Empty(); + CKey key; + if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS) + key.QueryValue(kLangValueName, langFile); +} + + +////////////////////////////////// + +#define NEED_NAME_WINDOWS_TO_UNIX +#include "myPrivate.h" // global_use_utf16_conversion + +void mySplitCommandLineW(int numArguments, TCHAR **arguments,UStringVector &parts) { + + parts.Clear(); + for(int ind=0;ind < numArguments; ind++) { + UString tmp = arguments[ind]; + // tmp.Trim(); " " is a valid filename ... + if (!tmp.IsEmpty()) { + parts.Add(tmp); +// DEBUG printf("ARG %d : '%ls'\n",ind,(const wchar_t *)tmp); + } + } +} + +// ---------------------------------------------------------------------------- +// private classes +// ---------------------------------------------------------------------------- + +// Define a new frame type +class MyFrame: public wxFrame +{ +public: + // ctor + MyFrame(wxFrame *frame, const wxString& title, int x, int y, int w, int h); + // virtual ~MyFrame(); + + // operations + void WriteText(const wxString& text) { m_txtctrl->WriteText(text); } + +protected: + // callbacks + void OnWorkerEvent(wxCommandEvent& event); +private: + // just some place to put our messages in + wxTextCtrl *m_txtctrl; + DECLARE_EVENT_TABLE() +}; + +enum { + WORKER_EVENT=100 // this one gets sent from the worker thread +}; + +BEGIN_EVENT_TABLE(MyFrame, wxFrame) + EVT_MENU(WORKER_EVENT, MyFrame::OnWorkerEvent) + // EVT_IDLE(MyFrame::OnIdle) +END_EVENT_TABLE() + +// My frame constructor +MyFrame::MyFrame(wxFrame *frame, const wxString& title, + int x, int y, int w, int h) + : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h)) +{ + this->SetIcon(wxICON(p7zip_32)); + +#if wxUSE_STATUSBAR + CreateStatusBar(2); +#endif // wxUSE_STATUSBAR + + m_txtctrl = new wxTextCtrl(this, wxID_ANY, _T(""), wxPoint(0, 0), wxSize(0, 0), wxTE_MULTILINE | wxTE_READONLY); +} + +void myCreateHandle(int n); +wxWindow * g_window=0; + +void MyFrame::OnWorkerEvent(wxCommandEvent& event) +{ + int n = event.GetInt(); + myCreateHandle(n); +} + + +// Define a new application type, each program should derive a class from wxApp +class MyApp : public wxApp +{ +public: + // override base class virtuals + // ---------------------------- + + // this one is called on application startup and is a good place for the app + // initialization (doing it here and not in the ctor allows to have an error + // return: if OnInit() returns false, the application terminates) + virtual bool OnInit(); +}; + +// Create a new application object: this macro will allow wxWidgets to create +// the application object during program execution (it's better than using a +// static object for many reasons) and also implements the accessor function +// wxGetApp() which will return the reference of the right type (i.e. MyApp and +// not wxApp) +IMPLEMENT_APP(MyApp) + +time_t g_T0 = 0; +class MyThread : public wxThread +{ + int _argc; + TCHAR **_argv; +public: + MyThread(int argc,TCHAR **argv): wxThread(),_argc(argc), _argv(argv) {} + + // thread execution starts here + virtual void *Entry() + { +#ifdef ACTIVATE_DIALOG_TESTS + int ret = Main3(_argc,_argv); +#else + int ret = Main1(_argc,_argv); +#endif + exit(ret); + } +}; + +// 'Main program' equivalent: the program execution "starts" here +bool MyApp::OnInit() +{ + // don't parse the command-line options ! + // : if ( !wxApp::OnInit() ) return false; + + { // define P7ZIP_HOME_DIR + extern void my_windows_split_path(const AString &p_path, AString &dir , AString &base); + static char p7zip_home_dir[MAX_PATH]; + + UString fullPath; + NDirectory::MyGetFullPathName(wxApp::argv[0], fullPath); + AString afullPath = GetAnsiString(fullPath); + + AString dir,name; + + my_windows_split_path(afullPath,dir,name); + + const char *dir2 = nameWindowToUnix((const char *)dir); + snprintf(p7zip_home_dir,sizeof(p7zip_home_dir),"P7ZIP_HOME_DIR=%s/",dir2); + p7zip_home_dir[sizeof(p7zip_home_dir)-1] = 0; + putenv(p7zip_home_dir); + // DEBUG printf("putenv(%s)\n",p7zip_home_dir); + } + global_use_utf16_conversion = 1; // UNICODE ! + + g_T0 = time(0); + // DEBUG printf("MAIN Thread : 0x%lx\n",wxThread::GetCurrentId()); + + // Create the main frame window + MyFrame *frame = new MyFrame((wxFrame *)NULL, _T("7-zip Main Window"), 50, 50, 450, 340); + // Don't Show the frame ! + // frame->Show(true); + + SetTopWindow(frame); + + g_window = frame; + + MyThread *thread = new MyThread(wxApp::argc,wxApp::argv); + thread->Create(); // != wxTHREAD_NO_ERROR + thread->Run(); + + // success: wxApp::OnRun() will be called which will enter the main message + // loop and the application will run. If we returned false here, the + // application would exit immediately. + return true; +} + +DWORD WINAPI GetTickCount(VOID) { + static wxStopWatch sw; + return sw.Time(); +} + +////////////////////////////////////////// + +#include "resource.h" +#include "ExtractRes.h" + +static CStringTable g_stringTable[] = +{ + /* resource.rc */ + /***************/ + { IDS_OPEN_TYPE_ALL_FILES, L"All Files" }, + { IDS_METHOD_STORE, L"Store" }, + { IDS_METHOD_NORMAL, L"Normal" }, + { IDS_METHOD_MAXIMUM, L"Maximum" }, + { IDS_METHOD_FAST, L"Fast" }, + { IDS_METHOD_FASTEST, L"Fastest" }, + { IDS_METHOD_ULTRA, L"Ultra" }, + { IDS_COMPRESS_NON_SOLID, L"Non-solid" }, + { IDS_COMPRESS_SOLID, L"Solid" }, + + { IDS_COMPRESS_UPDATE_MODE_ADD, L"Add and replace files" }, + { IDS_COMPRESS_UPDATE_MODE_UPDATE, L"Update and add files" }, + { IDS_COMPRESS_UPDATE_MODE_FRESH, L"Freshen existing files" }, + { IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE, L"Synchronize files" }, + { IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE, L"Browse" }, + { IDS_COMPRESS_INCORRECT_VOLUME_SIZE, L"Incorrect volume size" }, + { IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE, L"Specified volume size: {0} bytes.\nAre you sure you want to split archive into such volumes?" }, + + { IDS_PASSWORD_USE_ASCII, L"Use only English letters, numbers and special characters (!, #, $, ...) for password." }, + { IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH, L"Passwords do not match" }, + { IDS_PASSWORD_IS_TOO_LONG, L"Password is too long" }, + + { IDS_PROGRESS_COMPRESSING, L"Compressing" }, + { IDS_PROGRESS_TESTING, L"Testing" }, + { IDS_MESSAGE_NO_ERRORS, L"There are no errors" }, + { IDS_FILES_COLON, L"Files:" }, + { IDS_FOLDERS_COLON, L"Folders:" }, + { IDS_SIZE_COLON, L"Size:" }, + { IDS_COMPRESSED_COLON, L"Compressed size:" }, + { IDS_ARCHIVES_COLON, L"Archives:" }, + + /* Extract.rc */ + /**************/ + { IDS_CANNOT_CREATE_FOLDER , L"Cannot create folder '{0}'"}, + { IDS_OPEN_IS_NOT_SUPORTED_ARCHIVE, L"File is not supported archive."}, + + { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC , L"CRC failed in '{0}'. File is broken."}, + { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR , L"Data error in '{0}'. File is broken"}, + { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_UNSUPPORTED_METHOD , L"Unsupported compression method for '{0}'."}, + { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED , L"CRC failed in encrypted file '{0}'. Wrong password?"}, + { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED , L"Data error in encrypted file '{0}'. Wrong password?"}, + + { IDS_EXTRACT_SET_FOLDER , L"Specify a location for extracted files."}, + { IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CANNOT_OPEN_FILE, L"Can not open output file '{0}'."}, + { IDS_PROGRESS_EXTRACTING, L"Extracting" }, + + { IDS_CANT_OPEN_ARCHIVE , L"Can not open file '{0}' as archive"}, + { IDS_CANT_OPEN_ENCRYPTED_ARCHIVE , L"Can not open encrypted archive '{0}'. Wrong password?"}, + + { 0 , 0 } +}; + +REGISTER_STRINGTABLE(g_stringTable) + |