diff options
Diffstat (limited to 'CPP/7zip/UI/FileManager')
95 files changed, 2171 insertions, 1569 deletions
diff --git a/CPP/7zip/UI/FileManager/AboutDialog.cpp b/CPP/7zip/UI/FileManager/AboutDialog.cpp index fcdea7e0..a450a765 100755 --- a/CPP/7zip/UI/FileManager/AboutDialog.cpp +++ b/CPP/7zip/UI/FileManager/AboutDialog.cpp @@ -7,7 +7,7 @@ #include "HelpUtils.h" #include "LangUtils.h" -static CIDLangPair kIDLangPairs[] = +static CIDLangPair kIDLangPairs[] = { { IDC_ABOUT_STATIC_REGISTER_INFO, 0x01000103 }, { IDC_ABOUT_BUTTON_SUPPORT, 0x01000104 }, @@ -23,7 +23,7 @@ static LPCTSTR kSupportPageURL = MY_HOME_PAGE TEXT("support.html"); static LPCWSTR kHelpTopic = L"start.htm"; -bool CAboutDialog::OnInit() +bool CAboutDialog::OnInit() { LangSetWindowText(HWND(*this), 0x01000100); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); diff --git a/CPP/7zip/UI/FileManager/App.cpp b/CPP/7zip/UI/FileManager/App.cpp index 4a4dcc96..ec1d2df4 100755 --- a/CPP/7zip/UI/FileManager/App.cpp +++ b/CPP/7zip/UI/FileManager/App.cpp @@ -3,22 +3,26 @@ #include "StdAfx.h" #include "resource.h" +#include "OverwriteDialogRes.h" +#include "Common/IntToString.h" #include "Common/StringConvert.h" -#include "Windows/FileDir.h" -#include "Windows/Error.h" + #include "Windows/COM.h" +#include "Windows/Error.h" +#include "Windows/FileDir.h" +#include "Windows/PropVariant.h" +#include "Windows/PropVariantConversions.h" #include "Windows/Thread.h" -#include "IFolder.h" #include "App.h" - #include "CopyDialog.h" - #include "ExtractCallback.h" -#include "ViewSettings.h" -#include "RegistryUtils.h" +#include "FormatUtils.h" +#include "IFolder.h" #include "LangUtils.h" +#include "RegistryUtils.h" +#include "ViewSettings.h" using namespace NWindows; using namespace NFile; @@ -27,22 +31,23 @@ using namespace NFind; extern DWORD g_ComCtl32Version; extern HINSTANCE g_hInstance; -static LPCWSTR kTempDirPrefix = L"7zE"; +static LPCWSTR kTempDirPrefix = L"7zE"; void CPanelCallbackImp::OnTab() { if (g_App.NumPanels != 1) - _app->Panels[1 - _index].SetFocusToList(); + _app->Panels[1 - _index].SetFocusToList(); _app->RefreshTitle(); } void CPanelCallbackImp::SetFocusToPath(int index) -{ +{ int newPanelIndex = index; if (g_App.NumPanels == 1) newPanelIndex = g_App.LastFocusedPanel; - _app->Panels[newPanelIndex]._headerComboBox.SetFocus(); _app->RefreshTitle(); + _app->Panels[newPanelIndex]._headerComboBox.SetFocus(); + _app->Panels[newPanelIndex]._headerComboBox.ShowDropDown(); } @@ -69,7 +74,7 @@ void CApp::SetListSettings() /* if (ReadSingleClick()) { - extendedStyle |= LVS_EX_ONECLICKACTIVATE + extendedStyle |= LVS_EX_ONECLICKACTIVATE | LVS_EX_TRACKSELECT; if (ReadUnderline()) extendedStyle |= LVS_EX_UNDERLINEHOT; @@ -99,10 +104,10 @@ void CApp::SetShowSystemMenu() ShowSystemMenu = ReadShowSystemMenu(); } -void CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted) +HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted) { if (PanelsCreated[panelIndex]) - return; + return S_OK; m_PanelCallbackImp[panelIndex].Init(this, panelIndex); UString path; if (mainPath.IsEmpty()) @@ -113,9 +118,10 @@ void CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &archive else path = mainPath; int id = 1000 + 100 * panelIndex; - Panels[panelIndex].Create(_window, _window, - id, path, &m_PanelCallbackImp[panelIndex], &AppState, archiveIsOpened, encrypted); + RINOK(Panels[panelIndex].Create(_window, _window, + id, path, &m_PanelCallbackImp[panelIndex], &AppState, archiveIsOpened, encrypted)); PanelsCreated[panelIndex] = true; + return S_OK; } static void CreateToolbar( @@ -124,27 +130,27 @@ static void CreateToolbar( NWindows::NControl::CToolBar &toolBar, bool LargeButtons) { - toolBar.Attach(::CreateWindowEx(0, + toolBar.Attach(::CreateWindowEx(0, TOOLBARCLASSNAME, NULL, 0 | WS_VISIBLE | TBSTYLE_FLAT - | TBSTYLE_TOOLTIPS + | TBSTYLE_TOOLTIPS | WS_CHILD | CCS_NOPARENTALIGN - | CCS_NORESIZE + | CCS_NORESIZE | CCS_NODIVIDER // | TBSTYLE_AUTOSIZE - // | CCS_ADJUSTABLE + // | CCS_ADJUSTABLE ,0,0,0,0, parent, NULL, g_hInstance, NULL)); - // TB_BUTTONSTRUCTSIZE message, which is required for + // TB_BUTTONSTRUCTSIZE message, which is required for // backward compatibility. toolBar.ButtonStructSize(); imageList.Create( - LargeButtons ? 48: 24, - LargeButtons ? 36: 24, + LargeButtons ? 48: 24, + LargeButtons ? 36: 24, ILC_MASK, 0, 0); toolBar.SetImageList(0, imageList); } @@ -154,20 +160,20 @@ struct CButtonInfo UINT commandID; UINT BitmapResID; UINT Bitmap2ResID; - UINT StringResID; + UINT StringResID; UINT32 LangID; UString GetText()const { return LangString(StringResID, LangID); }; }; -static CButtonInfo g_StandardButtons[] = +static CButtonInfo g_StandardButtons[] = { { IDM_COPY_TO, IDB_COPY, IDB_COPY2, IDS_BUTTON_COPY, 0x03020420}, { IDM_MOVE_TO, IDB_MOVE, IDB_MOVE2, IDS_BUTTON_MOVE, 0x03020421}, { IDM_DELETE, IDB_DELETE, IDB_DELETE2, IDS_BUTTON_DELETE, 0x03020422} , - { IDM_FILE_PROPERTIES, IDB_INFO, IDB_INFO2, IDS_BUTTON_INFO, 0x03020423} + { IDM_FILE_PROPERTIES, IDB_INFO, IDB_INFO2, IDS_BUTTON_INFO, 0x03020423} }; -static CButtonInfo g_ArchiveButtons[] = +static CButtonInfo g_ArchiveButtons[] = { { kAddCommand, IDB_ADD, IDB_ADD2, IDS_ADD, 0x03020400}, { kExtractCommand, IDB_EXTRACT, IDB_EXTRACT2, IDS_EXTRACT, 0x03020401}, @@ -190,37 +196,37 @@ bool SetButtonText(UINT32 commandID, CButtonInfo *buttons, int numButtons, UStri void SetButtonText(UINT32 commandID, UString &s) { - if (SetButtonText(commandID, g_StandardButtons, + if (SetButtonText(commandID, g_StandardButtons, sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]), s)) return; - SetButtonText(commandID, g_ArchiveButtons, + SetButtonText(commandID, g_ArchiveButtons, sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]), s); } static void AddButton( NControl::CImageList &imageList, - NControl::CToolBar &toolBar, + NControl::CToolBar &toolBar, CButtonInfo &butInfo, bool showText, bool large) { - TBBUTTON but; - but.iBitmap = 0; - but.idCommand = butInfo.commandID; - but.fsState = TBSTATE_ENABLED; + TBBUTTON but; + but.iBitmap = 0; + but.idCommand = butInfo.commandID; + but.fsState = TBSTATE_ENABLED; but.fsStyle = BTNS_BUTTON - // | BTNS_AUTOSIZE + // | BTNS_AUTOSIZE ; but.dwData = 0; UString s = butInfo.GetText(); but.iString = 0; if (showText) - but.iString = (INT_PTR)(LPCWSTR)s; + but.iString = (INT_PTR)(LPCWSTR)s; but.iBitmap = imageList.GetImageCount(); - HBITMAP b = ::LoadBitmap(g_hInstance, - large ? + HBITMAP b = ::LoadBitmap(g_hInstance, + large ? MAKEINTRESOURCE(butInfo.BitmapResID): MAKEINTRESOURCE(butInfo.Bitmap2ResID)); if (b != 0) @@ -245,7 +251,7 @@ static void AddBand(NControl::CReBar &reBar, NControl::CToolBar &toolBar) REBARBANDINFO rbBand; rbBand.cbSize = sizeof(REBARBANDINFO); // Required - rbBand.fMask = RBBIM_STYLE + rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE; rbBand.fStyle = RBBS_CHILDEDGE; // RBBS_NOGRIPPER; rbBand.cxMinChild = size.cx; // rect.right - rect.left; @@ -258,7 +264,7 @@ static void AddBand(NControl::CReBar &reBar, NControl::CToolBar &toolBar) } void CApp::ReloadToolbars() -{ +{ if (!_rebar) return; HWND parent = _rebar; @@ -276,7 +282,7 @@ void CApp::ReloadToolbars() { CreateToolbar(parent, _archiveButtonsImageList, _archiveToolBar, LargeButtons); for (int i = 0; i < sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]); i++) - AddButton(_archiveButtonsImageList, _archiveToolBar, g_ArchiveButtons[i], + AddButton(_archiveButtonsImageList, _archiveToolBar, g_ArchiveButtons[i], ShowButtonsLables, LargeButtons); AddBand(_rebar, _archiveToolBar); } @@ -285,7 +291,7 @@ void CApp::ReloadToolbars() { CreateToolbar(parent, _standardButtonsImageList, _standardToolBar, LargeButtons); for (int i = 0; i < sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]); i++) - AddButton(_standardButtonsImageList, _standardToolBar, g_StandardButtons[i], + AddButton(_standardButtonsImageList, _standardToolBar, g_StandardButtons[i], ShowButtonsLables, LargeButtons); AddBand(_rebar, _standardToolBar); } @@ -305,16 +311,16 @@ void CApp::ReloadRebar(HWND hwnd) _rebar.Attach(::CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, - NULL, - WS_VISIBLE - | WS_BORDER - | WS_CHILD - | WS_CLIPCHILDREN - | WS_CLIPSIBLINGS - // | CCS_NODIVIDER + NULL, + WS_VISIBLE + | WS_BORDER + | WS_CHILD + | WS_CLIPCHILDREN + | WS_CLIPSIBLINGS + // | CCS_NODIVIDER // | CCS_NOPARENTALIGN // it's bead for moveing of two bands // | CCS_TOP - | RBS_VARHEIGHT + | RBS_VARHEIGHT | RBS_BANDBORDERS // | RBS_AUTOSIZE ,0,0,0,0, hwnd, NULL, g_hInstance, NULL)); @@ -329,7 +335,7 @@ void CApp::ReloadRebar(HWND hwnd) ReloadToolbars(); } -void CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted) +HRESULT CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted) { ReadToolbar(); ReloadRebar(hwnd); @@ -360,7 +366,7 @@ void CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archi bool archiveIsOpened2 = false; bool encrypted2 = false; bool mainPanel = (i == LastFocusedPanel); - CreateOnePanel(i, mainPanel ? mainPath : L"", archiveIsOpened2, encrypted2); + RINOK(CreateOnePanel(i, mainPanel ? mainPath : L"", archiveIsOpened2, encrypted2)); if (mainPanel) { archiveIsOpened = archiveIsOpened2; @@ -369,17 +375,18 @@ void CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archi } SetFocusedPanel(LastFocusedPanel); Panels[LastFocusedPanel].SetFocusToList(); + return S_OK; } extern void MoveSubWindows(HWND hWnd); -void CApp::SwitchOnOffOnePanel() +HRESULT CApp::SwitchOnOffOnePanel() { if (NumPanels == 1) { NumPanels++; bool archiveIsOpened, encrypted; - CreateOnePanel(1 - LastFocusedPanel, UString(), archiveIsOpened, encrypted); + RINOK(CreateOnePanel(1 - LastFocusedPanel, UString(), archiveIsOpened, encrypted)); Panels[1 - LastFocusedPanel].Enable(true); Panels[1 - LastFocusedPanel].Show(SW_SHOWNORMAL); } @@ -390,6 +397,7 @@ void CApp::SwitchOnOffOnePanel() Panels[1 - LastFocusedPanel].Show(SW_HIDE); } MoveSubWindows(_window); + return S_OK; } void CApp::Save() @@ -412,17 +420,17 @@ void CApp::Save() void CApp::Release() { - // It's for unloading COM dll's: don't change it. + // It's for unloading COM dll's: don't change it. for (int i = 0; i < kNumPanelsMax; i++) Panels[i].Release(); } static bool IsThereFolderOfPath(const UString &path) { - CFileInfoW fileInfo; - if (!FindFile(path, fileInfo)) + CFileInfoW fi; + if (!FindFile(path, fi)) return false; - return fileInfo.IsDirectory(); + return fi.IsDir(); } // reduces path to part that exists on disk @@ -470,6 +478,99 @@ static bool IsPathAbsolute(const UString &path) return false; } +extern UString ConvertSizeToString(UInt64 value); + +static UString AddSizeValue(UInt64 size) +{ + return MyFormatNew(IDS_FILE_SIZE, 0x02000982, ConvertSizeToString(size)); +} + +static void AddValuePair1(UINT resourceID, UInt32 langID, UInt64 size, UString &s) +{ + s += LangString(resourceID, langID); + s += L" "; + s += AddSizeValue(size); + s += L"\n"; +} + +void AddValuePair2(UINT resourceID, UInt32 langID, UInt64 num, UInt64 size, UString &s) +{ + if (num == 0) + return; + s += LangString(resourceID, langID); + s += L" "; + s += ConvertSizeToString(num); + + if (size != (UInt64)(Int64)-1) + { + s += L" ( "; + s += AddSizeValue(size); + s += L" )"; + } + s += L"\n"; +} + +static void AddPropValueToSum(IFolderFolder *folder, int index, PROPID propID, UInt64 &sum) +{ + if (sum == (UInt64)(Int64)-1) + return; + NCOM::CPropVariant prop; + folder->GetProperty(index, propID, &prop); + switch(prop.vt) + { + case VT_UI4: + case VT_UI8: + sum += ConvertPropVariantToUInt64(prop); + break; + default: + sum = (UInt64)(Int64)-1; + } +} + +UString CPanel::GetItemsInfoString(const CRecordVector<UInt32> &indices) +{ + UString info; + UInt64 numDirs, numFiles, filesSize, foldersSize; + numDirs = numFiles = filesSize = foldersSize = 0; + int i; + for (i = 0; i < indices.Size(); i++) + { + int index = indices[i]; + if (IsItemFolder(index)) + { + AddPropValueToSum(_folder, index, kpidSize, foldersSize); + numDirs++; + } + else + { + AddPropValueToSum(_folder, index, kpidSize, filesSize); + numFiles++; + } + } + + AddValuePair2(IDS_FOLDERS_COLON, 0x02000321, numDirs, foldersSize, info); + AddValuePair2(IDS_FILES_COLON, 0x02000320, numFiles, filesSize, info); + int numDefined = ((foldersSize != (UInt64)(Int64)-1) && foldersSize != 0) ? 1: 0; + numDefined += ((filesSize != (UInt64)(Int64)-1) && filesSize != 0) ? 1: 0; + if (numDefined == 2) + AddValuePair1(IDS_SIZE_COLON, 0x02000322, filesSize + foldersSize, info); + + info += L"\n"; + info += _currentFolderPrefix; + + for (i = 0; i < indices.Size() && i < kCopyDialog_NumInfoLines - 6; i++) + { + info += L"\n "; + int index = indices[i]; + info += GetItemRelPath(index); + if (IsItemFolder(index)) + info += L'\\'; + } + if (i != indices.Size()) + info += L"\n ..."; + return info; +} + void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) { int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex); @@ -481,7 +582,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) if (!srcPanel.DoesItSupportOperations()) { - srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } @@ -503,7 +604,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) } else { - srcPanel.GetOperatedItemIndices(indices); + srcPanel.GetOperatedIndicesSmart(indices); if (indices.Size() == 0) return; destPath = destPanel._currentFolderPrefix; @@ -518,13 +619,15 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) copyDialog.Strings = copyFolders; copyDialog.Value = destPath; - copyDialog.Title = move ? + copyDialog.Title = move ? LangString(IDS_MOVE, 0x03020202): LangString(IDS_COPY, 0x03020201); - copyDialog.Static = move ? + copyDialog.Static = move ? LangString(IDS_MOVE_TO, 0x03020204): LangString(IDS_COPY_TO, 0x03020203); + copyDialog.Info = srcPanel.GetItemsInfoString(indices); + if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL) return; @@ -532,7 +635,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) if (destPath.IsEmpty()) { - srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } @@ -540,7 +643,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) { if (!srcPanel.IsFSFolder()) { - srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } destPath = srcPanel._currentFolderPrefix + destPath; @@ -549,11 +652,11 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) if (destPath.Length() > 0 && destPath[0] == '\\') if (destPath.Length() == 1 || destPath[1] != '\\') { - srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } - if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind('\\') == destPath.Length() - 1) || + if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind('\\') == destPath.Length() - 1) || IsThereFolderOfPath(destPath)) { NDirectory::CreateComplexDirectory(destPath); @@ -562,7 +665,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) { if (NumPanels < 2 || destPath != destPanel._currentFolderPrefix || !destPanel.DoesItSupportOperations()) { - srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } useDestPanel = true; @@ -577,7 +680,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) NDirectory::CreateComplexDirectory(prefix); if (!CheckFolderPath(prefix)) { - srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } } @@ -688,7 +791,7 @@ void CApp::OnSetSubFolder(int srcPanelIndex) /* - UString string = srcPanel._currentFolderPrefix + + UString string = srcPanel._currentFolderPrefix + srcPanel.GetItemName(realIndex) + L'\\'; destPanel.BindToFolder(string); */ @@ -719,7 +822,7 @@ int CApp::GetFocusedPanelIndex() const return 0; for (int i = 0; i < kNumPanelsMax; i++) { - if (PanelsCreated[i] && + if (PanelsCreated[i] && ((HWND)Panels[i] == hwnd || Panels[i]._listView == hwnd)) return i; } @@ -745,7 +848,7 @@ void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh) } return ; } - else + else { if (pnmh->code == TTN_GETDISPINFO) { @@ -772,7 +875,7 @@ void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh) } void CApp::RefreshTitle(bool always) -{ +{ UString path = GetFocusedPanel()._currentFolderPrefix; if (path.IsEmpty()) path += LangString(IDS_APP_TITLE, 0x03000000); @@ -783,7 +886,7 @@ void CApp::RefreshTitle(bool always) } void CApp::RefreshTitle(int panelIndex, bool always) -{ +{ if (panelIndex != GetFocusedPanelIndex()) return; RefreshTitle(always); diff --git a/CPP/7zip/UI/FileManager/App.h b/CPP/7zip/UI/FileManager/App.h index 2479d81e..d30e1151 100755 --- a/CPP/7zip/UI/FileManager/App.h +++ b/CPP/7zip/UI/FileManager/App.h @@ -16,7 +16,7 @@ const int kNumPanelsMax = 2; extern void MoveSubWindows(HWND hWnd); -enum +enum { kAddCommand = kToolbarStartID, kExtractCommand, @@ -28,10 +28,10 @@ class CPanelCallbackImp: public CPanelCallback CApp *_app; int _index; public: - void Init(CApp *app, int index) - { + void Init(CApp *app, int index) + { _app = app; - _index = index; + _index = index; } virtual void OnTab(); virtual void SetFocusToPath(int index); @@ -42,11 +42,11 @@ public: virtual void DragBegin(); virtual void DragEnd(); virtual void RefreshTitle(bool always); -}; +}; class CApp; -class CDropTarget: +class CDropTarget: public IDropTarget, public CMyUnknownImp { @@ -54,7 +54,7 @@ class CDropTarget: UStringVector m_SourcePaths; int m_SelectionIndex; bool m_DropIsAllowed; // = true, if data contain fillist - bool m_PanelDropIsAllowed; // = false, if current target_panel is source_panel. + bool m_PanelDropIsAllowed; // = false, if current target_panel is source_panel. // check it only if m_DropIsAllowed == true int m_SubFolderIndex; UString m_SubFolderName; @@ -77,22 +77,22 @@ class CDropTarget: public: MY_UNKNOWN_IMP1_MT(IDropTarget) - STDMETHOD(DragEnter)(IDataObject * dataObject, DWORD keyState, + STDMETHOD(DragEnter)(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD *effect); STDMETHOD(DragOver)(DWORD keyState, POINTL pt, DWORD * effect); STDMETHOD(DragLeave)(); - STDMETHOD(Drop)(IDataObject * dataObject, DWORD keyState, + STDMETHOD(Drop)(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD *effect); - CDropTarget(): - TargetPanelIndex(-1), - SrcPanelIndex(-1), - m_IsAppTarget(false), - m_Panel(0), - App(0), - m_PanelDropIsAllowed(false), - m_DropIsAllowed(false), - m_SelectionIndex(-1), + CDropTarget(): + TargetPanelIndex(-1), + SrcPanelIndex(-1), + m_IsAppTarget(false), + m_Panel(0), + App(0), + m_PanelDropIsAllowed(false), + m_DropIsAllowed(false), + m_SelectionIndex(-1), m_SubFolderIndex(-1), m_SetPathIsOK(false) {} @@ -138,18 +138,18 @@ public: void SetFocusedPanel(int index) { - LastFocusedPanel = index; + LastFocusedPanel = index; _dropTargetSpec->TargetPanelIndex = LastFocusedPanel; } void DragBegin(int panelIndex) - { + { _dropTargetSpec->TargetPanelIndex = (NumPanels > 1) ? 1 - panelIndex : panelIndex; _dropTargetSpec->SrcPanelIndex = panelIndex; } void DragEnd() - { + { _dropTargetSpec->TargetPanelIndex = LastFocusedPanel; _dropTargetSpec->SrcPanelIndex = -1; } @@ -159,8 +159,8 @@ public: void OnSetSameFolder(int srcPanelIndex); void OnSetSubFolder(int srcPanelIndex); - void CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted); - void Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted); + HRESULT CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted); + HRESULT Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted); void Read(); void Save(); void Release(); @@ -253,7 +253,7 @@ public: void RefreshView() { GetFocusedPanel().OnReload(); } void RefreshAllPanels() - { + { for (int i = 0; i < NumPanels; i++) { int index = i; @@ -264,7 +264,7 @@ public: } void SetListSettings(); void SetShowSystemMenu(); - void SwitchOnOffOnePanel(); + HRESULT SwitchOnOffOnePanel(); bool GetFlatMode() { return Panels[LastFocusedPanel].GetFlatMode(); } void ChangeFlatMode() { Panels[LastFocusedPanel].ChangeFlatMode(); } @@ -293,41 +293,37 @@ public: SaveToolbarsMask(mask); } void SwitchStandardToolbar() - { + { ShowStandardToolbar = !ShowStandardToolbar; SaveToolbar(); ReloadRebar(g_HWND); MoveSubWindows(_window); } void SwitchArchiveToolbar() - { + { ShowArchiveToolbar = !ShowArchiveToolbar; SaveToolbar(); ReloadRebar(g_HWND); MoveSubWindows(_window); } void SwitchButtonsLables() - { + { ShowButtonsLables = !ShowButtonsLables; SaveToolbar(); ReloadRebar(g_HWND); MoveSubWindows(_window); } void SwitchLargeButtons() - { + { LargeButtons = !LargeButtons; SaveToolbar(); ReloadRebar(g_HWND); MoveSubWindows(_window); } - - void AddToArchive() - { GetFocusedPanel().AddToArchive(); } - void ExtractArchives() - { GetFocusedPanel().ExtractArchives(); } - void TestArchives() - { GetFocusedPanel().TestArchives(); } + void AddToArchive() { GetFocusedPanel().AddToArchive(); } + void ExtractArchives() { GetFocusedPanel().ExtractArchives(); } + void TestArchives() { GetFocusedPanel().TestArchives(); } void OnNotify(int ctrlID, LPNMHDR pnmh); diff --git a/CPP/7zip/UI/FileManager/AppState.h b/CPP/7zip/UI/FileManager/AppState.h index 318c0258..2b2a3e84 100755 --- a/CPP/7zip/UI/FileManager/AppState.h +++ b/CPP/7zip/UI/FileManager/AppState.h @@ -5,7 +5,7 @@ #include "Windows/Synchronization.h" -void inline AddUniqueStringToHead(UStringVector &list, +void inline AddUniqueStringToHead(UStringVector &list, const UString &string) { for(int i = 0; i < list.Size();) diff --git a/CPP/7zip/UI/FileManager/ClassDefs.cpp b/CPP/7zip/UI/FileManager/ClassDefs.cpp index 0b4c9093..5b4401a1 100755 --- a/CPP/7zip/UI/FileManager/ClassDefs.cpp +++ b/CPP/7zip/UI/FileManager/ClassDefs.cpp @@ -13,5 +13,5 @@ #include "../Agent/Agent.h" // {23170F69-40C1-278A-1000-000100020000} -DEFINE_GUID(CLSID_CZipContextMenu, +DEFINE_GUID(CLSID_CZipContextMenu, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00); diff --git a/CPP/7zip/UI/FileManager/ComboDialog.cpp b/CPP/7zip/UI/FileManager/ComboDialog.cpp index 83c142ff..807a5dd2 100755 --- a/CPP/7zip/UI/FileManager/ComboDialog.cpp +++ b/CPP/7zip/UI/FileManager/ComboDialog.cpp @@ -5,23 +5,23 @@ #include "Windows/Control/Static.h" -#ifdef LANG +#ifdef LANG #include "LangUtils.h" #endif using namespace NWindows; -#ifdef LANG -static CIDLangPair kIDLangPairs[] = +#ifdef LANG +static CIDLangPair kIDLangPairs[] = { { IDOK, 0x02000702 }, { IDCANCEL, 0x02000710 } }; #endif -bool CComboDialog::OnInit() +bool CComboDialog::OnInit() { - #ifdef LANG + #ifdef LANG LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif _comboBox.Attach(GetItem(IDC_COMBO_COMBO)); diff --git a/CPP/7zip/UI/FileManager/CopyDialog.cpp b/CPP/7zip/UI/FileManager/CopyDialog.cpp index 77b62ec0..2bf60301 100755 --- a/CPP/7zip/UI/FileManager/CopyDialog.cpp +++ b/CPP/7zip/UI/FileManager/CopyDialog.cpp @@ -9,23 +9,23 @@ #include "Windows/Shell.h" #include "Windows/FileName.h" -#ifdef LANG +#ifdef LANG #include "LangUtils.h" #endif using namespace NWindows; -#ifdef LANG -static CIDLangPair kIDLangPairs[] = +#ifdef LANG +static CIDLangPair kIDLangPairs[] = { { IDOK, 0x02000702 }, { IDCANCEL, 0x02000710 } }; #endif -bool CCopyDialog::OnInit() +bool CCopyDialog::OnInit() { - #ifdef LANG + #ifdef LANG LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif _path.Attach(GetItem(IDC_COPY_COMBO)); @@ -34,9 +34,10 @@ bool CCopyDialog::OnInit() NControl::CStatic staticContol; staticContol.Attach(GetItem(IDC_COPY_STATIC)); staticContol.SetText(Static); - for(int i = 0; i < Strings.Size(); i++) + for (int i = 0; i < Strings.Size(); i++) _path.AddString(Strings[i]); _path.SetText(Value); + SetItemText(IDC_COPY_INFO, Info); return CModalDialog::OnInit(); } @@ -51,13 +52,13 @@ bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND) return CModalDialog::OnButtonClicked(buttonID, buttonHWND); } -void CCopyDialog::OnButtonSetPath() +void CCopyDialog::OnButtonSetPath() { UString currentPath; _path.GetText(currentPath); /* - #ifdef LANG + #ifdef LANG UString title = LangLoadString(IDS_EXTRACT_SET_FOLDER, 0x02000881); #else UString title = MyLoadString(IDS_EXTRACT_SET_FOLDER); diff --git a/CPP/7zip/UI/FileManager/CopyDialog.h b/CPP/7zip/UI/FileManager/CopyDialog.h index ed894bf8..55872f1c 100755 --- a/CPP/7zip/UI/FileManager/CopyDialog.h +++ b/CPP/7zip/UI/FileManager/CopyDialog.h @@ -7,6 +7,8 @@ #include "Windows/Control/ComboBox.h" #include "CopyDialogRes.h" +const int kCopyDialog_NumInfoLines = 11; + class CCopyDialog: public NWindows::NControl::CModalDialog { NWindows::NControl::CComboBox _path; @@ -20,6 +22,8 @@ public: UString Value; UStringVector Strings; + UString Info; + INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COPY, parentWindow); } }; diff --git a/CPP/7zip/UI/FileManager/CopyDialog.rc b/CPP/7zip/UI/FileManager/CopyDialog.rc index bf3aebde..1686adda 100755 --- a/CPP/7zip/UI/FileManager/CopyDialog.rc +++ b/CPP/7zip/UI/FileManager/CopyDialog.rc @@ -1,8 +1,11 @@ #include "CopyDialogRes.h" #include "../../GuiCommon.rc" +#undef infoSize +#define infoSize 100 + #define xSize2 346 -#define ySize2 57 +#define ySize2 (infoSize + 50) #define xSize (xSize2 + marg + marg) #define ySize (ySize2 + marg + marg) @@ -17,12 +20,13 @@ MY_FONT BEGIN LTEXT "", IDC_COPY_STATIC, marg, marg, xSize2, 8 COMBOBOX IDC_COPY_COMBO, marg, 20, xSize2 - bDotsSize - 12, 65, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "...", IDC_COPY_SET_PATH, (xSize - marg - bDotsSize), 20, bDotsSize, 14, WS_GROUP + PUSHBUTTON "...", IDC_COPY_SET_PATH, (xSize - marg - bDotsSize), 20, bDotsSize, 14, WS_GROUP + LTEXT "", IDC_COPY_INFO, marg, bYPos - (infoSize + 2), xSize2, infoSize, SS_NOPREFIX | SS_LEFTNOWORDWRAP DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize END -STRINGTABLE DISCARDABLE +STRINGTABLE DISCARDABLE BEGIN IDS_SET_FOLDER "Specify a location for output folder." END diff --git a/CPP/7zip/UI/FileManager/CopyDialogRes.h b/CPP/7zip/UI/FileManager/CopyDialogRes.h index 7ec6162a..900bf29f 100755 --- a/CPP/7zip/UI/FileManager/CopyDialogRes.h +++ b/CPP/7zip/UI/FileManager/CopyDialogRes.h @@ -3,5 +3,6 @@ #define IDC_COPY_STATIC 1000 #define IDC_COPY_COMBO 1001 #define IDC_COPY_SET_PATH 1002 +#define IDC_COPY_INFO 1003 #define IDS_SET_FOLDER 210 diff --git a/CPP/7zip/UI/FileManager/EditPage.cpp b/CPP/7zip/UI/FileManager/EditPage.cpp index 06bde407..69261eb6 100755 --- a/CPP/7zip/UI/FileManager/EditPage.cpp +++ b/CPP/7zip/UI/FileManager/EditPage.cpp @@ -18,7 +18,7 @@ using namespace NWindows; -static CIDLangPair kIDLangPairs[] = +static CIDLangPair kIDLangPairs[] = { { IDC_EDIT_STATIC_EDITOR, 0x03010201} }; diff --git a/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp b/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp index ef9463fb..291ea1f1 100755 --- a/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp +++ b/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp @@ -5,7 +5,7 @@ #include "EnumFormatEtc.h" #include "MyCom2.h" -class CEnumFormatEtc : +class CEnumFormatEtc : public IEnumFORMATETC, public CMyUnknownImp { @@ -13,7 +13,7 @@ public: MY_UNKNOWN_IMP1_MT(IEnumFORMATETC) STDMETHOD(Next)(ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched); - STDMETHOD(Skip)(ULONG celt); + STDMETHOD(Skip)(ULONG celt); STDMETHOD(Reset)(void); STDMETHOD(Clone)(IEnumFORMATETC **ppEnumFormatEtc); @@ -73,7 +73,7 @@ STDMETHODIMP CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG *pcel copied++; m_Index++; } - if(pceltFetched != 0) + if(pceltFetched != 0) *pceltFetched = copied; return (copied == celt) ? S_OK : S_FALSE; } diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.cpp b/CPP/7zip/UI/FileManager/ExtractCallback.cpp index 7998d5cc..d5f0e867 100755 --- a/CPP/7zip/UI/FileManager/ExtractCallback.cpp +++ b/CPP/7zip/UI/FileManager/ExtractCallback.cpp @@ -4,9 +4,10 @@ #include "ExtractCallback.h" +#include "Windows/Error.h" #include "Windows/FileFind.h" #include "Windows/FileDir.h" -#include "Windows/Error.h" +#include "Windows/ResourceString.h" #include "OverwriteDialog.h" #ifndef _NO_CRYPTO @@ -52,7 +53,7 @@ void CExtractCallbackImp::AddErrorMessage(LPCWSTR message) Messages.Add(message); } -STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64 +STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64 #ifndef _SFX numFiles #endif @@ -72,19 +73,57 @@ STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 total) STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *value) { - for (;;) - { - if(ProgressDialog.ProgressSynch.GetStopped()) - return E_ABORT; - if(!ProgressDialog.ProgressSynch.GetPaused()) - break; - ::Sleep(100); - } + RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); if (value != NULL) ProgressDialog.ProgressSynch.SetPos(*value); return S_OK; } +HRESULT CExtractCallbackImp::Open_CheckBreak() +{ + return ProgressDialog.ProgressSynch.ProcessStopAndPause(); +} + +HRESULT CExtractCallbackImp::Open_SetTotal(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */) +{ + // if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesTotal(*numFiles); + return S_OK; +} + +HRESULT CExtractCallbackImp::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */) +{ + RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); + // if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesCur(*numFiles); + return S_OK; +} + +#ifndef _NO_CRYPTO + +HRESULT CExtractCallbackImp::Open_CryptoGetTextPassword(BSTR *password) +{ + return CryptoGetTextPassword(password); +} + +HRESULT CExtractCallbackImp::Open_GetPasswordIfAny(UString &password) +{ + if (PasswordIsDefined) + password = Password; + return S_OK; +} + +bool CExtractCallbackImp::Open_WasPasswordAsked() +{ + return PasswordWasAsked; +} + +void CExtractCallbackImp::Open_ClearPasswordWasAskedFlag() +{ + PasswordWasAsked = false; +} + +#endif + + #ifndef _SFX STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) { @@ -135,34 +174,20 @@ STDMETHODIMP CExtractCallbackImp::AskOverwrite( dialog.NewFileInfo.Name = newName; /* - NOverwriteDialog::NResult::EEnum writeAnswer = + NOverwriteDialog::NResult::EEnum writeAnswer = NOverwriteDialog::Execute(oldFileInfo, newFileInfo); */ - INT_PTR writeAnswer = dialog.Create(NULL); // ParentWindow doesn't work with 7z + INT_PTR writeAnswer = dialog.Create(ProgressDialog); // ParentWindow doesn't work with 7z switch(writeAnswer) { - case IDCANCEL: - return E_ABORT; - // askResult = NAskOverwriteAnswer::kCancel; - // break; - case IDNO: - *answer = NOverwriteAnswer::kNo; - break; - case IDC_BUTTON_OVERWRITE_NO_TO_ALL: - *answer = NOverwriteAnswer::kNoToAll; - break; - case IDC_BUTTON_OVERWRITE_YES_TO_ALL: - *answer = NOverwriteAnswer::kYesToAll; - break; - case IDC_BUTTON_OVERWRITE_AUTO_RENAME: - *answer = NOverwriteAnswer::kAutoRename; - break; - case IDYES: - *answer = NOverwriteAnswer::kYes; - break; - default: - return E_FAIL; + case IDCANCEL: *answer = NOverwriteAnswer::kCancel; return E_ABORT; + case IDYES: *answer = NOverwriteAnswer::kYes; break; + case IDNO: *answer = NOverwriteAnswer::kNo; break; + case IDC_BUTTON_OVERWRITE_YES_TO_ALL: *answer = NOverwriteAnswer::kYesToAll; break; + case IDC_BUTTON_OVERWRITE_NO_TO_ALL: *answer = NOverwriteAnswer::kNoToAll; break; + case IDC_BUTTON_OVERWRITE_AUTO_RENAME: *answer = NOverwriteAnswer::kAutoRename; break; + default: return E_FAIL; } return S_OK; } @@ -203,13 +228,13 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool langID = 0x02000A91; break; case NArchive::NExtract::NOperationResult::kDataError: - messageID = encrypted ? + messageID = encrypted ? IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED: IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR; langID = encrypted ? 0x02000A94 : 0x02000A92; break; case NArchive::NExtract::NOperationResult::kCRCError: - messageID = encrypted ? + messageID = encrypted ? IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED: IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC; langID = encrypted ? 0x02000A95 : 0x02000A93; @@ -223,10 +248,10 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool _needWriteArchivePath = false; } AddErrorMessage( - MyFormatNew(messageID, - #ifdef LANG - langID, - #endif + MyFormatNew(messageID, + #ifdef LANG + langID, + #endif _currentFilePath)); } } @@ -276,11 +301,32 @@ HRESULT CExtractCallbackImp::OpenResult(const wchar_t *name, HRESULT result, boo { if (result != S_OK) { - MessageError(MyFormatNew(encrypted ? IDS_CANT_OPEN_ENCRYPTED_ARCHIVE : IDS_CANT_OPEN_ARCHIVE, + UString message; + if (result == S_FALSE) + { + message = MyFormatNew(encrypted ? IDS_CANT_OPEN_ENCRYPTED_ARCHIVE : IDS_CANT_OPEN_ARCHIVE, #ifdef LANG (encrypted ? 0x0200060A : 0x02000609), #endif - name)); + name); + } + else + { + message = name; + message += L": "; + UString message2; + if (result == E_OUTOFMEMORY) + message2 = + #ifdef LANG + LangString(IDS_MEM_ERROR, 0x0200060B); + #else + MyLoadStringW(IDS_MEM_ERROR); + #endif + else + NError::MyFormatMessage(result, message2); + message += message2; + } + MessageError(message); NumArchiveErrors++; } _currentArchivePath = name; @@ -314,29 +360,27 @@ HRESULT CExtractCallbackImp::SetPassword(const UString &password) STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password) { + PasswordWasAsked = true; if (!PasswordIsDefined) { CPasswordDialog dialog; - - if (dialog.Create(ParentWindow) == IDCANCEL) + if (dialog.Create(ProgressDialog) == IDCANCEL) return E_ABORT; - Password = dialog.Password; PasswordIsDefined = true; } CMyComBSTR tempName(Password); *password = tempName.Detach(); - return S_OK; } // IExtractCallBack3 STDMETHODIMP CExtractCallbackImp::AskWrite( - const wchar_t *srcPath, Int32 srcIsFolder, + const wchar_t *srcPath, Int32 srcIsFolder, const FILETIME *srcTime, const UInt64 *srcSize, - const wchar_t *destPath, - BSTR *destPathResult, + const wchar_t *destPath, + BSTR *destPathResult, Int32 *writeAnswer) { UString destPathResultTemp = destPath; @@ -357,7 +401,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( { if (srcIsFolderSpec) { - if (!destFileInfo.IsDirectory()) + if (!destFileInfo.IsDir()) { UString message = UString(L"can not replace file \'") + destPathSpec + @@ -368,7 +412,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( *writeAnswer = BoolToInt(false); return S_OK; } - if (destFileInfo.IsDirectory()) + if (destFileInfo.IsDir()) { UString message = UString(L"can not replace folder \'") + destPathSpec + @@ -385,10 +429,10 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( { Int32 overwiteResult; RINOK(AskOverwrite( - destPathSpec, - &destFileInfo.LastWriteTime, &destFileInfo.Size, + destPathSpec, + &destFileInfo.MTime, &destFileInfo.Size, srcPath, - srcTime, srcSize, + srcTime, srcSize, &overwiteResult)); switch(overwiteResult) { @@ -432,7 +476,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( return E_ABORT; } } - CMyComBSTR destPathResultBSTR = destPathResultTemp; + CMyComBSTR destPathResultBSTR(destPathResultTemp); *destPathResult = destPathResultBSTR.Detach(); *writeAnswer = BoolToInt(true); return S_OK; diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.h b/CPP/7zip/UI/FileManager/ExtractCallback.h index 13117871..ee46222a 100755 --- a/CPP/7zip/UI/FileManager/ExtractCallback.h +++ b/CPP/7zip/UI/FileManager/ExtractCallback.h @@ -5,6 +5,7 @@ #include "../Agent/IFolderArchive.h" #include "Common/MyString.h" +#include "../Common/ArchiveOpenCallback.h" #ifdef _SFX #include "ProgressDialog.h" @@ -14,7 +15,7 @@ #include "Windows/ResourceString.h" -#ifdef LANG +#ifdef LANG #include "LangUtils.h" #endif @@ -24,8 +25,9 @@ #include "Common/MyCom.h" #include "IFolder.h" -class CExtractCallbackImp: +class CExtractCallbackImp: public IExtractCallbackUI, + public IOpenCallbackUI, public IFolderOperationsExtractCallback, // public IFolderArchiveExtractCallback, // mkultiple from IProgress #ifndef _SFX @@ -48,14 +50,13 @@ public: MY_QUERYINTERFACE_END MY_ADDREF_RELEASE - // IProgress - STDMETHOD(SetTotal)(UInt64 total); - STDMETHOD(SetCompleted)(const UInt64 *value); - #ifndef _SFX STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); #endif + INTERFACE_IProgress(;) + INTERFACE_IOpenCallbackUI(;) + // IFolderArchiveExtractCallback // STDMETHOD(SetTotalFiles)(UInt64 total); // STDMETHOD(SetCompletedFiles)(const UInt64 *value); @@ -81,12 +82,12 @@ public: // IFolderOperationsExtractCallback STDMETHOD(AskWrite)( - const wchar_t *srcPath, - Int32 srcIsFolder, - const FILETIME *srcTime, + const wchar_t *srcPath, + Int32 srcIsFolder, + const FILETIME *srcTime, const UInt64 *srcSize, - const wchar_t *destPathRequest, - BSTR *destPathResult, + const wchar_t *destPathRequest, + BSTR *destPathResult, Int32 *writeAnswer); STDMETHOD(ShowMessage)(const wchar_t *message); STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath); @@ -128,12 +129,14 @@ public: #ifndef _NO_CRYPTO bool PasswordIsDefined; + bool PasswordWasAsked; UString Password; #endif - CExtractCallbackImp(): + CExtractCallbackImp(): #ifndef _NO_CRYPTO PasswordIsDefined(false), + PasswordWasAsked(false), #endif OverwriteMode(NExtract::NOverwriteMode::kAskBefore), ParentWindow(0), diff --git a/CPP/7zip/UI/FileManager/FM.cpp b/CPP/7zip/UI/FileManager/FM.cpp index 66e5a086..4e5a3724 100755 --- a/CPP/7zip/UI/FileManager/FM.cpp +++ b/CPP/7zip/UI/FileManager/FM.cpp @@ -5,8 +5,8 @@ #include "resource.h" #include "Panel.h" -extern "C" -{ +extern "C" +{ #include "../../../../C/Alloc.h" } @@ -53,6 +53,7 @@ const int kNumDefaultPanels = 1; const int kSplitterWidth = 4; int kSplitterRateMax = 1 << 16; +int kPanelSizeMin = 120; // bool OnMenuCommand(HWND hWnd, int id); @@ -77,7 +78,7 @@ class CSplitterPos int _pos; int _fullWidth; void SetRatioFromPos(HWND hWnd) - { _ratio = (_pos + kSplitterWidth / 2) * kSplitterRateMax / + { _ratio = (_pos + kSplitterWidth / 2) * kSplitterRateMax / MyMax(GetWidth(hWnd), 1); } public: int GetPos() const @@ -89,17 +90,22 @@ public: return rect.right; } void SetRatio(HWND hWnd, int aRatio) - { - _ratio = aRatio; + { + _ratio = aRatio; SetPosFromRatio(hWnd); } void SetPosPure(HWND hWnd, int pos) { int posMax = GetWidth(hWnd) - kSplitterWidth; - if (pos > posMax) - pos = posMax; - if (pos < 0) - pos = 0; + if (posMax < kPanelSizeMin * 2) + pos = posMax / 2; + else + { + if (pos > posMax - kPanelSizeMin) + pos = posMax - kPanelSizeMin; + else if (pos < kPanelSizeMin) + pos = kPanelSizeMin; + } _pos = pos; } void SetPos(HWND hWnd, int pos) @@ -109,23 +115,23 @@ public: SetRatioFromPos(hWnd); } void SetPosFromRatio(HWND hWnd) - { + { int fullWidth = GetWidth(hWnd); - if (_fullWidth != fullWidth) + if (_fullWidth != fullWidth && fullWidth != 0) { _fullWidth = fullWidth; - SetPosPure(hWnd, GetWidth(hWnd) * _ratio / kSplitterRateMax - kSplitterWidth / 2); + SetPosPure(hWnd, GetWidth(hWnd) * _ratio / kSplitterRateMax - kSplitterWidth / 2); } } }; -bool g_CanChangeSplitter = false; -UINT32 g_SplitterPos = 0; -CSplitterPos g_Splitter; -bool g_PanelsInfoDefined = false; +static bool g_CanChangeSplitter = false; +static UINT32 g_SplitterPos = 0; +static CSplitterPos g_Splitter; +static bool g_PanelsInfoDefined = false; -int g_StartCaptureMousePos; -int g_StartCaptureSplitterPos; +static int g_StartCaptureMousePos; +static int g_StartCaptureSplitterPos; CApp g_App; @@ -141,7 +147,7 @@ static bool IsItWindowsNT() { OSVERSIONINFO versionInfo; versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) + if (!::GetVersionEx(&versionInfo)) return false; return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); } @@ -164,11 +170,11 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) /* //If it is already running, then focus on the window hWnd = FindWindow(windowClass, title); - if (hWnd) + if (hWnd) { - SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01)); + SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01)); return 0; - } + } */ WNDCLASSW wc; @@ -237,7 +243,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) placement.length = sizeof(placement); if (wnd.GetPlacement(&placement)) { - if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW || + if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW || nCmdShow == SW_SHOWDEFAULT) { if (maximized) @@ -276,7 +282,7 @@ static void GetCommands(const UString &aCommandLine, UString &aCommands) break; } } - else + else aProgramName += aChar; } aCommands = aCommandLine.Mid(i); @@ -294,7 +300,7 @@ DWORD GetDllVersion(LPCTSTR lpszDllName) pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion"); /*Because some DLLs might not implement this function, you - must test for it explicitly. Depending on the particular + must test for it explicitly. Depending on the particular DLL, the lack of a DllGetVersion function can be a useful indicator of the version. */ @@ -345,7 +351,7 @@ bool IsLargePageSupported() #else OSVERSIONINFO versionInfo; versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) + if (!::GetVersionEx(&versionInfo)) return false; if (versionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || versionInfo.dwMajorVersion < 5) return false; @@ -382,7 +388,7 @@ enum Enum } -static const CSwitchForm kSwitchForms[kNumSwitches] = +static const CSwitchForm kSwitchForms[kNumSwitches] = { { L"SOA", NSwitchType::kSimple, false }, }; @@ -405,7 +411,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* g_ComCtl32Version = ::GetDllVersion(TEXT("comctl32.dll")); // OleInitialize is required for drag and drop. - OleInitialize(NULL); + OleInitialize(NULL); // Maybe needs CoInitializeEx also ? // NCOM::CComInitializer comInitializer; @@ -429,18 +435,18 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* UStringVector commandStrings; NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings); NCommandLineParser::CParser parser(kNumSwitches); - try - { - parser.ParseStrings(kSwitchForms, commandStrings); + try + { + parser.ParseStrings(kSwitchForms, commandStrings); const UStringVector &nonSwitchStrings = parser.NonSwitchStrings; - if(nonSwitchStrings.Size() > 1) + if(nonSwitchStrings.Size() > 1) { g_MainPath = nonSwitchStrings[1]; // g_OpenArchive = parser[NKey::kOpenArachive].ThereIs; CFileInfoW fileInfo; if (FindFile(g_MainPath, fileInfo)) { - if (!fileInfo.IsDirectory()) + if (!fileInfo.IsDir()) g_OpenArchive = true; } } @@ -452,7 +458,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* SetMemoryLock(); MSG msg; - if (!InitInstance (hInstance, nCmdShow)) + if (!InitInstance (hInstance, nCmdShow)) return FALSE; MyLoadMenu(g_HWND); @@ -461,9 +467,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* if (g_IsNT) { HACCEL hAccels = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR1)); - while (GetMessageW(&msg, NULL, 0, 0)) + while (GetMessageW(&msg, NULL, 0, 0)) { - if (TranslateAcceleratorW(g_HWND, hAccels, &msg) == 0) + if (TranslateAcceleratorW(g_HWND, hAccels, &msg) == 0) { TranslateMessage(&msg); DispatchMessageW(&msg); @@ -474,9 +480,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* #endif { HACCEL hAccels = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1)); - while (GetMessage(&msg, NULL, 0, 0)) + while (GetMessage(&msg, NULL, 0, 0)) { - if (TranslateAccelerator(g_HWND, hAccels, &msg) == 0) + if (TranslateAccelerator(g_HWND, hAccels, &msg) == 0) { // if (g_Hwnd != NULL || !IsDialogMessage(g_Hwnd, &msg)) // if (!IsDialogMessage(g_Hwnd, &msg)) @@ -502,9 +508,9 @@ static void SaveWindowInfo(HWND aWnd) placement.length = sizeof(placement); if (!::GetWindowPlacement(aWnd, &placement)) return; - SaveWindowSize(placement.rcNormalPosition, + SaveWindowSize(placement.rcNormalPosition, BOOLToBool(::IsZoomed(aWnd))); - SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel, + SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel, g_Splitter.GetPos()); } @@ -527,11 +533,11 @@ void ExecuteCommand(UINT commandID) LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; - switch (message) + switch (message) { case WM_COMMAND: - wmId = LOWORD(wParam); - wmEvent = HIWORD(wParam); + wmId = LOWORD(wParam); + wmEvent = HIWORD(wParam); if ((HWND) lParam != NULL && wmEvent != 0) break; if (wmId >= kToolbarStartID) @@ -568,7 +574,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) InitCommonControlsEx(&icex); // Toolbar buttons used to create the first 4 buttons. - TBBUTTON tbb [ ] = + TBBUTTON tbb [ ] = { // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0}, // {VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0}, @@ -578,11 +584,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) int baseID = 100; NWindows::NControl::CToolBar aToolBar; - aToolBar.Attach(::CreateToolbarEx (hWnd, - WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS, // | TBSTYLE_FLAT - baseID + 2, 11, - (HINSTANCE)HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR, - (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]), + aToolBar.Attach(::CreateToolbarEx (hWnd, + WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS, // | TBSTYLE_FLAT + baseID + 2, 11, + (HINSTANCE)HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR, + (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]), 0, 0, 100, 30, sizeof (TBBUTTON))); */ // HCURSOR cursor = ::LoadCursor(0, IDC_SIZEWE); @@ -613,18 +619,36 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { NFile::NFind::CFileInfoW fileInfo; if (NFile::NFind::FindFile(g_MainPath, fileInfo)) - if (!fileInfo.IsDirectory()) + if (!fileInfo.IsDir()) needOpenFile = true; } - g_App.Create(hWnd, g_MainPath, xSizes, archiveIsOpened, encrypted); + HRESULT res = g_App.Create(hWnd, g_MainPath, xSizes, archiveIsOpened, encrypted); - if (needOpenFile && !archiveIsOpened) + if (res == E_ABORT) { - UString message; - if (encrypted) - message = MyFormatNew(IDS_CANT_OPEN_ENCRYPTED_ARCHIVE, 0x0200060A, g_MainPath); + return -1; + } + if (needOpenFile && !archiveIsOpened || res != S_OK) + { + UString message = L"Error"; + if (res == S_FALSE || res == S_OK) + { + if (encrypted) + message = MyFormatNew(IDS_CANT_OPEN_ENCRYPTED_ARCHIVE, 0x0200060A, g_MainPath); + else + message = MyFormatNew(IDS_CANT_OPEN_ARCHIVE, 0x02000609, g_MainPath); + } else - message = MyFormatNew(IDS_CANT_OPEN_ARCHIVE, 0x02000609, g_MainPath); + { + if (res != S_OK) + { + if (res == E_OUTOFMEMORY) + message = LangString(IDS_MEM_ERROR, 0x0200060B); + else + if (!NError::MyFormatMessage(res, message)) + message = L"Error"; + } + } MessageBoxW(0, message, L"7-zip", MB_ICONERROR); return -1; } @@ -637,7 +661,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } case WM_DESTROY: { - // ::DragAcceptFiles(hWnd, FALSE); + // ::DragAcceptFiles(hWnd, FALSE); RevokeDragDrop(hWnd); g_App._dropTarget.Release(); @@ -663,11 +687,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ::ReleaseCapture(); break; } - case WM_MOUSEMOVE: + case WM_MOUSEMOVE: { if ((wParam & MK_LBUTTON) != 0 && ::GetCapture() == hWnd) { - g_Splitter.SetPos(hWnd, g_StartCaptureSplitterPos + + g_Splitter.SetPos(hWnd, g_StartCaptureSplitterPos + (short)LOWORD(lParam) - g_StartCaptureMousePos); MoveSubWindows(hWnd); } @@ -704,7 +728,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) /* case WM_ACTIVATE: { - int fActive = LOWORD(wParam); + int fActive = LOWORD(wParam); switch (fActive) { case WA_INACTIVE: @@ -786,6 +810,10 @@ void MoveSubWindows(HWND hWnd) if (g_App._rebar) headerSize = Window_GetRealHeight(g_App._rebar); int ySize = MyMax((int)(rect.bottom - headerSize), 0); + + // It's for such case: Minimize / Close: + if (xSize == 0 && ySize == 0) + return; if (g_App.NumPanels > 1) { diff --git a/CPP/7zip/UI/FileManager/FM.dsp b/CPP/7zip/UI/FileManager/FM.dsp index d2284325..8a3ddc83 100755 --- a/CPP/7zip/UI/FileManager/FM.dsp +++ b/CPP/7zip/UI/FileManager/FM.dsp @@ -947,6 +947,10 @@ SOURCE=..\..\..\Windows\Thread.h # End Source File # Begin Source File +SOURCE=..\..\..\Windows\Time.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\Windows\Time.h # End Source File # Begin Source File diff --git a/CPP/7zip/UI/FileManager/FSDrives.cpp b/CPP/7zip/UI/FileManager/FSDrives.cpp index 42540287..6fd8d708 100755 --- a/CPP/7zip/UI/FileManager/FSDrives.cpp +++ b/CPP/7zip/UI/FileManager/FSDrives.cpp @@ -23,16 +23,16 @@ using namespace NWindows; using namespace NFile; using namespace NFind; -static const STATPROPSTG kProperties[] = +static const STATPROPSTG kProperties[] = { { NULL, kpidName, VT_BSTR}, - // { NULL, kpidIsFolder, VT_BOOL}, + // { NULL, kpidIsDir, VT_BOOL}, { L"Total Size", kpidTotalSize, VT_UI8}, { L"Free Space", kpidFreeSpace, VT_UI8}, { NULL, kpidType, VT_BSTR}, { L"Label", kpidVolumeName, VT_BSTR}, { L"File system", kpidFileSystem, VT_BSTR}, - { L"Cluster Size", kpidClusterSize, VT_UI8} + { L"Cluster Size", kpidClusterSize, VT_UI8} }; static const wchar_t *kDriveTypes[] = @@ -54,31 +54,31 @@ STDMETHODIMP CFSDrives::LoadItems() MyGetLogicalDriveStrings(driveStrings); for (int i = 0; i < driveStrings.Size(); i++) { - CDriveInfo driveInfo; + CDriveInfo di; const UString &driveName = driveStrings[i]; - driveInfo.FullSystemName = driveName; + di.FullSystemName = driveName; - driveInfo.Name = driveInfo.FullSystemName.Left( - driveInfo.FullSystemName.Length() - 1); - driveInfo.ClusterSize = 0; - driveInfo.DriveSize = 0; - driveInfo.FreeSpace = 0; + di.Name = di.FullSystemName.Left( + di.FullSystemName.Length() - 1); + di.ClusterSize = 0; + di.DriveSize = 0; + di.FreeSpace = 0; UINT driveType = NFile::NSystem::MyGetDriveType(driveName); if (driveType < sizeof(kDriveTypes) / sizeof(kDriveTypes[0])) { - driveInfo.Type = kDriveTypes[driveType]; + di.Type = kDriveTypes[driveType]; } bool needRead = true; if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE) { /* DWORD dwSerialNumber;` - if (!::GetVolumeInformation(driveInfo.FullSystemName, - NULL, 0, &dwSerialNumber, NULL, NULL, NULL, 0)) + if (!::GetVolumeInformation(di.FullSystemName, + NULL, 0, &dwSerialNumber, NULL, NULL, NULL, 0)) */ - driveInfo.KnownSizes = false; + di.KnownSizes = false; { needRead = false; } @@ -87,18 +87,18 @@ STDMETHODIMP CFSDrives::LoadItems() { UString volumeName, fileSystemName; DWORD volumeSerialNumber, maximumComponentLength, fileSystemFlags; - NFile::NSystem::MyGetVolumeInformation(driveName, + NFile::NSystem::MyGetVolumeInformation(driveName, volumeName, - &volumeSerialNumber, &maximumComponentLength, &fileSystemFlags, + &volumeSerialNumber, &maximumComponentLength, &fileSystemFlags, fileSystemName); - driveInfo.VolumeName = volumeName; - driveInfo.FileSystemName = fileSystemName; + di.VolumeName = volumeName; + di.FileSystemName = fileSystemName; NFile::NSystem::MyGetDiskFreeSpace(driveName, - driveInfo.ClusterSize, driveInfo.DriveSize, driveInfo.FreeSpace); - driveInfo.KnownSizes = true; + di.ClusterSize, di.DriveSize, di.FreeSpace); + di.KnownSizes = true; } - _drives.Add(driveInfo); + _drives.Add(di); } return S_OK; } @@ -113,39 +113,20 @@ STDMETHODIMP CFSDrives::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT { if (itemIndex >= (UInt32)_drives.Size()) return E_INVALIDARG; - NCOM::CPropVariant propVariant; - const CDriveInfo &driveInfo = _drives[itemIndex]; + NCOM::CPropVariant prop; + const CDriveInfo &di = _drives[itemIndex]; switch(propID) { - case kpidIsFolder: - propVariant = true; - break; - case kpidName: - propVariant = driveInfo.Name; - break; - case kpidTotalSize: - if (driveInfo.KnownSizes) - propVariant = driveInfo.DriveSize; - break; - case kpidFreeSpace: - if (driveInfo.KnownSizes) - propVariant = driveInfo.FreeSpace; - break; - case kpidClusterSize: - if (driveInfo.KnownSizes) - propVariant = driveInfo.ClusterSize; - break; - case kpidType: - propVariant = driveInfo.Type; - break; - case kpidVolumeName: - propVariant = driveInfo.VolumeName; - break; - case kpidFileSystem: - propVariant = driveInfo.FileSystemName; - break; + case kpidIsDir: prop = true; break; + case kpidName: prop = di.Name; break; + case kpidTotalSize: if (di.KnownSizes) prop = di.DriveSize; break; + case kpidFreeSpace: if (di.KnownSizes) prop = di.FreeSpace; break; + case kpidClusterSize: if (di.KnownSizes) prop = di.ClusterSize; break; + case kpidType: prop = di.Type; break; + case kpidVolumeName: prop = di.VolumeName; break; + case kpidFileSystem: prop = di.FileSystemName; break; } - propVariant.Detach(value); + prop.Detach(value); return S_OK; } @@ -164,17 +145,17 @@ STDMETHODIMP CFSDrives::BindToFolder(UInt32 index, IFolderFolder **resultFolder) *resultFolder = 0; if (index >= (UInt32)_drives.Size()) return E_INVALIDARG; - const CDriveInfo &driveInfo = _drives[index]; + const CDriveInfo &di = _drives[index]; if (_volumeMode) { *resultFolder = 0; CPhysDriveFolder *folderSpec = new CPhysDriveFolder; CMyComPtr<IFolderFolder> subFolder = folderSpec; - RINOK(folderSpec->Init(driveInfo.Name)); + RINOK(folderSpec->Init(di.Name)); *resultFolder = subFolder.Detach(); return S_OK; } - return BindToFolderSpec(driveInfo.FullSystemName, resultFolder); + return BindToFolderSpec(di.FullSystemName, resultFolder); } STDMETHODIMP CFSDrives::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder) @@ -194,7 +175,7 @@ STDMETHODIMP CFSDrives::GetNumberOfProperties(UInt32 *numProperties) return S_OK; } -STDMETHODIMP CFSDrives::GetPropertyInfo(UInt32 index, +STDMETHODIMP CFSDrives::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) { if (index >= sizeof(kProperties) / sizeof(kProperties[0])) @@ -224,9 +205,9 @@ STDMETHODIMP CFSDrives::GetFolderProperty(PROPID propID, PROPVARIANT *value) STDMETHODIMP CFSDrives::GetSystemIconIndex(UInt32 index, INT32 *iconIndex) { *iconIndex = 0; - const CDriveInfo &driveInfo = _drives[index]; + const CDriveInfo &di = _drives[index]; int iconIndexTemp; - if (GetRealIconIndex(driveInfo.FullSystemName, 0, iconIndexTemp) != 0) + if (GetRealIconIndex(di.FullSystemName, 0, iconIndexTemp) != 0) { *iconIndex = iconIndexTemp; return S_OK; diff --git a/CPP/7zip/UI/FileManager/FSDrives.h b/CPP/7zip/UI/FileManager/FSDrives.h index 527c2438..84db5b7e 100755 --- a/CPP/7zip/UI/FileManager/FSDrives.h +++ b/CPP/7zip/UI/FileManager/FSDrives.h @@ -24,7 +24,7 @@ struct CDriveInfo UString FileSystemName; }; -class CFSDrives: +class CFSDrives: public IFolderFolder, public IFolderGetSystemIconIndex, public CMyUnknownImp diff --git a/CPP/7zip/UI/FileManager/FSFolder.cpp b/CPP/7zip/UI/FileManager/FSFolder.cpp index aeb3b333..a3e4787a 100755 --- a/CPP/7zip/UI/FileManager/FSFolder.cpp +++ b/CPP/7zip/UI/FileManager/FSFolder.cpp @@ -32,16 +32,16 @@ using namespace NFind; namespace NFsFolder { -static STATPROPSTG kProperties[] = +static STATPROPSTG kProperties[] = { { NULL, kpidName, VT_BSTR}, - // { NULL, kpidIsFolder, VT_BOOL}, + // { NULL, kpidIsDir, VT_BOOL}, { NULL, kpidSize, VT_UI8}, - { NULL, kpidLastWriteTime, VT_FILETIME}, - { NULL, kpidCreationTime, VT_FILETIME}, - { NULL, kpidLastAccessTime, VT_FILETIME}, - { NULL, kpidAttributes, VT_UI4}, - { NULL, kpidPackedSize, VT_UI8}, + { NULL, kpidMTime, VT_FILETIME}, + { NULL, kpidCTime, VT_FILETIME}, + { NULL, kpidATime, VT_FILETIME}, + { NULL, kpidAttrib, VT_UI4}, + { NULL, kpidPackSize, VT_UI8}, { NULL, kpidComment, VT_BSTR}, { NULL, kpidPrefix, VT_BSTR} }; @@ -51,8 +51,8 @@ HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder) _parentFolder = parentFolder; _path = path; - _findChangeNotification.FindFirst(_path, false, - FILE_NOTIFY_CHANGE_FILE_NAME | + _findChangeNotification.FindFirst(_path, false, + FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_SIZE | @@ -79,7 +79,7 @@ HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, CFileInfoW fileInfo; while (enumerator.Next(fileInfo)) { - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) { UInt64 subFolders, subFiles, subSize; RINOK(GetFolderSize(path + UString(L"\\") + fileInfo.Name, subFolders, subFiles, subSize, progress)); @@ -106,11 +106,11 @@ HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path) { fileInfo.CompressedSizeIsDefined = false; /* - if (!GetCompressedFileSize(_path + fileInfo.Name, + if (!GetCompressedFileSize(_path + fileInfo.Name, fileInfo.CompressedSize)) fileInfo.CompressedSize = fileInfo.Size; */ - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) { // fileInfo.Size = GetFolderSize(_path + fileInfo.Name); fileInfo.Size = 0; @@ -124,7 +124,7 @@ HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path) for (int i = 0; i < dirItem.Files.Size(); i++) { CDirItem &item = dirItem.Files[i]; - if (item.IsDirectory()) + if (item.IsDir()) LoadSubItems(item, path + item.Name + L'\\'); } return S_OK; @@ -144,7 +144,7 @@ void CFSFolder::AddRefs(CDirItem &dirItem) for (i = 0; i < dirItem.Files.Size(); i++) { CDirItem &item = dirItem.Files[i]; - if (item.IsDirectory()) + if (item.IsDir()) AddRefs(item); } } @@ -233,7 +233,7 @@ STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders) { UInt32 numSubFoldersLoc = 0; for (int i = 0; i < _files.Size(); i++) - if (_files[i].IsDirectory()) + if (_files[i].IsDir()) numSubFoldersLoc++; *numSubFolders = numSubFoldersLoc; return S_OK; @@ -262,61 +262,47 @@ bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size) STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) { - NCOM::CPropVariant propVariant; + NCOM::CPropVariant prop; if (itemIndex >= (UInt32)_refs.Size()) return E_INVALIDARG; CDirItem &fileInfo = *_refs[itemIndex]; switch(propID) { - case kpidIsFolder: - propVariant = fileInfo.IsDirectory(); - break; - case kpidName: - propVariant = fileInfo.Name; - break; - case kpidSize: - propVariant = fileInfo.Size; - break; - case kpidPackedSize: + case kpidIsDir: prop = fileInfo.IsDir(); break; + case kpidName: prop = fileInfo.Name; break; + case kpidSize: if (!fileInfo.IsDir()) prop = fileInfo.Size; break; + case kpidPackSize: if (!fileInfo.CompressedSizeIsDefined) { fileInfo.CompressedSizeIsDefined = true; - if (fileInfo.IsDirectory () || + if (fileInfo.IsDir () || !MyGetCompressedFileSizeW(_path + GetRelPath(fileInfo), fileInfo.CompressedSize)) fileInfo.CompressedSize = fileInfo.Size; } - propVariant = fileInfo.CompressedSize; - break; - case kpidAttributes: - propVariant = (UInt32)fileInfo.Attributes; - break; - case kpidCreationTime: - propVariant = fileInfo.CreationTime; - break; - case kpidLastAccessTime: - propVariant = fileInfo.LastAccessTime; - break; - case kpidLastWriteTime: - propVariant = fileInfo.LastWriteTime; + prop = fileInfo.CompressedSize; break; + case kpidAttrib: prop = (UInt32)fileInfo.Attrib; break; + case kpidCTime: prop = fileInfo.CTime; break; + case kpidATime: prop = fileInfo.ATime; break; + case kpidMTime: prop = fileInfo.MTime; break; case kpidComment: { LoadComments(); UString comment; if (_comments.GetValue(GetRelPath(fileInfo), comment)) - propVariant = comment; + prop = comment; break; } case kpidPrefix: { if (_flatMode) { - propVariant = GetPrefix(fileInfo); + prop = GetPrefix(fileInfo); } break; } } - propVariant.Detach(value); + prop.Detach(value); return S_OK; } @@ -351,7 +337,7 @@ STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder) { *resultFolder = 0; const CDirItem &fileInfo = *_refs[index]; - if (!fileInfo.IsDirectory()) + if (!fileInfo.IsDir()) return E_INVALIDARG; return BindToFolderSpec(GetRelPath(fileInfo), resultFolder); } @@ -414,7 +400,7 @@ STDMETHODIMP CFSFolder::GetNumberOfProperties(UInt32 *numProperties) return S_OK; } -STDMETHODIMP CFSFolder::GetPropertyInfo(UInt32 index, +STDMETHODIMP CFSFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) { if (index >= sizeof(kProperties) / sizeof(kProperties[0])) @@ -459,7 +445,7 @@ STDMETHODIMP CFSFolder::WasChanged(INT32 *wasChanged) _findChangeNotification.FindNext(); wasChangedMain = true; } - else + else break; } *wasChanged = BoolToInt(wasChangedMain); @@ -475,7 +461,7 @@ STDMETHODIMP CFSFolder::Clone(IFolderFolder **resultFolder) return S_OK; } -HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, +HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress) { numFiles = numFolders = size = 0; @@ -486,7 +472,7 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, if (index >= _refs.Size()) return E_INVALIDARG; const CDirItem &fileInfo = *_refs[index]; - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) { UInt64 subFolders, subFiles, subSize; RINOK(GetFolderSize(_path + GetRelPath(fileInfo), subFolders, subFiles, subSize, progress)); @@ -507,7 +493,7 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress) { const CDirItem &fileInfo = *_refs[index]; - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) { /* CMyComPtr<IFolderFolder> subFolder; @@ -516,7 +502,7 @@ HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress) subFolder.QueryInterface(&aFolderReload); aFolderReload->Reload(); UInt32 numItems; - RINOK(subFolder->GetNumberOfItems(&numItems)); + RINOK(subFolder->GetNumberOfItems(&numItems)); CMyComPtr<IFolderGetItemFullSize> aGetItemFullSize; subFolder.QueryInterface(&aGetItemFullSize); for (UInt32 i = 0; i < numItems; i++) @@ -535,13 +521,13 @@ HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress) STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress) { - NCOM::CPropVariant propVariant; + NCOM::CPropVariant prop; if (index >= (UInt32)_refs.Size()) return E_INVALIDARG; UInt64 size = 0; HRESULT result = GetItemFullSize(index, size, progress); - propVariant = size; - propVariant.Detach(value); + prop = size; + prop.Detach(value); return result; } @@ -603,7 +589,7 @@ STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress const CDirItem &fileInfo = *_refs[indices[i]]; const UString fullPath = _path + GetRelPath(fileInfo); bool result; - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) result = NDirectory::RemoveDirectoryWithSubItems(fullPath); else result = NDirectory::DeleteFileAlways(fullPath); @@ -615,7 +601,7 @@ STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress return S_OK; } -STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID, +STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress * /* progress */) { if (index >= (UInt32)_refs.Size()) @@ -661,7 +647,7 @@ STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex) const CDirItem &fileInfo = *_refs[index]; *iconIndex = 0; int iconIndexTemp; - if (GetRealIconIndex(_path + GetRelPath(fileInfo), fileInfo.Attributes, iconIndexTemp) != 0) + if (GetRealIconIndex(_path + GetRelPath(fileInfo), fileInfo.Attrib, iconIndexTemp) != 0) { *iconIndex = iconIndexTemp; return S_OK; diff --git a/CPP/7zip/UI/FileManager/FSFolder.h b/CPP/7zip/UI/FileManager/FSFolder.h index d938969f..ca229055 100755 --- a/CPP/7zip/UI/FileManager/FSFolder.h +++ b/CPP/7zip/UI/FileManager/FSFolder.h @@ -37,7 +37,7 @@ struct CDirItem: public CFileInfoEx } }; -class CFSFolder: +class CFSFolder: public IFolderFolder, public IFolderWasChanged, public IFolderOperations, @@ -87,7 +87,7 @@ private: NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification; - HRESULT GetItemsFullSize(const UInt32 *indices, UInt32 numItems, + HRESULT GetItemsFullSize(const UInt32 *indices, UInt32 numItems, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress); HRESULT GetItemFullSize(int index, UInt64 &size, IProgress *progress); HRESULT GetComplexName(const wchar_t *name, UString &resultPath); diff --git a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp index 32823fb9..8818b6a9 100755 --- a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp +++ b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp @@ -27,7 +27,7 @@ static bool IsItWindows2000orHigher() { OSVERSIONINFO versionInfo; versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) + if (!::GetVersionEx(&versionInfo)) return false; return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) && (versionInfo.dwMajorVersion >= 5); @@ -78,7 +78,7 @@ typedef BOOL (WINAPI * CopyFileExPointerW)( ); #ifndef _UNICODE -static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; } +static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; } static CSysString GetSysPath(LPCWSTR sysPath) { return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); } #endif @@ -194,7 +194,7 @@ static HRESULT MyCopyFile( RINOK(callback->AskWrite( srcPath, BoolToInt(false), - &srcFileInfo.LastWriteTime, &srcFileInfo.Size, + &srcFileInfo.MTime, &srcFileInfo.Size, destPath, &destPathResult, &writeAskResult)); @@ -205,8 +205,8 @@ static HRESULT MyCopyFile( if (!MyCopyFile(srcPath, destPathNew, callback, completedSize)) { UString message = NError::MyFormatMessageW(GetLastError()) + - UString(L" \'") + - UString(destPathNew) + + UString(L" \'") + + UString(destPathNew) + UString(L"\'"); RINOK(callback->ShowMessage(message)); return E_ABORT; @@ -230,7 +230,7 @@ static HRESULT CopyFolder( { if (destPath.Length() == len || destPath[len] == L'\\') { - UString message = UString(L"can not copy folder \'") + + UString message = UString(L"can not copy folder \'") + destPath + UString(L"\' onto itself"); RINOK(callback->ShowMessage(message)); return E_ABORT; @@ -249,7 +249,7 @@ static HRESULT CopyFolder( { const UString srcPath2 = srcPath + UString(L"\\") + fileInfo.Name; const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name; - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) { RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize)); } @@ -261,7 +261,7 @@ static HRESULT CopyFolder( return S_OK; } -STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems, +STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems, const wchar_t *path, IFolderOperationsExtractCallback *callback) { if (numItems == 0) @@ -287,7 +287,7 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems, if (!NDirectory::CreateComplexDirectory(destPath))) { DWORD lastError = ::GetLastError(); - UString message = UString(L"can not create folder ") + + UString message = UString(L"can not create folder ") + destPath; RINOK(callback->ShowMessage(message)); return E_ABORT; @@ -303,7 +303,7 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems, if (!directName) destPath2 += fileInfo.Name; UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name; - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) { RINOK(CopyFolder(srcPath, destPath2, callback, completedSize)); } @@ -340,8 +340,8 @@ HRESULT MyMoveFile( RINOK(callback->AskWrite( srcPath, BoolToInt(false), - &srcFileInfo.LastWriteTime, &srcFileInfo.Size, - destPath, + &srcFileInfo.MTime, &srcFileInfo.Size, + destPath, &destPathResult, &writeAskResult)); if (IntToBool(writeAskResult)) @@ -371,7 +371,7 @@ HRESULT MyMoveFolder( { if (destPath.Length() == len || destPath[len] == L'\\') { - UString message = UString(L"can not move folder \'") + + UString message = UString(L"can not move folder \'") + destPath + UString(L"\' onto itself"); RINOK(callback->ShowMessage(message)); return E_ABORT; @@ -394,7 +394,7 @@ HRESULT MyMoveFolder( { const UString srcPath2 = srcPath + UString(L"\\") + fileInfo.Name; const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name; - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) { RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize)); } @@ -414,8 +414,8 @@ HRESULT MyMoveFolder( } STDMETHODIMP CFSFolder::MoveTo( - const UInt32 *indices, - UInt32 numItems, + const UInt32 *indices, + UInt32 numItems, const wchar_t *path, IFolderOperationsExtractCallback *callback) { @@ -439,7 +439,7 @@ STDMETHODIMP CFSFolder::MoveTo( else if (!NDirectory::CreateComplexDirectory(destPath)) { - UString message = UString(L"can not create folder ") + + UString message = UString(L"can not create folder ") + destPath; RINOK(callback->ShowMessage(message)); return E_ABORT; @@ -454,7 +454,7 @@ STDMETHODIMP CFSFolder::MoveTo( if (!directName) destPath2 += fileInfo.Name; UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name; - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) { RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize)); } @@ -480,7 +480,7 @@ STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */, CFileInfoW fileInfo; if (!FindFile(path, fileInfo)) return ::GetLastError(); - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) { UInt64 subFolders, subFiles, subSize; RINOK(GetFolderSize(path + UString(L"\\") + fileInfo.Name, subFolders, subFiles, subSize, progress)); diff --git a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp index a3a19414..f93c0943 100755 --- a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp +++ b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp @@ -2,11 +2,14 @@ #include "StdAfx.h" +#include "resource.h" + #include "Common/StringConvert.h" #include "Windows/Defs.h" #include "Windows/FileDir.h" #include "Windows/FileName.h" #include "Windows/DLL.h" +#include "Windows/Thread.h" #include "IFolder.h" #include "RegistryAssociations.h" @@ -14,12 +17,37 @@ #include "OpenCallback.h" #include "PluginLoader.h" +#include "LangUtils.h" #include "../Agent/Agent.h" using namespace NWindows; using namespace NRegistryAssociations; -static int FindPlugin(const CObjectVector<CPluginInfo> &plugins, +struct CThreadArchiveOpen +{ + UString Path; + CMyComPtr<IFolderManager> FolderManager; + CMyComPtr<IProgress> OpenCallback; + COpenArchiveCallback *OpenCallbackSpec; + + CMyComPtr<IFolderFolder> Folder; + HRESULT Result; + + void Process() + { + OpenCallbackSpec->ProgressDialog.WaitCreating(); + Result = FolderManager->OpenFolderFile(Path, &Folder, OpenCallback); + OpenCallbackSpec->ProgressDialog.MyClose(); + } + + static THREAD_FUNC_DECL MyThreadFunction(void *param) + { + ((CThreadArchiveOpen *)param)->Process(); + return 0; + } +}; + +static int FindPlugin(const CObjectVector<CPluginInfo> &plugins, const UString &pluginName) { for (int i = 0; i < plugins.Size(); i++) @@ -29,13 +57,12 @@ static int FindPlugin(const CObjectVector<CPluginInfo> &plugins, } HRESULT OpenFileFolderPlugin( - const UString &path, + const UString &path, HMODULE *module, - IFolderFolder **resultFolder, - HWND parentWindow, - bool &encrypted) + IFolderFolder **resultFolder, + HWND parentWindow, + bool &encrypted, UString &password) { - encrypted = false; CObjectVector<CPluginInfo> plugins; ReadFileFolderPluginInfoList(plugins); @@ -82,33 +109,50 @@ HRESULT OpenFileFolderPlugin( if (!plugin.ClassIDDefined) continue; CPluginLibrary library; - CMyComPtr<IFolderManager> folderManager; - CMyComPtr<IFolderFolder> folder; + + CThreadArchiveOpen t; + if (plugin.FilePath.IsEmpty()) - folderManager = new CArchiveFolderManager; - else if (library.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &folderManager) != S_OK) + t.FolderManager = new CArchiveFolderManager; + else if (library.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &t.FolderManager) != S_OK) continue; - COpenArchiveCallback *openCallbackSpec = new COpenArchiveCallback; - CMyComPtr<IProgress> openCallback = openCallbackSpec; - openCallbackSpec->PasswordIsDefined = false; - openCallbackSpec->ParentWindow = parentWindow; - openCallbackSpec->LoadFileInfo(dirPrefix, fileName); - HRESULT result = folderManager->OpenFolderFile(path, &folder, openCallback); - if (openCallbackSpec->PasswordWasAsked) - encrypted = true; - if (result == S_OK) + t.OpenCallbackSpec = new COpenArchiveCallback; + t.OpenCallback = t.OpenCallbackSpec; + t.OpenCallbackSpec->PasswordIsDefined = encrypted; + t.OpenCallbackSpec->Password = password; + t.OpenCallbackSpec->ParentWindow = parentWindow; + t.OpenCallbackSpec->LoadFileInfo(dirPrefix, fileName); + + t.Path = path; + + UString progressTitle = LangString(IDS_OPENNING, 0x03020283); + t.OpenCallbackSpec->ProgressDialog.MainWindow = parentWindow; + t.OpenCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000); + t.OpenCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" "); + + NWindows::CThread thread; + if (thread.Create(CThreadArchiveOpen::MyThreadFunction, &t) != S_OK) + throw 271824; + t.OpenCallbackSpec->StartProgressDialog(progressTitle); + + if (t.Result == E_ABORT) + return t.Result; + + if (t.Result == S_OK) { + // if (openCallbackSpec->PasswordWasAsked) + { + encrypted = t.OpenCallbackSpec->PasswordIsDefined; + password = t.OpenCallbackSpec->Password; + } *module = library.Detach(); - *resultFolder = folder.Detach(); + *resultFolder = t.Folder.Detach(); return S_OK; } - continue; - - /* - if (result != S_FALSE) - return result; - */ + + if (t.Result != S_FALSE) + return t.Result; } return S_FALSE; }
\ No newline at end of file diff --git a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h index 295048a9..9e5c66c7 100755 --- a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h +++ b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h @@ -3,7 +3,7 @@ #ifndef __FILEFOLDERPLUGINOPEN_H #define __FILEFOLDERPLUGINOPEN_H -HRESULT OpenFileFolderPlugin(const UString &path, - HMODULE *module, IFolderFolder **resultFolder, HWND parentWindow, bool &encrypted); +HRESULT OpenFileFolderPlugin(const UString &path, + HMODULE *module, IFolderFolder **resultFolder, HWND parentWindow, bool &encrypted, UString &password); #endif diff --git a/CPP/7zip/UI/FileManager/FilePlugins.cpp b/CPP/7zip/UI/FileManager/FilePlugins.cpp index 1812312e..173eeffa 100755 --- a/CPP/7zip/UI/FileManager/FilePlugins.cpp +++ b/CPP/7zip/UI/FileManager/FilePlugins.cpp @@ -57,7 +57,7 @@ void CExtDatabase::Read() if (pluginInfo.FilePath.IsEmpty()) folderManager = new CArchiveFolderManager; - else if (pluginLibrary.LoadAndCreateManager(pluginInfo.FilePath, + else if (pluginLibrary.LoadAndCreateManager(pluginInfo.FilePath, pluginInfo.ClassID, &folderManager) != S_OK) continue; CMyComBSTR extBSTR; diff --git a/CPP/7zip/UI/FileManager/FormatUtils.cpp b/CPP/7zip/UI/FileManager/FormatUtils.cpp index 553d8bcd..98bb043e 100755 --- a/CPP/7zip/UI/FileManager/FormatUtils.cpp +++ b/CPP/7zip/UI/FileManager/FormatUtils.cpp @@ -24,17 +24,17 @@ UString MyFormatNew(const UString &format, const UString &argument) return result; } -UString MyFormatNew(UINT resourceID, +UString MyFormatNew(UINT resourceID, #ifdef LANG - UInt32 langID, + UInt32 langID, #endif const UString &argument) { return MyFormatNew( #ifdef LANG - LangString(resourceID, langID), + LangString(resourceID, langID), #else - NWindows::MyLoadStringW(resourceID), + NWindows::MyLoadStringW(resourceID), #endif argument); } diff --git a/CPP/7zip/UI/FileManager/FormatUtils.h b/CPP/7zip/UI/FileManager/FormatUtils.h index 35536871..70a44434 100755 --- a/CPP/7zip/UI/FileManager/FormatUtils.h +++ b/CPP/7zip/UI/FileManager/FormatUtils.h @@ -9,9 +9,9 @@ UString NumberToString(UInt64 number); UString MyFormatNew(const UString &format, const UString &argument); -UString MyFormatNew(UINT resourceID, +UString MyFormatNew(UINT resourceID, #ifdef LANG - UInt32 langID, + UInt32 langID, #endif const UString &argument); diff --git a/CPP/7zip/UI/FileManager/IFolder.h b/CPP/7zip/UI/FileManager/IFolder.h index fdd9fa3c..6709cd1e 100755 --- a/CPP/7zip/UI/FileManager/IFolder.h +++ b/CPP/7zip/UI/FileManager/IFolder.h @@ -10,7 +10,7 @@ namespace NPlugin { - enum + enum { kName = 0, kType, @@ -45,12 +45,12 @@ FOLDER_INTERFACE_SUB(IFolderOperationsExtractCallback, IProgress, 0x0B) // STDMETHOD(SetTotalFiles)(UInt64 total) PURE; // STDMETHOD(SetCompletedFiles)(const UInt64 *completedValue) PURE; STDMETHOD(AskWrite)( - const wchar_t *srcPath, - Int32 srcIsFolder, - const FILETIME *srcTime, + const wchar_t *srcPath, + Int32 srcIsFolder, + const FILETIME *srcTime, const UInt64 *srcSize, - const wchar_t *destPathRequest, - BSTR *destPathResult, + const wchar_t *destPathRequest, + BSTR *destPathResult, Int32 *writeAnswer) PURE; STDMETHOD(ShowMessage)(const wchar_t *message) PURE; STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath) PURE; diff --git a/CPP/7zip/UI/FileManager/LangPage.cpp b/CPP/7zip/UI/FileManager/LangPage.cpp index 3300213b..264872f6 100755 --- a/CPP/7zip/UI/FileManager/LangPage.cpp +++ b/CPP/7zip/UI/FileManager/LangPage.cpp @@ -12,7 +12,7 @@ #include "HelpUtils.h" #include "LangUtils.h" -static CIDLangPair kIDLangPairs[] = +static CIDLangPair kIDLangPairs[] = { { IDC_LANG_STATIC_LANG, 0x01000401} }; @@ -40,7 +40,7 @@ bool CLangPage::OnInit() for (int i = 0; i < langs.Size(); i++) { const CLangEx &lang = langs[i]; - UString name; + UString name; UString englishName, nationalName; if (lang.Lang.GetMessage(0x00000000, englishName)) name = englishName; diff --git a/CPP/7zip/UI/FileManager/LangPage.h b/CPP/7zip/UI/FileManager/LangPage.h index b28d6984..64825b8e 100755 --- a/CPP/7zip/UI/FileManager/LangPage.h +++ b/CPP/7zip/UI/FileManager/LangPage.h @@ -9,7 +9,7 @@ class CLangPage: public NWindows::NControl::CPropertyPage { NWindows::NControl::CComboBox _langCombo; - UStringVector _paths; + UStringVector _paths; public: bool _langWasChanged; virtual bool OnInit(); diff --git a/CPP/7zip/UI/FileManager/LangUtils.cpp b/CPP/7zip/UI/FileManager/LangUtils.cpp index bf75df00..0591c73c 100755 --- a/CPP/7zip/UI/FileManager/LangUtils.cpp +++ b/CPP/7zip/UI/FileManager/LangUtils.cpp @@ -27,13 +27,13 @@ void ReloadLang() if (!g_LangID.IsEmpty() && g_LangID != L"-") { UString langPath = g_LangID; - if (langPath.Find('\\') < 0) + if (langPath.Find(WCHAR_PATH_SEPARATOR) < 0) { - if (langPath.Find('.') < 0) + if (langPath.Find(L'.') < 0) langPath += L".txt"; UString folderPath; if (GetProgramFolderPath(folderPath)) - langPath = folderPath + UString(L"Lang\\") + langPath; + langPath = folderPath + UString(L"Lang" WSTRING_PATH_SEPARATOR) + langPath; } g_Lang.Open(langPath); } @@ -94,12 +94,12 @@ void LoadLangs(CObjectVector<CLangEx> &langs) UString folderPath; if (!::GetProgramFolderPath(folderPath)) return; - folderPath += L"Lang\\"; + folderPath += L"Lang" WSTRING_PATH_SEPARATOR; NWindows::NFile::NFind::CEnumeratorW enumerator(folderPath + L"*.txt"); NWindows::NFile::NFind::CFileInfoW fileInfo; while (enumerator.Next(fileInfo)) { - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) continue; CLangEx lang; UString filePath = folderPath + fileInfo.Name; diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.cpp b/CPP/7zip/UI/FileManager/ListViewDialog.cpp index 67423501..7a78fcde 100755 --- a/CPP/7zip/UI/FileManager/ListViewDialog.cpp +++ b/CPP/7zip/UI/FileManager/ListViewDialog.cpp @@ -3,18 +3,18 @@ #include "StdAfx.h" #include "ListViewDialog.h" -#ifdef LANG +#ifdef LANG #include "LangUtils.h" -static CIDLangPair kIDLangPairs[] = +static CIDLangPair kIDLangPairs[] = { { IDOK, 0x02000702 }, { IDCANCEL, 0x02000710 } }; #endif -bool CListViewDialog::OnInit() +bool CListViewDialog::OnInit() { - #ifdef LANG + #ifdef LANG LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif _listView.Attach(GetItem(IDC_LISTVIEW_LIST)); @@ -28,15 +28,9 @@ bool CListViewDialog::OnInit() _listView.InsertColumn(0, &columnInfo); - for(int i = 0; i < Strings.Size(); i++) - { - LVITEMW item; - item.mask = LVIF_TEXT; - item.iItem = i; - item.pszText = (LPWSTR)(LPCWSTR)Strings[i]; - item.iSubItem = 0; - _listView.InsertItem(&item); - } + for (int i = 0; i < Strings.Size(); i++) + _listView.InsertItem(i, Strings[i]); + if (Strings.Size() > 0) _listView.SetItemState(0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); StringsWereChanged = false; diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.rc b/CPP/7zip/UI/FileManager/ListViewDialog.rc index e83f3330..cb456534 100755 --- a/CPP/7zip/UI/FileManager/ListViewDialog.rc +++ b/CPP/7zip/UI/FileManager/ListViewDialog.rc @@ -16,7 +16,7 @@ IDD_DIALOG_LISTVIEW DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE CAPTION "ListView" MY_FONT BEGIN - CONTROL "List1", IDC_LISTVIEW_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS | + CONTROL "List1", IDC_LISTVIEW_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP, marg, marg, xSize2, ySize2 - bYSize - 10 DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.cpp b/CPP/7zip/UI/FileManager/MessagesDialog.cpp index 57879d64..201c0bae 100755 --- a/CPP/7zip/UI/FileManager/MessagesDialog.cpp +++ b/CPP/7zip/UI/FileManager/MessagesDialog.cpp @@ -6,14 +6,14 @@ #include "Common/IntToString.h" #include "Windows/ResourceString.h" -#ifdef LANG +#ifdef LANG #include "LangUtils.h" #endif using namespace NWindows; -#ifdef LANG -static CIDLangPair kIDLangPairs[] = +#ifdef LANG +static CIDLangPair kIDLangPairs[] = { { IDOK, 0x02000713 } }; @@ -22,20 +22,10 @@ static CIDLangPair kIDLangPairs[] = void CMessagesDialog::AddMessageDirect(LPCWSTR message) { int itemIndex = _messageList.GetItemCount(); - LVITEMW item; - item.mask = LVIF_TEXT; - item.iItem = itemIndex; - wchar_t sz[32]; ConvertInt64ToString(itemIndex, sz); - - item.pszText = sz; - item.iSubItem = 0; - _messageList.InsertItem(&item); - - item.pszText = (LPWSTR)message; - item.iSubItem = 1; - _messageList.SetItem(&item); + _messageList.InsertItem(itemIndex, sz); + _messageList.SetSubItem(itemIndex, 1, message); } void CMessagesDialog::AddMessage(LPCWSTR message) @@ -52,39 +42,25 @@ void CMessagesDialog::AddMessage(LPCWSTR message) AddMessageDirect(s); } -bool CMessagesDialog::OnInit() +bool CMessagesDialog::OnInit() { - #ifdef LANG + #ifdef LANG LangSetWindowText(HWND(*this), 0x02000A00); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif _messageList.Attach(GetItem(IDC_MESSAGE_LIST)); _messageList.SetUnicodeFormat(true); - LVCOLUMNW columnInfo; - columnInfo.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; - columnInfo.fmt = LVCFMT_LEFT; - columnInfo.pszText = L"#"; - columnInfo.iSubItem = 0; - columnInfo.cx = 30; - - _messageList.InsertColumn(0, &columnInfo); - - - columnInfo.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; - columnInfo.fmt = LVCFMT_LEFT; - UString s = - #ifdef LANG - LangString(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, 0x02000A80); - #else - MyLoadStringW(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN); - #endif + _messageList.InsertColumn(0, L"#", 30); - columnInfo.pszText = (LPWSTR)(LPCWSTR)s; - columnInfo.iSubItem = 1; - columnInfo.cx = 600; + const UString s = + #ifdef LANG + LangString(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, 0x02000A80); + #else + MyLoadStringW(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN); + #endif - _messageList.InsertColumn(1, &columnInfo); + _messageList.InsertColumn(1, s, 600); for(int i = 0; i < Messages->Size(); i++) AddMessage((*Messages)[i]); diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.rc b/CPP/7zip/UI/FileManager/MessagesDialog.rc index fdefb172..bf1c56b0 100755 --- a/CPP/7zip/UI/FileManager/MessagesDialog.rc +++ b/CPP/7zip/UI/FileManager/MessagesDialog.rc @@ -15,7 +15,7 @@ MY_FONT BEGIN DEFPUSHBUTTON "&Close", IDOK, bXPos, bYPos, bXSize, bYSize CONTROL "List1",IDC_MESSAGE_LIST,"SysListView32", - LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, + LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, marg, marg, xSize2, ySize2 - bYSize - 6 END diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp index 4ad152b1..c6f57f9e 100755 --- a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp +++ b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp @@ -41,7 +41,7 @@ struct CStringLangPair UINT32 LangID; }; -static CStringLangPair kStringLangPairs[] = +static CStringLangPair kStringLangPairs[] = { { L"&File", 0x03000102 }, { L"&Edit", 0x03000103 }, @@ -57,7 +57,7 @@ UINT32 kToolbarsLangID = 0x03000451; /* static int FindStringLangItem(const UString &anItem) { - for (int i = 0; i < sizeof(kStringLangPairs) / + for (int i = 0; i < sizeof(kStringLangPairs) / sizeof(kStringLangPairs[0]); i++) if (anItem.CompareNoCase(kStringLangPairs[i].String) == 0) return i; @@ -65,7 +65,7 @@ static int FindStringLangItem(const UString &anItem) } */ -static CIDLangPair kIDLangPairs[] = +static CIDLangPair kIDLangPairs[] = { // File { IDM_FILE_OPEN, 0x03000210 }, @@ -151,9 +151,9 @@ public: g_IsNew_fMask = false; OSVERSIONINFO vi; vi.dwOSVersionInfoSize = sizeof(vi); - if (::GetVersionEx(&vi)) + if (::GetVersionEx(&vi)) { - g_IsNew_fMask = (vi.dwMajorVersion > 4 || + g_IsNew_fMask = (vi.dwMajorVersion > 4 || (vi.dwMajorVersion == 4 && vi.dwMinorVersion > 0)); } g_IsNew_fMask = false; @@ -217,7 +217,7 @@ static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex) } else { - if (level == 0 && i < sizeof(kStringLangPairs) / + if (level == 0 && i < sizeof(kStringLangPairs) / sizeof(kStringLangPairs[0])) newString = LangString(kStringLangPairs[i].LangID); else @@ -339,7 +339,7 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position) // View; CMenu menu; menu.Attach(hMenu); - menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS, + menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS, IDM_VIEW_LARGE_ICONS + g_App.GetListViewMode(), MF_BYCOMMAND); menu.CheckItem(IDM_VIEW_TWO_PANELS, MF_BYCOMMAND | ((g_App.NumPanels == 2) ? MF_CHECKED : MF_UNCHECKED)); @@ -413,7 +413,8 @@ void OnMenuUnActivating(HWND hWnd) */ -void LoadFileMenu(HMENU hMenu, int startPos, bool /* forFileMode */, bool programMenu) +void LoadFileMenu(HMENU hMenu, int startPos, bool programMenu, + bool isFsFolder, int numItems, bool allAreFiles) { { CMenu srcMenu; @@ -439,6 +440,10 @@ void LoadFileMenu(HMENU hMenu, int startPos, bool /* forFileMode */, bool progra if (!programMenu) if (item.wID == IDCLOSE) continue; + bool isOneFsFile = (isFsFolder && numItems == 1 && allAreFiles); + if ((item.wID == IDM_FILE_SPLIT || item.wID == IDM_FILE_COMBINE) && !isOneFsFile) + item.fState |= MFS_DISABLED; + /* bool createItem = (item.wID == IDM_CREATE_FOLDER || item.wID == IDM_CREATE_FILE); if (forFileMode) @@ -538,7 +543,7 @@ bool ExecuteFileCommand(int id) break; default: return false; - } + } return true; } @@ -607,7 +612,7 @@ bool OnMenuCommand(HWND hWnd, int id) /* CMenu menu; menu.Attach(::GetSubMenu(::GetMenu(hWnd), kViewMenuIndex)); - menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS, + menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS, id, MF_BYCOMMAND); */ } @@ -625,7 +630,7 @@ bool OnMenuCommand(HWND hWnd, int id) } case IDM_VIEW_ARANGE_BY_DATE: { - g_App.SortItemsWithPropID(kpidLastWriteTime); + g_App.SortItemsWithPropID(kpidMTime); break; } case IDM_VIEW_ARANGE_BY_SIZE: diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.h b/CPP/7zip/UI/FileManager/MyLoadMenu.h index 490dc6d8..83c1d24f 100755 --- a/CPP/7zip/UI/FileManager/MyLoadMenu.h +++ b/CPP/7zip/UI/FileManager/MyLoadMenu.h @@ -10,7 +10,8 @@ void OnMenuActivating(HWND hWnd, HMENU hMenu, int position); void MyLoadMenu(HWND hWnd); bool OnMenuCommand(HWND hWnd, int id); void MyLoadMenu(); -void LoadFileMenu(HMENU hMenu, int startPos, bool forFileMode, bool programMenu); +void LoadFileMenu(HMENU hMenu, int startPos, bool programMenu, + bool isFsFolder, int numItems, bool allAreFiles); bool ExecuteFileCommand(int id); #endif diff --git a/CPP/7zip/UI/FileManager/NetFolder.cpp b/CPP/7zip/UI/FileManager/NetFolder.cpp index 7bd5d2e5..e03a06c5 100755 --- a/CPP/7zip/UI/FileManager/NetFolder.cpp +++ b/CPP/7zip/UI/FileManager/NetFolder.cpp @@ -16,7 +16,7 @@ using namespace NWindows; using namespace NNet; -static const STATPROPSTG kProperties[] = +static const STATPROPSTG kProperties[] = { { NULL, kpidName, VT_BSTR}, { NULL, kpidLocalName, VT_BSTR}, @@ -63,7 +63,7 @@ void CNetFolder::Init(const UString &path) return; } -void CNetFolder::Init(const NWindows::NNet::CResourceW *netResource, +void CNetFolder::Init(const NWindows::NNet::CResourceW *netResource, IFolderFolder *parentFolder, const UString &path) { _path = path; @@ -105,7 +105,7 @@ STDMETHODIMP CNetFolder::LoadItems() } for (;;) - { + { CResourceEx resource; DWORD result = enumerator.Next(resource); if (result == NO_ERROR) @@ -123,7 +123,7 @@ STDMETHODIMP CNetFolder::LoadItems() } else if (result == ERROR_NO_MORE_ITEMS) break; - else + else return result; } @@ -162,31 +162,20 @@ STDMETHODIMP CNetFolder::GetNumberOfItems(UInt32 *numItems) STDMETHODIMP CNetFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) { - NCOM::CPropVariant propVariant; + NCOM::CPropVariant prop; const CResourceEx &item = _items[itemIndex]; switch(propID) { - case kpidIsFolder: - propVariant = true; - break; + case kpidIsDir: prop = true; break; case kpidName: // if (item.RemoteNameIsDefined) - propVariant = item.Name; - break; - case kpidLocalName: - if (item.LocalNameIsDefined) - propVariant = item.LocalName; - break; - case kpidComment: - if (item.CommentIsDefined) - propVariant = item.Comment; - break; - case kpidProvider: - if (item.ProviderIsDefined) - propVariant = item.Provider; + prop = item.Name; break; + case kpidLocalName: if (item.LocalNameIsDefined) prop = item.LocalName; break; + case kpidComment: if (item.CommentIsDefined) prop = item.Comment; break; + case kpidProvider: if (item.ProviderIsDefined) prop = item.Provider; break; } - propVariant.Detach(value); + prop.Detach(value); return S_OK; } @@ -194,7 +183,7 @@ STDMETHODIMP CNetFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder { *resultFolder = 0; const CResourceEx &resource = _items[index]; - if (resource.Usage == RESOURCEUSAGE_CONNECTABLE || + if (resource.Usage == RESOURCEUSAGE_CONNECTABLE || resource.DisplayType == RESOURCEDISPLAYTYPE_SHARE) { NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder; @@ -249,7 +238,7 @@ STDMETHODIMP CNetFolder::GetNumberOfProperties(UInt32 *numProperties) return S_OK; } -STDMETHODIMP CNetFolder::GetPropertyInfo(UInt32 index, +STDMETHODIMP CNetFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) { if (index >= sizeof(kProperties) / sizeof(kProperties[0])) @@ -280,7 +269,7 @@ STDMETHODIMP CNetFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex) *iconIndex = 0; const CResourceW &resource = _items[index]; int iconIndexTemp; - if (resource.DisplayType == RESOURCEDISPLAYTYPE_SERVER || + if (resource.DisplayType == RESOURCEDISPLAYTYPE_SERVER || resource.Usage == RESOURCEUSAGE_CONNECTABLE) { if (GetRealIconIndex(resource.RemoteName, 0, iconIndexTemp)) diff --git a/CPP/7zip/UI/FileManager/NetFolder.h b/CPP/7zip/UI/FileManager/NetFolder.h index 0214cfdb..92471ec6 100755 --- a/CPP/7zip/UI/FileManager/NetFolder.h +++ b/CPP/7zip/UI/FileManager/NetFolder.h @@ -16,7 +16,7 @@ struct CResourceEx: public NWindows::NNet::CResourceW UString Name; }; -class CNetFolder: +class CNetFolder: public IFolderFolder, public IFolderGetSystemIconIndex, public CMyUnknownImp @@ -41,7 +41,7 @@ private: public: void Init(const UString &path); - void Init(const NWindows::NNet::CResourceW *netResource, + void Init(const NWindows::NNet::CResourceW *netResource, IFolderFolder *parentFolder, const UString &path); CNetFolder(): _netResourcePointer(0) {} }; diff --git a/CPP/7zip/UI/FileManager/OpenCallback.cpp b/CPP/7zip/UI/FileManager/OpenCallback.cpp index 70ec3f39..be40fc1c 100755 --- a/CPP/7zip/UI/FileManager/OpenCallback.cpp +++ b/CPP/7zip/UI/FileManager/OpenCallback.cpp @@ -11,69 +11,80 @@ #include "PasswordDialog.h" -STDMETHODIMP COpenArchiveCallback::SetTotal(const UINT64 * /* numFiles */, const UINT64 * /* numBytes */) +STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 *numFiles, const UInt64 *numBytes) { + { + NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + _numFilesTotalDefined = (numFiles != NULL); + _numBytesTotalDefined = (numBytes != NULL); + if (_numFilesTotalDefined) + { + ProgressDialog.ProgressSynch.SetNumFilesTotal(*numFiles); + ProgressDialog.ProgressSynch.SetProgress(*numFiles, 0); + } + else if (_numBytesTotalDefined) + ProgressDialog.ProgressSynch.SetProgress(*numBytes, 0); + } return S_OK; } -STDMETHODIMP COpenArchiveCallback::SetCompleted(const UINT64 * /* numFiles */, const UINT64 * /* numBytes */) +STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *numFiles, const UInt64 *numBytes) { + NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); + if (numFiles != NULL) + { + ProgressDialog.ProgressSynch.SetNumFilesCur(*numFiles); + if (_numFilesTotalDefined) + ProgressDialog.ProgressSynch.SetPos(*numFiles); + } + if (numBytes != NULL && _numBytesTotalDefined) + ProgressDialog.ProgressSynch.SetPos(*numBytes); return S_OK; } -STDMETHODIMP COpenArchiveCallback::SetTotal(const UINT64 /* total */) +STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 total) { + ProgressDialog.ProgressSynch.SetProgress(total, 0); return S_OK; } -STDMETHODIMP COpenArchiveCallback::SetCompleted(const UINT64 * /* completed */) +STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *completed) { + RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); + if (completed != NULL) + ProgressDialog.ProgressSynch.SetPos(*completed); return S_OK; } STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value) { - NWindows::NCOM::CPropVariant propVariant; + NWindows::NCOM::CPropVariant prop; if (_subArchiveMode) { switch(propID) { - case kpidName: - propVariant = _subArchiveName; - break; + case kpidName: prop = _subArchiveName; break; } - propVariant.Detach(value); - return S_OK; } - switch(propID) + else { - case kpidName: - propVariant = _fileInfo.Name; - break; - case kpidIsFolder: - propVariant = _fileInfo.IsDirectory(); - break; - case kpidSize: - propVariant = _fileInfo.Size; - break; - case kpidAttributes: - propVariant = (UINT32)_fileInfo.Attributes; - break; - case kpidLastAccessTime: - propVariant = _fileInfo.LastAccessTime; - break; - case kpidCreationTime: - propVariant = _fileInfo.CreationTime; - break; - case kpidLastWriteTime: - propVariant = _fileInfo.LastWriteTime; - break; + switch(propID) + { + case kpidName: prop = _fileInfo.Name; break; + case kpidIsDir: prop = _fileInfo.IsDir(); break; + case kpidSize: prop = _fileInfo.Size; break; + case kpidAttrib: prop = (UInt32)_fileInfo.Attrib; break; + case kpidCTime: prop = _fileInfo.CTime; break; + case kpidATime: prop = _fileInfo.ATime; break; + case kpidMTime: prop = _fileInfo.MTime; break; + } } - propVariant.Detach(value); + prop.Detach(value); return S_OK; } -STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, +STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **inStream) { *inStream = NULL; @@ -86,7 +97,7 @@ STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, if (!NWindows::NFile::NFind::FindFile(fullPath, fileInfo)) return S_FALSE; _fileInfo = fileInfo; - if (_fileInfo.IsDirectory()) + if (_fileInfo.IsDir()) return S_FALSE; CInFileStream *inFile = new CInFileStream; CMyComPtr<IInStream> inStreamTemp = inFile; @@ -103,7 +114,7 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password) { CPasswordDialog dialog; - if (dialog.Create(ParentWindow) == IDCANCEL) + if (dialog.Create(ProgressDialog) == IDCANCEL) return E_ABORT; Password = dialog.Password; diff --git a/CPP/7zip/UI/FileManager/OpenCallback.h b/CPP/7zip/UI/FileManager/OpenCallback.h index 15b50168..168f171b 100755 --- a/CPP/7zip/UI/FileManager/OpenCallback.h +++ b/CPP/7zip/UI/FileManager/OpenCallback.h @@ -11,7 +11,15 @@ #include "../../Archive/IArchive.h" -class COpenArchiveCallback: + +#ifdef _SFX +#include "ProgressDialog.h" +#else +#include "ProgressDialog2.h" +#endif + + +class COpenArchiveCallback: public IArchiveOpenCallback, public IArchiveOpenVolumeCallback, public IArchiveOpenSetSubArchiveName, @@ -21,6 +29,11 @@ class COpenArchiveCallback: { UString _folderPrefix; NWindows::NFile::NFind::CFileInfoW _fileInfo; + + bool _numFilesTotalDefined; + bool _numBytesTotalDefined; + NWindows::NSynchronization::CCriticalSection _criticalSection; + public: bool PasswordIsDefined; UString Password; @@ -31,6 +44,8 @@ public: UString _subArchiveName; public: + CProgressDialog ProgressDialog; + MY_UNKNOWN_IMP5( IArchiveOpenCallback, IArchiveOpenVolumeCallback, @@ -38,17 +53,9 @@ public: IProgress, ICryptoGetTextPassword) - // IProgress - STDMETHOD(SetTotal)(UINT64 total); - STDMETHOD(SetCompleted)(const UINT64 *completeValue); - - // IArchiveOpenCallback - STDMETHOD(SetTotal)(const UINT64 *numFiles, const UINT64 *numBytes); - STDMETHOD(SetCompleted)(const UINT64 *numFiles, const UINT64 *numBytes); - - // IArchiveOpenVolumeCallback - STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value); - STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream); + INTERFACE_IProgress(;) + INTERFACE_IArchiveOpenCallback(;) + INTERFACE_IArchiveOpenVolumeCallback(;) // ICryptoGetTextPassword STDMETHOD(CryptoGetTextPassword)(BSTR *password); @@ -60,8 +67,12 @@ public: return S_OK; } - COpenArchiveCallback() + COpenArchiveCallback(): + ParentWindow(0) { + _numFilesTotalDefined = false; + _numBytesTotalDefined = false; + _subArchiveMode = false; PasswordIsDefined = false; PasswordWasAsked = false; @@ -79,7 +90,13 @@ public: if (!NWindows::NFile::NFind::FindFile(_folderPrefix + fileName, _fileInfo)) throw 1; } - void ShowMessage(const UINT64 *completed); + void ShowMessage(const UInt64 *completed); + + INT_PTR StartProgressDialog(const UString &title) + { + return ProgressDialog.Create(title, ParentWindow); + } + }; #endif diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.cpp b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp index 442df929..42c63266 100755 --- a/CPP/7zip/UI/FileManager/OverwriteDialog.cpp +++ b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp @@ -15,14 +15,14 @@ // #include "../resource.h" -#ifdef LANG +#ifdef LANG #include "LangUtils.h" #endif using namespace NWindows; -#ifdef LANG -static CIDLangPair kIDLangPairs[] = +#ifdef LANG +static CIDLangPair kIDLangPairs[] = { { IDC_STATIC_OVERWRITE_HEADER, 0x02000901}, { IDC_STATIC_OVERWRITE_QUESTION_BEGIN, 0x02000902 }, @@ -36,14 +36,14 @@ static CIDLangPair kIDLangPairs[] = }; #endif -void COverwriteDialog::SetFileInfoControl(int textID, int iconID, - const NOverwriteDialog::CFileInfo &fileInfo) +void COverwriteDialog::SetFileInfoControl(int textID, int iconID, + const NOverwriteDialog::CFileInfo &fileInfo) { UString sizeString; if (fileInfo.SizeIsDefined) - sizeString = MyFormatNew(IDS_FILE_SIZE, - #ifdef LANG - 0x02000982, + sizeString = MyFormatNew(IDS_FILE_SIZE, + #ifdef LANG + 0x02000982, #endif NumberToString(fileInfo.Size)); @@ -64,13 +64,13 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID, if (fileInfo.TimeIsDefined) { UString timeString; - FILETIME localFileTime; + FILETIME localFileTime; if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime)) throw 4190402; timeString = ConvertFileTimeToString(localFileTime); - fullString += - #ifdef LANG + fullString += + #ifdef LANG LangString(IDS_FILE_MODIFIED, 0x02000983); #else MyLoadStringW(IDS_FILE_MODIFIED); @@ -86,8 +86,8 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID, SHFILEINFO shellFileInfo; if (::SHGetFileInfo( - GetSystemString(fileInfo.Name), FILE_ATTRIBUTE_NORMAL, &shellFileInfo, - sizeof(shellFileInfo), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_LARGEICON)) + GetSystemString(fileInfo.Name), FILE_ATTRIBUTE_NORMAL, &shellFileInfo, + sizeof(shellFileInfo), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_LARGEICON)) { NControl::CStatic staticContol; staticContol.Attach(GetItem(iconID)); @@ -95,21 +95,21 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID, } } -bool COverwriteDialog::OnInit() +bool COverwriteDialog::OnInit() { - #ifdef LANG + #ifdef LANG LangSetWindowText(HWND(*this), 0x02000900); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif - SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, + SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, IDC_STATIC_OVERWRITE_OLD_FILE_ICON, OldFileInfo); - SetFileInfoControl(IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, + SetFileInfoControl(IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, IDC_STATIC_OVERWRITE_NEW_FILE_ICON, NewFileInfo); return CModalDialog::OnInit(); } -bool COverwriteDialog::OnButtonClicked(int buttonID, HWND buttonHWND) -{ +bool COverwriteDialog::OnButtonClicked(int buttonID, HWND buttonHWND) +{ switch(buttonID) { case IDYES: diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.h b/CPP/7zip/UI/FileManager/OverwriteDialog.h index fd7444eb..d206fb01 100755 --- a/CPP/7zip/UI/FileManager/OverwriteDialog.h +++ b/CPP/7zip/UI/FileManager/OverwriteDialog.h @@ -20,7 +20,7 @@ namespace NOverwriteDialog class COverwriteDialog: public NWindows::NControl::CModalDialog { - void SetFileInfoControl(int textID, int iconID, + void SetFileInfoControl(int textID, int iconID, const NOverwriteDialog::CFileInfo &fileInfo); virtual bool OnInit(); bool OnButtonClicked(int buttonID, HWND buttonHWND); diff --git a/CPP/7zip/UI/FileManager/Panel.cpp b/CPP/7zip/UI/FileManager/Panel.cpp index 9807b958..e0ed7b50 100755 --- a/CPP/7zip/UI/FileManager/Panel.cpp +++ b/CPP/7zip/UI/FileManager/Panel.cpp @@ -21,6 +21,7 @@ #include "ExtractCallback.h" #include "resource.h" +#include "..\GUI\ExtractRes.h" #include "../Agent/IFolderArchive.h" @@ -28,6 +29,7 @@ #include "../Common/ArchiveName.h" using namespace NWindows; +using namespace NControl; #ifndef _UNICODE extern bool g_IsNT; @@ -36,9 +38,6 @@ extern bool g_IsNT; static const UINT_PTR kTimerID = 1; static const UINT kTimerElapse = 1000; -static LPCWSTR kSelectOneFile = L"Select one file"; -static LPCWSTR kSelectFiles = L"Select files"; - static DWORD kStyles[4] = { LVS_ICON, LVS_SMALLICON, LVS_LIST, LVS_REPORT }; // static const int kCreateFolderID = 101; @@ -49,7 +48,7 @@ extern DWORD g_ComCtl32Version; void CPanel::Release() { - // It's for unloading COM dll's: don't change it. + // It's for unloading COM dll's: don't change it. CloseOpenFolders(); _sevenZipContextMenu.Release(); _systemContextMenu.Release(); @@ -60,11 +59,17 @@ CPanel::~CPanel() CloseOpenFolders(); } +HWND CPanel::GetParent() +{ + HWND h = CWindow2::GetParent(); + return (h == 0) ? _mainWindow : h; +} + static LPCWSTR kClassName = L"7-Zip::Panel"; -LRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id, - const UString ¤tFolderPrefix, CPanelCallback *panelCallback, CAppState *appState, +HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id, + const UString ¤tFolderPrefix, CPanelCallback *panelCallback, CAppState *appState, bool &archiveIsOpened, bool &encrypted) { _mainWindow = mainWindow; @@ -84,10 +89,10 @@ LRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id, if (currentFolderPrefix[0] == L'.') if (!NFile::NDirectory::MyGetFullPathName(currentFolderPrefix, cfp)) cfp = currentFolderPrefix; - BindToPath(cfp, archiveIsOpened, encrypted); + RINOK(BindToPath(cfp, archiveIsOpened, encrypted)); - if (!CreateEx(0, kClassName, 0, WS_CHILD | WS_VISIBLE, - 0, 0, _xSize, 260, + if (!CreateEx(0, kClassName, 0, WS_CHILD | WS_VISIBLE, + 0, 0, _xSize, 260, parentWindow, (HMENU)(UINT_PTR)id, g_hInstance)) return E_FAIL; return S_OK; @@ -127,14 +132,14 @@ LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) return CWindow2::OnMessage(message, wParam, lParam); } -static LRESULT APIENTRY ListViewSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ +static LRESULT APIENTRY ListViewSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ CWindow tempDialog(hwnd); CMyListView *w = (CMyListView *)(tempDialog.GetUserDataLongPtr()); if (w == NULL) return 0; return w->OnMessage(message, wParam, lParam); -} +} LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { @@ -158,7 +163,7 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) // For Alt+Enter Beep disabling UINT scanCode = (UINT)(lParam >> 16) & 0xFF; UINT virtualKey = MapVirtualKey(scanCode, 1); - if (virtualKey == VK_RETURN || virtualKey == VK_MULTIPLY || + if (virtualKey == VK_RETURN || virtualKey == VK_MULTIPLY || virtualKey == VK_ADD || virtualKey == VK_SUBTRACT) return 0; } @@ -208,48 +213,48 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) _panel->_lastFocusedIsList = true; _panel->_panelCallback->PanelWasFocused(); } - #ifndef _UNICODE + #ifndef _UNICODE if (g_IsNT) - return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam); + return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam); else #endif - return CallWindowProc(_origWindowProc, *this, message, wParam, lParam); + return CallWindowProc(_origWindowProc, *this, message, wParam, lParam); } /* -static LRESULT APIENTRY ComboBoxSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ +static LRESULT APIENTRY ComboBoxSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ CWindow tempDialog(hwnd); CMyComboBox *w = (CMyComboBox *)(tempDialog.GetUserDataLongPtr()); if (w == NULL) return 0; return w->OnMessage(message, wParam, lParam); -} +} LRESULT CMyComboBox::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { - return CallWindowProc(_origWindowProc, *this, message, wParam, lParam); + return CallWindowProc(_origWindowProc, *this, message, wParam, lParam); } */ -static LRESULT APIENTRY ComboBoxEditSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ +static LRESULT APIENTRY ComboBoxEditSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ CWindow tempDialog(hwnd); CMyComboBoxEdit *w = (CMyComboBoxEdit *)(tempDialog.GetUserDataLongPtr()); if (w == NULL) return 0; return w->OnMessage(message, wParam, lParam); -} +} LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { // See MSDN / Subclassing a Combo Box / Creating a Combo-box Toolbar - switch (message) - { - case WM_SYSKEYDOWN: - switch (wParam) - { - case VK_F1: - case VK_F2: + switch (message) + { + case WM_SYSKEYDOWN: + switch (wParam) + { + case VK_F1: + case VK_F2: { // check ALT if ((lParam & (1<<29)) == 0) @@ -260,20 +265,20 @@ LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) if (alt && !ctrl && !shift) { _panel->_panelCallback->SetFocusToPath(wParam == VK_F1 ? 0 : 1); - return 0; + return 0; } - break; + break; } } break; - case WM_KEYDOWN: - switch (wParam) - { - case VK_TAB: - // SendMessage(hwndMain, WM_ENTER, 0, 0); + case WM_KEYDOWN: + switch (wParam) + { + case VK_TAB: + // SendMessage(hwndMain, WM_ENTER, 0, 0); _panel->SetFocusToList(); - return 0; - case VK_F9: + return 0; + case VK_F9: { bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0; bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; @@ -281,26 +286,35 @@ LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) if (!alt && !ctrl && !shift) { g_App.SwitchOnOffOnePanel();; - return 0; + return 0; } - break; + break; } } break; - case WM_CHAR: - switch (wParam) - { - case VK_TAB: - case VK_ESCAPE: - return 0; - } + case WM_CHAR: + switch (wParam) + { + case VK_TAB: + case VK_ESCAPE: + return 0; + } } - #ifndef _UNICODE + #ifndef _UNICODE if (g_IsNT) - return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam); + return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam); else #endif - return CallWindowProc(_origWindowProc, *this, message, wParam, lParam); + return CallWindowProc(_origWindowProc, *this, message, wParam, lParam); +} + +static HIMAGELIST GetSysImageList(bool smallIcons) +{ + SHFILEINFO shellInfo; + return (HIMAGELIST)SHGetFileInfo(TEXT(""), + FILE_ATTRIBUTE_NORMAL |FILE_ATTRIBUTE_DIRECTORY, + &shellInfo, sizeof(shellInfo), + SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | (smallIcons ? SHGFI_SMALLICON : SHGFI_ICON)); } bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) @@ -322,8 +336,8 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) if (_ListViewMode >= kNumListModes) _ListViewMode = kNumListModes - 1; - style |= kStyles[_ListViewMode] - | WS_TABSTOP + style |= kStyles[_ListViewMode] + | WS_TABSTOP | LVS_EDITLABELS; if (_mySelectMode) style |= LVS_SINGLESEL; @@ -336,7 +350,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) DWORD exStyle; exStyle = WS_EX_CLIENTEDGE; - if (!_listView.CreateEx(exStyle, style, 0, 0, 116, 260, + if (!_listView.CreateEx(exStyle, style, 0, 0, 116, 260, HWND(*this), (HMENU)(UINT_PTR)(_baseID + 1), g_hInstance, NULL)) return false; @@ -347,32 +361,15 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) #ifndef _UNICODE if(g_IsNT) - _listView._origWindowProc = + _listView._origWindowProc = (WNDPROC)_listView.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc)); else #endif - _listView._origWindowProc = + _listView._origWindowProc = (WNDPROC)_listView.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc)); - SHFILEINFO shellInfo; - HIMAGELIST imageList = (HIMAGELIST)SHGetFileInfo(TEXT(""), - FILE_ATTRIBUTE_NORMAL | - FILE_ATTRIBUTE_DIRECTORY, - &shellInfo, sizeof(shellInfo), - SHGFI_USEFILEATTRIBUTES | - SHGFI_SYSICONINDEX | - SHGFI_SMALLICON - ); - _listView.SetImageList(imageList, LVSIL_SMALL); - imageList = (HIMAGELIST)SHGetFileInfo(TEXT(""), - FILE_ATTRIBUTE_NORMAL | - FILE_ATTRIBUTE_DIRECTORY, - &shellInfo, sizeof(shellInfo), - SHGFI_USEFILEATTRIBUTES | - SHGFI_SYSICONINDEX | - SHGFI_ICON - ); - _listView.SetImageList(imageList, LVSIL_NORMAL); + _listView.SetImageList(GetSysImageList(true), LVSIL_SMALL); + _listView.SetImageList(GetSysImageList(false), LVSIL_NORMAL); // _exStyle |= LVS_EX_HEADERDRAGDROP; // DWORD extendedStyle = _listView.GetExtendedListViewStyle(); @@ -384,14 +381,14 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) _listView.InvalidateRect(NULL, true); _listView.Update(); - // Ensure that the common control DLL is loaded. + // Ensure that the common control DLL is loaded. INITCOMMONCONTROLSEX icex; icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_BAR_CLASSES; InitCommonControlsEx(&icex); - TBBUTTON tbb [ ] = + TBBUTTON tbb [ ] = { // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0}, {VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0}, @@ -407,12 +404,12 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) _headerReBar.Attach(::CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, - NULL, WS_VISIBLE | WS_BORDER | WS_CHILD | - WS_CLIPCHILDREN | WS_CLIPSIBLINGS - | CCS_NODIVIDER - | CCS_NOPARENTALIGN + NULL, WS_VISIBLE | WS_BORDER | WS_CHILD | + WS_CLIPCHILDREN | WS_CLIPSIBLINGS + | CCS_NODIVIDER + | CCS_NOPARENTALIGN | CCS_TOP - | RBS_VARHEIGHT + | RBS_VARHEIGHT | RBS_BANDBORDERS ,0,0,0,0, HWND(*this), NULL, g_hInstance, NULL)); } @@ -421,8 +418,8 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) if (_headerReBar) { toolbarStyle |= 0 - // | WS_CLIPCHILDREN - // | WS_CLIPSIBLINGS + // | WS_CLIPCHILDREN + // | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS | CCS_NODIVIDER @@ -431,11 +428,11 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) ; } - _headerToolBar.Attach(::CreateToolbarEx ((*this), toolbarStyle, - _baseID + 2, 11, - (HINSTANCE)HINST_COMMCTRL, - IDB_VIEW_SMALL_COLOR, - (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]), + _headerToolBar.Attach(::CreateToolbarEx ((*this), toolbarStyle, + _baseID + 2, 11, + (HINSTANCE)HINST_COMMCTRL, + IDB_VIEW_SMALL_COLOR, + (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]), 0, 0, 0, 0, sizeof (TBBUTTON))); icex.dwSize = sizeof(INITCOMMONCONTROLSEX); @@ -444,19 +441,20 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) _headerComboBox.CreateEx(0, WC_COMBOBOXEXW, NULL, WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL, - 0, 0, 100, 20, + 0, 0, 100, 520, ((_headerReBar == 0) ? HWND(*this) : _headerToolBar), (HMENU)(UINT_PTR)(_comboBoxID), g_hInstance, NULL); - // _headerComboBox.SendMessage(CBEM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0); + _headerComboBox.SendMessage(CBEM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0); + _headerComboBox.SetImageList(GetSysImageList(true)); _headerComboBox.SetExtendedStyle(CBES_EX_PATHWORDBREAKPROC, CBES_EX_PATHWORDBREAKPROC); /* _headerComboBox.SetUserDataLongPtr(LONG_PTR(&_headerComboBox)); _headerComboBox._panel = this; - _headerComboBox._origWindowProc = + _headerComboBox._origWindowProc = (WNDPROC)_headerComboBox.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ComboBoxSubclassProc)); */ @@ -468,15 +466,13 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) _comboBoxEdit._panel = this; #ifndef _UNICODE if(g_IsNT) - _comboBoxEdit._origWindowProc = + _comboBoxEdit._origWindowProc = (WNDPROC)_comboBoxEdit.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc)); else #endif - _comboBoxEdit._origWindowProc = + _comboBoxEdit._origWindowProc = (WNDPROC)_comboBoxEdit.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc)); - - if (_headerReBar) { REBARINFO rbi; @@ -485,9 +481,9 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) rbi.himl = (HIMAGELIST)NULL; _headerReBar.SetBarInfo(&rbi); - // Send the TB_BUTTONSTRUCTSIZE message, which is required for - // backward compatibility. - // _headerToolBar.SendMessage(TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); + // Send the TB_BUTTONSTRUCTSIZE message, which is required for + // backward compatibility. + // _headerToolBar.SendMessage(TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); SIZE size; _headerToolBar.GetMaxSize(&size); @@ -540,7 +536,7 @@ void CPanel::OnDestroy() CWindow2::OnDestroy(); } -void CPanel::ChangeWindowSize(int xSize, int ySize) +void CPanel::ChangeWindowSize(int xSize, int ySize) { int kHeaderSize; int kStatusBarSize; @@ -567,7 +563,7 @@ void CPanel::ChangeWindowSize(int xSize, int ySize) else { _headerToolBar.Move(0, 0, xSize, 0); - _headerComboBox.Move(kStartXPos, 2, + _headerComboBox.Move(kStartXPos, 2, MyMax(xSize - kStartXPos - 10, kStartXPos), 0); } _listView.Move(0, kHeaderSize, xSize, yListViewSize); @@ -577,7 +573,7 @@ void CPanel::ChangeWindowSize(int xSize, int ySize) // _statusBar2.MoveWindow(0, 200, xSize, kStatusBar2Size); } -bool CPanel::OnSize(WPARAM /* wParam */, int xSize, int ySize) +bool CPanel::OnSize(WPARAM /* wParam */, int xSize, int ySize) { if (_headerReBar) _headerReBar.Move(0, 0, xSize, 0); @@ -611,7 +607,7 @@ bool CPanel::OnNotify(UINT /* controlID */, LPNMHDR header, LRESULT &result) // if (header->hwndFrom == _listView) else if (header->hwndFrom == _listView) return OnNotifyList(header, result); - else if (::GetParent(header->hwndFrom) == _listView && + else if (::GetParent(header->hwndFrom) == _listView && header->code == NM_RCLICK) return OnRightClick((LPNMITEMACTIVATE)header, result); return false; @@ -635,7 +631,8 @@ bool CPanel::OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result) */ if (itemID == _comboBoxID) { - OnComboBoxCommand(code, lParam); + if (OnComboBoxCommand(code, lParam, result)) + return true; } return CWindow2::OnCommand(code, itemID, lParam, result); } @@ -649,7 +646,16 @@ void CPanel::MessageBox(LPCWSTR message) void CPanel::MessageBoxMyError(LPCWSTR message) { MessageBox(message, L"Error"); } void CPanel::MessageBoxError(HRESULT errorCode, LPCWSTR caption) - { MessageBox(NError::MyFormatMessageW(errorCode), caption); } +{ + UString message; + if (errorCode == E_OUTOFMEMORY) + message = LangString(IDS_MEM_ERROR, 0x0200060B); + else + if (!NError::MyFormatMessage(errorCode, message)) + message = L"Error"; + MessageBox(message, caption); +} + void CPanel::MessageBoxError(HRESULT errorCode) { MessageBoxError(errorCode, L"7-Zip"); } void CPanel::MessageBoxLastError(LPCWSTR caption) @@ -657,6 +663,10 @@ void CPanel::MessageBoxLastError(LPCWSTR caption) void CPanel::MessageBoxLastError() { MessageBoxLastError(L"Error"); } +void CPanel::MessageBoxErrorLang(UINT resourceID, UInt32 langID) + { MessageBox(LangString(resourceID, langID)); } + + void CPanel::SetFocusToList() { _listView.SetFocus(); @@ -761,12 +771,12 @@ void CPanel::AddToArchive() GetOperatedItemIndices(indices); if (!IsFSFolder()) { - MessageBox(L"Compress operation is not supported for that folder"); + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } if (indices.Size() == 0) { - MessageBox(kSelectFiles); + MessageBoxErrorLang(IDS_SELECT_FILES, 0x03020A03); return; } UStringVector names; @@ -781,9 +791,9 @@ void CPanel::AddToArchive() if (res != S_OK) { if (_currentFolderPrefix.Length() >= MAX_PATH) - MessageBox(L"Can't call this operation for file with long path"); + MessageBoxErrorLang(IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER, 0x03020A01); else - MessageBoxError(res, L"Error"); + MessageBoxError(res); } // KillSelection(); } @@ -799,6 +809,25 @@ static UString GetSubFolderNameForExtract(const UString &archiveName) return res; } +void CPanel::GetFilePaths(const CRecordVector<UInt32> &indices, UStringVector &paths) +{ + for (int i = 0; i < indices.Size(); i++) + { + int index = indices[i]; + if (IsItemFolder(index)) + { + paths.Clear(); + break; + } + paths.Add(_currentFolderPrefix + GetItemRelPath(index)); + } + if (paths.Size() == 0) + { + MessageBoxErrorLang(IDS_SELECT_FILES, 0x03020A03); + return; + } +} + void CPanel::ExtractArchives() { if (_parentFolders.Size() > 0) @@ -809,22 +838,9 @@ void CPanel::ExtractArchives() CRecordVector<UInt32> indices; GetOperatedItemIndices(indices); UStringVector paths; - if (indices.Size() == 0) - { - // GetAllItemIndices(indices); - MessageBox(kSelectOneFile); + GetFilePaths(indices, paths); + if (paths.IsEmpty()) return; - } - for (int i = 0; i < indices.Size(); i++) - { - int index = indices[i]; - if (IsItemFolder(index)) - { - MessageBox(kSelectOneFile); - return; - } - paths.Add(_currentFolderPrefix + GetItemRelPath(index)); - } UString folderName; if (indices.Size() == 1) folderName = GetSubFolderNameForExtract(GetItemRelPath(indices[0])); @@ -841,28 +857,28 @@ struct CThreadTest CMyComPtr<IArchiveFolder> ArchiveFolder; HRESULT Result; - DWORD Test() + void Test() { ExtractCallbackSpec->ProgressDialog.WaitCreating(); - Result = ArchiveFolder->Extract(&Indices[0], Indices.Size(), - NExtract::NPathMode::kFullPathnames, NExtract::NOverwriteMode::kAskBefore, + Result = ArchiveFolder->Extract(&Indices[0], Indices.Size(), + NExtract::NPathMode::kFullPathnames, NExtract::NOverwriteMode::kAskBefore, NULL, BoolToInt(true), ExtractCallback); ExtractCallbackSpec->ProgressDialog.MyClose(); - return 0; } static THREAD_FUNC_DECL MyThreadFunction(void *param) { - return ((CThreadTest*)param)->Test(); + ((CThreadTest*)param)->Test(); + return 0; } }; -static void AddValuePair(UINT resourceID, UInt32 langID, UInt64 values, UString &s) +static void AddValuePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s) { wchar_t sz[32]; s += LangString(resourceID, langID); s += L" "; - ConvertUInt64ToString(values, sz); + ConvertUInt64ToString(value, sz); s += sz; s += L"\n"; } @@ -886,7 +902,7 @@ static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s void CPanel::TestArchives() { CRecordVector<UInt32> indices; - GetOperatedItemIndices(indices); + GetOperatedIndicesSmart(indices); CMyComPtr<IArchiveFolder> archiveFolder; _folder.QueryInterface(IID_IArchiveFolder, &archiveFolder); if (archiveFolder) @@ -901,8 +917,6 @@ void CPanel::TestArchives() extracter.ExtractCallbackSpec->ShowMessages = true; if (indices.IsEmpty()) - GetAllItemIndices(indices); - if (indices.IsEmpty()) return; extracter.Indices = indices; @@ -946,25 +960,13 @@ void CPanel::TestArchives() if (!IsFSFolder()) { - MessageBox(L"Test archive operation is not supported for that folder"); + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } UStringVector paths; - if (indices.Size() == 0) - { - MessageBox(kSelectOneFile); + GetFilePaths(indices, paths); + if (paths.IsEmpty()) return; - } - for (int i = 0; i < indices.Size(); i++) - { - int index = indices[i]; - if (IsItemFolder(index)) - { - MessageBox(kSelectOneFile); - return; - } - paths.Add(_currentFolderPrefix + GetItemRelPath(index)); - } ::TestArchives(paths); } diff --git a/CPP/7zip/UI/FileManager/Panel.h b/CPP/7zip/UI/FileManager/Panel.h index a9c6a304..86f3dc25 100755 --- a/CPP/7zip/UI/FileManager/Panel.h +++ b/CPP/7zip/UI/FileManager/Panel.h @@ -92,6 +92,11 @@ struct CFolderLink: public CTempFileInfo { NWindows::NDLL::CLibrary Library; CMyComPtr<IFolderFolder> ParentFolder; + bool UsePassword; + UString Password; + + UString VirtualPath; + CFolderLink(): UsePassword(false) {} }; enum MyMessages @@ -141,10 +146,8 @@ struct CSelectedState CSelectedState(): FocusedItem(-1), SelectFocused(false) {} }; -class CPanel:public NWindows::NControl::CWindow2 +class CPanel: public NWindows::NControl::CWindow2 { - HWND _mainWindow; - CExtToIconMap _extToIconMap; UINT _baseID; int _comboBoxID; @@ -158,7 +161,12 @@ class CPanel:public NWindows::NControl::CWindow2 virtual bool OnSize(WPARAM wParam, int xSize, int ySize); virtual void OnDestroy(); virtual bool OnNotify(UINT controlID, LPNMHDR lParam, LRESULT &result); - void OnComboBoxCommand(UINT code, LPARAM &aParam); + + void AddComboBoxItem(const UString &name, int iconIndex, int indent, bool addToList); + + bool OnComboBoxCommand(UINT code, LPARAM param, LRESULT &result); + + LRESULT OnNotifyComboBoxEnter(const UString &s); bool OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result); #ifndef _UNICODE bool OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result); @@ -175,6 +183,7 @@ class CPanel:public NWindows::NControl::CWindow2 bool OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result); public: + HWND _mainWindow; CPanelCallback *_panelCallback; void DeleteItems(bool toRecycleBin); @@ -217,6 +226,7 @@ public: NWindows::NControl::CReBar _headerReBar; NWindows::NControl::CToolBar _headerToolBar; NWindows::NControl::CComboBoxEx _headerComboBox; + UStringVector ComboBoxPaths; // CMyComboBox _headerComboBox; CMyComboBoxEdit _comboBoxEdit; CMyListView _listView; @@ -235,6 +245,8 @@ public: CSelectedState _selectedState; + HWND GetParent(); + UInt32 GetRealIndex(const LVITEMW &item) const { /* @@ -256,7 +268,7 @@ public: } UInt32 _ListViewMode; - int _xSize; + int _xSize; bool _flatMode; @@ -287,7 +299,7 @@ public: // PanelFolderChange.cpp void SetToRootFolder(); - HRESULT BindToPath(const UString &fullPath, bool &archiveIsOpened, bool &encrypted); // can be prefix + HRESULT BindToPath(const UString &fullPath, bool &archiveIsOpened, bool &encrypted); // can be prefix HRESULT BindToPathAndRefresh(const UString &path); void OpenDrivesFolder(); @@ -302,9 +314,9 @@ public: void OpenRootFolder(); - LRESULT Create(HWND mainWindow, HWND parentWindow, + HRESULT Create(HWND mainWindow, HWND parentWindow, UINT id, - const UString ¤tFolderPrefix, + const UString ¤tFolderPrefix, CPanelCallback *panelCallback, CAppState *appState, bool &archiveIsOpened, bool &encrypted); void SetFocusToList(); @@ -314,13 +326,13 @@ public: void ReadListViewInfo(); void SaveListViewInfo(); - CPanel() : + CPanel() : // _virtualMode(flase), _exStyle(0), _showDots(false), _showRealFileIcons(false), - _needSaveInfo(false), - _startGroupSelect(0), + _needSaveInfo(false), + _startGroupSelect(0), _selectionIsDefined(false), _ListViewMode(3), _flatMode(false), @@ -328,7 +340,7 @@ public: _mySelectMode(false), _enableItemChangeNotify(true), _dontShowMode(false) - {} + {} void SetExtendedStyle() { @@ -361,19 +373,19 @@ public: HRESULT CreateShellContextMenu( const CRecordVector<UInt32> &operatedIndices, CMyComPtr<IContextMenu> &systemContextMenu); - void CreateSystemMenu(HMENU menu, + void CreateSystemMenu(HMENU menu, const CRecordVector<UInt32> &operatedIndices, CMyComPtr<IContextMenu> &systemContextMenu); - void CreateSevenZipMenu(HMENU menu, + void CreateSevenZipMenu(HMENU menu, const CRecordVector<UInt32> &operatedIndices, CMyComPtr<IContextMenu> &sevenZipContextMenu); - void CreateFileMenu(HMENU menu, + void CreateFileMenu(HMENU menu, CMyComPtr<IContextMenu> &sevenZipContextMenu, CMyComPtr<IContextMenu> &systemContextMenu, bool programMenu); void CreateFileMenu(HMENU menu); bool InvokePluginCommand(int id); - bool InvokePluginCommand(int id, IContextMenu *sevenZipContextMenu, + bool InvokePluginCommand(int id, IContextMenu *sevenZipContextMenu, IContextMenu *systemContextMenu); void InvokeSystemCommand(const char *command); @@ -395,6 +407,7 @@ public: void GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const; void GetOperatedItemIndices(CRecordVector<UInt32> &indices) const; void GetAllItemIndices(CRecordVector<UInt32> &indices) const; + void GetOperatedIndicesSmart(CRecordVector<UInt32> &indices) const; // void GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const; void KillSelection(); @@ -419,24 +432,24 @@ public: CPanel &_panel; public: - CDisableTimerProcessing(CPanel &panel): _panel(panel) - { + CDisableTimerProcessing(CPanel &panel): _panel(panel) + { Disable(); } void Disable() { _processTimerMem = _panel._processTimer; _processNotifyMem = _panel._processNotify; - _panel._processTimer = false; - _panel._processNotify = false; + _panel._processTimer = false; + _panel._processNotify = false; } void Restore() { - _panel._processTimer = _processTimerMem; - _panel._processNotify = _processNotifyMem; + _panel._processTimer = _processTimerMem; + _panel._processNotify = _processNotifyMem; } - ~CDisableTimerProcessing() - { + ~CDisableTimerProcessing() + { Restore(); } CDisableTimerProcessing& operator=(const CDisableTimerProcessing &) {; } @@ -456,6 +469,7 @@ public: void MessageBoxLastError(LPCWSTR caption); void MessageBoxLastError(); + void MessageBoxErrorLang(UINT resourceID, UInt32 langID); void OpenFocusedItemAsInternal(); void OpenSelectedItems(bool internal); @@ -464,14 +478,16 @@ public: void OpenFolder(int index); HRESULT OpenParentArchiveFolder(); - HRESULT OpenItemAsArchive(const UString &name, + HRESULT OpenItemAsArchive(const UString &name, const UString &folderPath, - const UString &filePath, bool &encrypted); - HRESULT OpenItemAsArchive(const UString &aName); + const UString &filePath, + const UString &virtualFilePath, + bool &encrypted); + HRESULT OpenItemAsArchive(const UString &name); HRESULT OpenItemAsArchive(int index); void OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bool editMode); - HRESULT OnOpenItemChanged(const UString &folderPath, const UString &itemName); + HRESULT OnOpenItemChanged(const UString &folderPath, const UString &itemName, bool usePassword, const UString &password); LRESULT OnOpenItemChanged(LPARAM lParam); void OpenItem(int index, bool tryInternal, bool tryExternal); @@ -491,13 +507,30 @@ public: void OnRefreshStatusBar(); void AddToArchive(); + + void GetFilePaths(const CRecordVector<UInt32> &indices, UStringVector &paths); void ExtractArchives(); void TestArchives(); - HRESULT CopyTo(const CRecordVector<UInt32> &indices, const UString &folder, - bool moveMode, bool showErrorMessages, UStringVector *messages); + HRESULT CopyTo(const CRecordVector<UInt32> &indices, const UString &folder, + bool moveMode, bool showErrorMessages, UStringVector *messages, + bool &usePassword, UString &password); + + HRESULT CopyTo(const CRecordVector<UInt32> &indices, const UString &folder, + bool moveMode, bool showErrorMessages, UStringVector *messages) + { + bool usePassword = false; + UString password; + if (_parentFolders.Size() > 0) + { + const CFolderLink &fl = _parentFolders.Back(); + usePassword = fl.UsePassword; + password = fl.Password; + } + return CopyTo(indices, folder, moveMode, showErrorMessages, messages, usePassword, password); + } - HRESULT CopyFrom(const UString &folderPrefix, const UStringVector &filePaths, + HRESULT CopyFrom(const UString &folderPrefix, const UStringVector &filePaths, bool showErrorMessages, UStringVector *messages); void CopyFromNoAsk(const UStringVector &filePaths); @@ -511,6 +544,8 @@ public: void RefreshTitle(bool always = false) { _panelCallback->RefreshTitle(always); } void RefreshTitleAlways() { RefreshTitle(true); } + + UString GetItemsInfoString(const CRecordVector<UInt32> &indices); }; #endif diff --git a/CPP/7zip/UI/FileManager/PanelCopy.cpp b/CPP/7zip/UI/FileManager/PanelCopy.cpp index c5745010..8ad3d4c9 100755 --- a/CPP/7zip/UI/FileManager/PanelCopy.cpp +++ b/CPP/7zip/UI/FileManager/PanelCopy.cpp @@ -3,7 +3,7 @@ #include "StdAfx.h" #include "Panel.h" -#include "resource.h" +#include "resource.h" #include "LangUtils.h" #include "ExtractCallback.h" #include "Windows/Thread.h" @@ -29,10 +29,10 @@ struct CThreadExtractInArchive2 { ExtractCallbackSpec->ProgressDialog.WaitCreating(); if (MoveMode) - Result = FolderOperations->MoveTo(&Indices.Front(), Indices.Size(), + Result = FolderOperations->MoveTo(&Indices.Front(), Indices.Size(), DestPath, ExtractCallback); else - Result = FolderOperations->CopyTo(&Indices.Front(), Indices.Size(), + Result = FolderOperations->CopyTo(&Indices.Front(), Indices.Size(), DestPath, ExtractCallback); ExtractCallbackSpec->ProgressDialog.MyClose(); return 0; @@ -44,8 +44,9 @@ struct CThreadExtractInArchive2 } }; -HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &folder, - bool moveMode, bool showErrorMessages, UStringVector *messages) +HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &folder, + bool moveMode, bool showErrorMessages, UStringVector *messages, + bool &usePassword, UString &password) { CMyComPtr<IFolderOperations> folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) @@ -68,7 +69,7 @@ HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &fold extracter.ExtractCallbackSpec->ShowMessages = showErrorMessages; extracter.ExtractCallbackSpec->ProgressDialog.CompressingMode = false; - UString title = moveMode ? + UString title = moveMode ? LangString(IDS_MOVING, 0x03020206): LangString(IDS_COPYING, 0x03020205); UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); @@ -83,6 +84,9 @@ HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &fold extracter.DestPath = folder; extracter.FolderOperations = folderOperations; extracter.MoveMode = moveMode; + + extracter.ExtractCallbackSpec->PasswordIsDefined = usePassword; + extracter.ExtractCallbackSpec->Password = password; NWindows::CThread extractThread; RINOK(extractThread.Create(CThreadExtractInArchive2::MyThreadFunction, &extracter)); @@ -90,7 +94,13 @@ HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &fold if (messages != 0) *messages = extracter.ExtractCallbackSpec->Messages; - res = extracter.Result; + res = extracter.Result; + + if (res == S_OK && extracter.ExtractCallbackSpec->Messages.IsEmpty()) + { + usePassword = extracter.ExtractCallbackSpec->PasswordIsDefined; + password = extracter.ExtractCallbackSpec->Password; + } } RefreshTitleAlways(); return res; @@ -126,7 +136,7 @@ struct CThreadUpdate }; -HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &filePaths, +HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &filePaths, bool showErrorMessages, UStringVector *messages) { CMyComPtr<IFolderOperations> folderOperations; diff --git a/CPP/7zip/UI/FileManager/PanelCrc.cpp b/CPP/7zip/UI/FileManager/PanelCrc.cpp index 4ce435da..61490b57 100755 --- a/CPP/7zip/UI/FileManager/PanelCrc.cpp +++ b/CPP/7zip/UI/FileManager/PanelCrc.cpp @@ -4,8 +4,8 @@ #include "resource.h" -extern "C" -{ +extern "C" +{ #include "../../../../C/Alloc.h" #include "../../../../C/7zCrc.h" } @@ -93,7 +93,7 @@ bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UStr Prefixes.DeleteBack(); } resPath += fileInfo.Name; - if (!FlatMode && fileInfo.IsDirectory()) + if (!FlatMode && fileInfo.IsDir()) { UString prefix = resPath + (UString)(wchar_t)kDirDelimiter; Enumerators.Add(NFind::CEnumeratorW(BasePrefix + prefix + (UString)(wchar_t)kAnyStringWildcard)); @@ -171,7 +171,7 @@ struct CThreadCrc } if (!filled) break; - if (!fileInfo.IsDirectory()) + if (!fileInfo.IsDir()) totalSize += fileInfo.Size; ProgressDialog->ProgressSynch.SetCurrentFileName(scanningStr + resPath); ProgressDialog->ProgressSynch.SetProgress(totalSize, 0); @@ -199,7 +199,7 @@ struct CThreadCrc break; UInt32 crc = CRC_INIT_VAL; - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) NumFolders++; else { @@ -276,7 +276,7 @@ void CApp::CalculateCrc() CPanel &srcPanel = Panels[srcPanelIndex]; if (!srcPanel.IsFSFolder()) { - srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } CRecordVector<UInt32> indices; diff --git a/CPP/7zip/UI/FileManager/PanelDrag.cpp b/CPP/7zip/UI/FileManager/PanelDrag.cpp index f242c8a1..25cbbc38 100755 --- a/CPP/7zip/UI/FileManager/PanelDrag.cpp +++ b/CPP/7zip/UI/FileManager/PanelDrag.cpp @@ -22,12 +22,12 @@ using namespace NWindows; extern bool g_IsNT; #endif -static wchar_t *kTempDirPrefix = L"7zE"; -static LPCTSTR kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder"); +static wchar_t *kTempDirPrefix = L"7zE"; +static LPCTSTR kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder"); //////////////////////////////////////////////////////// -class CDataObject: +class CDataObject: public IDataObject, public CMyUnknownImp { @@ -61,7 +61,7 @@ public: CDataObject::CDataObject() { - m_SetFolderFormat = RegisterClipboardFormat(kSvenZipSetFolderFormat); + m_SetFolderFormat = RegisterClipboardFormat(kSvenZipSetFolderFormat); m_Etc.cfFormat = CF_HDROP; m_Etc.ptd = NULL; m_Etc.dwAspect = DVASPECT_CONTENT; @@ -70,13 +70,13 @@ CDataObject::CDataObject() } STDMETHODIMP CDataObject::SetData(LPFORMATETC etc, STGMEDIUM *medium, BOOL /* release */) -{ - if (etc->cfFormat == m_SetFolderFormat && etc->tymed == TYMED_HGLOBAL && +{ + if (etc->cfFormat == m_SetFolderFormat && etc->tymed == TYMED_HGLOBAL && etc->dwAspect == DVASPECT_CONTENT && medium->tymed == TYMED_HGLOBAL) { Path.Empty(); if (medium->hGlobal == 0) - return S_OK; + return S_OK; size_t size = GlobalSize(medium->hGlobal) / sizeof(wchar_t); const wchar_t *src = (const wchar_t *)GlobalLock(medium->hGlobal); if (src != 0) @@ -89,10 +89,10 @@ STDMETHODIMP CDataObject::SetData(LPFORMATETC etc, STGMEDIUM *medium, BOOL /* re Path += c; } GlobalUnlock(medium->hGlobal); - return S_OK; + return S_OK; } } - return E_NOTIMPL; + return E_NOTIMPL; } static HGLOBAL DuplicateGlobalMem(HGLOBAL srcGlobal) @@ -156,7 +156,7 @@ STDMETHODIMP CDataObject::EnumFormatEtc(DWORD direction, LPENUMFORMATETC FAR* en //////////////////////////////////////////////////////// -class CDropSource: +class CDropSource: public IDropSource, public CMyUnknownImp { @@ -199,8 +199,8 @@ STDMETHODIMP CDropSource::QueryContinueDrag(BOOL escapePressed, DWORD keyState) } if (needExtract) { - Result = Panel->CopyTo(Indices, Folder, - false, // moveMode, + Result = Panel->CopyTo(Indices, Folder, + false, // moveMode, false, // showMessages &Messages); if (Result != S_OK || !Messages.IsEmpty()) @@ -300,7 +300,7 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */) // CSelectedState selState; // SaveSelectedState(selState); - UString dirPrefix; + UString dirPrefix; NFile::NDirectory::CTempDirectoryW tempDirectory; bool isFSFolder = IsFSFolder(); @@ -358,8 +358,8 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */) if (!dataObjectSpec->Path.IsEmpty()) { NFile::NName::NormalizeDirPathPrefix(dataObjectSpec->Path); - res = CopyTo(indices, dataObjectSpec->Path, - (effect == DROPEFFECT_MOVE),// dropSourceSpec->MoveMode, + res = CopyTo(indices, dataObjectSpec->Path, + (effect == DROPEFFECT_MOVE),// dropSourceSpec->MoveMode, false, // showErrorMessages &dropSourceSpec->Messages); } @@ -433,7 +433,7 @@ void CDropTarget::PositionCursor(POINTL ptl) for (int i = 0; i < kNumPanelsMax; i++) if (App->IsPanelVisible(i)) if (App->Panels[i].IsEnabled()) - if (ChildWindowFromPointEx(App->_window, pt2, + if (ChildWindowFromPointEx(App->_window, pt2, CWP_SKIPINVISIBLE | CWP_SKIPDISABLED) == (HWND)App->Panels[i]) { m_Panel = &App->Panels[i]; @@ -475,7 +475,7 @@ void CDropTarget::PositionCursor(POINTL ptl) if (realIndex == kParentIndex) return; if (!m_Panel->IsItemFolder(realIndex)) - return; + return; m_SubFolderIndex = realIndex; m_SubFolderName = m_Panel->GetItemName(m_SubFolderIndex); MySetDropHighlighted(m_Panel->_listView, index, true); @@ -604,9 +604,9 @@ DWORD CDropTarget::GetEffect(DWORD keyState, POINTL /* pt */, DWORD allowedEffec effect = allowedEffect & DROPEFFECT_MOVE; if(effect == 0) { - if(allowedEffect & DROPEFFECT_COPY) + if(allowedEffect & DROPEFFECT_COPY) effect = DROPEFFECT_COPY; - if(allowedEffect & DROPEFFECT_MOVE) + if(allowedEffect & DROPEFFECT_MOVE) { if (IsItSameDrive()) effect = DROPEFFECT_MOVE; @@ -634,7 +634,7 @@ UString CDropTarget::GetTargetPath() const bool CDropTarget::SetPath(bool enablePath) const { - UINT setFolderFormat = RegisterClipboardFormat(kSvenZipSetFolderFormat); + UINT setFolderFormat = RegisterClipboardFormat(kSvenZipSetFolderFormat); FORMATETC etc = { (CLIPFORMAT)setFolderFormat, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; STGMEDIUM medium; @@ -666,7 +666,7 @@ bool CDropTarget::SetPath() return m_SetPathIsOK; } -STDMETHODIMP CDropTarget::DragEnter(IDataObject * dataObject, DWORD keyState, +STDMETHODIMP CDropTarget::DragEnter(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD *effect) { GetNamesFromDataObject(dataObject, m_SourcePaths); @@ -696,7 +696,7 @@ STDMETHODIMP CDropTarget::DragLeave() // We suppose that there was ::DragOver for same POINTL_pt before ::Drop // So SetPath() is same as in Drop. -STDMETHODIMP CDropTarget::Drop(IDataObject *dataObject, DWORD keyState, +STDMETHODIMP CDropTarget::Drop(IDataObject *dataObject, DWORD keyState, POINTL pt, DWORD * effect) { QueryGetData(dataObject); @@ -770,7 +770,7 @@ void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &fo { if (fileNames.Size() == 0) return; - const UString archiveName = CreateArchiveName(fileNames.Front(), + const UString archiveName = CreateArchiveName(fileNames.Front(), (fileNames.Size() > 1), false); bool createNewArchive = true; if (!IsFSFolder()) @@ -785,7 +785,7 @@ void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &fo if (IsFolderInTemp(folderPath2)) folderPath2 = L"C:\\"; // fix it } - CompressFiles(folderPath2, archiveName, L"", fileNames, + CompressFiles(folderPath2, archiveName, L"", fileNames, false, // email true, // showDialog AreThereNamesFromTemp(fileNames) // waitFinish diff --git a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp index d6fdcc98..47363ef4 100755 --- a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp +++ b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp @@ -34,6 +34,37 @@ HRESULT CPanel::BindToPath(const UString &fullPath, bool &archiveIsOpened, bool archiveIsOpened = false; encrypted = false; CDisableTimerProcessing disableTimerProcessing1(*this); + + if (_parentFolders.Size() > 0) + { + const UString &virtPath = _parentFolders.Back().VirtualPath; + if (fullPath.Left(virtPath.Length()) == virtPath) + { + for (;;) + { + CMyComPtr<IFolderFolder> newFolder; + HRESULT res = _folder->BindToParentFolder(&newFolder); + if (!newFolder || res != S_OK) + break; + _folder = newFolder; + } + UStringVector parts; + SplitPathToParts(fullPath.Mid(virtPath.Length()), parts); + for (int i = 0; i < parts.Size(); i++) + { + const UString &s = parts[i]; + if ((i == 0 || i == parts.Size() - 1) && s.IsEmpty()) + continue; + CMyComPtr<IFolderFolder> newFolder; + HRESULT res = _folder->BindToFolder(s, &newFolder); + if (!newFolder || res != S_OK) + break; + _folder = newFolder; + } + return S_OK; + } + } + CloseOpenFolders(); UString sysPath = fullPath; CFileInfoW fileInfo; @@ -59,7 +90,7 @@ HRESULT CPanel::BindToPath(const UString &fullPath, bool &archiveIsOpened, bool if (_folder->BindToFolder(fullPath, &newFolder) == S_OK) _folder = newFolder; } - else if (fileInfo.IsDirectory()) + else if (fileInfo.IsDir()) { NName::NormalizeDirPathPrefix(sysPath); if (_folder->BindToFolder(sysPath, &newFolder) == S_OK) @@ -77,8 +108,20 @@ HRESULT CPanel::BindToPath(const UString &fullPath, bool &archiveIsOpened, bool UString fileName; if (NDirectory::GetOnlyName(sysPath, fileName)) { - if (OpenItemAsArchive(fileName, _currentFolderPrefix, - _currentFolderPrefix + fileName, encrypted) == S_OK) + HRESULT res = + OpenItemAsArchive(fileName, _currentFolderPrefix, + _currentFolderPrefix + fileName, + _currentFolderPrefix + fileName, + encrypted); + if (res != S_FALSE) + { + RINOK(res); + } + /* + if (res == E_ABORT) + return res; + */ + if (res == S_OK) { archiveIsOpened = true; for (int i = reducedParts.Size() - 1; i >= 0; i--) @@ -138,56 +181,79 @@ void CPanel::LoadFullPath() _currentFolderPrefix += GetFolderPath(_folder); } +static int GetRealIconIndex(LPCWSTR path, DWORD attributes) +{ + int index = -1; + if (GetRealIconIndex(path, attributes, index) != 0) + return index; + return -1; +} + void CPanel::LoadFullPathAndShow() -{ +{ LoadFullPath(); _appState->FolderHistory.AddString(_currentFolderPrefix); - // _headerComboBox.SendMessage(CB_RESETCONTENT, 0, 0); - _headerComboBox.SetText(_currentFolderPrefix); + _headerComboBox.SetText(_currentFolderPrefix); + COMBOBOXEXITEM item; + item.mask = 0; + + UString path = _currentFolderPrefix; + if (path.Length() > 3 && path[path.Length() - 1] == L'\\') + path.Delete(path.Length() - 1); + + CFileInfoW info; + DWORD attrib = FILE_ATTRIBUTE_DIRECTORY; + if (NFile::NFind::FindFile(path, info)) + attrib = info.Attrib; + + item.iImage = GetRealIconIndex(path, attrib); + + if (item.iImage >= 0) + { + item.iSelectedImage = item.iImage; + item.mask |= (CBEIF_IMAGE | CBEIF_SELECTEDIMAGE); + } + item.iItem = -1; + _headerComboBox.SetItem(&item); + RefreshTitle(); +} - /* - for (int i = 0; i < g_Folders.m_Strings.Size(); i++) +LRESULT CPanel::OnNotifyComboBoxEnter(const UString &s) +{ + if (BindToPathAndRefresh(GetUnicodeString(s)) == S_OK) { - UString string = g_Folders.m_Strings[i]; - COMBOBOXEXITEM item; - item.mask = CBEIF_TEXT; - item.iItem = i; - item.pszText = (LPTSTR)(LPCTSTR)string; - _headerComboBox.InsertItem(&item); + PostMessage(kSetFocusToListView); + return TRUE; } - */ + return FALSE; } bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result) { if (info->iWhy == CBENF_ESCAPE) { - _headerComboBox.SetText(_currentFolderPrefix); + _headerComboBox.SetText(_currentFolderPrefix); PostMessage(kSetFocusToListView); result = FALSE; return true; } + + /* if (info->iWhy == CBENF_DROPDOWN) { result = FALSE; return true; } + */ if (info->iWhy == CBENF_RETURN) { + // When we use Edit control and press Enter. UString s; _headerComboBox.GetText(s); - // length of NMCBEENDEDITW.szText is limited by MAX_PATH - // if (BindToPathAndRefresh(info->szText) != S_OK) - if (BindToPathAndRefresh(s) != S_OK) - { - result = TRUE; - return true; - } - result = FALSE; - PostMessage(kSetFocusToListView); + result = OnNotifyComboBoxEnter(s); return true; } return false; @@ -198,52 +264,144 @@ bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result) { if (info->iWhy == CBENF_ESCAPE) { - _headerComboBox.SetText(_currentFolderPrefix); + _headerComboBox.SetText(_currentFolderPrefix); PostMessage(kSetFocusToListView); result = FALSE; return true; } + /* if (info->iWhy == CBENF_DROPDOWN) { result = FALSE; return true; } + */ if (info->iWhy == CBENF_RETURN) { - if (BindToPathAndRefresh(GetUnicodeString(info->szText)) != S_OK) - { - result = TRUE; - return true; - } - result = FALSE; - PostMessage(kSetFocusToListView); + UString s; + _headerComboBox.GetText(s); + // GetUnicodeString(info->szText) + result = OnNotifyComboBoxEnter(s); return true; } return false; } #endif -void CPanel::OnComboBoxCommand(UINT /* code */, LPARAM & /* param */) +void CPanel::AddComboBoxItem(const UString &name, int iconIndex, int indent, bool addToList) { - /* - if (code == CBN_SELENDOK) + COMBOBOXEXITEMW item; + item.mask = CBEIF_TEXT | CBEIF_INDENT; + item.iSelectedImage = item.iImage = iconIndex; + if (iconIndex >= 0) + item.mask |= (CBEIF_IMAGE | CBEIF_SELECTEDIMAGE); + item.iItem = -1; + item.iIndent = indent; + item.pszText = (LPWSTR)(LPCWSTR)name; + _headerComboBox.InsertItem(&item); + if (addToList) + ComboBoxPaths.Add(name); +} + +extern UString RootFolder_GetName_Computer(int &iconIndex); +extern UString RootFolder_GetName_Network(int &iconIndex); +extern UString RootFolder_GetName_Documents(int &iconIndex); + +bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result) +{ + result = FALSE; + switch(code) { - UString path; - if (!_headerComboBox.GetText(path)) - return; - CRootFolder *rootFolderSpec = new CRootFolder; - CMyComPtr<IFolderFolder> rootFolder = rootFolderSpec; - rootFolderSpec->Init(); - CMyComPtr<IFolderFolder> newFolder; - if (rootFolder->BindToFolder(path, &newFolder) != S_OK) - return; - _folder = newFolder; - SetCurrentPathText(); - RefreshListCtrl(UString(), -1, UStringVector()); - PostMessage(kSetFocusToListView); + case CBN_DROPDOWN: + { + ComboBoxPaths.Clear(); + _headerComboBox.ResetContent(); + + int iconIndex; + UString name; + + int i; + UStringVector pathParts; + + SplitPathToParts(_currentFolderPrefix, pathParts); + UString sumPass; + for (i = 0; i < pathParts.Size(); i++) + { + UString name = pathParts[i]; + if (name.IsEmpty()) + continue; + sumPass += name; + UString curName = sumPass; + if (i == 0) + curName += L"\\"; + CFileInfoW info; + DWORD attrib = FILE_ATTRIBUTE_DIRECTORY; + if (NFile::NFind::FindFile(sumPass, info)) + attrib = info.Attrib; + sumPass += L"\\"; + AddComboBoxItem(name, GetRealIconIndex(curName, attrib), i, false); + ComboBoxPaths.Add(sumPass); + } + + name = RootFolder_GetName_Documents(iconIndex); + AddComboBoxItem(name, iconIndex, 0, true); + + name = RootFolder_GetName_Computer(iconIndex); + AddComboBoxItem(name, iconIndex, 0, true); + + UStringVector driveStrings; + MyGetLogicalDriveStrings(driveStrings); + for (i = 0; i < driveStrings.Size(); i++) + { + UString s = driveStrings[i]; + ComboBoxPaths.Add(s); + int iconIndex = GetRealIconIndex(s, 0); + if (s.Length() > 0 && s[s.Length() - 1] == '\\') + s.Delete(s.Length() - 1); + AddComboBoxItem(s, iconIndex, 1, false); + } + + name = RootFolder_GetName_Network(iconIndex); + AddComboBoxItem(name, iconIndex, 0, true); + + // UStringVector strings; _appState->FolderHistory.GetList(strings); + + return false; + } + + case CBN_SELENDOK: + { + code = code; + int index = _headerComboBox.GetCurSel(); + if (index >= 0) + { + UString pass = ComboBoxPaths[index]; + _headerComboBox.SetCurSel(-1); + _headerComboBox.SetText(pass); // it's fix for seclecting by mouse. + if (BindToPathAndRefresh(pass) == S_OK) + { + PostMessage(kSetFocusToListView); + return true; + } + } + return false; + } + /* + case CBN_CLOSEUP: + { + LoadFullPathAndShow(); + true; + + } + case CBN_SELCHANGE: + { + // LoadFullPathAndShow(); + return true; + } + */ } - */ + return false; } bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result) @@ -254,6 +412,7 @@ bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result) { _lastFocusedIsList = false; _panelCallback->PanelWasFocused(); + break; } #ifndef _UNICODE case CBEN_ENDEDIT: diff --git a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp index bf746282..afb376d0 100755 --- a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp +++ b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp @@ -2,9 +2,9 @@ #include "StdAfx.h" -#include "resource.h" +#include "resource.h" -#include "Common/StringConvert.h" +#include "Common/StringConvert.h" #include "Common/Random.h" #include "Common/StringConvert.h" #include "Common/AutoPtr.h" @@ -14,14 +14,15 @@ #include "Windows/Thread.h" #include "Windows/Synchronization.h" #include "Windows/Error.h" -// #include "Windows/COM.h" #include "ExtractCallback.h" +#include "UpdateCallback100.h" #include "IFolder.h" #include "FileFolderPluginOpen.h" #include "FormatUtils.h" #include "Panel.h" #include "RegistryUtils.h" +#include "LangUtils.h" using namespace NWindows; using namespace NSynchronization; @@ -33,9 +34,8 @@ extern HWND g_HWND; extern bool g_IsNT; #endif -static wchar_t *kTempDirPrefix = L"7zO"; +static wchar_t *kTempDirPrefix = L"7zO"; -static const wchar_t *virusMessage = L"File looks like virus (file name has long spaces in name). 7-Zip will not open it"; static bool IsNameVirus(const UString &name) { @@ -47,6 +47,9 @@ struct CTmpProcessInfo: public CTempFileInfo HANDLE ProcessHandle; HWND Window; UString FullPathFolderPrefix; + bool UsePassword; + UString Password; + CTmpProcessInfo(): UsePassword(false) {} }; class CTmpProcessInfoRelease @@ -63,18 +66,21 @@ public: } }; -HRESULT CPanel::OpenItemAsArchive(const UString &name, - const UString &folderPath, const UString &filePath, bool &encrypted) +HRESULT CPanel::OpenItemAsArchive(const UString &name, + const UString &folderPath, const UString &filePath, + const UString &virtualFilePath, + bool &encrypted) { encrypted = false; CFolderLink folderLink; if (!NFile::NFind::FindFile(filePath, folderLink.FileInfo)) return E_FAIL; - if (folderLink.FileInfo.IsDirectory()) + if (folderLink.FileInfo.IsDir()) return S_FALSE; folderLink.FilePath = filePath; folderLink.FolderPath = folderPath; + folderLink.VirtualPath = virtualFilePath; CMyComPtr<IFolderFolder> newFolder; @@ -82,8 +88,13 @@ HRESULT CPanel::OpenItemAsArchive(const UString &name, // _password.Empty(); NDLL::CLibrary library; - RINOK(OpenFileFolderPlugin(filePath, &library, &newFolder, GetParent(), encrypted)); + + UString password; + RINOK(OpenFileFolderPlugin(filePath, &library, &newFolder, GetParent(), encrypted, password)); + folderLink.Password = password; + folderLink.UsePassword = encrypted; + folderLink.ParentFolder = _folder; folderLink.ItemName = name; _parentFolders.Add(folderLink); @@ -100,7 +111,10 @@ HRESULT CPanel::OpenItemAsArchive(const UString &name, HRESULT CPanel::OpenItemAsArchive(const UString &name) { bool encrypted; - return OpenItemAsArchive(name, _currentFolderPrefix, _currentFolderPrefix + name, encrypted); + return OpenItemAsArchive(name, _currentFolderPrefix, + _currentFolderPrefix + name, + _currentFolderPrefix + name, + encrypted); } HRESULT CPanel::OpenItemAsArchive(int index) @@ -120,17 +134,17 @@ HRESULT CPanel::OpenParentArchiveFolder() NFind::CFileInfoW newFileInfo; if (NFind::FindFile(folderLink.FilePath, newFileInfo)) { - if (newFileInfo.Size != folderLink.FileInfo.Size || - CompareFileTime(&newFileInfo.LastWriteTime, - &folderLink.FileInfo.LastWriteTime) != 0) + if (newFileInfo.Size != folderLink.FileInfo.Size || + CompareFileTime(&newFileInfo.MTime, &folderLink.FileInfo.MTime) != 0) { - UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE, + UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE, 0x03020280, folderLink.ItemName); if (::MessageBoxW(HWND(*this), message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK) { - if (OnOpenItemChanged(folderLink.FolderPath, folderLink.ItemName) != S_OK) + if (OnOpenItemChanged(folderLink.FolderPath, folderLink.ItemName, + folderLink.UsePassword, folderLink.Password) != S_OK) { - ::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE, + ::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE, 0x03020281, folderLink.FilePath), L"7-Zip", MB_OK | MB_ICONSTOP); return S_OK; } @@ -141,17 +155,17 @@ HRESULT CPanel::OpenParentArchiveFolder() return S_OK; } -static const wchar_t *kStartExtensions[] = +static const wchar_t *kStartExtensions[] = { L"exe", L"bat", L"com", L"chm", L"msi", L"doc", L"xls", L"ppt", L"pps", L"wps", L"wpt", L"wks", L"xlr", L"wdb", - L"docx", L"docm", L"dotx", L"dotm", L"xlsx", L"xlsm", L"xltx", L"xltm", L"xlsb", - L"xlam", L"pptx", L"pptm", L"potx", L"potm", L"ppam", L"ppsx", L"ppsm", L"xsn", + L"docx", L"docm", L"dotx", L"dotm", L"xlsx", L"xlsm", L"xltx", L"xltm", L"xlsb", + L"xlam", L"pptx", L"pptm", L"potx", L"potm", L"ppam", L"ppsx", L"ppsm", L"xsn", L"odt", L"ods", - L"wb3", + L"wb3", L"pdf" }; @@ -198,7 +212,7 @@ static HANDLE StartEditApplication(const UString &path, HWND window) startupInfo.cbReserved2 = 0; startupInfo.lpReserved2 = 0; - result = ::CreateProcessA(NULL, (CHAR *)(const CHAR *)GetSystemString(command), + result = ::CreateProcessA(NULL, (CHAR *)(const CHAR *)GetSystemString(command), NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation); } else @@ -213,7 +227,7 @@ static HANDLE StartEditApplication(const UString &path, HWND window) startupInfo.cbReserved2 = 0; startupInfo.lpReserved2 = 0; - result = ::CreateProcessW(NULL, (WCHAR *)(const WCHAR *)command, + result = ::CreateProcessW(NULL, (WCHAR *)(const WCHAR *)command, NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation); } @@ -222,7 +236,7 @@ static HANDLE StartEditApplication(const UString &path, HWND window) ::CloseHandle(processInformation.hThread); return processInformation.hProcess; } - ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282), + ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282), L"7-Zip", MB_OK | MB_ICONSTOP); return 0; } @@ -279,7 +293,7 @@ static HANDLE StartApplication(const UString &path, HWND window) switch(result) { case SE_ERR_NOASSOC: - ::MessageBoxW(window, + ::MessageBoxW(window, NError::MyFormatMessageW(::GetLastError()), // L"There is no application associated with the given file name extension", L"7-Zip", MB_OK | MB_ICONSTOP); @@ -318,29 +332,39 @@ void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal) UString name = GetItemRelPath(index); if (IsNameVirus(name)) { - MessageBoxMyError(virusMessage); + MessageBoxErrorLang(IDS_VIRUS, 0x03020284); return; } UString fullPath = _currentFolderPrefix + name; if (tryInternal) if (!tryExternal || !DoItemAlwaysStart(name)) - if (OpenItemAsArchive(index) == S_OK) + { + HRESULT res = OpenItemAsArchive(index); + if (res == S_OK || res == E_ABORT) return; + if (res != S_FALSE) + { + MessageBoxError(res); + return; + } + } if (tryExternal) { - NDirectory::MySetCurrentDirectory(_currentFolderPrefix); + // SetCurrentDirectory opens HANDLE to folder!!! + // NDirectory::MySetCurrentDirectory(_currentFolderPrefix); HANDLE hProcess = StartApplication(fullPath, (HWND)*this); if (hProcess != 0) ::CloseHandle(hProcess); } } - -HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName) + +HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName, + bool usePassword, const UString &password) { CMyComPtr<IFolderOperations> folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return E_FAIL; } UStringVector fileNames; @@ -350,7 +374,12 @@ HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &item UString pathPrefix = folderPath; NName::NormalizeDirPathPrefix(pathPrefix); - return folderOperations->CopyFrom(pathPrefix, &fileNamePointers.Front(),fileNamePointers.Size(), NULL); + + CUpdateCallback100Imp *callbackSpec = new CUpdateCallback100Imp; + CMyComPtr<IProgress> callback = callbackSpec; + callbackSpec->Init((HWND)*this, usePassword, password); + + return folderOperations->CopyFrom(pathPrefix, &fileNamePointers.Front(), fileNamePointers.Size(), callback); } LRESULT CPanel::OnOpenItemChanged(LPARAM lParam) @@ -363,7 +392,8 @@ LRESULT CPanel::OnOpenItemChanged(LPARAM lParam) CSelectedState state; SaveSelectedState(state); - HRESULT result = OnOpenItemChanged(tmpProcessInfo.FolderPath, tmpProcessInfo.ItemName); + HRESULT result = OnOpenItemChanged(tmpProcessInfo.FolderPath, tmpProcessInfo.ItemName, + tmpProcessInfo.UsePassword, tmpProcessInfo.Password); if (result != S_OK) return 0; RefreshListCtrl(state); @@ -407,17 +437,16 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param) NFind::CFileInfoW newFileInfo; if (NFind::FindFile(tmpProcessInfo->FilePath, newFileInfo)) { - if (newFileInfo.Size != tmpProcessInfo->FileInfo.Size || - CompareFileTime(&newFileInfo.LastWriteTime, - &tmpProcessInfo->FileInfo.LastWriteTime) != 0) + if (newFileInfo.Size != tmpProcessInfo->FileInfo.Size || + CompareFileTime(&newFileInfo.MTime, &tmpProcessInfo->FileInfo.MTime) != 0) { - UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE, + UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE, 0x03020280, tmpProcessInfo->ItemName); if (::MessageBoxW(g_HWND, message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK) { if (SendMessage(tmpProcessInfo->Window, kOpenItemChanged, 0, (LONG_PTR)tmpProcessInfo) != 1) { - ::MessageBoxW(g_HWND, MyFormatNew(IDS_CANNOT_UPDATE_FILE, + ::MessageBoxW(g_HWND, MyFormatNew(IDS_CANNOT_UPDATE_FILE, 0x03020281, tmpProcessInfo->FilePath), L"7-Zip", MB_OK | MB_ICONSTOP); return 0; } @@ -428,20 +457,19 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param) return 0; } -void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, - bool editMode) +void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bool editMode) { const UString name = GetItemName(index); if (IsNameVirus(name)) { - MessageBoxMyError(virusMessage); + MessageBoxErrorLang(IDS_VIRUS, 0x03020284); return; } CMyComPtr<IFolderOperations> folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } @@ -455,7 +483,24 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, indices.Add(index); UStringVector messages; - HRESULT result = CopyTo(indices, tempDirNorm, false, true, &messages); + + bool usePassword = false; + UString password; + if (_parentFolders.Size() > 0) + { + const CFolderLink &fl = _parentFolders.Back(); + usePassword = fl.UsePassword; + password = fl.Password; + } + + HRESULT result = CopyTo(indices, tempDirNorm, false, true, &messages, usePassword, password); + + if (_parentFolders.Size() > 0) + { + CFolderLink &fl = _parentFolders.Back(); + fl.UsePassword = usePassword; + fl.Password = password; + } if (!messages.IsEmpty()) return; @@ -472,6 +517,9 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get(); tmpProcessInfo->FolderPath = tempDir; tmpProcessInfo->FilePath = tempFilePath; + tmpProcessInfo->UsePassword = usePassword; + tmpProcessInfo->Password = password; + if (!NFind::FindFile(tempFilePath, tmpProcessInfo->FileInfo)) return; @@ -480,7 +528,8 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, if (!tryExternal || !DoItemAlwaysStart(name)) { bool encrypted; - if (OpenItemAsArchive(name, tempDir, tempFilePath, encrypted) == S_OK) + if (OpenItemAsArchive(name, tempDir, tempFilePath, + _currentFolderPrefix + name, encrypted) == S_OK) { RefreshListCtrl(); return; @@ -530,21 +579,18 @@ void DeleteOldTempFiles() if(!NFile::NDirectory::MyGetTempPath(tempPath)) throw 1; - SYSTEMTIME systemTime; - ::GetSystemTime(&systemTime); UINT64 currentFileTime; - if(!::SystemTimeToFileTime(&systemTime, (FILETIME *)¤tFileTime)) - throw 2; + NTime::GetCurUtcFileTime(currentFileTime); UString searchWildCard = tempPath + kTempDirPrefix + L"*.tmp"; searchWildCard += WCHAR(NName::kAnyStringWildcard); NFind::CEnumeratorW enumerator(searchWildCard); NFind::CFileInfoW fileInfo; while(enumerator.Next(fileInfo)) { - if (!fileInfo.IsDirectory()) + if (!fileInfo.IsDir()) continue; - const UINT64 &creationTime = *(const UINT64 *)(&fileInfo.CreationTime); - if(CheckDeleteItem(creationTime, currentFileTime)) + const UINT64 &cTime = *(const UINT64 *)(&fileInfo.CTime); + if(CheckDeleteItem(cTime, currentFileTime)) RemoveDirectoryWithSubItems(tempPath + fileInfo.Name); } } diff --git a/CPP/7zip/UI/FileManager/PanelItems.cpp b/CPP/7zip/UI/FileManager/PanelItems.cpp index 41ef45dd..89b47ec7 100755 --- a/CPP/7zip/UI/FileManager/PanelItems.cpp +++ b/CPP/7zip/UI/FileManager/PanelItems.cpp @@ -4,19 +4,18 @@ #include "Common/StringConvert.h" +#include "Windows/Menu.h" #include "Windows/PropVariant.h" #include "Windows/PropVariantConversions.h" -#include "Windows/Menu.h" #include "../../PropID.h" -#include "Panel.h" #include "resource.h" -#include "RootFolder.h" - -#include "PropertyName.h" #include "LangUtils.h" +#include "Panel.h" +#include "PropertyName.h" +#include "RootFolder.h" extern "C" { @@ -29,9 +28,9 @@ static int GetColumnAlign(PROPID propID, VARTYPE varType) { switch(propID) { - case kpidCreationTime: - case kpidLastAccessTime: - case kpidLastWriteTime: + case kpidCTime: + case kpidATime: + case kpidMTime: return LVCFMT_LEFT; } switch(varType) @@ -45,7 +44,7 @@ static int GetColumnAlign(PROPID propID, VARTYPE varType) case VT_UINT: case VT_I8: case VT_UI8: - case VT_BOOL: + case VT_BOOL: return LVCFMT_RIGHT; case VT_EMPTY: @@ -84,7 +83,7 @@ void CPanel::InitColumns() _needSaveInfo = true; UInt32 numProperties; - _folder->GetNumberOfProperties(&numProperties); + _folder->GetNumberOfProperties(&numProperties); int i; for (i = 0; i < (int)numProperties; i++) { @@ -95,24 +94,17 @@ void CPanel::InitColumns() if (_folder->GetPropertyInfo(i, &name, &propID, &varType) != S_OK) throw 1; - CItemProperty destProperty; - destProperty.Type = varType; - destProperty.ID = propID; - if (propID == kpidIsFolder) + if (propID == kpidIsDir) continue; - { - if (name != NULL) - destProperty.Name = name; - else - destProperty.Name = L"Error"; - } - UString propName = GetNameOfProperty(propID); - if (!propName.IsEmpty()) - destProperty.Name = propName; - destProperty.Order = -1; - destProperty.IsVisible = true; - destProperty.Width = 100; - _properties.Add(destProperty); + + CItemProperty prop; + prop.Type = varType; + prop.ID = propID; + prop.Name = GetNameOfProperty(propID, name); + prop.Order = -1; + prop.IsVisible = true; + prop.Width = 100; + _properties.Add(prop); } // InitColumns2(sortID); @@ -177,10 +169,7 @@ void CPanel::InsertColumn(int index) column.fmt = GetColumnAlign(property.ID, property.Type); column.iOrder = property.Order; column.iSubItem = index; - UString propertyName = GetNameOfProperty(property.ID); - if (propertyName.IsEmpty()) - propertyName = property.Name; - column.pszText = (wchar_t *)(const wchar_t *)propertyName; + column.pszText = (wchar_t *)(const wchar_t *)property.Name; _listView.InsertColumn(index, &column); } @@ -338,7 +327,7 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se _listView.SetItemCount(numItems + (showDots ? 1 : 0)); _selectedStatusVector.Reserve(numItems); - int cursorIndex = -1; + int cursorIndex = -1; CMyComPtr<IFolderGetSystemIconIndex> folderGetSystemIconIndex; if (!IsFSFolder() || _showRealFileIcons) @@ -414,7 +403,7 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se item.pszText = (wchar_t *)(const wchar_t *)itemName; NCOM::CPropVariant propVariant; - _folder->GetProperty(i, kpidAttributes, &propVariant); + _folder->GetProperty(i, kpidAttrib, &propVariant); UInt32 attributes = 0; if (propVariant.vt == VT_UI4) attributes = propVariant.ulVal; @@ -459,7 +448,7 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se { if (focusedPos >= _listView.GetItemCount()) focusedPos = _listView.GetItemCount() - 1; - SetFocusedSelectedItem(focusedPos, true); + SetFocusedSelectedItem(focusedPos, showDots); } // m_RedrawEnabled = true; _listView.EnsureVisible(_listView.GetFocusedItem(), false); @@ -517,6 +506,13 @@ void CPanel::GetAllItemIndices(CRecordVector<UInt32> &indices) const indices.Add(i); } +void CPanel::GetOperatedIndicesSmart(CRecordVector<UInt32> &indices) const +{ + GetOperatedItemIndices(indices); + if (indices.IsEmpty() || (indices.Size() == 1 && indices[0] == (UInt32)(Int32)-1)) + GetAllItemIndices(indices); +} + /* void CPanel::GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const { @@ -568,7 +564,7 @@ void CPanel::OpenSelectedItems(bool tryInternal) GetOperatedItemIndices(indices); if (indices.Size() > 20) { - MessageBox(LangString(IDS_TOO_MANY_ITEMS, 0x02000606)); + MessageBoxErrorLang(IDS_TOO_MANY_ITEMS, 0x02000606); return; } @@ -640,7 +636,7 @@ bool CPanel::IsItemFolder(int itemIndex) const if (itemIndex == kParentIndex) return true; NCOM::CPropVariant propVariant; - if (_folder->GetProperty(itemIndex, kpidIsFolder, &propVariant) != S_OK) + if (_folder->GetProperty(itemIndex, kpidIsDir, &propVariant) != S_OK) throw 2723400; if (propVariant.vt == VT_BOOL) return VARIANT_BOOLToBool(propVariant.boolVal); @@ -745,7 +741,7 @@ bool CPanel::OnRightClick(LPNMITEMACTIVATE itemActiveate, LRESULT &result) flags |= MF_GRAYED; menu.AppendItem(flags, kCommandStart + i, GetSystemString(property.Name)); } - int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY, + int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY, point.x, point.y, _listView); if (menuResult >= kCommandStart && menuResult <= kCommandStart + _properties.Size()) { diff --git a/CPP/7zip/UI/FileManager/PanelKey.cpp b/CPP/7zip/UI/FileManager/PanelKey.cpp index 218476ed..8e3eaaa1 100755 --- a/CPP/7zip/UI/FileManager/PanelKey.cpp +++ b/CPP/7zip/UI/FileManager/PanelKey.cpp @@ -16,11 +16,11 @@ struct CVKeyPropIDPair PROPID PropID; }; -static CVKeyPropIDPair g_VKeyPropIDPairs[] = +static CVKeyPropIDPair g_VKeyPropIDPairs[] = { { VK_F3, kpidName }, { VK_F4, kpidExtension }, - { VK_F5, kpidLastWriteTime }, + { VK_F5, kpidMTime }, { VK_F6, kpidSize }, { VK_F7, kpidNoProperty } }; @@ -48,7 +48,7 @@ bool CPanel::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result) bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; result = 0; - if (keyDownInfo->wVKey >= '0' && keyDownInfo->wVKey <= '9' && + if (keyDownInfo->wVKey >= '0' && keyDownInfo->wVKey <= '9' && (rightCtrl || alt)) { int index = keyDownInfo->wVKey - '0'; @@ -64,7 +64,7 @@ bool CPanel::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result) } } - if ((keyDownInfo->wVKey == VK_F2 || + if ((keyDownInfo->wVKey == VK_F2 || keyDownInfo->wVKey == VK_F1) && alt && !ctrl && !shift) { _panelCallback->SetFocusToPath(keyDownInfo->wVKey == VK_F1 ? 0 : 1); diff --git a/CPP/7zip/UI/FileManager/PanelListNotify.cpp b/CPP/7zip/UI/FileManager/PanelListNotify.cpp index 572118d0..21600a68 100755 --- a/CPP/7zip/UI/FileManager/PanelListNotify.cpp +++ b/CPP/7zip/UI/FileManager/PanelListNotify.cpp @@ -51,7 +51,7 @@ static UString ConvertSizeToStringShort(UInt64 value) return s; } -static UString ConvertSizeToString(UInt64 value) +UString ConvertSizeToString(UInt64 value) { wchar_t s[32]; ConvertUInt64ToString(value, s); @@ -90,22 +90,16 @@ LRESULT CPanel::SetItemText(LVITEMW &item) if (!defined) { NCOM::CPropVariant prop; - _folder->GetProperty(index, kpidAttributes, &prop); - UINT32 attributes = 0; + _folder->GetProperty(index, kpidAttrib, &prop); + UINT32 attrib = 0; if (prop.vt == VT_UI4) - attributes = prop.ulVal; - else - { - if (IsItemFolder(index)) - attributes |= FILE_ATTRIBUTE_DIRECTORY; - } + attrib = prop.ulVal; + else if (IsItemFolder(index)) + attrib |= FILE_ATTRIBUTE_DIRECTORY; if (_currentFolderPrefix.IsEmpty()) - { throw 1; - } else - item.iImage = _extToIconMap.GetIconIndex(attributes, - GetSystemString(GetItemName(index))); + item.iImage = _extToIconMap.GetIconIndex(attrib, GetSystemString(GetItemName(index))); } // item.iImage = 1; } @@ -156,8 +150,8 @@ LRESULT CPanel::SetItemText(LVITEMW &item) if (_folder->GetProperty(realIndex, propID, &prop) != S_OK) throw 2723407; - if ((propID == kpidSize || propID == kpidPackedSize || propID == kpidClusterSize || - propID == kpidNumSubFolders || propID == kpidNumSubFiles) && + if ((propID == kpidSize || propID == kpidPackSize || propID == kpidClusterSize || + propID == kpidNumSubDirs || propID == kpidNumSubFiles) && (prop.vt == VT_UI8 || prop.vt == VT_UI4)) s = ConvertSizeToString(ConvertPropVariantToUInt64(prop)); else if ((propID == kpidTotalSize || propID == kpidFreeSpace) && @@ -166,8 +160,8 @@ LRESULT CPanel::SetItemText(LVITEMW &item) else { s = ConvertPropertyToString(prop, propID, false); - s.Replace(wchar_t(0xA), L' '); - s.Replace(wchar_t(0xD), L' '); + s.Replace(wchar_t(0xA), L' '); + s.Replace(wchar_t(0xD), L' '); } int size = item.cchTextMax; if(size > 0) @@ -224,7 +218,7 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result) //is the sub-item information being requested? - if((dispInfo->item.mask & LVIF_TEXT) != 0 || + if((dispInfo->item.mask & LVIF_TEXT) != 0 || (dispInfo->item.mask & LVIF_IMAGE) != 0) SetItemText(dispInfo->item); return false; @@ -327,7 +321,7 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result) bool CPanel::OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result) { - switch(lplvcd->nmcd.dwDrawStage) + switch(lplvcd->nmcd.dwDrawStage) { case CDDS_PREPAINT : result = CDRF_NOTIFYITEMDRAW; @@ -410,8 +404,8 @@ void CPanel::OnRefreshStatusBar() { sizeString = ConvertSizeToString(GetItemSize(realIndex)); NCOM::CPropVariant prop; - if (_folder->GetProperty(realIndex, kpidLastWriteTime, &prop) == S_OK) - dateString = ConvertPropertyToString(prop, kpidLastWriteTime, false); + if (_folder->GetProperty(realIndex, kpidMTime, &prop) == S_OK) + dateString = ConvertPropertyToString(prop, kpidMTime, false); } } _statusBar.SetText(2, sizeString); diff --git a/CPP/7zip/UI/FileManager/PanelMenu.cpp b/CPP/7zip/UI/FileManager/PanelMenu.cpp index 8ebbc8ac..c881d8b8 100755 --- a/CPP/7zip/UI/FileManager/PanelMenu.cpp +++ b/CPP/7zip/UI/FileManager/PanelMenu.cpp @@ -5,6 +5,7 @@ #include "Windows/COM.h" #include "Windows/PropVariant.h" #include "Windows/Clipboard.h" +#include "Windows/PropVariantConversions.h" #include "../Common/PropIDUtils.h" #include "../../PropID.h" @@ -20,7 +21,7 @@ using namespace NWindows; // {23170F69-40C1-278A-1000-000100020000} -DEFINE_GUID(CLSID_CZipContextMenu, +DEFINE_GUID(CLSID_CZipContextMenu, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00); static const UINT kSevenZipStartMenuID = kPluginMenuStartID ; @@ -50,18 +51,30 @@ void CPanel::InvokeSystemCommand(const char *command) static const wchar_t *kSeparator = L"--------------------------------------\n"; static const wchar_t *kPropValueSeparator = L": "; -static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR, +extern UString ConvertSizeToString(UInt64 value); + +static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR, const NCOM::CPropVariant &prop, UString &s) { if (prop.vt != VT_EMPTY) { - UString name = GetNameOfProperty(propID); - if (name.IsEmpty() && nameBSTR != NULL) - name = nameBSTR; - if (name.IsEmpty()) - name = L"?"; - - const UString val = ConvertPropertyToString(prop, propID); + const UString name = GetNameOfProperty(propID, nameBSTR); + UString val; + + if (( + propID == kpidSize || + propID == kpidPackSize || + propID == kpidNumSubDirs || + propID == kpidNumSubFiles || + propID == kpidNumBlocks || + propID == kpidPhySize || + propID == kpidHeadersSize || + propID == kpidClusterSize + ) && (prop.vt == VT_UI8 || prop.vt == VT_UI4)) + val = ConvertSizeToString(ConvertPropVariantToUInt64(prop)); + else + val = ConvertPropertyToString(prop, propID); + if (!val.IsEmpty()) { s += name; @@ -77,7 +90,7 @@ static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR, } void CPanel::Properties() -{ +{ CMyComPtr<IGetFolderArchiveProperties> getFolderArchiveProperties; _folder.QueryInterface(IID_IGetFolderArchiveProperties, &getFolderArchiveProperties); if (!getFolderArchiveProperties) @@ -224,7 +237,7 @@ void CPanel::EditPaste() s += names[i]; } - MessageBoxW(0, s, L"", 0); + MessageBoxW(0, s, L"", 0); */ // InvokeSystemCommand("paste"); @@ -239,7 +252,7 @@ HRESULT CPanel::CreateShellContextMenu( CMyComPtr<IShellFolder> desktopFolder; RINOK(::SHGetDesktopFolder(&desktopFolder)); - if (!desktopFolder) + if (!desktopFolder) { // ShowMessage("Failed to get Desktop folder."); return E_FAIL; @@ -253,7 +266,7 @@ HRESULT CPanel::CreateShellContextMenu( LPITEMIDLIST parentPidl; DWORD eaten; RINOK(desktopFolder->ParseDisplayName( - GetParent(), 0, (wchar_t *)(const wchar_t *)folderPath, + GetParent(), 0, (wchar_t *)(const wchar_t *)folderPath, &eaten, &parentPidl, 0)); // Get an IShellFolder for the folder @@ -261,7 +274,7 @@ HRESULT CPanel::CreateShellContextMenu( CMyComPtr<IShellFolder> parentFolder; RINOK(desktopFolder->BindToObject(parentPidl, 0, IID_IShellFolder, (void**)&parentFolder)); - if (!parentFolder) + if (!parentFolder) { // ShowMessage("Invalid file name."); return E_FAIL; @@ -276,7 +289,7 @@ HRESULT CPanel::CreateShellContextMenu( UString fileName = GetItemRelPath(operatedIndices[i]); if (IsFSDrivesFolder()) fileName += L'\\'; - RINOK(parentFolder->ParseDisplayName(GetParent(), 0, + RINOK(parentFolder->ParseDisplayName(GetParent(), 0, (wchar_t *)(const wchar_t *)fileName, &eaten, &pidl, 0)); pidls.Add(pidl); } @@ -287,7 +300,7 @@ HRESULT CPanel::CreateShellContextMenu( temp.mkid.cb = 0; /* LPITEMIDLIST pidl; - HRESULT result = parentFolder->ParseDisplayName(GetParent(), 0, + HRESULT result = parentFolder->ParseDisplayName(GetParent(), 0, L".\\", &eaten, &pidl, 0); if (result != NOERROR) return; @@ -297,9 +310,9 @@ HRESULT CPanel::CreateShellContextMenu( // Get the IContextMenu for the file. CMyComPtr<IContextMenu> cm; - RINOK( parentFolder->GetUIObjectOf(GetParent(), pidls.Size(), + RINOK( parentFolder->GetUIObjectOf(GetParent(), pidls.Size(), (LPCITEMIDLIST *)&pidls.Front(), IID_IContextMenu, 0, (void**)&cm)); - if (!cm) + if (!cm) { // ShowMessage("Unable to get context menu interface."); return E_FAIL; @@ -308,7 +321,7 @@ HRESULT CPanel::CreateShellContextMenu( return S_OK; } -void CPanel::CreateSystemMenu(HMENU menuSpec, +void CPanel::CreateSystemMenu(HMENU menuSpec, const CRecordVector<UInt32> &operatedIndices, CMyComPtr<IContextMenu> &systemContextMenu) { @@ -326,7 +339,7 @@ void CPanel::CreateSystemMenu(HMENU menuSpec, ci.hwnd = GetParent(); /* - if (Sender == GoBtn) + if (Sender == GoBtn) { // Verbs that can be used are cut, paste, // properties, delete, and so on. @@ -346,8 +359,8 @@ void CPanel::CreateSystemMenu(HMENU menuSpec, ShowMessage( "Error copying file to clipboard."); - } - else + } + else */ { // HMENU hMenu = CreatePopupMenu(); @@ -381,7 +394,7 @@ void CPanel::CreateSystemMenu(HMENU menuSpec, menu.InsertItem(0, true, menuItem); } /* - if (Cmd < 100 && Cmd != 0) + if (Cmd < 100 && Cmd != 0) { ci.lpVerb = MAKEINTRESOURCE(Cmd - 1); ci.lpParameters = ""; @@ -393,7 +406,7 @@ void CPanel::CreateSystemMenu(HMENU menuSpec, // inserted menu items. else // Find the menu item. - for (int i = 0; i < popupMenu1->Items->Count; i++) + for (int i = 0; i < popupMenu1->Items->Count; i++) { TMenuItem* menu = popupMenu1->Items->Items[i]; // Call its OnClick handler. @@ -411,7 +424,7 @@ void CPanel::CreateFileMenu(HMENU menuSpec) CreateFileMenu(menuSpec, _sevenZipContextMenu, _systemContextMenu, true); } -void CPanel::CreateSevenZipMenu(HMENU menuSpec, +void CPanel::CreateSevenZipMenu(HMENU menuSpec, const CRecordVector<UInt32> &operatedIndices, CMyComPtr<IContextMenu> &sevenZipContextMenu) { @@ -443,7 +456,7 @@ void CPanel::CreateSevenZipMenu(HMENU menuSpec, if (initContextMenu->InitContextMenu(currentFolderUnicode, &namePointers.Front(), operatedIndices.Size()) == S_OK) { - HRESULT res = contextMenu->QueryContextMenu(menu, 0, kSevenZipStartMenuID, + HRESULT res = contextMenu->QueryContextMenu(menu, 0, kSevenZipStartMenuID, kSystemStartMenuID - 1, 0); sevenZipMenuCreated = (HRESULT_SEVERITY(res) == SEVERITY_SUCCESS); if (sevenZipMenuCreated) @@ -454,7 +467,7 @@ void CPanel::CreateSevenZipMenu(HMENU menuSpec, } } -void CPanel::CreateFileMenu(HMENU menuSpec, +void CPanel::CreateFileMenu(HMENU menuSpec, CMyComPtr<IContextMenu> &sevenZipContextMenu, CMyComPtr<IContextMenu> &systemContextMenu, bool programMenu) @@ -475,7 +488,13 @@ void CPanel::CreateFileMenu(HMENU menuSpec, if (menu.GetItemCount() > 0) menu.AppendItem(MF_SEPARATOR, 0, (LPCTSTR)0); - LoadFileMenu(menu, menu.GetItemCount(), !operatedIndices.IsEmpty(), programMenu); + int i; + for (i = 0; i < operatedIndices.Size(); i++) + if (IsItemFolder(operatedIndices[i])) + break; + bool allAreFiles = (i == operatedIndices.Size()); + LoadFileMenu(menu, menu.GetItemCount(), programMenu, + IsFSFolder(), operatedIndices.Size(), allAreFiles); } bool CPanel::InvokePluginCommand(int id) @@ -483,7 +502,7 @@ bool CPanel::InvokePluginCommand(int id) return InvokePluginCommand(id, _sevenZipContextMenu, _systemContextMenu); } -bool CPanel::InvokePluginCommand(int id, +bool CPanel::InvokePluginCommand(int id, IContextMenu *sevenZipContextMenu, IContextMenu *systemContextMenu) { UInt32 offset; @@ -576,7 +595,7 @@ bool CPanel::OnContextMenu(HANDLE windowHandle, int xPos, int yPos) CMyComPtr<IContextMenu> systemContextMenu; CreateFileMenu(menu, sevenZipContextMenu, systemContextMenu, false); - int result = menu.Track(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, + int result = menu.Track(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, xPos, yPos, _listView); if (result == 0) diff --git a/CPP/7zip/UI/FileManager/PanelOperations.cpp b/CPP/7zip/UI/FileManager/PanelOperations.cpp index 2cdabdc1..76de0c1a 100755 --- a/CPP/7zip/UI/FileManager/PanelOperations.cpp +++ b/CPP/7zip/UI/FileManager/PanelOperations.cpp @@ -28,51 +28,88 @@ using namespace NFile; extern bool g_IsNT; #endif -struct CThreadDelete +enum EFolderOpType { - CMyComPtr<IFolderOperations> FolderOperations; + FOLDER_TYPE_CREATE_FOLDER = 0, + FOLDER_TYPE_DELETE = 1, + FOLDER_TYPE_RENAME = 2 +}; + +struct CThreadFolderOperations +{ + EFolderOpType OpType; + UString Name; + UInt32 Index; CRecordVector<UInt32> Indices; + + CMyComPtr<IFolderOperations> FolderOperations; CMyComPtr<IProgress> UpdateCallback; CUpdateCallback100Imp *UpdateCallbackSpec; HRESULT Result; - DWORD Process() + CThreadFolderOperations(EFolderOpType opType); + + void Process() { NCOM::CComInitializer comInitializer; UpdateCallbackSpec->ProgressDialog.WaitCreating(); - Result = FolderOperations->Delete(&Indices.Front(), Indices.Size(), UpdateCallback); + + switch(OpType) + { + case FOLDER_TYPE_CREATE_FOLDER: + Result = FolderOperations->CreateFolder(Name, UpdateCallback); + break; + case FOLDER_TYPE_DELETE: + Result = FolderOperations->Delete(&Indices.Front(), Indices.Size(), UpdateCallback); + break; + case FOLDER_TYPE_RENAME: + Result = FolderOperations->Rename(Index, Name, UpdateCallback); + break; + default: + Result = E_FAIL; + } UpdateCallbackSpec->ProgressDialog.MyClose(); - return 0; } static THREAD_FUNC_DECL MyThreadFunction(void *param) { - return ((CThreadDelete *)param)->Process(); + ((CThreadFolderOperations *)param)->Process(); + return 0; } }; -struct CThreadCreateFolder +CThreadFolderOperations::CThreadFolderOperations(EFolderOpType opType): OpType(opType) {}; + +static void DoOperation(CThreadFolderOperations &op, CPanel &panel, const UString &progressTitle) { - CMyComPtr<IFolderOperations> FolderOperations; - UString Name; - CMyComPtr<IProgress> UpdateCallback; - CUpdateCallback100Imp *UpdateCallbackSpec; - HRESULT Result; - - DWORD Process() - { - NCOM::CComInitializer comInitializer; - UpdateCallbackSpec->ProgressDialog.WaitCreating(); - Result = FolderOperations->CreateFolder(Name, UpdateCallback); - UpdateCallbackSpec->ProgressDialog.MyClose(); - return 0; - } - - static THREAD_FUNC_DECL MyThreadFunction(void *param) + op.UpdateCallbackSpec = new CUpdateCallback100Imp; + op.UpdateCallback = op.UpdateCallbackSpec; + + bool usePassword = false; + UString password; + if (panel._parentFolders.Size() > 0) { - return ((CThreadCreateFolder *)param)->Process(); + const CFolderLink &fl = panel._parentFolders.Back(); + usePassword = fl.UsePassword; + password = fl.Password; } -}; + + op.UpdateCallbackSpec->Init(panel.GetParent(), usePassword, password); + + op.UpdateCallbackSpec->ProgressDialog.MainWindow = panel._mainWindow; + op.UpdateCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000); + op.UpdateCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" "); + + // op.FolderOperations = folderOperations; + // op.Index = realIndex; + // op.Name = newName; + // HRESULT result = folderOperations->Rename(realIndex, newName, 0); + + NWindows::CThread thread; + if (thread.Create(CThreadFolderOperations::MyThreadFunction, &op) != S_OK) + throw 271824; + op.UpdateCallbackSpec->StartProgressDialog(progressTitle); +} #ifndef _UNICODE typedef int (WINAPI * SHFileOperationWP)(LPSHFILEOPSTRUCTW lpFileOp); @@ -87,7 +124,7 @@ void CPanel::DeleteItems(bool toRecycleBin) return; CSelectedState state; SaveSelectedState(state); - bool useInternalDelete = false; + bool useInternalDelete = false; if (IsFSFolder() && toRecycleBin) { #ifndef _UNICODE @@ -143,7 +180,7 @@ void CPanel::DeleteItems(bool toRecycleBin) { if (toRecycleBin) { - MessageBoxMyError(L"You can't send file with long path to Recycle Bin"); + MessageBoxErrorLang(IDS_ERROR_LONG_PATH_TO_RECYCLE, 0x03020218); return; } useInternalDelete = true; @@ -190,7 +227,7 @@ void CPanel::DeleteItemsInternal(CRecordVector<UInt32> &indices) CMyComPtr<IFolderOperations> folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } @@ -214,35 +251,19 @@ void CPanel::DeleteItemsInternal(CRecordVector<UInt32> &indices) else { title = LangString(IDS_CONFIRM_ITEMS_DELETE, 0x03020212); - message = MyFormatNew(IDS_WANT_TO_DELETE_ITEMS, 0x03020215, + message = MyFormatNew(IDS_WANT_TO_DELETE_ITEMS, 0x03020215, NumberToString(indices.Size())); } if (::MessageBoxW(GetParent(), message, title, MB_OKCANCEL | MB_ICONQUESTION) != IDOK) return; { - CThreadDelete deleter; - deleter.UpdateCallbackSpec = new CUpdateCallback100Imp; - deleter.UpdateCallback = deleter.UpdateCallbackSpec; - deleter.UpdateCallbackSpec->Init(GetParent(), false, L""); - - UString progressTitle = LangString(IDS_DELETING, 0x03020216); - - deleter.UpdateCallbackSpec->ProgressDialog.MainWindow = _mainWindow; - deleter.UpdateCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000); - deleter.UpdateCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" "); - - deleter.FolderOperations = folderOperations; - deleter.Indices = indices; - - NWindows::CThread thread; - if (thread.Create(CThreadDelete::MyThreadFunction, &deleter) != S_OK) - throw 271824; - deleter.UpdateCallbackSpec->StartProgressDialog(progressTitle); - - HRESULT result = deleter.Result; - if (result != S_OK) - MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217)); + CThreadFolderOperations op(FOLDER_TYPE_DELETE); + op.FolderOperations = folderOperations; + op.Indices = indices; + DoOperation(op, *this, LangString(IDS_DELETING, 0x03020216)); + if (op.Result != S_OK) + MessageBoxError(op.Result, LangString(IDS_ERROR_DELETING, 0x03020217)); } RefreshTitleAlways(); } @@ -265,7 +286,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh) CMyComPtr<IFolderOperations> folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxMyError(L"Renaming is not supported"); + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return FALSE; } const UString newName = lpnmh->item.pszText; @@ -277,12 +298,21 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh) if (realIndex == kParentIndex) return FALSE; const UString prefix = GetItemPrefix(realIndex); - HRESULT result = folderOperations->Rename(realIndex, newName, 0); - if (result != S_OK) + + { - MessageBoxError(result, LangString(IDS_ERROR_RENAMING, 0x03020221)); - return FALSE; + CThreadFolderOperations op(FOLDER_TYPE_RENAME); + op.FolderOperations = folderOperations; + op.Index = realIndex; + op.Name = newName; + DoOperation(op, *this, LangString(IDS_RENAMING, 0x03020220)); + if (op.Result != S_OK) + { + MessageBoxError(op.Result, LangString(IDS_ERROR_RENAMING, 0x03020221)); + return FALSE; + } } + // Can't use RefreshListCtrl here. // RefreshListCtrlSaveFocused(); _selectedState.FocusedName = prefix + newName; @@ -291,7 +321,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh) // We need clear all items to disable GetText before Reload: // number of items can change. // _listView.DeleteAllItems(); - // But seems it can still call GetText (maybe for current item) + // But seems it can still call GetText (maybe for current item) // so we can't delete items. _dontShowMode = true; @@ -305,7 +335,7 @@ void CPanel::CreateFolder() CMyComPtr<IFolderOperations> folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); @@ -320,34 +350,17 @@ void CPanel::CreateFolder() UString newName = comboDialog.Value; - // HRESULT result = folderOperations->CreateFolder(newName, 0); - { - CThreadCreateFolder upd; - upd.UpdateCallbackSpec = new CUpdateCallback100Imp; - upd.UpdateCallback = upd.UpdateCallbackSpec; - upd.UpdateCallbackSpec->Init(GetParent(), false, L""); - - UString progressTitle = LangString(IDS_CREATE_FOLDER, 0x03020230); - - upd.UpdateCallbackSpec->ProgressDialog.MainWindow = _mainWindow; - upd.UpdateCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000); - upd.UpdateCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" "); - - upd.FolderOperations = folderOperations; - upd.Name = newName; - - NWindows::CThread thread; - if (thread.Create(CThreadCreateFolder::MyThreadFunction, &upd) != S_OK) - throw 271824; - upd.UpdateCallbackSpec->StartProgressDialog(progressTitle); + CThreadFolderOperations op(FOLDER_TYPE_CREATE_FOLDER); + op.FolderOperations = folderOperations; + op.Name = newName; + DoOperation(op, *this, LangString(IDS_CREATE_FOLDER, 0x03020230)); - HRESULT result = upd.Result; - - if (result != S_OK) - { - MessageBoxError(result, LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233)); - return; + if (op.Result != S_OK) + { + MessageBoxError(op.Result, LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233)); + return; + } } int pos = newName.Find(L'\\'); if (pos >= 0) @@ -356,7 +369,6 @@ void CPanel::CreateFolder() state.SelectedNames.Clear(); state.FocusedName = newName; state.SelectFocused = true; - } RefreshTitleAlways(); RefreshListCtrl(state); } @@ -366,7 +378,7 @@ void CPanel::CreateFile() CMyComPtr<IFolderOperations> folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); @@ -416,11 +428,11 @@ void CPanel::ChangeComment() CMyComPtr<IFolderOperations> folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } - UString comment; + UString comment; { NCOM::CPropVariant propVariant; if (_folder->GetProperty(realIndex, kpidComment, &propVariant) != S_OK) diff --git a/CPP/7zip/UI/FileManager/PanelSelect.cpp b/CPP/7zip/UI/FileManager/PanelSelect.cpp index 4b726b1e..bbd4a187 100755 --- a/CPP/7zip/UI/FileManager/PanelSelect.cpp +++ b/CPP/7zip/UI/FileManager/PanelSelect.cpp @@ -97,7 +97,7 @@ void CPanel::OnInsert() int nextIndex = focusedItem + 1; if (nextIndex < _listView.GetItemCount()) { - _listView.SetItemState(nextIndex, LVIS_FOCUSED | LVIS_SELECTED, + _listView.SetItemState(nextIndex, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); _listView.EnsureVisible(nextIndex, false); } @@ -151,7 +151,7 @@ void CPanel::UpdateSelection() void CPanel::SelectSpec(bool selectMode) { CComboDialog comboDialog; - comboDialog.Title = selectMode ? + comboDialog.Title = selectMode ? LangString(IDS_SELECT, 0x03020250): LangString(IDS_DESELECT, 0x03020251); comboDialog.Static = LangString(IDS_SELECT_MASK, 0x03020252); @@ -279,7 +279,7 @@ void CPanel::OnLeftClick(LPNMITEMACTIVATE itemActivate) } } } - else + else { _startGroupSelect = indexInList; if ((itemActivate->uKeyFlags & LVKF_CONTROL) != 0) diff --git a/CPP/7zip/UI/FileManager/PanelSort.cpp b/CPP/7zip/UI/FileManager/PanelSort.cpp index c5fddcd6..7eabc9ef 100755 --- a/CPP/7zip/UI/FileManager/PanelSort.cpp +++ b/CPP/7zip/UI/FileManager/PanelSort.cpp @@ -20,7 +20,7 @@ static UString GetExtension(const UString &name) int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData) { - if(lpData == NULL) + if (lpData == NULL) return 0; CPanel *panel = (CPanel*)lpData; @@ -55,7 +55,7 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData) /* if (panel->_sortIndex == 1) return MyCompare(file1.Size, file2.Size); - return ::CompareFileTime(&file1.LastWriteTime, &file2.LastWriteTime); + return ::CompareFileTime(&file1.MTime, &file2.MTime); */ // PROPID propID = panel->_properties[panel->_sortIndex].ID; @@ -65,7 +65,7 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData) // Name must be first property panel->_folder->GetProperty((UINT32)lParam1, propID, &propVariant1); panel->_folder->GetProperty((UINT32)lParam2, propID, &propVariant2); - if(propVariant1.vt != propVariant2.vt) + if (propVariant1.vt != propVariant2.vt) return 0; // It means some BUG if (propVariant1.vt == VT_BSTR) { @@ -77,22 +77,17 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData) int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData) { - if(lpData == NULL) - return 0; - if (lParam1 == kParentIndex) - return -1; - if (lParam2 == kParentIndex) - return 1; + if (lpData == NULL) return 0; + if (lParam1 == kParentIndex) return -1; + if (lParam2 == kParentIndex) return 1; CPanel *panel = (CPanel*)lpData; - bool isDirectory1 = panel->IsItemFolder((int)lParam1); - bool isDirectory2 = panel->IsItemFolder((int)lParam2); + bool isDir1 = panel->IsItemFolder((int)lParam1); + bool isDir2 = panel->IsItemFolder((int)lParam2); - if(isDirectory1 && (!isDirectory2)) - return -1; - if((!isDirectory1) && isDirectory2) - return 1; + if (isDir1 && !isDir2) return -1; + if (isDir2 && !isDir1) return 1; int result = CompareItems2(lParam1, lParam2, lpData); return panel->_ascending ? result: (-result); @@ -102,7 +97,7 @@ int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData) /* void CPanel::SortItems(int index) { - if(index == _sortIndex) + if (index == _sortIndex) _ascending = !_ascending; else { @@ -112,9 +107,9 @@ void CPanel::SortItems(int index) { case kpidSize: case kpidPackedSize: - case kpidCreationTime: - case kpidLastAccessTime: - case kpidLastWriteTime: + case kpidCTime: + case kpidATime: + case kpidMTime: _ascending = false; break; } @@ -131,7 +126,7 @@ void CPanel::SortItemsWithPropID(PROPID propID) */ void CPanel::SortItemsWithPropID(PROPID propID) { - if(propID == _sortID) + if (propID == _sortID) _ascending = !_ascending; else { @@ -140,11 +135,11 @@ void CPanel::SortItemsWithPropID(PROPID propID) switch (propID) { case kpidSize: - case kpidPackedSize: - case kpidCreationTime: - case kpidLastAccessTime: - case kpidLastWriteTime: - _ascending = false; + case kpidPackSize: + case kpidCTime: + case kpidATime: + case kpidMTime: + _ascending = false; break; } } diff --git a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp index cbfc6c25..36146d7a 100755 --- a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp +++ b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp @@ -4,8 +4,8 @@ #include "resource.h" -extern "C" -{ +extern "C" +{ #include "../../../../C/Alloc.h" } @@ -48,7 +48,7 @@ public: struct CVolSeqName { UString UnchangedPart; - UString ChangedPart; + UString ChangedPart; CVolSeqName(): ChangedPart(L"000") {}; bool ParseName(const UString &name) @@ -69,7 +69,7 @@ struct CVolSeqName UString GetNextName() { - UString newName; + UString newName; int i; int numLetters = ChangedPart.Length(); for (i = numLetters - 1; i >= 0; i--) @@ -172,18 +172,18 @@ struct CThreadSplit return; } } - DWORD Process() + void Process() { try { Process2(); } catch(const wchar_t *s) { Error = s; } catch(...) { Error = L"Error"; } ProgressDialog->MyClose(); - return 0; } static THREAD_FUNC_DECL MyThreadFunction(void *param) { - return ((CThreadSplit *)param)->Process(); + ((CThreadSplit *)param)->Process(); + return 0; } }; @@ -193,7 +193,7 @@ void CApp::Split() CPanel &srcPanel = Panels[srcPanelIndex]; if (!srcPanel.IsFSFolder()) { - srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } CRecordVector<UInt32> indices; @@ -202,13 +202,13 @@ void CApp::Split() return; if (indices.Size() != 1) { - srcPanel.MessageBox(L"Select one file"); + srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE, 0x03020A02); return; } int index = indices[0]; if (srcPanel.IsItemFolder(index)) { - srcPanel.MessageBox(L"Select one file"); + srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE, 0x03020A02); return; } const UString itemName = srcPanel.GetItemName(index); @@ -234,7 +234,7 @@ void CApp::Split() } if (fileInfo.Size <= splitDialog.VolumeSizes.Front()) { - srcPanel.MessageBoxMyError(LangString(IDS_SPLIT_VOL_MUST_BE_SMALLER, 0x03020522)); + srcPanel.MessageBoxErrorLang(IDS_SPLIT_VOL_MUST_BE_SMALLER, 0x03020522); return; } const UInt64 numVolumes = GetNumberOfVolumes(fileInfo.Size, splitDialog.VolumeSizes); @@ -242,8 +242,8 @@ void CApp::Split() { wchar_t s[32]; ConvertUInt64ToString(numVolumes, s); - if (::MessageBoxW(srcPanel, MyFormatNew(IDS_SPLIT_CONFIRM_MESSAGE, 0x03020521, s), - LangString(IDS_SPLIT_CONFIRM_TITLE, 0x03020520), + if (::MessageBoxW(srcPanel, MyFormatNew(IDS_SPLIT_CONFIRM_MESSAGE, 0x03020521, s), + LangString(IDS_SPLIT_CONFIRM_TITLE, 0x03020520), MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL) != IDYES) return; } @@ -301,117 +301,91 @@ void CApp::Split() struct CThreadCombine { CProgressDialog *ProgressDialog; + UString InputDirPrefix; - UString FirstVolumeName; - UString OutputDirPrefix; + UStringVector Names; + UString OutputPath; + UInt64 TotalSize; + UString Error; + HRESULT Res; void Process2() { - // NCOM::CComInitializer comInitializer; - ProgressDialog->WaitCreating(); - - CVolSeqName volSeqName; - if (!volSeqName.ParseName(FirstVolumeName)) - throw L"Can not detect file as splitted file"; - - UString nextName = InputDirPrefix + FirstVolumeName; - UInt64 totalSize = 0; - for (;;) + NFile::NIO::COutFile outFile; + if (!outFile.Create(OutputPath, false)) { - NFile::NFind::CFileInfoW fileInfo; - if (!NFile::NFind::FindFile(nextName, fileInfo)) - break; - if (fileInfo.IsDirectory()) - break; - totalSize += fileInfo.Size; - nextName = InputDirPrefix + volSeqName.GetNextName(); + Error = L"Can create open output file:\n" + OutputPath; + return; } - if (totalSize == 0) - throw L"no data"; - ProgressDialog->ProgressSynch.SetProgress(totalSize, 0); - - if (!volSeqName.ParseName(FirstVolumeName)) - throw L"Can not detect file as splitted file"; - UString outName = volSeqName.UnchangedPart; - while(!outName.IsEmpty()) - { - int lastIndex = outName.Length() - 1; - if (outName[lastIndex] != L'.') - break; - outName.Delete(lastIndex); - } - if (outName.IsEmpty()) - outName = L"file"; - NFile::NIO::COutFile outFile; - if (!outFile.Create(OutputDirPrefix + outName, false)) - throw L"Can create open output file"; + ProgressDialog->ProgressSynch.SetProgress(TotalSize, 0); - NFile::NIO::CInFile inFile; CMyBuffer bufferObject; if (!bufferObject.Allocate(kBufSize)) throw L"Can not allocate buffer"; Byte *buffer = (Byte *)(void *)bufferObject; UInt64 pos = 0; - nextName = InputDirPrefix + FirstVolumeName; - bool needOpen = true; - for (;;) + for (int i = 0; i < Names.Size(); i++) { - if (needOpen) + NFile::NIO::CInFile inFile; + const UString nextName = InputDirPrefix + Names[i]; + if (!inFile.Open(nextName)) { - NFile::NFind::CFileInfoW fileInfo; - if (!NFile::NFind::FindFile(nextName, fileInfo)) - break; - if (fileInfo.IsDirectory()) - break; - if (!inFile.Open(nextName)) - throw L"Can not open file"; - ProgressDialog->ProgressSynch.SetCurrentFileName(fileInfo.Name); - nextName = InputDirPrefix + volSeqName.GetNextName(); - needOpen = false; + Error = L"Can not open input file:\n" + nextName; + return; } - UInt32 processedSize; - if (!inFile.Read(buffer, kBufSize, processedSize)) - throw L"Can not read input file"; - if (processedSize == 0) + ProgressDialog->ProgressSynch.SetCurrentFileName(nextName); + for (;;) { - needOpen = true; - continue; + UInt32 processedSize; + if (!inFile.Read(buffer, kBufSize, processedSize)) + throw L"Can not read input file"; + if (processedSize == 0) + break; + UInt32 needSize = processedSize; + if (!outFile.Write(buffer, needSize, processedSize) || needSize != processedSize) + throw L"Can not write output file"; + pos += processedSize; + Res = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(pos); + if (Res != S_OK) + return; } - UInt32 needSize = processedSize; - if (!outFile.Write(buffer, needSize, processedSize)) - throw L"Can not write output file"; - if (needSize != processedSize) - throw L"Can not write output file"; - pos += processedSize; - HRESULT res = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(pos); - if (res != S_OK) - return; } } - DWORD Process() + + void Process() { + Res = S_OK; + ProgressDialog->WaitCreating(); try { Process2(); } catch(const wchar_t *s) { Error = s; } catch(...) { Error = L"Error";} ProgressDialog->MyClose(); - return 0; } static THREAD_FUNC_DECL MyThreadFunction(void *param) { - return ((CThreadCombine *)param)->Process(); + ((CThreadCombine *)param)->Process(); + return 0; } }; +extern void AddValuePair2(UINT resourceID, UInt32 langID, UInt64 num, UInt64 size, UString &s); + +static void AddInfoFileName(const UString &name, UString &dest) +{ + dest += L"\n "; + dest += name; +} + void CApp::Combine() { int srcPanelIndex = GetFocusedPanelIndex(); CPanel &srcPanel = Panels[srcPanelIndex]; if (!srcPanel.IsFSFolder()) { - srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } CRecordVector<UInt32> indices; @@ -421,7 +395,7 @@ void CApp::Combine() int index = indices[0]; if (indices.Size() != 1 || srcPanel.IsItemFolder(index)) { - srcPanel.MessageBox(LangString(IDS_COMBINE_SELECT_ONE_FILE, 0x03020620)); + srcPanel.MessageBoxErrorLang(IDS_COMBINE_SELECT_ONE_FILE, 0x03020620); return; } const UString itemName = srcPanel.GetItemName(index); @@ -433,49 +407,115 @@ void CApp::Combine() if (NumPanels > 1) if (destPanel.IsFSFolder()) path = destPanel._currentFolderPrefix; - CCopyDialog copyDialog; - copyDialog.Value = path; - copyDialog.Title = LangString(IDS_COMBINE, 0x03020600); - copyDialog.Title += ' '; - copyDialog.Title += srcPanel.GetItemRelPath(index); - - copyDialog.Static = LangString(IDS_COMBINE_TO, 0x03020601);; - if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL) - return; + CVolSeqName volSeqName; + if (!volSeqName.ParseName(itemName)) + { + srcPanel.MessageBoxErrorLang(IDS_COMBINE_CANT_DETECT_SPLIT_FILE, 0x03020621); + return; + } + CThreadCombine combiner; - // combiner.Panel = this; - + + UString nextName = itemName; + combiner.TotalSize = 0; + for (;;) { - CProgressDialog progressDialog; - combiner.ProgressDialog = &progressDialog; - - UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); - UString title = LangString(IDS_COMBINING, 0x03020610); - - progressDialog.MainWindow = _window; - progressDialog.MainTitle = progressWindowTitle; - progressDialog.MainAddTitle = title + UString(L" "); + NFile::NFind::CFileInfoW fileInfo; + if (!NFile::NFind::FindFile(srcPath + nextName, fileInfo) || fileInfo.IsDir()) + break; + combiner.Names.Add(nextName); + combiner.TotalSize += fileInfo.Size; + nextName = volSeqName.GetNextName(); + } + if (combiner.Names.Size() == 1) + { + srcPanel.MessageBoxErrorLang(IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART, 0x03020622); + return; + } + + if (combiner.TotalSize == 0) + { + srcPanel.MessageBoxMyError(L"No data"); + return; + } + + UString info; + AddValuePair2(IDS_FILES_COLON, 0x02000320, combiner.Names.Size(), combiner.TotalSize, info); + + info += L"\n"; + info += srcPath; + + int i; + for (i = 0; i < combiner.Names.Size() && i < 2; i++) + AddInfoFileName(combiner.Names[i], info); + if (i != combiner.Names.Size()) + { + if (i + 1 != combiner.Names.Size()) + AddInfoFileName(L"...", info); + AddInfoFileName(combiner.Names.Back(), info); + } + + { + CCopyDialog copyDialog; + copyDialog.Value = path; + copyDialog.Title = LangString(IDS_COMBINE, 0x03020600); + copyDialog.Title += ' '; + copyDialog.Title += srcPanel.GetItemRelPath(index); + copyDialog.Static = LangString(IDS_COMBINE_TO, 0x03020601); + copyDialog.Info = info; + if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL) + return; + path = copyDialog.Value; + } - path = copyDialog.Value; NFile::NName::NormalizeDirPathPrefix(path); if (!NFile::NDirectory::CreateComplexDirectory(path)) { srcPanel.MessageBoxMyError(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, 0x02000603, path)); return; } - - combiner.InputDirPrefix = srcPath; - combiner.FirstVolumeName = itemName; - combiner.OutputDirPrefix = path; - - // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel); - // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel); - - NWindows::CThread thread; - if (thread.Create(CThreadCombine::MyThreadFunction, &combiner) != S_OK) - throw 271824; - progressDialog.Create(title, _window); + + UString outName = volSeqName.UnchangedPart; + while (!outName.IsEmpty()) + { + int lastIndex = outName.Length() - 1; + if (outName[lastIndex] != L'.') + break; + outName.Delete(lastIndex); + } + if (outName.IsEmpty()) + outName = L"file"; + + NFile::NFind::CFileInfoW fileInfo; + UString destFilePath = path + outName; + combiner.OutputPath = destFilePath; + if (NFile::NFind::FindFile(destFilePath, fileInfo)) + { + srcPanel.MessageBoxMyError(MyFormatNew(IDS_FILE_EXIST, 0x03020A04, destFilePath)); + return; + } + + { + CProgressDialog progressDialog; + combiner.ProgressDialog = &progressDialog; + + UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); + UString title = LangString(IDS_COMBINING, 0x03020610); + + progressDialog.MainWindow = _window; + progressDialog.MainTitle = progressWindowTitle; + progressDialog.MainAddTitle = title + UString(L" "); + + combiner.InputDirPrefix = srcPath; + + // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel); + // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel); + + NWindows::CThread thread; + if (thread.Create(CThreadCombine::MyThreadFunction, &combiner) != S_OK) + throw 271824; + progressDialog.Create(title, _window); } RefreshTitleAlways(); diff --git a/CPP/7zip/UI/FileManager/PasswordDialog.cpp b/CPP/7zip/UI/FileManager/PasswordDialog.cpp index a366a61e..94e8219d 100755 --- a/CPP/7zip/UI/FileManager/PasswordDialog.cpp +++ b/CPP/7zip/UI/FileManager/PasswordDialog.cpp @@ -3,12 +3,12 @@ #include "StdAfx.h" #include "PasswordDialog.h" -#ifdef LANG +#ifdef LANG #include "LangUtils.h" #endif -#ifdef LANG -static CIDLangPair kIDLangPairs[] = +#ifdef LANG +static CIDLangPair kIDLangPairs[] = { { IDC_STATIC_PASSWORD_HEADER, 0x02000B01 }, { IDC_CHECK_PASSWORD_SHOW, 0x02000B02 }, @@ -17,9 +17,9 @@ static CIDLangPair kIDLangPairs[] = #endif -bool CPasswordDialog::OnInit() +bool CPasswordDialog::OnInit() { - #ifdef LANG + #ifdef LANG LangSetWindowText(HWND(*this), 0x02000B00); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif diff --git a/CPP/7zip/UI/FileManager/PhysDriveFolder.cpp b/CPP/7zip/UI/FileManager/PhysDriveFolder.cpp index d611e096..eb6674b3 100755 --- a/CPP/7zip/UI/FileManager/PhysDriveFolder.cpp +++ b/CPP/7zip/UI/FileManager/PhysDriveFolder.cpp @@ -2,8 +2,8 @@ #include "StdAfx.h" -extern "C" -{ +extern "C" +{ #include "../../../../C/Alloc.h" } @@ -18,7 +18,7 @@ using namespace NWindows; static const UInt32 kBufferSize = (4 << 20); -static STATPROPSTG kProperties[] = +static STATPROPSTG kProperties[] = { { NULL, kpidName, VT_BSTR}, { NULL, kpidSize, VT_UI8} @@ -56,22 +56,16 @@ STDMETHODIMP CPhysDriveFolder::GetNumberOfItems(UInt32 *numItems) STDMETHODIMP CPhysDriveFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) { - NCOM::CPropVariant propVariant; + NCOM::CPropVariant prop; if (itemIndex >= 1) return E_INVALIDARG; switch(propID) { - case kpidIsFolder: - propVariant = false; - break; - case kpidName: - propVariant = _name; - break; - case kpidSize: - propVariant = _length; - break; + case kpidIsDir: prop = false; break; + case kpidName: prop = _name; break; + case kpidSize: prop = _length; break; } - propVariant.Detach(value); + prop.Detach(value); return S_OK; } @@ -93,7 +87,7 @@ STDMETHODIMP CPhysDriveFolder::GetNumberOfProperties(UInt32 *numProperties) return S_OK; } -STDMETHODIMP CPhysDriveFolder::GetPropertyInfo(UInt32 index, +STDMETHODIMP CPhysDriveFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) { if (index >= sizeof(kProperties) / sizeof(kProperties[0])) @@ -136,13 +130,13 @@ STDMETHODIMP CPhysDriveFolder::Clone(IFolderFolder **resultFolder) STDMETHODIMP CPhysDriveFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress * /* progress */) { - NCOM::CPropVariant propVariant; + NCOM::CPropVariant prop; if (index >= 1) return E_INVALIDARG; UInt64 size = 0; HRESULT result = GetLength(size); - propVariant = size; - propVariant.Detach(value); + prop = size; + prop.Detach(value); return result; } @@ -235,7 +229,7 @@ HRESULT CopyFileSpec(LPCWSTR fromPath, LPCWSTR toPath, bool writeToDisk, UInt64 return S_OK; } -STDMETHODIMP CPhysDriveFolder::CopyTo(const UInt32 * /* indices */, UInt32 numItems, +STDMETHODIMP CPhysDriveFolder::CopyTo(const UInt32 * /* indices */, UInt32 numItems, const wchar_t *path, IFolderOperationsExtractCallback *callback) { if (numItems == 0) @@ -260,7 +254,7 @@ STDMETHODIMP CPhysDriveFolder::CopyTo(const UInt32 * /* indices */, UInt32 numIt Int32 writeAskResult; CMyComBSTR destPathResult; - RINOK(callback->AskWrite(GetFullPath(), BoolToInt(false), NULL, &fileSize, + RINOK(callback->AskWrite(GetFullPath(), BoolToInt(false), NULL, &fileSize, destPath, &destPathResult, &writeAskResult)); if (!IntToBool(writeAskResult)) return S_OK; @@ -275,8 +269,8 @@ STDMETHODIMP CPhysDriveFolder::CopyTo(const UInt32 * /* indices */, UInt32 numIt // Move Operations STDMETHODIMP CPhysDriveFolder::MoveTo( - const UInt32 * /* indices */, - UInt32 /* numItems */, + const UInt32 * /* indices */, + UInt32 /* numItems */, const wchar_t * /* path */, IFolderOperationsExtractCallback * /* callback */) { diff --git a/CPP/7zip/UI/FileManager/PhysDriveFolder.h b/CPP/7zip/UI/FileManager/PhysDriveFolder.h index 996dda13..1f327966 100755 --- a/CPP/7zip/UI/FileManager/PhysDriveFolder.h +++ b/CPP/7zip/UI/FileManager/PhysDriveFolder.h @@ -1,14 +1,14 @@ // PhysDriveFolder.h -#ifndef __PHYSDRIVEFOLDER_H -#define __PHYSDRIVEFOLDER_H +#ifndef __PHYSDRIVEFOLDER_H +#define __PHYSDRIVEFOLDER_H #include "Common/MyString.h" #include "Common/MyCom.h" #include "IFolder.h" -class CPhysDriveFolder: +class CPhysDriveFolder: public IFolderFolder, public IFolderWasChanged, public IFolderOperations, diff --git a/CPP/7zip/UI/FileManager/PluginInterface.h b/CPP/7zip/UI/FileManager/PluginInterface.h index 7bef6950..905aff9a 100755 --- a/CPP/7zip/UI/FileManager/PluginInterface.h +++ b/CPP/7zip/UI/FileManager/PluginInterface.h @@ -6,36 +6,36 @@ #include "Common/MyString.h" // {23170F69-40C1-278D-0000-000100010000} -DEFINE_GUID(IID_IInitContextMenu, +DEFINE_GUID(IID_IInitContextMenu, 0x23170F69, 0x40C1, 0x278D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00); MIDL_INTERFACE("23170F69-40C1-278D-0000-000100010000") IInitContextMenu: public IUnknown { public: - STDMETHOD(InitContextMenu)(const wchar_t *aFolder, const wchar_t **aNames, UINT32 aNumFiles) PURE; + STDMETHOD(InitContextMenu)(const wchar_t *aFolder, const wchar_t **aNames, UINT32 aNumFiles) PURE; }; // {23170F69-40C1-278D-0000-000100020100} -DEFINE_GUID(IID_IPluginOptionsCallback, +DEFINE_GUID(IID_IPluginOptionsCallback, 0x23170F69, 0x40C1, 0x278D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00); MIDL_INTERFACE("23170F69-40C1-278D-0000-000100020000") IPluginOptionsCallback: public IUnknown { public: - STDMETHOD(GetProgramFolderPath)(BSTR *value) PURE; - STDMETHOD(GetProgramPath)(BSTR *value) PURE; - STDMETHOD(GetRegistryCUPath)(BSTR *value) PURE; + STDMETHOD(GetProgramFolderPath)(BSTR *value) PURE; + STDMETHOD(GetProgramPath)(BSTR *value) PURE; + STDMETHOD(GetRegistryCUPath)(BSTR *value) PURE; }; // {23170F69-40C1-278D-0000-000100020000} -DEFINE_GUID(IID_IPluginOptions, +DEFINE_GUID(IID_IPluginOptions, 0x23170F69, 0x40C1, 0x278D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00); MIDL_INTERFACE("23170F69-40C1-278D-0000-000100020000") IPluginOptions: public IUnknown { public: - STDMETHOD(PluginOptions)(HWND hWnd, IPluginOptionsCallback *callback) PURE; + STDMETHOD(PluginOptions)(HWND hWnd, IPluginOptionsCallback *callback) PURE; // STDMETHOD(GetFileExtensions)(BSTR *extensions) PURE; }; diff --git a/CPP/7zip/UI/FileManager/PluginLoader.h b/CPP/7zip/UI/FileManager/PluginLoader.h index 598a874b..f48c9e97 100755 --- a/CPP/7zip/UI/FileManager/PluginLoader.h +++ b/CPP/7zip/UI/FileManager/PluginLoader.h @@ -6,11 +6,11 @@ #include "Windows/DLL.h" typedef UINT32 (WINAPI * CreateObjectPointer)( - const GUID *clsID, - const GUID *interfaceID, + const GUID *clsID, + const GUID *interfaceID, void **outObject); -class CPluginLibrary: public NWindows::NDLL::CLibrary +class CPluginLibrary: public NWindows::NDLL::CLibrary { public: HRESULT CreateManager(REFGUID clsID, IFolderManager **manager) diff --git a/CPP/7zip/UI/FileManager/PluginsPage.cpp b/CPP/7zip/UI/FileManager/PluginsPage.cpp index 3be15b18..3b205ce3 100755 --- a/CPP/7zip/UI/FileManager/PluginsPage.cpp +++ b/CPP/7zip/UI/FileManager/PluginsPage.cpp @@ -19,7 +19,7 @@ #include "PluginInterface.h" -static CIDLangPair kIDLangPairs[] = +static CIDLangPair kIDLangPairs[] = { { IDC_PLUGINS_STATIC_PLUGINS, 0x03010101}, { IDC_PLUGINS_BUTTON_OPTIONS, 0x03010110} @@ -36,14 +36,7 @@ bool CPluginsPage::OnInit() UINT32 newFlags = /*LVS_EX_CHECKBOXES | */ LVS_EX_FULLROWSELECT; _listView.SetExtendedListViewStyle(newFlags, newFlags); - UString title = L"Plugins"; - LVCOLUMNW column; - column.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT | LVCF_SUBITEM; - column.cx = 160; - column.fmt = LVCFMT_LEFT; - column.pszText = (LPWSTR)(LPCWSTR)title; - column.iSubItem = 0; - _listView.InsertColumn(0, &column); + _listView.InsertColumn(0, L"Plugins", 160); ReadFileFolderPluginInfoList(_plugins); @@ -104,7 +97,7 @@ bool CPluginsPage::OnButtonClicked(int buttonID, HWND buttonHWND) return true; } -class CPluginOptionsCallback: +class CPluginOptionsCallback: public IPluginOptionsCallback, public CMyUnknownImp { @@ -112,9 +105,9 @@ class CPluginOptionsCallback: public: MY_UNKNOWN_IMP - STDMETHOD(GetProgramFolderPath)(BSTR *value); - STDMETHOD(GetProgramPath)(BSTR *Value); - STDMETHOD(GetRegistryCUPath)(BSTR *Value); + STDMETHOD(GetProgramFolderPath)(BSTR *value); + STDMETHOD(GetProgramPath)(BSTR *Value); + STDMETHOD(GetRegistryCUPath)(BSTR *Value); void Init(const UString &pluginName) { _pluginName = pluginName; } }; @@ -192,8 +185,8 @@ void CPluginsPage::OnButtonOptions() pluginOptions->PluginOptions(HWND(*this), callback); } -bool CPluginsPage::OnNotify(UINT controlID, LPNMHDR lParam) -{ +bool CPluginsPage::OnNotify(UINT controlID, LPNMHDR lParam) +{ if (lParam->hwndFrom == HWND(_listView) && lParam->code == LVN_ITEMCHANGED) { const NMLISTVIEW *aNMListView = (const NMLISTVIEW *)lParam; @@ -206,7 +199,7 @@ bool CPluginsPage::OnNotify(UINT controlID, LPNMHDR lParam) } return true; } - return CPropertyPage::OnNotify(controlID, lParam); + return CPropertyPage::OnNotify(controlID, lParam); } /* diff --git a/CPP/7zip/UI/FileManager/PluginsPage.rc b/CPP/7zip/UI/FileManager/PluginsPage.rc index 5a1f48ec..b4868aa3 100755 --- a/CPP/7zip/UI/FileManager/PluginsPage.rc +++ b/CPP/7zip/UI/FileManager/PluginsPage.rc @@ -12,8 +12,8 @@ CAPTION "Plugins" MY_FONT BEGIN LTEXT "&Plugins:", IDC_PLUGINS_STATIC_PLUGINS, marg, marg, xSize2, 8 - CONTROL "List1", IDC_PLUGINS_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS | - LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, + CONTROL "List1", IDC_PLUGINS_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS | + LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, marg, 20, xSize2 - bXSize - 12, ySize2 - 12 PUSHBUTTON "Options...", IDC_PLUGINS_BUTTON_OPTIONS, (xSize - marg - bXSize), 20, bXSize, bYSize END diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.cpp b/CPP/7zip/UI/FileManager/ProgressDialog.cpp index b185868b..5be77a8f 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog.cpp +++ b/CPP/7zip/UI/FileManager/ProgressDialog.cpp @@ -11,17 +11,30 @@ using namespace NWindows; static const UINT_PTR kTimerID = 3; static const UINT kTimerElapse = 50; -#ifdef LANG +#ifdef LANG #include "LangUtils.h" #endif -#ifdef LANG -static CIDLangPair kIDLangPairs[] = +#ifdef LANG +static CIDLangPair kIDLangPairs[] = { { IDCANCEL, 0x02000711 } }; #endif +HRESULT CProgressSynch::ProcessStopAndPause() +{ + for (;;) + { + if (GetStopped()) + return E_ABORT; + if (!GetPaused()) + break; + ::Sleep(100); + } + return S_OK; +} + #ifndef _SFX CProgressDialog::~CProgressDialog() { @@ -36,12 +49,12 @@ void CProgressDialog::AddToTitle(LPCWSTR s) -bool CProgressDialog::OnInit() +bool CProgressDialog::OnInit() { _range = UINT64(-1); _prevPercentValue = -1; - #ifdef LANG + #ifdef LANG // LangSetWindowText(HWND(*this), 0x02000C00); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif @@ -53,7 +66,7 @@ bool CProgressDialog::OnInit() return CModalDialog::OnInit(); } -void CProgressDialog::OnCancel() +void CProgressDialog::OnCancel() { ProgressSynch.SetStopped(true); } @@ -96,7 +109,7 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) total = 1; int percentValue = (int)(completed * 100 / total); - if (percentValue != _prevPercentValue) + if (percentValue != _prevPercentValue) { wchar_t s[64]; ConvertUInt64ToString(percentValue, s); @@ -154,16 +167,16 @@ bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) return CModalDialog::OnMessage(message, wParam, lParam); } -bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) -{ +bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) +{ switch(buttonID) { case IDCANCEL: { bool paused = ProgressSynch.GetPaused();; ProgressSynch.SetPaused(true); - int res = ::MessageBoxW(HWND(*this), - L"Are you sure you want to cancel?", + int res = ::MessageBoxW(HWND(*this), + L"Are you sure you want to cancel?", _title, MB_YESNOCANCEL); ProgressSynch.SetPaused(paused); if (res == IDCANCEL || res == IDNO) diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.h b/CPP/7zip/UI/FileManager/ProgressDialog.h index 0ef2dc99..201aead7 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog.h +++ b/CPP/7zip/UI/FileManager/ProgressDialog.h @@ -19,6 +19,7 @@ class CProgressSynch public: CProgressSynch(): _stopped(false), _paused(false), _total(1), _completed(0) {} + HRESULT ProcessStopAndPause(); bool GetStopped() { NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); @@ -103,7 +104,7 @@ public: CProgressDialog(): _timer(0) #ifndef _SFX - ,MainWindow(0) + ,MainWindow(0) #endif { if (_dialogCreatedEvent.Create() != S_OK) @@ -114,9 +115,9 @@ public: INT_PTR Create(const UString &title, HWND wndParent = 0) - { + { _title = title; - return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent); + return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent); } static const UINT kCloseMessage; diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp index ae4752ef..0e24f187 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp +++ b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp @@ -10,12 +10,12 @@ using namespace NWindows; static const UINT_PTR kTimerID = 3; static const UINT kTimerElapse = 100; -#ifdef LANG +#ifdef LANG #include "LangUtils.h" #endif -#ifdef LANG -static CIDLangPair kIDLangPairs[] = +#ifdef LANG +static CIDLangPair kIDLangPairs[] = { { IDCANCEL, 0x02000C00 }, { IDC_PROGRESS_ELAPSED, 0x02000C01 }, @@ -33,16 +33,22 @@ static CIDLangPair kIDLangPairs[] = }; #endif -HRESULT CProgressSynch::SetPosAndCheckPaused(UInt64 completed) +HRESULT CProgressSynch::ProcessStopAndPause() { for (;;) { - if(GetStopped()) + if (GetStopped()) return E_ABORT; - if(!GetPaused()) + if (!GetPaused()) break; ::Sleep(100); } + return S_OK; +} + +HRESULT CProgressSynch::SetPosAndCheckPaused(UInt64 completed) +{ + RINOK(ProcessStopAndPause()); SetPos(completed); return S_OK; } @@ -62,7 +68,7 @@ void CProgressDialog::AddToTitle(LPCWSTR s) } static const int kTitleFileNameSizeLimit = 36; -static const int kCurrentFileNameSizeLimit = 68; +static const int kCurrentFileNameSizeLimit = 70; static void ReduceString(UString &s, int size) { @@ -71,7 +77,7 @@ static void ReduceString(UString &s, int size) } #endif -bool CProgressDialog::OnInit() +bool CProgressDialog::OnInit() { _range = (UInt64)(Int64)(-1); _prevPercentValue = UInt32(-1); @@ -83,7 +89,7 @@ bool CProgressDialog::OnInit() _elapsedTime = 0; _foreground = true; - #ifdef LANG + #ifdef LANG // LangSetWindowText(HWND(*this), 0x02000C00); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif @@ -110,7 +116,7 @@ bool CProgressDialog::OnInit() return CModalDialog::OnInit(); } -void CProgressDialog::OnCancel() +void CProgressDialog::OnCancel() { ProgressSynch.SetStopped(true); } @@ -161,9 +167,9 @@ void CProgressDialog::SetPos(UInt64 pos) static void GetTimeString(UInt64 timeValue, TCHAR *s) { - wsprintf(s, TEXT("%02d:%02d:%02d"), + wsprintf(s, TEXT("%02d:%02d:%02d"), UInt32(timeValue / 3600), - UInt32((timeValue / 60) % 60), + UInt32((timeValue / 60) % 60), UInt32(timeValue % 60)); } @@ -235,7 +241,8 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) } // if (elapsedChanged) { - UInt64 speedB = (completed * 1000) / _elapsedTime; + UInt32 elapsedTime = (_elapsedTime == 0) ? 1 : _elapsedTime; + UInt64 speedB = (completed * 1000) / elapsedTime; UInt64 speedKB = speedB / 1024; UInt64 speedMB = speedKB / 1024; const UInt32 kLimit1 = 10; @@ -263,7 +270,7 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) needRedraw = true; } } - else + else { if (_prevMode != kSpeedBytes || speedB != _prevSpeed) { @@ -284,7 +291,7 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) UInt32 percentValue = (UInt32)(completed * 100 / total); UString titleName; ProgressSynch.GetTitleFileName(titleName); - if (percentValue != _prevPercentValue || _prevTitleName != titleName) + if (percentValue != _prevPercentValue || _prevTitleName != titleName) { _prevPercentValue = percentValue; SetTitleText(); @@ -329,8 +336,19 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) ProgressSynch.GetCurrentFileName(fileName); if (_prevFileName != fileName) { - ReduceString(fileName, kCurrentFileNameSizeLimit); - SetItemText(IDC_PROGRESS_FILE_NAME, fileName); + int slashPos = fileName.ReverseFind(L'\\'); + UString s1, s2; + if (slashPos >= 0) + { + s1 = fileName.Left(slashPos + 1); + s2 = fileName.Mid(slashPos + 1); + } + else + s2 = fileName; + ReduceString(s1, kCurrentFileNameSizeLimit); + ReduceString(s2, kCurrentFileNameSizeLimit); + UString s = s1 + L"\n" + s2; + SetItemText(IDC_PROGRESS_FILE_NAME, s); _prevFileName == fileName; } @@ -418,7 +436,7 @@ void CProgressDialog::SetTitleText() void CProgressDialog::SetPauseText() { - SetItemText(IDC_BUTTON_PAUSE, ProgressSynch.GetPaused() ? + SetItemText(IDC_BUTTON_PAUSE, ProgressSynch.GetPaused() ? continueString : pauseString); SetTitleText(); } @@ -436,8 +454,8 @@ void CProgressDialog::OnPauseButton() void CProgressDialog::SetPriorityText() { - SetItemText(IDC_BUTTON_PROGRESS_PRIORITY, _foreground ? - backgroundString : + SetItemText(IDC_BUTTON_PROGRESS_PRIORITY, _foreground ? + backgroundString : foregroundString); SetTitleText(); } @@ -450,8 +468,8 @@ void CProgressDialog::OnPriorityButton() SetPriorityText(); } -bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) -{ +bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) +{ switch(buttonID) { case IDCANCEL: @@ -460,8 +478,8 @@ bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) // ProgressSynch.SetPaused(true); if (!paused) OnPauseButton(); - int res = ::MessageBoxW(HWND(*this), - LangString(IDS_PROGRESS_ASK_CANCEL, 0x02000C30), + int res = ::MessageBoxW(HWND(*this), + LangString(IDS_PROGRESS_ASK_CANCEL, 0x02000C30), _title, MB_YESNOCANCEL); // ProgressSynch.SetPaused(paused); if (!paused) diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.h b/CPP/7zip/UI/FileManager/ProgressDialog2.h index 9acaf9de..e838ae25 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog2.h +++ b/CPP/7zip/UI/FileManager/ProgressDialog2.h @@ -25,11 +25,11 @@ class CProgressSynch UString TitleFileName; UString CurrentFileName; public: - CProgressSynch(): - _stopped(false), _paused(false), - _total((UInt64)(Int64)-1), + CProgressSynch(): + _stopped(false), _paused(false), + _total((UInt64)(Int64)-1), _completed(0), - _totalFiles((UInt64)(Int64)-1), + _totalFiles((UInt64)(Int64)-1), _completedFiles(0), _inSize((UInt64)(Int64)-1), _outSize((UInt64)(Int64)-1) @@ -84,9 +84,10 @@ public: NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); _completedFiles = value; } + HRESULT ProcessStopAndPause(); HRESULT SetPosAndCheckPaused(UInt64 completed); - void GetProgress(UInt64 &total, UInt64 &completed, - UInt64 &totalFiles, UInt64 &completedFiles, + void GetProgress(UInt64 &total, UInt64 &completed, + UInt64 &totalFiles, UInt64 &completedFiles, UInt64 &inSize, UInt64 &outSize) { NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); @@ -211,9 +212,9 @@ public: INT_PTR Create(const UString &title, HWND wndParent = 0) - { + { _title = title; - return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent); + return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent); } static const UINT kCloseMessage; diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.rc b/CPP/7zip/UI/FileManager/ProgressDialog2.rc index 58cdec36..92b970f6 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog2.rc +++ b/CPP/7zip/UI/FileManager/ProgressDialog2.rc @@ -2,7 +2,7 @@ #include "../../GuiCommon.rc" #define xSize2 320 -#define ySize2 98 +#define ySize2 110 #define xSize (xSize2 + marg + marg) #define ySize (ySize2 + marg + marg) @@ -36,7 +36,7 @@ #define y3 (y2 + 11) -IDD_DIALOG_PROGRESS DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX +IDD_DIALOG_PROGRESS DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX CAPTION "Progress" MY_FONT BEGIN @@ -63,12 +63,12 @@ BEGIN RTEXT "", IDC_PROGRESS_UNPACKED_VALUE, x3, y2, x3Size, 8 RTEXT "", IDC_PROGRESS_PACKED_VALUE, x3, y3, x3Size, 8 - LTEXT "", IDC_PROGRESS_FILE_NAME, marg, bYPos - 30, xSize2, 8, SS_NOPREFIX + LTEXT "", IDC_PROGRESS_FILE_NAME, marg, bYPos - 42, xSize2, 21, SS_NOPREFIX | SS_LEFTNOWORDWRAP CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER, marg, bYPos - 20, xSize2, 13 END -STRINGTABLE DISCARDABLE +STRINGTABLE DISCARDABLE BEGIN IDS_PROGRESS_PAUSED "Paused" IDS_PROGRESS_FOREGROUND "&Foreground" diff --git a/CPP/7zip/UI/FileManager/PropertyName.cpp b/CPP/7zip/UI/FileManager/PropertyName.cpp index fb8f707e..cb4edfc2 100755 --- a/CPP/7zip/UI/FileManager/PropertyName.cpp +++ b/CPP/7zip/UI/FileManager/PropertyName.cpp @@ -2,32 +2,35 @@ #include "StdAfx.h" -#include "../../PropID.h" +#include "Common/IntToString.h" #include "Windows/ResourceString.h" + +#include "../../PropID.h" + #include "resource.h" -#include "PropertyName.h" #include "PropertyNameRes.h" #include "LangUtils.h" +#include "PropertyName.h" struct CPropertyIDNamePair { PROPID PropID; UINT ResourceID; - UINT LangID; + UInt32 LangID; }; -static CPropertyIDNamePair kPropertyIDNamePairs[] = +static CPropertyIDNamePair kPropertyIDNamePairs[] = { { kpidPath, IDS_PROPERTY_PATH, 0x02000203 }, { kpidName, IDS_PROPERTY_NAME, 0x02000204 }, - // { kpidExtension, L"Extension" }, - { kpidIsFolder, IDS_PROPERTY_IS_FOLDER, 0x02000206}, + { kpidExtension, IDS_PROPERTY_EXTENSION, 0x02000205 }, + { kpidIsDir, IDS_PROPERTY_IS_FOLDER, 0x02000206}, { kpidSize, IDS_PROPERTY_SIZE, 0x02000207}, - { kpidPackedSize, IDS_PROPERTY_PACKED_SIZE, 0x02000208 }, - { kpidAttributes, IDS_PROPERTY_ATTRIBUTES, 0x02000209 }, - { kpidCreationTime, IDS_PROPERTY_CREATION_TIME, 0x0200020A }, - { kpidLastAccessTime, IDS_PROPERTY_LAST_ACCESS_TIME, 0x0200020B }, - { kpidLastWriteTime, IDS_PROPERTY_LAST_WRITE_TIME, 0x0200020C }, + { kpidPackSize, IDS_PROPERTY_PACKED_SIZE, 0x02000208 }, + { kpidAttrib, IDS_PROPERTY_ATTRIBUTES, 0x02000209 }, + { kpidCTime, IDS_PROPERTY_CTIME, 0x0200020A }, + { kpidATime, IDS_PROPERTY_ATIME, 0x0200020B }, + { kpidMTime, IDS_PROPERTY_MTIME, 0x0200020C }, { kpidSolid, IDS_PROPERTY_SOLID, 0x0200020D }, { kpidCommented, IDS_PROPERTY_C0MMENTED, 0x0200020E }, { kpidEncrypted, IDS_PROPERTY_ENCRYPTED, 0x0200020F }, @@ -46,7 +49,7 @@ static CPropertyIDNamePair kPropertyIDNamePairs[] = { kpidComment, IDS_PROPERTY_COMMENT, 0x0200021C }, { kpidPosition, IDS_PROPERTY_POSITION, 0x0200021D }, { kpidPrefix, IDS_PROPERTY_PREFIX, 0x0200021E }, - { kpidNumSubFolders, IDS_PROPERTY_FOLDERS, 0x0200021F }, + { kpidNumSubDirs, IDS_PROPERTY_FOLDERS, 0x0200021F }, { kpidNumSubFiles, IDS_PROPERTY_FILES, 0x02000220 }, { kpidUnpackVer, IDS_PROPERTY_VERSION, 0x02000221}, { kpidVolume, IDS_PROPERTY_VOLUME, 0x02000222}, @@ -56,8 +59,17 @@ static CPropertyIDNamePair kPropertyIDNamePairs[] = { kpidNumBlocks, IDS_PROPERTY_NUM_BLOCKS, 0x02000226}, { kpidNumVolumes, IDS_PROPERTY_NUM_VOLUMES, 0x02000227}, + { kpidBit64, IDS_PROPERTY_BIT64, 0x02000229}, + { kpidBigEndian, IDS_PROPERTY_BIG_ENDIAN, 0x0200022A}, + { kpidCpu, IDS_PROPERTY_CPU, 0x0200022B}, + { kpidPhySize, IDS_PROPERTY_PHY_SIZE, 0x0200022C}, + { kpidHeadersSize, IDS_PROPERTY_HEADERS_SIZE, 0x0200022D}, + { kpidChecksum, IDS_PROPERTY_CHECKSUM, 0x0200022E}, + { kpidCharacts, IDS_PROPERTY_CHARACTS, 0x0200022F}, + { kpidVa, IDS_PROPERTY_VA, 0x02000230}, + { kpidTotalSize, IDS_PROPERTY_TOTAL_SIZE, 0x03031100 }, - { kpidFreeSpace, IDS_PROPERTY_FREE_SPACE, 0x03031101 }, + { kpidFreeSpace, IDS_PROPERTY_FREE_SPACE, 0x03031101 }, { kpidClusterSize, IDS_PROPERTY_CLUSTER_SIZE, 0x03031102}, { kpidVolumeName, IDS_PROPERTY_VOLUME_NAME, 0x03031103 }, @@ -68,16 +80,22 @@ static CPropertyIDNamePair kPropertyIDNamePairs[] = int FindProperty(PROPID propID) { for (int i = 0; i < sizeof(kPropertyIDNamePairs) / sizeof(kPropertyIDNamePairs[0]); i++) - if(kPropertyIDNamePairs[i].PropID == propID) + if (kPropertyIDNamePairs[i].PropID == propID) return i; return -1; } -UString GetNameOfProperty(PROPID propID) +UString GetNameOfProperty(PROPID propID, const wchar_t *name) { int index = FindProperty(propID); if (index < 0) - return UString(); + { + if (name) + return name; + wchar_t s[32]; + ConvertUInt64ToString(propID, s); + return s; + } const CPropertyIDNamePair &pair = kPropertyIDNamePairs[index]; return LangString(pair.ResourceID, pair.LangID); } diff --git a/CPP/7zip/UI/FileManager/PropertyName.h b/CPP/7zip/UI/FileManager/PropertyName.h index 413d2343..95e9dc9b 100755 --- a/CPP/7zip/UI/FileManager/PropertyName.h +++ b/CPP/7zip/UI/FileManager/PropertyName.h @@ -5,6 +5,6 @@ #include "Common/MyString.h" -UString GetNameOfProperty(PROPID propID); +UString GetNameOfProperty(PROPID propID, const wchar_t *name); #endif diff --git a/CPP/7zip/UI/FileManager/PropertyName.rc b/CPP/7zip/UI/FileManager/PropertyName.rc index 94171ee3..ad8a9012 100755 --- a/CPP/7zip/UI/FileManager/PropertyName.rc +++ b/CPP/7zip/UI/FileManager/PropertyName.rc @@ -11,9 +11,9 @@ BEGIN IDS_PROPERTY_SIZE "Size" IDS_PROPERTY_PACKED_SIZE "Packed Size" IDS_PROPERTY_ATTRIBUTES "Attributes" - IDS_PROPERTY_CREATION_TIME "Created" - IDS_PROPERTY_LAST_ACCESS_TIME "Accessed" - IDS_PROPERTY_LAST_WRITE_TIME "Modified" + IDS_PROPERTY_CTIME "Created" + IDS_PROPERTY_ATIME "Accessed" + IDS_PROPERTY_MTIME "Modified" IDS_PROPERTY_SOLID "Solid" IDS_PROPERTY_C0MMENTED "Commented" IDS_PROPERTY_ENCRYPTED "Encrypted" @@ -42,4 +42,12 @@ BEGIN IDS_PROPERTY_NUM_BLOCKS "Blocks" IDS_PROPERTY_NUM_VOLUMES "Volumes" + IDS_PROPERTY_BIT64 "64-bit" + IDS_PROPERTY_BIG_ENDIAN "Big-endian" + IDS_PROPERTY_CPU "CPU" + IDS_PROPERTY_PHY_SIZE "Physical Size" + IDS_PROPERTY_HEADERS_SIZE "Headers Size" + IDS_PROPERTY_CHECKSUM "Checksum" + IDS_PROPERTY_CHARACTS "Characteristics" + IDS_PROPERTY_VA "Va" END diff --git a/CPP/7zip/UI/FileManager/PropertyNameRes.h b/CPP/7zip/UI/FileManager/PropertyNameRes.h index 80c9637f..74d535ac 100755 --- a/CPP/7zip/UI/FileManager/PropertyNameRes.h +++ b/CPP/7zip/UI/FileManager/PropertyNameRes.h @@ -5,9 +5,9 @@ #define IDS_PROPERTY_SIZE 7 #define IDS_PROPERTY_PACKED_SIZE 8 #define IDS_PROPERTY_ATTRIBUTES 9 -#define IDS_PROPERTY_CREATION_TIME 10 -#define IDS_PROPERTY_LAST_ACCESS_TIME 11 -#define IDS_PROPERTY_LAST_WRITE_TIME 12 +#define IDS_PROPERTY_CTIME 10 +#define IDS_PROPERTY_ATIME 11 +#define IDS_PROPERTY_MTIME 12 #define IDS_PROPERTY_SOLID 13 #define IDS_PROPERTY_C0MMENTED 14 #define IDS_PROPERTY_ENCRYPTED 15 @@ -35,3 +35,12 @@ #define IDS_PROPERTY_LINKS 37 #define IDS_PROPERTY_NUM_BLOCKS 38 #define IDS_PROPERTY_NUM_VOLUMES 39 + +#define IDS_PROPERTY_BIT64 41 +#define IDS_PROPERTY_BIG_ENDIAN 42 +#define IDS_PROPERTY_CPU 43 +#define IDS_PROPERTY_PHY_SIZE 44 +#define IDS_PROPERTY_HEADERS_SIZE 45 +#define IDS_PROPERTY_CHECKSUM 46 +#define IDS_PROPERTY_CHARACTS 47 +#define IDS_PROPERTY_VA 48 diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp index a03762ef..72153f9d 100755 --- a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp +++ b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp @@ -37,7 +37,7 @@ bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo) { NSynchronization::CCriticalSectionLock lock(g_CriticalSection); CKey key; - if(key.Open(HKEY_CURRENT_USER, GetAssociationsPath() + CSysString('\\') + + if(key.Open(HKEY_CURRENT_USER, GetAssociationsPath() + CSysString('\\') + CSysString(GetSystemString(ext)), KEY_READ) != ERROR_SUCCESS) return false; UString pluginsString; @@ -94,7 +94,7 @@ void WriteInternalAssociations(const CObjectVector<CExtInfo> &items) } /////////////////////////////////// -// External +// External static const TCHAR *kShellNewKeyName = TEXT("ShellNew"); static const TCHAR *kShellNewDataValueName = TEXT("Data"); @@ -187,8 +187,8 @@ void DeleteShellExtensionInfo(const CSysString &extension) } void AddShellExtensionInfo(const CSysString &extension, - const UString &programTitle, - const UString &programOpenCommand, + const UString &programTitle, + const UString &programOpenCommand, const UString &iconPath, int iconIndex, const void *shellNewData, int shellNewDataSize) { @@ -243,7 +243,7 @@ void AddShellExtensionInfo(const CSysString &extension, /* static const TCHAR *kContextMenuKeyName = TEXT("\\shellex\\ContextMenuHandlers\\7-ZIP"); -static const TCHAR *kContextMenuHandlerCLASSIDValue = +static const TCHAR *kContextMenuHandlerCLASSIDValue = TEXT("{23170F69-40C1-278A-1000-000100020000}"); static const TCHAR *kRootKeyNameForFile = TEXT("*"); static const TCHAR *kRootKeyNameForFolder = TEXT("Folder"); @@ -265,7 +265,7 @@ static bool CheckContextMenuHandlerCommon(const CSysString &aKeyName) } bool CheckContextMenuHandler() -{ +{ return CheckContextMenuHandlerCommon(kRootKeyNameForFile) && CheckContextMenuHandlerCommon(kRootKeyNameForFolder); } @@ -279,8 +279,8 @@ static void DeleteContextMenuHandlerCommon(const CSysString &aKeyName) } void DeleteContextMenuHandler() -{ - DeleteContextMenuHandlerCommon(kRootKeyNameForFile); +{ + DeleteContextMenuHandlerCommon(kRootKeyNameForFile); DeleteContextMenuHandlerCommon(kRootKeyNameForFolder); } @@ -294,8 +294,8 @@ static void AddContextMenuHandlerCommon(const CSysString &aKeyName) } void AddContextMenuHandler() -{ - AddContextMenuHandlerCommon(kRootKeyNameForFile); +{ + AddContextMenuHandlerCommon(kRootKeyNameForFile); AddContextMenuHandlerCommon(kRootKeyNameForFolder); } */ diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.h b/CPP/7zip/UI/FileManager/RegistryAssociations.h index c1a64c96..2516fd2b 100755 --- a/CPP/7zip/UI/FileManager/RegistryAssociations.h +++ b/CPP/7zip/UI/FileManager/RegistryAssociations.h @@ -19,12 +19,12 @@ namespace NRegistryAssociations { bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex); - // void ReadCompressionInfo(NZipSettings::NCompression::CInfo &anInfo, + // void ReadCompressionInfo(NZipSettings::NCompression::CInfo &anInfo, void DeleteShellExtensionInfo(const CSysString &extension); void AddShellExtensionInfo(const CSysString &extension, - const UString &programTitle, - const UString &programOpenCommand, + const UString &programTitle, + const UString &programOpenCommand, const UString &iconPath, int iconIndex, const void *shellNewData, int shellNewDataSize); diff --git a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp index 771166ca..a0bfec05 100755 --- a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp +++ b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp @@ -28,7 +28,7 @@ static const TCHAR *kPluginsTypeValue = TEXT("Type"); static CSysString GetFileFolderPluginsKeyName() { - return CSysString(kLMBasePath) + CSysString(TEXT('\\')) + + return CSysString(kLMBasePath) + CSysString(TEXT('\\')) + CSysString(kPluginsKeyName); } @@ -115,7 +115,7 @@ void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins) NFind::CFileInfoW fileInfo; while (enumerator.Next(fileInfo)) { - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) continue; CPluginInfo pluginInfo; pluginInfo.FilePath = folderPath + fileInfo.Name; diff --git a/CPP/7zip/UI/FileManager/RegistryPlugins.h b/CPP/7zip/UI/FileManager/RegistryPlugins.h index 90bab7b5..77055ac7 100755 --- a/CPP/7zip/UI/FileManager/RegistryPlugins.h +++ b/CPP/7zip/UI/FileManager/RegistryPlugins.h @@ -5,7 +5,7 @@ #include "Common/MyString.h" -enum EPluginType +enum EPluginType { kPluginTypeFF = 0 }; diff --git a/CPP/7zip/UI/FileManager/RootFolder.cpp b/CPP/7zip/UI/FileManager/RootFolder.cpp index 5c8e0e28..3f3c67ef 100755 --- a/CPP/7zip/UI/FileManager/RootFolder.cpp +++ b/CPP/7zip/UI/FileManager/RootFolder.cpp @@ -20,7 +20,7 @@ using namespace NWindows; -static const STATPROPSTG kProperties[] = +static const STATPROPSTG kProperties[] = { { NULL, kpidName, VT_BSTR} }; @@ -28,10 +28,33 @@ static const STATPROPSTG kProperties[] = // static const wchar_t *kMyComputerTitle = L"Computer"; // static const wchar_t *kMyNetworkTitle = L"Network"; -void CRootFolder::Init() +UString RootFolder_GetName_Computer(int &iconIndex) { - _computerName = LangString(IDS_COMPUTER, 0x03020300); - _networkName = LangString(IDS_NETWORK, 0x03020301); + iconIndex = GetIconIndexForCSIDL(CSIDL_DRIVES); + return LangString(IDS_COMPUTER, 0x03020300); +} + +UString RootFolder_GetName_Network(int &iconIndex) +{ + iconIndex = GetIconIndexForCSIDL(CSIDL_NETWORK); + return LangString(IDS_NETWORK, 0x03020301); +} + +UString RootFolder_GetName_Documents(int &iconIndex) +{ + iconIndex = GetIconIndexForCSIDL(CSIDL_PERSONAL); + return LangString(IDS_DOCUMENTS, 0x03020302); ; +} + +const int ROOT_INDEX_COMPUTER = 0; +const int ROOT_INDEX_DOCUMENTS = 1; +const int ROOT_INDEX_NETWORK = 2; + +void CRootFolder::Init() +{ + _names[ROOT_INDEX_COMPUTER] = RootFolder_GetName_Computer(_iconIndices[ROOT_INDEX_COMPUTER]); + _names[ROOT_INDEX_DOCUMENTS] = RootFolder_GetName_Documents(_iconIndices[ROOT_INDEX_DOCUMENTS]); + _names[ROOT_INDEX_NETWORK] = RootFolder_GetName_Network(_iconIndices[ROOT_INDEX_NETWORK]); }; STDMETHODIMP CRootFolder::LoadItems() @@ -42,50 +65,78 @@ STDMETHODIMP CRootFolder::LoadItems() STDMETHODIMP CRootFolder::GetNumberOfItems(UInt32 *numItems) { - *numItems = 2; + *numItems = kNumRootFolderItems; return S_OK; } STDMETHODIMP CRootFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) { - NCOM::CPropVariant propVariant; + NCOM::CPropVariant prop; switch(propID) { - case kpidIsFolder: - propVariant = true; - break; - case kpidName: - if (itemIndex == 0) - propVariant = _computerName; - else if (itemIndex == 1) - propVariant = _networkName; - break; + case kpidIsDir: prop = true; break; + case kpidName: prop = _names[itemIndex]; break; } - propVariant.Detach(value); + prop.Detach(value); return S_OK; } +UString GetMyDocsPath() +{ + UString us; + WCHAR s[MAX_PATH + 1]; + if (SHGetSpecialFolderPathW(0, s, CSIDL_PERSONAL, FALSE)) + us = s; + #ifndef _UNICODE + else + { + CHAR s2[MAX_PATH + 1]; + if (SHGetSpecialFolderPathA(0, s2, CSIDL_PERSONAL, FALSE)) + us = GetUnicodeString(s2); + } + #endif + if (us.Length() > 0 && us[us.Length() - 1] != L'\\') + us += L'\\'; + return us; +} + STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder) { - if (index == 0) + if (index == ROOT_INDEX_COMPUTER) { CFSDrives *fsDrivesSpec = new CFSDrives; CMyComPtr<IFolderFolder> subFolder = fsDrivesSpec; fsDrivesSpec->Init(); *resultFolder = subFolder.Detach(); } - else if (index == 1) + else if (index == ROOT_INDEX_NETWORK) { CNetFolder *netFolderSpec = new CNetFolder; CMyComPtr<IFolderFolder> subFolder = netFolderSpec; - netFolderSpec->Init(0, 0, _networkName + L'\\'); + netFolderSpec->Init(0, 0, _names[ROOT_INDEX_NETWORK] + L'\\'); *resultFolder = subFolder.Detach(); } + else if (index == ROOT_INDEX_DOCUMENTS) + { + UString s = GetMyDocsPath(); + if (!s.IsEmpty()) + { + NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder; + CMyComPtr<IFolderFolder> subFolder = fsFolderSpec; + RINOK(fsFolderSpec->Init(s, NULL)); + *resultFolder = subFolder.Detach(); + } + } else return E_INVALIDARG; return S_OK; } +static bool AreEqualNames(const UString &name1, const UString &name2) +{ + return (name1 == name2 || name1 == (name2 + UString(L'\\'))); +} + STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder) { *resultFolder = 0; @@ -99,12 +150,15 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu *resultFolder = rootFolder.Detach(); return S_OK; } - if (name2 == _computerName || - name2 == (_computerName + UString(L'\\'))) - return BindToFolder(UInt32(0), resultFolder); - if (name2 == _networkName || - name2 == (_networkName + UString(L'\\'))) - return BindToFolder(UInt32(1), resultFolder); + for (int i = 0; i < kNumRootFolderItems; i++) + if (AreEqualNames(name2, _names[i])) + return BindToFolder((UInt32)i, resultFolder); + if (AreEqualNames(name2, L"My Documents") || + AreEqualNames(name2, L"Documents")) + return BindToFolder((UInt32)ROOT_INDEX_DOCUMENTS, resultFolder); + if (AreEqualNames(name2, L"My Computer") || + AreEqualNames(name2, L"Computer")) + return BindToFolder((UInt32)ROOT_INDEX_COMPUTER, resultFolder); if (name2 == UString(L'\\')) { CMyComPtr<IFolderFolder> subFolder = this; @@ -157,7 +211,7 @@ STDMETHODIMP CRootFolder::GetNumberOfProperties(UInt32 *numProperties) return S_OK; } -STDMETHODIMP CRootFolder::GetPropertyInfo(UInt32 index, +STDMETHODIMP CRootFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) { if (index >= sizeof(kProperties) / sizeof(kProperties[0])) @@ -183,12 +237,7 @@ STDMETHODIMP CRootFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value) STDMETHODIMP CRootFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex) { - int aCSIDL; - if (index == 0) - aCSIDL = CSIDL_DRIVES; - else - aCSIDL = CSIDL_NETWORK; - *iconIndex = GetIconIndexForCSIDL(aCSIDL); + *iconIndex = _iconIndices[index]; return S_OK; } diff --git a/CPP/7zip/UI/FileManager/RootFolder.h b/CPP/7zip/UI/FileManager/RootFolder.h index 7dad969d..f17a0783 100755 --- a/CPP/7zip/UI/FileManager/RootFolder.h +++ b/CPP/7zip/UI/FileManager/RootFolder.h @@ -9,7 +9,9 @@ #include "FSFolder.h" -class CRootFolder: +const int kNumRootFolderItems = 3; + +class CRootFolder: public IFolderFolder, public IFolderGetSystemIconIndex, public CMyUnknownImp @@ -25,8 +27,8 @@ public: void Init(); private: - UString _computerName; - UString _networkName; + UString _names[kNumRootFolderItems]; + int _iconIndices[kNumRootFolderItems]; }; #endif diff --git a/CPP/7zip/UI/FileManager/SettingsPage.cpp b/CPP/7zip/UI/FileManager/SettingsPage.cpp index 4ce2919d..8b2eb836 100755 --- a/CPP/7zip/UI/FileManager/SettingsPage.cpp +++ b/CPP/7zip/UI/FileManager/SettingsPage.cpp @@ -16,7 +16,7 @@ using namespace NWindows; -static CIDLangPair kIDLangPairs[] = +static CIDLangPair kIDLangPairs[] = { { IDC_SETTINGS_SHOW_DOTS, 0x03010401}, { IDC_SETTINGS_SHOW_REAL_FILE_ICONS, 0x03010402}, @@ -91,7 +91,7 @@ void CSettingsPage::OnNotifyHelp() } bool CSettingsPage::OnButtonClicked(int buttonID, HWND buttonHWND) -{ +{ switch(buttonID) { /* diff --git a/CPP/7zip/UI/FileManager/SettingsPage.rc b/CPP/7zip/UI/FileManager/SettingsPage.rc index ddd0911b..1d0e709b 100755 --- a/CPP/7zip/UI/FileManager/SettingsPage.rc +++ b/CPP/7zip/UI/FileManager/SettingsPage.rc @@ -13,23 +13,23 @@ MY_FONT BEGIN CONTROL "Show "".."" item", IDC_SETTINGS_SHOW_DOTS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, marg, marg, xSize2, 10 - CONTROL "Show real file &icons", IDC_SETTINGS_SHOW_REAL_FILE_ICONS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, + CONTROL "Show real file &icons", IDC_SETTINGS_SHOW_REAL_FILE_ICONS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, marg, 21, xSize2, 10 - CONTROL "Show system &menu", IDC_SETTINGS_SHOW_SYSTEM_MENU, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, + CONTROL "Show system &menu", IDC_SETTINGS_SHOW_SYSTEM_MENU, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, marg, 35, xSize2, 10 - CONTROL "&Full row select", IDC_SETTINGS_FULL_ROW, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, + CONTROL "&Full row select", IDC_SETTINGS_FULL_ROW, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, marg, 63, xSize2, 10 - CONTROL "Show &grid lines", IDC_SETTINGS_SHOW_GRID, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, + CONTROL "Show &grid lines", IDC_SETTINGS_SHOW_GRID, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, marg, 77, xSize2, 10 - CONTROL "&Single-click to open an item", IDC_SETTINGS_SINGLE_CLICK, "Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP, + CONTROL "&Single-click to open an item", IDC_SETTINGS_SINGLE_CLICK, "Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP, marg, 91, xSize2, 10 - CONTROL "&Underline current name", IDC_SETTINGS_UNDERLINE, "Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP, + CONTROL "&Underline current name", IDC_SETTINGS_UNDERLINE, "Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP, marg + 12, 105, xSize2 - 12, 10 - CONTROL "&Alternative selection mode", IDC_SETTINGS_ALTERNATIVE_SELECTION, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, + CONTROL "&Alternative selection mode", IDC_SETTINGS_ALTERNATIVE_SELECTION, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, marg, 122, xSize2, 10 - CONTROL "Use &large memory pages", IDC_SETTINGS_LARGE_PAGES, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, + CONTROL "Use &large memory pages", IDC_SETTINGS_LARGE_PAGES, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, marg, 142, xSize2, 10 END diff --git a/CPP/7zip/UI/FileManager/SplitDialog.cpp b/CPP/7zip/UI/FileManager/SplitDialog.cpp index 1a3770ee..bab319d1 100755 --- a/CPP/7zip/UI/FileManager/SplitDialog.cpp +++ b/CPP/7zip/UI/FileManager/SplitDialog.cpp @@ -8,7 +8,7 @@ #include "Windows/FileName.h" #include "SplitUtils.h" -#ifdef LANG +#ifdef LANG #include "LangUtils.h" #endif @@ -16,8 +16,8 @@ using namespace NWindows; -#ifdef LANG -static CIDLangPair kIDLangPairs[] = +#ifdef LANG +static CIDLangPair kIDLangPairs[] = { { IDC_STATIC_SPLIT_PATH, 0x03020501 }, { IDC_STATIC_SPLIT_VOLUME, 0x02000D40 }, @@ -25,9 +25,9 @@ static CIDLangPair kIDLangPairs[] = #endif -bool CSplitDialog::OnInit() +bool CSplitDialog::OnInit() { - #ifdef LANG + #ifdef LANG LangSetWindowText(HWND(*this), 0x03020500); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif @@ -59,7 +59,7 @@ bool CSplitDialog::OnButtonClicked(int buttonID, HWND buttonHWND) return CModalDialog::OnButtonClicked(buttonID, buttonHWND); } -void CSplitDialog::OnButtonSetPath() +void CSplitDialog::OnButtonSetPath() { UString currentPath; _pathCombo.GetText(currentPath); @@ -82,7 +82,7 @@ void CSplitDialog::OnOK() volumeString.Trim(); if (!ParseVolumeSizes(volumeString, VolumeSizes) || VolumeSizes.Size() == 0) { - ::MessageBoxW(*this, LangString(IDS_COMPRESS_INCORRECT_VOLUME_SIZE, 0x02000D41), L"7-Zip", 0); + ::MessageBoxW(*this, LangString(IDS_COMPRESS_INCORRECT_VOLUME_SIZE, 0x02000D41), L"7-Zip", 0); return; } CModalDialog::OnOK(); diff --git a/CPP/7zip/UI/FileManager/StringUtils.cpp b/CPP/7zip/UI/FileManager/StringUtils.cpp index 63eebdba..bddaa971 100755 --- a/CPP/7zip/UI/FileManager/StringUtils.cpp +++ b/CPP/7zip/UI/FileManager/StringUtils.cpp @@ -23,7 +23,7 @@ void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2) break; } } - else + else dest1 += c; } dest2 = src.Mid(i); diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.cpp b/CPP/7zip/UI/FileManager/SysIconUtils.cpp index 0d337550..5af6f850 100755 --- a/CPP/7zip/UI/FileManager/SysIconUtils.cpp +++ b/CPP/7zip/UI/FileManager/SysIconUtils.cpp @@ -11,21 +11,21 @@ extern bool g_IsNT; #endif -int GetIconIndexForCSIDL(int aCSIDL) +int GetIconIndexForCSIDL(int csidl) { - LPITEMIDLIST pidlMyComputer = 0; - SHGetSpecialFolderLocation(NULL, aCSIDL, &pidlMyComputer); - if (pidlMyComputer) + LPITEMIDLIST pidl = 0; + SHGetSpecialFolderLocation(NULL, csidl, &pidl); + if (pidl) { SHFILEINFO shellInfo; - SHGetFileInfo(LPCTSTR(pidlMyComputer), FILE_ATTRIBUTE_NORMAL, - &shellInfo, sizeof(shellInfo), + SHGetFileInfo(LPCTSTR(pidl), FILE_ATTRIBUTE_NORMAL, + &shellInfo, sizeof(shellInfo), SHGFI_PIDL | SHGFI_SYSICONINDEX); IMalloc *pMalloc; SHGetMalloc(&pMalloc); if(pMalloc) { - pMalloc->Free(pidlMyComputer); + pMalloc->Free(pidl); pMalloc->Release(); } return shellInfo.iIcon; @@ -33,10 +33,10 @@ int GetIconIndexForCSIDL(int aCSIDL) return 0; } -DWORD_PTR GetRealIconIndex(LPCTSTR path, UINT32 attributes, int &iconIndex) +DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attributes, int &iconIndex) { SHFILEINFO shellInfo; - DWORD_PTR res = ::SHGetFileInfo(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, + DWORD_PTR res = ::SHGetFileInfo(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX); iconIndex = shellInfo.iIcon; return res; @@ -70,13 +70,13 @@ DWORD_PTR MySHGetFileInfoW(LPCWSTR pszPath, DWORD dwFileAttributes, SHFILEINFOW } #ifndef _UNICODE -// static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; } -DWORD_PTR GetRealIconIndex(LPCWSTR path, UINT32 attributes, int &iconIndex) +// static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; } +DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attributes, int &iconIndex) { if(g_IsNT) { SHFILEINFOW shellInfo; - DWORD_PTR res = ::MySHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, + DWORD_PTR res = ::MySHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX); iconIndex = shellInfo.iIcon; return res; @@ -86,7 +86,7 @@ DWORD_PTR GetRealIconIndex(LPCWSTR path, UINT32 attributes, int &iconIndex) } #endif -DWORD_PTR GetRealIconIndex(const UString &fileName, UINT32 attributes, +DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attributes, int &iconIndex, UString &typeName) { #ifndef _UNICODE @@ -94,8 +94,8 @@ DWORD_PTR GetRealIconIndex(const UString &fileName, UINT32 attributes, { SHFILEINFO shellInfo; shellInfo.szTypeName[0] = 0; - DWORD_PTR res = ::SHGetFileInfoA(GetSystemString(fileName), FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, - sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX + DWORD_PTR res = ::SHGetFileInfoA(GetSystemString(fileName), FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, + sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | SHGFI_TYPENAME); typeName = GetUnicodeString(shellInfo.szTypeName); iconIndex = shellInfo.iIcon; @@ -106,8 +106,8 @@ DWORD_PTR GetRealIconIndex(const UString &fileName, UINT32 attributes, { SHFILEINFOW shellInfo; shellInfo.szTypeName[0] = 0; - DWORD_PTR res = ::MySHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, - sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX + DWORD_PTR res = ::MySHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, + sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | SHGFI_TYPENAME); typeName = shellInfo.szTypeName; iconIndex = shellInfo.iIcon; diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.h b/CPP/7zip/UI/FileManager/SysIconUtils.h index 3b6c6c2e..a90d28bc 100755 --- a/CPP/7zip/UI/FileManager/SysIconUtils.h +++ b/CPP/7zip/UI/FileManager/SysIconUtils.h @@ -32,7 +32,7 @@ class CExtToIconMap CObjectVector<CExtIconPair> _map; public: CExtToIconMap(): _dirIconIndex(-1), _noExtIconIndex(-1) {} - void Clear() + void Clear() { _dirIconIndex = -1; _noExtIconIndex = -1; @@ -42,10 +42,10 @@ public: int GetIconIndex(UINT32 attributes, const UString &fileName); }; -DWORD_PTR GetRealIconIndex(LPCTSTR path, UINT32 attributes, int &iconIndex); +DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attributes, int &iconIndex); #ifndef _UNICODE -DWORD_PTR GetRealIconIndex(LPCWSTR path, UINT32 attributes, int &iconIndex); +DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attributes, int &iconIndex); #endif -int GetIconIndexForCSIDL(int aCSIDL); +int GetIconIndexForCSIDL(int csidl); #endif diff --git a/CPP/7zip/UI/FileManager/SystemPage.cpp b/CPP/7zip/UI/FileManager/SystemPage.cpp index 40da5cb3..f8605ea8 100755 --- a/CPP/7zip/UI/FileManager/SystemPage.cpp +++ b/CPP/7zip/UI/FileManager/SystemPage.cpp @@ -26,7 +26,7 @@ using namespace NRegistryAssociations; const int kRefreshpluginsListMessage = WM_USER + 1; const int kUpdateDatabase = kRefreshpluginsListMessage + 1; -static CIDLangPair kIDLangPairs[] = +static CIDLangPair kIDLangPairs[] = { { IDC_SYSTEM_STATIC_ASSOCIATE, 0x03010302}, { IDC_SYSTEM_SELECT_ALL, 0x03000330} @@ -44,7 +44,7 @@ bool CSystemPage::OnInit() _listViewPlugins.Attach(GetItem(IDC_SYSTEM_LIST_PLUGINS)); /* - CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, + CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, NRegistryAssociations::CheckContextMenuHandler()); */ @@ -52,26 +52,11 @@ bool CSystemPage::OnInit() _listViewExt.SetExtendedListViewStyle(newFlags, newFlags); _listViewPlugins.SetExtendedListViewStyle(newFlags, newFlags); - UString s = LangString(IDS_PROPERTY_EXTENSION, 0x02000205); - LVCOLUMNW column; - column.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT | LVCF_SUBITEM; - column.cx = 70; - column.fmt = LVCFMT_LEFT; - column.pszText = (LPWSTR)(LPCWSTR)s; - column.iSubItem = 0; - _listViewExt.InsertColumn(0, &column); - - s = LangString(IDS_PLUGIN, 0x03010310); - column.cx = 70; - column.pszText = (LPWSTR)(LPCWSTR)s; - column.iSubItem = 1; - _listViewExt.InsertColumn(1, &column); - - s = LangString(IDS_PLUGIN, 0x03010310); - column.cx = 70; - column.pszText = (LPWSTR)(LPCWSTR)s; - column.iSubItem = 0; - _listViewPlugins.InsertColumn(0, &column); + _listViewExt.InsertColumn(0, LangString(IDS_PROPERTY_EXTENSION, 0x02000205), 70); + const UString s = LangString(IDS_PLUGIN, 0x03010310); + _listViewExt.InsertColumn(1, s, 70); + + _listViewPlugins.InsertColumn(0, s, 70); _extDatabase.Read(); @@ -79,13 +64,7 @@ bool CSystemPage::OnInit() { CExtInfoBig &extInfo = _extDatabase.ExtBigItems[i]; - LVITEMW item; - item.iItem = i; - item.mask = LVIF_TEXT | LVIF_PARAM; - item.lParam = i; - item.pszText = (LPWSTR)(LPCWSTR)extInfo.Ext; - item.iSubItem = 0; - int itemIndex = _listViewExt.InsertItem(&item); + int itemIndex = _listViewExt.InsertItem(i, (LPCWSTR)extInfo.Ext); UString iconPath; int iconIndex; @@ -111,13 +90,7 @@ bool CSystemPage::OnInit() void CSystemPage::SetMainPluginText(int itemIndex, int indexInDatabase) { - LVITEMW item; - item.iItem = itemIndex; - item.mask = LVIF_TEXT; - UString mainPlugin = _extDatabase.GetMainPluginNameForExtItem(indexInDatabase); - item.pszText = (WCHAR *)(const WCHAR *)mainPlugin; - item.iSubItem = 1; - _listViewExt.SetItem(&item); + _listViewExt.SetSubItem(itemIndex, 1, _extDatabase.GetMainPluginNameForExtItem(indexInDatabase)); } static UString GetProgramCommand() @@ -181,7 +154,7 @@ LONG CSystemPage::OnApply() const CPluginInfo &plugin = _extDatabase.Plugins[extInfo.PluginsPairs[0].Index]; iconPath = GetIconPath(plugin.FilePath, plugin.ClassID, extInfo.Ext, iconIndex); } - NRegistryAssociations::AddShellExtensionInfo(GetSystemString(extInfo.Ext), + NRegistryAssociations::AddShellExtensionInfo(GetSystemString(extInfo.Ext), title, command, iconPath, iconIndex, NULL, 0); } else @@ -203,7 +176,7 @@ void CSystemPage::OnNotifyHelp() } void CSystemPage::SelectAll() -{ +{ int count = _listViewExt.GetItemCount(); for (int i = 0; i < count; i++) _listViewExt.SetCheckState(i, true); @@ -211,7 +184,7 @@ void CSystemPage::SelectAll() } bool CSystemPage::OnButtonClicked(int buttonID, HWND buttonHWND) -{ +{ switch(buttonID) { case IDC_SYSTEM_SELECT_ALL: @@ -224,8 +197,8 @@ bool CSystemPage::OnButtonClicked(int buttonID, HWND buttonHWND) return CPropertyPage::OnButtonClicked(buttonID, buttonHWND); } -bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam) -{ +bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam) +{ if (lParam->hwndFrom == HWND(_listViewExt)) { switch(lParam->code) @@ -241,7 +214,7 @@ bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam) PostMessage(kUpdateDatabase, 0); break; } - } + } else if (lParam->hwndFrom == HWND(_listViewPlugins)) { switch(lParam->code) @@ -268,7 +241,7 @@ bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam) } } } - return CPropertyPage::OnNotify(controlID, lParam); + return CPropertyPage::OnNotify(controlID, lParam); } bool CSystemPage::OnPluginsKeyDown(LPNMLVKEYDOWN keyDownInfo) @@ -394,14 +367,7 @@ void CSystemPage::RefreshPluginsList(int selectIndex) for (int i = 0; i < extInfo.PluginsPairs.Size(); i++) { CPluginEnabledPair pluginPair = extInfo.PluginsPairs[i]; - UString pluginName = _extDatabase.Plugins[pluginPair.Index].Name; - LVITEMW item; - item.iItem = i; - item.mask = LVIF_TEXT | LVIF_PARAM; - item.lParam = i; - item.pszText = (LPWSTR)(LPCWSTR)pluginName; - item.iSubItem = 0; - int itemIndex = _listViewPlugins.InsertItem(&item); + int itemIndex = _listViewPlugins.InsertItem(i, _extDatabase.Plugins[pluginPair.Index].Name); _listViewPlugins.SetCheckState(itemIndex, pluginPair.Enabled); } if(_listViewPlugins.GetItemCount() > 0) diff --git a/CPP/7zip/UI/FileManager/SystemPage.rc b/CPP/7zip/UI/FileManager/SystemPage.rc index f881f612..1cf9405f 100755 --- a/CPP/7zip/UI/FileManager/SystemPage.rc +++ b/CPP/7zip/UI/FileManager/SystemPage.rc @@ -15,7 +15,7 @@ CAPTION "System" MY_FONT BEGIN LTEXT "Associate 7-Zip with:", IDC_SYSTEM_STATIC_ASSOCIATE, marg, marg, xSize2, 8 - CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32", + CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32", LVS_LIST | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP, marg, 20, g0Size, gYSize PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, marg, (ySize - marg - bYSize), 90, bYSize diff --git a/CPP/7zip/UI/FileManager/TextPairs.cpp b/CPP/7zip/UI/FileManager/TextPairs.cpp index a149fe37..74df1c62 100755 --- a/CPP/7zip/UI/FileManager/TextPairs.cpp +++ b/CPP/7zip/UI/FileManager/TextPairs.cpp @@ -38,8 +38,8 @@ static UString GetIDString(const wchar_t *srcString, int &finishPos) break; finishPos++; bool isSeparatorChar = IsSeparatorChar(c); - if (c == kNewLineChar || (isSeparatorChar && !quotes) - || (c == kQuoteChar && quotes)) + if (c == kNewLineChar || (isSeparatorChar && !quotes) + || (c == kQuoteChar && quotes)) break; else if (c == kQuoteChar) quotes = true; @@ -60,7 +60,7 @@ static UString GetValueString(const wchar_t *srcString, int &finishPos) if (c == kEndOfLine) break; finishPos++; - if (c == kNewLineChar) + if (c == kNewLineChar) break; result += c; } @@ -131,7 +131,7 @@ void CPairsStorage::Sort() int CPairsStorage::FindID(const UString &id, int &insertPos) { - int left = 0, right = Pairs.Size(); + int left = 0, right = Pairs.Size(); while (left != right) { UINT32 mid = (left + right) / 2; diff --git a/CPP/7zip/UI/FileManager/UpdateCallback100.cpp b/CPP/7zip/UI/FileManager/UpdateCallback100.cpp index 927d3cd5..376e7647 100755 --- a/CPP/7zip/UI/FileManager/UpdateCallback100.cpp +++ b/CPP/7zip/UI/FileManager/UpdateCallback100.cpp @@ -42,14 +42,7 @@ STDMETHODIMP CUpdateCallback100Imp::SetTotal(UInt64 size) STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 *completeValue) { - for (;;) - { - if(ProgressDialog.ProgressSynch.GetStopped()) - return E_ABORT; - if(!ProgressDialog.ProgressSynch.GetPaused()) - break; - ::Sleep(100); - } + RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); if (completeValue != NULL) ProgressDialog.ProgressSynch.SetPos(*completeValue); return S_OK; @@ -104,3 +97,23 @@ STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword2(Int32 *passwordIsDefi *password = tempName.Detach(); return S_OK; } + +STDMETHODIMP CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */) +{ + return S_OK; +} + +STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */) +{ + return ProgressDialog.ProgressSynch.ProcessStopAndPause(); +} + +STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password) +{ + if (!_passwordIsDefined) + return S_FALSE; + CMyComBSTR tempName = _password; + *password = tempName.Detach(); + return S_OK; +} + diff --git a/CPP/7zip/UI/FileManager/UpdateCallback100.h b/CPP/7zip/UI/FileManager/UpdateCallback100.h index fd75bf2f..5ae194a2 100755 --- a/CPP/7zip/UI/FileManager/UpdateCallback100.h +++ b/CPP/7zip/UI/FileManager/UpdateCallback100.h @@ -10,35 +10,33 @@ #include "ProgressDialog2.h" #include "../../IPassword.h" -#ifdef LANG +#ifdef LANG #include "LangUtils.h" #endif -class CUpdateCallback100Imp: +class CUpdateCallback100Imp: public IFolderArchiveUpdateCallback, public ICryptoGetTextPassword2, + public ICryptoGetTextPassword, + public IArchiveOpenCallback, public ICompressProgressInfo, public CMyUnknownImp { public: - MY_UNKNOWN_IMP3( - IFolderArchiveUpdateCallback, + MY_UNKNOWN_IMP5( + IFolderArchiveUpdateCallback, ICryptoGetTextPassword2, + ICryptoGetTextPassword, + IArchiveOpenCallback, ICompressProgressInfo) - // IProgress + INTERFACE_IProgress(;) + INTERFACE_IArchiveOpenCallback(;) + INTERFACE_IFolderArchiveUpdateCallback(;) - STDMETHOD(SetTotal)(UInt64 size); - STDMETHOD(SetCompleted)(const UInt64 *completeValue); STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); - // IUpdateCallBack - STDMETHOD(CompressOperation)(const wchar_t *name); - STDMETHOD(DeleteOperation)(const wchar_t *name); - STDMETHOD(OperationResult)(Int32 operationResult); - STDMETHOD(UpdateErrorMessage)(const wchar_t *message); - STDMETHOD(SetNumFiles)(UInt64 numFiles); - + STDMETHOD(CryptoGetTextPassword)(BSTR *password); STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password); private: bool _passwordIsDefined; @@ -56,7 +54,7 @@ public: UInt64 NumFolders; UInt64 NumFiles; - void Init(HWND parentWindow, + void Init(HWND parentWindow, bool passwordIsDefined, const UString &password) { _passwordIsDefined = passwordIsDefined; diff --git a/CPP/7zip/UI/FileManager/ViewSettings.cpp b/CPP/7zip/UI/FileManager/ViewSettings.cpp index 9102cc4e..34d01229 100755 --- a/CPP/7zip/UI/FileManager/ViewSettings.cpp +++ b/CPP/7zip/UI/FileManager/ViewSettings.cpp @@ -416,7 +416,7 @@ void SaveCopyHistory(const UStringVector &folders) void ReadCopyHistory(UStringVector &folders) { ReadStringList(kCopyHistoryValueName, folders); } -void AddUniqueStringToHeadOfList(UStringVector &list, +void AddUniqueStringToHeadOfList(UStringVector &list, const UString &string) { for(int i = 0; i < list.Size();) diff --git a/CPP/7zip/UI/FileManager/ViewSettings.h b/CPP/7zip/UI/FileManager/ViewSettings.h index 4af0b991..2500ce7b 100755 --- a/CPP/7zip/UI/FileManager/ViewSettings.h +++ b/CPP/7zip/UI/FileManager/ViewSettings.h @@ -13,13 +13,13 @@ struct CColumnInfo }; inline bool operator==(const CColumnInfo &a1, const CColumnInfo &a2) -{ - return (a1.PropID == a2.PropID) && - (a1.IsVisible == a2.IsVisible) && (a1.Width == a2.Width); +{ + return (a1.PropID == a2.PropID) && + (a1.IsVisible == a2.IsVisible) && (a1.Width == a2.Width); } inline bool operator!=(const CColumnInfo &a1, const CColumnInfo &a2) -{ +{ return !(a1 == a2); } @@ -44,11 +44,11 @@ struct CListViewInfo return -1; } - bool IsEqual(const CListViewInfo &aNewInfo) const + bool IsEqual(const CListViewInfo &aNewInfo) const { if (Columns.Size() != aNewInfo.Columns.Size() || - // SortIndex != aNewInfo.SortIndex || - SortID != aNewInfo.SortID || + // SortIndex != aNewInfo.SortIndex || + SortID != aNewInfo.SortID || Ascending != aNewInfo.Ascending) return false; for (int i = 0; i < Columns.Size(); i++) @@ -92,7 +92,7 @@ void ReadFastFolders(UStringVector &folders); void SaveCopyHistory(const UStringVector &folders); void ReadCopyHistory(UStringVector &folders); -void AddUniqueStringToHeadOfList(UStringVector &list, +void AddUniqueStringToHeadOfList(UStringVector &list, const UString &string); #endif diff --git a/CPP/7zip/UI/FileManager/makefile b/CPP/7zip/UI/FileManager/makefile index 0b815ad9..78921b90 100755 --- a/CPP/7zip/UI/FileManager/makefile +++ b/CPP/7zip/UI/FileManager/makefile @@ -102,6 +102,7 @@ WIN_OBJS = \ $O\Security.obj \ $O\Shell.obj \ $O\Synchronization.obj \ + $O\Time.obj \ $O\Window.obj \ WIN_CTRL_OBJS = \ diff --git a/CPP/7zip/UI/FileManager/resource.h b/CPP/7zip/UI/FileManager/resource.h index 864c066b..edd351b6 100755 --- a/CPP/7zip/UI/FileManager/resource.h +++ b/CPP/7zip/UI/FileManager/resource.h @@ -42,7 +42,7 @@ #define IDM_OPEN_PARENT_FOLDER 431 #define IDM_FOLDERS_HISTORY 432 #define IDM_VIEW_REFRESH 440 -#define IDM_VIEW_FLAT_VIEW 449 +#define IDM_VIEW_FLAT_VIEW 449 #define IDM_VIEW_TWO_PANELS 450 #define IDM_VIEW_TOOLBARS 451 #define IDM_VIEW_STANDARD_TOOLBAR 460 @@ -86,6 +86,7 @@ #define IDS_WANT_TO_DELETE_ITEMS 2215 #define IDS_DELETING 2216 #define IDS_ERROR_DELETING 2217 +#define IDS_ERROR_LONG_PATH_TO_RECYCLE 2218 #define IDS_RENAMING 2220 #define IDS_ERROR_RENAMING 2221 @@ -116,8 +117,10 @@ #define IDS_CANNOT_UPDATE_FILE 2281 #define IDS_CANNOT_START_EDITOR 2282 #define IDS_OPENNING 2283 +#define IDS_VIRUS 2284 #define IDS_COMPUTER 2300 #define IDS_NETWORK 2301 +#define IDS_DOCUMENTS 2302 #define IDS_ADD 2400 #define IDS_EXTRACT 2401 #define IDS_TEST 2402 @@ -145,6 +148,8 @@ #define IDS_COMBINE_TO 4031 #define IDS_COMBINING 4032 #define IDS_COMBINE_SELECT_ONE_FILE 4033 +#define IDS_COMBINE_CANT_DETECT_SPLIT_FILE 4034 +#define IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART 4035 #define IDS_CHECKSUM_CALCULATING 4040 #define IDS_CHECKSUM_INFORMATION 4041 @@ -157,3 +162,7 @@ #define IDS_PROGRESS_TESTING 4100 #define IDS_MESSAGE_NO_ERRORS 4200 +#define IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER 4301 +#define IDS_SELECT_ONE_FILE 4302 +#define IDS_SELECT_FILES 4303 +#define IDS_FILE_EXIST 4304 diff --git a/CPP/7zip/UI/FileManager/resource.rc b/CPP/7zip/UI/FileManager/resource.rc index b8664cbe..3ec3bb32 100755 --- a/CPP/7zip/UI/FileManager/resource.rc +++ b/CPP/7zip/UI/FileManager/resource.rc @@ -5,7 +5,7 @@ MY_VERSION_INFO_APP("7-Zip File Manager", "7zFM") -IDR_ACCELERATOR1 ACCELERATORS +IDR_ACCELERATOR1 ACCELERATORS BEGIN "N", IDM_CREATE_FILE, VIRTKEY, CONTROL, NOINVERT VK_F1, IDM_HELP_CONTENTS, VIRTKEY, NOINVERT @@ -42,10 +42,10 @@ BEGIN END POPUP "&Edit" BEGIN - MENUITEM "Cu&t\tCtrl+X", IDM_EDIT_CUT, GRAYED - MENUITEM "&Copy\tCtrl+C", IDM_EDIT_COPY, GRAYED - MENUITEM "&Paste\tCtrl+V", IDM_EDIT_PASTE, GRAYED - MENUITEM SEPARATOR + // MENUITEM "Cu&t\tCtrl+X", IDM_EDIT_CUT, GRAYED + // MENUITEM "&Copy\tCtrl+C", IDM_EDIT_COPY, GRAYED + // MENUITEM "&Paste\tCtrl+V", IDM_EDIT_PASTE, GRAYED + // MENUITEM SEPARATOR MENUITEM "Select &All\tShift+[Grey +]", IDM_SELECT_ALL MENUITEM "Deselect All\tShift+[Grey -]", IDM_DESELECT_ALL MENUITEM "&Invert Selection\tGrey *", IDM_INVERT_SELECTION @@ -126,7 +126,7 @@ IDB_DELETE2 BITMAP "Delete2.bmp" IDB_INFO2 BITMAP "Info2.bmp" -STRINGTABLE +STRINGTABLE BEGIN IDS_APP_TITLE "7-Zip File Manager" IDS_COPY "Copy" @@ -144,7 +144,9 @@ BEGIN IDS_COMBINE "Combine Files" IDS_COMBINE_TO "&Combine to:" IDS_COMBINING "Combining..." - IDS_COMBINE_SELECT_ONE_FILE "Select only first file" + IDS_COMBINE_SELECT_ONE_FILE "Select only first part of split file" + IDS_COMBINE_CANT_DETECT_SPLIT_FILE "Can not detect file as split file" + IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART "Can not find more than one part of split file" IDS_CHECKSUM_CALCULATING "Checksum calculating..." IDS_CHECKSUM_INFORMATION "Checksum information" @@ -165,6 +167,7 @@ BEGIN IDS_WANT_TO_DELETE_ITEMS "Are you sure you want to delete these {0} items?" IDS_DELETING "Deleting..." IDS_ERROR_DELETING "Error Deleting File or Folder" + IDS_ERROR_LONG_PATH_TO_RECYCLE "The system cannot move a file with long path to the Recycle Bin" IDS_RENAMING "Renaming..." IDS_ERROR_RENAMING "Error Renaming File or Folder" IDS_CONFIRM_FILE_COPY "Confirm File Copy" @@ -202,6 +205,7 @@ BEGIN IDS_CANNOT_UPDATE_FILE "Can not update file\n'{0}'" IDS_CANNOT_START_EDITOR "Cannot start editor." IDS_OPENNING "Opening..." + IDS_VIRUS "The file looks like a virus (the file name contains long spaces in name)." IDS_ADD "Add" IDS_EXTRACT "Extract" IDS_TEST "Test" @@ -212,9 +216,14 @@ BEGIN IDS_BOOKMARK "Bookmark" IDS_COMPUTER "Computer" IDS_NETWORK "Network" + IDS_DOCUMENTS "Documents" IDS_PROGRESS_TESTING "Testing" IDS_MESSAGE_NO_ERRORS "There are no errors" + IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER "The operation cannot be called from a folder that has a long path." + IDS_SELECT_ONE_FILE "You must select one file" + IDS_SELECT_FILES "You must select one or more files" + IDS_FILE_EXIST "File {0} is already exist" END |