WITH_XC_AUTOTYPE defaults to ON and WITH_XC_HTTP includes ALL networking

This commit is contained in:
Jonathan White 2017-03-02 18:44:01 -05:00
parent cdce9e27fb
commit 3139ae1528
No known key found for this signature in database
GPG Key ID: 440FC65F2E0C6E01
4 changed files with 27 additions and 6 deletions

View File

@ -34,7 +34,7 @@ option(WITH_GUI_TESTS "Enable building of GUI tests" OFF)
option(WITH_DEV_BUILD "Use only for development. Disables/warns about deprecated methods." OFF) option(WITH_DEV_BUILD "Use only for development. Disables/warns about deprecated methods." OFF)
option(WITH_COVERAGE "Use to build with coverage tests. (GCC ONLY)." OFF) option(WITH_COVERAGE "Use to build with coverage tests. (GCC ONLY)." OFF)
option(WITH_XC_AUTOTYPE "Include Autotype." OFF) option(WITH_XC_AUTOTYPE "Include Autotype." ON)
option(WITH_XC_HTTP "Include KeePassHTTP." OFF) option(WITH_XC_HTTP "Include KeePassHTTP." OFF)
option(WITH_XC_YUBIKEY "Include Yubikey support." OFF) option(WITH_XC_YUBIKEY "Include Yubikey support." OFF)

View File

@ -155,7 +155,7 @@ add_feature_info(Autotype WITH_XC_AUTOTYPE "Auto-type passwords in Input fields"
add_subdirectory(http) add_subdirectory(http)
if(WITH_XC_HTTP) if(WITH_XC_HTTP)
set(keepasshttp_LIB keepasshttp) set(keepasshttp_LIB keepasshttp qhttp Qt5::Network)
endif() endif()
add_subdirectory(autotype) add_subdirectory(autotype)
@ -196,11 +196,9 @@ target_link_libraries(keepassx_core
${keepasshttp_LIB} ${keepasshttp_LIB}
${autotype_LIB} ${autotype_LIB}
zxcvbn zxcvbn
qhttp
Qt5::Core Qt5::Core
Qt5::Concurrent Qt5::Concurrent
Qt5::Widgets Qt5::Widgets
Qt5::Network
${GCRYPT_LIBRARIES} ${GCRYPT_LIBRARIES}
${GPGERROR_LIBRARIES} ${GPGERROR_LIBRARIES}
${ZLIB_LIBRARIES}) ${ZLIB_LIBRARIES})

View File

