Skip to content

Commit

Permalink
Deprecate KeePassHTTP and introduce WITH_XC_NETWORKING CMake option
Browse files Browse the repository at this point in the history
  • Loading branch information
phoerious committed Jan 18, 2018
1 parent 5001731 commit 77314f4
Show file tree
Hide file tree
Showing 17 changed files with 127 additions and 43 deletions.
13 changes: 10 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (C) 2010 Felix Geyer <[email protected]>
# Copyright (C) 2017 KeePassXC Team <[email protected]>
# Copyright (C) 2010 Felix Geyer <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -41,10 +41,17 @@ option(WITH_COVERAGE "Use to build with coverage tests (GCC only)." OFF)
option(WITH_APP_BUNDLE "Enable Application Bundle for macOS" ON)

option(WITH_XC_AUTOTYPE "Include Auto-Type." ON)
option(WITH_XC_HTTP "Include KeePassHTTP and Custom Icon Downloads." OFF)
option(WITH_XC_NETWORKING "Include networking code (e.g. for downlading website icons)." OFF)
option(WITH_XC_BROWSER "Include browser integration with keepassxc-browser." OFF)
option(WITH_XC_HTTP "Include KeePassHTTP-compatible browser integration (deprecated, implies WITH_NETWORKING)." OFF)
option(WITH_XC_YUBIKEY "Include YubiKey support." OFF)
option(WITH_XC_SSHAGENT "Include SSH agent support." OFF)
option(WITH_XC_BROWSER "Include browser extension support." OFF)

if(WITH_XC_HTTP)
message(WARNING "KeePassHTTP support has been deprecated and will be removed in a future version. Please use WITH_XC_BROWSER instead!\n"
"For enabling / disabling network access code, WITH_XC_HTTP has been replaced by WITH_XC_NETWORKING.")
set(WITH_XC_NETWORKING ON CACHE BOOL "Include networking code (e.g. for downlading website icons)." FORCE)
endif()

# Process ui files automatically from source files
set(CMAKE_AUTOUIC ON)
Expand Down
21 changes: 14 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,21 @@ set(keepassx_SOURCES_MAINEXE
main.cpp
)

add_feature_info(AutoType WITH_XC_AUTOTYPE "Automatic password typing")
add_feature_info(KeePassHTTP WITH_XC_HTTP "Browser integration compatible with ChromeIPass and PassIFox")
add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response")
add_feature_info(Auto-Type WITH_XC_AUTOTYPE "Automatic password typing")
add_feature_info(Networking WITH_XC_NETWORKING "Compile KeePassXC with network access code (e.g. for downloading website icons)")
add_feature_info(keepassxc-browser WITH_XC_BROWSER "Browser integration with keepassxc-browser")
add_feature_info(KeePassHTTP WITH_XC_HTTP "Browser integration compatible with ChromeIPass and PassIFox (deprecated, implies Networking)")
add_feature_info(SSHAgent WITH_XC_SSHAGENT "SSH agent integration compatible with KeeAgent")
add_feature_info(keepassxc-browser WITH_XC_BROWSER "KeePassXC browser support with keepassxc-browser")
add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response")


add_subdirectory(http)
if(WITH_XC_HTTP)
set(keepasshttp_LIB keepasshttp qhttp Qt5::Network)
add_subdirectory(http)
set(keepasshttp_LIB keepasshttp)
endif()
if(WITH_XC_NETWORKING)
add_subdirectory(http/qhttp)
set(keepassxcnetwork_LIB qhttp Qt5::Network)
endif()

set(BROWSER_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/browser)
Expand Down Expand Up @@ -247,8 +253,9 @@ add_library(keepassx_core STATIC ${keepassx_SOURCES})

