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

59 Commits

Author SHA1 Message Date
iphydf
e71225268f
chore: Various code cleanups.
* Reorder class data members and/or constructor initialisers to match,
  reducing confusion about when members will be initialised.
* Remove (most) unused variables. Not removed: some global variables with
  `TODO(sudden6)` on them for using them in the future. I don't know how
  far into the future sudden6 wants to use them, so I left them there for
  now.
* Distinguish different bootstrap nodes in the logs by index in the
  bootstrap node list. Originally, we used to log the address/port of the
  node we're bootstrapping to. This was removed out of privacy concerns
  (even though the bootstrap nodes are public). This made the logs much
  less useful when debugging why the client isn't connecting. Having
  indices makes it easier to see that different nodes are being selected,
  and makes it possible to determine which node was selected.
* Explicitly cast unused results of Tox API functions to `void` when all
  we want is to know whether the function succeeds or not.
* Don't try to `#include <unistd.h>` on Windows. It does not exist on
  MSVC.
* Remove extra `;` after function definitions.
* Remove reference indirection of QJsonValueRef, since a copy of that ref
  (small pointer-like object) has to be made anyway when iterating over
  QJsonArrays.
* Make some file-scope global state `static`.
* Use `nullptr` instead of `NULL`.
* Add `#if DESKTOP_NOTIFICATIONS` around the code that implements desktop
  notifications, so it becomes a bit easier to compile everything with a
  single compiler command - useful for manually running static analysers.
* Fix an error on MSVC where `disconnect` is looked up to be a non-static
  member function and the `this` capture is missing.
* Consistently use `struct` and `class` tags for types.
* Use references in ranged-for where it reduces copies.
* Move private static data members out of the Style class and into
  file-local scope. There is no need for them to be in the class. Also
  marked them `const` where possible.
* Removed unused lambda capture.
* Ensure qTox can compile under NDEBUG with `-Wunused-variable` by
  inlining the unused variable into the `assert` that was its only
  target.
* Minor reformatting in core_test.cpp.
2020-04-16 19:07:40 +00:00
Jimi Huotari
6d51971c6f refactor(Qt): fix build with Qt 5.15
This fixes compile-time warnings about deprecated functions when
building with Qt 5.15.
2020-03-17 13:31:36 +02:00
Mick Sayson
e3e6e1d9c4
fix(history): Prevent invalid history access
* When the DB schema was too new we were accessing history anyways. This
has potential to just completely corrupt the DB
* When history was disabled there was a chance we would attempt to write
to history anyways. Added more checks in this area
* Chatform was accessing invalid iterators when there were no displayed
messages. Added a guard for this case
2019-12-02 03:04:53 -08:00
Anthony Bilinski
edd72906fb
perf(history): enable sql index on chat_id in history table
This makes every query with a "WHERE history.chat_id" clause quicker,
improving history load time by 50% on my profile.

Related to #5812
2019-11-25 16:21:17 -08:00
Anthony Bilinski
17bbe24ec5
chore: log schema version when we error due to future db 2019-11-04 14:42:20 -08:00
Anthony Bilinski
746314baf2
fix(history): move stuck action messages to broken_messages table
Before a bug in qTox would make it possible for a user to try to send an empty
action type message. This would fail to send at toxcore, but still be persisted
in history, causing it to fail every time FauxOfflineEngine tried to resend
it. Moving these stuck messages into the broke_messages table will stop qTox
from attempting to deliver them on each connect, and display in the GUI to
users that the messages aren't really pending anymore.
2019-10-20 02:35:20 -07:00
Anthony Bilinski
527c7d2d3c
refactor(history): represent message state as enum class
ensures that only one state is set at a time, avoids managing multiple bools
2019-10-20 02:34:48 -07:00
Anthony Bilinski
f6a15366ef
fix(history): select broken messages from History, track in ChatLogMessage 2019-10-20 02:34:48 -07:00
Anthony Bilinski
cd75618e38
refactor(history): rename pending message variables
"Sent" to "Delivered", since that's what we're tracking also rename "isOffline"
to "isPending", which is boolean the same, but "isOffline" was opposite of its
correct value before, so boolean reverse the assignment.
2019-10-20 02:34:47 -07:00
Anthony Bilinski
b28dc30061
fix(history): move stuck pending message into broken_messages table
Fix #5776

