0
0
mirror of https://github.com/keepassxreboot/keepassxc.git synced 2024-09-20 04:12:15 +02:00

Merge branch '2.0'

This commit is contained in:
Felix Geyer 2015-09-26 11:43:27 +02:00
commit 3b2a39fd38
16 changed files with 73 additions and 72 deletions

View File

@ -31,7 +31,6 @@ include(CheckCXXSourceCompiles)
option(WITH_TESTS "Enable building of unit tests" ON)
option(WITH_GUI_TESTS "Enable building of GUI tests" OFF)
option(WITH_LTO "Enable Link Time Optimization (LTO)" OFF)
set(KEEPASSX_VERSION "2.0 beta 2")
set(KEEPASSX_VERSION_NUM "1.9.92")
@ -100,20 +99,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,relro")
endif()
if(WITH_LTO)
if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
check_cxx_compiler_flag("-flto -fuse-linker-plugin" LTO_AVAILABLE)
if(LTO_AVAILABLE)
add_gcc_compiler_flags("-flto -fuse-linker-plugin")
else()
message(FATAL_ERROR "This version of gcc doesn't support LTO")
endif(LTO_AVAILABLE)
else()
message(FATAL_ERROR "LTO is only supported with gcc")
endif()
endif()
add_gcc_compiler_cxxflags("-std=c++11")
if(APPLE)

View File

@ -5,7 +5,7 @@ if(UNIX AND NOT APPLE)
add_feature_info(libXtest X11_XTest_FOUND "The X11 XTEST Protocol library is required for auto-type")
add_feature_info(Qt5X11Extras Qt5X11Extras_FOUND "The Qt5X11Extras library is required for auto-type")
if(X11_FOUND AND X11_XTest_FOUND AND Qt5X11Extras_FOUND)
if(X11_FOUND AND X11_Xi_FOUND AND X11_XTest_FOUND AND Qt5X11Extras_FOUND)
add_subdirectory(xcb)
endif()
endif()

View File

@ -33,23 +33,23 @@ class AutoTypePlatformTest : public QObject,
Q_INTERFACES(AutoTypePlatformInterface AutoTypeTestInterface)
public:
QString keyToString(Qt::Key key);
QString keyToString(Qt::Key key) Q_DECL_OVERRIDE;
QStringList windowTitles();
WId activeWindow();
QString activeWindowTitle();
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers);
void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers);
int platformEventFilter(void* event);
int initialTimeout();
bool raiseWindow(WId window);
AutoTypeExecutor* createExecutor();
QStringList windowTitles() Q_DECL_OVERRIDE;
WId activeWindow() Q_DECL_OVERRIDE;
QString activeWindowTitle() Q_DECL_OVERRIDE;
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
int platformEventFilter(void* event) Q_DECL_OVERRIDE;
int initialTimeout() Q_DECL_OVERRIDE;
bool raiseWindow(WId window) Q_DECL_OVERRIDE;
AutoTypeExecutor* createExecutor() Q_DECL_OVERRIDE;
void setActiveWindowTitle(const QString& title);
void setActiveWindowTitle(const QString& title) Q_DECL_OVERRIDE;
QString actionChars();
int actionCount();
void clearActions();
QString actionChars() Q_DECL_OVERRIDE;
int actionCount() Q_DECL_OVERRIDE;
void clearActions() Q_DECL_OVERRIDE;
void addActionChar(AutoTypeChar* action);
void addActionKey(AutoTypeKey* action);
@ -68,8 +68,8 @@ class AutoTypeExecturorTest : public AutoTypeExecutor
public:
explicit AutoTypeExecturorTest(AutoTypePlatformTest* platform);
void execChar(AutoTypeChar* action);
void execKey(AutoTypeKey* action);
void execChar(AutoTypeChar* action) Q_DECL_OVERRIDE;
void execKey(AutoTypeKey* action) Q_DECL_OVERRIDE;
private:
AutoTypePlatformTest* const m_platform;

View File

