1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
Commit Graph

126 Commits

Author SHA1 Message Date
Anthony Bilinski
9a8706a65f
fix(history): Heal duplicate peer entries with different case
Prior to 2f4e8dc3e8 we would take
the written ToxID and insert that straight into history without
any case check

Must be done prior to schema 11 since even though the UNIQUE constraint
on the peers table is fooled by the different case, the UNIQUE
constraint on the new chats and authors table which are stored as BLOBS
fail during upgrade when the two different case but equal ToxPks
collide.

Unfortunately it can't be done as its own upgrade since 11 was already
merged, and this is a prerequisite for 11 to pass for some users.

Execute prior to starting the split peer upgrade instead of as a larger
transaction for simplicity of the split upgrade, and since executing
this deduplication is idempotent.
2022-05-22 11:15:59 -07:00
Anthony Bilinski
dc46267833
fix(test): Don't rely on row IDs after moving tables
Row ID's are not guaranteed to match those from the original peer table.

New checking method is equally strict since we already verify the number
of entries, and the SQL schema guarantees that entries are unique.
2022-05-21 20:49:32 -07:00
Anthony Bilinski
6ad92bb637
test(history): Add unit test for when db is newer than qTox supports 2022-05-20 11:38:12 -07:00
Anthony Bilinski
9571434df9
feat(CI): Disallow unsafe implicit casts to QString
Covers char* without size, and QByteArray.

Catches the case of QByteArray to QString implicit conversion like was
fixed in 47ee51c61d, but still allows
construction or assignment from string literals in source. Gives most
of the type safety of QT_NO_CAST_FROM_ASCII without having to wrap
every literal string in QStringLiteral.

No functional issues found during change.
2022-04-05 12:10:05 -07:00
Anthony Bilinski
1e4eed76b5
refactor: Move GroupList global state into class 2022-04-05 10:34:53 -07:00
bodwok
a1b08d6493
fix(FriendList): exclusion of possible undefined behavior 2022-04-03 11:03:48 +03:00
Anthony Bilinski
71c3f997b4
refactor: Move FriendList global state into class 2022-03-30 19:04:11 -07:00
Anthony Bilinski
16ac8a8eac
refactor(History): Split peers table into chats and authors
peers had combined meaning, both being referenced by history for which
chat a message was in, and being reference by aliases for who authored a
message. This means that peers had conceptually different sub-groups:
all friends are both a chat and an author, but self is an author but not
a chat. With the addition of group chats this is amplified by groups
themselves being chats but not authors, and group members being authors
but not chats. Instead of having four sub-groups all within peers,
splitting peers into chats and authors gives a clean mapping,
simplifying interactions with the data.

In the new chats and authors tables, store what used to be a public_key
string as a BLOB, since it’s inherently a 32-byte binary value in both
cases. Call the public_key a UUID for chats, since group IDs are not
defined as public keys by toxcore.

Even though the data change is quite minor, the upgrade is large because
of SQLite's lack of support for modifying foreign key constrains for
existing tables. This means when peers are moved to new tables, all
tables referencing peers need to be cloned with a new foreign key
constraint, as well as all tables referencing those, recursively.
2022-03-29 21:27:01 -07:00
Anthony Bilinski
f6dddf7c58
refactor(History): Move history upgrades to new directory
Upcoming upgrade is fairly large, and all the helper functions for each
upgrade are becoming ambiguous.
2022-03-27 23:33:38 -07:00
Anthony Bilinski
f0a23bbb5d
refactor(tests): Move database test utilities to their own lib
So that we can have multiple db upgrade tests that can run in parallel,
instead of one monster test that runs independent test cases sequentially.
2022-03-27 23:32:11 -07:00
Anthony Bilinski
d1a8f5d6ae
refactor(test): Use temporary files in dbschema_test
Files are conceptually temporary, having extra conflict handling logic
is unnecessary, and having the test fail to run if it crashed on last
invocation is annoying.
2022-03-27 22:59:27 -07:00
Anthony Bilinski
f777aa885c
fix(history): Heal invalid resume_file_id's saved to history
Replace underlength resume_file_id's with arbitrary data. Loaded file IDs are
not used for anything at this time, but they should not be null nor invalid.
Any 32-byte value is valid, so use all 0's for consistency.

Fix #6553
2022-03-25 16:47:52 -07:00
Anthony Bilinski
0d366a5790
chore(build): Enable all warnings on qTox libraries as well
warnings interface was only being linked to qtox_static, so were not being
applied to e.g. util. Link it to each library as well as qtox_static so that
they all inherit all the warnings.
2022-03-24 04:19:41 -07:00
Anthony Bilinski
d7b67081e5
refactor(history): Separate db upgrade logic from History
Allows for cleaner testability of upgrade logic and reduces the overall size
and clutter of History.
2022-03-19 21:27:40 -07:00
Anthony Bilinski
3d7a0d249d
refactor: Comply with Clang's Wunused-const-variable 2022-03-15 08:19:53 -07:00
Anthony Bilinski
cabcf4111f
refactor(style): Match declaration and definition argument names
Conform with readability-named-parameter and
readability-inconsistent-declaration-parameter-name
2022-03-15 08:19:53 -07:00
Anthony Bilinski
b894531cdb
fix(tests): Mock Settings for SmileyPack test
Settings upgrades global settings on construction, which can cause the
SmileyPack test to be inconsistent based on file system state.

