Commit graph

145 commits

Author SHA1 Message Date
Jean Vincent
c864267f04 Replace Q_FOREACH with C++11 range-for
Summary:
The use of Q_FOREACH is advised against (https://doc.qt.io/qt-5/qtglobal.html#Q_FOREACH) since Qt 5.7 and will eventually be removed from Qt.

I replaced all occurrences with the range-for loop introduced in C++11 (except for the one in daemon.cpp in deviceIdByName which might have a bug / typo in it).

I added const to the container or casted it with qAsConst when appropriate to avoid unnecessary copies.

(This is my first submission. I did all the unit tests, and they all passed but I don't know how to show it here.)

Reviewers: #kde_connect, nicolasfella, apol

Reviewed By: #kde_connect, nicolasfella, apol

Subscribers: albertvaka, apol, nicolasfella

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D6724
2017-07-21 09:57:19 +02:00
Pino Toscano
9d968fa3ac Merge remote-tracking branch 'origin/1.x' 2017-05-27 06:29:30 +02:00
Pino Toscano
b6f280aedb tests: fix memory access in testnotificationlistener
set the image data as QByteArray of the right size, otherwise
referencing a stack-based char data will be problematic when the
function is out of scope
2017-05-27 06:14:00 +02:00
Albert Vaca
2c1c8525e5 Now a 100% more compiling 2017-02-14 23:03:59 +01:00
Aleix Pol
ea41d3786e Expose pairing state for devices
Will allow to have information about whether we're pairing, mostly for
better GUI.

Pair-programmed with Albert Vaca
2017-01-25 00:22:22 +01:00
David Faure
f708b4431d fix compilation with gcc 4.8 2017-01-15 22:12:49 +01:00
David Faure
e59fd940d6 fix compilation with gcc 4.8 2016-12-14 23:36:59 +01:00
Albert Vaca
beeae63086 Missing Q_OBJECT macro 2016-11-26 16:36:34 +01:00
Albert Vaca
60331ccbf1 Clazy says all this QStringLiteral and QLatin1String were missing/wrong 2016-11-26 16:21:29 +01:00
Albert Vaca
a1340c8042 Fixed old style connects with clazy 2016-11-26 15:14:19 +01:00
Holger Kaelberer
c122312c65 sendnotifications: also sync icon-data from notfication hints
According to the priorities defined in the notifications spec
version 1.2

REVIEW: 126722
2016-08-27 13:59:25 +02:00
Aleix Pol
91f952f5f1 Fix test
Use the right port
Store the port in a public variable, so it can be used from the test.
2016-08-08 19:38:58 +02:00
Aleix Pol
81634303b2 Make capabilities static
As discussed with Albert, move the population of capabilities into the
identity package, making them static along the execution of the link.

When we receive the identityPackage, we collect the plugins we can use with
the device and stick to those. This should simplify the implementation and
remove the possibility to lose packages if packages are received before the
capabilities are processed in the former approach.

REVIEW: 128386
2016-07-06 17:37:22 +02:00
Albert Vaca
8c07d88c17 Int was too large. 2016-07-05 12:28:31 +02:00
Aleix Pol
ef98fb4587 Fix file transfer under SSL
Introduces a big fat buffer :(
Actually test the trasfers :)
Takes QSslSocket causistic into account, for some reason QNAM refuses to
mark as finished when the QSslSocket (through QIODevice) closes.
It would be good to look into dropping the QBuffer, doing so with the test
in place will help.
2016-06-22 17:49:45 +02:00
Aleix Pol
4cb50d69d8 Fix some issues in the downloadjob and its test
Test on KJob abstraction, this way we can check if it has an error when it
breaks.
Handle errors in a different branch of the code.
2016-06-22 12:40:14 +02:00
Aleix Pol
49713d8aca Enforce Qt-specific keywords
Reviewed by Albert Vaca
2016-06-21 20:19:14 +02:00
Albert Vaca
e880e14ed5 Preffer Q_FOREACH to foreach 2016-06-21 14:50:17 +02:00
Aleix Pol
bfd698af36 Fix issues detected by clazy
Don't use for(:) on Qt containers. It detaches without need.
2016-06-20 19:22:29 +02:00
Aleix Pol
596e4484f4 Clean up use of virtual and override keywords
Only use virtual when actually virtual, to override just use override.
2016-06-20 19:22:29 +02:00
Albert Vaca
cc0fdacbf5 Fixed compilation on Windows 2016-06-20 02:31:55 +02:00
Albert Vaca
3177143439 Fixed build on windows 2016-06-09 02:36:02 +02:00
Aleix Pol
55c6014686 Fix tests
In case we need to discover the device (i.e. we're running the test in a
clean environment) we need to acquire the discovery mode.
Only initialize the test after setting the test mode enabled, so the
loopback is enabled.
2016-06-06 01:21:37 +02:00
Albert Vaca
0c48c00fa7 Added debug function to print a stack trace 2016-06-01 12:43:34 +02:00
Albert Vaca
04d5b12f8b Merge branch 'master' into sslrefactor 2016-06-01 12:20:07 +02:00
Harald Sitter
f071536649 force a lc_time to make sure the dummyTest passes
if the system locale is not en_US longMonthName might produce a localized
string, failing the qcompare.

REVIEW: 128067
2016-06-01 10:39:13 +02:00
Aleix Pol
a83998dae0 Remove absurd test 2016-06-01 02:29:28 +02:00
Aleix Pol
9aa794b0da Merge branch 'master' into sslrefactor 2016-05-31 17:29:06 +02:00
Albert Vaca
0b5fbe00bb Split plugins for sending and receiving notifications
CCMAIL: holger.k@elberer.de
2016-05-25 12:49:13 -06:00
Albert Vaca
0c95010c3b Merge branch 'master' into sslrefactor
# Conflicts:
#	core/device.cpp
#	interfaces/devicesmodel.cpp
2016-04-14 19:00:42 -07:00
Holger Kaelberer
4b5bde4858 notifications: synchronize icons if possible and requested
Configurably attach icons as payload to notification packages. By
design and due to restrictions on mobile devices *only* png is sent.
As KIconLoader preferably returns svg icons from iconPath() we fall
back to loading from "hicolor" using KIconTheme directly. Otherwise
*many* icons are dropped because of svg format.

This also improves slightly the test-case to use a tweaked TestDevice
to allow for inspecting sent NetworkPackage-s.

REVIEW: 126666
2016-01-11 20:12:43 +01:00
Albert Vaca
fa1771dd64 Merge branch 'master' into sslrefactor 2016-01-10 09:01:14 -08:00
Albert Vaca
aa4150f0c9 Moved ConnectionStarted from DeviceLink to LanDeviceLink 2016-01-10 07:12:13 -08:00
Holger Kaelberer
548508d6e6 notifications: don't register proxied notifications internally
REVIEW: 126645
2016-01-07 13:22:10 +01:00
Albert Vaca
f5404ea11b Removed more references to publicKey 2015-12-17 08:22:18 -08:00
Albert Vaca
77facdbcfd Merge branch 'master' into sslrefactor 2015-12-07 03:38:06 -08:00
Albert Vaca
2e4ce90656 Commented out old encryption functions 2015-12-07 03:34:41 -08:00
Aleix Pol
42110549f4 Improve SharePlugin share notification method
Make the share received notification explicitly internal.
Fix runtime warning about how QUrl cannot be exported.
Notify about all shares, not exclusively transferred files.
2015-12-07 03:27:40 +01:00
Aleix Pol
70f55d0ebc Fix compilation and a couple of warnings
CCMAIL: holger.k@elberer.de
2015-12-07 03:21:35 +01:00
Aleix Pol
a45e48ca7a Fix tests build
Daemon::requestPairing changed into ::askPairingConfirmation.
2015-12-06 00:08:02 +01:00
Holger Kaelberer
4fc39601dd tests: add test-case for NotificationsListener 2015-12-05 23:23:22 +01:00
Albert Vaca
af5be6e9e0 Added a test mode to lanlinkprovider
Should fix tests when you run them on networks with real kdeconnects
running.
2015-12-02 09:49:00 -08:00
Albert Vaca
cf6cbd2925 WIPx3! 2015-12-01 10:45:14 -08:00
Albert Vaca
82bc73dd9b WIPx2 2015-12-01 07:25:34 -08:00
Albert Vaca
30d2dd991b Merge branch 'master' into sslmaster 2015-11-30 03:40:07 -08:00
Aleix Pol
0bca50af93 Merge branch '0.9' 2015-10-19 17:48:13 +02:00
Albert Vaca
e2f068b286 Fixed a memory leak making the DownloadJob destroy itself on disconnect
There are still some code paths where it doesn't get destroyed though,
like when the device gets unreachable (and the download socket doesn't
close for some reason).
2015-10-18 21:51:51 -07:00
Vineet Garg
73a80f0296 Fixed Lan Link Provider Test
Pairing timer was started even when pair package sending is failed, fixed that
2015-09-13 01:45:19 +05:30
Aleix Pol
3269b7a9c2 Fix tests when the Qt mobile app is not built 2015-09-12 15:17:08 +02:00
Aleix Pol
67a2c1ffd9 Properly test to wait for signals 2015-09-11 18:21:18 +02:00
Aleix Pol
5e0a7a34b9 Merge branch 'master' into ssl
# Conflicts:
#	cli/kdeconnect-cli.cpp
#	core/backends/lan/landevicelink.cpp
#	core/backends/lan/landevicelink.h
#	core/backends/lan/lanlinkprovider.cpp
#	core/backends/lan/lanlinkprovider.h
#	core/backends/lan/socketlinereader.h
#	core/backends/lan/uploadjob.cpp
#	core/backends/lan/uploadjob.h
#	core/backends/loopback/loopbackdevicelink.h
#	core/daemon.cpp
#	core/daemon.h
#	core/device.cpp
#	core/device.h
2015-09-11 17:25:23 +02:00
Aleix Pol
95f01c4bea Use C++ for setting the default argument 2015-09-11 12:34:52 +02:00
Aleix Pol
fc074c8ec8 Fix tests
Ensure the loopback device is paired
2015-09-09 20:12:05 +02:00
Aleix Pol
acdd96c431 Fix device lookup on the tests 2015-09-08 20:11:52 +02:00
Aleix Pol
6a379e9227 Rename missingPlugins to unsupportedPlugins 2015-09-08 17:38:33 +02:00
Aleix Pol
df3581459a Add a test that makes sure that capabilities are gathered correctly
While at it, fix the logic, because it wasn't working all that well.

Reviewed by Albert Vaca
2015-09-08 17:35:30 +02:00
Aleix Pol
817fcbc9d6 Merge branch 'stable' 2015-09-08 10:51:41 +02:00
Aleix Pol
d58f6314fe run Clang Modernize
Minus the auto change
2015-09-08 10:47:37 +02:00
Aleix Pol
661d4579fc Merge branch 'stable' 2015-09-07 17:45:33 +02:00
Andreas Sturmlechner
1423000b44 Make tests optional
This patch makes it able to disable building tests by choice or unavailability of Qt5Test (by example of kwin).

REVIEW: 122984
2015-09-07 17:42:37 +02:00
Aleix Pol
d835d01a09 Add a test for file sending, using the loopback device
Extends unit testing by making sure that file sharing works locally.

REVIEW: 125086
2015-09-07 15:03:04 +02:00
Vineet Garg
9799c629d2 Added device test 2015-08-20 23:15:12 +05:30
Vineet Garg
c5a399b94b Fixed code identation issue 2015-08-12 23:49:15 +05:30
Vineet Garg
6acb4204a2 Added KdeConnectConfigTest, TestSslSocketLineReader, LanLinkProviderTest 2015-08-12 23:42:27 +05:30
Vineet Garg
e6da860fb7 Fixed issues pointed out on CR 2015-07-14 17:34:04 +05:30
Vineet Garg
148a713176 Initial working implementation of ssl 2015-07-05 18:53:53 +05:30
Albert Vaca
02e9e4d974 Fixed test 2015-04-19 22:29:03 -07:00
Aleix Pol
3caf5e7908 Move some find_package dependencies to the children directories as agreed 2015-04-10 17:48:48 +02:00
Heiko Becker
d17c4419bd testsocketlinereader: USE QTEST_GUILESS_MAIN
This patch allows running the tests without a display server.

REVIEW: 122991
2015-03-17 18:37:59 +01:00
Albert Vaca
a3decd542c Includes cleanup 2015-03-13 21:20:58 -07:00
Heiko Becker
260301155f Use co-installable qca-qt5 version
If both qt4 and qt5 versions of qca are present the build of the
frameworks branch tries to find Qt4 pulled in by qca and thus fails.

REVIEW: 122054
2015-01-15 21:35:30 -08:00
Aleix Pol
21ab5a4f81 Merge branch 'master' into frameworks
Mostly kDebug -> qCDebug
Also some KCmdLineArgs -> QCommandLineParser

Conflicts:
	cli/kdeconnect-cli.cpp
	core/CMakeLists.txt
	core/backends/lan/lanlinkprovider.cpp
	core/daemon.cpp
	core/pluginloader.cpp
	interfaces/CMakeLists.txt
	kio/kiokdeconnect.cpp
	plugins/mousepad/CMakeLists.txt
	plugins/mousepad/mousepadplugin.h
	plugins/mpriscontrol/mpriscontrolplugin.cpp
	plugins/sftp/sftpplugin.cpp
2014-11-04 19:12:29 +01:00
Aleix Pol
1a1969f42f Port to new QCA cmake structure, now it's called Qca
and the target name is qca
2014-09-23 20:05:22 +02:00
Àlex Fiestas
ced3fb5060 QDate.setYMD is deprecated, use setDate instead 2014-09-23 19:44:31 +02: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
21712668ee Pass arguments in correct order to QCOMPARE
It is actual, expected .
2014-09-13 00:50:46 +02:00
Àlex Fiestas
f20f489999 Port to aelperay from QJson to native json support
Straight forward port from QJson to the native Json support.

As a note I have added 2 helper functions that make the code bit more
readable (object2qvariant and qvariatn2qobject).
2014-09-13 00:49:56 +02:00
Àlex Fiestas
d3aec4887f Add content to the body that will be serialized
Just to make extra sure that the serializer works correctly.
2014-09-13 00:16:26 +02:00
Àlex Fiestas
a0ff36625d Make sure we have initialized QCA before using it
QCA::isSupported uses a private global object that is 0 if
QCA::Initializer is not instanciated.
2014-09-12 23:32:19 +02:00
Sune Vuorela
e3237881aa Catch a misconfigured QCA a bit earlier.
REVIEW:120095
2014-09-09 09:19:07 +02:00
David Suárez
c935ea8334 TestSocketLineReader: Ensure we provide a more appropiate message if we fail trying to open a connection to the client
A litle irrelevant change :)

BTW, I'm encounter this test error on Debian kfreebsd i386:
  https://buildd.debian.org/status/fetch.php?pkg=kdeconnect&arch=kfreebsd-i386&ver=0.7-1&stamp=1404242653

Maybe someone have a clue on what is happening here :)