Due to a long standing bug, faux offline message have been able to become stuck
going back years. Because of recent fixes to history loading, faux offline
messages will correctly all be sent on connection, but this causes an issue of
long stuck messages suddenly being delivered to a friend, out of context,
creating a confusing interaction. To work around this, this upgrade moves any
faux offline messages in a chat that are older than the last successfully
delivered message, indicating they were stuck, to a new table,
`broken_messages`, preventing them from ever being sent in the future.
2019-10-20 02:34:47 -07:00
Anthony Bilinski
f72f3f714d
fix(history): handle errors during db upgrade 2019-10-20 02:34:47 -07:00
Anthony Bilinski
dacfcdadac
refactor(history): apply db schema upgrade one version at a time
This allows upgrade steps to query the db at the last version and run C++ code
on the results, then do a single transaction to make the upgrade, instead of
all actions of each upgrade step being required to be part of the overall
upgrade transaction.
2019-10-20 02:34:47 -07:00
Mick Sayson
dbef0b7508
fix(offlinemsg): fix offline message dispatching on history load
* Fix callback hookup order in ChatHistory
* Add correct call to SessionChatLog to insert an unfinished message
* Fix incorrect logic in parsing History database response
2019-10-20 02:34:47 -07:00
Anthony Bilinski
64aa3eae4d
fix(history): select only pending history for the requested friend 2019-08-29 10:39:06 -07:00
TriKriSta
8c4b1e00a1 feat: edit load history in search 2019-07-22 21:16:26 +03:00
jenli669
04a9bc46f4
docs(copyright): update and add copyright info
zealously updates and adds qTox copyright information.

