summaryrefslogtreecommitdiff
path: root/Application.h
blob: e1b12172dbdf7a8a7f733dc3d6e6f80101738c44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/***************************************************************
 * Name:      FreeFileSyncApp.h
 * Purpose:   Defines Application Class
 * Author:    ZenJu (zhnmju123@gmx.de)
 * Created:   2008-07-16
 * Copyright: ZenJu ()
 * License:
 **************************************************************/

#ifndef FREEFILESYNCAPP_H
#define FREEFILESYNCAPP_H

#include <wx/app.h>
#include "ui/smallDialogs.h"
#include "library/misc.h"
#include "library/processXml.h"

class Application : public wxApp
{
public:
    bool OnInit();
    int  OnRun();
    int  OnExit();
    bool OnExceptionInMainLoop();

    void initialize();

    bool ProcessIdle();  //virtual impl.

private:
    void runBatchMode(const wxString& filename, xmlAccess::XmlGlobalSettings& globalSettings);

    CustomLocale programLanguage;

    int returnValue;
    xmlAccess::XmlGlobalSettings globalSettings; //settings used by GUI, batch mode or both
};


class BatchStatusHandler : public StatusHandler
{
public:
    BatchStatusHandler() {}
    virtual ~BatchStatusHandler() {}

    enum ExitCode
    {
        NONE,
        ABORTED,
        FINISHED
    };
    virtual void exitAndSetStatus(const wxString& message, ExitCode code) = 0; //overwrite final status message text
};


class LogFile;
class BatchStatusHandlerSilent : public BatchStatusHandler
{
public:
    BatchStatusHandlerSilent(bool ignoreAllErrors, LogFile* log, int& returnVal);
    ~BatchStatusHandlerSilent();


    void updateStatusText(const Zstring& text); //virtual impl.
    void initNewProcess(int objectsTotal, double dataTotal, Process processID); //virtual impl.
    void updateProcessedData(int objectsProcessed, double dataProcessed) {} //virtual impl.
    ErrorHandler::Response reportError(const Zstring& text); //virtual impl.
    void forceUiRefresh() {} //virtual impl.

    void exitAndSetStatus(const wxString& message, ExitCode code); //abort externally //virtual impl.

private:
    void abortThisProcess(); //virtual impl.

    bool ignoreErrors;
    wxArrayString unhandledErrors; //list of non-resolved errors
    Process currentProcess;
    int& returnValue;

    LogFile* m_log;
};


class BatchStatusHandlerGui : public BatchStatusHandler
{
public:
    BatchStatusHandlerGui(bool ignoreAllErrors, int& returnVal);
    ~BatchStatusHandlerGui();

    void updateStatusText(const Zstring& text); //virtual impl.
    void initNewProcess(int objectsTotal, double dataTotal, Process processID); //virtual impl.
    void updateProcessedData(int objectsProcessed, double dataProcessed); //virtual impl.
    ErrorHandler::Response reportError(const Zstring& text); //virtual impl.
    void forceUiRefresh(); //virtual impl.

    void exitAndSetStatus(const wxString& message, ExitCode code); //abort externally //virtual impl.

private:
    void abortThisProcess(); //virtual impl.

    bool ignoreErrors;
    wxArrayString unhandledErrors; //list of non-resolved errors
    Process currentProcess;
    int& returnValue;

    SyncStatus* syncStatusFrame;
    wxString additionalStatusInfo; //workaround to display "Nothing to synchronize..."
};

#endif // FREEFILESYNCAPP_H
bgstack15