From 3139ae152841e07ba1a69764f2602f50f6f3bbcd Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Thu, 2 Mar 2017 18:44:01 -0500 Subject: [PATCH] WITH_XC_AUTOTYPE defaults to ON and WITH_XC_HTTP includes ALL networking --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 4 +--- src/gui/EditWidgetIcons.cpp | 15 +++++++++++++++ src/gui/EditWidgetIcons.h | 12 ++++++++++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 347c52768..4d1ed7f57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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_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_YUBIKEY "Include Yubikey support." OFF) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0c539b50d..53b62ae75 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -155,7 +155,7 @@ add_feature_info(Autotype WITH_XC_AUTOTYPE "Auto-type passwords in Input fields" add_subdirectory(http) if(WITH_XC_HTTP) - set(keepasshttp_LIB keepasshttp) + set(keepasshttp_LIB keepasshttp qhttp Qt5::Network) endif() add_subdirectory(autotype) @@ -196,11 +196,9 @@ target_link_libraries(keepassx_core ${keepasshttp_LIB} ${autotype_LIB} zxcvbn - qhttp Qt5::Core Qt5::Concurrent Qt5::Widgets - Qt5::Network ${GCRYPT_LIBRARIES} ${GPGERROR_LIBRARIES} ${ZLIB_LIBRARIES}) diff --git a/src/gui/EditWidgetIcons.cpp b/src/gui/EditWidgetIcons.cpp index 8cd9837d8..74e57cdd4 100644 --- a/src/gui/EditWidgetIcons.cpp +++ b/src/gui/EditWidgetIcons.cpp @@ -28,10 +28,12 @@ #include "gui/IconModels.h" #include "gui/MessageBox.h" +#ifdef WITH_XC_HTTP #include "http/qhttp/qhttpclient.hpp" #include "http/qhttp/qhttpclientresponse.hpp" using namespace qhttp::client; +#endif IconStruct::IconStruct() : uuid(Uuid()) @@ -45,7 +47,9 @@ EditWidgetIcons::EditWidgetIcons(QWidget* parent) , m_database(nullptr) , m_defaultIconModel(new DefaultIconModel(this)) , m_customIconModel(new CustomIconModel(this)) + #ifdef WITH_XC_HTTP , m_httpClient(nullptr) + #endif { m_ui->setupUi(this); @@ -65,6 +69,9 @@ EditWidgetIcons::EditWidgetIcons(QWidget* parent) connect(m_ui->faviconButton, SIGNAL(clicked()), SLOT(downloadFavicon())); m_ui->faviconButton->setVisible(false); + + m_fallbackToGoogle = true; + m_redirectCount = 0; } EditWidgetIcons::~EditWidgetIcons() @@ -138,18 +145,25 @@ void EditWidgetIcons::load(const Uuid& currentUuid, Database* database, const Ic void EditWidgetIcons::setUrl(const QString& url) { +#ifdef WITH_XC_HTTP m_url = url; m_ui->faviconButton->setVisible(!url.isEmpty()); resetFaviconDownload(); +#else + m_ui->faviconButton->setVisible(false); +#endif } void EditWidgetIcons::downloadFavicon() { +#ifdef WITH_XC_HTTP QUrl url = QUrl(m_url); url.setPath("/favicon.ico"); fetchFavicon(url); +#endif } +#ifdef WITH_XC_HTTP void EditWidgetIcons::fetchFavicon(const QUrl& url) { if (nullptr == m_httpClient) { @@ -241,6 +255,7 @@ void EditWidgetIcons::resetFaviconDownload(bool clearRedirect) m_fallbackToGoogle = true; m_ui->faviconButton->setDisabled(false); } +#endif void EditWidgetIcons::addCustomIcon() { diff --git a/src/gui/EditWidgetIcons.h b/src/gui/EditWidgetIcons.h index 829a5d2db..467796266 100644 --- a/src/gui/EditWidgetIcons.h +++ b/src/gui/EditWidgetIcons.h @@ -22,6 +22,7 @@ #include #include +#include "config-keepassx.h" #include "core/Global.h" #include "core/Uuid.h" #include "gui/MessageWidget.h" @@ -30,11 +31,14 @@ class Database; class DefaultIconModel; class CustomIconModel; +#ifdef WITH_XC_HTTP namespace qhttp { namespace client { class QHttpClient; } } +#endif + namespace Ui { class EditWidgetIcons; } @@ -68,9 +72,11 @@ Q_SIGNALS: private Q_SLOTS: void downloadFavicon(); +#ifdef WITH_XC_HTTP void fetchFavicon(const QUrl& url); void fetchFaviconFromGoogle(const QString& domain); void resetFaviconDownload(bool clearRedirect = true); +#endif void addCustomIcon(); void removeCustomIcon(); void updateWidgetsDefaultIcons(bool checked); @@ -84,11 +90,13 @@ private: Uuid m_currentUuid; QString m_url; QUrl m_redirectUrl; - bool m_fallbackToGoogle = true; - unsigned short m_redirectCount = 0; + bool m_fallbackToGoogle; + unsigned short m_redirectCount; DefaultIconModel* const m_defaultIconModel; CustomIconModel* const m_customIconModel; +#ifdef WITH_XC_HTTP qhttp::client::QHttpClient* m_httpClient; +#endif Q_DISABLE_COPY(EditWidgetIcons) };