mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-17 21:04:19 -05:00
Add file header, use nullptr instead of NULL, fix code style
This commit is contained in:
parent
3218cb9ace
commit
533136fb0e
@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.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 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/>.
|
||||
*/
|
||||
|
||||
#include "ScreenLockListener.h"
|
||||
#include "ScreenLockListenerPrivate.h"
|
||||
|
||||
|
@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.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 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/>.
|
||||
*/
|
||||
|
||||
#ifndef SCREENLOCKLISTENER_H
|
||||
#define SCREENLOCKLISTENER_H
|
||||
#include <QWidget>
|
||||
@ -8,7 +25,7 @@ class ScreenLockListener : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ScreenLockListener(QWidget* parent=NULL);
|
||||
ScreenLockListener(QWidget* parent = nullptr);
|
||||
~ScreenLockListener();
|
||||
|
||||
Q_SIGNALS:
|
||||
|
@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.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 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/>.
|
||||
*/
|
||||
|
||||
#include "ScreenLockListenerDBus.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
|
@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.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 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/>.
|
||||
*/
|
||||
|
||||
#ifndef SCREENLOCKLISTENERDBUS_H
|
||||
#define SCREENLOCKLISTENERDBUS_H
|
||||
#include <QObject>
|
||||
|
@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.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 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/>.
|
||||
*/
|
||||
|
||||
#include "ScreenLockListenerMac.h"
|
||||
|
||||
#include <QMutexLocker>
|
||||
@ -8,8 +25,8 @@ ScreenLockListenerMac* ScreenLockListenerMac::instance()
|
||||
static QMutex mutex;
|
||||
QMutexLocker lock(&mutex);
|
||||
|
||||
static ScreenLockListenerMac* m_ptr=NULL;
|
||||
if (m_ptr == NULL) {
|
||||
static ScreenLockListenerMac* m_ptr = nullptr;
|
||||
if (m_ptr == nullptr) {
|
||||
m_ptr = new ScreenLockListenerMac();
|
||||
}
|
||||
return m_ptr;
|
||||
@ -27,7 +44,7 @@ ScreenLockListenerMac::ScreenLockListenerMac(QWidget* parent)
|
||||
CFNotificationCenterRef distCenter;
|
||||
CFStringRef screenIsLockedSignal = CFSTR("com.apple.screenIsLocked");
|
||||
distCenter = CFNotificationCenterGetDistributedCenter();
|
||||
if (NULL == distCenter) {
|
||||
if (nullptr == distCenter) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -35,7 +52,7 @@ ScreenLockListenerMac::ScreenLockListenerMac(QWidget* parent)
|
||||
distCenter,
|
||||
this, &ScreenLockListenerMac::notificationCenterCallBack,
|
||||
screenIsLockedSignal,
|
||||
NULL,
|
||||
nullptr,
|
||||
CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.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 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/>.
|
||||
*/
|
||||
|
||||
#ifndef SCREENLOCKLISTENERMAC_H
|
||||
#define SCREENLOCKLISTENERMAC_H
|
||||
#include <QObject>
|
||||
@ -16,7 +33,7 @@ public:
|
||||
CFNotificationName /*name*/, const void */*object*/, CFDictionaryRef /*userInfo*/);
|
||||
|
||||
private:
|
||||
ScreenLockListenerMac(QWidget* parent=NULL);
|
||||
ScreenLockListenerMac(QWidget* parent = nullptr);
|
||||
void onSignalReception();
|
||||
|
||||
};
|
||||
|
@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.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 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/>.
|
||||
*/
|
||||
|
||||
#include "ScreenLockListenerPrivate.h"
|
||||
#if defined(Q_OS_OSX)
|
||||
#include "ScreenLockListenerMac.h"
|
||||
|
@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.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 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/>.
|
||||
*/
|
||||
|
||||
#ifndef SCREENLOCKLISTENERPRIVATE_H
|
||||
#define SCREENLOCKLISTENERPRIVATE_H
|
||||
#include <QObject>
|
||||
@ -7,10 +24,10 @@ class ScreenLockListenerPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static ScreenLockListenerPrivate* instance(QWidget *parent = 0);
|
||||
static ScreenLockListenerPrivate* instance(QWidget* parent = 0);
|
||||
|
||||
protected:
|
||||
ScreenLockListenerPrivate(QWidget *parent = 0);
|
||||
ScreenLockListenerPrivate(QWidget* parent = 0);
|
||||
|
||||
Q_SIGNALS:
|
||||
void screenLocked();
|
||||
|
@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.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 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/>.
|
||||
*/
|
||||
|
||||
#include "ScreenLockListenerWin.h"
|
||||
#include <QApplication>
|
||||
#include <windows.h>
|
||||
@ -8,11 +25,11 @@
|
||||
* See https://msdn.microsoft.com/en-us/library/aa383841(v=vs.85).aspx
|
||||
* See https://blogs.msdn.microsoft.com/oldnewthing/20060104-50/?p=32783
|
||||
*/
|
||||
ScreenLockListenerWin::ScreenLockListenerWin(QWidget *parent)
|
||||
ScreenLockListenerWin::ScreenLockListenerWin(QWidget* parent)
|
||||
: ScreenLockListenerPrivate(parent)
|
||||
, QAbstractNativeEventFilter()
|
||||
{
|
||||
Q_ASSERT(parent != NULL);
|
||||
Q_ASSERT(parent != nullptr);
|
||||
// On windows, we need to register for platform specific messages and
|
||||
// install a message handler for them
|
||||
QCoreApplication::instance()->installNativeEventFilter(this);
|
||||
@ -21,7 +38,7 @@ ScreenLockListenerWin::ScreenLockListenerWin(QWidget *parent)
|
||||
HPOWERNOTIFY hPnotify = RegisterPowerSettingNotification(
|
||||
reinterpret_cast<HWND>(parent->winId()),
|
||||
&GUID_LIDSWITCH_STATE_CHANGE, DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||
m_powernotificationhandle = reinterpret_cast<void*>(hPnotify);
|
||||
m_powerNotificationHandle = reinterpret_cast<void*>(hPnotify);
|
||||
|
||||
// This call requests a notification for session changes
|
||||
if (!WTSRegisterSessionNotification(
|
||||
@ -40,10 +57,10 @@ ScreenLockListenerWin::~ScreenLockListenerWin()
|
||||
}
|
||||
}
|
||||
|
||||
bool ScreenLockListenerWin::nativeEventFilter(const QByteArray &eventType, void *message, long *)
|
||||
bool ScreenLockListenerWin::nativeEventFilter(const QByteArray &eventType, void* message, long *)
|
||||
{
|
||||
if (eventType == "windows_generic_MSG" || eventType == "windows_dispatcher_MSG") {
|
||||
MSG* m = static_cast<MSG *>(message);
|
||||
MSG* m = static_cast<MSG*>(message);
|
||||
if (m->message == WM_POWERBROADCAST) {
|
||||
if (m->wParam == PBT_POWERSETTINGCHANGE) {
|
||||
const POWERBROADCAST_SETTING* setting = reinterpret_cast<const POWERBROADCAST_SETTING*>(m->lParam);
|
||||
|
@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.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 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/>.
|
||||
*/
|
||||
|
||||
#ifndef SCREENLOCKLISTENERWIN_H
|
||||
#define SCREENLOCKLISTENERWIN_H
|
||||
#include <QObject>
|
||||
@ -10,12 +27,12 @@ class ScreenLockListenerWin : public ScreenLockListenerPrivate, public QAbstract
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ScreenLockListenerWin(QWidget *parent = 0);
|
||||
explicit ScreenLockListenerWin(QWidget* parent = 0);
|
||||
~ScreenLockListenerWin();
|
||||
virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE;
|
||||
virtual bool nativeEventFilter(const QByteArray &eventType, void* message, long *) override;
|
||||
|
||||
private:
|
||||
void * m_powernotificationhandle;
|
||||
void* m_powerNotificationHandle ;
|
||||
};
|
||||
|
||||
#endif // SCREENLOCKLISTENERWIN_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user