66 Commits

Author SHA1 Message Date
Linus Jahn
55a9776d2e Merge branch 'Kaidan/0.8' 2021-05-27 22:54:44 +02:00
Melvin Keskin
5374c441e5 MessageModel: Fix message notifications 2021-05-27 22:53:06 +02:00
Melvin Keskin
ca6fe2edd5
Rename 'Message::sentByMe()' to 'Message::isOwn()'
This should help to understand what is meant.
2021-04-30 19:22:05 +02:00
Melvin Keskin
a10ec3a3bc Rename 'DB_MSG_QUERY_LIMIT' to 'DB_QUERY_LIMIT_MESSAGES'
This is done in preparation for the upcoming group chat implementation which introduces a limit for group chat users.
2021-04-27 14:39:57 +00:00
Linus Jahn
2c039e8732 ChatPage: Add loading indicator for MAM backlog 2021-04-20 19:44:34 +02:00
Linus Jahn
e014517b54 Implement XEP-0313: Message Archive Management
Co-authored-by: Jonah Brüchert <jbb@kaidan.im>
2021-04-20 17:39:31 +02:00
Linus Jahn
f9f88cdb6c Introduce MessageOrigin for more simplicity and upcoming MAM 2021-04-19 01:11:39 +02:00
Linus Jahn
45182a7991 Prepare MessageModel & MessageDb for deduplication
New messages are now going through the following steps:
1. MessageModel::addMessageRequested() needs to be emitted
2. MessageDb::addMessage(): Deduplication is run (follows in one of the
   next commits)
3. MessageDb::messageAdded() is emitted
4. MessageModel::addMessage()
2021-04-18 11:56:09 +00:00
Linus Jahn
5494f165bf Replace MsgModel::updateMessageInDb with MsgDb::updateMessageRequested 2021-04-18 01:43:33 +02:00
Linus Jahn
bdf6b15f95 Replace setDeliveryState() calls by direct updateMessage() calls 2021-04-18 01:42:28 +02:00
Melvin Keskin
53135d81f9
Send message notifications in the MessageModel
Moves the message notification sending from the MessageHandler to the
MessageModel. Sending notifications is generally a GUI task (not XMPP
backend) and is also problematic there because it should be done after
message deduplication.
2021-04-18 00:22:06 +02:00
Melvin Keskin
7a79632184 Prepare for multi-account support 2021-04-17 21:15:02 +00:00
Jonah Brüchert
29e9eda43c Implement chat state notifications 2021-03-31 12:26:10 +02:00
Melvin Keskin
9a83d52952 Use instance getters for Message/RosterDb
The getters in the Kaidan class are unused now and can finally be
removed.
2021-03-30 23:13:21 +02:00
Melvin Keskin
24cb1ef92f Use RosterModel and MessageModel as singletons 2021-03-20 18:55:05 +00:00
Linus Jahn
88a6e366ae Restructure QML to XMPP Thread communication
Before this everything from QML that wanted to communicate with the XMPP
thread and the XMPP managers needed to use signals in Kaidan.h. The new
concept makes it possible to access the XMPP Managers directly although
you still need to use signals in order to communicate with the different
threads.
2021-02-02 23:42:19 +00:00
Melvin Keskin
c7867ed7e4 Update copyright year to 2021 2021-01-02 07:30:06 +00:00
Melvin Keskin
947ef32654 Make the AccountManager a singleton to avoid duplicated getters
This removes the duplicated jid/password/etc. getters from the Kaidan
class.
2020-12-23 21:45:45 +01:00
Melvin Keskin
cf10a599a4 Clean up includes and class declarations 2020-09-20 15:16:15 +02:00
Linus Jahn
775b4b183a Use default message ID lengths
From QXmpp 1.3 this will automatically use UUIDs this way.
2020-09-15 21:23:29 +02:00
Melvin Keskin
45723aa48d
Use 'm_' as a prefix for member variables consistently 2020-09-05 14:54:51 +02:00
Melvin Keskin
b6b9b3def0
Use 'Kaidan::instance()' instead of 'kaidan' 2020-09-05 13:22:24 +02:00
Yury Gubich
2397aeb480 Make pending messages correctable
The message ID in the database describes the ID of the latest message
correction now (instead of the ID of original message). There's a new
column in the Messages table now for storing the 'replaceId', the ID of
the original message.

