2011-04-06 13:48:02 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
2011-02-17 02:21:45 +03:00
|
|
|
#ifndef APPLICATION_H
|
|
|
|
#define APPLICATION_H
|
|
|
|
|
|
|
|
#include <QApplication>
|
2013-06-27 18:54:33 +04:00
|
|
|
#include <QPointer>
|
2013-07-31 00:22:43 +04:00
|
|
|
#include <QQueue>
|
2014-04-19 11:45:54 +04:00
|
|
|
#include <QTimer>
|
2015-09-28 23:51:16 +03:00
|
|
|
#include <QElapsedTimer>
|
2015-11-23 23:47:30 +03:00
|
|
|
#include <QNetworkConfigurationManager>
|
2011-02-17 02:21:45 +03:00
|
|
|
|
2012-07-30 18:10:48 +04:00
|
|
|
#include "qtsingleapplication.h"
|
|
|
|
|
2014-07-11 02:31:24 +04:00
|
|
|
#include "syncresult.h"
|
|
|
|
#include "logbrowser.h"
|
|
|
|
#include "owncloudgui.h"
|
|
|
|
#include "connectionvalidator.h"
|
|
|
|
#include "progressdispatcher.h"
|
|
|
|
#include "clientproxy.h"
|
|
|
|
#include "folderman.h"
|
2012-02-17 12:48:31 +04:00
|
|
|
|
2013-11-27 17:15:56 +04:00
|
|
|
class QMessageBox;
|
2011-02-17 02:21:45 +03:00
|
|
|
class QSystemTrayIcon;
|
2014-05-21 14:31:44 +04:00
|
|
|
class QSocket;
|
2011-02-17 02:21:45 +03:00
|
|
|
|
2015-03-12 18:49:47 +03:00
|
|
|
namespace CrashReporter {
|
|
|
|
class Handler;
|
|
|
|
}
|
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
namespace OCC {
|
2017-05-09 15:24:11 +03:00
|
|
|
|
|
|
|
Q_DECLARE_LOGGING_CATEGORY(lcApplication)
|
|
|
|
|
2012-02-16 13:42:44 +04:00
|
|
|
class Theme;
|
2013-07-04 21:59:40 +04:00
|
|
|
class Folder;
|
2022-07-04 15:36:06 +03:00
|
|
|
class ShellExtensionsServer;
|
2012-08-15 20:01:32 +04:00
|
|
|
class SslErrorDialog;
|
2011-02-17 02:21:45 +03:00
|
|
|
|
2022-11-30 19:11:52 +03:00
|
|
|
#ifdef Q_OS_MACOS
|
|
|
|
namespace Mac {
|
|
|
|
class FileProvider;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
|
|
|
* @brief The Application class
|
|
|
|
* @ingroup gui
|
2015-06-26 18:07:47 +03:00
|
|
|
*/
|
2012-07-30 18:10:48 +04:00
|
|
|
class Application : public SharedTools::QtSingleApplication
|
2011-02-17 02:21:45 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2012-04-20 15:17:48 +04:00
|
|
|
explicit Application(int &argc, char **argv);
|
2021-08-17 13:39:31 +03:00
|
|
|
~Application() override;
|
2012-06-15 15:36:38 +04:00
|
|
|
|
|
|
|
bool giveHelp();
|
2013-01-29 08:19:14 +04:00
|
|
|
void showHelp();
|
2015-07-03 17:01:24 +03:00
|
|
|
void showHint(std::string errorHint);
|
2014-08-26 17:46:24 +04:00
|
|
|
bool debugMode();
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] bool backgroundMode() const;
|
2015-07-16 19:12:45 +03:00
|
|
|
bool versionOnly(); // only display the version?
|
|
|
|
void showVersion();
|
2012-06-15 15:36:38 +04:00
|
|
|
|
2020-06-16 19:59:16 +03:00
|
|
|
void showMainDialog();
|
2015-01-26 15:00:45 +03:00
|
|
|
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] ownCloudGui *gui() const;
|
2020-06-29 15:53:40 +03:00
|
|
|
|
2022-07-19 13:05:20 +03:00
|
|
|
bool event(QEvent *event) override;
|
|
|
|
|
2013-07-04 21:59:40 +04:00
|
|
|
public slots:
|
|
|
|
// TODO: this should not be public
|
2012-11-28 22:25:12 +04:00
|
|
|
void slotownCloudWizardDone(int);
|
2017-09-20 12:48:13 +03:00
|
|
|
void slotCrash();
|
2018-01-15 18:46:52 +03:00
|
|
|
/**
|
2018-05-18 09:29:40 +03:00
|
|
|
* Will download a virtual file, and open the result.
|
|
|
|
* The argument is the filename of the virtual file (including the extension)
|
2018-01-15 18:46:52 +03:00
|
|
|
*/
|
2018-05-18 09:29:40 +03:00
|
|
|
void openVirtualFile(const QString &filename);
|
2011-02-17 02:21:45 +03:00
|
|
|
|
2019-03-06 12:55:45 +03:00
|
|
|
/// Attempt to show() the tray icon again. Used if no systray was available initially.
|
|
|
|
void tryTrayAgain();
|
|
|
|
|
2013-07-04 21:59:40 +04:00
|
|
|
protected:
|
2012-10-16 21:05:28 +04:00
|
|
|
void parseOptions(const QStringList &);
|
2013-02-14 21:27:44 +04:00
|
|
|
void setupTranslations();
|
2013-10-02 17:28:33 +04:00
|
|
|
void setupLogging();
|
2011-02-17 02:21:45 +03:00
|
|
|
|
2023-09-17 18:42:21 +03:00
|
|
|
// Attempt to setup new settings or restore legacy settings
|
|
|
|
// The settings include the accounts and folders saved in the config file
|
|
|
|
void setupOrRestoreSettings();
|
|
|
|
|
2013-07-04 21:59:40 +04:00
|
|
|
signals:
|
|
|
|
void folderRemoved();
|
2022-10-24 17:00:50 +03:00
|
|
|
void folderStateChanged(OCC::Folder *);
|
2019-12-21 05:04:31 +03:00
|
|
|
void isShowingSettingsDialog();
|
2013-07-04 21:59:40 +04:00
|
|
|
|
2011-09-26 17:00:12 +04:00
|
|
|
protected slots:
|
2015-02-19 18:54:34 +03:00
|
|
|
void slotParseMessage(const QString &, QObject *);
|
2013-07-05 15:14:48 +04:00
|
|
|
void slotCheckConnection();
|
2023-01-27 14:00:40 +03:00
|
|
|
void slotUseMonoIconsChanged(bool);
|
2013-09-18 16:11:19 +04:00
|
|
|
void slotCleanup();
|
2022-10-24 17:00:50 +03:00
|
|
|
void slotAccountStateAdded(OCC::AccountState *accountState);
|
|
|
|
void slotAccountStateRemoved(OCC::AccountState *accountState);
|
2015-11-23 23:47:30 +03:00
|
|
|
void slotSystemOnlineConfigurationChanged(QNetworkConfiguration);
|
2019-12-21 05:04:31 +03:00
|
|
|
void slotGuiIsShowingSettings();
|
2013-11-23 03:14:02 +04:00
|
|
|
|
2011-02-17 02:21:45 +03:00
|
|
|
private:
|
2013-01-29 08:19:14 +04:00
|
|
|
void setHelp();
|
2012-06-15 15:36:38 +04:00
|
|
|
|
2022-07-19 13:05:20 +03:00
|
|
|
void handleEditLocallyFromOptions();
|
|
|
|
|
2023-09-17 19:45:28 +03:00
|
|
|
AccountManager::AccountsRestoreResult restoreLegacyAccount();
|
2023-09-17 12:54:44 +03:00
|
|
|
void createConfigFile();
|
2023-09-20 17:34:53 +03:00
|
|
|
|
2018-05-02 16:40:54 +03:00
|
|
|
/**
|
|
|
|
* Maybe a newer version of the client was used with this config file:
|
|
|
|
* if so, backup, confirm with user and remove the config that can't be read.
|
|
|
|
*/
|
2018-05-14 15:37:48 +03:00
|
|
|
bool configVersionMigration();
|
2018-05-02 16:40:54 +03:00
|
|
|
|
2013-10-01 15:52:07 +04:00
|
|
|
QPointer<ownCloudGui> _gui;
|
2011-04-04 14:23:30 +04:00
|
|
|
|
2012-02-16 13:42:44 +04:00
|
|
|
Theme *_theme;
|
2013-08-02 13:33:45 +04:00
|
|
|
|
2023-02-06 12:38:59 +03:00
|
|
|
bool _helpOnly = false;
|
|
|
|
bool _versionOnly = false;
|
2013-07-31 00:22:43 +04:00
|
|
|
|
2015-09-28 23:51:16 +03:00
|
|
|
QElapsedTimer _startedAt;
|
|
|
|
|
2013-10-02 17:28:33 +04:00
|
|
|
// options from command line:
|
2023-02-06 12:38:59 +03:00
|
|
|
bool _showLogWindow = false;
|
2019-11-28 13:57:51 +03:00
|
|
|
bool _quitInstance = false;
|
2013-10-02 17:28:33 +04:00
|
|
|
QString _logFile;
|
|
|
|
QString _logDir;
|
2023-02-06 12:38:59 +03:00
|
|
|
int _logExpire = 0;
|
|
|
|
bool _logFlush = false;
|
2023-06-06 15:44:17 +03:00
|
|
|
bool _logDebug = false;
|
2023-02-06 12:38:59 +03:00
|
|
|
bool _userTriggeredConnect = false;
|
|
|
|
bool _debugMode = false;
|
|
|
|
bool _backgroundMode = false;
|
2022-07-19 13:05:20 +03:00
|
|
|
QUrl _editFileLocallyUrl;
|
2013-10-02 17:28:33 +04:00
|
|
|
|
2014-01-16 15:07:58 +04:00
|
|
|
ClientProxy _proxy;
|
|
|
|
|
2015-11-23 23:47:30 +03:00
|
|
|
QNetworkConfigurationManager _networkConfigurationManager;
|
2014-04-19 11:45:54 +04:00
|
|
|
QTimer _checkConnectionTimer;
|
|
|
|
|
2023-02-01 22:56:34 +03:00
|
|
|
QString _overrideServerUrl;
|
|
|
|
QString _overrideLocalDir;
|
|
|
|
|
2015-03-12 18:49:47 +03:00
|
|
|
#if defined(WITH_CRASHREPORTER)
|
|
|
|
QScopedPointer<CrashReporter::Handler> _crashHandler;
|
|
|
|
#endif
|
2015-01-08 18:52:23 +03:00
|
|
|
QScopedPointer<FolderMan> _folderManager;
|
2022-11-30 19:11:52 +03:00
|
|
|
#if defined(Q_OS_WIN)
|
2022-07-04 15:36:06 +03:00
|
|
|
QScopedPointer<ShellExtensionsServer> _shellExtensionsServer;
|
2022-11-30 19:11:52 +03:00
|
|
|
#elif defined(Q_OS_MACOS)
|
|
|
|
QScopedPointer<Mac::FileProvider> _fileProvider;
|
2022-07-04 15:36:06 +03:00
|
|
|
#endif
|
2011-02-17 02:21:45 +03:00
|
|
|
};
|
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
} // namespace OCC
|
2011-02-17 02:21:45 +03:00
|
|
|
|
|
|
|
#endif // APPLICATION_H
|