Commit graph

40 commits

Author SHA1 Message Date
Alexander Lohnau
69d6c17214 plugins: Use QLatin1String::arg for faster and simpler string concatination
Using an infix with .arg() is simpler than having two string literals
2023-08-28 17:20:46 +00:00
Albert Vaca Cintora
abb6dfcc6e plugins: Add context-aware logging in case of errors
Also clean up some unneeded statements
2023-08-03 20:54:38 +02:00
Alexander Lohnau
1631ada5b3 Simplify KDEConnectPlugin::recievePacket
- We do not need the return type. If a plugin declares it can handle the
  packet it should do so. We don't have any fallback logic in place and
  the packet types are namespaced with the plugin IDs anyway.

- Provide a default implementation with a warning, not all plugins need
  to overwrite this
2023-08-03 20:49:44 +02:00
Alexander Lohnau
2e67f95017 Add explicit moc includes to cpp files
The rationale is explained in https://planet.kde.org/friedrich-kossebau-2023-06-28-include-also-moc-files-of-headers/

In case of KDEConnect, it impressively speeds up compilation. Before it
took 390 seconds on a clean build and with this change it took 330 seconds.
This is due to the mocs_compilation having to include the header files
and thus all their headers. Due to the lots of small plugins we have,
this means that the same headers must be compiled plenty of times.
When we include the moc files directly in the C++ file, they are already
available.
2023-07-30 07:27:45 +00:00
Albert Vaca Cintora
2a1c751ef4 Remove request packets from Battery and Connectivity Report plugins
We already send updates right after connecting and once there's a
change, so this was redundant.
2023-07-17 14:58:59 +00:00
Nicolas Fella
a918ffc0cb Add and make use of ECM's clang-format integration 2022-09-11 23:21:58 +00:00
Nicolas Fella
4011cecf05 [plugins/battery] Determine empty battery based on percentage instead of remaning time
timeToEmpty in UPower is unreliable, e.g. it's always 0 on the PinePhone.

Instead warn when the percentage drops below 15%. That's how it is for Android anyway.
2021-02-25 13:35:07 +01:00
Jason Nader
b5ac96ce5b
plugins/battery: add battery charge info to the update signal 2020-12-13 21:28:23 +09:00
Nicolas Fella
f90d6a019f Rework the battery plugin
Instead of having the DBus stuff in a separate class expose the plugin class itself like we do for the other plugins.

Replace the method-based API with properties.

Change the path to <device>/battery for consistency with other plugins
2020-08-27 15:04:40 +00:00
Philip Cohn-Cort
cfc29fafa6 Improve battery reporting reliability 2020-08-22 15:28:35 +00:00
Nicolas Fella
87db95b22f Convert license headers to SPDX expressions 2020-08-17 09:48:10 +00:00
Antonio Larrosa
1d36164230 Use ecm_qt_declare_logging_category to declare the logging categories
This automatizes the generation of logging categories so a
kdeconnect-kde.categories is generated and installed to
/usr/share/qlogging-categories5/ so kdebugsettings can use it.

Also, sets the default logging level to Warning. So now the logs
of users won't be filled with debug messages but they can
modify the configuration easily with kdebugsettings.
2020-05-26 18:55:47 +02:00
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
Nicolas Fella
5c16bfda5d Use K_PLUGIN_CLASS_WITH_JSON 2019-06-12 22:16:54 +02:00
Nicolas Fella
e601755644 Force usage of QStringLiteral and port remaining offenders 2019-06-10 14:40:28 +00:00
Nicolas Fella
afe78214ac More https 2019-03-24 10:42:34 +01:00
Nicolas Fella
3b8fedea1a Replace http GNU urls with https 2019-03-23 17:29:26 +01:00
Nicolas Fella
b7e52dfd86 [plugins/battery] Don't link against QtGui 2019-03-11 18:58:11 +01:00
Adam Pigg
9a8f1b48a0 Build kdeconnect on sailfish and port some simple plugins
Summary:
Below is a lost of the commits, but, in summary
Port the build system for Sailfish, which means selectively building only the bits we need/can, and only against the KF5 libs that are available.
Allow to build on Qt 5.6
Switch from knotification to nemo notification (not complete!)
Add a very simple example sailfish app.

