2012-05-10 10:42:17 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Tobias Tangemann
|
2012-07-12 16:33:20 -04:00
|
|
|
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
|
2017-06-09 17:40:36 -04:00
|
|
|
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
|
2012-05-10 10:42:17 -04:00
|
|
|
*
|
|
|
|
* 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 or (at your option)
|
|
|
|
* version 3 of the License.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2012-05-17 18:35:24 -04:00
|
|
|
#ifndef KEEPASSX_APPLICATION_H
|
|
|
|
#define KEEPASSX_APPLICATION_H
|
|
|
|
|
2013-10-03 09:18:16 -04:00
|
|
|
#include <QApplication>
|
2016-07-25 00:41:13 -04:00
|
|
|
#include <QtNetwork/QLocalServer>
|
2012-05-10 10:42:17 -04:00
|
|
|
|
2018-10-30 08:46:12 -04:00
|
|
|
#if defined(Q_OS_WIN) || (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
|
|
|
|
#include <QScopedPointer>
|
|
|
|
|
|
|
|
class OSEventFilter;
|
|
|
|
#endif
|
2018-09-29 13:00:47 -04:00
|
|
|
class QLockFile;
|
2017-01-17 18:15:33 -05:00
|
|
|
class QSocketNotifier;
|
|
|
|
|
2012-05-17 18:35:24 -04:00
|
|
|
class Application : public QApplication
|
2012-05-10 10:42:17 -04:00
|
|
|
{
|
2012-05-17 17:59:31 -04:00
|
|
|
Q_OBJECT
|
2012-05-10 10:42:17 -04:00
|
|
|
|
|
|
|
public:
|
2012-05-17 18:35:24 -04:00
|
|
|
Application(int& argc, char** argv);
|
2018-10-30 08:46:12 -04:00
|
|
|
~Application() override;
|
2012-05-10 10:42:17 -04:00
|
|
|
|
2015-07-24 12:28:12 -04:00
|
|
|
bool event(QEvent* event) override;
|
2016-07-25 00:41:13 -04:00
|
|
|
bool isAlreadyRunning() const;
|
2012-05-17 17:59:31 -04:00
|
|
|
|
2017-12-05 10:25:08 -05:00
|
|
|
bool sendFileNamesToRunningInstance(const QStringList& fileNames);
|
|
|
|
|
2017-03-10 09:58:42 -05:00
|
|
|
signals:
|
2012-05-21 16:11:26 -04:00
|
|
|
void openFile(const QString& filename);
|
2016-07-25 00:41:13 -04:00
|
|
|
void anotherInstanceStarted();
|
2017-12-05 10:25:08 -05:00
|
|
|
void applicationActivated();
|
|
|
|
void quitSignalReceived();
|
2015-10-10 11:00:50 -04:00
|
|
|
|
2017-03-10 09:58:42 -05:00
|
|
|
private slots:
|
2017-01-17 18:33:47 -05:00
|
|
|
#if defined(Q_OS_UNIX)
|
2017-01-17 18:15:33 -05:00
|
|
|
void quitBySignal();
|
2017-01-17 18:33:47 -05:00
|
|
|
#endif
|
2017-12-05 10:25:08 -05:00
|
|
|
void processIncomingConnection();
|
|
|
|
void socketReadyRead();
|
2017-01-17 18:15:33 -05:00
|
|
|
|
2017-01-17 18:33:47 -05:00
|
|
|
private:
|
2017-01-17 18:15:33 -05:00
|
|
|
#if defined(Q_OS_UNIX)
|
|
|
|
/**
|
|
|
|
* Register Unix signals such as SIGINT and SIGTERM for clean shutdown.
|
|
|
|
*/
|
|
|
|
void registerUnixSignals();
|
|
|
|
QSocketNotifier* m_unixSignalNotifier;
|
|
|
|
static void handleUnixSignal(int sig);
|
|
|
|
static int unixSignalSocket[2];
|
|
|
|
#endif
|
2017-09-13 22:54:30 -04:00
|
|
|
bool m_alreadyRunning;
|
|
|
|
QLockFile* m_lockFile;
|
|
|
|
QLocalServer m_lockServer;
|
2017-12-05 10:25:08 -05:00
|
|
|
QString m_socketName;
|
2018-10-30 08:46:12 -04:00
|
|
|
#if defined(Q_OS_WIN) || (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
|
|
|
|
QScopedPointer<OSEventFilter> m_osEventFilter;
|
|
|
|
#endif
|
2012-05-17 17:59:31 -04:00
|
|
|
};
|
2012-05-17 18:35:24 -04:00
|
|
|
|
|
|
|
#endif // KEEPASSX_APPLICATION_H
|