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

131 Commits

Author SHA1 Message Date
Anthony Bilinski
8abd4e47e9
refactor(style): use #pragma once rather than include guards 2020-05-03 15:51:52 -07:00
Anthony Bilinski
c748b5a8d0
Merge branch 'v1.17-dev' 2020-04-24 18:35:00 -07:00
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
Anthony Bilinski
6e2ac12d84
fix(avatar): reject avatars that are larger than 64KB
This will prevent qTox from auto-accepting arbitrarily large avatars. Avatars
are already limited by TCS 2.2.4 to 64KB, so we would only receive larger
avatars from badly behaving clients.
2020-04-10 15:32:35 -07:00
Anthony Bilinski
ef8c2b7cb3
Merge branch 'v1.17-dev' 2020-03-28 01:43:40 -07:00
Anthony Bilinski
ad042b09e0
chore(cleanup): don't add semicolon to Q_DECLARE_METATYPE
It is uneeded and prevents enabling of warnings for uneeded semicolons after
classes or namespaces

Fix #6007
2020-03-23 18:21:14 -07:00
Anthony Bilinski
2b981d88a2
fix(interface): use virtual destructors for all interfaces
Avoids memory leak if derived classes are deleted through interface pointer.

Fix #6006
2020-03-22 01:59:24 -07:00
Anthony Bilinski
2c1a86482a
chore(style): remove old style casts and cross sign comparisons
Enable warnings for both. Favour casting to signed rather than casting to
unsigend for comparisons. Per isocpp's core guidelines ES.102, signed
arithmetic gives more expected results. If we need one extra bit of range,
using longer signed types achives that.

Fix #6010
Fix #6012
2020-03-21 20:29:10 -07:00
Anthony Bilinski
c906cdf57b
fix(history): check history settings when getting initial chatlog idx
Checking if history pointer is valid is not sufficient, the setting must also
be checked. This caused asserts in history when history was disabled in
settings.
2020-03-21 01:45:46 -07:00
Anthony Bilinski
3a5e28fffb
fix(model): take QObject receiver argument to interface signal connection macro
receiver QObject is used by Qt to automatically deregister the connection when
the receiver is destroyed. Forward it on to Qt's connect.

(cherry picked from commit 24e4ec3751)
2020-03-20 02:07:20 -07:00
Anthony Bilinski
b7062b2518
fix(model): stop interfaces from inheriting from QObject
Qt doesn't support QObject multiple inheritance, so use our existing interface
macros to declare signals in the interface without QObject, and implement them
in child classes.

(cherry picked from commit 82a4f1b412)
2020-03-20 02:07:20 -07:00
Anthony Bilinski
40e43586f1
fix(model): return connection from interface macro
connection is normally returned from Qt's connect, and the caller may want to
track the connection to manually disconnect it.

(cherry picked from commit 41b2b35ce3)
2020-03-20 02:07:19 -07: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
Anthony Bilinski
24e4ec3751
fix(model): take QObject receiver argument to interface signal connection macro
receiver QObject is used by Qt to automatically deregister the connection when
the receiver is destroyed. Forward it on to Qt's connect.
2020-02-06 16:48:56 -08:00
Anthony Bilinski
82a4f1b412
fix(model): stop interfaces from inheriting from QObject
Qt doesn't support QObject multiple inheritance, so use our existing interface
macros to declare signals in the interface without QObject, and implement them
in child classes.
2020-02-06 16:48:56 -08:00
Anthony Bilinski
41b2b35ce3
fix(model): return connection from interface macro
connection is normally returned from Qt's connect, and the caller may want to
track the connection to manually disconnect it.
2020-02-06 16:48:56 -08:00
Anthony Bilinski
f252816f55
Merge branch 'v1.17-dev' 2019-12-02 08:46:04 -08:00
Anthony Bilinski
479b39f536
fix(offlingmsg): only dipatch offline messages on friend online change
Before if the new status was online, we would dipsatch, which could cause
double sends in the case of a friend going from e.g. busy -> away
2019-11-25 20:52:06 -08:00
Anthony Bilinski
239dfdc65c
refactor(status): move isOnline into Status from Friend
Allows checking if a status if equivalent to Online without needing a Friend
class.
2019-11-25 20:52:06 -08:00
Anthony Bilinski
f7d82a425d
Merge branch 'v1.17-dev' 2019-10-21 23:49:36 -07:00
Anthony Bilinski
1a726b54cd
fix(history): display broken messages UI with error icon
Allows users to still see their broken messages in the chatlog, but in a way
that's clear that they haven't been delivered and won't be sent.
2019-10-20 02:34:48 -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
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
1ad561ca4c
refactor(style): use only one of override, virtual, or final
following https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-override