@ -31,12 +31,12 @@ AutoTypePlatformX11::AutoTypePlatformX11()
m_dpy = QX11Info::display();
m_rootWindow = QX11Info::appRootWindow();
m_atomWmState = XInternAtom(m_dpy, "WM_STATE", true);
m_atomWmName = XInternAtom(m_dpy, "WM_NAME", true);
m_atomNetWmName = XInternAtom(m_dpy, "_NET_WM_NAME", true);
m_atomString = XInternAtom(m_dpy, "STRING", true);
m_atomUtf8String = XInternAtom(m_dpy, "UTF8_STRING", true);
m_atomNetActiveWindow = XInternAtom(m_dpy, "_NET_ACTIVE_WINDOW", true);
m_atomWmState = XInternAtom(m_dpy, "WM_STATE", True);
m_atomWmName = XInternAtom(m_dpy, "WM_NAME", True);
m_atomNetWmName = XInternAtom(m_dpy, "_NET_WM_NAME", True);
m_atomString = XInternAtom(m_dpy, "STRING", True);
m_atomUtf8String = XInternAtom(m_dpy, "UTF8_STRING", True);
m_atomNetActiveWindow = XInternAtom(m_dpy, "_NET_ACTIVE_WINDOW", True);
m_classBlacklist << "desktop_window" << "gnome-panel"; // Gnome
m_classBlacklist << "kdesktop" << "kicker"; // KDE 3
@ -118,12 +118,12 @@ bool AutoTypePlatformX11::registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifi
uint nativeModifiers = qtToNativeModifiers(modifiers);
startCatchXErrors();
XGrabKey(m_dpy, keycode, nativeModifiers, m_rootWindow, true, GrabModeAsync, GrabModeAsync);
XGrabKey(m_dpy, keycode, nativeModifiers | Mod2Mask, m_rootWindow, true, GrabModeAsync,
XGrabKey(m_dpy, keycode, nativeModifiers, m_rootWindow, True, GrabModeAsync, GrabModeAsync);
XGrabKey(m_dpy, keycode, nativeModifiers | Mod2Mask, m_rootWindow, True, GrabModeAsync,
GrabModeAsync);
XGrabKey(m_dpy, keycode, nativeModifiers | LockMask, m_rootWindow, true, GrabModeAsync,
XGrabKey(m_dpy, keycode, nativeModifiers | LockMask, m_rootWindow, True, GrabModeAsync,
GrabModeAsync);
XGrabKey(m_dpy, keycode, nativeModifiers | Mod2Mask | LockMask, m_rootWindow, true,
XGrabKey(m_dpy, keycode, nativeModifiers | Mod2Mask | LockMask, m_rootWindow, True,
GrabModeAsync, GrabModeAsync);
stopCatchXErrors();
@ -236,7 +236,7 @@ QString AutoTypePlatformX11::windowTitle(Window window, bool useBlacklist)
// the window manager spec says we should read _NET_WM_NAME first, then fall back to WM_NAME
int retVal = XGetWindowProperty(m_dpy, window, m_atomNetWmName, 0, 1000, false, m_atomUtf8String,
int retVal = XGetWindowProperty(m_dpy, window, m_atomNetWmName, 0, 1000, False, m_atomUtf8String,
&type, &format, &nitems, &after, &data);
if ((retVal == 0) && data) {
@ -359,7 +359,7 @@ bool AutoTypePlatformX11::isTopLevelWindow(Window window)
unsigned long nitems;
unsigned long after;
unsigned char* data = nullptr;
int retVal = XGetWindowProperty(m_dpy, window, m_atomWmState, 0, 0, false, AnyPropertyType, &type, &format,
int retVal = XGetWindowProperty(m_dpy, window, m_atomWmState, 0, 0, False, AnyPropertyType, &type, &format,
&nitems, &after, &data);
if (data) {
XFree(data);
@ -541,7 +541,7 @@ void AutoTypePlatformX11::stopCatchXErrors()
{
Q_ASSERT(m_catchXErrors);
XSync(m_dpy, false);
XSync(m_dpy, False);
XSetErrorHandler(m_oldXErrorHandler);
m_catchXErrors = false;
}
@ -594,7 +594,14 @@ void AutoTypePlatformX11::SendEvent(XKeyEvent* event, int event_type)
int (*oldHandler) (Display*, XErrorEvent*) = XSetErrorHandler(MyErrorHandler);
event->type = event_type;
XTestFakeKeyEvent(event->display, event->keycode, event->type == KeyPress, 0);
Bool press;
if (event->type == KeyPress) {
press = True;
}
else {
press = False;
}
XTestFakeKeyEvent(event->display, event->keycode, press, 0);
XFlush(event->display);
XSetErrorHandler(oldHandler);

View File

@ -43,15 +43,15 @@ class AutoTypePlatformX11 : public QObject, public AutoTypePlatformInterface
public:
AutoTypePlatformX11();
void unload() override;
QStringList windowTitles();
WId activeWindow();
QString activeWindowTitle();
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers);
void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers);
int platformEventFilter(void* event);
int initialTimeout();
bool raiseWindow(WId window);
AutoTypeExecutor* createExecutor();
QStringList windowTitles() override;
WId activeWindow() override;
QString activeWindowTitle() override;
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) override;
void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) override;
int platformEventFilter(void* event) override;
int initialTimeout() override;
bool raiseWindow(WId window) override;
AutoTypeExecutor* createExecutor() override;
KeySym charToKeySym(const QChar& ch);
KeySym keyToKeySym(Qt::Key key);
@ -122,8 +122,8 @@ class AutoTypeExecturorX11 : public AutoTypeExecutor
public:
explicit AutoTypeExecturorX11(AutoTypePlatformX11* platform);
void execChar(AutoTypeChar* action);
void execKey(AutoTypeKey* action);
void execChar(AutoTypeChar* action) Q_DECL_OVERRIDE;
void execKey(AutoTypeKey* action) Q_DECL_OVERRIDE;
private:
AutoTypePlatformX11* const m_platform;

View File

@ -24,6 +24,7 @@
#include "core/Database.h"
#include "core/Endian.h"
#include "crypto/CryptoHash.h"
#include "format/KeePass1.h"
#include "format/KeePass2.h"
#include "format/KeePass2RandomStream.h"
#include "format/KeePass2XmlReader.h"
@ -70,7 +71,14 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
}
quint32 signature2 = Endian::readUInt32(m_headerStream, KeePass2::BYTEORDER, &ok);
if (!ok || signature2 != KeePass2::SIGNATURE_2) {
if (ok && signature2 == KeePass1::SIGNATURE_2) {
raiseError(tr("The selected file is an old KeePass 1 database (.kdb).\n\n"
"You can import it by clicking on Database > 'Import KeePass 1 database'.\n"
"This is a one-way migration. You won't be able to open the imported "
"database with the old KeePassX 0.4 version."));
return Q_NULLPTR;
}
else if (!ok || signature2 != KeePass2::SIGNATURE_2) {
raiseError(tr("Not a KeePass database."));
return nullptr;
}

View File

@ -67,6 +67,7 @@ QString FileDialog::getSaveFileName(QWidget* parent, const QString& caption, QSt
QString result;
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
Q_UNUSED(defaultExtension);
// the native dialogs on these platforms already append the file extension
result = QFileDialog::getSaveFileName(parent, caption, dir, filter,
selectedFilter, options);

View File

@ -243,7 +243,7 @@ QMimeData* EntryModel::mimeData(const QModelIndexList& indexes) const
return nullptr;
}
else {
data->setData(mimeTypes().first(), encoded);
data->setData(mimeTypes().at(0), encoded);
return data;
}
}

View File

@ -357,7 +357,7 @@ QMimeData* GroupModel::mimeData(const QModelIndexList& indexes) const
return nullptr;
}
else {
data->setData(mimeTypes().first(), encoded);
data->setData(mimeTypes().at(0), encoded);
return data;
}
}