@ -28,10 +28,12 @@
#include "gui/IconModels.h" #include "gui/IconModels.h"
#include "gui/MessageBox.h" #include "gui/MessageBox.h"
#ifdef WITH_XC_HTTP
#include "http/qhttp/qhttpclient.hpp" #include "http/qhttp/qhttpclient.hpp"
#include "http/qhttp/qhttpclientresponse.hpp" #include "http/qhttp/qhttpclientresponse.hpp"
using namespace qhttp::client; using namespace qhttp::client;
#endif
IconStruct::IconStruct() IconStruct::IconStruct()
: uuid(Uuid()) : uuid(Uuid())
@ -45,7 +47,9 @@ EditWidgetIcons::EditWidgetIcons(QWidget* parent)
, m_database(nullptr) , m_database(nullptr)
, m_defaultIconModel(new DefaultIconModel(this)) , m_defaultIconModel(new DefaultIconModel(this))
, m_customIconModel(new CustomIconModel(this)) , m_customIconModel(new CustomIconModel(this))
#ifdef WITH_XC_HTTP
, m_httpClient(nullptr) , m_httpClient(nullptr)
#endif
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
@ -65,6 +69,9 @@ EditWidgetIcons::EditWidgetIcons(QWidget* parent)
connect(m_ui->faviconButton, SIGNAL(clicked()), SLOT(downloadFavicon())); connect(m_ui->faviconButton, SIGNAL(clicked()), SLOT(downloadFavicon()));
m_ui->faviconButton->setVisible(false); m_ui->faviconButton->setVisible(false);
m_fallbackToGoogle = true;
m_redirectCount = 0;
} }
EditWidgetIcons::~EditWidgetIcons() EditWidgetIcons::~EditWidgetIcons()
@ -138,18 +145,25 @@ void EditWidgetIcons::load(const Uuid& currentUuid, Database* database, const Ic
void EditWidgetIcons::setUrl(const QString& url) void EditWidgetIcons::setUrl(const QString& url)
{ {
#ifdef WITH_XC_HTTP
m_url = url; m_url = url;
m_ui->faviconButton->setVisible(!url.isEmpty()); m_ui->faviconButton->setVisible(!url.isEmpty());
resetFaviconDownload(); resetFaviconDownload();
#else
m_ui->faviconButton->setVisible(false);
#endif
} }
void EditWidgetIcons::downloadFavicon() void EditWidgetIcons::downloadFavicon()
{ {
#ifdef WITH_XC_HTTP
QUrl url = QUrl(m_url); QUrl url = QUrl(m_url);
url.setPath("/favicon.ico"); url.setPath("/favicon.ico");
fetchFavicon(url); fetchFavicon(url);
#endif
} }
#ifdef WITH_XC_HTTP
void EditWidgetIcons::fetchFavicon(const QUrl& url) void EditWidgetIcons::fetchFavicon(const QUrl& url)
{ {
if (nullptr == m_httpClient) { if (nullptr == m_httpClient) {
@ -241,6 +255,7 @@ void EditWidgetIcons::resetFaviconDownload(bool clearRedirect)
m_fallbackToGoogle = true; m_fallbackToGoogle = true;
m_ui->faviconButton->setDisabled(false); m_ui->faviconButton->setDisabled(false);
} }
#endif
void EditWidgetIcons::addCustomIcon() void EditWidgetIcons::addCustomIcon()
{ {

View File

@ -22,6 +22,7 @@
#include <QSet> #include <QSet>
#include <QUrl> #include <QUrl>
#include "config-keepassx.h"
#include "core/Global.h" #include "core/Global.h"
#include "core/Uuid.h" #include "core/Uuid.h"
#include "gui/MessageWidget.h" #include "gui/MessageWidget.h"
@ -30,11 +31,14 @@ class Database;
class DefaultIconModel; class DefaultIconModel;
class CustomIconModel; class CustomIconModel;
#ifdef WITH_XC_HTTP
namespace qhttp { namespace qhttp {
namespace client { namespace client {
class QHttpClient; class QHttpClient;
} }
} }
#endif
namespace Ui { namespace Ui {
class EditWidgetIcons; class EditWidgetIcons;
} }
@ -68,9 +72,11 @@ Q_SIGNALS:
private Q_SLOTS: private Q_SLOTS:
void downloadFavicon(); void downloadFavicon();
#ifdef WITH_XC_HTTP
void fetchFavicon(const QUrl& url); void fetchFavicon(const QUrl& url);
void fetchFaviconFromGoogle(const QString& domain); void fetchFaviconFromGoogle(const QString& domain);
void resetFaviconDownload(bool clearRedirect = true); void resetFaviconDownload(bool clearRedirect = true);
#endif
void addCustomIcon(); void addCustomIcon();
void removeCustomIcon(); void removeCustomIcon();
void updateWidgetsDefaultIcons(bool checked); void updateWidgetsDefaultIcons(bool checked);
@ -84,11 +90,13 @@ private:
Uuid m_currentUuid; Uuid m_currentUuid;
QString m_url; QString m_url;
QUrl m_redirectUrl; QUrl m_redirectUrl;
bool m_fallbackToGoogle = true; bool m_fallbackToGoogle;
unsigned short m_redirectCount = 0; unsigned short m_redirectCount;
DefaultIconModel* const m_defaultIconModel; DefaultIconModel* const m_defaultIconModel;
CustomIconModel* const m_customIconModel; CustomIconModel* const m_customIconModel;
#ifdef WITH_XC_HTTP
qhttp::client::QHttpClient* m_httpClient; qhttp::client::QHttpClient* m_httpClient;
#endif
Q_DISABLE_COPY(EditWidgetIcons) Q_DISABLE_COPY(EditWidgetIcons)
}; };