Little GUI change: Unavailable options in the message context menu are
invisible instead of being disabled.
2020-07-29 16:28:53 +02:00
Yury Gubich
dd3b5c0f87
Allow to correct multiple messages
This changes the way MessageModel concludes whether the message is
suitable for correction. A message can be corrected, if:
 * it is `sentByMe()`
 * is amog the latest 20 messages sent by us
 * is not older than 2 days

Also instead of searching the message with the correct ID, the function
now uses the index from QML instead.
2020-07-27 21:51:31 +02:00
Jonah Brüchert
edd7521643
Refactor Kaidan.{cpp,h}
The changes in other files than Kaidan.cpp and Kaidan.h are just fallout from renaming some functions in the api of the Kaidan class.
2020-06-29 01:29:03 +02:00
Melvin Keskin
5aee0f9858
Improve notifications
* Add actions for opening chat and marking messages as read
* Do not notify for new messages when sender is muted or chat with sender is already opened

Co-authored-by: Jonah Brüchert <jbb.prv@gmx.de>
Co-authored-by: caca hueto <cacahueto@olomono.de>
Co-authored-by: Linus Jahn <lnj@kaidan.im>
2020-06-29 01:08:26 +02:00
Melvin Keskin
88dc645d95
Rename 'chatPartner' to 'currentChatJid' 2020-06-29 01:06:17 +02:00
Melvin Keskin
06f9870795
MessageModel: Use attribute instead of getter 2020-06-29 01:06:17 +02:00
Yury Gubich
17c621f6b6
Add offline message queue and adv. delivery states
Writing messages in the database while offline, sending pending messages
from the database on connect

This also adds new icons for the different delivery states.
2020-04-11 09:34:50 +02:00
Jonah Brüchert
2e36f9fa08
MessageModel: Truncate messages to 10k characters
Fixes #350.

Signed-off-by: Linus Jahn <lnj@kaidan.im>
2020-02-01 12:29:21 +01:00
Linus Jahn
31713c9f5e Bump copyright year to 2020 2020-01-06 19:47:58 +01:00
Yury Gubich
9f10d0580a
Add message search
Co-authored-by: Melvin Keskin <melvo@olomono.de>
2019-12-03 20:25:09 +01:00
Filipe Azevedo
6d3d9828e4
Refactor media previews
Both send media sheet and chat message now share preview code.

Task-Id: #287
Signed-off-by: Linus Jahn <lnj@kaidan.im>
2019-11-26 15:24:08 +01:00
Linus Jahn
d67cfb3cae
Fix some clazy warnings 2019-07-07 14:28:45 +02:00
Linus Jahn
df891fd810 chatpage: Fix avatar bug 2019-06-27 12:37:55 +02:00
Linus Jahn
e8750bad7a
Rewrite database models to not block the GUI
This rewrites parts of the main database class. All classes working on
the database have been moved to the new database thread, so inserting
records into the database isn't blocking the user interface anymore.
What also improved the performance *massively* is the use of SQLite
transactions, when inserting multiple records. So inserting is so fast
now that it actually wouldn't necessarily require another thread, but
with this we're safe in the future.

The message model and the roster model have been splitted up into a
database manager and the list model that is used to present cached data
to the user. The XMPP managers are connected to both the model and the
db classes, so both are updated in parallel.

There are also two new classes for the RosterItem and the Message,
because we need to cache those in the models in a vector. The Message
class inherits from QXmppMessage, so we can now use the same class for
sending messages and inserting messages into the database.

