diff --git a/CMakeLists.txt b/CMakeLists.txt index ef892ca0..7408da3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,178 +1,182 @@ # CMake version required. This must be the very first line, because it sets default policies affecting everything else cmake_minimum_required(VERSION 3.1) # Project name and version project(Falkon VERSION 3.0.99) # Find ECM, with nice error handling in case of failure include(FeatureSummary) find_package(ECM 5.27.0 CONFIG) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/frameworks/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # Many includes from ECM, to get all the nice cmake functions and settings include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMInstallIcons) include(ECMSetupVersion) include(ECMAddAppIcon) include(ECMQtDeclareLoggingCategory) include(ECMPoQmTools) # Output dirs (like ECM 5.38 does) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") if (UNIX AND NOT APPLE) set(FALKON_INSTALL_PLUGINDIR "${KDE_INSTALL_PLUGINDIR}/falkon") else() set(FALKON_INSTALL_PLUGINDIR "${KDE_INSTALL_PLUGINDIR}") endif() if (IS_ABSOLUTE ${FALKON_INSTALL_PLUGINDIR}) set(PLUGIN_PATH "${FALKON_INSTALL_PLUGINDIR}") else() set(PLUGIN_PATH "${CMAKE_INSTALL_PREFIX}/${FALKON_INSTALL_PLUGINDIR}") endif() if (NOT WIN32) set(FALKON_PLUGIN_PATH "${PLUGIN_PATH}" CACHE PATH "Default plugin search path") endif() # Defines that are always set add_definitions(-DQT_NO_URL_CAST_FROM_STRING -DQT_USE_QSTRINGBUILDER -DQT_NO_CAST_TO_ASCII) # Mandatory: Qt5 set(QT_MIN_VERSION "5.9.0") find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Widgets Network Sql QuickWidgets PrintSupport WebEngineWidgets WebChannel) if (BUILD_TESTING) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Test) endif() if (NOT DISABLE_DBUS) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS DBus) endif() if (UNIX AND NOT APPLE AND NOT NO_X11) add_definitions(-DQZ_WS_X11) find_package(XCB REQUIRED COMPONENTS XCB UTIL) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS X11Extras) endif() if (WIN32) add_definitions(-DW7API) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS WinExtras) # taken from https://stackoverflow.com/a/40217291 macro(get_WIN32_WINNT version) if (CMAKE_SYSTEM_VERSION) set(ver ${CMAKE_SYSTEM_VERSION}) string(REGEX MATCH "^([0-9]+).([0-9])" ver ${ver}) string(REGEX MATCH "^([0-9]+)" verMajor ${ver}) # Check for Windows 10, b/c we'll need to convert to hex 'A'. if ("${verMajor}" MATCHES "10") set(verMajor "A") string(REGEX REPLACE "^([0-9]+)" ${verMajor} ver ${ver}) endif ("${verMajor}" MATCHES "10") # Remove all remaining '.' characters. string(REPLACE "." "" ver ${ver}) # Prepend each digit with a zero. string(REGEX REPLACE "([0-9A-Z])" "0\\1" ver ${ver}) set(${version} "0x${ver}") endif(CMAKE_SYSTEM_VERSION) endmacro(get_WIN32_WINNT) get_WIN32_WINNT(ver) add_definitions(-D_WIN32_WINNT=${ver}) endif() # Mandatory: OpenSSL find_package(OpenSSL REQUIRED) # KF5I18n: Mandatory with downloaded translations (only for ki18n_install) if (EXISTS "${CMAKE_SOURCE_DIR}/po") find_package(KF5I18n REQUIRED) endif() # Optional: GnomeKeyring find_package(PkgConfig) if (PKG_CONFIG_FOUND) option(BUILD_KEYRING "Gnome keyring password plugin" ON) if (BUILD_KEYRING) pkg_check_modules(GNOME_KEYRING gnome-keyring-1) endif() endif() -# Optional: KWallet + KIO +# Optional: KWallet, KIO, KCrash, KCoreAddons set(KF5_MIN_VERSION "5.27.0") find_package(KF5Wallet ${KF5_MIN_VERSION} CONFIG) set_package_properties(KF5Wallet PROPERTIES DESCRIPTION "KDESupport plugin" TYPE OPTIONAL) find_package(KF5KIO ${KF5_MIN_VERSION} CONFIG) set_package_properties(KF5KIO PROPERTIES DESCRIPTION "KDESupport plugin" TYPE OPTIONAL) +find_package(KF5Crash ${KF5_MIN_VERSION} CONFIG) +set_package_properties(KF5Crash PROPERTIES DESCRIPTION "KDESupport plugin" TYPE OPTIONAL) +find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG) +set_package_properties(KF5CoreAddons PROPERTIES DESCRIPTION "KDESupport plugin" TYPE OPTIONAL) # Optional: PySide2 find_package(PySide2 "2.0.0") find_package(Shiboken2 "2.0.0") find_package(PythonLibs "3.0") set_package_properties(PySide2 PROPERTIES DESCRIPTION "Python plugins (experimental)" TYPE OPTIONAL) set_package_properties(Shiboken2 PROPERTIES DESCRIPTION "Python plugins (experimental)" TYPE OPTIONAL) set_package_properties(PythonLibs PROPERTIES DESCRIPTION "Python plugins (experimental)" TYPE OPTIONAL) if (PySide2_FOUND AND Shiboken2_FOUND AND PythonLibs_FOUND) set(ENABLE_PYTHON_PLUGINS TRUE) endif() # Git revision if (EXISTS "${CMAKE_SOURCE_DIR}/.git") find_package(Git QUIET) if(GIT_FOUND) execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_REVISION ) string(REGEX REPLACE "\n" "" GIT_REVISION "${GIT_REVISION}") set(FALKON_GIT_REVISION "${GIT_REVISION}") else() message(STATUS "Git revision could not be determined") endif() endif() configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/src/config.h) # Include dirs used everywhere include_directories( ${CMAKE_SOURCE_DIR}/src/lib/3rdparty ${CMAKE_SOURCE_DIR}/src/lib/adblock ${CMAKE_SOURCE_DIR}/src/lib/app ${CMAKE_SOURCE_DIR}/src/lib/autofill ${CMAKE_SOURCE_DIR}/src/lib/bookmarks ${CMAKE_SOURCE_DIR}/src/lib/cookies ${CMAKE_SOURCE_DIR}/src/lib/downloads ${CMAKE_SOURCE_DIR}/src/lib/history ${CMAKE_SOURCE_DIR}/src/lib/navigation ${CMAKE_SOURCE_DIR}/src/lib/network ${CMAKE_SOURCE_DIR}/src/lib/notifications ${CMAKE_SOURCE_DIR}/src/lib/opensearch ${CMAKE_SOURCE_DIR}/src/lib/other ${CMAKE_SOURCE_DIR}/src/lib/plugins ${CMAKE_SOURCE_DIR}/src/lib/popupwindow ${CMAKE_SOURCE_DIR}/src/lib/preferences ${CMAKE_SOURCE_DIR}/src/lib/session ${CMAKE_SOURCE_DIR}/src/lib/sidebar ${CMAKE_SOURCE_DIR}/src/lib/tabwidget ${CMAKE_SOURCE_DIR}/src/lib/tools ${CMAKE_SOURCE_DIR}/src/lib/webengine ${CMAKE_SOURCE_DIR}/src/lib/webtab ) # Finally, go into the subdirs add_subdirectory(src) if (BUILD_TESTING) add_subdirectory(autotests) add_subdirectory(tests/benchmarks) endif() # Tell releaseme that po is already taken care of # SKIP_PO_INSTALL feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 9107b5f2..9069d332 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -1,26 +1,26 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/plugins") add_subdirectory(AutoScroll) add_subdirectory(FlashCookieManager) add_subdirectory(GreaseMonkey) add_subdirectory(MouseGestures) add_subdirectory(PIM) add_subdirectory(StatusBarIcons) add_subdirectory(TabManager) add_subdirectory(VerticalTabs) if (GNOME_KEYRING_FOUND) add_subdirectory(GnomeKeyringPasswords) endif() -if (KF5Wallet_FOUND AND KF5KIO_FOUND) +if (KF5Wallet_FOUND AND KF5KIO_FOUND AND KF5Crash_FOUND AND KF5CoreAddons_FOUND) add_subdirectory(KDESupport) endif() if (ENABLE_PYTHON_PLUGINS) add_subdirectory(PyFalkon) endif() if (CMAKE_BUILD_TYPE STREQUAL "Debug") add_subdirectory(TestPlugin) endif() diff --git a/src/plugins/KDESupport/CMakeLists.txt b/src/plugins/KDESupport/CMakeLists.txt index 479b7e53..eea7e953 100644 --- a/src/plugins/KDESupport/CMakeLists.txt +++ b/src/plugins/KDESupport/CMakeLists.txt @@ -1,16 +1,23 @@ set(KDESupport_SRCS kdesupportplugin.cpp kwalletpasswordbackend.cpp kioschemehandler.cpp ) ecm_create_qm_loader(KDESupport_SRCS falkon_kdesupport_qt) set(KDESupport_RSCS kdesupport.qrc ) qt5_add_resources(RSCS ${KDESupport_RSCS}) add_library(KDESupport MODULE ${KDESupport_SRCS} ${RSCS}) install(TARGETS KDESupport DESTINATION ${FALKON_INSTALL_PLUGINDIR}) -target_link_libraries(KDESupport FalkonPrivate KF5::Wallet KF5::KIOCore KF5::KIOWidgets) +target_link_libraries(KDESupport + FalkonPrivate + KF5::Wallet + KF5::KIOCore + KF5::KIOWidgets + KF5::Crash + KF5::CoreAddons +) diff --git a/src/plugins/KDESupport/kdesupportplugin.cpp b/src/plugins/KDESupport/kdesupportplugin.cpp index deeae6d4..2ae5c809 100644 --- a/src/plugins/KDESupport/kdesupportplugin.cpp +++ b/src/plugins/KDESupport/kdesupportplugin.cpp @@ -1,82 +1,90 @@ /* ============================================================ * KDESupport - KDE support plugin for Falkon * Copyright (C) 2013-2018 David Rosca * * 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 * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ============================================================ */ #include "kdesupportplugin.h" #include "kwalletpasswordbackend.h" #include "pluginproxy.h" #include "browserwindow.h" #include "../config.h" #include "mainapplication.h" #include "autofill.h" #include "passwordmanager.h" #include "desktopfile.h" #include "kioschemehandler.h" #include "webpage.h" +#include +#include #include #include KDESupportPlugin::KDESupportPlugin() : QObject() , m_backend(0) { } DesktopFile KDESupportPlugin::metaData() const { return DesktopFile(QSL(":kdesupport/metadata.desktop")); } void KDESupportPlugin::init(InitState state, const QString &settingsPath) { Q_UNUSED(state); Q_UNUSED(settingsPath); m_backend = new KWalletPasswordBackend; mApp->autoFill()->passwordManager()->registerBackend(QSL("KWallet"), m_backend); const auto protocols = KProtocolInfo::protocols(); for (const QString &protocol : protocols) { if (WebPage::internalSchemes().contains(protocol)) { continue; } KIOSchemeHandler *handler = new KIOSchemeHandler(protocol, this); m_kioSchemeHandlers.append(handler); mApp->webProfile()->installUrlSchemeHandler(protocol.toUtf8(), handler); WebPage::addSupportedScheme(protocol); } + + KAboutData aboutData(QSL("falkon"), QSL("Falkon"), QCoreApplication::applicationVersion()); + KAboutData::setApplicationData(aboutData); + + KCrash::initialize(); + KCrash::setFlags(KCrash::KeepFDs); } void KDESupportPlugin::unload() { mApp->autoFill()->passwordManager()->unregisterBackend(m_backend); delete m_backend; for (KIOSchemeHandler *handler : qAsConst(m_kioSchemeHandlers)) { mApp->webProfile()->removeUrlSchemeHandler(handler); WebPage::removeSupportedScheme(handler->protocol()); delete handler; } m_kioSchemeHandlers.clear(); } bool KDESupportPlugin::testPlugin() { // Require the version that the plugin was built with return (Qz::VERSION == QLatin1String(FALKON_VERSION)); }