View File

@ -33,8 +33,8 @@ public:
QModelIndex index(Group* group) const;
Group* groupFromIndex(const QModelIndex& index) const;
int rowCount(const QModelIndex& parent = QModelIndex()) const;
int columnCount(const QModelIndex& parent = QModelIndex()) const;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex& index) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;

View File

@ -47,7 +47,7 @@ private Q_SLOTS:
void modelReset();
protected:
void dragMoveEvent(QDragMoveEvent* event);
void dragMoveEvent(QDragMoveEvent* event) Q_DECL_OVERRIDE;
private:
void recInitExpanded(Group* group);

View File

@ -31,8 +31,8 @@ public:
HashedBlockStream(QIODevice* baseDevice, qint32 blockSize);
~HashedBlockStream();
bool reset();
void close();
bool reset() Q_DECL_OVERRIDE;
void close() Q_DECL_OVERRIDE;
protected:
qint64 readData(char* data, qint64 maxSize) override;

View File

@ -119,6 +119,6 @@ void TestEntry::testClone()
QCOMPARE(entryCloneNone->uuid(), entryOrg->uuid());
QCOMPARE(entryCloneHistory->title(), QString("New Title"));
QCOMPARE(entryCloneHistory->historyItems().size(), 1);
QCOMPARE(entryCloneHistory->historyItems().first()->title(), QString("Original Title"));
QCOMPARE(entryCloneHistory->historyItems().at(0)->title(), QString("Original Title"));
QCOMPARE(entryCloneHistory->timeInfo().creationTime(), entryOrg->timeInfo().creationTime());
}