Closes #273.
2019-06-26 21:58:50 +02:00
Linus Jahn
9f197a1497 Fix recognition of media messages and download inside of spoilers 2019-04-18 12:43:42 +01:00
Linus Jahn
0beb640bec Last Message Correction: Follow new guidelines for multiple edits
There are upcoming changes of the expected behaviour when correcting a
message multiple times. The old way was to correct the last correction,
the new way is to always correct the original id.

See https://github.com/xsf/xeps/pull/764
2019-04-18 11:48:17 +01:00
Linus Jahn
30db3ee139 Fix message editing bugs
There were three edge cases:
1) The wrong message was replaced:
   - You send a message
   - You open the edit menu
   - Contact or another device of you sends a message
     (lastMessageId is updated)
   - You finish your edit and a message is sent to replace your contacts
     message, which is obviously not what we want. Database and XMPP
     both get the wrong message id to replace.
2) Can't edit last message:
   - You send a message
   - Contact sends a message
     (lastMessageId is updated)
   - You can't edit your last message, although that is expected to work.

The solution was to only update the lastMessageId for own messages.

Also the QML code has been slightly beautified by the use of a signal.
2019-04-17 18:11:02 +01:00
Xavier
87447c897f Implement XEP-0382: Spoiler messages
Spoiler messages are used to hide messages containing NSFW content / very long
messages / secret content by default. Kaidan can now send & receive those messages.
A context action on the chat page has been added for this purpose.

Details about the XEP:
https://xmpp.org/extensions/xep-0382.html
2019-04-02 19:28:00 +02:00
Linus Jahn
4da78fbc3d Implement XEP-0308: Last Message Correction (back-end) 2019-02-05 17:31:10 +00:00
Linus Jahn
8ed3a2a0e4
copyright: 🎉 Welcome 2019! 2019-01-22 21:08:37 +01:00
Linus Jahn
f6e523f405
media-sharing: Recognize specific media type instead 2018-12-04 15:42:36 +01:00
LNJ
f2c0bbe5aa
media-sharing: Display upload preview, display images in chat 2018-11-24 14:33:50 +01:00
Linus Jahn
482f06bad3
Fix MessageModel and improve database access
It now uses the correct way to modify the database instead of doing
strange things with the SQL database and not updating the displayed
cache.
2018-11-24 14:33:48 +01:00
LNJ
007ba433f9
media-sharing: Save media hashes in database
All media hashes are now saved in the messages table. They are saved just in the
XML format of 'XEP-0300: Use of Cryptographic Hash Functions in XMPP'.

This also adds a mediaThumb column to the messages table.
2018-09-15 16:01:42 +02:00
LNJ
975f4c3123
UploadHandler: Save media information in database
With this local file paths, content types, sizes of file uploads are saved in
the database.

The database has some new columns for the media information and the version has
been increased to 6.

This also contains some clean ups and minor improvements of the code.
2018-09-15 16:01:41 +02:00
LNJ
72457cd526
database: Add message types and mediaUrl; Clean up
This introduces different message types (text, image, video, audio, document,
file). They should be used to determine the correct message element in the UI.

Also, there is a new mediaUrl in the Messages table which will be used to
save the HTTP urls to download the media shares.

The database version is increased to 5.
2018-09-15 16:01:40 +02:00
LNJ
b3b72117e4 MessageHandler: Fix timezone bug of timestamps, Clean up
Finally got fixed! :)

Fixes #159.
2018-05-15 17:45:03 +02:00
LNJ
bc071e8c97
Fix lag when changing chat (#205)
This also does some clean up and restructuring of the deployment of the
`chatPartner` property to the ClientThread (MessageHandler) and MessageModel.

Before, a thread-safe function of the ClientThread was used, so the mutex of it
blocked the GUI, when the client thread was busy in this moment.
2018-03-02 20:46:34 +01:00