Fix typos
src: Yearly copyright bump This time on time!
common: Allow skipping negotiation of IRCv3 caps Add "skipCaps" to Network, storing a list of IRCv3 capabilities to skip during capability negotiation. This allows selectively disabling capabilities on specific IRC networks. Some networks might not behave as expected, and some IRC features (e.g. "echo-message" support) are enough of a departure from traditional IRC behavior that users may want to turn it off. Add the necessary migrations and setup to SQLite and PostgreSQL. Add the "SkipIrcCaps" feature flag to signal protocol support. Fix up a comment in CoreNetwork referring to an old variable name. Update the SQL README to mention the Serializers protocol checks. Missing this caused me a few hours of confusion over why the protocol change wasn't being received :)
src: Yearly copyright bump Let's welcome 2020.
common: Always let QVariant::fromValue() deduce the type In some places, we would explicitly give the type to QVariant::fromValue(), forgoing automatic type deduction. This is almost always redundant, and in the cases where it is not, the input type should be explicitly cast. Additionally, the implementation of QVariant::fromValue() subtly changed in Qt 5.14, leading to compile errors when giving a non-decayed type (as we did in SignalProxy::attachSignal()).
src: Yearly copyright bump ... and it's still January!
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.
clazy: Convert many old-style connects into function pointer based Since Qt5, signal/slot connections can be expressed using function pointers rather than the SIGNAL/SLOT macros. This is a) much more efficient, and b) provides a compile-time check for the sender and receiver being compatible. Let clazy auto-fix old-style connects where it can. However, a lot of occurrences remain where we'll need manual intervention for one reason or another.
modernize: Use nullptr Let clang-tidy fix all occurrences where nullptr should be used instead of 0.
common: Simplify SyncableObject macros and usage Since the C++11 standard defines "__func__", and modern versions of MSVC support this, we can remove the workaround for MSVC from the SyncableObject macros. It is no longer necessary to derive the function name from MSVC's __FUNCTION__ (which contains the enclosing class name), and thus the _classNameOffset__ function declared by the SYNCABLE_OBJECT macro is no longer needed. Repurpose the macro to define the syncMetaObject() member function instead, and remove the no-longer needed INIT_SYNCABLE_OBJECT macro. The syncMetaObject() function is used by the signal proxy for accessing the metaObject() of the base class in case there are client- or core-specific specializations of a syncable object; i.e. if you have Foo directly inheriting from SyncableObject, and ClientFoo derived from Foo, the function must only be declared in Foo, otherwise syncing won't work. Thus, the SYNCABLE_OBJECT macro declares the function as final, so it can't be accidentally overridden. While we're at it, replace include guards with #pragma once in files we touched.
clang-tidy: Reorder NetworkInfo attributes to avoid excessive padding Use a more optimal attribute order to avoid excessive padding in the NetworkInfo struct. Remove the default constructor in favor of direct initialization. Rewrite the comparison operator using a boolean expression instead of a bunch of conditions.
common: Sort user prefix channelmodes on add/set Sort prefix channelmodes whenever adding/removing/setting per-channel IrcUser modes. This keeps the highest mode at the front, necessary for backlog storage to allow only showing the highest mode. It's not possible to get away without sorting as modes can be added in any order. modesToPrefixes/prefixesToModes operate in order, so sorting prefixes results in sorted modes for free. IrcUser modes don't need sorted as they're not hierarchical and not stored anywhere.
IrcUser: Rename lastAwayMessage to lastAwayMessageTime This will make it easier for clients to implement both at the same time. Also, add a backwards-compatibility function to allow old cores to set the lastAwayMessageTime. There is still no forwards- compatibility (support for old clients on new cores) since no existing clients do anything with lastAwayMessage.
IrcUser: Use QDateTime for lastAwayMessage, not int This converts the lastAwayTime to a 64-bit time. Backwards- compatibility is also included in Network to convert back and forth between the old 32-bit type for legacy peers. No backwards- compatibility is provided for the SYNC call because the value is never actually used in any existing clients. New clients that want to implement this functionality would need to implement the LongTime feature.
Semi-yearly copyright bump It's no longer 2016.
core: Stop ratelimiting log spam with old client Downgrade invalid 'setMessageRateBurstSize' and 'setMessageRateDelay' warning messages to debugging level. This happens any time an older client tries to configure a network for a newer core and in most cases can be ignored. Should an issue arise, the log level can be set to debug.
Add capAvailable to Network akin to capEnabled Add capAvailable to Network, checking if the server advertised the given capability. This mimics capEnabled, but applies regardless of whether or not Quassel requested the capability. This is useful for showing elsewhere whether or not a certain capability could've been requested. Use this in Network::saslMaybeSupports to avoid falsely claiming SASL support when the SASL capability wasn't advertised. This matches the behavior of CoreNetwork.
Move SASL maybeSupports into Network class Move IrcCap::SaslMechs::maybeSupported to the Network class, simplifying usage. Now there's no need to specify the capability value, avoiding hassle for most cases when you already have the Network object. Update CoreNetwork to use the moved function. Tidy!
Keep old clients from removing message rate delay Add a guard against zero message delay in setMessageRateDelay, following the error-checking of setMessageRateBurstSize. This blocks old clients from setting message rate delay to 0 seconds for newly- created networks, improperly overriding the default of 2.2 seconds. This affects creating a network in an old client, switching to a new client, then enabling custom rate-limits. The supported method for removing rate limits by setting Unlimited to true still works. Resolves GH-252.
Implement custom rate limits Add custom rate limits flag and settings. > In database, add 'usecustommessagerate', 'messagerateburstsize', 'messageratedelay', and 'unlimitedmessagerate' to 'network' table, defaulting to the values already used. This modifies schema, requiring a version bump, changes to migration scripts, etc. Use 4 upgrade scripts as SQLite does not support adding multiple columns at once. > In protocol, add 'useCustomMessageRate', 'msgRateBurstSize', 'msgRateMessageDelay', and 'unlimitedMessageRate' to Network, configuring custom rate limits. Add 'CustomRateLimits' feature flag so the client can tell users about needing to upgrade their core to get this feature. If rate limits set to unlimited, disable the token bucket timer and send messages immediately. Otherwise, modify the existing token bucket variables according to the new limits. The defaults are unchanged. Add "Use Custom Rate Limits" checkbox to network "Connection" tab with an explanatory tooltip warning against setting too low of rate limits. Tooltip is modified and checkbox disabled if the core does not support the feature. Testing: > Database schema handling SQLite new install - works SQLite upgrade - works SQLite migrate to Postgres - works Postgres new install - works Postgres upgrade - works > Client/core connections New client, new core - works New client, old core - works, custom rates grayed out Old client, new core - works, custom rates reset + disabled on edit (Unfortunately there's no way to use a boolean and tell if the client is old, or actually disabling custom rate limits. Would need the work-in-progress ClientFeature system 'esainane' designed)