Note, there is still much missing functionality.  Notifications dont work, pairing sort of works but not really, but when it is paired you can send a ping to the desktop client

Dont build kio for Sailfish

Port core build system

Port daemon buld system

Require CoreAddons on Sailfish

Port plugins build for sailfish and include the ping plugin for now

Final build changes for sailfish.

Disable tests and other not needed parts

Add includes for QCA

Fix build errors on sailfish

Get core/ to build on sailfish

Get interfaces/ to build on sailfish

Build daemon on sailfish

On sailfish, dont install the kcm file

Start port plugin to sailfish

Fixup installed files

Add sfos app

Hack declarative plugin to give a public interface

Build sfos app

Compile declarativeplugin into the sfos app for now

Redefine qAsConst for qt 5.6

Packaging fixes

Use official icon

Package .desktop

Reviewers: #kde_connect, apol, nicolasfella, albertvaka

Reviewed By: #kde_connect, apol, nicolasfella, albertvaka

Subscribers: kdeconnect, andyholmes, albertvaka, kossebau, mtijink, vonreth, apol, #kde_connect, nicolasfella

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D10703
2018-08-02 20:10:59 +01:00
Adam Pigg
ebc316f703 Add a method for creating simple notifications
Summary:
Add a helper function to the daemon interface, which must be subclassed
by the implementations, which creates a simple notification.

For more complex needs, involving interacting with the notification, it
will still be nescessary to use KNotification directly, but this allows
for other future implementations to create a simple notification without
ifdef'ing the code.

Reviewers: kdeconnect, apol

Reviewed By: apol

Subscribers: kdeconnect

Differential Revision: https://phabricator.kde.org/D11104
2018-03-18 12:52:22 +01:00
Albert Vaca
f47f517827 Rename NetworkPackage -> NetworkPacket
Summary: KDE Connect, now with correct naming!

Test Plan: It still builds.

Reviewers: #kde_connect, apol, nicolasfella

Reviewed By: #kde_connect, apol, nicolasfella

Subscribers: nicolasfella

