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}
|
${GCRYPT_LIBRARIES}
|
||||||
${GPGERROR_LIBRARIES}
|
${GPGERROR_LIBRARIES}
|
||||||
${ZLIB_LIBRARIES})
|
${ZLIB_LIBRARIES})
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
target_link_libraries(keepassx_core "-framework Foundation")
|
||||||
|
endif()
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
target_link_libraries(keepassx_core Qt5::DBus)
|
target_link_libraries(keepassx_core Qt5::DBus)
|
||||||
endif()
|
endif()
|
||||||
|
if(MINGW)
|
||||||
|
target_link_libraries(keepassx_core Wtsapi32.lib)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(MINGW)
|
if(MINGW)
|
||||||
include(GenerateProductVersion)
|
include(GenerateProductVersion)
|
||||||
|
@ -119,6 +119,7 @@ void Config::init(const QString& fileName)
|
|||||||
m_defaults.insert("security/lockdatabaseidle", false);
|
m_defaults.insert("security/lockdatabaseidle", false);
|
||||||
m_defaults.insert("security/lockdatabaseidlesec", 240);
|
m_defaults.insert("security/lockdatabaseidlesec", 240);
|
||||||
m_defaults.insert("security/lockdatabaseminimize", false);
|
m_defaults.insert("security/lockdatabaseminimize", false);
|
||||||
|
m_defaults.insert("security/lockdatabasescreenlock", true);
|
||||||
m_defaults.insert("security/passwordsrepeat", false);
|
m_defaults.insert("security/passwordsrepeat", false);
|
||||||
m_defaults.insert("security/passwordscleartext", false);
|
m_defaults.insert("security/passwordscleartext", false);
|
||||||
m_defaults.insert("security/autotypeask", true);
|
m_defaults.insert("security/autotypeask", true);
|
||||||
|
@ -9,6 +9,15 @@ ScreenLockListenerDBus::ScreenLockListenerDBus(QWidget *parent):
|
|||||||
{
|
{
|
||||||
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
||||||
QDBusConnection systemBus = QDBusConnection::systemBus();
|
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(
|
sessionBus.connect(
|
||||||
"org.gnome.SessionManager", // service
|
"org.gnome.SessionManager", // service
|
||||||
"/org/gnome/SessionManager/Presence", // path
|
"/org/gnome/SessionManager/Presence", // path
|
||||||
@ -36,14 +45,14 @@ ScreenLockListenerDBus::ScreenLockListenerDBus(QWidget *parent):
|
|||||||
|
|
||||||
void ScreenLockListenerDBus::gnomeSessionStatusChanged(uint status)
|
void ScreenLockListenerDBus::gnomeSessionStatusChanged(uint status)
|
||||||
{
|
{
|
||||||
if(status != 0){
|
if (status != 0) {
|
||||||
Q_EMIT screenLocked();
|
Q_EMIT screenLocked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenLockListenerDBus::logindPrepareForSleep(bool beforeSleep)
|
void ScreenLockListenerDBus::logindPrepareForSleep(bool beforeSleep)
|
||||||
{
|
{
|
||||||
if(beforeSleep){
|
if (beforeSleep) {
|
||||||
Q_EMIT screenLocked();
|
Q_EMIT screenLocked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,3 +61,10 @@ void ScreenLockListenerDBus::unityLocked()
|
|||||||
{
|
{
|
||||||
Q_EMIT screenLocked();
|
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 gnomeSessionStatusChanged(uint status);
|
||||||
void logindPrepareForSleep(bool beforeSleep);
|
void logindPrepareForSleep(bool beforeSleep);
|
||||||
void unityLocked();
|
void unityLocked();
|
||||||
|
void freedesktopScreenSaver(bool status);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCREENLOCKLISTENERDBUS_H
|
#endif // SCREENLOCKLISTENERDBUS_H
|
||||||
|
@ -3,29 +3,33 @@
|
|||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
|
||||||
ScreenLockListenerMac* ScreenLockListenerMac::instance(){
|
ScreenLockListenerMac* ScreenLockListenerMac::instance()
|
||||||
|
{
|
||||||
static QMutex mutex;
|
static QMutex mutex;
|
||||||
QMutexLocker lock(&mutex);
|
QMutexLocker lock(&mutex);
|
||||||
|
|
||||||
static ScreenLockListenerMac* m_ptr=NULL;
|
static ScreenLockListenerMac* m_ptr=NULL;
|
||||||
if (m_ptr==NULL){
|
if (m_ptr == NULL) {
|
||||||
m_ptr = new ScreenLockListenerMac();
|
m_ptr = new ScreenLockListenerMac();
|
||||||
}
|
}
|
||||||
return m_ptr;
|
return m_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenLockListenerMac::notificationCenterCallBack(CFNotificationCenterRef /*center*/, void */*observer*/,
|
void ScreenLockListenerMac::notificationCenterCallBack(CFNotificationCenterRef /*center*/, void */*observer*/,
|
||||||
CFNotificationName /*name*/, const void */*object*/, CFDictionaryRef /*userInfo*/){
|
CFNotificationName /*name*/, const void */*object*/, CFDictionaryRef /*userInfo*/)
|
||||||
|
{
|
||||||
instance()->onSignalReception();
|
instance()->onSignalReception();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenLockListenerMac::ScreenLockListenerMac(QWidget* parent):
|
ScreenLockListenerMac::ScreenLockListenerMac(QWidget* parent)
|
||||||
ScreenLockListenerPrivate(parent){
|
: ScreenLockListenerPrivate(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 (NULL == distCenter) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CFNotificationCenterAddObserver(
|
CFNotificationCenterAddObserver(
|
||||||
distCenter,
|
distCenter,
|
||||||
|
@ -9,11 +9,13 @@
|
|||||||
#include "ScreenLockListenerWin.h"
|
#include "ScreenLockListenerWin.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ScreenLockListenerPrivate::ScreenLockListenerPrivate(QWidget* parent):
|
ScreenLockListenerPrivate::ScreenLockListenerPrivate(QWidget* parent)
|
||||||
QObject(parent){
|
: QObject(parent)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenLockListenerPrivate* ScreenLockListenerPrivate::instance(QWidget* parent){
|
ScreenLockListenerPrivate* ScreenLockListenerPrivate::instance(QWidget* parent)
|
||||||
|
{
|
||||||
#if defined(Q_OS_OSX)
|
#if defined(Q_OS_OSX)
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
return ScreenLockListenerMac::instance();
|
return ScreenLockListenerMac::instance();
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
* See https://msdn.microsoft.com/en-us/library/aa383841(v=vs.85).aspx
|
* See https://msdn.microsoft.com/en-us/library/aa383841(v=vs.85).aspx
|
||||||
* See https://blogs.msdn.microsoft.com/oldnewthing/20060104-50/?p=32783
|
* See https://blogs.msdn.microsoft.com/oldnewthing/20060104-50/?p=32783
|
||||||
*/
|
*/
|
||||||
ScreenLockListenerWin::ScreenLockListenerWin(QWidget *parent) :
|
ScreenLockListenerWin::ScreenLockListenerWin(QWidget *parent)
|
||||||
ScreenLockListenerPrivate(parent),
|
: ScreenLockListenerPrivate(parent)
|
||||||
QAbstractNativeEventFilter()
|
, QAbstractNativeEventFilter()
|
||||||
{
|
{
|
||||||
Q_ASSERT(parent!=NULL);
|
Q_ASSERT(parent != NULL);
|
||||||
// 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);
|
||||||
@ -26,7 +26,7 @@ ScreenLockListenerWin::ScreenLockListenerWin(QWidget *parent) :
|
|||||||
// This call requests a notification for session changes
|
// This call requests a notification for session changes
|
||||||
if (!WTSRegisterSessionNotification(
|
if (!WTSRegisterSessionNotification(
|
||||||
reinterpret_cast<HWND>(parent->winId()),
|
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());
|
HWND h= reinterpret_cast<HWND>(static_cast<QWidget*>(parent())->winId());
|
||||||
WTSUnRegisterSessionNotification(h);
|
WTSUnRegisterSessionNotification(h);
|
||||||
|
|
||||||
if(m_powernotificationhandle){
|
if (m_powernotificationhandle) {
|
||||||
UnregisterPowerSettingNotification(reinterpret_cast<HPOWERNOTIFY>(m_powernotificationhandle));
|
UnregisterPowerSettingNotification(reinterpret_cast<HPOWERNOTIFY>(m_powernotificationhandle));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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"){
|
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->message == WM_POWERBROADCAST) {
|
||||||
const POWERBROADCAST_SETTING* setting = reinterpret_cast<const POWERBROADCAST_SETTING*>(m->lParam);
|
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);
|
const DWORD* state = reinterpret_cast<const DWORD*>(&setting->Data);
|
||||||
if (*state == 0){
|
if (*state == 0) {
|
||||||
Q_EMIT screenLocked();
|
Q_EMIT screenLocked();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(m->message == WM_WTSSESSION_CHANGE){
|
if (m->message == WM_WTSSESSION_CHANGE) {
|
||||||
if (m->wParam==WTS_CONSOLE_DISCONNECT){
|
if (m->wParam == WTS_CONSOLE_DISCONNECT) {
|
||||||
Q_EMIT screenLocked();
|
Q_EMIT screenLocked();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (m->wParam==WTS_SESSION_LOCK){
|
if (m->wParam == WTS_SESSION_LOCK) {
|
||||||
Q_EMIT screenLocked();
|
Q_EMIT screenLocked();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -123,6 +123,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -142,13 +149,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
Loading…
Reference in New Issue
Block a user