mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-13 08:19:50 -05:00
Fixed various Qt5 changes in the http code
This commit is contained in:
parent
aba4fa94be
commit
7f7753a004
@ -163,8 +163,6 @@ find_package(Gcrypt 1.6.0 REQUIRED)
|
|||||||
|
|
||||||
find_package(LibMicroHTTPD REQUIRED)
|
find_package(LibMicroHTTPD REQUIRED)
|
||||||
|
|
||||||
find_package(QJSON REQUIRED)
|
|
||||||
|
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
|
|
||||||
check_cxx_source_compiles("
|
check_cxx_source_compiles("
|
||||||
|
@ -140,16 +140,6 @@ set(keepassx_SOURCES_MAINEXE
|
|||||||
main.cpp
|
main.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(keepassx_MOC
|
|
||||||
http/AccessControlDialog.h
|
|
||||||
http/EntryConfig.h
|
|
||||||
http/HttpPasswordGeneratorWidget.h
|
|
||||||
http/OptionDialog.h
|
|
||||||
http/Protocol.h
|
|
||||||
http/Server.h
|
|
||||||
http/Service.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set(keepassx_FORMS
|
set(keepassx_FORMS
|
||||||
gui/AboutDialog.ui
|
gui/AboutDialog.ui
|
||||||
gui/ChangeMasterKeyWidget.ui
|
gui/ChangeMasterKeyWidget.ui
|
||||||
@ -189,6 +179,7 @@ target_link_libraries(keepassx_core Qt5::Core Qt5::Concurrent Qt5::Widgets)
|
|||||||
add_executable(${PROGNAME} WIN32 MACOSX_BUNDLE ${keepassx_SOURCES_MAINEXE})
|
add_executable(${PROGNAME} WIN32 MACOSX_BUNDLE ${keepassx_SOURCES_MAINEXE})
|
||||||
target_link_libraries(${PROGNAME}
|
target_link_libraries(${PROGNAME}
|
||||||
keepassx_core
|
keepassx_core
|
||||||
|
${MHD_LIBRARIES}
|
||||||
Qt5::Core
|
Qt5::Core
|
||||||
Qt5::Concurrent
|
Qt5::Concurrent
|
||||||
Qt5::Widgets
|
Qt5::Widgets
|
||||||
|
@ -91,7 +91,7 @@ Uuid Uuid::fromBase64(const QString& str)
|
|||||||
|
|
||||||
Uuid Uuid::fromHex(const QString& str)
|
Uuid Uuid::fromHex(const QString& str)
|
||||||
{
|
{
|
||||||
QByteArray data = QByteArray::fromHex(str.toAscii());
|
QByteArray data = QByteArray::fromHex(str.toLatin1());
|
||||||
return Uuid(data);
|
return Uuid(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
AccessControlDialog::AccessControlDialog(QWidget *parent) :
|
AccessControlDialog::AccessControlDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::AccessControlDialog)
|
ui(new Ui::AccessControlDialog())
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
connect(ui->allowButton, SIGNAL(clicked()), this, SLOT(accept()));
|
connect(ui->allowButton, SIGNAL(clicked()), this, SLOT(accept()));
|
||||||
@ -26,7 +26,6 @@ AccessControlDialog::AccessControlDialog(QWidget *parent) :
|
|||||||
|
|
||||||
AccessControlDialog::~AccessControlDialog()
|
AccessControlDialog::~AccessControlDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccessControlDialog::setUrl(const QString &url)
|
void AccessControlDialog::setUrl(const QString &url)
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
#ifndef ACCESSCONTROLDIALOG_H
|
#ifndef ACCESSCONTROLDIALOG_H
|
||||||
#define ACCESSCONTROLDIALOG_H
|
#define ACCESSCONTROLDIALOG_H
|
||||||
|
|
||||||
#include <QtGui/QDialog>
|
#include <QDialog>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
class Entry;
|
class Entry;
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ class AccessControlDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AccessControlDialog(QWidget *parent = 0);
|
explicit AccessControlDialog(QWidget *parent = nullptr);
|
||||||
~AccessControlDialog();
|
~AccessControlDialog();
|
||||||
|
|
||||||
void setUrl(const QString & url);
|
void setUrl(const QString & url);
|
||||||
@ -36,7 +37,7 @@ public:
|
|||||||
void setRemember(bool r);
|
void setRemember(bool r);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::AccessControlDialog *ui;
|
QScopedPointer<Ui::AccessControlDialog> ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ACCESSCONTROLDIALOG_H
|
#endif // ACCESSCONTROLDIALOG_H
|
||||||
|
@ -12,11 +12,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "EntryConfig.h"
|
#include "EntryConfig.h"
|
||||||
|
#include <QtCore>
|
||||||
#include "core/Entry.h"
|
#include "core/Entry.h"
|
||||||
#include "core/EntryAttributes.h"
|
#include "core/EntryAttributes.h"
|
||||||
#include "qjson/parser.h"
|
#include "http/Protocol.h"
|
||||||
#include "qjson/qobjecthelper.h"
|
|
||||||
#include "qjson/serializer.h"
|
|
||||||
|
|
||||||
static const char KEEPASSHTTP_NAME[] = "KeePassHttp Settings"; //TODO: duplicated string (also in Service.cpp)
|
static const char KEEPASSHTTP_NAME[] = "KeePassHttp Settings"; //TODO: duplicated string (also in Service.cpp)
|
||||||
|
|
||||||
@ -83,19 +82,21 @@ bool EntryConfig::load(const Entry *entry)
|
|||||||
if (s.isEmpty())
|
if (s.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool isOk = false;
|
QJsonDocument doc = QJsonDocument::fromJson(s.toUtf8());
|
||||||
QVariant v = QJson::Parser().parse(s.toUtf8(), &isOk);
|
if (doc.isNull())
|
||||||
if (!isOk || v.type() != QVariant::Map)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QJson::QObjectHelper::qvariant2qobject(v.toMap(), this);
|
QVariantMap map = doc.object().toVariantMap();
|
||||||
|
for(QVariantMap::iterator iter = map.begin(); iter != map.end(); ++iter) {
|
||||||
|
setProperty(iter.key().toLatin1(), iter.value());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntryConfig::save(Entry *entry)
|
void EntryConfig::save(Entry *entry)
|
||||||
{
|
{
|
||||||
//QVariant v = QJson::QObjectHelper::qobject2qvariant(this, QJson::QObjectHelper::Flag_None);
|
QVariantMap v = qobject2qvariant(this);
|
||||||
QVariant v = QJson::QObjectHelper::qobject2qvariant(this);
|
QJsonObject o = QJsonObject::fromVariantMap(v);
|
||||||
QByteArray json = QJson::Serializer().serialize(v);
|
QByteArray json = QJsonDocument(o).toJson(QJsonDocument::Compact);
|
||||||
entry->attributes()->set(KEEPASSHTTP_NAME, json);
|
entry->attributes()->set(KEEPASSHTTP_NAME, json);
|
||||||
}
|
}
|
||||||
|
@ -15,27 +15,24 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef KEEPASSX_PASSWORDGENERATORWIDGET_H
|
#ifndef KEEPASSX_HTTPPASSWORDGENERATORWIDGET_H
|
||||||
#define KEEPASSX_PASSWORDGENERATORWIDGET_H
|
#define KEEPASSX_HTTPPASSWORDGENERATORWIDGET_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QComboBox>
|
#include <QScopedPointer>
|
||||||
|
|
||||||
#include "core/Global.h"
|
|
||||||
#include "core/PasswordGenerator.h"
|
#include "core/PasswordGenerator.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class HttpPasswordGeneratorWidget;
|
class HttpPasswordGeneratorWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class PasswordGenerator;
|
|
||||||
|
|
||||||
class HttpPasswordGeneratorWidget : public QWidget
|
class HttpPasswordGeneratorWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit HttpPasswordGeneratorWidget(QWidget* parent = Q_NULLPTR);
|
explicit HttpPasswordGeneratorWidget(QWidget* parent = nullptr);
|
||||||
~HttpPasswordGeneratorWidget();
|
~HttpPasswordGeneratorWidget();
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
void reset();
|
void reset();
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
OptionDialog::OptionDialog(QWidget *parent) :
|
OptionDialog::OptionDialog(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::OptionDialog)
|
ui(new Ui::OptionDialog())
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
connect(ui->removeSharedEncryptionKeys, SIGNAL(clicked()), this, SIGNAL(removeSharedEncryptionKeys()));
|
connect(ui->removeSharedEncryptionKeys, SIGNAL(clicked()), this, SIGNAL(removeSharedEncryptionKeys()));
|
||||||
@ -26,7 +26,6 @@ OptionDialog::OptionDialog(QWidget *parent) :
|
|||||||
|
|
||||||
OptionDialog::~OptionDialog()
|
OptionDialog::~OptionDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionDialog::loadSettings()
|
void OptionDialog::loadSettings()
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
#ifndef OPTIONDIALOG_H
|
#ifndef OPTIONDIALOG_H
|
||||||
#define OPTIONDIALOG_H
|
#define OPTIONDIALOG_H
|
||||||
|
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class OptionDialog;
|
class OptionDialog;
|
||||||
@ -25,7 +26,7 @@ class OptionDialog : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit OptionDialog(QWidget *parent = 0);
|
explicit OptionDialog(QWidget *parent = nullptr);
|
||||||
~OptionDialog();
|
~OptionDialog();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
@ -37,7 +38,7 @@ Q_SIGNALS:
|
|||||||
void removeStoredPermissions();
|
void removeStoredPermissions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::OptionDialog *ui;
|
QScopedPointer<Ui::OptionDialog> ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OPTIONDIALOG_H
|
#endif // OPTIONDIALOG_H
|
||||||
|
@ -12,14 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Protocol.h"
|
#include "Protocol.h"
|
||||||
|
#include <QtCore>
|
||||||
#include <QtCore/QMetaProperty>
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
#include <QtCore/QVariant>
|
|
||||||
|
|
||||||
#include "qjson/parser.h"
|
|
||||||
#include "qjson/qobjecthelper.h"
|
|
||||||
#include "qjson/serializer.h"
|
|
||||||
|
|
||||||
#include "crypto/Random.h"
|
#include "crypto/Random.h"
|
||||||
#include "crypto/SymmetricCipher.h"
|
#include "crypto/SymmetricCipher.h"
|
||||||
@ -40,6 +33,24 @@ static const char * const STR_VERSION = "1.8.4.0";
|
|||||||
|
|
||||||
using namespace KeepassHttpProtocol;
|
using namespace KeepassHttpProtocol;
|
||||||
|
|
||||||
|
QVariantMap qobject2qvariant( const QObject* object, const QStringList& ignoredProperties )
|
||||||
|
{
|
||||||
|
QVariantMap result;
|
||||||
|
const QMetaObject *metaobject = object->metaObject();
|
||||||
|
int count = metaobject->propertyCount();
|
||||||
|
for (int i=0; i<count; ++i) {
|
||||||
|
QMetaProperty metaproperty = metaobject->property(i);
|
||||||
|
const char *name = metaproperty.name();
|
||||||
|
|
||||||
|
if (ignoredProperties.contains(QLatin1String(name)) || (!metaproperty.isReadable()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QVariant value = object->property(name);
|
||||||
|
result[QLatin1String(name)] = value;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static QHash<QString, RequestType> createStringHash()
|
static QHash<QString, RequestType> createStringHash()
|
||||||
{
|
{
|
||||||
QHash<QString, RequestType> hash;
|
QHash<QString, RequestType> hash;
|
||||||
@ -61,12 +72,12 @@ static RequestType parseRequest(const QString &str)
|
|||||||
|
|
||||||
static QByteArray decode64(QString s)
|
static QByteArray decode64(QString s)
|
||||||
{
|
{
|
||||||
return QByteArray::fromBase64(s.toAscii());
|
return QByteArray::fromBase64(s.toLatin1());
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString encode64(QByteArray b)
|
static QString encode64(QByteArray b)
|
||||||
{
|
{
|
||||||
return QString::fromAscii(b.toBase64());
|
return QString::fromLatin1(b.toBase64());
|
||||||
}
|
}
|
||||||
|
|
||||||
static QByteArray decrypt2(const QByteArray & data, SymmetricCipherGcrypt & cipher)
|
static QByteArray decrypt2(const QByteArray & data, SymmetricCipherGcrypt & cipher)
|
||||||
@ -263,13 +274,15 @@ bool Request::CheckVerifier(const QString &key) const
|
|||||||
|
|
||||||
bool Request::fromJson(QString text)
|
bool Request::fromJson(QString text)
|
||||||
{
|
{
|
||||||
bool isok = false;
|
QJsonDocument doc = QJsonDocument::fromJson(text.toUtf8());
|
||||||
QVariant v = QJson::Parser().parse(text.toUtf8(), &isok);
|
if (doc.isNull())
|
||||||
if (!isok)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_requestType.clear();
|
m_requestType.clear();
|
||||||
QJson::QObjectHelper::qvariant2qobject(v.toMap(), this);
|
QVariantMap map = doc.object().toVariantMap();
|
||||||
|
for(QVariantMap::iterator iter = map.begin(); iter != map.end(); ++iter) {
|
||||||
|
setProperty(iter.key().toLatin1(), iter.value());
|
||||||
|
}
|
||||||
|
|
||||||
return requestType() != INVALID;
|
return requestType() != INVALID;
|
||||||
}
|
}
|
||||||
@ -307,11 +320,17 @@ void Response::setVerifier(QString key)
|
|||||||
|
|
||||||
QString Response::toJson()
|
QString Response::toJson()
|
||||||
{
|
{
|
||||||
QVariant result = QJson::QObjectHelper::qobject2qvariant(this);
|
QJsonObject json;
|
||||||
|
|
||||||
|
int count = metaObject()->propertyCount();
|
||||||
|
for (int i=0; i<count; ++i) {
|
||||||
|
QMetaProperty metaproperty = metaObject()->property(i);
|
||||||
|
const char *name = metaproperty.name();
|
||||||
|
json.insert(QString(name), QJsonValue::fromVariant(this->property(name)));
|
||||||
|
}
|
||||||
|
|
||||||
QJson::Serializer s;
|
QJsonDocument doc(json);
|
||||||
s.setIndentMode(QJson::IndentCompact);
|
return doc.toJson(QJsonDocument::Compact);
|
||||||
return s.serialize(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KeepassHttpProtocol::RequestType Response::requestType() const
|
KeepassHttpProtocol::RequestType Response::requestType() const
|
||||||
@ -352,7 +371,7 @@ QVariant Response::getEntries() const
|
|||||||
QList<QVariant> res;
|
QList<QVariant> res;
|
||||||
res.reserve(m_entries.size());
|
res.reserve(m_entries.size());
|
||||||
Q_FOREACH (const Entry &entry, m_entries)
|
Q_FOREACH (const Entry &entry, m_entries)
|
||||||
res.append(QJson::QObjectHelper::qobject2qvariant(&entry));
|
res.append(qobject2qvariant(&entry));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,7 +509,7 @@ QVariant Entry::getStringFields() const
|
|||||||
QList<QVariant> res;
|
QList<QVariant> res;
|
||||||
res.reserve(m_stringFields.size());
|
res.reserve(m_stringFields.size());
|
||||||
Q_FOREACH (const StringField &stringfield, m_stringFields)
|
Q_FOREACH (const StringField &stringfield, m_stringFields)
|
||||||
res.append(QJson::QObjectHelper::qobject2qvariant(&stringfield));
|
res.append(qobject2qvariant(&stringfield));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,12 +14,11 @@
|
|||||||
#ifndef RESPONSE_H
|
#ifndef RESPONSE_H
|
||||||
#define RESPONSE_H
|
#define RESPONSE_H
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore>
|
||||||
#include <QtCore/QCryptographicHash>
|
|
||||||
#include <QtCore/QMetaType>
|
|
||||||
#include <QtCore/QVariant>
|
|
||||||
#include "crypto/SymmetricCipherGcrypt.h"
|
#include "crypto/SymmetricCipherGcrypt.h"
|
||||||
|
|
||||||
|
QVariantMap qobject2qvariant( const QObject* object, const QStringList& ignoredProperties = QStringList(QString(QLatin1String("objectName"))) );
|
||||||
|
|
||||||
namespace KeepassHttpProtocol {
|
namespace KeepassHttpProtocol {
|
||||||
|
|
||||||
enum RequestType {
|
enum RequestType {
|
||||||
|
@ -201,7 +201,7 @@ void Server::handleRequest(const QByteArray in, QByteArray *out)
|
|||||||
(getDatabaseRootUuid() + getDatabaseRecycleBinUuid()).toUtf8(),
|
(getDatabaseRootUuid() + getDatabaseRecycleBinUuid()).toUtf8(),
|
||||||
QCryptographicHash::Sha1).toHex();
|
QCryptographicHash::Sha1).toHex();
|
||||||
|
|
||||||
Response protocolResp(r, QString::fromAscii(hash));
|
Response protocolResp(r, QString::fromLatin1(hash));
|
||||||
switch(r.requestType()) {
|
switch(r.requestType()) {
|
||||||
case INVALID: break;
|
case INVALID: break;
|
||||||
case GET_LOGINS: getLogins(r, &protocolResp); break;
|
case GET_LOGINS: getLogins(r, &protocolResp); break;
|
||||||
|
@ -11,10 +11,10 @@
|
|||||||
***************************************************************************
|
***************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtGui/QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QtGui/QProgressDialog>
|
#include <QProgressDialog>
|
||||||
#include <QtCore/QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "Service.h"
|
#include "Service.h"
|
||||||
#include "Protocol.h"
|
#include "Protocol.h"
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#ifndef SERVICE_H
|
#ifndef SERVICE_H
|
||||||
#define SERVICE_H
|
#define SERVICE_H
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QObject>
|
||||||
#include "gui/DatabaseTabWidget.h"
|
#include "gui/DatabaseTabWidget.h"
|
||||||
#include "Server.h"
|
#include "Server.h"
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ set(TEST_LIBRARIES
|
|||||||
|
|
||||||
set(testsupport_SOURCES modeltest.cpp FailDevice.cpp)
|
set(testsupport_SOURCES modeltest.cpp FailDevice.cpp)
|
||||||
add_library(testsupport STATIC ${testsupport_SOURCES})
|
add_library(testsupport STATIC ${testsupport_SOURCES})
|
||||||
target_link_libraries(testsupport Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Test)
|
target_link_libraries(testsupport ${MHD_LIBRARIES} Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Test)
|
||||||
|
|
||||||
add_unit_test(NAME testgroup SOURCES TestGroup.cpp
|
add_unit_test(NAME testgroup SOURCES TestGroup.cpp
|
||||||
LIBS ${TEST_LIBRARIES})
|
LIBS ${TEST_LIBRARIES})
|
||||||
|
@ -18,6 +18,7 @@ include_directories(../src)
|
|||||||
add_executable(kdbx-extract kdbx-extract.cpp)
|
add_executable(kdbx-extract kdbx-extract.cpp)
|
||||||
target_link_libraries(kdbx-extract
|
target_link_libraries(kdbx-extract
|
||||||
keepassx_core
|
keepassx_core
|
||||||
|
${MHD_LIBRARIES}
|
||||||
Qt5::Core
|
Qt5::Core
|
||||||
Qt5::Concurrent
|
Qt5::Concurrent
|
||||||
Qt5::Widgets
|
Qt5::Widgets
|
||||||
|
Loading…
Reference in New Issue
Block a user