virtual means exactly and only "this is a new virtual function."
override means exactly and only "this is a non-final overrider."
final means exactly and only "this is a final overrider."

Nothing was changed from e.g. override to final, just reduced duplication of
these labels.
2019-10-19 12:26:50 -07:00
Mick Sayson
4b691f9392 fix(chatlog): Remove invalid usages of raw chatlog indexes
ChatLogIdx is a strong type where the underlying data is only supposed
to be used in very rare circumstances. The ChatLog providing the indexes
provides no guarantees about what the first ChatLogIdx or last
ChatLogIdx will be. This commit removes unnecessary casts to underlying
data and fixes assumptions made about the underlying data
2019-09-21 14:26:14 -07:00
TriKriSta
dbf880078e
feat: save selected search text after scrolling up 2019-08-28 14:26:08 -07:00
TriKriSta
acb91ed731
fix: data validation during the search (fix: #5791, #5723) 2019-08-28 14:25:57 -07:00
sudden6
834baff556
Merge pull request #5793
TriKriSta (5):
      fix: data validation during the search (fix: #5791, #5723)
      feat: check chat status before start a search
      feat: save selected search text after scrolling up
      refactor: optimize load messages during the search
      fix: update workerStb
2019-08-28 21:13:38 +02:00
sudden6
db802822f3
fix: empty username causes mention on ever message
This fixes #2119 and additionally introduces the possibility to mention
users by their public key.
2019-08-26 23:22:17 -07:00
sudden6
641fba3553
fix: empty username causes mention on ever message
This fixes #2119 and additionally introduces the possibility to mention
users by their public key.
2019-08-26 19:08:34 +02:00
TriKriSta
a6a0481ddc feat: save selected search text after scrolling up 2019-08-22 15:11:18 +03:00
TriKriSta
e3c35c9153 fix: data validation during the search (fix: #5791, #5723) 2019-08-21 15:26:18 +03:00
TriKriSta
5aeac56b76 feat: prohibition to remove messages in group chat 2019-07-22 21:16:26 +03:00
TriKriSta
0a9e72020e refactor: edit load history when scrolling 2019-07-22 21:16:26 +03:00
TriKriSta
b807998fe9 refactor: simple edit code 2019-07-22 21:16:26 +03:00
TriKriSta
2a9648d12c feat: add action "Go to current date" 2019-07-22 21:16:26 +03:00
bodwok
77d55d5d7d
fix(search): application crash when starting a search 2019-07-02 12:29:00 +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
jenli669
72b39adb75
refactor(startup): clang-format changes to edited files 2019-06-25 10:18:22 +02:00
jenli669
a7df4bfddb
refactor(startup): display last used profile when logging out 2019-06-25 10:17:14 +02: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
Mick Sayson
71f8220925 refactor(chatlog): Add class to manage underlying chatlog state 2019-06-21 11:01:35 -07:00
Mick Sayson
c779d52aef refactor(messages): Replace QRegExp with QRegularExpression 2019-06-21 11:01:10 -07:00
Mick Sayson
fef89d70f9 fix(messages): Fix broken sanitized name for notifications/alert messages
* Note that this fix will not take effect until the message processor is
hooked up to widget and chatform
2019-06-21 11:01:10 -07:00
Mick Sayson
f0d840002a refactor(messages): Create class to manage sending/receiving group messages from core 2019-06-21 11:01:10 -07:00
Mick Sayson
3fd4ce5952 refactor(core): Remove length parameter from splitMessages
* From the archeology I managed, MAX_GROUP_MESSAGE_LEN was a workaround
for an old toxcore bug. Testing removal of this parameter and replacing it
with tox_max_message_length() seems to work fine.
2019-06-21 11:01:10 -07:00
Mick Sayson
22a4c38bfd refactor(messages): Create class to manage sending/receiving friend messages from core 2019-06-21 11:01:10 -07:00