1/*
2 * Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 */
14
15#ifndef APPLICATION_H
16#define APPLICATION_H
17
18#include <QApplication>
19#include <QPointer>
20#include <QQueue>
21#include <QTimer>
22#include <QElapsedTimer>
23#include <QNetworkConfigurationManager>
24
25#include "qtsingleapplication.h"
26
27#include "syncresult.h"
28#include "logbrowser.h"
29#include "owncloudgui.h"
30#include "connectionvalidator.h"
31#include "progressdispatcher.h"
32#include "clientproxy.h"
33#include "folderman.h"
34
35class QMessageBox;
36class QSystemTrayIcon;
37class QSocket;
38
39namespace CrashReporter {
40class Handler;
41}
42
43namespace OCC {
44
45Q_DECLARE_LOGGING_CATEGORY(lcApplication)
46
47class Theme;
48class Folder;
49class SslErrorDialog;
50
51/**
52 * @brief The Application class
53 * @ingroup gui
54 */
55class Application : public SharedTools::QtSingleApplication
56{
57 Q_OBJECT
58public:
59 explicit Application(int &argc, char **argv);
60 ~Application();
61
62 bool giveHelp();
63 void showHelp();
64 void showHint(std::string errorHint);
65 bool debugMode();
66 bool versionOnly(); // only display the version?
67 void showVersion();
68
69 void showSettingsDialog();
70
71public slots:
72 // TODO: this should not be public
73 void slotownCloudWizardDone(int);
74 void slotCrash();
75 /**
76 * Will download a virtual file, and open the result.
77 * The argument is the filename of the virtual file (including the extension)
78 */
79 void openVirtualFile(const QString &filename);
80
81protected:
82 void parseOptions(const QStringList &);
83 void setupTranslations();
84 void setupLogging();
85 bool event(QEvent *event);
86
87signals:
88 void folderRemoved();
89 void folderStateChanged(Folder *);
90
91protected slots:
92 void slotParseMessage(const QString &, QObject *);
93 void slotCheckConnection();
94 void slotUseMonoIconsChanged(bool);
95 void slotCleanup();
96 void slotAccountStateAdded(AccountState *accountState);
97 void slotAccountStateRemoved(AccountState *accountState);
98 void slotSystemOnlineConfigurationChanged(QNetworkConfiguration);
99
100private:
101 void setHelp();
102
103 /**
104 * Maybe a newer version of the client was used with this config file:
105 * if so, backup, confirm with user and remove the config that can't be read.
106 */
107 bool configVersionMigration();
108
109 QPointer<ownCloudGui> _gui;
110
111 Theme *_theme;
112
113 bool _helpOnly;
114 bool _versionOnly;
115
116 QElapsedTimer _startedAt;
117
118 // options from command line:
119 bool _showLogWindow;
120 QString _logFile;
121 QString _logDir;
122 int _logExpire;
123 bool _logFlush;
124 bool _logDebug;
125 bool _userTriggeredConnect;
126 bool _debugMode;
127
128 ClientProxy _proxy;
129
130 QNetworkConfigurationManager _networkConfigurationManager;
131 QTimer _checkConnectionTimer;
132
133#if defined(WITH_CRASHREPORTER)
134 QScopedPointer<CrashReporter::Handler> _crashHandler;
135#endif
136 QScopedPointer<FolderMan> _folderManager;
137};
138
139} // namespace OCC
140
141#endif // APPLICATION_H
142