Add file header, use nullptr instead of NULL, fix code style

This commit is contained in:
thez3ro 2017-05-08 16:03:19 +02:00
parent 3218cb9ace
commit 533136fb0e
No known key found for this signature in database
GPG key ID: F628F9E41DD7C073
10 changed files with 186 additions and 16 deletions

View file

@ -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 "ScreenLockListener.h"
#include "ScreenLockListenerPrivate.h" #include "ScreenLockListenerPrivate.h"

View file

@ -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 #ifndef SCREENLOCKLISTENER_H
#define SCREENLOCKLISTENER_H #define SCREENLOCKLISTENER_H
#include <QWidget> #include <QWidget>
@ -8,7 +25,7 @@ class ScreenLockListener : public QObject {
Q_OBJECT Q_OBJECT
public: public:
ScreenLockListener(QWidget* parent=NULL); ScreenLockListener(QWidget* parent = nullptr);
~ScreenLockListener(); ~ScreenLockListener();
Q_SIGNALS: Q_SIGNALS:

View file

@ -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 "ScreenLockListenerDBus.h"
#include <QDBusConnection> #include <QDBusConnection>

View file

@ -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 #ifndef SCREENLOCKLISTENERDBUS_H
#define SCREENLOCKLISTENERDBUS_H #define SCREENLOCKLISTENERDBUS_H
#include <QObject> #include <QObject>

View file

@ -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 "ScreenLockListenerMac.h"
#include <QMutexLocker> #include <QMutexLocker>
@ -8,8 +25,8 @@ ScreenLockListenerMac* ScreenLockListenerMac::instance()
static QMutex mutex; static QMutex mutex;
QMutexLocker lock(&mutex); QMutexLocker lock(&mutex);
static ScreenLockListenerMac* m_ptr=NULL; static ScreenLockListenerMac* m_ptr = nullptr;
if (m_ptr == NULL) { if (m_ptr == nullptr) {
m_ptr = new ScreenLockListenerMac(); m_ptr = new ScreenLockListenerMac();
} }
return m_ptr; return m_ptr;
@ -27,7 +44,7 @@ ScreenLockListenerMac::ScreenLockListenerMac(QWidget* parent)
CFNotificationCenterRef distCenter; CFNotificationCenterRef distCenter;
CFStringRef screenIsLockedSignal = CFSTR("com.apple.screenIsLocked"); CFStringRef screenIsLockedSignal = CFSTR("com.apple.screenIsLocked");
distCenter = CFNotificationCenterGetDistributedCenter(); distCenter = CFNotificationCenterGetDistributedCenter();
if (NULL == distCenter) { if (nullptr == distCenter) {
return; return;
} }
@ -35,7 +52,7 @@ ScreenLockListenerMac::ScreenLockListenerMac(QWidget* parent)
distCenter, distCenter,
this, &ScreenLockListenerMac::notificationCenterCallBack, this, &ScreenLockListenerMac::notificationCenterCallBack,
screenIsLockedSignal, screenIsLockedSignal,
NULL, nullptr,
CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationSuspensionBehaviorDeliverImmediately);
} }

View file

@ -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 #ifndef SCREENLOCKLISTENERMAC_H
#define SCREENLOCKLISTENERMAC_H #define SCREENLOCKLISTENERMAC_H
#include <QObject> #include <QObject>
@ -16,7 +33,7 @@ public:
CFNotificationName /*name*/, const void */*object*/, CFDictionaryRef /*userInfo*/); CFNotificationName /*name*/, const void */*object*/, CFDictionaryRef /*userInfo*/);
private: private:
ScreenLockListenerMac(QWidget* parent=NULL); ScreenLockListenerMac(QWidget* parent = nullptr);
void onSignalReception(); void onSignalReception();
}; };

View file

@ -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" #include "ScreenLockListenerPrivate.h"
#if defined(Q_OS_OSX) #if defined(Q_OS_OSX)
#include "ScreenLockListenerMac.h" #include "ScreenLockListenerMac.h"

View file

@ -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 #ifndef SCREENLOCKLISTENERPRIVATE_H
#define SCREENLOCKLISTENERPRIVATE_H #define SCREENLOCKLISTENERPRIVATE_H
#include <QObject> #include <QObject>

View file

@ -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 "ScreenLockListenerWin.h"
#include <QApplication> #include <QApplication>
#include <windows.h> #include <windows.h>
@ -12,7 +29,7 @@ ScreenLockListenerWin::ScreenLockListenerWin(QWidget *parent)
: ScreenLockListenerPrivate(parent) : ScreenLockListenerPrivate(parent)
, QAbstractNativeEventFilter() , QAbstractNativeEventFilter()
{ {
Q_ASSERT(parent != NULL); Q_ASSERT(parent != nullptr);
// On windows, we need to register for platform specific messages and // On windows, we need to register for platform specific messages and
// install a message handler for them // install a message handler for them
QCoreApplication::instance()->installNativeEventFilter(this); QCoreApplication::instance()->installNativeEventFilter(this);
@ -21,7 +38,7 @@ ScreenLockListenerWin::ScreenLockListenerWin(QWidget *parent)
HPOWERNOTIFY hPnotify = RegisterPowerSettingNotification( HPOWERNOTIFY hPnotify = RegisterPowerSettingNotification(
reinterpret_cast<HWND>(parent->winId()), reinterpret_cast<HWND>(parent->winId()),
&GUID_LIDSWITCH_STATE_CHANGE, DEVICE_NOTIFY_WINDOW_HANDLE); &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 // This call requests a notification for session changes
if (!WTSRegisterSessionNotification( if (!WTSRegisterSessionNotification(

View file

@ -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 #ifndef SCREENLOCKLISTENERWIN_H
#define SCREENLOCKLISTENERWIN_H #define SCREENLOCKLISTENERWIN_H
#include <QObject> #include <QObject>
@ -12,10 +29,10 @@ class ScreenLockListenerWin : public ScreenLockListenerPrivate, public QAbstract
public: public:
explicit ScreenLockListenerWin(QWidget* parent = 0); explicit ScreenLockListenerWin(QWidget* parent = 0);
~ScreenLockListenerWin(); ~ScreenLockListenerWin();
virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE; virtual bool nativeEventFilter(const QByteArray &eventType, void* message, long *) override;
private: private:
void * m_powernotificationhandle; void* m_powerNotificationHandle ;
}; };
#endif // SCREENLOCKLISTENERWIN_H #endif // SCREENLOCKLISTENERWIN_H