1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 17:52:10 +02:00

GnomeKeyring: Port to Qt6

Limit the timestamp to 32 bits.

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2023-11-13 22:02:14 +01:00
parent 4f953aa0aa
commit 1e9b37bccb
Signed by: SGOrava
GPG Key ID: 13660A3F1D9F093B
2 changed files with 14 additions and 3 deletions

View File

@ -126,7 +126,7 @@ endif()
# Optional: GnomeKeyring # Optional: GnomeKeyring
find_package(PkgConfig) find_package(PkgConfig)
if (PKG_CONFIG_FOUND) if (PKG_CONFIG_FOUND)
option(BUILD_KEYRING "Gnome keyring password plugin" OFF) option(BUILD_KEYRING "Gnome keyring password plugin" ON)
if (BUILD_KEYRING) if (BUILD_KEYRING)
pkg_check_modules(GNOME_KEYRING IMPORTED_TARGET gnome-keyring-1 ) pkg_check_modules(GNOME_KEYRING IMPORTED_TARGET gnome-keyring-1 )
endif() endif()

View File

@ -24,6 +24,17 @@ extern "C" {
#include "gnome-keyring.h" #include "gnome-keyring.h"
} }
// TODO QT6 - should we just start storing timestamps as 64-bit instead?
static uint Q_DATETIME_TOTIME_T(const QDateTime &dateTime)
{
if (!dateTime.isValid())
return uint(-1);
qint64 retval = dateTime.toMSecsSinceEpoch() / 1000;
if (quint64(retval) >= Q_UINT64_C(0xFFFFFFFF))
return uint(-1);
return uint(retval);
}
static PasswordEntry createEntry(GnomeKeyringFound* item) static PasswordEntry createEntry(GnomeKeyringFound* item)
{ {
PasswordEntry entry; PasswordEntry entry;
@ -141,7 +152,7 @@ void GnomeKeyringPasswordBackend::addEntry(const PasswordEntry &entry)
initialize(); initialize();
PasswordEntry stored = entry; PasswordEntry stored = entry;
stored.updated = QDateTime::currentDateTime().toTime_t(); stored.updated = Q_DATETIME_TOTIME_T(QDateTime::currentDateTime());
storeEntry(stored); storeEntry(stored);
@ -201,7 +212,7 @@ void GnomeKeyringPasswordBackend::updateLastUsed(PasswordEntry &entry)
{ {
initialize(); initialize();
entry.updated = QDateTime::currentDateTime().toTime_t(); entry.updated = Q_DATETIME_TOTIME_T(QDateTime::currentDateTime());
GnomeKeyringAttributeList* attributes = createAttributes(entry); GnomeKeyringAttributeList* attributes = createAttributes(entry);