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

4273 Commits

Author SHA1 Message Date
Anthony Bilinski
2197bce610
fix(AppManager): Don't create temporary copy of argc
QApplication takes argc by reference, so copying it in to AppManager's
constructor causes QApplication's to have an invalid reference once AppManager's
constructor returns.

Instead just reference main's argc.

Fix #6641
2022-06-14 16:24:09 -07:00
Anthony Bilinski
b394f22599
refactor(Nexus): Remove singleton, construct with needed arguments 2022-06-07 19:53:03 -07:00
Anthony Bilinski
0e7da7378f
refactor(Nexus): Remove static getCameraSource
On path towards removing Nexus singleton.
2022-06-07 19:52:47 -07:00
Anthony Bilinski
d4421c7161
chore(Qt): Replace QGuiApplication usage with QApplication
QGuiApplication is for QML projects, QApplication is for Qt Widget projects.

We use QApplication everywhere else, so use here too.
2022-05-30 14:01:56 -07:00
Anthony Bilinski
665a6c4e3d
refactor(Nexus): Remove Nexus::getDesktopGUI
Remove ProfileImporter's dependence on Widget, on path towards removing
Nexus singleton.
2022-05-26 18:04:01 -07:00
Anthony Bilinski
d2fe222b89
refactor(core): Remove unused Core::getKeyPair 2022-05-26 13:26:41 -07:00
Anthony Bilinski
7c519c3895
refactor(main): Move main global state into new AppManager class
main() couldn't hold its own state since cleanup() needed access to it.
Having the state in a class allows QApplication::aboutToQuit to call
into a member function with access to the state.

Data used in logging still needs to be global due to
qInstallMessageHandler not accepting a void* to get back to this.

Set QGuiApplication attributes before constructing Qapplication as required,
by using comma operator to call an initialization function before construction
all members in the member initializer list.

Keep logic largely unchanged, but with a defined destruction order.

Destruction is still abnormal due to QApplication::aboutToQuit forcing
us to do partial cleanup before QApplication returns, since some OSes
will kill qTox before the QApplication returns.
2022-05-24 13:26:48 -07:00
Anthony Bilinski
fd930cfbb2
refactor(History): Split remove history query into transaction 2022-05-24 12:27:16 -07:00
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
69d07f077e
refactor(history): Expose mergeDuplicatePeers from DbUpgrader
To be used by both dbSchema8to9 and dbTo11.
2022-05-22 11:15:59 -07:00
Anthony Bilinski
f29570138f
fix(history): Strictly check public_key during database upgrade
Text comparisons in SQL are not case sensitive. Since we want to use this check
to specifically check for case mismatch, cast to blob which then does an exact
comparison.
2022-05-22 11:15:55 -07:00
Anthony Bilinski
40b339b367
refactor(IPC): Remove activate's handler reliance on global state
Register in Widget's constructor so that handler can always get back to
Widget.

Add unregistration functionality so that the handler doesn't run when
we've returned to the login window or when exiting.
2022-05-21 17:18:07 -07:00
Anthony Bilinski
f4e64ee7a6
feat(History): Add a GUI error on database schema mismatch
Fix #5683
2022-05-20 11:38:12 -07:00
bodwok
039f6ff0b3
fix(Widget): Incorrect removing of contacts 2022-05-14 10:21:47 -07:00
bodwok
1545945236
fix(contacts): window with multiple friends contacts 2022-05-08 04:06:16 -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
f1b401166a
feat(CI): Disallow implicit casting of QByteArray to char* or void*
QByteArray usually holds arbitrary binary data, which can have null
characters or invalid characters when converted to ASCII or UTF8.
Disallow implicit casting for safety, forcing an explicit decision if
the conversion is wanted.
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
Anthony Bilinski
a3517d4291
refactor(Nexus): Remove all uses of getProfile in child classes
Pass Profile to where it's needed to move away from requiring singleton Nexus.

Keep non-static getProfile for use by by main.
2022-04-04 00:39:12 -07:00
Anthony Bilinski
6c6620ffc1
refactor(Settings): Save loaded profile automatically
It's invalid to save a different profile than was loaded, so no need to
require the profile to be passed in again on save.

Removes dependence on Nexus singleton for Nexus::getProfile.
2022-04-04 00:38:57 -07:00
Anthony Bilinski
a1f7c71feb
perf(Settings): Make personal settings saving consistently async
The function is documented as async, but is only async when called from
a different thread. Save is called from within Settings, it looks like
only from public functions that would be called on other threads, but
make it async regardless of calling thread for consistency.

There is already a sync function that is used, so safety is not lost.
2022-04-04 00:38:57 -07:00
Anthony Bilinski
4f45f30ef9
fix(history): Fix alias removal SQL query after group history addition 2022-04-03 20:39:01 -07:00
Anthony Bilinski
c5fdb78676
fix(UI): Centre message boxes on main window
Setting the parent of MessageBoxManager to Widget has a dual effect of
centreing the QMessageBox's on Widget' window which we want, but also
giving ownership of MessageBoxManager to Widget, which causes Widget to
destroy it in Widget's destructor. Since the original MessageBoxManager
must outlive Widget to be used in Settings and when loading Profiles
before Widget is constructed, we don't want Widget to destroy it.

Instead of juggling MessageBoxManager's parent around dynamically when
Nexus changes the active Window, just construct a second one in Widget
to be used by all its children with the parent set on Widget, centreing
the window and allowing it to have ownership.

