Manuel Nickschas [Fri, 30 Aug 2019 19:54:47 +0000 (21:54 +0200)]
common: Remove the copy assignment operator from DccConfig
Since C++11 the standard no longer mandates the existence of an
implicit copy constructor if there is a user-supplied copy assignment
operator, and GCC 9 warns about that:
src/qtui/settingspages/dccsettingspage.cpp: In member function ‘virtual void DccSettingsPage::load()’:
src/qtui/settingspages/dccsettingspage.cpp:91:71: warning: implicitly-declared ‘DccConfig::DccConfig(const DccConfig&)’ is deprecated [-Wdeprecated-copy]
Remove the copy assignment operator altogether and rely on the
implicitly generated one, which does the same thing.
Manuel Nickschas [Fri, 30 Aug 2019 19:48:32 +0000 (21:48 +0200)]
core: Don't store a reference in CoreCertManager
Storing references violates all sorts of Best Practices, and also
prevents the compiler from implicitly declaring a copy assignment
operator. Store a pointer instead, and clean up the API a bit.
Manuel Nickschas [Fri, 30 Aug 2019 19:43:21 +0000 (21:43 +0200)]
core: Remove copy assignment operator from CoreIdentity
The operator is no longer needed due to the switch from QList
to std::vector that was done in the previous commit.
This avoids a warning in GCC 9:
src/core/coreidentity.cpp: In member function ‘CoreIdentity& CoreIdentity::operator=(const CoreIdentity&)’:
src/core/coreidentity.cpp:91:23: warning: implicitly-declared ‘Identity& Identity::operator=(const Identity&)’ is deprecated [-Wdeprecated-copy]
The warning is caused by relying on the implicit copy assignment
operator in the base class, which is no longer required by the
standard since C++11, and may be removed in the future.
Manuel Nickschas [Fri, 30 Aug 2019 19:36:09 +0000 (21:36 +0200)]
core: Replace QList by std::vector in the storage API
QList is inefficient and deprecated; also Qt containers have
issues with ranged-for and STL algorithms. Use std::vector instead in
the storage API and fix affected code.
Modernize some affected bits by replacing weird loops with STL
algorithms.
Manuel Nickschas [Fri, 30 Aug 2019 18:28:10 +0000 (20:28 +0200)]
qa: Replace Qt module includes by class ones
Including whole Qt modules is less efficient than including only
the classes that are needed. Remove module includes and add class
ones as needed.
Manuel Nickschas [Wed, 28 Aug 2019 18:24:48 +0000 (20:24 +0200)]
cmake: Don't needlessly sync translations
A mismatch in the stamp file name for syncing translations caused
the sync to be run for every make. Fix the naming so we don't
re-run the syncing needlessly.
Janne Koschinski [Sun, 4 Aug 2019 20:46:26 +0000 (22:46 +0200)]
Remove debug console and QtScript, which was deprecated with Qt5
- reduces dependencies, allows building quasselcore on most distros
without pulling in X11
- removes unused code and dependencies, reduces size
Manuel Nickschas [Wed, 28 Aug 2019 18:13:43 +0000 (20:13 +0200)]
core: Use QLatin1String in a few places
It is recommended to use QLatin1String as an efficient wrapper
around const char*. Use this in the places recently touched.
Manuel Nickschas [Wed, 28 Aug 2019 18:06:17 +0000 (20:06 +0200)]
Add missing includes
For std::sort we should include <algorithm>.
Janne Koschinski [Mon, 5 Aug 2019 10:44:27 +0000 (12:44 +0200)]
Add a flag to enable Qt deprecation warnings on Qt < 5.13
Janne Koschinski [Mon, 5 Aug 2019 10:34:46 +0000 (12:34 +0200)]
Replace deprecated additionalFormats with formats
Janne Koschinski [Mon, 5 Aug 2019 11:44:45 +0000 (13:44 +0200)]
Replace deprecated QComboBox::currentIndexChanged with currentTextChanged
Janne Koschinski [Mon, 5 Aug 2019 11:22:02 +0000 (13:22 +0200)]
Replace usage of deprecated QDir::operator=
Janne Koschinski [Mon, 5 Aug 2019 10:42:32 +0000 (12:42 +0200)]
Replace deprecated QSqlError::number with ::nativeErrorCode
Janne Koschinski [Mon, 5 Aug 2019 10:37:13 +0000 (12:37 +0200)]
Replace deprecated QModelIndex::child with QAbstractItemModel::index
Janne Koschinski [Mon, 5 Aug 2019 10:33:47 +0000 (12:33 +0200)]
Replace QSignalMapper with new-style lambda signals
Janne Koschinski [Mon, 5 Aug 2019 10:30:19 +0000 (12:30 +0200)]
Replace deprecated qSort with std::sort
Jan Alexander Steffens (heftig) [Fri, 22 Mar 2019 21:37:22 +0000 (22:37 +0100)]
qtui: Set desktop file name
The XCB platform plugin defaults the WM class to the executable name,
which already matches our desktop file name. Unfortunately, the Wayland
platform plugin prepends the inverted organization domain, resulting in
an app ID of "org.quassel-irc.quasselclient", thus breaking the
association.
Set the desktop file name explicitly so the Wayland platform doesn't get
confused.
Rafael Kitover [Sat, 1 Jun 2019 09:48:02 +0000 (09:48 +0000)]
cmake: fix build on MSYS2
Some minor changes to allow building easily on MSYS2:
- don't check for snorenotify on MSYS2 because it segfaults on startup
- don't use -fstack-protector-strong (libssp) on MinGW because it
currently causes segfaults during static initialization
https://sourceforge.net/p/mingw-w64/bugs/755/
- use the `cat` command to read files when using the 'MSYS Makefiles'
generator, and not the cmd.exe `type` command
- update doc for the quassel_add_module function wrt.
7d0879ab
Tested to build correctly on MSYS2 with both the 'MSYS Makefiles'
generator and the Ninja generator using a native ninja.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Kai Uwe Broulik [Tue, 30 Apr 2019 12:28:21 +0000 (14:28 +0200)]
Check for KNotifications version
setDefaultAction was introduced in KDE Frameworks version 5.31
Kai Uwe Broulik [Tue, 30 Apr 2019 12:28:21 +0000 (14:28 +0200)]
Set default action on notification
This makes the entire notification popup clickable.
Also, mark the text for translation.
Janne Koschinski [Tue, 19 Mar 2019 11:53:46 +0000 (12:53 +0100)]
Implement a metrics daemon to expose Prometheus metrics
- logs IRC and client sessions, IRC traffic in/out, login attempts per user
- logs certificate expiry time
Manuel Nickschas [Sun, 4 Aug 2019 18:53:07 +0000 (20:53 +0200)]
tests: Fix include order
Daniel Albers [Fri, 2 Aug 2019 10:48:39 +0000 (12:48 +0200)]
Merge branch 'simplify-time-formatting' of https://github.com/justjanne/quassel
Closes #504.
Daniel Albers [Fri, 2 Aug 2019 09:57:15 +0000 (11:57 +0200)]
Merge branch 'select-account-from-cli' of https://github.com/justjanne/quassel
Closes #503.
Janne Koschinski [Fri, 26 Jul 2019 13:28:11 +0000 (15:28 +0200)]
Simplify the time formatting used in formatDateTimeToISO
- Previously, a convoluted workaround using deprecated functionality was
used to ensure we would format all types of QDateTime objects
correctly
- A new workaround has been found which ensures this works reliably
without using deprecated functionality
Janne Koschinski [Fri, 26 Jul 2019 12:19:48 +0000 (14:19 +0200)]
Allow selecting the core account to connect to from CLI
- adds new --account option
- if an account id is specified, connects to that account instead of
asking or using any other defaults
Kai Uwe Broulik [Tue, 30 Apr 2019 12:27:08 +0000 (14:27 +0200)]
Send icon name instead of pixmap
Lets the notification server load an appropriate crisp pixmap depending on the size it wants to display it at
Kai Uwe Broulik [Tue, 30 Apr 2019 12:19:18 +0000 (14:19 +0200)]
Add DesktopEntry to notifyrc
This allows the new notification KCM to identify Quassel as an application
Rafael Kitover [Thu, 24 Jan 2019 09:29:59 +0000 (01:29 -0800)]
cmake: Lower Boost dep version 1.56 -> 1.54
Require Boost 1.54 instead of 1.56.
Tested to compile and work correctly on OpenSUSE Leap 42.3.
Fixes #1510.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Rafael Kitover [Thu, 24 Jan 2019 09:31:02 +0000 (01:31 -0800)]
cmake: Add ENABLE_SHARED option, default ON
Add an ENABLE_SHARED option, defaults to ON, when set to OFF
quassel_add_module() will build modules as static (does not affect
platforms where modules would be built as static anyway.)
The option name ENABLE_SHARED is frequently used for this purpose in
cmake.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Ben Rosser [Thu, 14 Feb 2019 16:28:02 +0000 (11:28 -0500)]
Core: in LDAP authenticator, don't try database auth with blank password
In the LDAP authenticator, we were trying to do database auth against
the core with a blank password (QString()), after LDAP auth has succeeded.
This was done because there was not another way to retrieve a quassel
UserId object for a given string username.
However, if we want to support migrating a user from Database to LDAP
auth, this causes problems-- we'd need to set the password column to
whatever an empty QString() maps to in the hashing algorithm.
It seems much simpler to just add a new method to core.h to look up
a UserId object in the current storage provider when we pass it
a string username. Then we can just call that method in the LDAP
authenticator.
Ben Rosser [Thu, 7 Feb 2019 19:47:50 +0000 (14:47 -0500)]
Core: only try local auth if a user has the "database" auth provider set
This commit attempts to resolve issue #1501; currently, quassel will
always attempt to do local authentication, and *then* try LDAP auth. This
makes it difficult to migrate a core from local auth to LDAP auth; users
who have local passwords can always use those passwords to log in, and there
is not a simple way to migrate them to non-local auth.
There is an "authenticator" column in the database for each user, but it
is currently only used to stop passwords from being changed for LDAP users.
This commit modifies the login flow to first check that database field--
if authenticator is not "Database", we don't try local authentication and
proceed directly to non-local authentication.
This is a bit clumsy-- I added a method to the core to look up a user's
authenticator by string. But there's no way to map that to the actual
authenticator object, because we only store one configured authenticator
per core-- so we then just check if that authenticator is "Database" or
not. I think this is something that should be improved in the future,
but as a quick fix to #1501 this is probably good enough.
Shane Synan [Thu, 30 May 2019 20:19:18 +0000 (16:19 -0400)]
tests: Verify ExpressionMatch test data won't OOB
Verify that the ExpressionMatch test data for test
trimMultiWildcardWhitespace won't try to access out of bounds data by
changing EXPECT to ASSERT for patternPair.size() == 2.
If the test data is wrong, the results will be undefined, so there's
no point in continuing the test.
Alternative: use std::vector's .at() function, which will raise a
runtime error if out of bounds.
Shane Synan [Thu, 3 Jan 2019 03:54:02 +0000 (22:54 -0500)]
tests: Verify ExpressionMatch with invalid regex
Verify that ExpressionMatch behaves reasonably with an invalid
regular expression passed in, rejecting all matches and being labeled
as not valid.
This matches the test devised by justJanne in the process of
resolving a crash in Quasseldroid-NG. We should make sure Quassel
desktop never regresses into crashing, too.
See https://git.kuschku.de/justJanne/QuasselDroid-ng/commit/
f1f320782cb0bca3fb7974e7688ce33af19456cf
Janne Koschinski [Tue, 12 Feb 2019 11:00:12 +0000 (12:00 +0100)]
Implement IRCv3 Server-Time
Janne Koschinski [Fri, 15 Feb 2019 13:32:31 +0000 (14:32 +0100)]
Cleanup allowing for tags to be available at later points, adds TAGMSG
Janne Koschinski [Fri, 15 Feb 2019 08:24:52 +0000 (09:24 +0100)]
Don't server-encode twice
Janne Koschinski [Thu, 14 Feb 2019 13:31:13 +0000 (14:31 +0100)]
Improve debugging for new IRCv3 functionality
Janne Koschinski [Fri, 15 Feb 2019 08:24:26 +0000 (09:24 +0100)]
Minor cleanup of messages handling
Janne Koschinski [Tue, 12 Feb 2019 11:36:53 +0000 (12:36 +0100)]
Code cleanup
Janne Koschinski [Tue, 12 Feb 2019 10:54:06 +0000 (11:54 +0100)]
Implement IRCv3 tag parsing and sending
Wolfgang Müller [Thu, 14 Feb 2019 17:54:07 +0000 (18:54 +0100)]
logger: export LogEntry symbols
Shane Synan [Thu, 14 Feb 2019 13:58:46 +0000 (14:58 +0100)]
logger: Dedup code, fix client Debug Log loglevel
Deduplicate code by moving LogEntry formatting into a separate
function, LogEntry::toString(), which applies timestamps and the log
level string.
Fix client Debug Log dialog to print log level using this new function.
Modify msgWithTime() to use this new function, too.
Wolfgang Müller [Wed, 13 Feb 2019 13:48:19 +0000 (14:48 +0100)]
logger: resolve program name using RunMode and BuildInfo
Wolfgang Müller [Sat, 12 Jan 2019 18:14:28 +0000 (19:14 +0100)]
logger: resolve level string in msgWithTime
This means that the log level string is included in logs to files
and stdout even if syslog output is enabled.
Wolfgang Müller [Fri, 11 Jan 2019 16:45:52 +0000 (16:45 +0000)]
logger: Make output to syslog nicer
phuzion [Wed, 13 Feb 2019 14:28:13 +0000 (14:28 +0000)]
Update Help>About Qt to use modern Qt logo and remove old Qt logo from repo
Shane Synan [Wed, 13 Feb 2019 05:00:48 +0000 (00:00 -0500)]
core: Remove updateSQLResource.sh, cleanup docs
Remove updateSQLResource.sh as it's no longer needed. `sql.qrc` is
now generated automatically as of commit
1a45f16a9734820fba42fe1db3f38dd1eee49df6
Update the README.md documentation in `src/core` to match.
Hooray!
Shane Synan [Tue, 29 Jan 2019 07:52:25 +0000 (02:52 -0500)]
core: Remove redundant updateSchemaVersion() call
Remove the redundant updateSchemaVersion() call at the end of schema
migrations. This is already called within the final iteration of the
loop.
Cleans up a leftover from
f10304a35af0a7a4f8b812e467e69287d358ce7c
Shane Synan [Tue, 29 Jan 2019 04:08:30 +0000 (23:08 -0500)]
core: Display problem step if storage setup fails
Print the problematic setup step (e.g. 'setup_070_coreinfo') if
storage backend initialization fails. This may help with debugging.
Modify setupQueries() to return a list of query strings and
resource filenames, used for the above.
Shane Synan [Tue, 29 Jan 2019 04:08:03 +0000 (23:08 -0500)]
core: Track upgrade step within schema version
Track the last successful upgrade step (upgrade_###_XXX.sql) within
each schema version, storing it within 'coreinfo' table as
'schemaupgradestep'. When a schema upgrade finishes, clear
'schemaupgradestep' and set 'schemaversion'.
This allows for resuming multi-step schema upgrades that were
interrupted in the middle.
Whenever starting a schema upgrade, also check the value of
'schemaupgradestep'. One of two states exist:
1. Empty ('') or nonexistent
No interrupted schema upgrade, start the next schema version
upgrade from the first query.
2. Contains text, e.g. 'upgrade_010_alter_sender_64bit_ids'
The schema upgrade was interrupted, skip schema upgrade steps
including the specified successful step, and resume from the next
step.
For case 2, if the schema upgrade step cannot be found, warn and bail
out. This should only happen if:
1. The storage of successful query glitched, or the database was
manually changed
2. Quassel changed the filenames of upgrade queries, and the local
Quassel core version was replaced during an interrupted schema
upgrade
Modify SqliteStorage and PostgreSqlStorage to fetch/save the
'schemaupgradestep' key. Clearing this key is done atomically within
updateSchemaVersion().
(Ideally, the whole upgrade would be wrapped in a transaction, but
that doesn't seem to be easily possible.)
Modify upgradeQueries() to return a list of query strings and
resource filenames, used for tracking the upgrade step and providing
clearer feedback on what steps fail.
Shane Synan [Sun, 27 Jan 2019 07:42:40 +0000 (02:42 -0500)]
common: Don't add quotes to exit exceptions
When logging exit exceptions, wrap the QString in qPrintable(),
removing the extra quotes added by the debug logger.
Shane Synan [Sat, 26 Jan 2019 04:16:40 +0000 (23:16 -0500)]
build: Add Boost 1.0 license for CMake script
Add copy of Boost 1.0 license for the included CMake script
GetGitRevisionDescription. This addresses licensing concerns for
Debian and derivatives.
Rename the license file according to existing licenses GPLv2 and v3.
See https://www.boost.org/LICENSE_1_0.txt
Fixes #1504
Janne Koschinski [Tue, 15 Jan 2019 16:32:43 +0000 (17:32 +0100)]
Fixes misalignment of buttons in inputwidget
Janne Koschinski [Tue, 15 Jan 2019 16:32:08 +0000 (17:32 +0100)]
Fixes bug where nicklist was broken on first start
Starting with commit
66e6d26 the nicklist gets hidden in
setDisconnectedState, but only unhidden in loadLayout.
As loadLayout skips the setVisible(true) if the state is empty, the
actual widget gets never shown, and the nicklist dock remains empty.
This was fixed by moving the setVisible call above the conditional
return.
Shane Synan [Wed, 13 Feb 2019 08:35:36 +0000 (09:35 +0100)]
Apply suggested info change
Co-Authored-By: justjanne <janne@kuschku.de>
Janne Koschinski [Tue, 12 Feb 2019 21:42:26 +0000 (22:42 +0100)]
Allow configuring listen address
Janne Koschinski [Wed, 2 Jan 2019 18:35:43 +0000 (19:35 +0100)]
Properly handle options if core has just now been configured
Janne Koschinski [Wed, 2 Jan 2019 18:35:00 +0000 (19:35 +0100)]
Make the identd listen on all adresses
Manuel Nickschas [Thu, 24 Jan 2019 22:57:15 +0000 (23:57 +0100)]
src: Yearly copyright bump
... and it's still January!
Manuel Nickschas [Thu, 13 Dec 2018 20:05:04 +0000 (21:05 +0100)]
cmake: Remove left-over debug message
Manuel Nickschas [Tue, 20 Nov 2018 21:29:58 +0000 (22:29 +0100)]
cmake: Add missing Boost dependency
Add a dependency to Boost in the modules that use Boost already,
so Boost headers installed in a non-standard location are found.
Manuel Nickschas [Tue, 20 Nov 2018 22:33:56 +0000 (23:33 +0100)]
cmake: Create imported target for Boost, if it doesn't exist yet
Older versions of CMake's FindBoost.cmake don't create imported
targets for the library. Create it ourselves if necessary.
Manuel Nickschas [Tue, 20 Nov 2018 21:10:27 +0000 (22:10 +0100)]
cmake: Fix OSX post-build if not all targets are requested
The post-build actions for OSX were not conditional on the selected
Quassel variants, so add_custom_command would be added to an undefined
target in that case.
This bug has been there since literally forever; however, CMake < 3.0
silently ignored the custom commands in that case, and thus this
issue was not visible.
With cmake_minimum_required now set to 3.5, the new behavior is
enabled and causes an error at configure time. Fix this by adding
the missing conditions.
Manuel Nickschas [Sun, 18 Nov 2018 22:18:47 +0000 (23:18 +0100)]
serializers: Fix quint16 deserialization, remove code duplication
Fix a bug where a quint16 would be deserialized into a QVariant
of type Int (instead of UShort). This broke the sync of
autoReconnectRetries in the network settings, because the slot's
signature didn't match the type of the QVariant.
The issue was caused by QVariant not having a constructor for
quint16, thus casting it into an int. Fix this by using
QVariant::fromValue(), which handles the type correctly.
Use the opportunity to remove much of the code duplication in the
deserialization code by providing and using a template function,
avoiding potential other issues with using QVariant's constructor.
Manuel Nickschas [Sun, 18 Nov 2018 20:02:12 +0000 (21:02 +0100)]
cmake: Allow to make compile warnings fatal
Failing on any compile warning is very useful in CI builds,
so add an option for enabling this. The option defaults to OFF,
because we don't want to annoy users that don't want this.
Enable fatal warnings in Travis CI.
Manuel Nickschas [Sun, 18 Nov 2018 19:51:01 +0000 (20:51 +0100)]
qa: Remove dead code
Manuel Nickschas [Sun, 18 Nov 2018 19:50:25 +0000 (20:50 +0100)]
qa: Simplify main window activation logic
Remove code duplication, avoid a warning about unreachable code.
Manuel Nickschas [Sun, 18 Nov 2018 19:49:05 +0000 (20:49 +0100)]
qa: Don't import whole Protocol namespace
Explicitly specify the Protocol namespace where needed. This avoids
warnings about hidden global symbols.
Manuel Nickschas [Sun, 18 Nov 2018 18:12:10 +0000 (19:12 +0100)]
cmake: Increase warning level on MSVC
By default, CMake sets /W3, which basically outputs nothing.
The next level /W4 is more useful, but causes lots of false positives.
So let's use /W4 and silence stuff that is annoying and useless.
Manuel Nickschas [Sun, 18 Nov 2018 17:31:07 +0000 (18:31 +0100)]
cmake: Set proper install paths for Windows
Instead of dumping everything into the install prefix, set
separate paths for runtime and library artifacts.
The paths chosen match the expectations of Craft packaging, so
we can subsequently remove the overrides in the craft blueprint.
Manuel Nickschas [Fri, 16 Nov 2018 22:29:56 +0000 (23:29 +0100)]
travis: Add Ubuntu 18.10 "Cosmic" to the list of CI distros
Add Ubuntu 18.10 to the build matrix, so we ensure we can build
on the newest Ubuntu release.
Rework the combination of build options; it's probably enough to
test building without KDE only on the baseline, since the non-KDE
code does not change between distro versions (while the installed
version of KDE Frameworks does). This keeps the number of build
jobs reasonably low.
Manuel Nickschas [Fri, 16 Nov 2018 22:09:50 +0000 (23:09 +0100)]
cmake: Move version setup into a separate .cmake file
Introduce a new QuasselVersion.cmake that contains the hard-coded
version, as well as the code for retrieving version information from
git (if available). This file also sets up version.h with the given
information. Remove the corresponding code from the main
CMakeLists.txt.
Output the git revision at configure time if available, which helps
when analyzing build logs.
Manuel Nickschas [Thu, 15 Nov 2018 21:41:26 +0000 (22:41 +0100)]
cmake: Consolidate compile settings
Consolidate the various places where we were setting compiler options
in QuasselCompileSettings.cmake. No longer include KDE's settings;
instead, take some inspiration from their setup and incorporate this
in our own, so we not only benefit when building against KDE
Frameworks.
Properly handle CMAKE_CXX_FLAGS and friends; append the flags to the
end of our own list of flags, so one can override what we define.
Clear the variables afterwards to avoid duplication.
Get rid of some MinGW options that have been around for a decade
and are most likely no longer required.
Manuel Nickschas [Wed, 7 Nov 2018 23:09:33 +0000 (00:09 +0100)]
funchelpers: Provide overload for invoking a member function
To avoid having to write boilerplate code for invoking a member
function pointer on an object, provide an appropriate overload
for invokeWithArgsList().
Extend the test case accordingly.
Manuel Nickschas [Wed, 31 Oct 2018 23:39:21 +0000 (00:39 +0100)]
funchelpers: Support the invocation of non-void callables
Let invokeWithArgsList() handle and return the return value of
non-void callables wrapped in a QVariant. To avoid special-casing,
the invocation of a void callable also returns a (default-constructed,
thus invalid) QVariant.
To indicate failure, wrap the QVariant in a boost::optional that is
empty if the callable could not be invoked.
Manuel Nickschas [Thu, 18 Oct 2018 22:20:30 +0000 (00:20 +0200)]
travis: Use ctest to execute unit tests
ctest gives us more options than make/ninja, for example verbose
output.
Manuel Nickschas [Thu, 18 Oct 2018 22:00:58 +0000 (00:00 +0200)]
cleanup: Clean up BufferViewConfig
Only mark methods as slots that need to be slots. Don't return const
refs. Un-inline everything. Rename the overload of initSetBufferList()
that isn't actually used as an init setter to simply setBufferList()
to avoid confusion.
Manuel Nickschas [Thu, 18 Oct 2018 18:33:03 +0000 (20:33 +0200)]
tests: Extend SignalProxyTest to cover request/receive method pairs
When sending an RPC request (using REQUEST()), if the request method
on the server side returns a value, a corresponding receive method
is called on the client side. Extend the test case to cover this, so
we can safely refactor relevant parts of SignalProxy in the future.
Manuel Nickschas [Wed, 17 Oct 2018 23:00:12 +0000 (01:00 +0200)]
sigproxy: Modernize RPC calls (remote signals)
The previous implementation relied on undocumented Qt internals to
transform signals into RpcCall messages. It also relied on the
old-style, slow signal/slot connections and required RPC call
receivers to be actual slots, a feature deprecated in Qt.
Reimplement this feature to make use of PMF connections. Utilize
C++14 features such as variadic lambdas and templates to shift
most of the work to compile time, which is not only more efficient,
but also gives us compile-time checks for most things.
Arguments are now marshalled to and from QVariant using the methods
intended for the purpose, rather than reinterpreting void pointers
into raw memory (which mimicked the way Qt works internally, but
is of course fully unsupported, even though it miraculously worked
basically unchanged since the early days of Qt 4...). The marshalling
code is generated at compile time, which is more efficient than the
previous approach of looking up types and constructing arguments
at runtime.
SignalProxy::attachSignal() now expects the signal to be given as a
member function pointer. SignalProxy::attachSlot() supports member
function pointers as well as functors, similar to QObject::connect().
Remove SignalRelay and related methods that are no longer needed.
While we're at it, rename RpcCall's slotName attribute to signalName,
which better reflects reality.
The reimplementation does not affect the protocol; the serialization
format remains unchanged.
Manuel Nickschas [Wed, 17 Oct 2018 20:14:24 +0000 (22:14 +0200)]
sigproxy: Actually rename SyncableObjects when requested
Until now, renaming a SyncableObject would properly update the maps
in SignalProxy, but it would not actually update the objectName
property on the client side. Fix this.
Remove the renameObject() method in SyncableObject in favor of
using setObjectName() and listening to the notifier signal emitted
by Qt for triggering the update. This ensures that the actual object
name and the expected one stay in sync. Also change places where
we unnecessarily rename right after construction to use the
appropriate constructor instead.
Extend the test case to cover the renaming of SyncableObject.
Manuel Nickschas [Wed, 17 Oct 2018 20:09:53 +0000 (22:09 +0200)]
tests: Check that sourcePeer() is set in SignalProxyTest
We expect SignalProxy::current()->sourcePeer() to be set to the
currently sending peer when handling a signal, so add a check
for this to SignalProxyTest.
Manuel Nickschas [Mon, 15 Oct 2018 22:39:31 +0000 (00:39 +0200)]
funchelpers: Add a way to invoke a callable with a list of arguments
In various places, we serialize function arguments as a QVariantList,
and later use QMetaMethod and friends to call a slot with that list.
In order to avoid this kind of runtime method lookup, we need a way
to directly invoke a given callable (e.g. a function pointer) with
a list of serialized arguments. We'll also want to use the type-based
conversion functionality of QVariant instead of using undocumented
methods and reinterpret_cast'ing raw memory, as is currently the case.
Provide a method invokeWithArgsList() that takes any callable and
a list of arguments serialized in a QVariantList, performs some
runtime sanity checks (argument count and types), and invokes the
callable with the arguments converted to the correct type, if
possible.
Also add a test case for this function.
Manuel Nickschas [Mon, 15 Oct 2018 20:18:24 +0000 (22:18 +0200)]
funchelpers: Support traits for non-member functions
Add a FuncHelper overload for non-member (free) functions. Rename
MemberFunction to FunctionTraits to reflect that enhancement.
Manuel Nickschas [Mon, 15 Oct 2018 19:22:04 +0000 (21:22 +0200)]
types: Add STL-compliant Hash functor for Qt types
In order to use Qt types with std::unordered_set (and map), a
compatible hash function needs to be provided. Provide a generic
Hash<T> functor that just uses the qHash() function for the given
type.
This can be used as follows:
std::unordered_set<QString, Hash<QString>> set;
Manuel Nickschas [Thu, 4 Oct 2018 20:16:50 +0000 (22:16 +0200)]
tests: Add unit test for basic SignalProxy functionality
Add unit test cases for attached signals as well as syncable objects.
These test cases don't check for error behavior (yet); they mostly
are intended for ensuring that the upcoming refactoring of the
SignalProxy does not affect the format on the wire. As such, the test
cases mostly focus on the protocol messages sent by invoking
SignalProxy and SyncableObject functionality.
Manuel Nickschas [Thu, 4 Oct 2018 19:10:13 +0000 (21:10 +0200)]
test: Add a spy type that waits for one or more signals
Introducing SignalSpy that allows to wait for one or more signals
to be emitted in test cases. Unlike QSignalSpy, it is not bound to
a particular signal on construction; instead, one has to explicitly
connect one or more signal(s) before calling wait().
Manuel Nickschas [Thu, 4 Oct 2018 17:03:02 +0000 (19:03 +0200)]
test: Add a way to mock peers for SignalProxy-related test cases
Introduce a new mock class MockedPeer that allows for setting
expectations for dispatched Quassel protocol messages. Also provide
matchers to express such expectations in a straightforward way.
MockedPeer for now only supports SignalProxy messages; support for
authentication messages can be added later if needed. Note that
expectations can be set on the level of protocol messages, but things
like a testing a particular serialization, the use of network sockets,
or other lower-level implementation details are not supported, nor is
MockedPeer intended for such use cases (we'd expect specific tests for
specific peer types).
Manuel Nickschas [Thu, 4 Oct 2018 16:59:59 +0000 (18:59 +0200)]
test: Add GTest printers for commonly used Qt types
Because GTest by default prints out unknown types as hexdump or other
badly readably formats, provide PrintTo functions for Qt types we use
in tests. That way, GTest will use those instead of falling back to
its own default.
Reuse Qt's own QDebug stream support to avoid having to reimplement
printing functionality for all the types. This makes it very easy
to see e.g. the contents of a QVariantMap or other complex types.
Manuel Nickschas [Thu, 4 Oct 2018 16:40:23 +0000 (18:40 +0200)]
test: Add InvocationSpy and ValueSpy helper classes
For test cases testing asynchronous operations that require a running
event loop, it is convenient to have a way to wait until something
happens. Qt provides QSignalSpy to wait for a specific signal while
spinning the event loop. This is not always convenient to use, though.
Provide InvocationSpy and ValueSpy (based on QSignalSpy) that provide
an explicit way of notifying them, without having to connect a signal
first. Unlike QSignalSpy, those classes also time out when not notified
within a given time span.
Put those classes in a new library Quassel::Test::Util, which will
gain more testing-related utils over time.
Manuel Nickschas [Sun, 30 Sep 2018 20:11:56 +0000 (22:11 +0200)]
test: Introduce Quassel::Test::Global library
Move things that are needed in every test case into a new library,
rather than requiring the Test::Main one (which is not going to be
linked to other test tooling which we'll introduce).
Manuel Nickschas [Sun, 14 Oct 2018 22:49:57 +0000 (00:49 +0200)]
modernize: Remove custom Quassel-specific log macros
The quInfo(), quWarning(), quError() macros were introduced a long
time ago to provide custom log message handling, such as logging to
file or syslog. Such features have been directly supported for the
standard Qt log macros for a while now, using a global message handler.
The only reason for Quassel's custom macros to still exist was the
lack of an info log level prior to Qt 5.5.
As we can now rely on Qt 5.5 to be available, replace the custom
macros by Qt ones, and remove LogMessage which is no longer needed.
Manuel Nickschas [Mon, 24 Sep 2018 22:42:00 +0000 (00:42 +0200)]
modernize: Remove Uncrustify config and script
Since we can now use clang-format for formatting the code, and
provide a .clang-format ruleset in the repository, we can remove
the ancient Uncrustify configuration and script.
Manuel Nickschas [Mon, 24 Sep 2018 22:13:14 +0000 (00:13 +0200)]
modernize: Reformat ALL the source... again!
It's been more than six years since we last used an autoformatter
on the codebase. Tooling has progressed, so has the language and
of course our personal preferences.
Use clang-format this time to reformat the whole codebase, following
the rules laid out in .clang-format (which one can use for configuring
an IDE, too, if it supports autoformatting). Overall, the new style
is not too different from what we used before, with one significant
change:
We now attach pointer/reference indicators (*&) to the type rather
than the name, i.e. we left-align. While this is a major deviation
from the Qt style which we use for almost everything else, it aligns
more closely with many other projects, as well as the C++
documentation and STL. It also makes more sense semantically,
because */& are really part of the type.
Other changes include (but are not limited to):
- Use only one blank line between function definitions
- Categorize includes from generic/system to local, sorting each
category alphabetically. The generic-to-local sort order seems to
be more common than the other way round, so we use that.
- In .cpp files, the corresponding header is always included first.
This is a general recommendation, because it makes it harder to
accidentally introduce a reliance on transitive includes in headers.
- Consistently break initializers in ctors before the comma, so the
commas are left-aligned together with the colon.
- Use two spaces between code and trailing comments.
Note that sometimes even clang-format gets things wrong. In a few
places, formatting was manually fixed; however, reviewing a diff of
almost 80k lines is a rather boring task, so we didn't thoroughly
go through all the changes. Wrong formatting can always be fixed
in follow-up commits, anyway.
Note also that we don't intend to re-run clang-format on a regular
basis, nor do we want to religiously follow a hardcoded set of rules
for new code in the future. Where it makes sense, the rules may be
bent in favor of better readability or more pleasing code.
Manuel Nickschas [Mon, 24 Sep 2018 19:55:42 +0000 (21:55 +0200)]
cmake: Add build-time dependency to Boost 1.56
We'll be using some Boost features in the future, so prepare the
build system to reflect that dependency.
Manuel Nickschas [Mon, 24 Sep 2018 19:26:35 +0000 (21:26 +0200)]
travis: Reduce ccache size
Reduce the ccache size in order to not waste too much time packing/
extracting the cache. Since we're only building one project, 1G should
be plenty.
Manuel Nickschas [Mon, 24 Sep 2018 19:04:30 +0000 (21:04 +0200)]
tests: Enable tests in Travis
Build Quassel with -DBUILD_TESTING=ON and run the tests as part of
the CI build.
Manuel Nickschas [Mon, 24 Sep 2018 18:42:51 +0000 (20:42 +0200)]
tests: Convert ExpressionMatchTests into a GTest-based test case
As first contender for the newly introduced test framework, use
the recently added ExpressionMatchTests class. Convert to use
GTest, and move into the new home for Quassel unit tests (the
tests/<module>/ directory).
With this, "make test" (or "ninja test") actually does something
if Quassel is configured with -DBUILD_TESTING=ON.
Manuel Nickschas [Mon, 24 Sep 2018 18:36:21 +0000 (20:36 +0200)]
test: Add build system support and a main function for unit tests
Add a new CMake option BUILD_TESTING (defaults to OFF) that, if
enabled, will build unit tests and related requirements.
Add a new library Quassel::Test::Main that provides a main function
for test cases.
Add a new CMake macro quassel_add_test for making the adding of test
cases convenient by hiding most of the boilerplate.
Test cases should #include "testglobal.h", so they automatically have
access to GTest/GMock macros as well as the imported main function.