00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
#include <wx/wxprec.h>
00029
00030
#ifdef __BORLANDC__
00031
#pragma hdrstop
00032
#endif
00033
00034
#ifndef WX_PRECOMP
00035
00036
#include <wx/wx.h>
00037
#endif
00038
00039
#include <wx/config.h>
00040
#include <wx/datetime.h>
00041
#include <wx/file.h>
00042
#include <wx/filename.h>
00043
00044
#include <climits>
00045
00046
#include "dlgMultiCheck.hpp"
00047
#include "appprefs.hpp"
00048
#include "bytedisp.hpp"
00049
#include "checksum.hpp"
00050
#include "checksumutil.hpp"
00051
#include "comdefs.hpp"
00052
#include "fileutil.hpp"
00053
#include "osdep.hpp"
00054
#include "sumfile.hpp"
00055
#include "utils.hpp"
00056
00057
#include "compat.hpp"
00058
00059
00060
00061
00062
using namespace std;
00063
00064
00065 IMPLEMENT_DYNAMIC_CLASS(
dlgMultiCheck,
dlgResultsProgress)
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 class
dlgMultiCheck::
FilesStatistics
00076 {
00077
public:
00078 int CKTotallyCorrect;
00079 int CKPartiallyCorrect;
00080 int CKFullyIncorrect;
00081 int CKInvalid;
00082 int CKNotOpened;
00083
00084 int FCorrect;
00085 int FIncorrect;
00086 int FNotFound;
00087 int FNotOpened;
00088
00089
00090 FilesStatistics()
00091 {
00092 CKTotallyCorrect = 0;
00093 CKPartiallyCorrect = 0;
00094 CKFullyIncorrect = 0;
00095 CKInvalid = 0;
00096 CKNotOpened = 0;
00097
00098 resetCkFiles();
00099 }
00100
00101
00102 void resetCkFiles()
00103 {
00104 FCorrect = 0;
00105 FIncorrect = 0;
00106 FNotFound = 0;
00107 FNotOpened = 0;
00108 }
00109
00110
00111 int getCheckedFilesCount()
const
00112
{
00113
return FCorrect + FIncorrect + FNotFound + FNotOpened;
00114 }
00115
00116
00117 int getChecksumsFilesChecked()
const
00118
{
00119
return CKTotallyCorrect + CKPartiallyCorrect + CKFullyIncorrect + CKInvalid + CKNotOpened;
00120 }
00121
00122
00123 bool allAreCorrects()
const
00124
{
00125
return FIncorrect == 0 && FNotFound == 0 && FNotOpened == 0;
00126 }
00127
00128
00129 bool allChecksumsFilesAreCorrects()
const
00130
{
00131
return CKPartiallyCorrect == 0 && CKFullyIncorrect == 0 && CKInvalid == 0 && CKNotOpened == 0;
00132 }
00133 };
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 class dlgMultiCheck::ChecksumProgress :
public ::
ChecksumProgress
00146 {
00147
protected:
00148 BytesDisplayer current;
00149 wxTimeSpan
timeSpan;
00150 wxDateTime
lt;
00151 wxDateTime
ct;
00152 dlgMultiCheck*
progress;
00153
00154
00155 ChecksumProgress() {
init(); };
00156
00157
00158
void init();
00159
00160
public:
00161
00162
ChecksumProgress(
dlgMultiCheck* progressDlg,
const BytesDisplayer& total);
00163
00164
00165
virtual void update(size_t read,
bool& canceled);
00166
00167
00168
void finished();
00169 };
00170
00171
00172
00173
00174
00175
00176 void dlgMultiCheck::ChecksumProgress::init()
00177 {
00178
progress = NULL;
00179 }
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 dlgMultiCheck::ChecksumProgress::ChecksumProgress(
dlgMultiCheck* progressDlg,
const BytesDisplayer& total)
00190 {
00191
init();
00192
00193
timeSpan = wxTimeSpan(0, 0, 0,
UPDATE_PROGRESS_DLG);
00194
lt = wxDateTime::UNow() -
timeSpan;
00195
progress = progressDlg;
00196
00197
00198
progress->
setReadBytes(
current);
00199
progress->
setTotalBytes(total);
00200 }
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212 void dlgMultiCheck::ChecksumProgress::update(size_t read,
bool& canceled)
00213 {
00214
current += static_cast<unsigned long>(read);
00215
ct = wxDateTime::UNow();
00216
if (
ct.IsLaterThan(
lt))
00217 {
00218
progress->
setReadBytes(
current);
00219 ::wxYield();
00220
lt =
ct +
timeSpan;
00221 }
00222
00223
00224
while (
progress->
getState() == dlgMultiCheck::paused)
00225 ::wxYield();
00226
00227
00228
if (
progress->
getState() == dlgMultiCheck::canceled)
00229 canceled =
true;
00230 }
00231
00232
00233
00234
00235
00236
00237 void dlgMultiCheck::ChecksumProgress::finished()
00238 {
00239
progress->
setReadBytes(
current);
00240 ::wxYield();
00241 }
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252 #define GAUGE_MAX SHRT_MAX
00253
00254
00255 #define DGAUGE_MAX static_cast<double>(GAUGE_MAX)
00256
00257
00258
00259
00260
00261
00262 dlgMultiCheck::dlgMultiCheck() :
dlgResultsProgress()
00263 {
00264 winDisabler = NULL;
00265
createControls();
00266 }
00267
00268
00269
00270
00271
00272
00273
00274
00275 dlgMultiCheck::dlgMultiCheck(wxWindow* parent) :
00276
dlgResultsProgress(parent, -1, _("Check multiple checksums' files"),
00277 wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
00278 {
00279
createControls();
00280 Fit();
00281
00282
00283 wxSize s =
AppPrefs::get()->
readSize(prMC_WINDOW_SIZE);
00284
if (s.GetWidth() == -1 || s.GetHeight() == -1)
00285 {
00286
if (GetParent() != NULL)
00287 SetSize(GetParent()->GetSize());
00288 }
00289
else
00290 SetSize(s);
00291 Centre();
00292
00293 Show(
true);
00294 Enable(
true);
00295 ::wxYield();
00296
#ifdef __WXMAC__
00297
MacUpdateImmediately();
00298
#endif
00299
}
00300
00301
00302
00303
00304
00305
00306 void dlgMultiCheck::createControls()
00307 {
00308
00309 wxClientDC dc(txtResults);
00310 wxSize labelSize(dc.GetCharWidth() * 20, -1);
00311
00312 wxStaticText* lblCurTotal =
new wxStaticText(
this, -1, _(
"Checking:"));
00313
lblTotal =
new wxStaticText(
this, -1, wxEmptyString, wxDefaultPosition,
00314 labelSize, wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
00315
gauTotal =
new wxGauge(
this, -1, 0, wxDefaultPosition, wxSize(-1,
lblTotal->GetSize().GetHeight()),
00316 wxGA_HORIZONTAL | wxGA_SMOOTH);
00317
gauTotal->SetRange(
GAUGE_MAX);
00318 wxStaticText* lblCurChecksumFile =
new wxStaticText(
this, -1, _(
"In checksums' file:"));
00319
lblChecksumFile =
new wxStaticText(
this, -1, wxEmptyString, wxDefaultPosition,
00320 labelSize, wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
00321
gauChecksumFile =
new wxGauge(
this, -1, 0, wxDefaultPosition, wxSize(-1,
lblChecksumFile->GetSize().GetHeight()),
00322 wxGA_HORIZONTAL | wxGA_SMOOTH);
00323
gauChecksumFile->SetRange(
GAUGE_MAX);
00324 wxStaticText* lblCurFile =
new wxStaticText(
this, -1, _(
"Current file:"));
00325
lblFile =
new wxStaticText(
this, -1, wxEmptyString, wxDefaultPosition,
00326 labelSize, wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
00327
gauFile =
new wxGauge(
this, -1, 0, wxDefaultPosition, wxSize(-1,
lblFile->GetSize().GetHeight()),
00328 wxGA_HORIZONTAL | wxGA_SMOOTH);
00329
gauFile->SetRange(
GAUGE_MAX);
00330
00331
00332
00333
00334
00335 wxFlexGridSizer* progressSizer =
new wxFlexGridSizer(3,
CONTROL_SPACE / 2,
CONTROL_SPACE);
00336 infoSizer->Add(progressSizer, 0, wxTOP | wxGROW, 3 *
CONTROL_SPACE / 2);
00337 progressSizer->AddGrowableCol(2);
00338 progressSizer->Add(lblCurTotal, 0, wxALIGN_CENTER_VERTICAL);
00339 progressSizer->Add(
lblTotal, 0, wxALIGN_CENTER_VERTICAL);
00340 progressSizer->Add(
gauTotal, 1, wxALIGN_CENTER_VERTICAL | wxGROW);
00341 progressSizer->Add(lblCurChecksumFile, 0, wxALIGN_CENTER_VERTICAL);
00342 progressSizer->Add(
lblChecksumFile, 0, wxALIGN_CENTER_VERTICAL);
00343 progressSizer->Add(
gauChecksumFile, 1, wxALIGN_CENTER_VERTICAL | wxGROW);
00344 progressSizer->Add(lblCurFile, 0, wxALIGN_CENTER_VERTICAL);
00345 progressSizer->Add(
lblFile, 0, wxALIGN_CENTER_VERTICAL);
00346 progressSizer->Add(
gauFile, 1, wxALIGN_CENTER_VERTICAL | wxGROW);
00347
00348
00349 this->SetAutoLayout(
true);
00350 this->Layout();
00351
00352
00353
00354
00355
setFilesToCheck(0);
00356
setFilesInChecksumsFile(0);
00357
setTotalBytes(
BytesDisplayer(0UL));
00358 }
00359
00360
00361
00362
00363
00364
00365
00366
00367 void dlgMultiCheck::btnCancelClick(wxCommandEvent& event)
00368 {
00369
if (
getState() == finished)
00370 {
00371
00372
AppPrefs::get()->
write(prMC_WINDOW_SIZE, GetSize());
00373 }
00374
00375
00376 event.Skip();
00377 }
00378
00379
00380
00381
00382
00383
00384
00385
00386 unsigned long dlgMultiCheck::getFilesToCheck()
const
00387
{
00388
return filesToCheck;
00389 }
00390
00391
00392
00393
00394
00395
00396
00397
00398 void dlgMultiCheck::setFilesToCheck(
unsigned long nbTotalChecksumsFiles)
00399 {
00400
filesToCheck = nbTotalChecksumsFiles;
00401
if (
getFileToBeChecked() >
getFilesToCheck())
00402
setFileToBeChecked(
getFilesToCheck());
00403
00404
updateTotalChecksumsFiles();
00405 }
00406
00407
00408
00409
00410
00411
00412
00413
00414 unsigned long dlgMultiCheck::getFileToBeChecked()
const
00415
{
00416
return fileChecked;
00417 }
00418
00419
00420
00421
00422
00423
00424
00425
00426 void dlgMultiCheck::setFileToBeChecked(
unsigned long nbChecksumsFiles)
00427 {
00428
fileChecked = (
getFilesToCheck() >= nbChecksumsFiles) ? nbChecksumsFiles :
getFilesToCheck();
00429
updateTotalChecksumsFiles();
00430 }
00431
00432
00433
00434
00435
00436
00437
00438
00439 unsigned long dlgMultiCheck::getFilesInChecksumsFile()
const
00440
{
00441
return filesInChecksumsFile;
00442 }
00443
00444
00445
00446
00447
00448
00449
00450
00451 void dlgMultiCheck::setFilesInChecksumsFile(
unsigned long nbTotalInChecksumsFiles)
00452 {
00453
filesInChecksumsFile = nbTotalInChecksumsFiles;
00454
if (
getFileInChecksumsFile() >
getFilesInChecksumsFile())
00455
setFileInChecksumsFile(
getFilesInChecksumsFile());
00456
00457
updateFilesInChecksumsFiles();
00458 }
00459
00460
00461
00462
00463
00464
00465
00466
00467 unsigned long dlgMultiCheck::getFileInChecksumsFile()
const
00468
{
00469
return fileInChecksumsFile;
00470 }
00471
00472
00473
00474
00475
00476
00477
00478
00479 void dlgMultiCheck::setFileInChecksumsFile(
unsigned long nbInChecksumsFiles)
00480 {
00481
fileInChecksumsFile = (
getFilesInChecksumsFile() >= nbInChecksumsFiles) ? nbInChecksumsFiles :
getFilesInChecksumsFile();
00482
updateFilesInChecksumsFiles();
00483 }
00484
00485
00486
00487
00488
00489
00490
00491
00492 BytesDisplayer dlgMultiCheck::getTotalBytes()
const
00493
{
00494
return totalBytes;
00495 }
00496
00497
00498
00499
00500
00501
00502
00503
00504 void dlgMultiCheck::setTotalBytes(
const BytesDisplayer& bytes)
00505 {
00506
totalBytes = bytes;
00507
if (
getReadBytes().
toDouble() >
getTotalBytes().
toDouble())
00508
setReadBytes(
getTotalBytes());
00509
00510
updateCurrentCheckedFile();
00511 }
00512
00513
00514
00515
00516
00517
00518
00519
00520 BytesDisplayer dlgMultiCheck::getReadBytes()
const
00521
{
00522
return bytesRead;
00523 }
00524
00525
00526
00527
00528
00529
00530
00531
00532 void dlgMultiCheck::setReadBytes(
const BytesDisplayer& bytes)
00533 {
00534
bytesRead = (
getTotalBytes().
toDouble() >= bytes.
toDouble()) ? bytes :
getTotalBytes();
00535
updateCurrentCheckedFile();
00536 }
00537
00538
00539
00540
00541
00542
00543 void dlgMultiCheck::updateTotalChecksumsFiles()
00544 {
00545
lblTotal->SetLabel(wxString::Format(_(
"%d/%d"),
getFileToBeChecked(),
getFilesToCheck()));
00546
double gauTotalValue = (
getFileToBeChecked() > 0) ? static_cast<double>(
getFileToBeChecked() - 1) : 0.0;
00547
00548
if (
getFilesToCheck() > 0)
00549
gauTotal->SetValue(static_cast<int>(gauTotalValue *
DGAUGE_MAX / static_cast<double>(
getFilesToCheck())));
00550
else
00551
gauTotal->SetValue(0);
00552
00553
00554
refreshDialog();
00555 }
00556
00557
00558
00559
00560
00561
00562 void dlgMultiCheck::updateFilesInChecksumsFiles()
00563 {
00564
lblChecksumFile->SetLabel(wxString::Format(_(
"%d/%d"),
getFileInChecksumsFile(),
getFilesInChecksumsFile()));
00565
double gauChecksumFileValue = (
getFileInChecksumsFile() > 0) ? static_cast<double>(
getFileInChecksumsFile() - 1) : 0.0;
00566
00567
if (
getFilesInChecksumsFile() > 0)
00568
gauChecksumFile->SetValue(static_cast<int>(gauChecksumFileValue *
DGAUGE_MAX / static_cast<double>(
getFilesInChecksumsFile())));
00569
else
00570
gauChecksumFile->SetValue(0);
00571
00572
00573
refreshDialog();
00574
00575 }
00576
00577
00578
00579
00580
00581
00582 void dlgMultiCheck::updateCurrentCheckedFile()
00583 {
00584
00585
lblFile->SetLabel(wxString::Format(_(
"%s/%s"),
getReadBytes().toString().c_str(),
getTotalBytes().toString().c_str()));
00586
00587
00588
double gauFileValue = (
getTotalBytes().
toDouble() > 0.0) ?
getReadBytes().
toDouble() /
getTotalBytes().
toDouble() : 0.0;
00589
00590
double gauChecksumFileValue = (
getFileInChecksumsFile() > 0) ? static_cast<double>(
getFileInChecksumsFile() - 1) : 0.0;
00591 gauChecksumFileValue += gauFileValue;
00592 gauChecksumFileValue = (
getFilesInChecksumsFile() > 0) ? gauChecksumFileValue / static_cast<double>(
getFilesInChecksumsFile()) : 0.0;
00593
00594
double gauTotalValue = (
getFileToBeChecked() > 0) ? static_cast<double>(
getFileToBeChecked() - 1) : 0.0;
00595 gauTotalValue += gauChecksumFileValue;
00596 gauTotalValue = (
getFilesToCheck() > 0) ? gauTotalValue / static_cast<double>(
getFilesToCheck()) : 0.0;
00597
00598
00599
int intFileValue = static_cast<int>(gauFileValue *
DGAUGE_MAX);
00600
int intChecksumFile = static_cast<int>(gauChecksumFileValue *
DGAUGE_MAX);
00601
int intTotal = static_cast<int>(gauTotalValue *
DGAUGE_MAX);
00602
00603
if (
gauFile->GetValue() != intFileValue)
00604
gauFile->SetValue(intFileValue);
00605
if (
gauChecksumFile->GetValue() != intChecksumFile)
00606
gauChecksumFile->SetValue(intChecksumFile);
00607
if (
gauTotal->GetValue() != intTotal)
00608
gauTotal->SetValue(intTotal);
00609
00610
00611
refreshDialog();
00612 }
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625 void dlgMultiCheck::checkFile(
const wxFileName& fileName,
Checksum* cc,
const wxString& checksum,
dlgMultiCheck& dlgPrg,
FilesStatistics& stats)
00626 {
00627
wxCOff_t fs;
00628
BytesDisplayer total;
00629 ChecksumFileCalculator::State retState;
00630
00631 fs =
wxCGetFileLength(fileName.GetFullPath());
00632 total = (fs == static_cast<wxCOff_t>(wxInvalidOffset)) ? 0.0 : static_cast<double>(fs);
00633
00634
ChecksumProgress progressUpdater(&dlgPrg, total);
00635
ChecksumFileCalculator cfc(cc, &progressUpdater);
00636
00637
00638 retState = cfc.
check(fileName.GetFullPath(), checksum);
00639
00640
00641 progressUpdater.
finished();
00642
00643
switch (retState)
00644 {
00645
case ChecksumFileCalculator::Ok :
00646 stats.
FCorrect++;
00647
if (
AppPrefs::get()->
readBool(prMC_FILE_STATE))
00648
if (
AppPrefs::get()->
readBool(prMC_NO_CORRECT_FILE_STATE))
00649 dlgPrg.
removeLastResultLine();
00650
else
00651 dlgPrg.
replaceLastResultLine(wxString::Format(_(
"'%s': OK\n"), fileName.GetFullPath().c_str()), 1U, getColour(prMC_SUCCESS_COLOUR));
00652
break;
00653
00654
case ChecksumFileCalculator::Invalid :
00655 stats.
FIncorrect++;
00656
if (
AppPrefs::get()->
readBool(prMC_FILE_STATE))
00657 dlgPrg.
replaceLastResultLine(wxString::Format(_(
"'%s': Checksums differ\n"), fileName.GetFullPath().c_str()), 1U, getColour(prMC_ERROR_COLOUR));
00658
break;
00659
00660
case ChecksumFileCalculator::ReadError :
00661 stats.
FNotFound++;
00662
if (
AppPrefs::get()->
readBool(prMC_FILE_STATE))
00663 dlgPrg.
replaceLastResultLine(wxString::Format(_(
"Error while reading '%s'.\n"), fileName.GetFullPath().c_str()), 1U, getColour(prMC_ERROR_COLOUR));
00664
break;
00665
00666
case ChecksumFileCalculator::FileNotFound :
00667 stats.
FNotFound++;
00668
if (
AppPrefs::get()->
readBool(prMC_FILE_STATE))
00669 dlgPrg.
replaceLastResultLine(wxString::Format(_(
"'%s': File not found\n"), fileName.GetFullPath().c_str()), 1U, getColour(prMC_ERROR_COLOUR));
00670
break;
00671
00672
case ChecksumFileCalculator::CantOpenFile :
00673 stats.
FNotOpened++;
00674
if (
AppPrefs::get()->
readBool(prMC_FILE_STATE))
00675 dlgPrg.
replaceLastResultLine(wxString::Format(_(
"'%s': File cannot be opened\n"), fileName.GetFullPath().c_str()), 1U, getColour(prMC_ERROR_COLOUR));
00676
break;
00677
00678
00679 }
00680 }
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690 void dlgMultiCheck::checkChecksumsFiles(
const wxArrayString& files, wxWindow* parent)
00691 {
00692
FilesStatistics fstats;
00693
dlgMultiCheck dlgPrg(parent);
00694
SumFile* sumFile;
00695 wxFile file;
00696 size_t i, j;
00697 wxString msg;
00698
00699
00700
00701
00702 wxColour colour;
00703
00704
00705 wxLogNull logNo;
00706
00707 dlgPrg.
setFilesToCheck(files.GetCount());
00708 i = 0;
00709
while (i < files.GetCount() && dlgPrg.
canContinue())
00710 {
00711
00712 dlgPrg.
addResultLine(wxString::Format(_(
"Checking '%s'.\n"), files[i].c_str()), 0U, getColour(prMC_NORMAL_COLOUR));
00713 dlgPrg.
setFileToBeChecked(i + 1);
00714
00715
00716
if (file.Open(files[i], wxFile::read))
00717 {
00718 file.Close();
00719 sumFile = ::openChecksumFile(files[i]);
00720
if (sumFile != NULL)
00721 {
00722
00723 wxFileName sumFileName(sumFile->
getFileName());
00724
00725
00726 dlgPrg.
setFilesInChecksumsFile(sumFile->
getChecksumDataCount());
00727
00728
00729
Checksum* cc = sumFile->
getChecksumCalculator();
00730
00731
00732 fstats.
resetCkFiles();
00733 j = 1;
00734 MChecksumData::const_iterator it = sumFile->
getChecksumDataBegin();
00735
while (it != sumFile->
getChecksumDataEnd() && dlgPrg.
canContinue())
00736 {
00737
00738 wxFileName fn(it->second.getFileName());
00739 fn.MakeAbsolute(sumFileName.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
00740
00741
00742 dlgPrg.
setFileInChecksumsFile(j);
00743 msg.Printf(_(
"Checking '%s'...\n"), fn.GetFullPath().c_str());
00744
if (it == sumFile->
getChecksumDataBegin() ||
AppPrefs::get()->
readBool(prMC_FILE_STATE))
00745 dlgPrg.
addResultLine(msg, 1U, getColour(prMC_NORMAL_COLOUR));
00746
else
00747 dlgPrg.
replaceLastResultLine(msg, 1U, getColour(prMC_NORMAL_COLOUR));
00748
00749
00750
checkFile(fn, cc, it->second.getChecksum(), dlgPrg, fstats);
00751
00752 it++;
00753 j++;
00754 }
00755
00756
00757
if (dlgPrg.
canContinue())
00758 {
00759
if (sumFile->
getChecksumDataCount() > 0)
00760 {
00761
00762
if (!
AppPrefs::get()->
readBool(prMC_FILE_STATE))
00763 dlgPrg.
removeLastResultLine();
00764
00765
if (
AppPrefs::get()->
readBool(prMC_CHECKSUMS_FILE_SUMMARY))
00766 {
00767
if (
AppPrefs::get()->
readBool(prMC_FILE_STATE))
00768 dlgPrg.
addResultLine(wxT(
"\n"));
00769 dlgPrg.
addResultLine(wxString::Format(_(
"Total checked: %d\n"), fstats.
getCheckedFilesCount()), 0U, getColour(prMC_NORMAL_COLOUR));
00770
if (fstats.
allAreCorrects()) colour = getColour(prMC_SUCCESS_COLOUR);
else if (fstats.
FCorrect > 0) colour = getColour(prMC_WARNING_COLOUR);
else colour = getColour(prMC_ERROR_COLOUR);
00771 dlgPrg.
addResultLine(wxString::Format(_(
"Correct(s): %d\n"), fstats.
FCorrect), 1U, colour);
00772 colour = (fstats.
FIncorrect == 0) ? getColour(prMC_SUCCESS_COLOUR) : getColour(prMC_ERROR_COLOUR);
00773 dlgPrg.
addResultLine(wxString::Format(_(
"Incorrect(s): %d\n"), fstats.
FIncorrect), 1U, colour);
00774 colour = (fstats.
FNotFound == 0) ? getColour(prMC_SUCCESS_COLOUR) : getColour(prMC_ERROR_COLOUR);
00775 dlgPrg.
addResultLine(wxString::Format(_(
"Not found: %d\n"), fstats.
FNotFound), 1U, colour);
00776 colour = (fstats.
FNotOpened == 0) ? getColour(prMC_SUCCESS_COLOUR) : getColour(prMC_ERROR_COLOUR);
00777 dlgPrg.
addResultLine(wxString::Format(_(
"Not opened: %d\n"), fstats.
FNotOpened), 1U, colour);
00778
00779
if (
AppPrefs::get()->
readBool(prMC_FILE_STATE))
00780 dlgPrg.
addResultLine(wxT(
"\n"));
00781 }
00782
else
00783 {
00784
if (fstats.
allAreCorrects())
00785 dlgPrg.
addResultLine(_(
"All checksums are corrects.\n"), 0U, getColour(prMC_SUCCESS_COLOUR));
00786
else
00787 dlgPrg.
addResultLine(_(
"Some checksums are incorrects.\n"), 0U, getColour(prMC_ERROR_COLOUR));
00788 }
00789 }
00790
else
00791 dlgPrg.
addResultLine(wxString::Format(_(
"'%s' is empty.\n"), files[i].c_str()), 0U, getColour(prMC_WARNING_COLOUR));
00792 }
00793
00794
delete cc;
00795
delete sumFile;
00796
00797
00798
if (fstats.
allAreCorrects())
00799 fstats.
CKTotallyCorrect++;
00800
else
00801
if (fstats.
FCorrect == 0)
00802 fstats.
CKFullyIncorrect++;
00803
else
00804 fstats.
CKPartiallyCorrect++;
00805 }
00806
else
00807 {
00808 dlgPrg.
addResultLine(wxString::Format(_(
"'%s' is not a valid checksums' file.\n"), files[i].c_str()), 0U, getColour(prMC_ERROR_COLOUR));
00809 fstats.
CKInvalid++;
00810 }
00811 }
00812
else
00813 {
00814 dlgPrg.
addResultLine(wxString::Format(_(
"'%s' cannot be opened.\n"), files[i].c_str()), 0U, getColour(prMC_ERROR_COLOUR));
00815 fstats.
CKNotOpened++;
00816 }
00817
00818 dlgPrg.
addResultLine(wxT(
"\n"));
00819
00820 i++;
00821 }
00822
00823
if (dlgPrg.
getState() != canceled)
00824 {
00825
00826
if (
AppPrefs::get()->
readBool(prMC_GLOBAL_SUMMARY))
00827 {
00828 dlgPrg.
addResultLine(wxString::Format(_(
"Total checksums' files checked: %d\n"), fstats.
getChecksumsFilesChecked()), 0U, getColour(prMC_NORMAL_COLOUR));
00829
if (fstats.
allChecksumsFilesAreCorrects()) colour = getColour(prMC_SUCCESS_COLOUR);
else if (fstats.
CKTotallyCorrect > 0) colour = getColour(prMC_WARNING_COLOUR);
else colour = getColour(prMC_ERROR_COLOUR);
00830 dlgPrg.
addResultLine(wxString::Format(_(
"Correct(s): %d\n"), fstats.
CKTotallyCorrect), 1U, colour);
00831 colour = (fstats.
CKPartiallyCorrect == 0) ? getColour(prMC_SUCCESS_COLOUR) : getColour(prMC_ERROR_COLOUR);
00832 dlgPrg.
addResultLine(wxString::Format(_(
"Partially correct(s): %d\n"), fstats.
CKPartiallyCorrect), 1U, colour);
00833 colour = (fstats.
CKFullyIncorrect == 0) ? getColour(prMC_SUCCESS_COLOUR) : getColour(prMC_ERROR_COLOUR);
00834 dlgPrg.
addResultLine(wxString::Format(_(
"Fully incorrect(s): %d\n"), fstats.
CKFullyIncorrect), 1U, colour);
00835 colour = (fstats.
CKInvalid == 0) ? getColour(prMC_SUCCESS_COLOUR) : getColour(prMC_ERROR_COLOUR);
00836 dlgPrg.
addResultLine(wxString::Format(_(
"Invalid(s): %d\n"), fstats.
CKInvalid), 1U, colour);
00837 colour = (fstats.
CKNotOpened == 0) ? getColour(prMC_SUCCESS_COLOUR) : getColour(prMC_ERROR_COLOUR);
00838 dlgPrg.
addResultLine(wxString::Format(_(
"Not opened: %d\n"), fstats.
CKNotOpened), 1U, colour);
00839 }
00840
else
00841 {
00842
if (fstats.
allChecksumsFilesAreCorrects())
00843 dlgPrg.
addResultLine(_(
"All checksums' files are corrects.\n"), 0U, getColour(prMC_SUCCESS_COLOUR));
00844
else
00845 dlgPrg.
addResultLine(_(
"Some checksums' files are incorrects.\n"), 0U, getColour(prMC_ERROR_COLOUR));
00846 }
00847
00848 dlgPrg.
Finished();
00849 }
00850 }
00851
00852
00853
00854 BEGIN_EVENT_TABLE(
dlgMultiCheck,
dlgResultsProgress)
00855 EVT_BUTTON(wxID_CANCEL,
dlgMultiCheck::btnCancelClick)
00856 END_EVENT_TABLE()
00857