Settings and Profile still use the original parent-less
MessageBoxManager since they show popups before Widget is constructed.
2022-04-03 18:31:33 -07:00
Anthony Bilinski
25223119c9
fix(chatlog): Display correct system message timestamp in chatlog 2022-04-03 17:27:18 -07:00
bodwok
a1b08d6493
fix(FriendList): exclusion of possible undefined behavior 2022-04-03 11:03:48 +03:00
Anthony Bilinski
0352ada08c
feat(history): Enable group history
Fix #5452
2022-03-30 19:45:06 -07:00
Anthony Bilinski
cd3c7b392e
feat(UI): Add UI for removing group history 2022-03-30 19:45:06 -07:00
Anthony Bilinski
1142cc03f8
feat(history): Remove group history on quit when selected
The same user may have sent a message both in the group and 1:1, so
generically remove aliases that have no associated messages, rather than
aliases that were used in the group.

Similarly, generically remove authors that have no associated aliases.

The group itself is a chat so will be removed through existing query.
2022-03-30 19:40:22 -07:00
Anthony Bilinski
1ac7285c79
refactor(widget): Make RemoveFriendDialog generic for Chats 2022-03-30 19:27:57 -07:00
Anthony Bilinski
de09bf655e
refactor(history): Use abstract Chat in ChatHistory rather than Friend
ChatHistory will be used by Groups for their history as well.
2022-03-30 19:27:57 -07:00
Anthony Bilinski
b320397558
refactor(model): Add getDisplayedName(ToxPk) to Chat
To allow resolving the author's name in a group through Chat
2022-03-30 19:26:06 -07:00
Anthony Bilinski
e4fefccff8
refactor(history): Move History APIs from Friend-based to Chat-based
Makes it more clear when we're talking about an author (ToxPK) or a chat
(Chat). Prepares for group chat history which will use the same APIs.
2022-03-30 19:26:06 -07:00
Anthony Bilinski
cfe18f8340
refactor(ContactId): Add clone function to ChatId interface
So that History can load history messages without needing to know
what type of Chat the messages are from.
2022-03-30 19:26:05 -07:00
Anthony Bilinski
71c3f997b4
refactor: Move FriendList global state into class 2022-03-30 19:04:11 -07:00
Anthony Bilinski
4a74b51bbc
refactor(main): Remove unused sodium_init
Was used by auto-updater which was removed in 7475ba4689
2022-03-30 06:04:57 -07:00
Anthony Bilinski
ffbff0bfa8
refactor: Remove ContentDialogManager singleton
Remove some more global state.
2022-03-30 02:08:32 -07:00
Anthony Bilinski
7565f8b350
fix(main): Construct ToxSave event handler
Bug introduced in 0c967725df, when the class
was added but never constructed.
2022-03-30 00:18:26 -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
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
47ee51c61d
fix(history): Don't cast file_id to QString before inserting
The implicit cast in addNewFileMessage's argument causes a conversion from the
binary data of file_id to be interpreted as UTF8 characters. On null bytes or
invalid UTF8, the resulting QString can be empty or truncated. Empty IDs causes
null file_restart_id's to be inserted into the database.

Fixes the cause of #6553, but the database damage still needs to be healed.
2022-03-25 16:47:52 -07:00
Anthony Bilinski
c6ee8d0654
refactor(Nexus): Remove Nexus::getCore
It relies on singleton state, instead just pass core to classes that need it.
2022-03-25 15:14:06 -07:00
Anthony Bilinski
2d6cc25405
fix(History): Correct SQL query for empty finished file transfer
"finished" is not a field in file_transfers. Bug has been present since
initially introduced in d9b39b3102.

Had no real effect since file transfers are inserted with initial state
CANCELLED, which is usually the case for a 0-length finished file, but
it still logged an SQL error.
2022-03-24 15:51:10 -07:00
Anthony Bilinski
270286b38c
refactor(audio): Move getVolume and volumeAvailable to qreal from float
Reduces casting back and forth between types.
2022-03-24 04:19:41 -07:00
Anthony Bilinski
27f19ec2fa
fix(History): Deep copy QByteArrays from SQL selects
We already deep copy all other data types. Especially with Qt types like
QByteArray, having a deep copy to start is important since it shallow
copies on any subsequent copy, so the callback provider only gets a
shallow copy in the QByteArray of the temporary data from SQLite.
2022-03-24 03:09:12 -07:00
Anthony Bilinski
efc641efd7
feat(Settings): Add GUI notice for global settings upgrade failure
Due to new MessageBoxManager, Settings now has the ability to show errors
during init.
2022-03-24 02:14:21 -07:00
Anthony Bilinski
b24faabf42
refactor(GUI): Move remaining messsage box functionality to new class
* Pass MessageBoxManager instantiation around instead of relying on a singleton
* Mock MessageBoxManager for unit tests when needed, since they don't have a
  QApplication which is required for creating QWidgets
* Remove GUI class, which didn't have a clear purpose
2022-03-24 02:14:20 -07:00
Anthony Bilinski
3bd85452da
refactor(GUI): Remove GUI::getMainWidget
It was just dispatching to Nexus::getDesktopGUI - call it directly instead,
for now.
2022-03-24 02:14:20 -07:00
Anthony Bilinski
b57e6c6fc4
refactor(GUI): Remove GUI setWindowTitle
Widget is the only caller, let it set its own title. Wrap inherited setTitle to
prepend "qTox". Check for thread is not needed since it is only called
from Widget's slots.
2022-03-24 02:14:20 -07:00
Anthony Bilinski
94d0f29603
refactor(GUI): Remove GUI::themeReload, give responsibility to Style
Style already has themeChanged, which was unused. GUI's themeReload just
dispatches to Style, which is already piped to GUI classes. Give the signal
to Style itself so that classes can connect to that, rather than relying on
GUI's singleton.
2022-03-24 02:14:20 -07:00