|
|
1.1.1.10! root 1: /* ! 2: Legal Notice: The source code contained in this file has been derived from ! 3: the source code of Encryption for the Masses 2.02a, which is Copyright (c) ! 4: Paul Le Roux and which is covered by the 'License Agreement for Encryption ! 5: for the Masses'. Modifications and additions to that source code contained ! 6: in this file are Copyright (c) TrueCrypt Foundation and are covered by the ! 7: TrueCrypt License 2.2 the full text of which is contained in the file ! 8: License.txt included in TrueCrypt binary and source code distribution ! 9: packages. */ 1.1.1.6 root 10: 11: #include "Tcdefs.h" 12: #include "Language.h" 13: #include "Dlgcode.h" 14: #include "Progress.h" 1.1.1.10! root 15: #include "../Format/FormatCom.h" ! 16: #include "../Format/resource.h" 1.1 root 17: 18: extern HWND hCurPage; 19: extern HWND hProgressBar; 20: extern BOOL bThreadCancel; 21: extern int nPbar; 22: 1.1.1.3 root 23: ULONG prevTime, startTime; 24: __int64 totalSectors; 1.1 root 25: 1.1.1.7 root 26: static wchar_t *seconds, *minutes, *hours, *days; 1.1.1.6 root 27: 1.1 root 28: void 1.1.1.3 root 29: InitProgressBar (__int64 totalSecs) 1.1 root 30: { 31: HWND hProgressBar = GetDlgItem (hCurPage, nPbar); 32: SendMessage (hProgressBar, PBM_SETRANGE32, 0, 10000); 33: SendMessage (hProgressBar, PBM_SETSTEP, 1, 0); 34: 1.1.1.7 root 35: seconds = GetString ("SECONDS"); 1.1.1.6 root 36: minutes = GetString ("MINUTES"); 37: hours = GetString ("HOURS"); 38: days = GetString ("DAYS"); 39: 1.1 root 40: prevTime = startTime = GetTickCount (); 41: totalSectors = totalSecs; 42: } 43: 1.1.1.10! root 44: 1.1 root 45: BOOL 1.1.1.3 root 46: UpdateProgressBar (__int64 nSecNo) 1.1 root 47: { 1.1.1.10! root 48: BOOL bThreadCancel; ! 49: ! 50: if (UacUpdateProgressBar (nSecNo, &bThreadCancel)) ! 51: return bThreadCancel; ! 52: ! 53: return UpdateProgressBarProc (nSecNo); ! 54: } ! 55: ! 56: ! 57: BOOL ! 58: UpdateProgressBarProc (__int64 nSecNo) ! 59: { 1.1.1.6 root 60: wchar_t text[100]; 61: wchar_t speed[100]; 1.1 root 62: HWND hProgressBar = GetDlgItem (hCurPage, nPbar); 63: int time = GetTickCount (); 64: int elapsed = (time - startTime) / 1000; 1.1.1.6 root 65: unsigned __int64 bytesDone = (nSecNo + 1) * SECTOR_SIZE; 66: unsigned __int64 bytesPerSec = bytesDone / (1 + elapsed); 1.1 root 67: 1.1.1.6 root 68: GetSizeString (bytesDone, text); 1.1.1.7 root 69: if (bytesDone < (unsigned __int64) BYTES_PER_MB * 1000000) 70: swprintf(text, L"%I64d %s ", bytesDone / BYTES_PER_MB, GetString ("MB")); 71: else if (bytesDone < (unsigned __int64) BYTES_PER_GB * 1000000) 72: swprintf(text, L"%I64d %s ", bytesDone / BYTES_PER_GB, GetString ("GB")); 73: else if (bytesDone < (unsigned __int64) BYTES_PER_TB * 1000000) 74: swprintf(text, L"%I64d %s ", bytesDone / BYTES_PER_TB, GetString ("TB")); 75: else 76: swprintf(text, L"%I64d %s ", bytesDone / BYTES_PER_PB, GetString ("PB")); 77: 1.1.1.6 root 78: SetWindowTextW (GetDlgItem (hCurPage, IDC_BYTESWRITTEN), text); 79: 80: GetSpeedString (bytesPerSec, speed); 81: wcscat (speed, L" "); 82: SetWindowTextW (GetDlgItem (hCurPage, IDC_WRITESPEED), speed); 1.1 root 83: 84: if (nSecNo < totalSectors) 85: { 1.1.1.6 root 86: int sec = (int)((totalSectors - nSecNo) / ((nSecNo + 1)/(elapsed + 1) + 1)); 1.1.1.3 root 87: 1.1.1.6 root 88: if (sec >= 60 * 60 * 24 * 2) 89: swprintf (text, L"%d %s ", sec / (60 * 24 * 60), days); 1.1.1.4 root 90: else if (sec >= 120 * 60) 1.1.1.6 root 91: swprintf (text, L"%d %s ", sec / (60 * 60), hours); 1.1.1.4 root 92: else if (sec >= 120) 1.1.1.6 root 93: swprintf (text, L"%d %s ", sec / 60, minutes); 1.1.1.3 root 94: else 1.1.1.7 root 95: swprintf (text, L"%d %s ", sec, seconds); 1.1.1.3 root 96: 1.1.1.6 root 97: SetWindowTextW (GetDlgItem (hCurPage, IDC_TIMEREMAIN), text); 1.1 root 98: } 99: 100: prevTime = time; 101: 102: SendMessage (hProgressBar, PBM_SETPOS, (int) (10000.0 * nSecNo / totalSectors), 0); 103: 104: return bThreadCancel; 105: } 1.1.1.7 root 106: 107:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.