Fixes #5713
2019-06-28 01:18:26 +02:00
TriKriSta
b0f32379d0 fix: check time for get num messages for friend (fix #5714) 2019-06-25 20:44:21 +03:00
Mick Sayson
ed514d7166 refactor(chatform): Remove message handling logic from gui path
Functional changes
* Offline messages are still sent when the chat log is cleared
* Spinner now does not wait for history to be complete, just a receipt
  from our friend
* Export chat and load chat history are now available in group chats
* Merged save chat log and export chat log
  * Note that we lost the info messages in the process

NonFunctional Changes
* FileTransferWidget slots only called for correct file
* Settings::getEnableGroupChatsColor now embedded in
GenericChatForm::colorizeNames
  * Settings::setEnableGroupChatscolor now emits signal connected to
GenericChatForm::setColorizedNames to keep state in sync
* Chatlog history not reloaded on setPassword()
  * I am pretty sure this had no purpose
* Removed a lot of responsibility from ChatForm
  * History moved to ChatHistory implementation of IChatLog
  * OfflineMsgEngine moved to FriendMessageDispatcher
  * Export chat and load chat history moved to GenericChatLog
    * Backed by IChatLog so can be used generically
  * Message processing moved to FriendMessageDispatcher
  * The action of sending files to coreFile is still handled by
  ChatForm, but displaying of the sent messages is done through IChatLog
  -> GenericChatForm
  * Search moved to ChatHistory/SessionChatLog
  * All insertion of chat log elements should be handled by
  GenericChatForm now
* Removed overlapping responsibilities from GroupChatForm
  * Search and message sending goes through ichatlog/messagedispatcher
  too
  * Lots of search functionality pushed down into IChatLog
* Some of the file logic was moved into Widget. This is mostly to avoid
  scope increase of this PR even further.
* History APIs removed that were no longer used
2019-06-21 11:01:35 -07:00
Mick Sayson
e607e6ecb4 refactor(chatlog): Add a class to manage history through the IChatLog interface 2019-06-21 11:01:35 -07:00
Anthony Bilinski
316893ace9
test(db): add db schema upgrade test 2019-05-15 13:26:21 -07:00
Anthony Bilinski
c12605db6d
fix(history): create file_transfers table in upgrade
* bug introduced in refactor 329172321d
2019-05-09 00:19:46 -07:00
Anthony Bilinski
329172321d
refactor(history): create db as part of schema upgrade
* update user_version as part of transaction, so that we rollback if update fails and don't increment version
* differentiate between two user_version 0 versions, to avoid the SQL error on new profile creation
* make table creation dependent on user_version, instead of creating tables if not exists every start
2019-05-05 14:52:32 -07:00
Anthony Bilinski
edf6b67313
refactor(core): strong type message receipt and row ID
Avoid implicit casting and invalid arithmetic.
2019-01-28 10:58:54 -08:00
TriKriSta
c3095ab150 fix: check valid date in getDateWhereFindPhrase 2018-12-22 00:36:38 +02:00
Anthony Bilinski
84362244da
refactor(files): change ToxFile's fileName to QString 2018-12-14 00:33:27 -08:00
Mick Sayson
25005c5c19 feat(db): File transfer history review comments 2018-12-05 21:15:14 -08:00
Anthony Bilinski
8427be6678 feat(db): add file hash to file history
Not currently used, but there are plans to display if a transfered file
has been modified, which the file hash will be needed for. Adding file
hash at the same time as file history also saves a db schema update.
2018-12-02 14:40:54 -08:00
Mick Sayson
d9b39b3102 feat(db): Hookup file history to the rest of the system 2018-12-02 14:40:53 -08:00
Mick Sayson
567ddfb203 feat(db): Database support for file history 2018-12-02 14:35:18 -08:00
Mick Sayson
fb805b9cdb feat(db): Support schema version upgrades 2018-12-02 14:35:04 -08:00
Jakie.OYMJ
e6d40be72e fix: add remove history prompt, clear log area after remove 2018-10-05 10:24:39 +08:00
TriKriSta
b6ab0ec2ca refactor: add SearchDirection 2018-08-14 01:06:28 +03:00
TriKriSta
706822123f refactor: delete sqlite in travis, edit some functions 2018-07-14 00:58:35 +03:00
TriKriSta
ea8bbfd8a5 refactor: use const and QStringLiteral 2018-07-08 14:02:03 +03:00
TriKriSta
17a97f1ff6 feat: add function for generating a filter for search word only 2018-07-08 12:33:37 +03:00
TriKriSta
74468fde32 docs: add documentation for some new functions 2018-06-29 23:10:14 +03:00
TriKriSta
4fdf73f2f0 refactor: remove commented code, use QStringLiteral 2018-06-29 19:31:34 +03:00
TriKriSta
610e04aa26 feat: use search settings 2018-06-24 21:11:20 +03:00
Anthony Bilinski
ca32e77d74
feat(history): load set number of messages from history
Fix #3124
Fix #3004

Instead of loading a set 7 days of history. Better performance when there are lots of messages, and better context when friends haven't talked in over a week.

Removed historyBaselineDate, introduced in deb8440c6a to fix duplicate messages, but duplicate messages were very likely fixed by https://github.com/qTox/qTox/pull/4607.

Also refactored history loading.
2018-05-06 15:31:54 -07:00
Anthony Bilinski
5dc4e6de81
chore(legal): update copyright date to 2018 for all source files 2018-04-25 17:33:38 -07:00
Anthony Bilinski
b852809d0c
fix(history): don't save own messages when history is disabled
Fix #5036
2018-03-30 01:50:12 -07:00
TriKriSta
fe4dd83d10 refactor: add/delete checks in search code 2018-02-15 13:21:05 +02:00
TriKriSta
3e05279c09 fix: add search symbol ' in history 2018-02-14 11:30:38 +02:00
TriKriSta
18fa8a745b feat: optimise search in history 2018-02-12 01:02:28 +02:00
TriKriSta
de9c906117 feat: edit load history for search 2018-02-10 17:56:16 +02:00
tWido
3257770bfa feat(chatform): Highlight chat history
Calendar dates with chat history highlighted with bold
Fixes #2296
2017-06-25 21:23:04 +02:00
Diadlo
365d703e8a
perf: Pass std::function by reference 2017-06-12 13:46:38 +03:00
Zetok Zalbavar
80f5de31b3
style: reformat current C++ codebase using clang-format 2017-02-26 11:52:45 +00:00
sudden6
38cecdc780
refactor(history): remove deprecated historykeeper
This commit removes historykeeper and code only used by it.

BREAKING CHANGE:
qTox can't open old historykeeper chatlogs after this commit. Use
previous versions to migrate to the new database.
2017-02-05 22:20:12 +01:00
Zetok Zalbavar
7b60a5dd36
chore: explicitly mention that copyright belongs to qTox contributors 2016-11-29 11:12:06 +00:00