Fix #6530
2022-03-15 01:32:16 -07:00
Anthony Bilinski
16aeb5f572
refactor(model): Rename Contact and ContactId to Chat and ChatId
* Referring to groups generically as contacts is confusing.
* Friends are referred to as contacts in many places either as more
  neutral wording, or to avoid using the keyword friend as a variable
  name. Calling Contact Chat allows contact to be used for Friends.
2022-03-14 12:44:37 -07:00
Anthony Bilinski
0c967725df
refactor: Remove Settings singleton
* Make main.cpp's toxSave free functions into a ToxSave class so that it can be
  given Settings on construction.
* Add void* to IPC callbacks so that classes can get back to themselves.
2022-03-13 16:00:48 -07:00
Anthony Bilinski
1206da2b05
refactor(ToxPk): Don't define model's ToxPk, ToxId, GroupId from tox.h
Since they exist in saved settings and the chat database, they are their own
size. assert that it matches tox.h's size in Core constructor, though.
2022-03-13 05:28:41 -07:00
Anthony Bilinski
7d773930c1
feat(tests): Merge core and core_online tests
Re-use tox instances between tests to avoid re-bootstrapping or re-requesting
friendship, saving time. Test case order within core_test is now important.
2022-03-13 03:21:09 -07:00
Anthony Bilinski
5f870c28e5
feat(test): Bootstrap core_test off second local tox instance
Allows core_test to be run without internet, and makes it much faster
and less flaky in CI.

Also split socks5 and http tests.
2022-03-13 03:21:05 -07:00
Anthony Bilinski
6f3fb30f24
feat(test): Add mock bootstrap list generator 2022-03-13 01:50:47 -08:00
Anthony Bilinski
7395c1cb3f
refactor(model): Fix case of IBootstrapListGenerator::getBootstrapNodes 2022-03-13 00:42:33 -08:00
Anthony Bilinski
47328cc6bf
refactor: Remove SmileyPack singleton 2022-03-12 16:28:06 -08:00
Anthony Bilinski
bda1a6a909
refactor: Comply with Wpedantic
* Remove semicolons after calling a macro
* Remove semicolons at the end of class declarations
* Remove semicolons at the end of namespaces
2022-03-11 10:08:02 -08:00
Anthony Bilinski
adc0f0cca6
refactor: Comply with Wmissing-declarations
* Move free functions to the anonymous namespace
* Additionally move static free functions to the anonymous namespace
* Move functions that must be accessed externally to static class functions
2022-03-11 10:08:02 -08:00
Anthony Bilinski
02d5270dcc
refactor: Comply with Wmissing-field-initializers
Add explicit missing initializers.
2022-03-11 10:08:02 -08:00
Anthony Bilinski
48ad6cc17a
refactor: Comply with Wunused-parameter
Explicitly ignore unused parameters.

Also replace Q_UNUSED with std::ignore for consistency and to favour std
over Qt when equivalent.
2022-03-11 10:07:57 -08:00
Anthony Bilinski
fc2e445294
refactor: Comply with Wshadow
Avoid shadowing variables:
* Rename variables to something better if possible
* If not, postfix shadowing arguments with _. Favour leaving member
  variables without postfixes.
* Rename variables prefixed with _ to avoid library function collisions
* Avoid double underscore anywhere in names
* Make definition and declaration argument names match where seen
* Favour using class variable over argument variable, where equivalent
* Remove explicit this-> where equivalent
2022-03-11 08:35:38 -08:00
Anthony Bilinski
e316a683ff
chore(CI): Set a long test timeout for core_online_test
Same reasoning as 30d54b1b0f.
Missed the test timeout when increasing the verify timeout.
2022-03-08 20:18:30 -08:00
Anthony Bilinski
30d54b1b0f
chore(CI): Set a very long timeout for core_online_test
CI has very flaky network causing everything to take way longer than expected.
None of the tests are actually checking that something happens quickly, so just
set a stupidly long timeout to avoid flakiness.
2022-03-08 15:41:17 -08:00
Anthony Bilinski
bc751c8e1c
refactor(test): Move mocks into their own library
Avoid re-compiling sources for each test that uses them.
2022-03-02 23:30:04 -08:00
Anthony Bilinski
40846f886c
refactor(test): Deduplicate MockCoreSettings
Also add Mock sources to all tests, to handle tests that require both project
resources and mock without complicating auto_test
2022-03-02 23:30:04 -08:00
Anthony Bilinski
12b3b05217
test: Fix signal spy mixup for core_online_test
* Fix statusMessage -> userName mixup in change_status_message
* Create named constant for sleep interval waiting for friend's message to arrive
* Elaborate on comments around the sleeps a bit more, I was confused by them still
* Increase bootstrap timeout to 120s, it expired in CI at 65s
2022-03-02 23:30:04 -08:00
sudden6
e2d0472a9f
test: add more online test 2022-03-02 23:30:04 -08:00
Anthony Bilinski
e426994e5f
test: Fix issues with core_online_test
* Move static function variables from core to be class member variables,
  allowing two Core instances to run at once