Differential Revision: https://phabricator.kde.org/D11036
2018-03-05 20:03:23 +01:00
Jean Vincent
72535ecf48 Make member variable names, & placement and * placement more coherent
Summary:
Change all member variables to the form m_fooBar because it is the preferred form in Qt (it was half and half between this and mFooBar, and a minority didn't have anything).
Place all references and pointers on the side of the type since it is the majority.

Basically:
 - mFoo -> m_foo
 - foo -> m_foo (if it is a member variable)
 - Type &ref -> Type& ref
 - Type *ptr -> Type* ptr

Reviewers: #kde_connect, nicolasfella, albertvaka

Reviewed By: #kde_connect, nicolasfella, albertvaka

Subscribers: albertvaka, #kde_connect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D7312
2017-09-03 21:45:08 +02:00
Albert Vaca
60331ccbf1 Clazy says all this QStringLiteral and QLatin1String were missing/wrong 2016-11-26 16:21:29 +01:00
Aleix Pol
f9406e8afc Introduce QVariantMap as an argument of NetworkPackage
Makes it possible to specify the different properties sent at once,
rather than one by one as we used to do.

Also port whenever possible to the initializer-list syntax.

REVIEW: 128269
2016-06-21 20:07:12 +02:00
Albert Vaca
73f5996f14 Consistent naming of _REQUEST package type macros 2016-06-03 00:47:03 +02:00
Aleix Pol
95f01c4bea Use C++ for setting the default argument 2015-09-11 12:34:52 +02:00
Lamarque V. Souza
1c764c55a3 Fix typo. 2015-07-14 19:55:32 -03:00
Aleix Pol
c7cee37330 Port away from KServiceTrader
Uses KPluginLoader+KPluginMetadata instead.
Describes plugins in json instead of desktop files. These desktop files are
then embedded into the .so file. All the plugins will be in a kdeconnect/
directory, and those will be the ones to look for.

Note it doesn't drop the KService dependency as KIOCore is a KDE Connect
dependency as well.

REVIEW: 123042
2015-03-19 16:36:53 +01:00
Kai Uwe Broulik
930c107f7b Cleanup notifications
Use iconName instead of sending a fixed-size pixmap around, fix wording and use title
capitalization, more meaningful names in notifyrc, QStringLiteral and new style connect.

REVIEW: 122121
2015-01-18 01:53:20 +01:00
Àlex Fiestas
dbea3171bd Make kdeconnect core compile without KDELibs4Support
This meant to add a lot of dependencies to each plugin since we had
KDELibs4support as PUBLIC link meaning that anything linking against
kdeconnectcore was linking at the same time to mostly all frameworks.

Now each plugin has more or less its dependencies in the CMake some
still depend on KDELibs4Support.

For the mousepad plugin I needed to add a fixX11.h file that basically
undefines/defines again some stuff xlib has that conflcits with normal
C++ and Qt.

Before it was not conflicting because some lib within KDELibs4Support
was including this file, but now we have to do it ourselves.
2014-09-22 02:40:51 +02:00
Àlex Fiestas
677f650216 Removed K_EXPORT_PLUGIN, no longer needed
With kf5 this is not longer needed. removing it!
2014-09-22 02:40:51 +02:00
Àlex Fiestas
9e3d1dc851 Port battery away from kDebug 2014-09-22 00:44:17 +02:00
Àlex Fiestas
42269a9dda Port from KIcon to QIcon
Executed kcm and some notifications, icons are still shown.
2014-09-13 01:04:48 +02:00
Albert Vaca
a303b73238 Merge branch 'master' into frameworks
Conflicts:
	cli/kdeconnect-cli.cpp
	core/CMakeLists.txt
	plasmoid/package/contents/ui/FullRepresentation.qml
	plugins/ping/pingplugin.cpp
2014-07-01 23:59:38 +02:00
Albert Vaca
3147067fbf Fixed notifications not being appearing in the model nor in the plasmoid
The parent of the QDbusAdaptor has to be a Device, and now it was a
KdeConnectPlugin for the Notifications plugin.

Instead of passing the parent (that is actually a Device) to the
QDbusAdaptor as we were doing in the Battery plugin, I preferred to get the
actual Device from the KdeConnectPlugin, even though it needs a const_cast.
2014-07-01 01:26:07 +02:00
Aleix Pol
b618a64f51 Merge remote-tracking branch 'origin/master' into frameworks
Conflicts:
	cli/kdeconnect-cli.cpp
2014-06-18 02:46:14 +02:00
Albert Vaca
dd43479956 Now plugins load by default the kdeconnect-plugins catalog. 2014-06-17 22:21:20 +02:00
Aleix Pol
a1a560c469 First approach to a KF5 port of KDE Connect
Ported using KDELibs4Support, for a smaller delta, so we can keep
developing on master until we decide not to.

At the moment, it builds and installs but tests don't pass because
of a QCA2 initialization problem I didn't manage to debug yet.

CCMAIL: kdeconnect@kde.org
2014-06-16 20:02:07 +02:00
Aleix Pol
6ce0b6b874 Document in the desktop files the outgoing types for the plugins
This way we narrow the things a plugin can send, to its own scope. Still
every plugin can set a list of types, so it should be ok.
2014-06-14 20:35:00 +02:00
Aleix Pol
741abafaf7 Move the plugins into a different top-ĺevel directory
Reviewed by Albert Vaca
2014-06-14 16:34:11 +02:00
Renamed from core/plugins/battery/batteryplugin.cpp (Browse further)