REVIEW: 119091
2014-07-07 12:45:13 +02:00
Aleix Pol
bf272ea3e7 Remove usage of KDE4_ variables 2014-06-18 02:39:30 +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
b88897847b Reorganize sources
We broke kded into core and kded, core contains the library with the backends
and plugins.
Also we renamed libkdeconnect to interfaces.
2014-06-14 15:22:40 +02:00
Aleix Pol
5c9d3a9d42 Make a new kdeconnectcore library
Solves the need of compiling device.cpp against all plugins. Also
networkpackage and others don't need to either.

REVIEW: 118742
2014-06-14 14:31:31 +02:00
David Suárez
d6824ad8f8 Fixed unit test!
REVIEW: 117387
2014-04-12 23:07:40 +02:00
Albert Vaca
d7e9a42a7b Moved unit tests together 2014-04-12 23:04:35 +02:00
Aleix Pol
e3b4b3660f Compile everything
Albert, this is asking you to be a library ;)

CCMAIL: albertvaka@gmail.com
2013-11-08 03:13:13 +01:00
Albert Vaca
cf869dfd57 CMake now enforces QJson version 8.1 or greater 2013-10-29 17:46:57 +01:00
Albert Vaca
1d4482b5c1 Oops, last commits broke tests
Missing files to link
2013-10-01 14:09:17 +02:00
Albert Vaca
39550ff6ea Type was missing for identity packages
Added a test for it
2013-09-03 02:14:55 +02:00
Albert Vaca
892385f3fc Simplified NetworkPackage format
Now protocol version is only sent once (in the identity package)
Removed "isEncrypted" bit, using type "kdeconnect.encrypted" instead.
NetworkPackage's decrypt and unserialize return false when find problems
Updated tests.
2013-09-02 13:26:26 +02:00
Albert Vaca
36e5d41811 Renamed daemon -> kded 2013-09-02 03:23:34 +02:00
Albert Vaca
f59ab45644 Support encrypting strings longer than key.maximumEncryptSize()
Strings are divided in smaller chunks and serialized in an array
Added a test for this case
2013-09-02 03:17:23 +02:00
Albert Vaca
deeeb595b3 Implemented encryption in NetworkPackage using QCA2
Fixed some bugs in the pairing process state machine
Keys are now stored in base64 in KConfig (was storing non-allowed chars)
Updated NetworkPackage tests to include encryption
Increased networkpackage version 1 -> 2
2013-09-01 22:13:03 +02:00