* Replace deprecated QLatin1Literal with QLatin1String
* qvariant_cast slot argument to ToxPk, rather than trying to convert variant
  to bytes directly which is invalid
* Fix "wait for both to come online" accidentally waiting for Bob twice
* Move all sleeps to QTRY_VERIFY_WITH_TIMEOUT to speed up test
* Update settings* -> settings& based on Core API change
* Update Mock to match API change of IBootstrapListGenerator
* Register metatype of ToxPk, uint32_t, Status::Status
* Correct Alice's spy looking for Bob's pk
2022-03-02 23:30:04 -08:00
sudden6
54e72aa73d
test: add test case for real world Core usage 2022-03-02 23:30:03 -08:00
Anthony Bilinski
aeb8a9aca1
refactor(bootstrap): Use std::shuffle instead of custom not fully random logic
Simplifies logic and naming.
2022-02-24 16:28:59 -08:00
Anthony Bilinski
1be5b99d17
feat(Settings): Add setting for hiding group join and leave system messages
Messages can become spammy is long lasting quiet groups, drowning out real user
messages
2022-02-20 17:32:23 -08:00
Anthony Bilinski
e5df648e1a
refactor(settings): Use IGroupSettings in GroupChatForm
Move interface signals from Settings to be declared by the interface itself
2022-02-20 17:32:23 -08:00
Anthony Bilinski
9ac44ee09c
fix(history): Replace invalid Tox ID saved in peers table with Tox public key
Due to an old bug that has since be fixed, old history dbs can contain both a
Tox ID version and Tox public key version of the same friend, and always
themselves. They could have n more duplicates if they've updated their nospam.

Tox ID is an invalid length to be stored in strongly typed ToxPk, and in
general having multiple entries belonging to the same user effectively violates
our UNIQUE constraint on public_key.

Introduced in 7168d2b858

Fix #6485
2022-02-20 14:27:33 -08:00
Anthony Bilinski
9cd9da4a53
fix(CI): Fix memory leak in core_test
Causes false positives when running tests with ASAN
2022-02-17 20:10:38 -08:00
Anthony Bilinski
a1ebf297d3
chore(cleanup): Minor cleanup to contact management test
* Fix compile error on macOS by marking GroupWidget::widgetIsVisible as
override
* Mark mock functions override for consistency
* Change QWARN to QVERIFY since logs will be missed in CI
* Uncomment add of offline and online friends in testSortByActivity
* Add out-of-line method definition to anchor vtable
2022-02-17 17:17:48 -08:00
bodwok
0a9e121811
test(FriendListManager): add contact management test 2022-02-17 13:20:58 -08:00
Anthony Bilinski
9cbf3c0874
refactor(ToxPk): Update unit test
Remove check for invalid ToxId, since short ToxIds aren't constructable.
2022-02-17 07:20:21 -08:00
Anthony Bilinski
557af80428
refactor(Paths): Remove Paths factory to enable copy construction
std::atomic disallows copy construction and the default constructor disables
the parameterized constructor.

Additionally the case where paths aren't writable isn't handled and would just
segfault in Settings previously, so no safety is lost.
2022-02-16 20:15:46 -08:00
Mick Sayson
257a19caaa feat(filesform): Add in progress transfers to files form
As part of #1532 it was identified that long running file transfers
could get lost deep in the chatlog. This could result in unexpected use
of bandwidth over time if users lose track of old/large transfers. This
commit updates the files form to show in progress file transfers and
offer a way to control them.

* FilesForm now works on ToxFiles instead of finished file paths
* FilesForm widgets have been replaced with an MV tree view with depth
  1. The existing QListWidget did not provide us the controls to render
  more complex items. The use of delegates allows us to efficiently draw
  progress bars and controls
* getHumanReadableSize has been extracted from FileTransferWidget into a
  more general utils file
2021-12-11 15:38:35 -08:00
Mick Sayson
c7efe320d2 refactor(filetransfer): Move file transfer progress into ToxFile
* Refactor/test ToxFileProgress to ensure that when it's moved it
  behaves well
* Notice problems with speed averaging. We were average speeds without
  keeping track of the times they were over. Adding samples of different
  lengths would result in incorrect speeds. Refactor whole class to correct
* Move ToxFileProgress to be a member of ToxFile
* Remove duplicated members between ToxFile and ToxFileProgress
* Move sample addition into CoreFile
2021-12-11 15:38:35 -08:00
Anthony Bilinski
54a2b8970b
chore(review): Copyright notice cleanup 2021-11-21 16:19:22 -08:00