AgeCommit message (Collapse)Author
2018-11-14Catch bad_numeric_casts in crypto codeEdwin Mons
Exceptions thrown by boost::numeric_cast are now caught and an assert explicitly triggered. Test-Information: Unit tests pass on macOS 10.13 Change-Id: I9a1cbe5ae2765e4275bf35473a871ef8468fd729
2018-11-14Fix various uses of numeric_cast in UI bitsEdwin Mons
Apart from QtUI bits, this addresses use of uncaught numeric cast exceptions in message count handling, the spell parser and the MacOS idle querier. The WindowsServicePrincipalName logic previously had an issue where using ports from 32768 onwards would result in a bad_numeric_cast exception to be thrown. This has been addressed at the same time as the uncaught exceptions, and all ports should work now. The tags file has been extended to ignore more files. Change-Id: I73ced35f06517bee5c58f990d20fa437b40ac84e
2018-11-14Fix Stanza Ack maximum and testsEdwin Mons
The stanza ack code now uses a constexpr without numeric cast to calculate the maximum, and test code uses the constant UINT32_MAX from limits, both of which should result in the same number. Test-Information: Unit tests pass on macOS 10.14 Change-Id: Iba8fc779e52699d480d1ce458df0c6581a16ad06
2018-11-13Update one forgotten port in BoostConnectionEdwin Mons
Test-Information: Unit tests pass on Debian 9 and macOS 10.14 Change-Id: I7881249c68a294679a6a9d0f6bef65cad5034687
2018-11-09Remove numeric_casts from XML parsersEdwin Mons
The code has been updated to use asserts where a sensible recovery path was deemed impossible, and a conditional return for parse. In general, our XML parsing will fail for any single parse of a document over roughly 2 2GiB, which is probably not going to be a practical issue soon. Test-Information: Unit tests pass on macOS 10.13 using Expat and Debian 9 using LibXML Change-Id: I3a8da802860028ea278b322af081c2b22b55a442
2018-11-09Store NATPortMapping lifetime as uint32_tEdwin Mons
The NAT-PMP RFC specifies lifetime as an unsigned, 32 bit integer, so using this internally makes sense. This also removes the need for casts in interface code. A slight bug in the NATPMPInterface implementation to remove a mapping has been addressed. Test-Information: Unit tests pass on macOS 10.13 Change-Id: I06687fd2735a8706f339f85d6c957ad7aadaaf02
2018-11-08Handle RFC 1035 label and domain len restrictions in libidn backendTobias Markmann
LibIDNConverter was fixed to handle these restrictions correctly. Test-Information: Added unit tests for RFC 1035 length restrictions for labels and domain names. The libidn and ICU backends pass the new test. Change-Id: Ie570b0ee4c5c6381f7769f6178ec2a5824074221
2018-11-08Change unread counters to size_tEdwin Mons
Since the counters cannot be negative, changing the type used for unread counters to size_t seems a better fit, and it avoids the need for numeric_casts. Test-Information: Unit tests pass on macOS 10.13 Change-Id: I61badcfc410f0cce7f922da90b50ef5a809c6521
2018-11-08Consistently use unsigned short for network portsEdwin Mons
Network ports are now consistently stored as unsigned shorts, apart from the options and user interface, where -1 is still used to denote the use of default ports. Test-Information: Unit tests pass on macOS 10.13 and Debian 9 On macOS: tested the UI with various proxy and manual ports, behaviour as expected. Change-Id: I7a65f40083022887aa30ed7b21eadc56d0c52be1
2018-10-25Strip off trailing dot from domainpart of jidEdwin Mons
RFC 6122 specifies that if a domainpart ends in a dot, it must be stripped off before any other canonicalisation steps are taken. Unit tests have been added to check that various JID scenarios with a domain ending in a dot pass or are rejected as expected. Test-Information: Unit tests pass on macOS 10.13. Manual tests in sluift show expected behaviour. Change-Id: Id6813aaa4422a81bff0a4559eacd6855ef104dc3
2018-10-24Honour JID part length in ICUConverterEdwin Mons
ICUConverter allowed jidparts greater than 1023 bytes during stringprep. The SConscript of StorageTest did not work when libidn had been disabled, which prevented test=unit from completing. Test-Information: Unit tests pass on Debian 9 in a build with ICU and ASan enabled. Change-Id: I791a09457c6b852e61ce1281871e0f3ca0ce645c
2018-10-24Fix buffer overrun in LibIDNConverterEdwin Mons
When Swift::LibIDNConverter::getStringPrepared was called with an input of 1024 or more characters, stringprep would be called on a memory region that wasn't NUL-terminated. It also blindly trimmed the input to 1024 bytes, even though there may be input longer than that that still results in a valid 1023 byte prepped string. IDNConverterTest has been converted to gtest, as cppunit cannot deal with testing for std::exceptions being thrown on at least macOS Test-Information: Unit tests pass on macOS 10.13 and Debian 9 Before fix, the newly added unit tests triggered an ASan abort due to a buffer overrun. After fix, all unit tests pass, even with ASan enabled. Change-Id: Ia3e51a39f5db1de32b8f8bb388f81ca041136df7
2018-10-12Fix Component's disconnect to run event loop while isActiveRoger Planas
The Component::disconnect() was controlling the running of the event loop with the isAvailable flag, but it turns out that depending on timing, a re-connect could be attempted and the component erroneously claim that the "Component is already connecting or connected", which could not possibly the case if the first attempt to connect the component failed (hence, not possible it was connected). By updating the event loop to use the correct isActive flag, this issue is fixed. This error was highlighted as a result of the previous commit "Prevent connect on active sluift clients and components". Also, the getNextEvent is fixed to do not suffer from the same problem, and use isActive instead of isAvailable. Test-information: Before the patch, a test that would attempt a second component connect after a failed one would randomly fail. After the patch, a test that would attempt a second component connect after a failed one has passed hundreds of time without failure. Change-Id: I20be6b1c8aec485ded3330c143dedd2161c4c66e
2018-10-10Remove JID prep caching from JID classTobias Markmann
Ran a flamegraph diff on Swift login to an account with a moderate number of JIDs in roster and more than 10 rooms in auto join. It showed a difference less that 0.1% on the changed method. As it does not make much of a difference for Swift at least, caching is removed. Test-Information: Unit tests passes, Swift still logins fine on macOS. Change-Id: Id33d6d1a655580e06e1364df717fd6f34cce5327
2018-10-09Address compiler warnings about missing override on dtorsTobias Markmann
Test-Information: Builds and compiler warnings in not emitted by clang 8.0.0 anymore. Change-Id: I118552b3b058acd15cdb9579e3695d9bf3d6b2fe
2018-10-04Prevent connect on active sluift clients and componentsEdwin Mons
Connect should not be called twice on clients or compoments without disconnecting first. While this worked in some cases, mixing connect options, specifically first trying without, and then with a bosh_url, would lead to asserts being triggered. The connect logic now checks whether there's already a connection in progress or established, and raises a Lua exception early if there is. Test-Information: Tested on macOS 10.13 Connected components and clients with invalid and valid hosts, and with valid and invalid bosh_urls, all with and without disconnecting in between attempts. No asserts were triggered, and appropriate Lua exceptions were thrown. Change-Id: I6b91b57945844bce7fce0073e5d0fe199ab815d5
2018-10-01Pass /bigobj when building on WindowsTobias Markmann
Debug builds building with /MDd will otherwise fail on Windows with MSVS 2015. Test-Information: Builds successfully with /MDd flag on Windows using MSVS 2015. Change-Id: I9ac7e9408f09354025bb39cb5642efce686d11f0
2018-10-01Add ability to specify MSVC runtime libraryTobias Markmann
Test-Information: Builds in default configuration on Windows 10 with MSVS 2015. Change-Id: I82e6a317820168d471694c8ee1f33b652515c0d9
2018-10-01Change ur literals to r, as ur is unsupported in Python 3Tobias Markmann
r literal is supported by both Python 2 and Python 3. Test-Information: Builds on Windows 10 with Python 3 and VS 2015. Change-Id: I2210a1ba01a4bf3c175634adeb067f1f939a7e61
2018-10-01Catch numeric cast errors in BoostConnectionServerEdwin Mons
When BoostConnectionServer tries to set up a listener, it casts an int to an unsigned short, which may throw an uncaught exception if the cast fails. Test-Information: Unit tests pass on Debian 9 Test server code no longer crashes when it tries to set up a listener on an invalid port. Change-Id: If6b920e54481ce6bf174df01d14ad12eff90e3f4
2018-09-26Update SCons in 3rdParty from 2.4.0 to 3.0.1Tobias Markmann
This also has our scons patch in 3rdParty/SCons applied. Test-Information: Builds with unit tests on macOS 10.13.6. Change-Id: I25d3662eeec27a76dab10d501ba46dc16f0bef4b
2018-08-02Have StreamStack own the top and bottom layerTobias Markmann
Test-Information: Builds, unit tests and integration tests pass on macOS with clang 7.0 master. Change-Id: I0db411e49339ccb2301edd1a16612cb1ad2c927c
2018-08-01Use interfaces for top and bottom layer in StreamStackTobias Markmann
Test-Information: Builds, unit and integration tests pass on macOS with clang 7.0 master Change-Id: Idb9648c1293adbe6f4b79af3ad619ebb0630e48d
2018-08-01Avoid lvalue and simplify boolean expressionTobias Markmann
Test-Information: Builds and unit tests pass on macOS with clang 7 master. Change-Id: I0bf2828db49dfb6a7e99c78f1d2f7e76e87f8ca1
2018-07-31Have StreamStack own intermediate layers via std::unique_ptrTobias Markmann
Test-Information: `./scons test=all` passes with no errors on macOS with clang 7 master. Change-Id: I31765ac15750dc5af7b70d1a85171dc8e3590181
2018-07-30Add clang-tidy-fix target to MakefileTobias Markmann
This has clang-tidy write changes out to YAML files in parallel and finally runs clang-apply-replacements which merges, deduplicates and applies the changes in serial. Uses Python to determine the number of parallel jobs to run. Test-Information: Tested by adding new checks and running clang-tidy-fix. Works as described above and is much faster compared to a serial `clang-tidy -fix` run. Change-Id: Idb357e63edeba75ef9a4fb53f5ddef2a7c3c23ee
2018-07-30Use std::unique_ptr to have TLS classes own the TLSContextTobias Markmann
TLSLayer and TLSConnection now own the TLSContext they use. The TLSContextFactory interface is adjusted to use std::unique_ptr. Test-Information: Builds and all tests pass on macOS with clang-7-master. Change-Id: I14e33c98b48445094f404b73ea41af0a51d2dde6
2018-07-27Autofix boost-use-to-string clang-tidy warningsKevin Smith
Done by adding --fix --fix-errors to the clang-tidy args in the Makefile Test-Information: Unit tests pass (macOS) Change-Id: I3a4df955ac3553afeb9384f23f9d8b2ef01117e2
2018-07-27Fix compiler warningsKevin Smith
This doesn't address the issue in ChattablesTest that the checks against 0 are being reported as checking null against 0 literals. Test-Information: Fewer warnings after the change (macOS). Change-Id: I24330f0ab99d6eb267e03a46983ced75e42c22cc
2018-07-27Add clang-tidy supportKevin Smith
This adds a single check (which is already enough to fail). clang-tidy < 7 requires absolute paths in the compile-commands.json, which isn't what will happen here. If you want to run with a previous version (6 is latest, 7 expected in a month), apply this patch (which will break normal ninja compilation, thus not applying it properly, and I'm not sure it's worth any time getting it work when the clang-tidy bug is fixed imminently): diff --git a/BuildTools/ b/BuildTools/ index df4c6559d..13e78d650 100755 --- a/BuildTools/ +++ b/BuildTools/ @@ -168,8 +168,16 @@ class NinjaBuilder : self.variables += str(name) + " = " + str(value) + "\n" def build(self, target, rule, sources = None, **kwargs) : + if is_list(target): + target = [os.path.abspath(x) for x in target] + else: + target = os.path.abspath(target) self._build += "build " + self.to_string(target) + ": " + rule if sources : + if is_list(sources): + sources = [os.path.abspath(x) for x in sources] + elif isinstance(sources, basestring): + sources = os.path.abspath(sources) self._build += " " + self.to_string(sources) if 'deps' in kwargs and kwargs['deps'] : self._build += " | " + self.to_string(kwargs["deps"]) Test-Information: Running make clang-tidy spits out complaints about the code. Change-Id: Ic9f43fd2e11ebd595b4b8a5cee8d290cd5349abf
2018-07-26Allow scons2ninja to work with check=1Kevin Smith
Test-Information: Ran ./BuildTools/ check=1 build_examples=0, and it generated a script that builds and runs the checker, and that makes ninja -t compdb cxx spit out things suitable for compile_commands.json Change-Id: I9b92557f35c8230cc59a32580546a520e5684cab
2018-07-26Fix trailing whitespaceKevin Smith
Change-Id: I2e8bf314459b8748953cee3c7471e6ab1589b043
2018-07-26Handle changes in the new roster model properlyPeter Burgess
The new roster was temporarily resetting the model every time there was a change, this patch sets it up properly to use beginXxxRows, endXxxRows and dataChanged instead. Test-Information: Unit test created to check the onBeginAdd and onAdded signals get called at the correct time and that data is stored properly when a JID is added. Also tested live on test server, checked what happens when the user first logs in, and when contacts log on and off. There was some concern over the new setState function, and its impact on populating the new roster on login. I ran multiple tests, swift-4 vs swift-5 with the new roster, I tested having 3000 users with and without presence in the roster, 100 users and 3000 users split into 30 groups of 100. We tested both the time to populate the roster (pre presence) and the time from login until the roster become responsive and usable. The results weren't terribly different between swift-4 and swift-5 with the new roster, and swift-5 was populating both the old and new rosters, therefore we concluded that the new roster is not causing a significant slowing down during login. Change-Id: I2aba5cbcd81296b49d36c54ee7f07453f1b2db08
2018-07-24Add a XEP-346 FDP Form Submission DialogPeter Burgess
A new form submission dialog that will discover nodes containing fdp form templates in a given pubsub domain, and will present the form to the user ready to be filled out and submitted. Test-Infomation: Personally tested the request for all node items, loading the latest form from one of the discovered nodes, submitting a form and checking it turns up on my mlink server using mlc, checked that the submitted infomation is correct, what happens when an incorrect domain is queried, what happens when a valid domain is queried but it has no fdp nodes, and what happens when a form is requested from an invalid node. Unit tests written to test success and failure of the three controller functions requestPubSubNodeData(), requestTemplateForm() and testSubmitForm(). Change-Id: If8c57bb4e3120dd44d52f7332069eb18a14cb385
2018-07-19Rename MainController to AccountControllerThanos Doukoudakis
Change-Id: I9c006a2435294f2afb95a95bd856ad64274a8752 Test-Information: None.
2018-07-19Fix compiler warningsKevin Smith
Test-Information: Compiles now, didn't before (mac allow_warnings=0). Change-Id: I6bff608d8c308e933e8582242a3c9d55858981ce
2018-07-19Add server avatars to multiaccountThanos Doukoudakis
This patch implements a Model/View/Delegate for the multiple accounts a user might have. The list is shown on the left of the client, with an avatar, status presence and unread message counter. Mouse over a server avatar will show the user jid that was used to connect to the server. Server avatars are currently using the default Swift logo, server information are not connected with the actual data, and the presence icon is not being rendered. Future patches will improve this and connect to the actual server data. Test-Information Tested the changes in the UI in Windows 10 Qt5.8 and Ubuntu 16.04 Qt 5.6. Tested the status change, login, logout and saving account information during startup. Change-Id: I4aa86afffe6a02d589b47185cc587b2e09de7450
2018-07-18Add support for multiple accountsThanos Doukoudakis
Added support for multiple accounts and a list of servers where the user can switch between the accounts. Future patches will make the list widget to use server avatars with user status. Upon startup the client will reconnect with all previous accounts. If the user log outs with any of the accounts then it will not login automatically for future sessions, the credential though will be available to the user. Upon upgrading from previous versions, the client will migrate the account that was previously marked to auto-login to the new configuration and enable it. After the migration the autologin setting will be set to false. Some of the settings and command line arguments have been made obsolete due to these changes and removed, including SSO support, which will be re-introduced in a future patch. Test-Information: Tested the changes in Windows and Linux, tested adding and removing accounts, and switching between them. Tested the new configuration for accounts, the upgrade behaviour when an account is marked/not marked to autojoin, and the migration to the new configuration. Verified that the auto-login setting is set to false after the migration, and that the migrated account can be disabled (currently only by signing out). Change-Id: I63662f80e006112fde6f418f9743e2b420e81870
2018-07-17Rename variable for consistencyKevin Smith
Everything else in the class uses underscore suffixes already. Test-Information: Unit tests pass. Change-Id: I1263025f18a6e06971610f8c7fc06f47bbbe9c9d
2018-07-17Add unit test for missing bookmark responsesKevin Smith
Test-Information: Without the recent fix for missing bookmark results, tests crash, on master they pass Change-Id: Iab2d55d6d60e5926485d31f4dd63a117a9d12aee
2018-07-17Don't crash on missing bookmark resultKevin Smith
Test-Information: Before the patch, boom, after the patch, no boom. (No boom today. Boom tomorrow. There's always a boom tomorrow) Change-Id: Id454d7b0d0cd05774d0f1ee0b3cb77057371c459
2018-07-16Change some spelling mistakes and improve styleThanos Doukoudakis
Test-Information: None. Change-Id: Idea7be5b1dd5d1829cd1a468d12cb527204ab397
2018-07-12Fix Python 3 compatibility of our SCons and tooling Python codeTobias Markmann
For the upcoming update to Scons 3, which works with Python 2 and Python 3, this change makes our code compatible with Python 3 so that it still works with Python 2. Test-Information: Tested these changes with SCons 3.0.1 on macOS 10.13.6 with Python 2.7.15 and Python 3.7.0. Change-Id: Idb5207b179a79a0dbe89d7e620d182a7d2f1ca6c
2018-06-21Add a leave room option in MUC roomsThanos Doukoudakis
This patch will add a leave room option in the cog menu of a MUC room, allowing the user to leave the room and close the window. Additionally when joining or leaving a room the autojoin field will change to true or false respectively. This patch also fixes a minor issue with a gui option that was not identifying bookmarked rooms at the cog menu. The autojoin option on the Enter room, Bookmark room and Edit Bookmark menu has been removed, since the default behaviour will be to automatically bookmark every MUC room the user joins, setting autojoin to true. If the user chooses to leave the room, then the autojoin flag will be set to false and the bookmark will be updated. Test-Information: Tested the changes in the UI in Windows Qt 5.9. Updated the ChatsManagerTests unit tests to check the chattables and the behaviour of the bookmarks, when joining and leaving MUCs. Change-Id: Iad1f34480a1e0b9df25c73b49247acc7b7825e20
2018-06-19Don't double-connect to IP literalsKevin Smith
Before this change, an IP literal would be attempted directly, and if that failed it would then 'resolve' the literal and try the result. Test-Information: Added a unit test verifying the bug before fixing it. Change-Id: Ic887c74152f5a4b259392dad402952b3777268b1
2018-05-29Add Bernhard M. Wiedemann to COPYING.thirdpartyTobias Markmann
Test-Information: N/A. Change-Id: I8c43cec0cb0f3349dc12fe7cc1d19f396c2c9332
2018-05-29Sort input file listBernhard M. Wiedemann
so that the swift-im openSUSE package builds in a reproducible way in spite of indeterministic filesystem readdir order See for why this is good. License: This patch is BSD licensed - see Documentation/Licenses/BSD-simplified.txt for details. Test-Information: Builds on different machines should no longer have differences in Swiften.h Change-Id: I8066a66db83c7d7ff10858196cb72b13af3f6008
2018-05-18Remove remants of non-netbook mode related codePeter Burgess
This includes removing the class QtChatTabsShortcutOnlySubstitute, passing around QtChatTabs instead of QtChatTabsBase, removing checks and casts relating to the possible use of either QtChatTabs or QtChatTabsShortcutOnlySubstitute, checks to see if the splitter exists as the splitter should now always exist. Test-Information: Program still builds and runs fine. Both login and main windows open and work correctly. Chat tabs open and close without fault. Unit tests still pass. Removing loginWindowGeometry from the config file causes no issues. Change-Id: Iab58ab7fd23571f4aeeb7c8a9a988bdb1500ba5b
2018-05-18Add underscore to QtUIFactory's member variablesPeter Burgess
Patch to add an underscore to the end of old QtUIFactory's member variable names that are missing one. Test-Information: Swift still builds and runs, no noticable problems logging in, chatting, opening new chat tabs etc, no unit tests broke. Change-Id: I938d1c325ccefd775d3742ee2b509f98e84c426d
2018-05-18Open swift with sensible geometry in netbook mode the first timePeter Burgess
If swift has never been run in netbook mode before, then netbook mode geometry is set by some hard coded default value during construction of QtSingleWindow. The code to set and utilize the original non-netbook mode geometry has been removed. Test-information: No unit tests as all changes at Qt specific. Tested after deleting config file. Tested after replacing config file with one that has no SINGLE_WINDOW_XXX settings (so a config file you would find if swift had never been opened in netbook mode). Tested with one or other of the SINGLE_WINDOW_XXX settings missing Tested with config file that contains all SINGLE_WINDOW_XXX settings Change-Id: I0075456796bd830b855629fbd03d601df7f2891c