1 // Panel.h 2 3 #ifndef __PANEL_H 4 #define __PANEL_H 5 6 #include "../../../Common/MyWindows.h" 7 8 #include <ShlObj.h> 9 10 #include "../../../../C/Alloc.h" 11 12 #include "../../../Common/Defs.h" 13 #include "../../../Common/MyCom.h" 14 15 #include "../../../Windows/DLL.h" 16 #include "../../../Windows/FileDir.h" 17 #include "../../../Windows/FileFind.h" 18 #include "../../../Windows/FileName.h" 19 #include "../../../Windows/Handle.h" 20 #include "../../../Windows/PropVariantConv.h" 21 #include "../../../Windows/Synchronization.h" 22 23 #include "../../../Windows/Control/ComboBox.h" 24 #include "../../../Windows/Control/Edit.h" 25 #include "../../../Windows/Control/ListView.h" 26 #include "../../../Windows/Control/ReBar.h" 27 #include "../../../Windows/Control/Static.h" 28 #include "../../../Windows/Control/StatusBar.h" 29 #include "../../../Windows/Control/ToolBar.h" 30 #include "../../../Windows/Control/Window2.h" 31 32 #include "../../Archive/IArchive.h" 33 34 #include "ExtractCallback.h" 35 36 #include "AppState.h" 37 #include "IFolder.h" 38 #include "MyCom2.h" 39 #include "ProgressDialog2.h" 40 #include "SysIconUtils.h" 41 42 #ifdef UNDER_CE 43 #define NON_CE_VAR(_v_) 44 #else 45 #define NON_CE_VAR(_v_) _v_ 46 #endif 47 48 const int kParentFolderID = 100; 49 50 const int kParentIndex = -1; 51 const UInt32 kParentIndex_UInt32 = (UInt32)(Int32)kParentIndex; 52 53 #if !defined(_WIN32) || defined(UNDER_CE) 54 #define ROOT_FS_FOLDER L"\\" 55 #else 56 #define ROOT_FS_FOLDER L"C:\\" 57 #endif 58 59 struct CPanelCallback 60 { 61 virtual void OnTab() = 0; 62 virtual void SetFocusToPath(unsigned index) = 0; 63 virtual void OnCopy(bool move, bool copyToSame) = 0; 64 virtual void OnSetSameFolder() = 0; 65 virtual void OnSetSubFolder() = 0; 66 virtual void PanelWasFocused() = 0; 67 virtual void DragBegin() = 0; 68 virtual void DragEnd() = 0; 69 virtual void RefreshTitle(bool always) = 0; 70 }; 71 72 void PanelCopyItems(); 73 74 75 struct CPropColumn 76 { 77 int Order; 78 PROPID ID; 79 VARTYPE Type; 80 bool IsVisible; 81 bool IsRawProp; 82 UInt32 Width; 83 UString Name; 84 IsEqualToCPropColumn85 bool IsEqualTo(const CPropColumn &a) const 86 { 87 return Order == a.Order 88 && ID == a.ID 89 && Type == a.Type 90 && IsVisible == a.IsVisible 91 && IsRawProp == a.IsRawProp 92 && Width == a.Width 93 && Name == a.Name; 94 } 95 CompareCPropColumn96 int Compare(const CPropColumn &a) const { return MyCompare(Order, a.Order); } 97 Compare_NameFirstCPropColumn98 int Compare_NameFirst(const CPropColumn &a) const 99 { 100 if (ID == kpidName) 101 { 102 if (a.ID != kpidName) 103 return -1; 104 } 105 else if (a.ID == kpidName) 106 return 1; 107 return MyCompare(Order, a.Order); 108 } 109 }; 110 111 112 class CPropColumns: public CObjectVector<CPropColumn> 113 { 114 public: FindItem_for_PropID(PROPID id)115 int FindItem_for_PropID(PROPID id) const 116 { 117 FOR_VECTOR (i, (*this)) 118 if ((*this)[i].ID == id) 119 return i; 120 return -1; 121 } 122 IsEqualTo(const CPropColumns & props)123 bool IsEqualTo(const CPropColumns &props) const 124 { 125 if (Size() != props.Size()) 126 return false; 127 FOR_VECTOR (i, (*this)) 128 if (!(*this)[i].IsEqualTo(props[i])) 129 return false; 130 return true; 131 } 132 }; 133 134 135 struct CTempFileInfo 136 { 137 UInt32 FileIndex; // index of file in folder 138 UString RelPath; // Relative path of file from Folder 139 FString FolderPath; 140 FString FilePath; 141 NWindows::NFile::NFind::CFileInfo FileInfo; 142 bool NeedDelete; 143 CTempFileInfoCTempFileInfo144 CTempFileInfo(): FileIndex((UInt32)(Int32)-1), NeedDelete(false) {} DeleteDirAndFileCTempFileInfo145 void DeleteDirAndFile() const 146 { 147 if (NeedDelete) 148 { 149 NWindows::NFile::NDir::DeleteFileAlways(FilePath); 150 NWindows::NFile::NDir::RemoveDir(FolderPath); 151 } 152 } WasChangedCTempFileInfo153 bool WasChanged(const NWindows::NFile::NFind::CFileInfo &newFileInfo) const 154 { 155 return newFileInfo.Size != FileInfo.Size || 156 CompareFileTime(&newFileInfo.MTime, &FileInfo.MTime) != 0; 157 } 158 }; 159 160 struct CFolderLink: public CTempFileInfo 161 { 162 NWindows::NDLL::CLibrary Library; 163 CMyComPtr<IFolderFolder> ParentFolder; // can be NULL, if parent is FS folder (in _parentFolders[0]) 164 UString ParentFolderPath; // including tail slash (doesn't include paths parts of parent in next level) 165 bool UsePassword; 166 UString Password; 167 bool IsVirtual; 168 169 UString VirtualPath; // without tail slash CFolderLinkCFolderLink170 CFolderLink(): UsePassword(false), IsVirtual(false) {} 171 WasChangedCFolderLink172 bool WasChanged(const NWindows::NFile::NFind::CFileInfo &newFileInfo) const 173 { 174 return IsVirtual || CTempFileInfo::WasChanged(newFileInfo); 175 } 176 177 }; 178 179 enum MyMessages 180 { 181 // we can use WM_USER, since we have defined new window class. 182 // so we don't need WM_APP. 183 kShiftSelectMessage = WM_USER + 1, 184 kReLoadMessage, 185 kSetFocusToListView, 186 kOpenItemChanged, 187 kRefresh_StatusBar 188 #ifdef UNDER_CE 189 , kRefresh_HeaderComboBox 190 #endif 191 }; 192 193 UString GetFolderPath(IFolderFolder *folder); 194 195 class CPanel; 196 197 class CMyListView: public NWindows::NControl::CListView2 198 { 199 public: 200 CPanel *_panel; 201 LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam); 202 }; 203 204 /* 205 class CMyComboBox: public NWindows::NControl::CComboBoxEx 206 { 207 public: 208 WNDPROC _origWindowProc; 209 CPanel *_panel; 210 LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam); 211 }; 212 */ 213 class CMyComboBoxEdit: public NWindows::NControl::CEdit 214 { 215 public: 216 WNDPROC _origWindowProc; 217 CPanel *_panel; 218 LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam); 219 }; 220 221 struct CSelectedState 222 { 223 int FocusedItem; 224 bool SelectFocused; 225 bool FocusedName_Defined; 226 UString FocusedName; 227 UStringVector SelectedNames; 228 CSelectedStateCSelectedState229 CSelectedState(): FocusedItem(-1), SelectFocused(true), FocusedName_Defined(false) {} 230 }; 231 232 #ifdef UNDER_CE 233 #define MY_NMLISTVIEW_NMITEMACTIVATE NMLISTVIEW 234 #else 235 #define MY_NMLISTVIEW_NMITEMACTIVATE NMITEMACTIVATE 236 #endif 237 238 struct CCopyToOptions 239 { 240 bool streamMode; 241 bool moveMode; 242 bool testMode; 243 bool includeAltStreams; 244 bool replaceAltStreamChars; 245 bool showErrorMessages; 246 247 UString folder; 248 249 UStringVector hashMethods; 250 251 CVirtFileSystem *VirtFileSystemSpec; 252 ISequentialOutStream *VirtFileSystem; 253 CCopyToOptionsCCopyToOptions254 CCopyToOptions(): 255 streamMode(false), 256 moveMode(false), 257 testMode(false), 258 includeAltStreams(true), 259 replaceAltStreamChars(false), 260 showErrorMessages(false), 261 VirtFileSystemSpec(NULL), 262 VirtFileSystem(NULL) 263 {} 264 }; 265 266 267 268 struct COpenResult 269 { 270 // bool needOpenArc; 271 // out: 272 bool ArchiveIsOpened; 273 bool Encrypted; 274 UString ErrorMessage; 275 COpenResultCOpenResult276 COpenResult(): 277 // needOpenArc(false), 278 ArchiveIsOpened(false), Encrypted(false) {} 279 }; 280 281 282 283 284 class CPanel: public NWindows::NControl::CWindow2 285 { 286 CExtToIconMap _extToIconMap; 287 UINT _baseID; 288 int _comboBoxID; 289 UINT _statusBarID; 290 291 CAppState *_appState; 292 293 bool OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result); 294 LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam); 295 virtual bool OnCreate(CREATESTRUCT *createStruct); 296 virtual bool OnSize(WPARAM wParam, int xSize, int ySize); 297 virtual void OnDestroy(); 298 virtual bool OnNotify(UINT controlID, LPNMHDR lParam, LRESULT &result); 299 300 void AddComboBoxItem(const UString &name, int iconIndex, int indent, bool addToList); 301 302 bool OnComboBoxCommand(UINT code, LPARAM param, LRESULT &result); 303 304 #ifndef UNDER_CE 305 306 LRESULT OnNotifyComboBoxEnter(const UString &s); 307 bool OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result); 308 #ifndef _UNICODE 309 bool OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result); 310 #endif 311 312 #endif 313 314 bool OnNotifyReBar(LPNMHDR lParam, LRESULT &result); 315 bool OnNotifyComboBox(LPNMHDR lParam, LRESULT &result); 316 void OnItemChanged(NMLISTVIEW *item); 317 void OnNotifyActivateItems(); 318 bool OnNotifyList(LPNMHDR lParam, LRESULT &result); 319 void OnDrag(LPNMLISTVIEW nmListView); 320 bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result); 321 BOOL OnBeginLabelEdit(LV_DISPINFOW * lpnmh); 322 BOOL OnEndLabelEdit(LV_DISPINFOW * lpnmh); 323 void OnColumnClick(LPNMLISTVIEW info); 324 bool OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result); 325 326 327 public: 328 HWND _mainWindow; 329 CPanelCallback *_panelCallback; 330 SysIconsWereChanged()331 void SysIconsWereChanged() { _extToIconMap.Clear(); } 332 333 void DeleteItems(bool toRecycleBin); 334 void CreateFolder(); 335 void CreateFile(); 336 bool CorrectFsPath(const UString &path, UString &result); 337 // bool IsPathForPlugin(const UString &path); 338 339 private: 340 341 void ChangeWindowSize(int xSize, int ySize); 342 343 HRESULT InitColumns(); 344 void DeleteColumn(unsigned index); 345 void AddColumn(const CPropColumn &prop); 346 347 void SetFocusedSelectedItem(int index, bool select); 348 349 void OnShiftSelectMessage(); 350 void OnArrowWithShift(); 351 352 void OnInsert(); 353 // void OnUpWithShift(); 354 // void OnDownWithShift(); 355 public: 356 void UpdateSelection(); 357 void SelectSpec(bool selectMode); 358 void SelectByType(bool selectMode); 359 void SelectAll(bool selectMode); 360 void InvertSelection(); 361 private: 362 363 // UString GetFileType(UInt32 index); 364 LRESULT SetItemText(LVITEMW &item); 365 366 // CRecordVector<PROPID> m_ColumnsPropIDs; 367 368 public: 369 NWindows::NControl::CReBar _headerReBar; 370 NWindows::NControl::CToolBar _headerToolBar; 371 NWindows::NControl:: 372 #ifdef UNDER_CE 373 CComboBox 374 #else 375 CComboBoxEx 376 #endif 377 _headerComboBox; 378 UStringVector ComboBoxPaths; 379 // CMyComboBox _headerComboBox; 380 CMyComboBoxEdit _comboBoxEdit; 381 CMyListView _listView; 382 bool _thereAre_ListView_Items; 383 NWindows::NControl::CStatusBar _statusBar; 384 bool _lastFocusedIsList; 385 // NWindows::NControl::CStatusBar _statusBar2; 386 387 DWORD _exStyle; 388 bool _showDots; 389 bool _showRealFileIcons; 390 // bool _virtualMode; 391 // CUIntVector _realIndices; 392 bool _enableItemChangeNotify; 393 bool _mySelectMode; 394 395 int _timestampLevel; 396 397 RedrawListItems()398 void RedrawListItems() 399 { 400 _listView.RedrawAllItems(); 401 } 402 403 404 CBoolVector _selectedStatusVector; 405 406 CSelectedState _selectedState; 407 bool _thereAreDeletedItems; 408 bool _markDeletedItems; 409 410 bool PanelCreated; 411 DeleteListItems()412 void DeleteListItems() 413 { 414 if (_thereAre_ListView_Items) 415 { 416 bool b = _enableItemChangeNotify; 417 _enableItemChangeNotify = false; 418 _listView.DeleteAllItems(); 419 _thereAre_ListView_Items = false; 420 _enableItemChangeNotify = b; 421 } 422 } 423 424 HWND GetParent() const; 425 GetRealIndex(const LVITEMW & item)426 UInt32 GetRealIndex(const LVITEMW &item) const 427 { 428 /* 429 if (_virtualMode) 430 return _realIndices[item.iItem]; 431 */ 432 return (UInt32)item.lParam; 433 } 434 GetRealItemIndex(int indexInListView)435 int GetRealItemIndex(int indexInListView) const 436 { 437 /* 438 if (_virtualMode) 439 return indexInListView; 440 */ 441 LPARAM param; 442 if (!_listView.GetItemParam(indexInListView, param)) 443 throw 1; 444 return (int)param; 445 } 446 447 UInt32 _ListViewMode; 448 int _xSize; 449 450 bool _flatMode; 451 bool _flatModeForDisk; 452 bool _flatModeForArc; 453 454 // bool _showNtfsStrems_Mode; 455 // bool _showNtfsStrems_ModeForDisk; 456 // bool _showNtfsStrems_ModeForArc; 457 458 bool _dontShowMode; 459 460 461 UString _currentFolderPrefix; 462 463 CObjectVector<CFolderLink> _parentFolders; 464 NWindows::NDLL::CLibrary _library; 465 466 CMyComPtr<IFolderFolder> _folder; 467 CMyComPtr<IFolderCompare> _folderCompare; 468 CMyComPtr<IFolderGetItemName> _folderGetItemName; 469 CMyComPtr<IArchiveGetRawProps> _folderRawProps; 470 CMyComPtr<IFolderAltStreams> _folderAltStreams; 471 CMyComPtr<IFolderOperations> _folderOperations; 472 473 void ReleaseFolder(); 474 void SetNewFolder(IFolderFolder *newFolder); 475 476 // CMyComPtr<IFolderGetSystemIconIndex> _folderGetSystemIconIndex; 477 478 UStringVector _fastFolders; 479 480 void GetSelectedNames(UStringVector &selectedNames); 481 void SaveSelectedState(CSelectedState &s); 482 HRESULT RefreshListCtrl(const CSelectedState &s); 483 HRESULT RefreshListCtrl_SaveFocused(); 484 485 bool GetItem_BoolProp(UInt32 itemIndex, PROPID propID) const; 486 bool IsItem_Deleted(int itemIndex) const; 487 bool IsItem_Folder(int itemIndex) const; 488 bool IsItem_AltStream(int itemIndex) const; 489 490 UString GetItemName(int itemIndex) const; 491 UString GetItemName_for_Copy(int itemIndex) const; 492 void GetItemName(int itemIndex, UString &s) const; 493 UString GetItemPrefix(int itemIndex) const; 494 UString GetItemRelPath(int itemIndex) const; 495 UString GetItemRelPath2(int itemIndex) const; 496 UString GetItemFullPath(int itemIndex) const; 497 UInt64 GetItem_UInt64Prop(int itemIndex, PROPID propID) const; 498 UInt64 GetItemSize(int itemIndex) const; 499 500 //////////////////////// 501 // PanelFolderChange.cpp 502 503 void SetToRootFolder(); 504 HRESULT BindToPath(const UString &fullPath, const UString &arcFormat, COpenResult &openRes); // can be prefix 505 HRESULT BindToPathAndRefresh(const UString &path); 506 void OpenDrivesFolder(); 507 508 void SetBookmark(unsigned index); 509 void OpenBookmark(unsigned index); 510 511 void LoadFullPath(); 512 void LoadFullPathAndShow(); 513 void FoldersHistory(); 514 void OpenParentFolder(); 515 void CloseOneLevel(); 516 void CloseOpenFolders(); 517 void OpenRootFolder(); 518 519 UString GetParentDirPrefix() const; 520 521 HRESULT Create(HWND mainWindow, HWND parentWindow, 522 UINT id, 523 const UString ¤tFolderPrefix, 524 const UString &arcFormat, 525 CPanelCallback *panelCallback, 526 CAppState *appState, 527 bool needOpenArc, 528 COpenResult &openRes); 529 530 void SetFocusToList(); 531 void SetFocusToLastRememberedItem(); 532 533 534 void SaveListViewInfo(); 535 CPanel()536 CPanel() : 537 _thereAre_ListView_Items(false), 538 _exStyle(0), 539 _showDots(false), 540 _showRealFileIcons(false), 541 // _virtualMode(flase), 542 _enableItemChangeNotify(true), 543 _mySelectMode(false), 544 _timestampLevel(kTimestampPrintLevel_MIN), 545 546 _thereAreDeletedItems(false), 547 _markDeletedItems(true), 548 PanelCreated(false), 549 550 _ListViewMode(3), 551 _xSize(300), 552 553 _flatMode(false), 554 _flatModeForDisk(false), 555 _flatModeForArc(false), 556 557 // _showNtfsStrems_Mode(false), 558 // _showNtfsStrems_ModeForDisk(false), 559 // _showNtfsStrems_ModeForArc(false), 560 561 _dontShowMode(false), 562 563 _needSaveInfo(false), 564 _startGroupSelect(0), 565 _selectionIsDefined(false) 566 {} 567 SetExtendedStyle()568 void SetExtendedStyle() 569 { 570 if (_listView != 0) 571 _listView.SetExtendedListViewStyle(_exStyle); 572 } 573 574 575 bool _needSaveInfo; 576 UString _typeIDString; 577 CListViewInfo _listViewInfo; 578 579 CPropColumns _columns; 580 CPropColumns _visibleColumns; 581 582 PROPID _sortID; 583 // int _sortIndex; 584 bool _ascending; 585 Int32 _isRawSortProp; 586 587 void SetSortRawStatus(); 588 589 void Release(); 590 ~CPanel(); 591 void OnLeftClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate); 592 bool OnRightClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate, LRESULT &result); 593 void ShowColumnsContextMenu(int x, int y); 594 595 void OnTimer(); 596 void OnReload(); 597 bool OnContextMenu(HANDLE windowHandle, int xPos, int yPos); 598 599 CMyComPtr<IContextMenu> _sevenZipContextMenu; 600 CMyComPtr<IContextMenu> _systemContextMenu; 601 HRESULT CreateShellContextMenu( 602 const CRecordVector<UInt32> &operatedIndices, 603 CMyComPtr<IContextMenu> &systemContextMenu); 604 void CreateSystemMenu(HMENU menu, 605 const CRecordVector<UInt32> &operatedIndices, 606 CMyComPtr<IContextMenu> &systemContextMenu); 607 void CreateSevenZipMenu(HMENU menu, 608 const CRecordVector<UInt32> &operatedIndices, 609 CMyComPtr<IContextMenu> &sevenZipContextMenu); 610 void CreateFileMenu(HMENU menu, 611 CMyComPtr<IContextMenu> &sevenZipContextMenu, 612 CMyComPtr<IContextMenu> &systemContextMenu, 613 bool programMenu); 614 void CreateFileMenu(HMENU menu); 615 bool InvokePluginCommand(unsigned id); 616 bool InvokePluginCommand(unsigned id, IContextMenu *sevenZipContextMenu, 617 IContextMenu *systemContextMenu); 618 619 void InvokeSystemCommand(const char *command); 620 void Properties(); 621 void EditCut(); 622 void EditCopy(); 623 void EditPaste(); 624 625 int _startGroupSelect; 626 627 bool _selectionIsDefined; 628 bool _selectMark; 629 int _prevFocusedItem; 630 631 632 // void SortItems(int index); 633 void SortItemsWithPropID(PROPID propID); 634 635 void GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const; 636 void GetOperatedItemIndices(CRecordVector<UInt32> &indices) const; 637 void GetAllItemIndices(CRecordVector<UInt32> &indices) const; 638 void GetOperatedIndicesSmart(CRecordVector<UInt32> &indices) const; 639 // void GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const; 640 void KillSelection(); 641 642 UString GetFolderTypeID() const; 643 644 bool IsFolderTypeEqTo(const char *s) const; 645 bool IsRootFolder() const; 646 bool IsFSFolder() const; 647 bool IsFSDrivesFolder() const; 648 bool IsAltStreamsFolder() const; 649 bool IsArcFolder() const; 650 bool IsHashFolder() const; 651 652 /* 653 c:\Dir 654 Computer\ 655 \\?\ 656 \\.\ 657 */ Is_IO_FS_Folder()658 bool Is_IO_FS_Folder() const 659 { 660 return IsFSFolder() || IsFSDrivesFolder() || IsAltStreamsFolder(); 661 } 662 Is_Slow_Icon_Folder()663 bool Is_Slow_Icon_Folder() const 664 { 665 return IsFSFolder() || IsAltStreamsFolder(); 666 } 667 668 // bool IsFsOrDrivesFolder() const { return IsFSFolder() || IsFSDrivesFolder(); } IsDeviceDrivesPrefix()669 bool IsDeviceDrivesPrefix() const { return _currentFolderPrefix == L"\\\\.\\"; } IsSuperDrivesPrefix()670 bool IsSuperDrivesPrefix() const { return _currentFolderPrefix == L"\\\\?\\"; } 671 672 /* 673 c:\Dir 674 Computer\ 675 \\?\ 676 */ IsFsOrPureDrivesFolder()677 bool IsFsOrPureDrivesFolder() const { return IsFSFolder() || (IsFSDrivesFolder() && !IsDeviceDrivesPrefix()); } 678 679 /* 680 c:\Dir 681 Computer\ 682 \\?\ 683 \\SERVER\ 684 */ IsFolder_with_FsItems()685 bool IsFolder_with_FsItems() const 686 { 687 if (IsFsOrPureDrivesFolder()) 688 return true; 689 #if defined(_WIN32) && !defined(UNDER_CE) 690 FString prefix = us2fs(GetFsPath()); 691 return (prefix.Len() == NWindows::NFile::NName::GetNetworkServerPrefixSize(prefix)); 692 #else 693 return false; 694 #endif 695 } 696 697 UString GetFsPath() const; 698 UString GetDriveOrNetworkPrefix() const; 699 DoesItSupportOperations()700 bool DoesItSupportOperations() const { return _folderOperations != NULL; } 701 bool IsThereReadOnlyFolder() const; 702 bool CheckBeforeUpdate(UINT resourceID); 703 704 bool _processTimer; 705 bool _processNotify; 706 bool _processStatusBar; 707 708 class CDisableTimerProcessing 709 { 710 CLASS_NO_COPY(CDisableTimerProcessing); 711 712 bool _processTimer; 713 714 CPanel &_panel; 715 716 public: 717 CDisableTimerProcessing(CPanel & panel)718 CDisableTimerProcessing(CPanel &panel): _panel(panel) { Disable(); } ~CDisableTimerProcessing()719 ~CDisableTimerProcessing() { Restore(); } Disable()720 void Disable() 721 { 722 _processTimer = _panel._processTimer; 723 _panel._processTimer = false; 724 } Restore()725 void Restore() 726 { 727 _panel._processTimer = _processTimer; 728 } 729 }; 730 731 class CDisableNotify 732 { 733 CLASS_NO_COPY(CDisableNotify); 734 735 bool _processNotify; 736 bool _processStatusBar; 737 738 CPanel &_panel; 739 740 public: 741 CDisableNotify(CPanel & panel)742 CDisableNotify(CPanel &panel): _panel(panel) { Disable(); } ~CDisableNotify()743 ~CDisableNotify() { Restore(); } Disable()744 void Disable() 745 { 746 _processNotify = _panel._processNotify; 747 _processStatusBar = _panel._processStatusBar; 748 _panel._processNotify = false; 749 _panel._processStatusBar = false; 750 } SetMemMode_Enable()751 void SetMemMode_Enable() 752 { 753 _processNotify = true; 754 _processStatusBar = true; 755 } Restore()756 void Restore() 757 { 758 _panel._processNotify = _processNotify; 759 _panel._processStatusBar = _processStatusBar; 760 } 761 }; 762 InvalidateList()763 void InvalidateList() { _listView.InvalidateRect(NULL, true); } 764 765 HRESULT RefreshListCtrl(); 766 767 768 // void MessageBox_Info(LPCWSTR message, LPCWSTR caption) const; 769 // void MessageBox_Warning(LPCWSTR message) const; 770 void MessageBox_Error_Caption(LPCWSTR message, LPCWSTR caption) const; 771 void MessageBox_Error(LPCWSTR message) const; 772 void MessageBox_Error_HRESULT_Caption(HRESULT errorCode, LPCWSTR caption) const; 773 void MessageBox_Error_HRESULT(HRESULT errorCode) const; 774 void MessageBox_Error_2Lines_Message_HRESULT(LPCWSTR message, HRESULT errorCode) const; 775 void MessageBox_LastError(LPCWSTR caption) const; 776 void MessageBox_LastError() const; 777 void MessageBox_Error_LangID(UINT resourceID) const; 778 void MessageBox_Error_UnsupportOperation() const; 779 // void MessageBoxErrorForUpdate(HRESULT errorCode, UINT resourceID); 780 781 782 void OpenAltStreams(); 783 784 void OpenFocusedItemAsInternal(const wchar_t *type = NULL); 785 void OpenSelectedItems(bool internal); 786 787 void OpenFolderExternal(int index); 788 789 void OpenFolder(int index); 790 HRESULT OpenParentArchiveFolder(); 791 792 HRESULT OpenAsArc(IInStream *inStream, 793 const CTempFileInfo &tempFileInfo, 794 const UString &virtualFilePath, 795 const UString &arcFormat, 796 COpenResult &openRes); 797 798 HRESULT OpenAsArc_Msg(IInStream *inStream, 799 const CTempFileInfo &tempFileInfo, 800 const UString &virtualFilePath, 801 const UString &arcFormat 802 // , bool showErrorMessage 803 ); 804 805 HRESULT OpenAsArc_Name(const UString &relPath, const UString &arcFormat 806 // , bool showErrorMessage 807 ); 808 HRESULT OpenAsArc_Index(int index, const wchar_t *type /* = NULL */ 809 // , bool showErrorMessage 810 ); 811 812 void OpenItemInArchive(int index, bool tryInternal, bool tryExternal, 813 bool editMode, bool useEditor, const wchar_t *type = NULL); 814 815 HRESULT OnOpenItemChanged(UInt32 index, const wchar_t *fullFilePath, bool usePassword, const UString &password); 816 LRESULT OnOpenItemChanged(LPARAM lParam); 817 818 bool IsVirus_Message(const UString &name); 819 void OpenItem(int index, bool tryInternal, bool tryExternal, const wchar_t *type = NULL); 820 void EditItem(bool useEditor); 821 void EditItem(int index, bool useEditor); 822 823 void RenameFile(); 824 void ChangeComment(); 825 826 void SetListViewMode(UInt32 index); GetListViewMode()827 UInt32 GetListViewMode() const { return _ListViewMode; } GetSortID()828 PROPID GetSortID() const { return _sortID; } 829 830 void ChangeFlatMode(); 831 void Change_ShowNtfsStrems_Mode(); GetFlatMode()832 bool GetFlatMode() const { return _flatMode; } 833 // bool Get_ShowNtfsStrems_Mode() const { return _showNtfsStrems_Mode; } 834 835 bool AutoRefresh_Mode; Set_AutoRefresh_Mode(bool mode)836 void Set_AutoRefresh_Mode(bool mode) 837 { 838 AutoRefresh_Mode = mode; 839 } 840 841 void Post_Refresh_StatusBar(); 842 void Refresh_StatusBar(); 843 844 void AddToArchive(); 845 846 void GetFilePaths(const CRecordVector<UInt32> &indices, UStringVector &paths, bool allowFolders = false); 847 void ExtractArchives(); 848 void TestArchives(); 849 850 HRESULT CopyTo(CCopyToOptions &options, 851 const CRecordVector<UInt32> &indices, 852 UStringVector *messages, 853 bool &usePassword, UString &password); 854 CopyTo(CCopyToOptions & options,const CRecordVector<UInt32> & indices,UStringVector * messages)855 HRESULT CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &indices, UStringVector *messages) 856 { 857 bool usePassword = false; 858 UString password; 859 if (_parentFolders.Size() > 0) 860 { 861 const CFolderLink &fl = _parentFolders.Back(); 862 usePassword = fl.UsePassword; 863 password = fl.Password; 864 } 865 return CopyTo(options, indices, messages, usePassword, password); 866 } 867 868 HRESULT CopyFrom(bool moveMode, const UString &folderPrefix, const UStringVector &filePaths, 869 bool showErrorMessages, UStringVector *messages); 870 871 void CopyFromNoAsk(const UStringVector &filePaths); 872 void CopyFromAsk(const UStringVector &filePaths); 873 874 // empty folderPath means create new Archive to path of first fileName. 875 void DropObject(IDataObject * dataObject, const UString &folderPath); 876 877 // empty folderPath means create new Archive to path of first fileName. 878 void CompressDropFiles(const UStringVector &fileNames, const UString &folderPath); 879 880 void RefreshTitle(bool always = false) { _panelCallback->RefreshTitle(always); } RefreshTitleAlways()881 void RefreshTitleAlways() { RefreshTitle(true); } 882 883 UString GetItemsInfoString(const CRecordVector<UInt32> &indices); 884 }; 885 886 class CMyBuffer 887 { 888 void *_data; 889 public: CMyBuffer()890 CMyBuffer(): _data(0) {} 891 operator void *() { return _data; } Allocate(size_t size)892 bool Allocate(size_t size) 893 { 894 if (_data != 0) 895 return false; 896 _data = ::MidAlloc(size); 897 return _data != 0; 898 } ~CMyBuffer()899 ~CMyBuffer() { ::MidFree(_data); } 900 }; 901 902 class CExitEventLauncher 903 { 904 public: 905 NWindows::NSynchronization::CManualResetEvent _exitEvent; 906 bool _needExit; 907 CRecordVector< ::CThread > _threads; 908 unsigned _numActiveThreads; 909 CExitEventLauncher()910 CExitEventLauncher() 911 { 912 _needExit = false; 913 if (_exitEvent.Create(false) != S_OK) 914 throw 9387173; 915 _needExit = true; 916 _numActiveThreads = 0; 917 }; 918 ~CExitEventLauncher()919 ~CExitEventLauncher() { Exit(true); } 920 921 void Exit(bool hardExit); 922 }; 923 924 extern CExitEventLauncher g_ExitEventLauncher; 925 926 #endif 927