other-licenses/7zstub/src/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 // ProgressDialog.h
michael@0 2
michael@0 3 #ifndef __PROGRESSDIALOG_H
michael@0 4 #define __PROGRESSDIALOG_H
michael@0 5
michael@0 6 #include "resource.h"
michael@0 7
michael@0 8 #include "Windows/Control/Dialog.h"
michael@0 9 #include "Windows/Control/ProgressBar.h"
michael@0 10 #include "Windows/Synchronization.h"
michael@0 11
michael@0 12 class CProgressSynch
michael@0 13 {
michael@0 14 NWindows::NSynchronization::CCriticalSection _criticalSection;
michael@0 15 bool _stopped;
michael@0 16 bool _paused;
michael@0 17 UINT64 _total;
michael@0 18 UINT64 _completed;
michael@0 19 public:
michael@0 20 CProgressSynch(): _stopped(false), _paused(false), _total(1), _completed(0) {}
michael@0 21
michael@0 22 bool GetStopped()
michael@0 23 {
michael@0 24 NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
michael@0 25 return _stopped;
michael@0 26 }
michael@0 27 void SetStopped(bool value)
michael@0 28 {
michael@0 29 NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
michael@0 30 _stopped = value;
michael@0 31 }
michael@0 32 bool GetPaused()
michael@0 33 {
michael@0 34 NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
michael@0 35 return _paused;
michael@0 36 }
michael@0 37 void SetPaused(bool value)
michael@0 38 {
michael@0 39 NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
michael@0 40 _paused = value;
michael@0 41 }
michael@0 42 void SetProgress(UINT64 total, UINT64 completed)
michael@0 43 {
michael@0 44 NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
michael@0 45 _total = total;
michael@0 46 _completed = completed;
michael@0 47 }
michael@0 48 void SetPos(UINT64 completed)
michael@0 49 {
michael@0 50 NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
michael@0 51 _completed = completed;
michael@0 52 }
michael@0 53 void GetProgress(UINT64 &total, UINT64 &completed)
michael@0 54 {
michael@0 55 NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
michael@0 56 total = _total;
michael@0 57 completed = _completed;
michael@0 58 }
michael@0 59 };
michael@0 60
michael@0 61 class CU64ToI32Converter
michael@0 62 {
michael@0 63 UINT64 _numShiftBits;
michael@0 64 public:
michael@0 65 void Init(UINT64 _range);
michael@0 66 int Count(UINT64 aValue);
michael@0 67 };
michael@0 68
michael@0 69 // class CProgressDialog: public NWindows::NControl::CModelessDialog
michael@0 70
michael@0 71 class CProgressDialog: public NWindows::NControl::CModalDialog
michael@0 72 {
michael@0 73 private:
michael@0 74 UINT_PTR _timer;
michael@0 75
michael@0 76 UString _title;
michael@0 77 CU64ToI32Converter _converter;
michael@0 78 UINT64 _peviousPos;
michael@0 79 UINT64 _range;
michael@0 80 NWindows::NControl::CProgressBar m_ProgressBar;
michael@0 81
michael@0 82 int _prevPercentValue;
michael@0 83
michael@0 84 bool OnTimer(WPARAM timerID, LPARAM callback);
michael@0 85 void SetRange(UINT64 range);
michael@0 86 void SetPos(UINT64 pos);
michael@0 87 virtual bool OnInit();
michael@0 88 virtual void OnCancel();
michael@0 89 NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent;
michael@0 90 #ifndef _SFX
michael@0 91 void AddToTitle(LPCWSTR string);
michael@0 92 #endif
michael@0 93 bool OnButtonClicked(int buttonID, HWND buttonHWND);
michael@0 94 public:
michael@0 95 CProgressSynch ProgressSynch;
michael@0 96
michael@0 97 #ifndef _SFX
michael@0 98 HWND MainWindow;
michael@0 99 UString MainTitle;
michael@0 100 UString MainAddTitle;
michael@0 101 ~CProgressDialog();
michael@0 102 #endif
michael@0 103
michael@0 104 CProgressDialog(): _timer(0)
michael@0 105 #ifndef _SFX
michael@0 106 ,MainWindow(0)
michael@0 107 #endif
michael@0 108 {}
michael@0 109
michael@0 110 void WaitCreating() { _dialogCreatedEvent.Lock(); }
michael@0 111
michael@0 112
michael@0 113 INT_PTR Create(const UString &title, HWND wndParent = 0)
michael@0 114 {
michael@0 115 _title = title;
michael@0 116 return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent);
michael@0 117 }
michael@0 118
michael@0 119 static const UINT kCloseMessage;
michael@0 120
michael@0 121 virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
michael@0 122
michael@0 123 void MyClose()
michael@0 124 {
michael@0 125 PostMessage(kCloseMessage);
michael@0 126 };
michael@0 127 };
michael@0 128
michael@0 129 #endif

mercurial