1 // CompressDialog.h
2 
3 #ifndef __COMPRESS_DIALOG_H
4 #define __COMPRESS_DIALOG_H
5 
6 #include "Windows/Control/ComboBox.h"
7 #include "Windows/Control/Dialog.h"
8 #include "Windows/Control/Edit.h"
9 
10 #include "../Common/LoadCodecs.h"
11 #include "../Common/ZipRegistry.h"
12 
13 #include "CompressDialogRes.h"
14 
15 namespace NCompressDialog
16 {
17   namespace NUpdateMode
18   {
19     enum EEnum
20     {
21       kAdd,
22       kUpdate,
23       kFresh,
24       kSynchronize,
25     };
26   }
27   struct CInfo
28   {
29     NUpdateMode::EEnum UpdateMode;
30     bool SolidIsSpecified;
31     bool MultiThreadIsAllowed;
32     UInt64 SolidBlockSize;
33     UInt32 NumThreads;
34 
35     CRecordVector<UInt64> VolumeSizes;
36 
37     UInt32 Level;
38     UString Method;
39     UInt32 Dictionary;
40     bool OrderMode;
41     UInt32 Order;
42     UString Options;
43 
44     UString EncryptionMethod;
45 
46     bool SFXMode;
47     bool OpenShareForWrite;
48 
49 
50     UString ArchiveName; // in: Relative for ; out: abs
51     UString CurrentDirPrefix;
52     bool KeepName;
53 
54     bool GetFullPathName(UString &result) const;
55 
56     int ArchiverInfoIndex;
57 
58     UString Password;
59     bool EncryptHeadersIsAllowed;
60     bool EncryptHeaders;
61 
InitCInfo62     void Init()
63     {
64       Level = Dictionary = Order = UInt32(-1);
65       OrderMode = false;
66       Method.Empty();
67       Options.Empty();
68       EncryptionMethod.Empty();
69     }
CInfoCInfo70     CInfo()
71     {
72       Init();
73     }
74   };
75 }
76 
77 class CCompressDialog: public NWindows::NControl::CModalDialog
78 {
79   NWindows::NControl::CComboBox m_ArchivePath;
80   NWindows::NControl::CComboBox m_Format;
81   NWindows::NControl::CComboBox m_Level;
82   NWindows::NControl::CComboBox m_Method;
83   NWindows::NControl::CComboBox m_Dictionary;
84   NWindows::NControl::CComboBox m_Order;
85   NWindows::NControl::CComboBox m_Solid;
86   NWindows::NControl::CComboBox m_NumThreads;
87   NWindows::NControl::CComboBox m_UpdateMode;
88   NWindows::NControl::CComboBox m_Volume;
89   NWindows::NControl::CDialogChildControl m_Params;
90 
91   NWindows::NControl::CEdit _password1Control;
92   NWindows::NControl::CEdit _password2Control;
93   NWindows::NControl::CComboBox _encryptionMethod;
94 
95   NCompression::CInfo m_RegistryInfo;
96 
97   int m_PrevFormat;
98   void SetArchiveName(const UString &name);
99   int FindRegistryFormat(const UString &name);
100   int FindRegistryFormatAlways(const UString &name);
101 
102   void CheckSFXNameChange();
103   void SetArchiveName2(bool prevWasSFX);
104 
105   int GetStaticFormatIndex();
106 
107   void SetNearestSelectComboBox(NWindows::NControl::CComboBox &comboBox, UInt32 value);
108 
109   void SetLevel();
110 
111   void SetMethod(int keepMethodId = -1);
112   int GetMethodID();
113   UString GetMethodSpec();
114   UString GetEncryptionMethodSpec();
115 
116   bool IsZipFormat();
117 
118   void SetEncryptionMethod();
119 
120   int AddDictionarySize(UInt32 size, bool kilo, bool maga);
121   int AddDictionarySize(UInt32 size);
122 
123   void SetDictionary();
124 
125   UInt32 GetComboValue(NWindows::NControl::CComboBox &c, int defMax = 0);
126 
GetLevel()127   UInt32 GetLevel()  { return GetComboValue(m_Level); }
GetLevelSpec()128   UInt32 GetLevelSpec()  { return GetComboValue(m_Level, 1); }
129   UInt32 GetLevel2();
GetDictionary()130   UInt32 GetDictionary() { return GetComboValue(m_Dictionary); }
GetDictionarySpec()131   UInt32 GetDictionarySpec() { return GetComboValue(m_Dictionary, 1); }
GetOrder()132   UInt32 GetOrder() { return GetComboValue(m_Order); }
GetOrderSpec()133   UInt32 GetOrderSpec() { return GetComboValue(m_Order, 1); }
GetNumThreadsSpec()134   UInt32 GetNumThreadsSpec() { return GetComboValue(m_NumThreads, 1); }
GetNumThreads2()135   UInt32 GetNumThreads2() { UInt32 num = GetNumThreadsSpec(); if (num == UInt32(-1)) num = 1; return num; }
GetBlockSizeSpec()136   UInt32 GetBlockSizeSpec() { return GetComboValue(m_Solid, 1); }
137 
138   int AddOrder(UInt32 size);
139   void SetOrder();
140   bool GetOrderMode();
141 
142   void SetSolidBlockSize();
143   void SetNumThreads();
144 
145   UInt64 GetMemoryUsage(UInt32 dictionary, UInt64 &decompressMemory);
146   UInt64 GetMemoryUsage(UInt64 &decompressMemory);
147   void PrintMemUsage(UINT res, UInt64 value);
148   void SetMemoryUsage();
149   void SetParams();
150   void SaveOptionsInMem();
151 
152   void UpdatePasswordControl();
IsShowPasswordChecked()153   bool IsShowPasswordChecked() const
154     { return IsButtonChecked(IDC_COMPRESS_CHECK_SHOW_PASSWORD) == BST_CHECKED; }
155 
156   int GetFormatIndex();
157 public:
158   CObjectVector<CArcInfoEx> m_ArchiverInfoList;
159 
160   NCompressDialog::CInfo Info;
161   UString OriginalFileName; // for bzip2, gzip2
162 
163   INT_PTR Create(HWND wndParent = 0)
164     { return CModalDialog::Create(IDD_DIALOG_COMPRESS, wndParent); }
165 
166 protected:
167 
168   void CheckSFXControlsEnable();
169   void CheckVolumeEnable();
170   void CheckControlsEnable();
171 
172   void OnButtonSetArchive();
173   bool IsSFX();
174   void OnButtonSFX();
175 
176   virtual bool OnInit();
177   virtual bool OnCommand(int code, int itemID, LPARAM lParam);
178   virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
179   virtual void OnOK();
180   virtual void OnHelp();
181 
182 };
183 
184 #endif
185