application.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. #ifndef APPLICATION_H
  15. #define APPLICATION_H
  16. #include <QApplication>
  17. #include <QPointer>
  18. #include <QQueue>
  19. #include <QTimer>
  20. #include <QElapsedTimer>
  21. #include <QNetworkConfigurationManager>
  22. #include "qtsingleapplication.h"
  23. #include "syncresult.h"
  24. #include "logbrowser.h"
  25. #include "owncloudgui.h"
  26. #include "connectionvalidator.h"
  27. #include "progressdispatcher.h"
  28. #include "clientproxy.h"
  29. #include "folderman.h"
  30. class QMessageBox;
  31. class QSystemTrayIcon;
  32. class QSocket;
  33. namespace CrashReporter {
  34. class Handler;
  35. }
  36. namespace OCC {
  37. Q_DECLARE_LOGGING_CATEGORY(lcApplication)
  38. class Theme;
  39. class Folder;
  40. class ShellExtensionsServer;
  41. class SslErrorDialog;
  42. /**
  43. * @brief The Application class
  44. * @ingroup gui
  45. */
  46. class Application : public SharedTools::QtSingleApplication
  47. {
  48. Q_OBJECT
  49. public:
  50. explicit Application(int &argc, char **argv);
  51. ~Application() override;
  52. bool giveHelp();
  53. void showHelp();
  54. void showHint(std::string errorHint);
  55. bool debugMode();
  56. [[nodiscard]] bool backgroundMode() const;
  57. bool versionOnly(); // only display the version?
  58. void showVersion();
  59. void showMainDialog();
  60. [[nodiscard]] ownCloudGui *gui() const;
  61. bool event(QEvent *event) override;
  62. public slots:
  63. // TODO: this should not be public
  64. void slotownCloudWizardDone(int);
  65. void slotCrash();
  66. /**
  67. * Will download a virtual file, and open the result.
  68. * The argument is the filename of the virtual file (including the extension)
  69. */
  70. void openVirtualFile(const QString &filename);
  71. /// Attempt to show() the tray icon again. Used if no systray was available initially.
  72. void tryTrayAgain();
  73. protected:
  74. void parseOptions(const QStringList &);
  75. void setupTranslations();
  76. void setupLogging();
  77. signals:
  78. void folderRemoved();
  79. void folderStateChanged(OCC::Folder *);
  80. void isShowingSettingsDialog();
  81. protected slots:
  82. void slotParseMessage(const QString &, QObject *);
  83. void slotCheckConnection();
  84. void slotCleanup();
  85. void slotAccountStateAdded(OCC::AccountState *accountState);
  86. void slotAccountStateRemoved(OCC::AccountState *accountState);
  87. void slotSystemOnlineConfigurationChanged(QNetworkConfiguration);
  88. void slotGuiIsShowingSettings();
  89. private:
  90. void setHelp();
  91. void handleEditLocallyFromOptions();
  92. /**
  93. * Maybe a newer version of the client was used with this config file:
  94. * if so, backup, confirm with user and remove the config that can't be read.
  95. */
  96. bool configVersionMigration();
  97. QPointer<ownCloudGui> _gui;
  98. Theme *_theme;
  99. bool _helpOnly;
  100. bool _versionOnly;
  101. QElapsedTimer _startedAt;
  102. // options from command line:
  103. bool _showLogWindow;
  104. bool _quitInstance = false;
  105. QString _logFile;
  106. QString _logDir;
  107. int _logExpire;
  108. bool _logFlush;
  109. bool _logDebug;
  110. bool _userTriggeredConnect;
  111. bool _debugMode;
  112. bool _backgroundMode;
  113. QUrl _editFileLocallyUrl;
  114. ClientProxy _proxy;
  115. QNetworkConfigurationManager _networkConfigurationManager;
  116. QTimer _checkConnectionTimer;
  117. #if defined(WITH_CRASHREPORTER)
  118. QScopedPointer<CrashReporter::Handler> _crashHandler;
  119. #endif
  120. QScopedPointer<FolderMan> _folderManager;
  121. #ifdef Q_OS_WIN
  122. QScopedPointer<ShellExtensionsServer> _shellExtensionsServer;
  123. #endif
  124. };
  125. } // namespace OCC
  126. #endif // APPLICATION_H