2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2015, 2019 Vladimir Golovnev <glassez@yandex.ru>
4 * Copyright (C) 2006 Christophe Dumez
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * In addition, as a special exception, the copyright holders give permission to
21 * link this program with the OpenSSL project's "OpenSSL" library (or with
22 * modified versions of it that use the same license as the "OpenSSL" library),
23 * and distribute the linked executables. You must obey the GNU General Public
24 * License in all respects for all of the code used other than "OpenSSL". If you
25 * modify file(s), you may extend this exception to your version of the file(s),
26 * but you are not obligated to do so. If you do not wish to do so, delete this
27 * exception statement from your version.
33 #include <QStringList>
34 #include <QTranslator>
37 #include <QApplication>
38 using BaseApplication
= QApplication
;
42 class QSessionManager
;
46 #include <QCoreApplication>
47 using BaseApplication
= QCoreApplication
;
50 #include "base/path.h"
51 #include "base/settingvalue.h"
52 #include "base/types.h"
53 #include "cmdoptions.h"
59 class ApplicationInstanceManager
;
73 class Application final
: public BaseApplication
76 Q_DISABLE_COPY_MOVE(Application
)
79 Application(int &argc
, char **argv
);
80 ~Application() override
;
83 int exec(const QStringList
¶ms
);
84 bool sendParams(const QStringList
¶ms
);
87 QPointer
<MainWindow
> mainWindow();
90 const QBtCommandLineParameters
&commandLineArgs() const;
93 int memoryWorkingSetLimit() const;
94 void setMemoryWorkingSetLimit(int size
);
97 // FileLogger properties
98 bool isFileLoggerEnabled() const;
99 void setFileLoggerEnabled(bool value
);
100 Path
fileLoggerPath() const;
101 void setFileLoggerPath(const Path
&path
);
102 bool isFileLoggerBackup() const;
103 void setFileLoggerBackup(bool value
);
104 bool isFileLoggerDeleteOld() const;
105 void setFileLoggerDeleteOld(bool value
);
106 int fileLoggerMaxSize() const;
107 void setFileLoggerMaxSize(int bytes
);
108 int fileLoggerAge() const;
109 void setFileLoggerAge(int value
);
110 int fileLoggerAgeType() const;
111 void setFileLoggerAgeType(int value
);
116 bool event(QEvent
*) override
;
121 void processMessage(const QString
&message
);
122 void torrentFinished(BitTorrent::Torrent
*const torrent
);
123 void allTorrentsFinished();
125 #if (!defined(DISABLE_GUI) && defined(Q_OS_WIN))
126 void shutdownCleanup(QSessionManager
&manager
);
131 void applyMemoryWorkingSetLimit();
133 void initializeTranslation();
134 void processParams(const QStringList
¶ms
);
135 void runExternalProgram(const BitTorrent::Torrent
*torrent
) const;
136 void sendNotificationEmail(const BitTorrent::Torrent
*torrent
);
138 ApplicationInstanceManager
*m_instanceManager
= nullptr;
140 ShutdownDialogAction m_shutdownAct
;
141 QBtCommandLineParameters m_commandLineArgs
;
144 QPointer
<MainWindow
> m_window
;
147 #ifndef DISABLE_WEBUI
148 WebUI
*m_webui
= nullptr;
152 QPointer
<FileLogger
> m_fileLogger
;
154 QTranslator m_qtTranslator
;
155 QTranslator m_translator
;
156 QStringList m_paramsQueue
;
159 SettingValue
<int> m_storeMemoryWorkingSetLimit
;
161 SettingValue
<bool> m_storeFileLoggerEnabled
;
162 SettingValue
<bool> m_storeFileLoggerBackup
;
163 SettingValue
<bool> m_storeFileLoggerDeleteOld
;
164 SettingValue
<int> m_storeFileLoggerMaxSize
;
165 SettingValue
<int> m_storeFileLoggerAge
;
166 SettingValue
<int> m_storeFileLoggerAgeType
;
167 SettingValue
<Path
> m_storeFileLoggerPath
;