summaryrefslogtreecommitdiff
path: root/ui/batchStatusHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ui/batchStatusHandler.cpp')
-rw-r--r--ui/batchStatusHandler.cpp384
1 files changed, 227 insertions, 157 deletions
diff --git a/ui/batchStatusHandler.cpp b/ui/batchStatusHandler.cpp
index f7f0df9f..294613dd 100644
--- a/ui/batchStatusHandler.cpp
+++ b/ui/batchStatusHandler.cpp
@@ -1,11 +1,13 @@
#include "batchStatusHandler.h"
#include "smallDialogs.h"
-#include <wx/stopwatch.h>
#include <wx/taskbar.h>
#include "../algorithm.h"
#include <wx/ffile.h>
#include <wx/msgdlg.h>
-#include "../library/globalFunctions.h"
+#include "../shared/globalFunctions.h"
+#include "../shared/standardPaths.h"
+#include "../shared/fileHandling.h"
+#include "../library/resources.h"
class LogFile
@@ -14,11 +16,11 @@ public:
LogFile(const wxString& logfileDirectory)
{
//create logfile directory
- const Zstring logfileDir = logfileDirectory.empty() ? FreeFileSync::getDefaultLogDirectory().c_str() : logfileDirectory.c_str();
- if (!wxDirExists(logfileDir))
+ const wxString logfileDir = logfileDirectory.empty() ? FreeFileSync::getDefaultLogDirectory() : logfileDirectory;
+ if (!FreeFileSync::dirExists(logfileDir))
try
{
- FreeFileSync::createDirectory(logfileDir, Zstring(), false);
+ FreeFileSync::createDirectory(logfileDir.c_str()); //create recursively if necessary
}
catch (FreeFileSync::FileError&)
{
@@ -27,9 +29,10 @@ public:
}
//assemble logfile name
- wxString logfileName = logfileDir.c_str();
- if (!FreeFileSync::endsWithPathSeparator(logfileName.c_str()))
- logfileName += FreeFileSync::FILE_NAME_SEPARATOR;
+ wxString logfileName = logfileDir;
+ if (!logfileName.empty() && logfileName.Last() != globalFunctions::FILE_NAME_SEPARATOR)
+ logfileName += globalFunctions::FILE_NAME_SEPARATOR;
+
wxString timeNow = wxDateTime::Now().FormatISOTime();
timeNow.Replace(wxT(":"), wxT("-"));
logfileName += wxDateTime::Now().FormatISODate() + wxChar(' ') + timeNow + wxT(".log");
@@ -39,6 +42,7 @@ public:
readyToWrite = logFile.IsOpened();
if (readyToWrite)
{
+ //write header
wxString headerLine = wxString(wxT("FreeFileSync - ")) +
_("Batch execution") + wxT(" (") +
_("Date") + wxT(": ") + wxDateTime::Now().FormatDate() + wxT(" ") + //"Date" is used at other places too
@@ -50,8 +54,7 @@ public:
logFile.Write(caption + wxChar('\n'));
logFile.Write(wxString().Pad(caption.Len(), wxChar('-')) + wxChar('\n'));
- write(_("Start")); //attention: write() replaces '\n'-characters
- logFile.Write(wxChar('\n')); //
+ logFile.Write(wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] ") + _("Start") + wxChar('\n') + wxChar('\n'));
totalTime.Start(); //measure total time
}
@@ -59,48 +62,57 @@ public:
~LogFile()
{
- if (readyToWrite)
- close();
- }
+ if (readyToWrite) //could be reached when creation of logfile failed
+ {
+ //write actual logfile
+ const std::vector<wxString>& messages = errorLog.getFormattedMessages();
+ for (std::vector<wxString>::const_iterator i = messages.begin(); i != messages.end(); ++i)
+ logFile.Write(*i + wxChar('\n'));
- bool isOkay()
- {
- return readyToWrite;
- }
+ //write ending
+ logFile.Write(wxChar('\n'));
- void write(const wxString& logText, const wxString& problemType = wxEmptyString)
- {
- logFile.Write(wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] "));
+ const long time = totalTime.Time(); //retrieve total time
+ logFile.Write(wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] "));
+ logFile.Write(wxString(_("Stop")) + wxT(" (") + _("Total time:") + wxT(" ") + (wxTimeSpan::Milliseconds(time)).Format() + wxT(")"));
- if (problemType != wxEmptyString)
- logFile.Write(problemType + wxT(": "));
+ //logFile.close(); <- not needed
+ }
+ }
- //remove linebreaks
- wxString formattedText = logText;
- for (wxString::iterator i = formattedText.begin(); i != formattedText.end(); ++i)
- if (*i == wxChar('\n'))
- *i = wxChar(' ');
- logFile.Write(formattedText + wxChar('\n'));
+ bool isOkay() //has to be checked before LogFile can be used!
+ {
+ return readyToWrite;
}
-private:
- void close()
+ void logError(const wxString& errorMessage)
{
- logFile.Write(wxChar('\n'));
+ errorLog.logError(errorMessage);
+ }
- long time = totalTime.Time(); //retrieve total time
+ void logWarning(const wxString& warningMessage)
+ {
+ errorLog.logWarning(warningMessage);
+ }
- logFile.Write(wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] "));
- logFile.Write(wxString(_("Stop")) + wxT(" (") + _("Total time:") + wxT(" ") + (wxTimeSpan::Milliseconds(time)).Format() + wxT(")"));
+ void logInfo(const wxString& infoMessage)
+ {
+ errorLog.logInfo(infoMessage);
+ }
- //logFile.close(); <- not needed
+ bool errorsOccured()
+ {
+ return errorLog.errorsTotal() > 0;
}
+private:
bool readyToWrite;
wxFFile logFile;
wxStopWatch totalTime;
+
+ FreeFileSync::ErrorLogging errorLog;
};
@@ -109,18 +121,22 @@ class FfsTrayIcon : public wxTaskBarIcon
public:
FfsTrayIcon(StatusHandler* statusHandler) :
m_statusHandler(statusHandler),
- processPaused(false)
+ processPaused(false),
+ percentage(_("%x Percent")),
+ currentProcess(StatusHandler::PROCESS_NONE),
+ totalObjects(0),
+ currentObjects(0)
{
running.reset(new wxIcon(*GlobalResources::getInstance().programIcon));
paused.reset(new wxIcon);
paused->CopyFromBitmap(*GlobalResources::getInstance().bitmapFFSPaused);
- wxTaskBarIcon::SetIcon(*running);
+ wxTaskBarIcon::SetIcon(*running, wxT("FreeFileSync"));
}
~FfsTrayIcon() {}
- enum
+ enum Selection
{
CONTEXT_PAUSE,
CONTEXT_ABORT,
@@ -132,9 +148,9 @@ public:
wxMenu* contextMenu = new wxMenu;
contextMenu->Append(CONTEXT_PAUSE, _("&Pause"), wxEmptyString, wxITEM_CHECK);
contextMenu->Check(CONTEXT_PAUSE, processPaused);
- contextMenu->Append(CONTEXT_ABORT, _("&Abort"));
- contextMenu->AppendSeparator();
contextMenu->Append(CONTEXT_ABOUT, _("&About..."));
+ contextMenu->AppendSeparator();
+ contextMenu->Append(CONTEXT_ABORT, _("&Exit"));
//event handling
contextMenu->Connect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(FfsTrayIcon::onContextMenuSelection), NULL, this);
@@ -143,46 +159,100 @@ public:
void onContextMenuSelection(wxCommandEvent& event)
{
- int eventId = event.GetId();
- if (eventId == CONTEXT_PAUSE)
+ const Selection eventId = static_cast<Selection>(event.GetId());
+ switch (eventId)
{
+ case CONTEXT_PAUSE:
processPaused = !processPaused;
- if (processPaused)
- wxTaskBarIcon::SetIcon(*paused);
- else
- wxTaskBarIcon::SetIcon(*running);
- }
- else if (eventId == CONTEXT_ABORT)
- {
+ break;
+ case CONTEXT_ABORT:
processPaused = false;
- wxTaskBarIcon::SetIcon(*running);
m_statusHandler->requestAbortion();
- }
- else if (eventId == CONTEXT_ABOUT)
+ break;
+ case CONTEXT_ABOUT:
{
AboutDlg* aboutDlg = new AboutDlg(NULL);
aboutDlg->ShowModal();
aboutDlg->Destroy();
}
+ break;
+ }
+ }
+
+ wxString calcPercentage(const wxLongLong& current, const wxLongLong& total)
+ {
+ const double ratio = current.ToDouble() * 100 / total.ToDouble();
+ wxString output = percentage;
+ output.Replace(wxT("%x"), wxString::Format(wxT("%3.2f"), ratio), false);
+ return output;
}
void updateSysTray()
{
+ switch (currentProcess)
+ {
+ case StatusHandler::PROCESS_SCANNING:
+ wxTaskBarIcon::SetIcon(*running, wxString(wxT("FreeFileSync - ")) + wxString(_("Scanning...")) + wxT(" ") +
+ globalFunctions::numberToWxString(currentObjects));
+ break;
+ case StatusHandler::PROCESS_COMPARING_CONTENT:
+ wxTaskBarIcon::SetIcon(*running, wxString(wxT("FreeFileSync - ")) + wxString(_("Comparing content...")) + wxT(" ") +
+ calcPercentage(currentData, totalData));
+ break;
+ case StatusHandler::PROCESS_SYNCHRONIZING:
+ wxTaskBarIcon::SetIcon(*running, wxString(wxT("FreeFileSync - ")) + wxString(_("Synchronizing...")) + wxT(" ") +
+ calcPercentage(currentData, totalData));
+ break;
+ case StatusHandler::PROCESS_NONE:
+ assert(false);
+ break;
+ }
+
updateUiNow();
+
//support for pause button
- while (processPaused)
+ if (processPaused)
{
- wxMilliSleep(UI_UPDATE_INTERVAL);
- updateUiNow();
+ wxTaskBarIcon::SetIcon(*paused, wxString(wxT("FreeFileSync - ")) + _("Paused"));
+ while (processPaused)
+ {
+ wxMilliSleep(UI_UPDATE_INTERVAL);
+ updateUiNow();
+ }
}
}
+ void initNewProcess(int objectsTotal, wxLongLong dataTotal, StatusHandler::Process processID)
+ {
+ totalObjects = objectsTotal;
+ totalData = dataTotal;
+ currentObjects = 0;
+ currentData = 0;
+ currentProcess = processID;
+ }
+
+ void updateProcessedData(int objectsProcessed, wxLongLong dataProcessed)
+ {
+ currentObjects += objectsProcessed;
+ currentData += dataProcessed;
+ }
+
+
private:
StatusHandler* m_statusHandler;
bool processPaused;
std::auto_ptr<wxIcon> running;
std::auto_ptr<wxIcon> paused;
+ const wxString percentage;
+
+ //status variables
+ StatusHandler::Process currentProcess;
+ int totalObjects;
+ wxLongLong totalData;
+ int currentObjects; //each object represents a file or directory processed
+ wxLongLong currentData; //each data element represents one byte for proper progress indicator scaling
+
};
@@ -199,6 +269,7 @@ BatchStatusHandlerSilent::BatchStatusHandlerSilent(const xmlAccess::OnError hand
if (!m_log->isOkay())
{ //handle error: file load
wxMessageBox(_("Unable to create logfile!"), _("Error"), wxOK | wxICON_ERROR);
+ returnValue = -7;
throw FreeFileSync::AbortThisProcess();
}
}
@@ -206,21 +277,19 @@ BatchStatusHandlerSilent::BatchStatusHandlerSilent(const xmlAccess::OnError hand
BatchStatusHandlerSilent::~BatchStatusHandlerSilent()
{
- unsigned int failedItems = unhandledErrors.GetCount();
-
//write result
if (abortIsRequested())
{
returnValue = -4;
- m_log->write(_("Synchronization aborted!"), _("Error"));
+ m_log->logError(_("Synchronization aborted!"));
}
- else if (failedItems)
+ else if (m_log->errorsOccured())
{
returnValue = -5;
- m_log->write(_("Synchronization completed with errors!"), _("Info"));
+ m_log->logInfo(_("Synchronization completed with errors!"));
}
else
- m_log->write(_("Synchronization completed successfully!"), _("Info"));
+ m_log->logInfo(_("Synchronization completed successfully!"));
}
@@ -233,7 +302,7 @@ void BatchStatusHandlerSilent::updateStatusText(const Zstring& text)
case StatusHandler::PROCESS_COMPARING_CONTENT:
break;
case StatusHandler::PROCESS_SYNCHRONIZING:
- m_log->write(text.c_str(), _("Info"));
+ m_log->logInfo(text.c_str());
break;
case StatusHandler::PROCESS_NONE:
assert(false);
@@ -246,10 +315,18 @@ inline
void BatchStatusHandlerSilent::initNewProcess(int objectsTotal, wxLongLong dataTotal, StatusHandler::Process processID)
{
currentProcess = processID;
+
+ trayIcon->initNewProcess(objectsTotal, dataTotal, processID);
}
-ErrorHandler::Response BatchStatusHandlerSilent::reportError(const Zstring& errorMessage)
+void BatchStatusHandlerSilent::updateProcessedData(int objectsProcessed, wxLongLong dataProcessed)
+{
+ trayIcon->updateProcessedData(objectsProcessed, dataProcessed);
+}
+
+
+ErrorHandler::Response BatchStatusHandlerSilent::reportError(const wxString& errorMessage)
{
switch (m_handleError)
{
@@ -258,38 +335,34 @@ ErrorHandler::Response BatchStatusHandlerSilent::reportError(const Zstring& erro
bool ignoreNextErrors = false;
ErrorDlg* errorDlg = new ErrorDlg(NULL,
ErrorDlg::BUTTON_IGNORE | ErrorDlg::BUTTON_RETRY | ErrorDlg::BUTTON_ABORT,
- wxString(errorMessage) + wxT("\n\n") + _("Ignore this error, retry or abort?"),
+ errorMessage + wxT("\n\n\n") + _("Ignore this error, retry or abort?"),
ignoreNextErrors);
- const int rv = errorDlg->ShowModal();
+ const ErrorDlg::ReturnCodes rv = static_cast<ErrorDlg::ReturnCodes>(errorDlg->ShowModal());
errorDlg->Destroy();
switch (rv)
{
case ErrorDlg::BUTTON_IGNORE:
if (ignoreNextErrors) //falsify only
m_handleError = xmlAccess::ON_ERROR_IGNORE;
- unhandledErrors.Add(errorMessage.c_str());
- m_log->write(errorMessage.c_str(), _("Error"));
+ m_log->logError(errorMessage);
return ErrorHandler::IGNORE_ERROR;
case ErrorDlg::BUTTON_RETRY:
return ErrorHandler::RETRY;
case ErrorDlg::BUTTON_ABORT:
- unhandledErrors.Add(errorMessage.c_str());
- m_log->write(errorMessage.c_str(), _("Error"));
+ m_log->logError(errorMessage);
abortThisProcess();
}
}
break; //used if last switch didn't find a match
case xmlAccess::ON_ERROR_EXIT: //abort
- unhandledErrors.Add(errorMessage.c_str());
- m_log->write(errorMessage.c_str(), _("Error"));
+ m_log->logError(errorMessage);
abortThisProcess();
case xmlAccess::ON_ERROR_IGNORE:
- unhandledErrors.Add(errorMessage.c_str());
- m_log->write(errorMessage.c_str(), _("Error"));
+ m_log->logError(errorMessage);
return ErrorHandler::IGNORE_ERROR;
}
@@ -298,7 +371,7 @@ ErrorHandler::Response BatchStatusHandlerSilent::reportError(const Zstring& erro
}
-void BatchStatusHandlerSilent::reportFatalError(const Zstring& errorMessage)
+void BatchStatusHandlerSilent::reportFatalError(const wxString& errorMessage)
{
switch (m_handleError)
{
@@ -307,7 +380,7 @@ void BatchStatusHandlerSilent::reportFatalError(const Zstring& errorMessage)
bool dummy = false;
ErrorDlg* errorDlg = new ErrorDlg(NULL,
ErrorDlg::BUTTON_ABORT,
- errorMessage.c_str(), dummy);
+ errorMessage, dummy);
errorDlg->ShowModal();
errorDlg->Destroy();
}
@@ -320,14 +393,18 @@ void BatchStatusHandlerSilent::reportFatalError(const Zstring& errorMessage)
break;
}
- unhandledErrors.Add(errorMessage.c_str());
- m_log->write(errorMessage.c_str(), _("Error"));
+ m_log->logError(errorMessage);
abortThisProcess();
}
-void BatchStatusHandlerSilent::reportWarning(const Zstring& warningMessage, bool& dontShowAgain)
+void BatchStatusHandlerSilent::reportWarning(const wxString& warningMessage, bool& warningActive)
{
+ m_log->logWarning(warningMessage);
+
+ if (!warningActive)
+ return;
+
switch (m_handleError)
{
case xmlAccess::ON_ERROR_POPUP:
@@ -336,41 +413,36 @@ void BatchStatusHandlerSilent::reportWarning(const Zstring& warningMessage, bool
bool dontWarnAgain = false;
WarningDlg* warningDlg = new WarningDlg(NULL,
WarningDlg::BUTTON_IGNORE | WarningDlg::BUTTON_ABORT,
- warningMessage.c_str(),
+ warningMessage,
dontWarnAgain);
- const int rv = warningDlg->ShowModal();
+ const WarningDlg::Response rv = static_cast<WarningDlg::Response>(warningDlg->ShowModal());
warningDlg->Destroy();
switch (rv)
{
case WarningDlg::BUTTON_ABORT:
- unhandledErrors.Add(warningMessage.c_str());
- m_log->write(warningMessage.c_str(), _("Warning"));
abortThisProcess();
+ break;
+
case WarningDlg::BUTTON_IGNORE: //no unhandled error situation!
- dontShowAgain = dontWarnAgain;
- m_log->write(warningMessage.c_str(), _("Warning"));
- return;
+ warningActive = !dontWarnAgain;
+ break;
}
}
break; //keep it! last switch might not find match
case xmlAccess::ON_ERROR_EXIT: //abort
- unhandledErrors.Add(warningMessage.c_str());
- m_log->write(warningMessage.c_str(), _("Warning"));
abortThisProcess();
+ break;
case xmlAccess::ON_ERROR_IGNORE: //no unhandled error situation!
- m_log->write(warningMessage.c_str(), _("Warning"));
- return;
+ break;
}
-
- assert(false);
}
-void BatchStatusHandlerSilent::addFinalInfo(const Zstring& infoMessage)
+void BatchStatusHandlerSilent::addFinalInfo(const wxString& infoMessage)
{
- m_log->write(infoMessage.c_str(), _("Info"));
+ m_log->logInfo(infoMessage);
}
@@ -390,10 +462,26 @@ void BatchStatusHandlerSilent::abortThisProcess() //used by sys-tray menu
BatchStatusHandlerGui::BatchStatusHandlerGui(const xmlAccess::OnError handleError, int& returnVal) :
- m_handleError(handleError),
+ showPopups(true),
currentProcess(StatusHandler::PROCESS_NONE),
returnValue(returnVal)
{
+ switch (handleError)
+ {
+ case xmlAccess::ON_ERROR_POPUP:
+ showPopups = true;
+ break;
+
+ case xmlAccess::ON_ERROR_EXIT: //doesn't make much sense for "batch gui"-mode
+ showPopups = true;
+ break;
+
+ case xmlAccess::ON_ERROR_IGNORE:
+ showPopups = false;
+ break;
+ }
+
+
syncStatusFrame = new SyncStatus(this, NULL);
syncStatusFrame->Show();
}
@@ -401,24 +489,24 @@ BatchStatusHandlerGui::BatchStatusHandlerGui(const xmlAccess::OnError handleErro
BatchStatusHandlerGui::~BatchStatusHandlerGui()
{
- //display result
+ //print the results list
wxString finalMessage;
-
- unsigned int failedItems = unhandledErrors.GetCount();
- if (failedItems)
+ if (errorLog.messageCount() > 0)
{
- finalMessage = wxString(_("Warning: Synchronization failed for %x item(s):")) + wxT("\n\n");
- finalMessage.Replace(wxT("%x"), globalFunctions::numberToWxString(failedItems), false);
-
- for (unsigned int j = 0; j < failedItems; ++j)
- { //remove linebreaks
- wxString errorMessage = unhandledErrors[j];
- for (wxString::iterator i = errorMessage.begin(); i != errorMessage.end(); ++i)
- if (*i == wxChar('\n'))
- *i = wxChar(' ');
+ if (errorLog.errorsTotal() > 0)
+ {
+ wxString header(_("Warning: Synchronization failed for %x item(s):"));
+ header.Replace(wxT("%x"), globalFunctions::numberToWxString(errorLog.errorsTotal()), false);
+ finalMessage += header + wxT("\n\n");
+ }
- finalMessage += errorMessage + wxT("\n");
+ const std::vector<wxString>& messages = errorLog.getFormattedMessages();
+ for (std::vector<wxString>::const_iterator i = messages.begin(); i != messages.end(); ++i)
+ {
+ finalMessage += *i;
+ finalMessage += wxChar('\n');
}
+
finalMessage += wxT("\n");
}
@@ -433,7 +521,7 @@ BatchStatusHandlerGui::~BatchStatusHandlerGui()
syncStatusFrame->setStatusText_NoUpdate(finalMessage.c_str());
syncStatusFrame->processHasFinished(SyncStatus::ABORTED); //enable okay and close events
}
- else if (failedItems)
+ else if (errorLog.errorsTotal())
{
returnValue = -5;
finalMessage += _("Synchronization completed with errors!");
@@ -499,69 +587,57 @@ void BatchStatusHandlerGui::updateProcessedData(int objectsProcessed, wxLongLong
}
-ErrorHandler::Response BatchStatusHandlerGui::reportError(const Zstring& errorMessage)
+ErrorHandler::Response BatchStatusHandlerGui::reportError(const wxString& errorMessage)
{
- //add current time before error message
- const wxString errorWithTime = wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] ") + errorMessage.c_str();
-
- switch (m_handleError)
- {
- case xmlAccess::ON_ERROR_POPUP:
+ if (showPopups)
{
syncStatusFrame->updateStatusDialogNow();
bool ignoreNextErrors = false;
ErrorDlg* errorDlg = new ErrorDlg(syncStatusFrame,
ErrorDlg::BUTTON_IGNORE | ErrorDlg::BUTTON_RETRY | ErrorDlg::BUTTON_ABORT,
- wxString(errorMessage) + wxT("\n\n") + _("Ignore this error, retry or abort?"),
+ errorMessage + wxT("\n\n\n") + _("Ignore this error, retry or abort?"),
ignoreNextErrors);
- switch (errorDlg->ShowModal())
+ switch (static_cast<ErrorDlg::ReturnCodes>(errorDlg->ShowModal()))
{
case ErrorDlg::BUTTON_IGNORE:
- if (ignoreNextErrors) //falsify only
- m_handleError = xmlAccess::ON_ERROR_IGNORE;
- unhandledErrors.Add(errorWithTime);
+ showPopups = !ignoreNextErrors;
+ errorLog.logError(errorMessage);
return ErrorHandler::IGNORE_ERROR;
case ErrorDlg::BUTTON_RETRY:
return ErrorHandler::RETRY;
case ErrorDlg::BUTTON_ABORT:
- unhandledErrors.Add(errorWithTime);
+ errorLog.logError(errorMessage);
abortThisProcess();
}
}
- break; //used IF last switch didn't find a match
-
- case xmlAccess::ON_ERROR_EXIT: //abort
- unhandledErrors.Add(errorWithTime);
- abortThisProcess();
-
- case xmlAccess::ON_ERROR_IGNORE:
- unhandledErrors.Add(errorWithTime);
+ else
+ {
+ errorLog.logError(errorMessage);
return ErrorHandler::IGNORE_ERROR;
}
assert(false);
- return ErrorHandler::IGNORE_ERROR; //dummy value
+ errorLog.logError(errorMessage);
+ return ErrorHandler::IGNORE_ERROR; //dummy
}
-void BatchStatusHandlerGui::reportFatalError(const Zstring& errorMessage)
-{ //add current time before error message
- wxString errorWithTime = wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] ") + errorMessage.c_str();
-
- unhandledErrors.Add(errorWithTime);
+void BatchStatusHandlerGui::reportFatalError(const wxString& errorMessage)
+{
+ errorLog.logError(errorMessage);
abortThisProcess();
}
-void BatchStatusHandlerGui::reportWarning(const Zstring& warningMessage, bool& dontShowAgain)
-{ //add current time before warning message
- wxString warningWithTime = wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] ") + warningMessage.c_str();
+void BatchStatusHandlerGui::reportWarning(const wxString& warningMessage, bool& warningActive)
+{
+ errorLog.logWarning(warningMessage);
- switch (m_handleError)
- {
- case xmlAccess::ON_ERROR_POPUP:
- case xmlAccess::ON_ERROR_EXIT: //show popup in this case also
+ if (!warningActive)
+ return;
+
+ if (showPopups)
{
syncStatusFrame->updateStatusDialogNow();
@@ -569,27 +645,21 @@ void BatchStatusHandlerGui::reportWarning(const Zstring& warningMessage, bool& d
bool dontWarnAgain = false;
WarningDlg* warningDlg = new WarningDlg(NULL,
WarningDlg::BUTTON_IGNORE | WarningDlg::BUTTON_ABORT,
- warningMessage.c_str(),
+ warningMessage,
dontWarnAgain);
- const int rv = warningDlg->ShowModal();
+ const WarningDlg::Response rv = static_cast<WarningDlg::Response>(warningDlg->ShowModal());
warningDlg->Destroy();
switch (rv)
{
case WarningDlg::BUTTON_IGNORE: //no unhandled error situation!
- dontShowAgain = dontWarnAgain;
- return;
+ warningActive = !dontWarnAgain;
+ break;
+
case WarningDlg::BUTTON_ABORT:
- unhandledErrors.Add(warningWithTime);
abortThisProcess();
+ break;
}
}
- break; //keep it! last switch might not find match
-
- case xmlAccess::ON_ERROR_IGNORE: //no unhandled error situation!
- return;
- }
-
- assert(false);
}
@@ -610,7 +680,7 @@ void BatchStatusHandlerGui::abortThisProcess()
}
-void BatchStatusHandlerGui::addFinalInfo(const Zstring& infoMessage)
+void BatchStatusHandlerGui::addFinalInfo(const wxString& infoMessage)
{
- finalInfo = infoMessage.c_str();
+ finalInfo = infoMessage;
}
bgstack15