View File

@ -59,19 +59,19 @@ void TestExporter::testToDbExporter()
Database* dbExp = ToDbExporter().exportGroup(groupOrg);
QCOMPARE(dbExp->rootGroup()->children().size(), 1);
Group* groupExp = dbExp->rootGroup()->children().first();
Group* groupExp = dbExp->rootGroup()->children().at(0);
QVERIFY(groupExp != groupOrg);
QCOMPARE(groupExp->name(), groupOrg->name());
QCOMPARE(groupExp->entries().size(), 1);
Entry* entryExp = groupExp->entries().first();
Entry* entryExp = groupExp->entries().at(0);
QCOMPARE(entryExp->title(), entryOrg->title());
QCOMPARE(dbExp->metadata()->customIcons().size(), 1);
QVERIFY(dbExp->metadata()->containsCustomIcon(iconUuid));
QCOMPARE(entryExp->iconNumber(), entryOrg->iconNumber());
QCOMPARE(entryExp->historyItems().size(), 1);
QCOMPARE(entryExp->historyItems().first()->iconUuid(), iconUuid);
QCOMPARE(entryExp->historyItems().at(0)->iconUuid(), iconUuid);
delete dbOrg;
delete dbExp;

View File

@ -70,7 +70,7 @@ void TestKeePass1Reader::testBasic()
QVERIFY(entry11->timeInfo().expires());
QCOMPARE(entry11->timeInfo().expiryTime(), genDT(2012, 5, 9, 10, 32));
QCOMPARE(entry11->attachments()->keys().size(), 1);
QCOMPARE(entry11->attachments()->keys().first(), QString("attachment.txt"));
QCOMPARE(entry11->attachments()->keys().at(0), QString("attachment.txt"));
QCOMPARE(entry11->attachments()->value("attachment.txt"), QByteArray("hello world\n"));
Entry* entry12 = group1->entries().at(1);
@ -117,7 +117,7 @@ void TestKeePass1Reader::testCustomIcons()
{
QCOMPARE(m_db->metadata()->customIcons().size(), 1);
Entry* entry = m_db->rootGroup()->children().at(1)->entries().first();
Entry* entry = m_db->rootGroup()->children().at(1)->entries().at(0);
QCOMPARE(entry->icon().width(), 16);
QCOMPARE(entry->icon().height(), 16);

View File

@ -314,7 +314,7 @@ void TestKeePass2XmlReader::testEntry2()
void TestKeePass2XmlReader::testEntryHistory()
{
const Entry* entryMain = m_db->rootGroup()->entries().first();
const Entry* entryMain = m_db->rootGroup()->entries().at(0);
QCOMPARE(entryMain->historyItems().size(), 2);
{