kdeconnect-kde/CMakeLists.txt
Philip Cohn-Cort c315170be5 Finally, we have support for sending out Battery information.
## Summary

The core idea is as follows:

1. When a Link loads the BatteryPlugin, we query Solid for a list of batteries.
    1. If the list is empty, we print a warning message and return quickly
    2. Otherwise, we connect *two signals* to every object in that list
2. We send out a single new NetworkPacket as soon as we've processed that list
3. When either of those two signals emits, we send another new NetworkPacket

### Multi-battery Support

BUG: 357193

To handle devices with multiple batteries (requested in that bug), we average
together the battery percentages. This also includes a new field in the packet for
'number of batteries' called `batteryQuantity`. For backwards compatibility, we can
assume it has a default value of one.

This should ensure we support
- devices with no batteries at all (like many desktop machines)
- devices with hot-pluggable batteries (like those laptops with detachable screens)

### Concerns

Note that the implementation isn't perfect.
We'll need some new localizable text to make it clear that we now support sending
battery status information.

Then there's a rather significant question: maybe we should have two battery plugins
on each client, like we do for the `findmyphone`/`findthisdevice` plugins?

## Test Plan

We need to ensure that other clients (including those using the Android codebase)
will respond correctly. The main things to look at are
1. are these new packets sent when the plugin is enabled, and not sent when it's disabled?
2. is the charge percentage accurate?
3. is the charge state (charging, discharging, or full) accurate?
and
4. do we see the correct number of warnings for low-battery?
2020-04-13 05:54:11 +00:00

127 lines
3.4 KiB
CMake

cmake_minimum_required(VERSION 3.0)
project(kdeconnect)
if (SAILFISHOS)
set(KF5_MIN_VERSION "5.36.0")
set(QT_MIN_VERSION "5.6.0")
else()
set(KF5_MIN_VERSION "5.64.0")
set(QT_MIN_VERSION "5.10.0")
endif()
set(QCA_MIN_VERSION "2.1.0")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
include(KDEInstallDirs)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
include(ECMAddTests)
include(ECMSetupVersion)
include(ECMInstallIcons)
include(FeatureSummary)
include(GenerateExportHeader)
if (NOT SAILFISHOS)
include(ECMQMLModules)
endif()
include(KDEConnectMacros.cmake)
ecm_setup_version(1.4.0
VARIABLE_PREFIX KDECONNECT
VERSION_HEADER ${CMAKE_CURRENT_BINARY_DIR}/kdeconnect-version.h
)
if (SAILFISHOS)
set(KF5_REQUIRED_COMPONENTS I18n CoreAddons Config)
set(KF5_OPTIONAL_COMPONENTS)
set(Qca_LIBRARY CONAN_PKG::Qca-qt5)
add_definitions(-DSAILFISHOS)
else()
find_package(Qca-qt5 ${QCA_MIN_VERSION} REQUIRED)
set(Qca_LIBRARY qca-qt5)
set(KF5_REQUIRED_COMPONENTS I18n ConfigWidgets DBusAddons IconThemes Notifications KIO KCMUtils Service Solid Kirigami2 People)
set(KF5_OPTIONAL_COMPONENTS DocTools)
set_package_properties(KF5Kirigami2 PROPERTIES
DESCRIPTION "QtQuick plugins to build user interfaces based on KDE UX guidelines"
PURPOSE "Required for KDE Connect's QML-based GUI applications"
URL "https://www.kde.org/products/kirigami/"
TYPE RUNTIME
)
if(UNIX AND NOT APPLE)
find_package(KF5PulseAudioQt)
endif()
find_package(KF5PeopleVCard)
set_package_properties(KF5PeopleVCard PROPERTIES
PURPOSE "Read vcards from the file system"
URL "https://phabricator.kde.org/source/kpeoplevcard/"
TYPE RUNTIME
)
add_definitions(-DHAVE_KIO)
ecm_find_qmlmodule(org.kde.people 1.0)
ecm_find_qmlmodule(QtQuick.Particles 2.0)
endif()
add_definitions(-DQT_NO_URL_CAST_FROM_STRING -DQT_NO_KEYWORDS -DQT_NO_CAST_FROM_ASCII)
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS DBus Quick Network Multimedia)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS ${KF5_REQUIRED_COMPONENTS})
if (KF5_OPTIONAL_COMPONENTS)
find_package(KF5 ${KF5_MIN_VERSION} COMPONENTS ${KF5_OPTIONAL_COMPONENTS})
endif()
if (NOT ZSH_AUTOCOMPLETE_DIR)
set(ZSH_AUTOCOMPLETE_DIR "${CMAKE_INSTALL_PREFIX}/share/zsh/site-functions")
endif()
option(PRIVATE_DBUS_ENABLED "Use private dbus session for kdeconnect" OFF)
if(PRIVATE_DBUS_ENABLED OR APPLE)
add_compile_definitions(USE_PRIVATE_DBUS)
endif()
add_subdirectory(core)
add_subdirectory(plugins)
add_subdirectory(interfaces)
if (NOT SAILFISHOS)
add_subdirectory(icon)
add_subdirectory(data)
add_subdirectory(cli)
add_subdirectory(declarativeplugin)
add_subdirectory(kcm)
add_subdirectory(kcmplugin)
add_subdirectory(daemon)
add_subdirectory(app)
add_subdirectory(indicator)
add_subdirectory(urlhandler)
add_subdirectory(nautilus-extension)
add_subdirectory(fileitemactionplugin)
add_subdirectory(smsapp)
add_subdirectory(settings)
if(NOT WIN32)
add_subdirectory(kio)
add_subdirectory(plasmoid)
endif()
endif()
if(KF5DocTools_FOUND)
add_subdirectory(doc)
endif()
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)