mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04: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(QJSON REQUIRED)
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
check_cxx_source_compiles("
|
||||
|
@ -140,16 +140,6 @@ set(keepassx_SOURCES_MAINEXE
|
||||
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
|
||||
gui/AboutDialog.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})
|
||||
target_link_libraries(${PROGNAME}
|
||||
keepassx_core
|
||||
${MHD_LIBRARIES}
|
||||
Qt5::Core
|
||||
Qt5::Concurrent
|
||||
Qt5::Widgets
|
||||
|
@ -91,7 +91,7 @@ Uuid Uuid::fromBase64(const QString& str)
|
||||
|
||||
Uuid Uuid::fromHex(const QString& str)
|
||||
{
|
||||
QByteArray data = QByteArray::fromHex(str.toAscii());
|
||||
QByteArray data = QByteArray::fromHex(str.toLatin1());
|
||||
return Uuid(data);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
AccessControlDialog::AccessControlDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::AccessControlDialog)
|
||||
ui(new Ui::AccessControlDialog())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->allowButton, SIGNAL(clicked()), this, SLOT(accept()));
|
||||
@ -26,7 +26,6 @@ AccessControlDialog::AccessControlDialog(QWidget *parent) :
|
||||
|
||||
AccessControlDialog::~AccessControlDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AccessControlDialog::setUrl(const QString &url)
|
||||
|
@ -14,7 +14,8 @@
|
||||
#ifndef ACCESSCONTROLDIALOG_H
|
||||
#define ACCESSCONTROLDIALOG_H
|
||||
|
||||
#include <QtGui/QDialog>
|
||||
#include <QDialog>
|
||||
#include <QScopedPointer>
|
||||
|
||||
class Entry;
|
||||
|
||||
@ -27,7 +28,7 @@ class AccessControlDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AccessControlDialog(QWidget *parent = 0);
|
||||
explicit AccessControlDialog(QWidget *parent = nullptr);
|
||||
~AccessControlDialog();
|
||||
|
||||
void setUrl(const QString & url);
|
||||
@ -36,7 +37,7 @@ public:
|
||||
void setRemember(bool r);
|
||||
|
||||
private:
|
||||
Ui::AccessControlDialog *ui;
|
||||
QScopedPointer<Ui::AccessControlDialog> ui;
|
||||
};
|
||||
|
||||
#endif // ACCESSCONTROLDIALOG_H
|
||||
|
@ -12,11 +12,10 @@
|
||||
*/
|
||||
|
||||
#include "EntryConfig.h"
|
||||
#include <QtCore>
|
||||
#include "core/Entry.h"
|
||||
#include "core/EntryAttributes.h"
|
||||
#include "qjson/parser.h"
|
||||
#include "qjson/qobjecthelper.h"
|
||||
#include "qjson/serializer.h"
|
||||
#include "http/Protocol.h"
|
||||
|
||||
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())
|
||||
return false;
|
||||
|
||||
bool isOk = false;
|
||||
QVariant v = QJson::Parser().parse(s.toUtf8(), &isOk);
|
||||
if (!isOk || v.type() != QVariant::Map)
|
||||
QJsonDocument doc = QJsonDocument::fromJson(s.toUtf8());
|
||||
if (doc.isNull())
|
||||
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;
|
||||
}
|
||||
|
||||
void EntryConfig::save(Entry *entry)
|
||||
{
|
||||
//QVariant v = QJson::QObjectHelper::qobject2qvariant(this, QJson::QObjectHelper::Flag_None);
|
||||
QVariant v = QJson::QObjectHelper::qobject2qvariant(this);
|
||||
QByteArray json = QJson::Serializer().serialize(v);
|
||||
QVariantMap v = qobject2qvariant(this);
|
||||
QJsonObject o = QJsonObject::fromVariantMap(v);
|
||||
QByteArray json = QJsonDocument(o).toJson(QJsonDocument::Compact);
|
||||
entry->attributes()->set(KEEPASSHTTP_NAME, json);
|
||||
}
|
||||
|
@ -15,27 +15,24 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KEEPASSX_PASSWORDGENERATORWIDGET_H
|
||||
#define KEEPASSX_PASSWORDGENERATORWIDGET_H
|
||||
#ifndef KEEPASSX_HTTPPASSWORDGENERATORWIDGET_H
|
||||
#define KEEPASSX_HTTPPASSWORDGENERATORWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QComboBox>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include "core/Global.h"
|
||||
#include "core/PasswordGenerator.h"
|
||||
|
||||
namespace Ui {
|
||||
class HttpPasswordGeneratorWidget;
|
||||
}
|
||||
|
||||
class PasswordGenerator;
|
||||
|
||||
class HttpPasswordGeneratorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HttpPasswordGeneratorWidget(QWidget* parent = Q_NULLPTR);
|
||||
explicit HttpPasswordGeneratorWidget(QWidget* parent = nullptr);
|
||||
~HttpPasswordGeneratorWidget();
|
||||
void loadSettings();
|
||||
void reset();
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
OptionDialog::OptionDialog(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::OptionDialog)
|
||||
ui(new Ui::OptionDialog())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->removeSharedEncryptionKeys, SIGNAL(clicked()), this, SIGNAL(removeSharedEncryptionKeys()));
|
||||
@ -26,7 +26,6 @@ OptionDialog::OptionDialog(QWidget *parent) :
|
||||
|
||||
OptionDialog::~OptionDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void OptionDialog::loadSettings()
|
||||
|
@ -14,7 +14,8 @@
|
||||
#ifndef OPTIONDIALOG_H
|
||||
#define OPTIONDIALOG_H
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui {
|
||||
class OptionDialog;
|
||||
@ -25,7 +26,7 @@ class OptionDialog : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OptionDialog(QWidget *parent = 0);
|
||||
explicit OptionDialog(QWidget *parent = nullptr);
|
||||
~OptionDialog();
|
||||
|
||||
public Q_SLOTS:
|
||||
@ -37,7 +38,7 @@ Q_SIGNALS:
|
||||
void removeStoredPermissions();
|
||||
|
||||
private:
|
||||
Ui::OptionDialog *ui;
|
||||
QScopedPointer<Ui::OptionDialog> ui;
|
||||
};
|
||||
|
||||
#endif // OPTIONDIALOG_H
|
||||
|
@ -12,14 +12,7 @@
|
||||
*/
|
||||
|
||||
#include "Protocol.h"
|
||||
|
||||
#include <QtCore/QMetaProperty>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
#include "qjson/parser.h"
|
||||
#include "qjson/qobjecthelper.h"
|
||||
#include "qjson/serializer.h"
|
||||
#include <QtCore>
|
||||
|
||||
#include "crypto/Random.h"
|
||||
#include "crypto/SymmetricCipher.h"
|
||||
@ -40,6 +33,24 @@ static const char * const STR_VERSION = "1.8.4.0";
|
||||
|
||||
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()
|
||||
{
|
||||
QHash<QString, RequestType> hash;
|
||||
@ -61,12 +72,12 @@ static RequestType parseRequest(const QString &str)
|
||||
|
||||
static QByteArray decode64(QString s)
|
||||
{
|
||||
return QByteArray::fromBase64(s.toAscii());
|
||||
return QByteArray::fromBase64(s.toLatin1());
|
||||
}
|
||||
|
||||
static QString encode64(QByteArray b)
|
||||
{
|
||||
return QString::fromAscii(b.toBase64());
|
||||
return QString::fromLatin1(b.toBase64());
|
||||
}
|
||||
|
||||
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 isok = false;
|
||||
QVariant v = QJson::Parser().parse(text.toUtf8(), &isok);
|
||||
if (!isok)
|
||||
QJsonDocument doc = QJsonDocument::fromJson(text.toUtf8());
|
||||
if (doc.isNull())
|
||||
return false;
|
||||
|
||||
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;
|
||||
}
|
||||
@ -307,11 +320,17 @@ void Response::setVerifier(QString key)
|
||||
|
||||
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;
|
||||
s.setIndentMode(QJson::IndentCompact);
|
||||
return s.serialize(result);
|
||||
QJsonDocument doc(json);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
KeepassHttpProtocol::RequestType Response::requestType() const
|
||||
@ -352,7 +371,7 @@ QVariant Response::getEntries() const
|
||||
QList<QVariant> res;
|
||||
res.reserve(m_entries.size());
|
||||
Q_FOREACH (const Entry &entry, m_entries)
|
||||
res.append(QJson::QObjectHelper::qobject2qvariant(&entry));
|
||||
res.append(qobject2qvariant(&entry));
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -490,7 +509,7 @@ QVariant Entry::getStringFields() const
|
||||
QList<QVariant> res;
|
||||
res.reserve(m_stringFields.size());
|
||||
Q_FOREACH (const StringField &stringfield, m_stringFields)
|
||||
res.append(QJson::QObjectHelper::qobject2qvariant(&stringfield));
|
||||
res.append(qobject2qvariant(&stringfield));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -14,12 +14,11 @@
|
||||
#ifndef RESPONSE_H
|
||||
#define RESPONSE_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QCryptographicHash>
|
||||
#include <QtCore/QMetaType>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtCore>
|
||||
#include "crypto/SymmetricCipherGcrypt.h"
|
||||
|
||||
QVariantMap qobject2qvariant( const QObject* object, const QStringList& ignoredProperties = QStringList(QString(QLatin1String("objectName"))) );
|
||||
|
||||
namespace KeepassHttpProtocol {
|
||||
|
||||
enum RequestType {
|
||||
|
@ -201,7 +201,7 @@ void Server::handleRequest(const QByteArray in, QByteArray *out)
|
||||
(getDatabaseRootUuid() + getDatabaseRecycleBinUuid()).toUtf8(),
|
||||
QCryptographicHash::Sha1).toHex();
|
||||
|
||||
Response protocolResp(r, QString::fromAscii(hash));
|
||||
Response protocolResp(r, QString::fromLatin1(hash));
|
||||
switch(r.requestType()) {
|
||||
case INVALID: break;
|
||||
case GET_LOGINS: getLogins(r, &protocolResp); break;
|
||||
|
@ -11,10 +11,10 @@
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
#include <QtGui/QInputDialog>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QProgressDialog>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QProgressDialog>
|
||||
#include <QDebug>
|
||||
|
||||
#include "Service.h"
|
||||
#include "Protocol.h"
|
||||
|
@ -14,7 +14,7 @@
|
||||
#ifndef SERVICE_H
|
||||
#define SERVICE_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QObject>
|
||||
#include "gui/DatabaseTabWidget.h"
|
||||
#include "Server.h"
|
||||
|
||||
|
@ -95,7 +95,7 @@ set(TEST_LIBRARIES
|
||||
|
||||
set(testsupport_SOURCES modeltest.cpp FailDevice.cpp)
|
||||
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
|
||||
LIBS ${TEST_LIBRARIES})
|
||||
|
@ -18,6 +18,7 @@ include_directories(../src)
|
||||
add_executable(kdbx-extract kdbx-extract.cpp)
|
||||
target_link_libraries(kdbx-extract
|
||||
keepassx_core
|
||||
${MHD_LIBRARIES}
|
||||
Qt5::Core
|
||||
Qt5::Concurrent
|
||||
Qt5::Widgets
|
||||
|
Loading…
Reference in New Issue
Block a user