mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Added freedesktop DBus, fixed codestyle
This commit is contained in:
parent
289e98ed5b
commit
1b7b2ff456
@ -222,9 +222,16 @@ target_link_libraries(keepassx_core
|
||||
${GCRYPT_LIBRARIES}
|
||||
${GPGERROR_LIBRARIES}
|
||||
${ZLIB_LIBRARIES})
|
||||
|
||||
if(APPLE)
|
||||
target_link_libraries(keepassx_core "-framework Foundation")
|
||||
endif()
|
||||
if (UNIX AND NOT APPLE)
|
||||
target_link_libraries(keepassx_core Qt5::DBus)
|
||||
endif()
|
||||
if(MINGW)
|
||||
target_link_libraries(keepassx_core Wtsapi32.lib)
|
||||
endif()
|
||||
|
||||
if(MINGW)
|
||||
include(GenerateProductVersion)
|
||||
|
@ -119,6 +119,7 @@ void Config::init(const QString& fileName)
|
||||
m_defaults.insert("security/lockdatabaseidle", false);
|
||||
m_defaults.insert("security/lockdatabaseidlesec", 240);
|
||||
m_defaults.insert("security/lockdatabaseminimize", false);
|
||||
m_defaults.insert("security/lockdatabasescreenlock", true);
|
||||
m_defaults.insert("security/passwordsrepeat", false);
|
||||
m_defaults.insert("security/passwordscleartext", false);
|
||||
m_defaults.insert("security/autotypeask", true);
|
||||
|
@ -9,6 +9,15 @@ ScreenLockListenerDBus::ScreenLockListenerDBus(QWidget *parent):
|
||||
{
|
||||
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
||||
QDBusConnection systemBus = QDBusConnection::systemBus();
|
||||
|
||||
sessionBus.connect(
|
||||
"org.freedesktop.ScreenSaver", // service
|
||||
"/org/freedesktop/ScreenSaver", // path
|
||||
"org.freedesktop.ScreenSaver", // interface
|
||||
"ActiveChanged", // signal name
|
||||
this, //receiver
|
||||
SLOT(freedesktopScreenSaver(bool)));
|
||||
|
||||
sessionBus.connect(
|
||||
"org.gnome.SessionManager", // service
|
||||
"/org/gnome/SessionManager/Presence", // path
|
||||
@ -36,14 +45,14 @@ ScreenLockListenerDBus::ScreenLockListenerDBus(QWidget *parent):
|
||||
|
||||
void ScreenLockListenerDBus::gnomeSessionStatusChanged(uint status)
|
||||
{
|
||||
if(status != 0){
|
||||
if (status != 0) {
|
||||
Q_EMIT screenLocked();
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenLockListenerDBus::logindPrepareForSleep(bool beforeSleep)
|
||||
{
|
||||
if(beforeSleep){
|
||||
if (beforeSleep) {
|
||||
Q_EMIT screenLocked();
|
||||
}
|
||||
}
|
||||
@ -52,3 +61,10 @@ void ScreenLockListenerDBus::unityLocked()
|
||||
{
|
||||
Q_EMIT screenLocked();
|
||||
}
|
||||
|
||||
void ScreenLockListenerDBus::freedesktopScreenSaver(bool status)
|
||||
{
|
||||
if (status) {
|
||||
Q_EMIT screenLocked();
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ private Q_SLOTS:
|
||||
void gnomeSessionStatusChanged(uint status);
|
||||
void logindPrepareForSleep(bool beforeSleep);
|
||||
void unityLocked();
|
||||
void freedesktopScreenSaver(bool status);
|
||||
};
|
||||
|
||||
#endif // SCREENLOCKLISTENERDBUS_H
|
||||
|
@ -3,29 +3,33 @@
|
||||
#include <QMutexLocker>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
ScreenLockListenerMac* ScreenLockListenerMac::instance(){
|
||||
ScreenLockListenerMac* ScreenLockListenerMac::instance()
|
||||
{
|
||||
static QMutex mutex;
|
||||
QMutexLocker lock(&mutex);
|
||||
|
||||
static ScreenLockListenerMac* m_ptr=NULL;
|
||||
if (m_ptr==NULL){
|
||||
if (m_ptr == NULL) {
|
||||
m_ptr = new ScreenLockListenerMac();
|
||||
}
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
void ScreenLockListenerMac::notificationCenterCallBack(CFNotificationCenterRef /*center*/, void */*observer*/,
|
||||
CFNotificationName /*name*/, const void */*object*/, CFDictionaryRef /*userInfo*/){
|
||||
CFNotificationName /*name*/, const void */*object*/, CFDictionaryRef /*userInfo*/)
|
||||
{
|
||||
instance()->onSignalReception();
|
||||
}
|
||||
|
||||
ScreenLockListenerMac::ScreenLockListenerMac(QWidget* parent):
|
||||
ScreenLockListenerPrivate(parent){
|
||||
ScreenLockListenerMac::ScreenLockListenerMac(QWidget* parent)
|
||||
: ScreenLockListenerPrivate(parent)
|
||||
{
|
||||
CFNotificationCenterRef distCenter;
|
||||
CFStringRef screenIsLockedSignal = CFSTR("com.apple.screenIsLocked");
|
||||
distCenter = CFNotificationCenterGetDistributedCenter();
|
||||
if (NULL == distCenter)
|
||||
if (NULL == distCenter) {
|
||||
return;
|
||||
}
|
||||
|
||||
CFNotificationCenterAddObserver(
|
||||
distCenter,
|
||||
|
@ -9,11 +9,13 @@
|
||||
#include "ScreenLockListenerWin.h"
|
||||
#endif
|
||||
|
||||
ScreenLockListenerPrivate::ScreenLockListenerPrivate(QWidget* parent):
|
||||
QObject(parent){
|
||||
ScreenLockListenerPrivate::ScreenLockListenerPrivate(QWidget* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
ScreenLockListenerPrivate* ScreenLockListenerPrivate::instance(QWidget* parent){
|
||||
ScreenLockListenerPrivate* ScreenLockListenerPrivate::instance(QWidget* parent)
|
||||
{
|
||||
#if defined(Q_OS_OSX)
|
||||
Q_UNUSED(parent);
|
||||
return ScreenLockListenerMac::instance();
|
||||
|
@ -8,11 +8,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) :
|
||||
ScreenLockListenerPrivate(parent),
|
||||
QAbstractNativeEventFilter()
|
||||
ScreenLockListenerWin::ScreenLockListenerWin(QWidget *parent)
|
||||
: ScreenLockListenerPrivate(parent)
|
||||
, QAbstractNativeEventFilter()
|
||||
{
|
||||
Q_ASSERT(parent!=NULL);
|
||||
Q_ASSERT(parent != NULL);
|
||||
// On windows, we need to register for platform specific messages and
|
||||
// install a message handler for them
|
||||
QCoreApplication::instance()->installNativeEventFilter(this);
|
||||
@ -26,7 +26,7 @@ ScreenLockListenerWin::ScreenLockListenerWin(QWidget *parent) :
|
||||
// This call requests a notification for session changes
|
||||
if (!WTSRegisterSessionNotification(
|
||||
reinterpret_cast<HWND>(parent->winId()),
|
||||
NOTIFY_FOR_THIS_SESSION)){
|
||||
NOTIFY_FOR_THIS_SESSION)) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,31 +35,31 @@ ScreenLockListenerWin::~ScreenLockListenerWin()
|
||||
HWND h= reinterpret_cast<HWND>(static_cast<QWidget*>(parent())->winId());
|
||||
WTSUnRegisterSessionNotification(h);
|
||||
|
||||
if(m_powernotificationhandle){
|
||||
if (m_powernotificationhandle) {
|
||||
UnregisterPowerSettingNotification(reinterpret_cast<HPOWERNOTIFY>(m_powernotificationhandle));
|
||||
}
|
||||
}
|
||||
|
||||
bool ScreenLockListenerWin::nativeEventFilter(const QByteArray &eventType, void *message, long *)
|
||||
{
|
||||
if(eventType == "windows_generic_MSG" || eventType == "windows_dispatcher_MSG"){
|
||||
if (eventType == "windows_generic_MSG" || eventType == "windows_dispatcher_MSG") {
|
||||
MSG* m = static_cast<MSG *>(message);
|
||||
if(m->message == WM_POWERBROADCAST){
|
||||
if (m->message == WM_POWERBROADCAST) {
|
||||
const POWERBROADCAST_SETTING* setting = reinterpret_cast<const POWERBROADCAST_SETTING*>(m->lParam);
|
||||
if (setting->PowerSetting == GUID_LIDSWITCH_STATE_CHANGE){
|
||||
if (setting->PowerSetting == GUID_LIDSWITCH_STATE_CHANGE) {
|
||||
const DWORD* state = reinterpret_cast<const DWORD*>(&setting->Data);
|
||||
if (*state == 0){
|
||||
if (*state == 0) {
|
||||
Q_EMIT screenLocked();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(m->message == WM_WTSSESSION_CHANGE){
|
||||
if (m->wParam==WTS_CONSOLE_DISCONNECT){
|
||||
if (m->message == WM_WTSSESSION_CHANGE) {
|
||||
if (m->wParam == WTS_CONSOLE_DISCONNECT) {
|
||||
Q_EMIT screenLocked();
|
||||
return true;
|
||||
}
|
||||
if (m->wParam==WTS_SESSION_LOCK){
|
||||
if (m->wParam == WTS_SESSION_LOCK) {
|
||||
Q_EMIT screenLocked();
|
||||
return true;
|
||||
}
|
||||
|
@ -123,6 +123,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="lockDatabaseOnScreenLockCheckBox">
|
||||
<property name="text">
|
||||
<string>Lock databases when session is locked or lid is closed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -142,13 +149,6 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="lockDatabaseOnScreenLockCheckBox">
|
||||
<property name="text">
|
||||
<string>Lock databases when session is locked or lid is closed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
Loading…
Reference in New Issue
Block a user