set_target_properties(keepassx_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
target_link_libraries(keepassx_core
${keepasshttp_LIB}
${keepassxcbrowser_LIB}
${keepasshttp_LIB}
${keepassxcnetwork_LIB}
${autotype_LIB}
${sshagent_LIB}
${YUBIKEY_LIBRARIES}
Expand Down
3 changes: 2 additions & 1 deletion src/browser/BrowserOptionDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "core/FilePath.h"

#include <QMessageBox>
#include <QtWidgets/QFileDialog>
#include <QFileDialog>

BrowserOptionDialog::BrowserOptionDialog(QWidget* parent) :
QWidget(parent),
Expand All @@ -36,6 +36,7 @@ BrowserOptionDialog::BrowserOptionDialog(QWidget* parent) :
m_ui->warningWidget->showMessage(tr("The following options can be dangerous!\nChange them only if you know what you are doing."), MessageWidget::Warning);
m_ui->warningWidget->setIcon(FilePath::instance()->icon("status", "dialog-warning"));
m_ui->warningWidget->setCloseButtonVisible(false);
m_ui->warningWidget->setAutoHideTimeout(-1);

m_ui->tabWidget->setEnabled(m_ui->enableBrowserSupport->isChecked());
connect(m_ui->enableBrowserSupport, SIGNAL(toggled(bool)), m_ui->tabWidget, SLOT(setEnabled(bool)));
Expand Down
5 changes: 3 additions & 2 deletions src/config-keepassx.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
#define KEEPASSX_PLUGIN_DIR "${PLUGIN_INSTALL_DIR}"
#define KEEPASSX_DATA_DIR "${DATA_INSTALL_DIR}"

#cmakedefine WITH_XC_HTTP
#cmakedefine WITH_XC_AUTOTYPE
#cmakedefine WITH_XC_NETWORKING
#cmakedefine WITH_XC_BROWSER
#cmakedefine WITH_XC_HTTP
#cmakedefine WITH_XC_YUBIKEY
#cmakedefine WITH_XC_SSHAGENT
#cmakedefine WITH_XC_BROWSER

#cmakedefine KEEPASSXC_DIST
#cmakedefine KEEPASSXC_DIST_TYPE "@KEEPASSXC_DIST_TYPE@"
Expand Down
14 changes: 7 additions & 7 deletions src/gui/AboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,20 @@ AboutDialog::AboutDialog(QWidget* parent)
#endif

QString extensions;
#ifdef WITH_XC_HTTP
extensions += "\n- KeePassHTTP";
#endif
#ifdef WITH_XC_AUTOTYPE
extensions += "\n- Auto-Type";
#endif
#ifdef WITH_XC_YUBIKEY
extensions += "\n- YubiKey";
#ifdef WITH_XC_BROWSER
extensions += "\n- Browser Integration";
#endif
#ifdef WITH_XC_HTTP
extensions += "\n- Legacy Browser Integration (KeePassHTTP)";
#endif
#ifdef WITH_XC_SSHAGENT
extensions += "\n- SSH Agent";
#endif
#ifdef WITH_XC_BROWSER
extensions += "\n- Native messaging browser extension";
#ifdef WITH_XC_YUBIKEY
extensions += "\n- YubiKey";
#endif

if (extensions.isEmpty())
Expand Down
14 changes: 8 additions & 6 deletions src/gui/EditWidgetIcons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "gui/IconModels.h"
#include "gui/MessageBox.h"

#ifdef WITH_XC_HTTP
#ifdef WITH_XC_NETWORKING
#include "http/qhttp/qhttpclient.hpp"
#include "http/qhttp/qhttpclientresponse.hpp"

Expand All @@ -49,11 +49,13 @@ EditWidgetIcons::EditWidgetIcons(QWidget* parent)
, m_database(nullptr)
, m_defaultIconModel(new DefaultIconModel(this))
, m_customIconModel(new CustomIconModel(this))
#ifdef WITH_XC_HTTP
#ifdef WITH_XC_NETWORKING
, m_fallbackToGoogle(true)
, m_redirectCount(0)
#endif
#ifdef WITH_XC_HTTP
, m_httpClient(nullptr)
#endif
#endif
{
m_ui->setupUi(this);

Expand Down Expand Up @@ -146,7 +148,7 @@ void EditWidgetIcons::load(const Uuid& currentUuid, Database* database, const Ic

void EditWidgetIcons::setUrl(const QString& url)
{
#ifdef WITH_XC_HTTP
#ifdef WITH_XC_NETWORKING
m_url = url;
m_ui->faviconButton->setVisible(!url.isEmpty());
resetFaviconDownload();
Expand All @@ -158,14 +160,14 @@ void EditWidgetIcons::setUrl(const QString& url)

void EditWidgetIcons::downloadFavicon()
{
#ifdef WITH_XC_HTTP
#ifdef WITH_XC_NETWORKING
QUrl url = QUrl(m_url);
url.setPath("/favicon.ico");
fetchFavicon(url);
#endif
}

#ifdef WITH_XC_HTTP
#ifdef WITH_XC_NETWORKING
void EditWidgetIcons::fetchFavicon(const QUrl& url)
{
if (nullptr == m_httpClient) {
Expand Down
6 changes: 3 additions & 3 deletions src/gui/EditWidgetIcons.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Database;
class DefaultIconModel;
class CustomIconModel;

#ifdef WITH_XC_HTTP
#ifdef WITH_XC_NETWORKING
namespace qhttp {
namespace client {
class QHttpClient;
Expand Down Expand Up @@ -73,7 +73,7 @@ public slots:

private slots:
void downloadFavicon();
#ifdef WITH_XC_HTTP
#ifdef WITH_XC_NETWORKING
void fetchFavicon(const QUrl& url);
void fetchFaviconFromGoogle(const QString& domain);
void resetFaviconDownload(bool clearRedirect = true);
Expand All @@ -93,7 +93,7 @@ private slots:
QString m_url;
DefaultIconModel* const m_defaultIconModel;
CustomIconModel* const m_customIconModel;
#ifdef WITH_XC_HTTP
#ifdef WITH_XC_NETWORKING
QUrl m_redirectUrl;
bool m_fallbackToGoogle;
unsigned short m_redirectCount;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/KMessageWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void KMessageWidget::setMessageType(KMessageWidget::MessageType type)
bg1 = palette().highlight().color();
break;
case Warning:
bg1.setRgb(181, 102, 0); // values taken from kcolorscheme.cpp (Neutral)
bg1.setRgb(191, 126, 7); // values taken from kcolorscheme.cpp (Neutral)
break;
case Error:
bg1.setRgb(191, 3, 3); // values taken from kcolorscheme.cpp (Negative)
Expand Down
37 changes: 36 additions & 1 deletion src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QMimeData>
#include <QShortcut>
#include <QTimer>
#include <QDesktopServices>

#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(QT_NO_DBUS)
#include <QList>
Expand Down Expand Up @@ -195,6 +196,9 @@ MainWindow::MainWindow()

setWindowIcon(filePath()->applicationIcon());
m_ui->globalMessageWidget->setHidden(true);
connect(m_ui->globalMessageWidget, SIGNAL(linkActivated(const QString&)), this, SLOT(openLink(const QString&)));
connect(m_ui->globalMessageWidget, SIGNAL(showAnimationStarted()), m_ui->globalMessageWidgetContainer, SLOT(show()));
connect(m_ui->globalMessageWidget, SIGNAL(hideAnimationFinished()), m_ui->globalMessageWidgetContainer, SLOT(hide()));

m_clearHistoryAction = new QAction(tr("Clear history"), m_ui->menuFile);
m_lastDatabasesActions = new QActionGroup(m_ui->menuRecentDatabases);
Expand Down Expand Up @@ -407,13 +411,44 @@ MainWindow::MainWindow()
m_ui->globalMessageWidget->showMessage(
tr("Access error for config file %1").arg(config()->getFileName()), MessageWidget::Error);
}

#ifdef WITH_XC_HTTP
if (config()->get("Http/Enabled", false).toBool() && !config()->get("Http/DeprecationNoticeShown", false).toBool()) {
// show message after tab widget dismissed all messages
connect(m_ui->tabWidget, SIGNAL(messageDismissGlobal()), this, SLOT(showKeePassHTTPDeprecationNotice()));
}
#endif
}

MainWindow::~MainWindow()
{
}

void MainWindow::showKeePassHTTPDeprecationNotice()
{
displayGlobalMessage(tr("<p>It looks like you are using KeePassHTTP for browser integration.<br>"
"This feature has been deprecated and will be removed in the future.<br>"
"Please switch to keepassxc-browser instead! For help with migration,<br>"
"visit our <a href=\"https://keepassxc.org/docs/keepassxc-browser-migration\">"
"keepassxc-browser migration guide</a>.</p>"),
MessageWidget::Warning, true, -1);

config()->set("Http/DeprecationNoticeShown", true);
disconnect(m_ui->tabWidget, SIGNAL(messageDismissGlobal()), this, SLOT(showKeePassHTTPDeprecationNotice()));
}

/**
* Open a link using the system's default handler.
* Links that are not HTTP(s) links are ignored.
*
* @param link link URL
*/
void MainWindow::openLink(const QString& link)
{
if (link.startsWith("http://") || link.startsWith("https://")) {
QDesktopServices::openUrl(QUrl(link));
}
}

void MainWindow::appExit()
{
m_appExitCalled = true;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ private slots:
void repairDatabase();
void hideTabMessage();
void handleScreenLock();
void showKeePassHTTPDeprecationNotice();
void openLink(const QString& link);

private:
static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0);
Expand Down
32 changes: 25 additions & 7 deletions src/gui/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
Expand All @@ -34,13 +37,28 @@
<number>0</number>
</property>
<item>
<widget class="MessageWidget" name="globalMessageWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QWidget" name="globalMessageWidgetContainer" native="true">
<layout class="QVBoxLayout" name="globalMessageWidgetLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="MessageWidget" name="globalMessageWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">MessageWidget {margin: 90px}</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
Expand Down
1 change: 1 addition & 0 deletions src/gui/MessageWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void MessageWidget::showMessage(const QString &text, KMessageWidget::MessageType
{
setMessageType(type);
setText(text);
emit showAnimationStarted();
animatedShow();
if (autoHideTimeout > 0) {
m_autoHideTimer->start(autoHideTimeout);
Expand Down
3 changes: 3 additions & 0 deletions src/gui/MessageWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class MessageWidget : public KMessageWidget
static const int DefaultAutoHideTimeout;
static const int DisableAutoHide;

signals:
void showAnimationStarted();

public slots:
void showMessage(const QString& text, MessageWidget::MessageType type);
void showMessage(const QString& text, MessageWidget::MessageType type, int autoHideTimeout);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/SettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ SettingsWidget::SettingsWidget(QWidget* parent)
connect(m_secUi->lockDatabaseIdleCheckBox, SIGNAL(toggled(bool)),
m_secUi->lockDatabaseIdleSpinBox, SLOT(setEnabled(bool)));

#ifndef WITH_XC_HTTP
#ifndef WITH_XC_NETWORKING
m_secUi->privacy->setVisible(false);
#endif
}
Expand Down
2 changes: 0 additions & 2 deletions src/http/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
add_subdirectory(qhttp)

if(WITH_XC_HTTP)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})

Expand Down
2 changes: 2 additions & 0 deletions src/http/OptionDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ OptionDialog::OptionDialog(QWidget *parent) :

m_ui->tabWidget->setEnabled(m_ui->enableHttpServer->isChecked());
connect(m_ui->enableHttpServer, SIGNAL(toggled(bool)), m_ui->tabWidget, SLOT(setEnabled(bool)));

m_ui->deprecationNotice->setOpenExternalLinks(true);
}

OptionDialog::~OptionDialog()
Expand Down
11 changes: 9 additions & 2 deletions src/http/OptionDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>577</width>
<height>404</height>
<width>803</width>
<height>433</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -26,6 +26,13 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="deprecationNotice">
<property name="text">
<string>&lt;p&gt;&lt;b&gt;NOTE:&lt;/b&gt; KeePassHTTP has been deprecated and will be removed in the future.&lt;br&gt;Please switch to keepassxc-browser instead! For help with migration, visit our &lt;a href=&quot;https://keepassxc.org/docs/keepassxc-browser-migration&quot;&gt;keepassxc-browser migration guide&lt;/a&gt;.&lt;/p&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableHttpServer">
<property name="toolTip">
Expand Down

0 comments on commit 77314f4

Please sign in to comment.