Compare commits

...

82 Commits

Author SHA1 Message Date
Tobias Fella
9ab8f796d8 Port away from remove things in libquotient
Mostly the User class and Omittable
2024-06-27 23:26:51 +02:00
Tobias Fella
2e0c074a9b Port away from Quotient::Omittable 2024-06-27 20:19:01 +02:00
Tobias Fella
fd8725f649 Add basic cross-signing support
(cherry picked from commit e1795076c8c41a34b91c31df35d1e344d0b14887)
2024-06-27 18:51:38 +02:00
Tobias Fella
3d433762b1 Fix ifs for ssss 2024-06-27 18:23:29 +02:00
Tobias Fella
ea4cb5bf62 Disable FreeBSD CI 2024-06-27 18:08:47 +02:00
Tobias Fella
a6ca3b8203 Require libQuotient 0.8.2 2024-06-27 18:08:28 +02:00
l10n daemon script
bc4ceb6d52 GIT_SILENT Sync po/docbooks with svn 2024-06-27 01:26:42 +00:00
l10n daemon script
24480229cd GIT_SILENT Sync po/docbooks with svn 2024-06-26 01:25:49 +00:00
l10n daemon script
8b10573197 GIT_SILENT Sync po/docbooks with svn 2024-06-25 01:23:09 +00:00
l10n daemon script
cbc81e8285 GIT_SILENT Sync po/docbooks with svn 2024-06-24 01:22:01 +00:00
Tobias Fella
0b9a978061 Update global menu 2024-06-23 21:09:33 +02:00
l10n daemon script
e974e5d13b GIT_SILENT Sync po/docbooks with svn 2024-06-23 01:25:25 +00:00
l10n daemon script
5a42e86bf6 GIT_SILENT Sync po/docbooks with svn 2024-06-22 01:29:39 +00:00
l10n daemon script
889946e186 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2024-06-22 01:19:19 +00:00
l10n daemon script
5c47e8044e GIT_SILENT made messages (after extraction) 2024-06-22 00:39:08 +00:00
l10n daemon script
1a974ac305 GIT_SILENT Sync po/docbooks with svn 2024-06-21 01:23:47 +00:00
Tobias Fella
db1bf61805 GlobalMenu: remove shortcut for QuickSwitcher
The shortcut needs to work when there is no Global Menu, so it's also in QuickSwitcher.qml.
It can't be in both places, since that breaks it. So we remove it here.

BUG: 488212
2024-06-20 18:14:36 +02:00
Tobias Fella
5456b4a7ff Fix global menu 2024-06-20 18:03:42 +02:00
l10n daemon script
a08ffaae77 GIT_SILENT Sync po/docbooks with svn 2024-06-20 01:27:52 +00:00
l10n daemon script
18445f55f0 GIT_SILENT Sync po/docbooks with svn 2024-06-19 01:24:36 +00:00
Albert Astals Cid
2daf3b5c4b CI: Disable requiring Windows tests passing
Has been broken for 4 consecutive weeks
2024-06-18 22:42:00 +02:00
l10n daemon script
923b844212 GIT_SILENT Sync po/docbooks with svn 2024-06-18 01:29:17 +00:00
James Lyne
0aec9f8472 Fix search results on room search page
Add missing IsEditable role to search model
2024-06-17 20:15:36 +00:00
l10n daemon script
23b0c8a143 GIT_SILENT Sync po/docbooks with svn 2024-06-17 01:25:34 +00:00
l10n daemon script
3c2c2e2bd8 GIT_SILENT Sync po/docbooks with svn 2024-06-16 01:24:54 +00:00
l10n daemon script
c1465a7368 GIT_SILENT Sync po/docbooks with svn 2024-06-14 01:22:57 +00:00
l10n daemon script
be1dadab74 GIT_SILENT Sync po/docbooks with svn 2024-06-13 01:23:33 +00:00
Derry Tutt
1cba39eae9 Update strings to be more clear for the average user 2024-06-12 19:37:39 +00:00
Tobias Fella
a0c8bdf021 Make notifications more useful
- Refactor and cleanup code
- Don't paginate through notifications - it spams the server with requests and realistically only contains anything relevant on startup after a long time, in which case you're going to lose some notification anyway
- Only show newest notification for the respective room, closing the old notification if one exists
- Only show text of this notification

BUG: 475228
2024-06-12 21:28:09 +02:00
l10n daemon script
6fdb22a5b5 GIT_SILENT Sync po/docbooks with svn 2024-06-12 01:26:41 +00:00
l10n daemon script
19c370a273 GIT_SILENT made messages (after extraction) 2024-06-12 00:38:48 +00:00
Tobias Fella
861336ea97 Remove unnecessary check 2024-06-11 21:48:56 +02:00
l10n daemon script
24219bcb03 GIT_SILENT Sync po/docbooks with svn 2024-06-11 01:29:06 +00:00
Tobias Fella
77ed762e2c Use plaintext for room aliases 2024-06-10 22:20:37 +02:00
l10n daemon script
d45b6cb03d GIT_SILENT Sync po/docbooks with svn 2024-06-10 01:35:39 +00:00
Heiko Becker
9a921b2e0d GIT_SILENT Update Appstream for new release
(cherry picked from commit c5c47d7b67)
2024-06-10 00:48:21 +02:00
l10n daemon script
c17e213e11 GIT_SILENT Sync po/docbooks with svn 2024-06-09 01:23:44 +00:00
Joshua Goins
6275d7afaa Switch from QQC2.ApplicationWindow.overlay to QQC2.Overlay.overlay
Closes #648
2024-06-08 11:47:30 -04:00
Joshua Goins
364eda6400 Fix keyboard navigation on search pages
Some of our search pages (such as the room and user search) has a list
header item. Due to how this works, it's not actually a part of the
list view keyboard navigation and a whole separate item. So in the tab
order, it comes *after* the list view which makes no sense. And it's
part of the list view, so users must expect it to be selectable with the
up and down arrows like other items.

This simple change makes it so it behaves as expected. The first actual
list item is selected by default, but it's possible to navigate to the
list header item via the up arrow key and then return to the list view
using the down arrow. The list header item is also removed from the tab
order and the whole page is much nicer to use now.
2024-06-08 15:44:38 +00:00
Joshua Goins
ccf34cfe20 The "Search Room" action should be called "Search Rooms" 2024-06-08 15:42:10 +00:00
Joshua Goins
7daae6a2d9 Fix the tooltips for the two drawer buttons at the top
One of them didn't even have a tooltip, which is a simple oversight
since it already has accessible text. The tooltips now use the attached
property instead of creating a new QQC2.ToolTip too.
2024-06-08 15:42:10 +00:00
Joshua Goins
277a4ad124 Fix keyboard navigation in space drawer
Some of the items were able to activated via the keyboard, but many were
not like the notifications and "create a space" buttons. This is because
the signals were hooked up to onClicked but the accessible and keyboard
nav were hooked up to onSelected. All of the buttons trigger their
actions with onSelected now.
2024-06-08 15:32:37 +00:00
Joshua Goins
b11d46e34a Add keyboard navigation for server selection in room search dialog
This was previously not keyboard navigable at all, making it
impossible to switch servers in this dialog solely with a keyboard. This
patch makes it possible to do some basic selection but not deletion yet,
but it's a good start.
2024-06-08 15:32:26 +00:00
Joshua Goins
e8ad0a055d Remove room member highlight on click
Previously it was possible to keep clicking and highlighting each member
which doesn't make any sense. We could make this exclusive by having it
highlight only when index == currentIndex, but honestly it doesn't need
to be highlighted at all. Clicking on a room member opens their user
card, there's no persistent state the user needs to keep track of here.
2024-06-08 11:25:49 -04:00
Joshua Goins
8a8c745d77 Use Qt.alpha in ThemeRadioButton
This was newly added in Qt6 and simplifies a Qt.rgba call we used here.
2024-06-08 14:35:09 +00:00
Joshua Goins
a523fe7674 Add focus border for the theme radio button, used on the Appearance page
Otherwise it's impossible to tell which option you're on, if you're
solely using a keyboard.
2024-06-08 14:35:09 +00:00
Joshua Goins
dc9a150929 Fix QR code not showing when tapping the button under account settings 2024-06-08 14:34:58 +00:00
Joshua Goins
be66ffef0f Fix map copyright link activation
The argument was missing, so it wasn't possible to actually click and
visit the copyright notices linked on maps.
2024-06-08 14:34:48 +00:00
Joshua Goins
f278cc0c86 Don't show the map if there's no locations available
It's hard to the read the text when there's a beige map behind it, and
unnecessary anyway.
2024-06-08 14:34:48 +00:00
Nicolas Fella
7f72808a9a Fixup AttachDialog
Use standard spacing values

Use implicit button size
2024-06-08 14:34:40 +00:00
Joshua Goins
1d5297c0f0 Rename the header for room actions "Actions" instead of "Options"
These aren't really configurable options in the usual sense, but rather
actions you can take in the room.
2024-06-08 14:34:21 +00:00
Joshua Goins
e40528ba45 Use a more natural sounding action name for favoriting the room
"Make room favorite" doesn't sound very natural in English, but
"Favorite this room" is and fits in with the rest of the actions here.
2024-06-08 14:34:21 +00:00
Tobias Fella
29972b5867 Port away from commitSingleShot 2024-06-08 15:43:16 +02:00
James Graham
91109ca845 Get 3PID binds on startup
Get binds on startup and update the staus properly after bind/unbinding 3PIDs
2024-06-08 08:42:34 +00:00
l10n daemon script
8e5ccb5461 GIT_SILENT Sync po/docbooks with svn 2024-06-08 01:27:06 +00:00
l10n daemon script
8a75967953 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2024-06-08 01:19:18 +00:00
l10n daemon script
3f4965b182 GIT_SILENT made messages (after extraction) 2024-06-08 00:39:04 +00:00
l10n daemon script
2ac266029c GIT_SILENT Sync po/docbooks with svn 2024-06-07 01:22:56 +00:00
l10n daemon script
3261231d07 GIT_SILENT made messages (after extraction) 2024-06-07 00:38:46 +00:00
l10n daemon script
95ce6385b0 GIT_SILENT Sync po/docbooks with svn 2024-06-05 01:36:19 +00:00
Volker Krause
64c5894602 Fix notifyrc file location 2024-06-04 15:01:54 +00:00
l10n daemon script
8c4839c300 GIT_SILENT Sync po/docbooks with svn 2024-06-04 01:22:51 +00:00
l10n daemon script
80c2bc1a52 GIT_SILENT Sync po/docbooks with svn 2024-06-03 01:23:01 +00:00
l10n daemon script
bcd417e039 GIT_SILENT Sync po/docbooks with svn 2024-06-02 01:24:06 +00:00
l10n daemon script
ac216f697f GIT_SILENT Sync po/docbooks with svn 2024-06-01 01:24:07 +00:00
l10n daemon script
9893fae27c SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2024-06-01 01:18:01 +00:00
l10n daemon script
cb183efa66 GIT_SILENT made messages (after extraction) 2024-06-01 00:39:03 +00:00
Carl Schwan
87d707bc21 CreateRoomDialog: Add missing formcard separators 2024-05-31 10:38:47 +00:00
James Graham
227ebd610a Support binding 3PIDs
Closes network/neochat#565
2024-05-31 09:25:42 +00:00
James Graham
ab4af48e52 Integrate NeoChatMaximizeComponent with MediaManger
Needs libraries/kirigami-addons!227

Closes network/neochat#641
2024-05-31 09:01:13 +00:00
l10n daemon script
78a8227219 GIT_SILENT Sync po/docbooks with svn 2024-05-31 01:31:41 +00:00
l10n daemon script
ec73a53101 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2024-05-31 01:19:16 +00:00
l10n daemon script
3fb1d086b7 GIT_SILENT Sync po/docbooks with svn 2024-05-30 01:24:46 +00:00
l10n daemon script
5d4a12c127 GIT_SILENT Sync po/docbooks with svn 2024-05-29 01:36:10 +00:00
Carl Schwan
d2a79214b5 Fix crash when sending message
Ensure the message has an eventId which only happens after the message
is sent.
2024-05-28 15:21:04 +02:00
Laurent Montel
db57111188 Use 6.7 image 2024-05-28 06:49:38 +02:00
l10n daemon script
b22276bcd5 GIT_SILENT Sync po/docbooks with svn 2024-05-28 01:22:05 +00:00
Tobias Fella
6e2d85f2d2 Add some Q_UNUSEDs 2024-05-27 20:06:28 +02:00
James Graham
efb72652ce Use MessageContentModel for replies
This allows code and other components to be displayed nicely.
2024-05-27 14:54:42 +00:00
l10n daemon script
3615c3e8e5 GIT_SILENT Sync po/docbooks with svn 2024-05-27 01:25:06 +00:00
Nicolas Fella
8186ee0e3f Add missing dependencies to QML modules 2024-05-26 16:15:57 +02:00
Nicolas Fella
74aa14c011 Make org.kde.neochat import all submodules
This way we don't need to explicitly import the various submodules and instead only import org.kde.neochat
2024-05-26 16:15:43 +02:00
146 changed files with 13077 additions and 10345 deletions

View File

@@ -2,7 +2,7 @@
"id": "org.kde.neochat",
"branch": "master",
"runtime": "org.kde.Platform",
"runtime-version": "6.6",
"runtime-version": "6.7",
"sdk": "org.kde.Sdk",
"command": "neochat",
"tags": [

View File

@@ -8,7 +8,7 @@ include:
- /gitlab-templates/android-qt6.yml
- /gitlab-templates/linux-qt6.yml
- /gitlab-templates/windows-qt6.yml
- /gitlab-templates/freebsd-qt6.yml
# - /gitlab-templates/freebsd-qt6.yml
- /gitlab-templates/flatpak.yml
- /gitlab-templates/craft-android-qt6-apks.yml
- /gitlab-templates/craft-appimage-qt6.yml

View File

@@ -40,4 +40,4 @@ Dependencies:
Options:
per-test-timeout: 90
require-passing-tests-on: [ '@all' ]
require-passing-tests-on: [ 'Linux', 'Android', 'FreeBSD' ]

View File

@@ -102,7 +102,7 @@ if (NOT ANDROID AND NOT WIN32 AND NOT APPLE)
find_package(KF6DBusAddons ${KF_MIN_VERSION} REQUIRED)
endif()
find_package(QuotientQt6 0.7)
find_package(QuotientQt6 0.8.2)
set_package_properties(QuotientQt6 PROPERTIES
TYPE REQUIRED
DESCRIPTION "Qt wrapper around Matrix API"

View File

@@ -38,8 +38,8 @@ Due to the nature of the Matrix specification development NeoChat also supports
Details where to find stable releases for NeoChat can be found on its [homepage](https://apps.kde.org/neochat).
Nightly builds for linux and windows can be downloaded from [cdn.kde.org](https://cdn.kde.org/ci-builds/network/neochat/).
Nightly builds for android are available from [KDE's nightly F-Droid repository](https://community.kde.org/Android/F-Droid).
Nightly builds for Linux and Windows can be downloaded from [cdn.kde.org](https://cdn.kde.org/ci-builds/network/neochat/).
Nightly builds for Android are available from [KDE's nightly F-Droid repository](https://community.kde.org/Android/F-Droid).
Nightly Flatpaks are available from [KDE's nightly Flatpak repository](https://userbase.kde.org/Tutorials/Flatpak).
## Building NeoChat

View File

@@ -50,7 +50,7 @@ void ChatBarCacheTest::empty()
QCOMPARE(chatBarCache->replyId(), QString());
QCOMPARE(chatBarCache->isEditing(), false);
QCOMPARE(chatBarCache->editId(), QString());
QCOMPARE(chatBarCache->relationUser(), room->getUser(nullptr));
QCOMPARE(chatBarCache->relationUser(), room->getUser(QString()));
QCOMPARE(chatBarCache->relationMessage(), QString());
QCOMPARE(chatBarCache->attachmentPath(), QString());
}
@@ -98,7 +98,7 @@ void ChatBarCacheTest::reply()
QCOMPARE(chatBarCache->replyId(), QLatin1String("$153456789:example.org"));
QCOMPARE(chatBarCache->isEditing(), false);
QCOMPARE(chatBarCache->editId(), QString());
QCOMPARE(chatBarCache->relationUser(), room->getUser(room->user(QLatin1String("@example:example.org"))));
QCOMPARE(chatBarCache->relationUser(), room->getUser(QLatin1String("@example:example.org")));
QCOMPARE(chatBarCache->relationMessage(), QLatin1String("This is an example\ntext message"));
QCOMPARE(chatBarCache->attachmentPath(), QString());
}
@@ -115,7 +115,7 @@ void ChatBarCacheTest::edit()
QCOMPARE(chatBarCache->replyId(), QString());
QCOMPARE(chatBarCache->isEditing(), true);
QCOMPARE(chatBarCache->editId(), QLatin1String("$153456789:example.org"));
QCOMPARE(chatBarCache->relationUser(), room->getUser(room->user(QLatin1String("@example:example.org"))));
QCOMPARE(chatBarCache->relationUser(), room->getUser(QLatin1String("@example:example.org")));
QCOMPARE(chatBarCache->relationMessage(), QLatin1String("This is an example\ntext message"));
QCOMPARE(chatBarCache->attachmentPath(), QString());
}
@@ -132,7 +132,7 @@ void ChatBarCacheTest::attachment()
QCOMPARE(chatBarCache->replyId(), QString());
QCOMPARE(chatBarCache->isEditing(), false);
QCOMPARE(chatBarCache->editId(), QString());
QCOMPARE(chatBarCache->relationUser(), room->getUser(nullptr));
QCOMPARE(chatBarCache->relationUser(), room->getUser(QString()));
QCOMPARE(chatBarCache->relationMessage(), QString());
QCOMPARE(chatBarCache->attachmentPath(), QLatin1String("some/path"));
}

View File

@@ -101,17 +101,17 @@ void EventHandlerTest::nullEventId()
void EventHandlerTest::author()
{
auto event = room->messageEvents().at(0).get();
auto author = room->user(event->senderId());
auto author = room->member(event->senderId());
EventHandler eventHandler(room, event);
auto eventHandlerAuthor = eventHandler.getAuthor();
QCOMPARE(eventHandlerAuthor["isLocalUser"_ls], author->id() == room->localUser()->id());
QCOMPARE(eventHandlerAuthor["id"_ls], author->id());
QCOMPARE(eventHandlerAuthor["displayName"_ls], author->displayname(room));
QCOMPARE(eventHandlerAuthor["isLocalUser"_ls], author.id() == room->localMember().id());
QCOMPARE(eventHandlerAuthor["id"_ls], author.id());
QCOMPARE(eventHandlerAuthor["displayName"_ls], author.displayName());
QCOMPARE(eventHandlerAuthor["avatarSource"_ls], room->avatarForMember(author));
QCOMPARE(eventHandlerAuthor["avatarMediaId"_ls], author->avatarMediaId(room));
QCOMPARE(eventHandlerAuthor["color"_ls], Utils::getUserColor(author->hueF()));
QCOMPARE(eventHandlerAuthor["avatarMediaId"_ls], author.avatarMediaId());
QCOMPARE(eventHandlerAuthor["color"_ls], Utils::getUserColor(author.hueF()));
QCOMPARE(eventHandlerAuthor["object"_ls], QVariant::fromValue(author));
}
@@ -122,7 +122,7 @@ void EventHandlerTest::nullAuthor()
EventHandler noEventHandler(room, nullptr);
QTest::ignoreMessage(QtWarningMsg, "getAuthor called with m_event set to nullptr. Returning empty user.");
QCOMPARE(noEventHandler.getAuthor(), room->getUser(nullptr));
QCOMPARE(noEventHandler.getAuthor(), room->getUser(QString()));
}
void EventHandlerTest::authorDisplayName()
@@ -393,21 +393,21 @@ void EventHandlerTest::nullReplyId()
void EventHandlerTest::replyAuthor()
{
auto replyEvent = room->messageEvents().at(0).get();
auto replyAuthor = room->user(replyEvent->senderId());
auto replyAuthor = room->member(replyEvent->senderId());
EventHandler eventHandler(room, room->messageEvents().at(5).get());
auto eventHandlerReplyAuthor = eventHandler.getReplyAuthor();
QCOMPARE(eventHandlerReplyAuthor["isLocalUser"_ls], replyAuthor->id() == room->localUser()->id());
QCOMPARE(eventHandlerReplyAuthor["id"_ls], replyAuthor->id());
QCOMPARE(eventHandlerReplyAuthor["displayName"_ls], replyAuthor->displayname(room));
QCOMPARE(eventHandlerReplyAuthor["isLocalUser"_ls], replyAuthor.id() == room->localMember().id());
QCOMPARE(eventHandlerReplyAuthor["id"_ls], replyAuthor.id());
QCOMPARE(eventHandlerReplyAuthor["displayName"_ls], replyAuthor.displayName());
QCOMPARE(eventHandlerReplyAuthor["avatarSource"_ls], room->avatarForMember(replyAuthor));
QCOMPARE(eventHandlerReplyAuthor["avatarMediaId"_ls], replyAuthor->avatarMediaId(room));
QCOMPARE(eventHandlerReplyAuthor["color"_ls], Utils::getUserColor(replyAuthor->hueF()));
QCOMPARE(eventHandlerReplyAuthor["avatarMediaId"_ls], replyAuthor.avatarMediaId());
QCOMPARE(eventHandlerReplyAuthor["color"_ls], Utils::getUserColor(replyAuthor.hueF()));
QCOMPARE(eventHandlerReplyAuthor["object"_ls], QVariant::fromValue(replyAuthor));
EventHandler eventHandlerNoAuthor(room, room->messageEvents().at(0).get());
QCOMPARE(eventHandlerNoAuthor.getReplyAuthor(), room->getUser(nullptr));
QCOMPARE(eventHandlerNoAuthor.getReplyAuthor(), room->getUser(QString()));
}
void EventHandlerTest::nullReplyAuthor()
@@ -417,7 +417,7 @@ void EventHandlerTest::nullReplyAuthor()
EventHandler noEventHandler(room, nullptr);
QTest::ignoreMessage(QtWarningMsg, "getReplyAuthor called with m_event set to nullptr. Returning empty user.");
QCOMPARE(noEventHandler.getReplyAuthor(), room->getUser(nullptr));
QCOMPARE(noEventHandler.getReplyAuthor(), room->getUser(QString()));
}
void EventHandlerTest::replyBody()

View File

@@ -53,7 +53,7 @@ void ReactionModelTest::basicReaction()
QCOMPARE(model.data(model.index(0), ReactionModel::ReactionRole), QStringLiteral("👍"));
QCOMPARE(model.data(model.index(0), ReactionModel::ToolTipRole),
QStringLiteral("@alice:matrix.org reacted with <span style=\"font-family: 'emoji';\">👍</span>"));
auto authorList = QVariantList{room->getUser(room->user(QStringLiteral("@alice:matrix.org")))};
auto authorList = QVariantList{room->getUser(QStringLiteral("@alice:matrix.org"))};
QCOMPARE(model.data(model.index(0), ReactionModel::AuthorsRole), authorList);
QCOMPARE(model.data(model.index(0), ReactionModel::HasLocalUser), false);
}

View File

@@ -80,12 +80,14 @@
<summary xml:lang="zh-TW">在 Matrix 上與您的朋友聊天</summary>
<description>
<p>NeoChat is a chat app that lets you take full advantage of the Matrix network. It provides you with a secure way to send text messages, videos and audio files to your family, colleagues and friends.</p>
<p xml:lang="ar">نيوتشات هو تطبيق دردشة يتيح لك الاستفادة الكاملة من شبكة Matrix. فهو يوفر لك طريقة آمنة لإرسال الرسائل النصية ومقاطع الفيديو والملفات الصوتية إلى عائلتك وزملائك وأصدقائك.</p>
<p xml:lang="ca">El NeoChat és una aplicació de xat que us permet aprofitar plenament la xarxa Matrix. Proporciona una manera segura d'enviar missatges de text, vídeos i arxius d'àudio a la vostra família, companys i amics.</p>
<p xml:lang="ca-valencia">NeoChat és una aplicació de xat que us permet aprofitar plenament la xarxa Matrix. Proporciona una manera segura d'enviar missatges de text, vídeos i arxius d'àudio a la vostra família, companys i amics.</p>
<p xml:lang="en-GB">NeoChat is a chat app that lets you take full advantage of the Matrix network. It provides you with a secure way to send text messages, videos and audio files to your family, colleagues and friends.</p>
<p xml:lang="eo">NeoChat estas babilej-apo, kiu ebligas al vi plene profiti de la Matrix-reto. Ĝi provizas al vi sekuran manieron sendi tekstmesaĝojn, filmetojn kaj sondosierojn al via familio, kolegoj kaj amikoj.</p>
<p xml:lang="es">NeoChat es una aplicación de chat que le permite aprovechar al máximo la red Matrix. Le proporciona un modo seguro de enviar mensajes de texto, vídeos y archivos de sonido a su familia, colegas y amigos.</p>
<p xml:lang="eu">NeoChat, Matrix sarearen abantaila guztiei probetsua ateratzeko aukera ematen dizun berriketa aplikaizo bat da. Zure familiari, kideei eta lagunei testu mezuak, bideoak eta audio fitxategiak era seguruan bidaltzeko aukera ematen dizu.</p>
<p xml:lang="fi">NeoChat on keskustelusovellus, jolla Matrix-verkosta saa täyden hyödyn. Se tarjoaa salatun kanavan lähettää perheelle, työkavereille ja ystäville tekstiviestejä sekä video- ja äänitiedostoja.</p>
<p xml:lang="fr">NeoChat est une application de discussions vous permettant de profiter pleinement du réseau Matrix. Elle vous offre un moyen sécurisé d'envoyer des messages de texte, des vidéos et des fichiers audio à votre famille, vos collègues et vos ami(e)s.</p>
<p xml:lang="hu">A NeoChat egy olyan csevegőalkalmazás, amellyel teljes mértékben kihasználhatja a Matrix hálózatot. Biztonságos módot biztosít szöveges üzenetek, videók és hangfájlok küldéséhez családtagjainak, kollégáinak és barátainak.</p>
<p xml:lang="ia">NeoChat es un app de conversation que te permitte prender avantage plen del rete Matrix. Il te forni un modo secur de inviar messages de texto, videos e files audio a tui familia, collegas e amicos.</p>
@@ -95,6 +97,7 @@
<p xml:lang="nl">NeoChat is een chat-toepassing die u het volledige voordeel van het Matrix-netwerk laat genieten. Het levert u op een veilige manier tekstberichten, video's en geluidsbestanden naar uw familie, collega's en vrienden te verzenden.</p>
<p xml:lang="pl">NoeChat to aplikacja do rozmów, która umożliwia wykorzystanie wszystkich możliwości Matriksa. Umożliwia wysyłanie wiadomości tekstowych, filmów i dźwięków w bezpieczny sposób do twojej rodziny, kolegów i przyjaciół.</p>
<p xml:lang="sl">NeoChat je aplikacija za klepet, ki vam omogoča, da v celoti izkoristite omrežje Matrix. Zagotavlja vam varen način za pošiljanje besedilnih sporočil, videoposnetkov in zvočnih datotek vaši družini, sodelavcem in prijateljem.</p>
<p xml:lang="sv">NeoChat är ett chattprogram som låter dig dra full nytta av Matrix-nätverket. Det ger dig ett säkert sätt att skicka textmeddelanden, videor och ljudfiler till din familj, kollegor och vänner.</p>
<p xml:lang="tr">NeoChat, Matrix ağının tüm özelliklerini kullanan bir sohbet uygulamasıdır. Ailenize, arkadaşlarınıza ve iş arkadaşlarınıza metin iletileri, ses ve video dosyaları göndermenin kolay bir yolunu sunar.</p>
<p xml:lang="uk">NeoChat є програмою для спілкування, за допомогою якої ви можете скористатися усіма перевагами мережі Matrix. За її допомогою ви можете безпечно надсилати текстові повідомлення, відео та звукові файли вашим родичам, колегам та друзям.</p>
<p xml:lang="x-test">xxNeoChat is a chat app that lets you take full advantage of the Matrix network. It provides you with a secure way to send text messages, videos and audio files to your family, colleagues and friends.xx</p>
@@ -111,7 +114,7 @@
<p xml:lang="fr">L'objectif de NeoChat est d'être une application complète pour le protocole Matrix. En tant que tel, tout dans la spécification stable actuelle avec les exceptions notables de VoIP, les processus et certains aspects du chiffrement de bout en bout sont pris en charge. Il y a quelques autres petites omissions en raison du fait que la spécification du protocole Matrix est en constante évolution. Cependant, l'objectif reste de fournir un soutien éventuel pour l'ensemble de la spécification.</p>
<p xml:lang="gl">NeoChat pretende ser unha aplicación completa para a especificación de Matrix. Coas excepcións de VoIP, conversas fiadas e algúns aspectos da cifraxe de extremo a extremo, a versión estábel segue as especificacións. Existen algunhas outras pequenas omisións debido ao feito de que Matrix está en continua evolución pero a intención é implementar a especificación completa.</p>
<p xml:lang="hu">A NeoChat célja, hogy a Matrix specifikációnak megfelelő teljes funkcionalitású alkalmazás legyen. Mint ilyen, a jelenlegi stabil specifikáció támogatott a VoIP, a szálak és a végpontok közötti titkosítás egyes elemeinek kivételével. Van még néhány kisebb hiányosság annak köszönhetően, hogy a Matrix specifikáció folyamatosan fejlődik, de végső cél a teljes specifikáció megvalósítása.</p>
<p xml:lang="ia">NeoChat aspira a esser un application plenemente eminente per le specification de Matrix. Tal como omne cosas in le specification currentemente stabile con le exceptiones notabile de VOIP, threads e alcun aspectos del cryptation End-to-End es supportate. Il ha ltere pauc omissiones, debite al facto que le specification de Matrix es in evolution constante ma le aspiration remane a fornir supporto eventual per le integre specification.</p>
<p xml:lang="ia">NeoChat aspira a esser un application plenmente eminente per le specification de Matrix. Tal como omne cosas in le specification currentemente stabile con le exceptiones notabile de VOIP, threads e alcun aspectos del cryptation End-to-End es supportate. Il ha ltere pauc omissiones, debite al facto que le specification de Matrix es in evolution constante ma le aspiration remane a fornir supporto eventual per le integre specification.</p>
<p xml:lang="it">NeoChat mira ad essere un'applicazione completa per le specifiche Matrix. Pertanto, sono supportati tutti gli elementi dell'attuale specifica stabile con le notevoli eccezioni di VoIP, conversazioni e alcuni aspetti della cifratura end-to-end. Ci sono alcune altre piccole omissioni dovute al fatto che le specifiche Matrix sono in continua evoluzione, ma l'obiettivo rimane quello di fornire un eventuale supporto per l'intera specifica.</p>
<p xml:lang="ka">NeoChat მიზნად ისახავს Matrix სპეციფიკაციის სრული განხორციელება ჰქონდეს. როგორც ასეთი, ყველაფერი მიმდინარე სპეციფიკაციიდან, VoIP-ის, ძაფებისა და გამჭოლი დაშიფვრის ზოგიერთი ასპექტის გარდა, მხარდაჭერილია. შეძლება ასევე იყოს მცირე ლაფსუსებიც იმის გამო, რომ Matrix-ის სპეციფიკაცია მუდმივად ვითარდება, მაგრამ ჩვენი მიზანი მისი სრული მხარდაჭერაა.</p>
<p xml:lang="ko">NeoChat은 Matrix 표준을 따르는 프로그램을 목표로 합니다. 현재 안정 버전의 표준에서 제공하는 기능의 대부분을 지원하며, VoIP, 스레드, 일부 종단간 암호화와 같은 기능은 아직 지원하지 않습니다. Matrix 표준은 계속하여 진화 중이기 때문에 일부 기능이 빠져 있을 수도 있지만 장기적으로는 전체 표준을 지원하는 것이 목표입니다.</p>
@@ -210,7 +213,7 @@
<li xml:lang="sl">Sticker Packs - MSC2545</li>
<li xml:lang="sv">Sticker Packs - MSC2545</li>
<li xml:lang="ta">ஒட்டி தொகுப்புகள் - MSC2545</li>
<li xml:lang="tr">Yapışkan Paketleri — MSC2545</li>
<li xml:lang="tr">Çıkartma Paketleri — MSC2545</li>
<li xml:lang="uk">Пакунки наліпок - MSC2545</li>
<li xml:lang="x-test">xxSticker Packs - MSC2545xx</li>
<li xml:lang="zh-TW">貼圖包 - MSC2545</li>
@@ -310,12 +313,14 @@
<screenshot type="default">
<image>https://cdn.kde.org/screenshots/neochat/spaces.png</image>
<caption>Discover new communities with Matrix Spaces</caption>
<caption xml:lang="ar">اكتشف مجتمعات جديدة مع فضاءات ماتركس</caption>
<caption xml:lang="ca">Descobriu comunitats noves amb els espais de Matrix</caption>
<caption xml:lang="ca-valencia">Descobriu comunitats noves amb els espais de Matrix</caption>
<caption xml:lang="en-GB">Discover new communities with Matrix Spaces</caption>
<caption xml:lang="eo">Malkovru novajn komunumojn per Matrix Spaces</caption>
<caption xml:lang="es">Descubra nuevas comunidades con los espacios de Matrix</caption>
<caption xml:lang="eu">Ezagutu komunitate berriak Matrixeko Tokiak erabiliz</caption>
<caption xml:lang="fi">Löydä uusia yhteisöjä Matrix Spacesillä</caption>
<caption xml:lang="fr">Découvrez de nouvelles communautés avec les espaces sous Matrix</caption>
<caption xml:lang="hu">Fedezzen fel új közösségeket a Matrix Terek segítségével</caption>
<caption xml:lang="ia">Discoperi nove communitate con Matrix Spaces (Spatios de Matrix)</caption>
@@ -325,6 +330,7 @@
<caption xml:lang="nl">Ontdek nieuwe gemeenschappen met Matrix-ruimten</caption>
<caption xml:lang="pl">Odkrywaj nowe społeczności w Przestrzeniach Matriksa</caption>
<caption xml:lang="sl">Odkrijte nove skupnosti z Matrix Spaces</caption>
<caption xml:lang="sv">Upptäck nya gemenskaper med Matrix Spaces</caption>
<caption xml:lang="tr">Matrix Alanlar ile yeni topluluklar keşfedin</caption>
<caption xml:lang="uk">Пошук нових спільнот за допомогою Matrix Spaces</caption>
<caption xml:lang="x-test">xxDiscover new communities with Matrix Spacesxx</caption>
@@ -407,6 +413,7 @@
<content_attribute id="social-chat">intense</content_attribute>
</content_rating>
<releases>
<release version="24.05.1" date="2024-06-13"/>
<release version="24.05.0" date="2024-05-23"/>
<release version="24.02.2" date="2024-04-11"/>
<release version="24.02.1" date="2024-03-21"/>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -185,6 +185,8 @@ add_library(neochat STATIC
enums/powerlevel.h
models/permissionsmodel.cpp
models/permissionsmodel.h
threepidbindhelper.cpp
threepidbindhelper.h
)
set_source_files_properties(qml/OsmLocationPlugin.qml PROPERTIES
@@ -281,6 +283,15 @@ qt_add_qml_module(neochat URI org.kde.neochat NO_PLUGIN
qml/ConsentDialog.qml
qml/AskDirectChatConfirmation.qml
qml/HoverLinkIndicator.qml
DEPENDENCIES
QtCore
QtQuick
IMPORTS
org.kde.neochat.timeline
org.kde.neochat.settings
org.kde.neochat.devtools
org.kde.neochat.login
org.kde.neochat.chatbar
)
add_subdirectory(settings)

View File

@@ -91,7 +91,7 @@ void ActionsHandler::handleMessage(const QString &text, QString handledText, Cha
for (auto it = m_room->messageEvents().crbegin(); it != m_room->messageEvents().crend(); it++) {
if (const auto event = eventCast<const RoomMessageEvent>(&**it)) {
if (event->senderId() == m_room->localUser()->id() && event->hasTextContent()) {
if (event->senderId() == m_room->localMember().id() && event->hasTextContent()) {
QString originalString;
if (event->content()) {
originalString = static_cast<const Quotient::EventContent::TextContent *>(event->content())->body;

View File

@@ -13,13 +13,15 @@ import org.kde.neochat
QQC2.Popup {
id: root
padding: 16
padding: Kirigami.Units.largeSpacing
signal chosen(string path)
contentItem: RowLayout {
spacing: Kirigami.Units.smallSpacing
QQC2.ToolButton {
Layout.preferredWidth: 160
Layout.fillHeight: true
icon.name: 'mail-attachment'
@@ -28,7 +30,7 @@ QQC2.Popup {
onClicked: {
root.close();
var fileDialog = openFileDialog.createObject(QQC2.ApplicationWindow.overlay);
var fileDialog = openFileDialog.createObject(QQC2.Overlay.overlay);
fileDialog.chosen.connect(path => root.chosen(path));
fileDialog.open();
}
@@ -37,11 +39,8 @@ QQC2.Popup {
Kirigami.Separator {}
QQC2.ToolButton {
Layout.preferredWidth: 160
Layout.fillHeight: true
padding: 16
icon.name: 'insert-image'
text: i18n("Clipboard image")
onClicked: {

View File

@@ -115,7 +115,7 @@ QQC2.Control {
displayHint: QQC2.AbstractButton.IconOnly
onTriggered: {
locationChooser.createObject(QQC2.ApplicationWindow.overlay, {
locationChooser.createObject(QQC2.Overlay.overlay, {
room: root.currentRoom
}).open();
}

View File

@@ -96,9 +96,9 @@ QVariantMap ChatBarCache::relationUser() const
return {};
}
if (m_relationId.isEmpty()) {
return room->getUser(nullptr);
return room->getUser(QString());
}
return room->getUser(room->user((*room->findInTimeline(m_relationId))->senderId()));
return room->getUser((*room->findInTimeline(m_relationId))->senderId());
}
QString ChatBarCache::relationMessage() const

View File

@@ -103,14 +103,16 @@ Controller::Controller(QObject *parent)
connect(&m_accountRegistry, &AccountRegistry::accountCountChanged, this, [this]() {
if (m_accountRegistry.size() > oldAccountCount) {
auto connection = dynamic_cast<NeoChatConnection *>(m_accountRegistry.accounts()[m_accountRegistry.size() - 1]);
connect(connection, &NeoChatConnection::syncDone, this, [connection]() {
NotificationsManager::instance().handleNotifications(connection);
});
connectSingleShot(connection, &NeoChatConnection::syncDone, this, [this, connection] {
if (!m_endpoint.isEmpty()) {
connection->setupPushNotifications(m_endpoint);
}
});
connect(
connection,
&NeoChatConnection::syncDone,
this,
[this, connection] {
if (!m_endpoint.isEmpty()) {
connection->setupPushNotifications(m_endpoint);
}
},
Qt::SingleShotConnection);
}
oldAccountCount = m_accountRegistry.size();
});
@@ -409,7 +411,16 @@ void Controller::removeConnection(const QString &userId)
bool Controller::ssssSupported() const
{
#if __has_include("Quotient/e2ee/sssshandler.h")
#if Quotient_VERSION_MINOR > 8 || Quotient_VERSION_PATCH > 1
return true;
#else
return false;
#endif
}
bool Controller::csSupported() const
{
#if Quotient_VERSION_MINOR > 9
return true;
#else
return false;

View File

@@ -51,6 +51,7 @@ class Controller : public QObject
Q_PROPERTY(QStringList accountsLoading MEMBER m_accountsLoading NOTIFY accountsLoadingChanged)
Q_PROPERTY(bool ssssSupported READ ssssSupported CONSTANT)
Q_PROPERTY(bool csSupported READ csSupported CONSTANT)
public:
static Controller &instance();
@@ -97,6 +98,7 @@ public:
Q_INVOKABLE void removeConnection(const QString &userId);
bool ssssSupported() const;
bool csSupported() const;
private:
explicit Controller(QObject *parent = nullptr);

11
src/definitions.h Normal file
View File

@@ -0,0 +1,11 @@
// SPDX-FileCopyrightText: 2024 Tobias Fella <tobias.fella@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
#if Quotient_VERSION_MINOR > 8
#define Omittable std::optional
#define quotientNone std::nullopt
#else
#include <Quotient/omittable.h>
#define Omittable Quotient::Omittable
#define quotientNone Quotient::none
#endif

View File

@@ -47,11 +47,11 @@ public:
LiveLocation, /**< The initial event of a shared live location (i.e., the place where this is supposed to be shown in the timeline). */
Encrypted, /**< An encrypted message that cannot be decrypted. */
Reply, /**< A component to show a replied-to message. */
ReplyLoad, /**< A loading dialog for a reply. */
LinkPreview, /**< A preview of a URL in the message. */
LinkPreviewLoad, /**< A loading dialog for a link preview. */
Edit, /**< A text edit for editing a message. */
Verification, /**< A user verification session start message. */
Loading, /**< The component is loading. */
Other, /**< Anything that cannot be classified as another type. */
};
Q_ENUM(Type);

View File

@@ -70,10 +70,10 @@ QVariantMap EventHandler::getAuthor(bool isPending) const
// If we have a room we can return an empty user by handing nullptr to m_room->getUser.
if (m_event == nullptr) {
qCWarning(EventHandling) << "getAuthor called with m_event set to nullptr. Returning empty user.";
return m_room->getUser(nullptr);
return m_room->getUser(QString());
}
const auto author = isPending ? m_room->localUser() : m_room->user(m_event->senderId());
const auto author = isPending ? m_room->localMember() : m_room->member(m_event->senderId());
return m_room->getUser(author);
}
@@ -96,8 +96,8 @@ QString EventHandler::getAuthorDisplayName(bool isPending) const
}
return previousDisplayName;
} else {
const auto author = isPending ? m_room->localUser() : m_room->user(m_event->senderId());
return m_room->htmlSafeMemberName(author->id());
const auto author = isPending ? m_room->localMember() : m_room->member(m_event->senderId());
return author.htmlSafeDisplayName();
}
}
@@ -112,8 +112,8 @@ QString EventHandler::singleLineAuthorDisplayname(bool isPending) const
return {};
}
const auto author = isPending ? m_room->localUser() : m_room->user(m_event->senderId());
auto displayName = m_room->safeMemberName(author->id());
const auto author = isPending ? m_room->localMember() : m_room->member(m_event->senderId());
auto displayName = author.displayName();
displayName.replace(QStringLiteral("<br>\n"), QStringLiteral(" "));
displayName.replace(QStringLiteral("<br>"), QStringLiteral(" "));
displayName.replace(QStringLiteral("<br />\n"), QStringLiteral(" "));
@@ -220,7 +220,7 @@ bool EventHandler::isHidden()
}
}
if (m_room->connection()->isIgnored(m_room->user(m_event->senderId()))) {
if (m_room->connection()->isIgnored(m_event->senderId())) {
return true;
}
@@ -255,7 +255,7 @@ QString EventHandler::rawMessageBody(const Quotient::RoomMessageEvent &event)
QString body;
if (event.hasTextContent() && event.content()) {
body = static_cast<const MessageEventContent::TextContent *>(event.content())->body;
body = static_cast<const EventContent::TextContent *>(event.content())->body;
} else {
body = event.plainBody();
}
@@ -318,7 +318,7 @@ QString EventHandler::getBody(const Quotient::RoomEvent *event, Qt::TextFormat f
},
[this, prettyPrint](const RoomMemberEvent &e) {
// FIXME: Rewind to the name that was at the time of this event
auto subjectName = m_room->htmlSafeMemberName(e.userId());
auto subjectName = m_room->member(e.userId()).htmlSafeDisplayName();
if (e.membership() == Membership::Leave) {
if (e.prevContent() && e.prevContent()->displayName) {
subjectName = sanitized(*e.prevContent()->displayName).toHtmlEscaped();
@@ -479,7 +479,7 @@ QString EventHandler::getMessageBody(const RoomMessageEvent &event, Qt::TextForm
QString body;
if (event.hasTextContent() && event.content()) {
body = static_cast<const MessageEventContent::TextContent *>(event.content())->body;
body = static_cast<const EventContent::TextContent *>(event.content())->body;
} else {
body = event.plainBody();
}
@@ -809,16 +809,15 @@ QVariantMap EventHandler::getReplyAuthor() const
// If we have a room we can return an empty user by handing nullptr to m_room->getUser.
if (m_event == nullptr) {
qCWarning(EventHandling) << "getReplyAuthor called with m_event set to nullptr. Returning empty user.";
return m_room->getUser(nullptr);
return m_room->getUser(QString());
}
auto replyPtr = m_room->getReplyForEvent(*m_event);
if (replyPtr) {
auto replyUser = m_room->user(replyPtr->senderId());
return m_room->getUser(replyUser);
return m_room->getUser(replyPtr->senderId());
} else {
return m_room->getUser(nullptr);
return m_room->getUser(QString());
}
}
@@ -966,7 +965,7 @@ bool EventHandler::hasReadMarkers() const
}
auto userIds = m_room->userIdsAtEvent(m_event->id());
userIds.remove(m_room->localUser()->id());
userIds.remove(m_room->localMember().id());
return userIds.size() > 0;
}
@@ -982,7 +981,7 @@ QVariantList EventHandler::getReadMarkers(int maxMarkers) const
}
auto userIds_temp = m_room->userIdsAtEvent(m_event->id());
userIds_temp.remove(m_room->localUser()->id());
userIds_temp.remove(m_room->localMember().id());
auto userIds = userIds_temp.values();
if (userIds.count() > maxMarkers) {
@@ -992,7 +991,7 @@ QVariantList EventHandler::getReadMarkers(int maxMarkers) const
QVariantList users;
users.reserve(userIds.size());
for (const auto &userId : userIds) {
auto user = m_room->user(userId);
auto user = m_room->member(userId);
users += m_room->getUser(user);
}
@@ -1011,7 +1010,7 @@ QString EventHandler::getNumberExcessReadMarkers(int maxMarkers) const
}
auto userIds = m_room->userIdsAtEvent(m_event->id());
userIds.remove(m_room->localUser()->id());
userIds.remove(m_room->localMember().id());
if (userIds.count() > maxMarkers) {
return QStringLiteral("+ ") + QString::number(userIds.count() - maxMarkers);
@@ -1032,7 +1031,7 @@ QString EventHandler::getReadMarkersString() const
}
auto userIds = m_room->userIdsAtEvent(m_event->id());
userIds.remove(m_room->localUser()->id());
userIds.remove(m_room->localMember().id());
/**
* The string ends up in the form
@@ -1040,8 +1039,8 @@ QString EventHandler::getReadMarkersString() const
*/
QString readMarkersString = i18np("1 user: ", "%1 users: ", userIds.size());
for (const auto &userId : userIds) {
auto user = m_room->user(userId);
auto displayName = user->displayname(m_room);
auto user = m_room->member(userId);
auto displayName = user.displayName();
if (displayName.isEmpty()) {
displayName = userId;
}

View File

@@ -16,7 +16,7 @@ ImagePackEventContent::ImagePackEventContent(const QJsonObject &json)
fromJson<Omittable<QString>>(json["pack"_ls].toObject()["attribution"_ls]),
};
} else {
pack = none;
pack = quotientNone;
}
const auto &keys = json["images"_ls].toObject().keys();
@@ -25,7 +25,7 @@ ImagePackEventContent::ImagePackEventContent(const QJsonObject &json)
if (json["images"_ls][k].toObject().contains(QStringLiteral("info"))) {
info = EventContent::ImageInfo(QUrl(json["images"_ls][k]["url"_ls].toString()), json["images"_ls][k]["info"_ls].toObject(), k);
} else {
info = none;
info = quotientNone;
}
images += ImagePackImage{
k,

View File

@@ -7,6 +7,8 @@
#include <Quotient/events/eventcontent.h>
#include <Quotient/events/stateevent.h>
#include "definitions.h"
namespace Quotient
{
/**
@@ -26,10 +28,10 @@ public:
* @brief Defines the properties of an image pack.
*/
struct Pack {
Quotient::Omittable<QString> displayName; /**< The display name of the pack. */
Quotient::Omittable<QUrl> avatarUrl; /**< The source mxc URL for the pack avatar. */
Quotient::Omittable<QStringList> usage; /**< An array of the usages for this pack. Possible usages are "emoticon" and "sticker". */
Quotient::Omittable<QString> attribution; /**< The attribution for the pack author(s). */
Omittable<QString> displayName; /**< The display name of the pack. */
Omittable<QUrl> avatarUrl; /**< The source mxc URL for the pack avatar. */
Omittable<QStringList> usage; /**< An array of the usages for this pack. Possible usages are "emoticon" and "sticker". */
Omittable<QString> attribution; /**< The attribution for the pack author(s). */
};
/**
@@ -38,14 +40,14 @@ public:
struct ImagePackImage {
QString shortcode; /**< The shortcode for the image. */
QUrl url; /**< The mxc URL for this image. */
Quotient::Omittable<QString> body; /**< An optional text body for this image. */
Quotient::Omittable<Quotient::EventContent::ImageInfo> info; /**< The ImageInfo object used for the info block of m.sticker events. */
Omittable<QString> body; /**< An optional text body for this image. */
Omittable<Quotient::EventContent::ImageInfo> info; /**< The ImageInfo object used for the info block of m.sticker events. */
/**
* @brief An array of the usages for this image.
*
* The possible values match those of the usage key of a pack object.
*/
Quotient::Omittable<QStringList> usage;
Omittable<QStringList> usage;
};
/**
@@ -53,7 +55,7 @@ public:
*
* @sa Pack
*/
Quotient::Omittable<Pack> pack;
Omittable<Pack> pack;
/**
* @brief Return a vector of images in the pack.

View File

@@ -14,12 +14,15 @@ Q_SCRIPTABLE RemoteActions FakeRunner::Actions()
Q_SCRIPTABLE RemoteMatches FakeRunner::Match(const QString &searchTerm)
{
Q_UNUSED(searchTerm);
QCoreApplication::quit();
return {};
}
Q_SCRIPTABLE void FakeRunner::Run(const QString &id, const QString &actionId)
{
Q_UNUSED(id);
Q_UNUSED(actionId);
QCoreApplication::quit();
}

View File

@@ -7,7 +7,7 @@
#include <Quotient/accountregistry.h>
#include <Quotient/keyverificationsession.h>
#if __has_include("Quotient/e2ee/sssshandler.h")
#if Quotient_VERSION_MINOR > 8 || Quotient_VERSION_PATCH > 1
#include <Quotient/e2ee/sssshandler.h>
#endif
@@ -47,7 +47,7 @@ struct ForeignKeyVerificationSession {
QML_UNCREATABLE("")
};
#if __has_include("Quotient/e2ee/sssshandler.h")
#if Quotient_VERSION_MINOR > 8 || Quotient_VERSION_PATCH > 1
struct ForeignSSSSHandler {
Q_GADGET
QML_FOREIGN(Quotient::SSSSHandler)

View File

@@ -33,43 +33,6 @@ void IdentityServerHelper::setConnection(NeoChatConnection *connection)
m_connection = connection;
Q_EMIT connectionChanged();
Q_EMIT currentServerChanged();
connect(m_connection, &NeoChatConnection::accountDataChanged, this, [this](const QString &type) {
if (type == QLatin1String("m.identity_server")) {
Q_EMIT currentServerChanged();
}
});
}
QString IdentityServerHelper::currentServer() const
{
if (m_connection == nullptr) {
return {};
}
if (!m_connection->hasAccountData(QLatin1String("m.identity_server"))) {
return i18nc("@info", "No identity server configured");
}
const auto url = m_connection->accountData(QLatin1String("m.identity_server"))->contentPart<QUrl>(QLatin1String("base_url"));
if (!url.isEmpty()) {
return url.toString();
}
return i18nc("@info", "No identity server configured");
}
bool IdentityServerHelper::hasCurrentServer() const
{
if (m_connection == nullptr && !m_connection->hasAccountData(QLatin1String("m.identity_server"))) {
return false;
}
const auto url = m_connection->accountData(QLatin1String("m.identity_server"))->contentPart<QUrl>(QLatin1String("base_url"));
if (!url.isEmpty()) {
return true;
}
return false;
}
QString IdentityServerHelper::url() const
@@ -100,7 +63,7 @@ void IdentityServerHelper::checkUrl()
m_idServerCheckRequest.clear();
}
if (m_url == currentServer()) {
if (m_url == m_connection->identityServer().toString()) {
m_status = Match;
Q_EMIT statusChanged();
return;
@@ -134,7 +97,7 @@ void IdentityServerHelper::checkUrl()
void IdentityServerHelper::setIdentityServer()
{
if (m_url == currentServer()) {
if (m_url == m_connection->identityServer().toString()) {
return;
}
@@ -145,7 +108,7 @@ void IdentityServerHelper::setIdentityServer()
void IdentityServerHelper::clearIdentityServer()
{
if (currentServer().isEmpty()) {
if (m_connection->identityServer().isEmpty()) {
return;
}
m_connection->setAccountData(QLatin1String("m.identity_server"), {{QLatin1String("base_url"), QString()}});

View File

@@ -26,16 +26,6 @@ class IdentityServerHelper : public QObject
*/
Q_PROPERTY(NeoChatConnection *connection READ connection WRITE setConnection NOTIFY connectionChanged)
/**
* @brief The current identity server.
*/
Q_PROPERTY(QString currentServer READ currentServer NOTIFY currentServerChanged)
/**
* @brief Whether an identity server is currently configured.
*/
Q_PROPERTY(bool hasCurrentServer READ hasCurrentServer NOTIFY currentServerChanged)
/**
* @brief The URL for the desired server.
*/
@@ -64,10 +54,6 @@ public:
[[nodiscard]] NeoChatConnection *connection() const;
void setConnection(NeoChatConnection *connection);
[[nodiscard]] QString currentServer() const;
[[nodiscard]] bool hasCurrentServer() const;
[[nodiscard]] QString url() const;
void setUrl(const QString &url);
@@ -87,7 +73,6 @@ public:
Q_SIGNALS:
void connectionChanged();
void currentServerChanged();
void urlChanged();
void statusChanged();

View File

@@ -6,8 +6,10 @@
#include <Quotient/jobs/basejob.h>
#include <Quotient/omittable.h>
#include "definitions.h"
class NeochatAdd3PIdJob : public Quotient::BaseJob
{
public:
explicit NeochatAdd3PIdJob(const QString &clientSecret, const QString &sid, const Quotient::Omittable<QJsonObject> &auth = Quotient::none);
explicit NeochatAdd3PIdJob(const QString &clientSecret, const QString &sid, const Omittable<QJsonObject> &auth = {});
};

View File

@@ -6,8 +6,10 @@
#include <Quotient/jobs/basejob.h>
#include <Quotient/omittable.h>
#include "definitions.h"
class NeochatChangePasswordJob : public Quotient::BaseJob
{
public:
explicit NeochatChangePasswordJob(const QString &newPassword, bool logoutDevices, const Quotient::Omittable<QJsonObject> &auth = Quotient::none);
explicit NeochatChangePasswordJob(const QString &newPassword, bool logoutDevices, const Omittable<QJsonObject> &auth = {});
};

View File

@@ -6,8 +6,10 @@
#include <Quotient/jobs/basejob.h>
#include <Quotient/omittable.h>
#include "definitions.h"
class NeoChatDeactivateAccountJob : public Quotient::BaseJob
{
public:
explicit NeoChatDeactivateAccountJob(const Quotient::Omittable<QJsonObject> &auth = Quotient::none);
explicit NeoChatDeactivateAccountJob(const Omittable<QJsonObject> &auth = {});
};

View File

@@ -6,8 +6,10 @@
#include <Quotient/jobs/basejob.h>
#include <Quotient/omittable.h>
#include "definitions.h"
class NeochatDeleteDeviceJob : public Quotient::BaseJob
{
public:
explicit NeochatDeleteDeviceJob(const QString &deviceId, const Quotient::Omittable<QJsonObject> &auth = Quotient::none);
explicit NeochatDeleteDeviceJob(const QString &deviceId, const Omittable<QJsonObject> &auth = {});
};

View File

@@ -54,14 +54,19 @@ void LoginHelper::init()
m_connection = new NeoChatConnection();
}
m_connection->resolveServer(m_matrixId);
connectSingleShot(m_connection.get(), &Connection::loginFlowsChanged, this, [this]() {
setHomeserverReachable(true);
m_testing = false;
Q_EMIT testingChanged();
m_supportsSso = m_connection->supportsSso();
m_supportsPassword = m_connection->supportsPasswordAuth();
Q_EMIT loginFlowsChanged();
});
connect(
m_connection.get(),
&Connection::loginFlowsChanged,
this,
[this]() {
setHomeserverReachable(true);
m_testing = false;
Q_EMIT testingChanged();
m_supportsSso = m_connection->supportsSso();
m_supportsPassword = m_connection->supportsPasswordAuth();
Q_EMIT loginFlowsChanged();
},
Qt::SingleShotConnection);
});
connect(m_connection, &Connection::connected, this, [this] {
Q_EMIT connected();
@@ -100,9 +105,14 @@ void LoginHelper::init()
Q_EMIT Controller::instance().errorOccured(i18n("Network Error"), std::move(error));
});
connectSingleShot(m_connection.get(), &Connection::syncDone, this, [this]() {
Q_EMIT loaded();
});
connect(
m_connection.get(),
&Connection::syncDone,
this,
[this]() {
Q_EMIT loaded();
},
Qt::SingleShotConnection);
}
void LoginHelper::setHomeserverReachable(bool reachable)
@@ -182,11 +192,16 @@ QUrl LoginHelper::ssoUrl() const
void LoginHelper::loginWithSso()
{
m_connection->resolveServer(m_matrixId);
connectSingleShot(m_connection.get(), &Connection::loginFlowsChanged, this, [this]() {
SsoSession *session = m_connection->prepareForSso(m_deviceName);
m_ssoUrl = session->ssoUrl();
Q_EMIT ssoUrlChanged();
});
connect(
m_connection.get(),
&Connection::loginFlowsChanged,
this,
[this]() {
SsoSession *session = m_connection->prepareForSso(m_deviceName);
m_ssoUrl = session->ssoUrl();
Q_EMIT ssoUrlChanged();
},
Qt::SingleShotConnection);
}
bool LoginHelper::testing() const

View File

@@ -13,7 +13,7 @@ LoginStep {
id: root
FormCard.FormTextDelegate {
text: i18n("Please wait. This might take a little while.")
text: i18n("Please wait while your messages are loaded from the server. This might take a little while.")
}
FormCard.AbstractFormDelegate {
contentItem: QQC2.BusyIndicator {}

View File

@@ -92,7 +92,7 @@ FormCard.FormCardPage {
}
QQC2.ToolButton {
text: i18nc("@action:button", "Remove this account")
text: i18nc("@action:button", "Log out of this account")
icon.name: "edit-delete-remove"
onClicked: Controller.removeConnection(modelData)
display: QQC2.Button.IconOnly

View File

@@ -202,11 +202,11 @@ QList<ActionsModel::Action> actions{
Q_EMIT room->showMessage(NeoChatRoom::Info, i18nc("<user> is banned from this room.", "%1 is banned from this room.", text));
return QString();
}
if (room->localUser()->id() == text) {
if (room->localMember().id() == text) {
Q_EMIT room->showMessage(NeoChatRoom::Positive, i18n("You are already in this room."));
return QString();
}
if (room->users().contains(room->user(text))) {
if (room->memberIds().contains(text)) {
Q_EMIT room->showMessage(NeoChatRoom::Info, i18nc("<user> is already in this room.", "%1 is already in this room.", text));
return QString();
}
@@ -359,7 +359,7 @@ QList<ActionsModel::Action> actions{
Q_EMIT room->showMessage(NeoChatRoom::Info, i18nc("<username> is already ignored.", "%1 is already ignored.", text));
return QString();
}
room->connection()->addToIgnoredUsers(room->connection()->user(text));
room->connection()->addToIgnoredUsers(text);
Q_EMIT room->showMessage(NeoChatRoom::Positive, i18nc("<username> is now ignored", "%1 is now ignored.", text));
return QString();
},
@@ -382,7 +382,7 @@ QList<ActionsModel::Action> actions{
Q_EMIT room->showMessage(NeoChatRoom::Info, i18nc("<username> is not ignored.", "%1 is not ignored.", text));
return QString();
}
room->connection()->removeFromIgnoredUsers(room->connection()->user(text));
room->connection()->removeFromIgnoredUsers(text);
Q_EMIT room->showMessage(NeoChatRoom::Positive, i18nc("<username> is no longer ignored.", "%1 is no longer ignored.", text));
return QString();
},
@@ -431,11 +431,11 @@ QList<ActionsModel::Action> actions{
if (!plEvent) {
return QString();
}
if (plEvent->ban() > plEvent->powerLevelForUser(room->localUser()->id())) {
if (plEvent->ban() > plEvent->powerLevelForUser(room->localMember().id())) {
Q_EMIT room->showMessage(NeoChatRoom::Error, i18n("You are not allowed to ban users from this room."));
return QString();
}
if (plEvent->powerLevelForUser(room->localUser()->id()) <= plEvent->powerLevelForUser(parts[0])) {
if (plEvent->powerLevelForUser(room->localMember().id()) <= plEvent->powerLevelForUser(parts[0])) {
Q_EMIT room->showMessage(
NeoChatRoom::Error,
i18nc("You are not allowed to ban <username> from this room.", "You are not allowed to ban %1 from this room.", parts[0]));
@@ -464,7 +464,7 @@ QList<ActionsModel::Action> actions{
if (!plEvent) {
return QString();
}
if (plEvent->ban() > plEvent->powerLevelForUser(room->localUser()->id())) {
if (plEvent->ban() > plEvent->powerLevelForUser(room->localMember().id())) {
Q_EMIT room->showMessage(NeoChatRoom::Error, i18n("You are not allowed to unban users from this room."));
return QString();
}
@@ -495,7 +495,7 @@ QList<ActionsModel::Action> actions{
i18nc("'<text>' does not look like a matrix id.", "'%1' does not look like a matrix id.", parts[0]));
return QString();
}
if (parts[0] == room->localUser()->id()) {
if (parts[0] == room->localMember().id()) {
Q_EMIT room->showMessage(NeoChatRoom::Error, i18n("You cannot kick yourself from the room."));
return QString();
}
@@ -508,11 +508,11 @@ QList<ActionsModel::Action> actions{
return QString();
}
auto kick = plEvent->kick();
if (plEvent->powerLevelForUser(room->localUser()->id()) < kick) {
if (plEvent->powerLevelForUser(room->localMember().id()) < kick) {
Q_EMIT room->showMessage(NeoChatRoom::Error, i18n("You are not allowed to kick users from this room."));
return QString();
}
if (plEvent->powerLevelForUser(room->localUser()->id()) <= plEvent->powerLevelForUser(parts[0])) {
if (plEvent->powerLevelForUser(room->localMember().id()) <= plEvent->powerLevelForUser(parts[0])) {
Q_EMIT room->showMessage(
NeoChatRoom::Error,
i18nc("You are not allowed to kick <username> from this room", "You are not allowed to kick %1 from this room.", parts[0]));

View File

@@ -63,7 +63,7 @@ void LocationsModel::addLocation(const RoomMessageEvent *event)
.latitude = latitude,
.longitude = longitude,
.content = event->contentJson(),
.author = m_room->user(event->senderId()),
.author = event->senderId(),
};
endInsertRows();
}

View File

@@ -57,7 +57,7 @@ private:
float latitude;
float longitude;
QJsonObject content;
Quotient::User *author;
QString author;
};
QList<LocationData> m_locations;
void addLocation(const Quotient::RoomMessageEvent *event);

View File

@@ -11,6 +11,7 @@
#include <Quotient/events/stickerevent.h>
#include <KLocalizedString>
#include <Quotient/qt_connection_util.h>
#ifndef Q_OS_ANDROID
#include <KSyntaxHighlighting/Definition>
@@ -29,95 +30,124 @@
using namespace Quotient;
MessageContentModel::MessageContentModel(const Quotient::RoomEvent *event, NeoChatRoom *room)
MessageContentModel::MessageContentModel(NeoChatRoom *room, const Quotient::RoomEvent *event, bool isReply)
: QAbstractListModel(nullptr)
, m_room(room)
, m_eventId(event != nullptr ? event->id() : QString())
, m_event(event)
, m_isReply(isReply)
{
if (m_room != nullptr) {
connect(m_room, &NeoChatRoom::pendingEventAboutToMerge, this, [this](Quotient::RoomEvent *serverEvent) {
if (m_room != nullptr && m_event != nullptr) {
if (m_event->id() == serverEvent->id()) {
beginResetModel();
m_event = serverEvent;
endResetModel();
}
}
});
connect(m_room, &NeoChatRoom::replacedEvent, this, [this](const Quotient::RoomEvent *newEvent) {
if (m_room != nullptr && m_event != nullptr) {
if (m_event->id() == newEvent->id()) {
beginResetModel();
m_event = newEvent;
endResetModel();
}
}
});
connect(m_room, &NeoChatRoom::replyLoaded, this, [this](const QString &eventId, const QString &replyId) {
Q_UNUSED(eventId)
if (m_event != nullptr && m_room != nullptr) {
const auto eventHandler = EventHandler(m_room, m_event);
if (replyId == eventHandler.getReplyId()) {
// HACK: Because DelegateChooser can't switch the delegate on dataChanged it has to think there is a new delegate.
beginResetModel();
m_components[0].type = MessageComponentType::Reply;
endResetModel();
}
}
});
connect(m_room, &NeoChatRoom::newFileTransfer, this, [this](const QString &eventId) {
if (m_event != nullptr && eventId == m_event->id()) {
Q_EMIT dataChanged(index(0), index(rowCount() - 1), {FileTransferInfoRole});
}
});
connect(m_room, &NeoChatRoom::fileTransferProgress, this, [this](const QString &eventId) {
if (m_event != nullptr && eventId == m_event->id()) {
Q_EMIT dataChanged(index(0), index(rowCount() - 1), {FileTransferInfoRole});
}
});
connect(m_room, &NeoChatRoom::fileTransferCompleted, this, [this](const QString &eventId) {
if (m_event != nullptr && eventId == m_event->id()) {
updateComponents();
Q_EMIT dataChanged(index(0), index(rowCount() - 1), {FileTransferInfoRole});
initializeModel();
}
QString mxcUrl;
if (auto event = eventCast<const Quotient::RoomMessageEvent>(m_event)) {
if (event->hasFileContent()) {
mxcUrl = event->content()->fileInfo()->url().toString();
}
} else if (auto event = eventCast<const Quotient::StickerEvent>(m_event)) {
mxcUrl = event->image().fileInfo()->url().toString();
}
if (mxcUrl.isEmpty()) {
return;
}
auto localPath = m_room->fileTransferInfo(m_event->id()).localPath.toLocalFile();
auto config = KSharedConfig::openStateConfig(QStringLiteral("neochatdownloads"))->group(QStringLiteral("downloads"));
config.writePathEntry(mxcUrl.mid(6), localPath);
}
});
connect(m_room, &NeoChatRoom::fileTransferFailed, this, [this](const QString &eventId) {
if (m_event != nullptr && eventId == m_event->id()) {
MessageContentModel::MessageContentModel(NeoChatRoom *room, const QString &eventId, bool isReply)
: QAbstractListModel(nullptr)
, m_room(room)
, m_eventId(eventId)
, m_isReply(isReply)
{
initializeModel();
}
void MessageContentModel::initializeModel()
{
Q_ASSERT(m_room != nullptr);
// Allow making a model for an event that is being downloaded but will appear later
// e.g. a reply, but we need an ID to know when it has arrived.
Q_ASSERT(!m_eventId.isEmpty());
Quotient::connectUntil(m_room.get(), &NeoChatRoom::extraEventLoaded, this, [this](const QString &eventId) {
if (m_room != nullptr) {
if (eventId == m_eventId) {
m_event = m_room->getEvent(eventId);
Q_EMIT eventUpdated();
updateReplyModel();
updateComponents();
Q_EMIT dataChanged(index(0), index(rowCount() - 1), {FileTransferInfoRole});
return true;
}
});
connect(m_room->editCache(), &ChatBarCache::relationIdChanged, this, [this](const QString &oldEventId, const QString &newEventId) {
if (m_event != nullptr && (oldEventId == m_event->id() || newEventId == m_event->id())) {
// HACK: Because DelegateChooser can't switch the delegate on dataChanged it has to think there is a new delegate.
beginResetModel();
updateComponents(newEventId == m_event->id());
endResetModel();
}
});
connect(m_room, &NeoChatRoom::urlPreviewEnabledChanged, this, [this]() {
updateComponents();
});
connect(NeoChatConfig::self(), &NeoChatConfig::ShowLinkPreviewChanged, this, [this]() {
updateComponents();
});
}
return false;
});
if (m_event == nullptr) {
m_room->downloadEventFromServer(m_eventId);
}
connect(m_room, &NeoChatRoom::pendingEventAboutToMerge, this, [this](Quotient::RoomEvent *serverEvent) {
if (m_room != nullptr && m_event != nullptr) {
if (m_event->id() == serverEvent->id()) {
beginResetModel();
m_event = serverEvent;
Q_EMIT eventUpdated();
endResetModel();
}
}
});
connect(m_room, &NeoChatRoom::replacedEvent, this, [this](const Quotient::RoomEvent *newEvent) {
if (m_room != nullptr && m_event != nullptr) {
if (m_event->id() == newEvent->id()) {
beginResetModel();
m_event = newEvent;
Q_EMIT eventUpdated();
endResetModel();
}
}
});
connect(m_room, &NeoChatRoom::newFileTransfer, this, [this](const QString &eventId) {
if (m_event != nullptr && eventId == m_event->id()) {
Q_EMIT dataChanged(index(0), index(rowCount() - 1), {FileTransferInfoRole});
}
});
connect(m_room, &NeoChatRoom::fileTransferProgress, this, [this](const QString &eventId) {
if (m_event != nullptr && eventId == m_event->id()) {
Q_EMIT dataChanged(index(0), index(rowCount() - 1), {FileTransferInfoRole});
}
});
connect(m_room, &NeoChatRoom::fileTransferCompleted, this, [this](const QString &eventId) {
if (m_event != nullptr && eventId == m_event->id()) {
updateComponents();
Q_EMIT dataChanged(index(0), index(rowCount() - 1), {FileTransferInfoRole});
QString mxcUrl;
if (auto event = eventCast<const Quotient::RoomMessageEvent>(m_event)) {
if (event->hasFileContent()) {
mxcUrl = event->content()->fileInfo()->url().toString();
}
} else if (auto event = eventCast<const Quotient::StickerEvent>(m_event)) {
mxcUrl = event->image().fileInfo()->url().toString();
}
if (mxcUrl.isEmpty()) {
return;
}
auto localPath = m_room->fileTransferInfo(m_event->id()).localPath.toLocalFile();
auto config = KSharedConfig::openStateConfig(QStringLiteral("neochatdownloads"))->group(QStringLiteral("downloads"));
config.writePathEntry(mxcUrl.mid(6), localPath);
}
});
connect(m_room, &NeoChatRoom::fileTransferFailed, this, [this](const QString &eventId) {
if (m_event != nullptr && eventId == m_event->id()) {
updateComponents();
Q_EMIT dataChanged(index(0), index(rowCount() - 1), {FileTransferInfoRole});
}
});
connect(m_room->editCache(), &ChatBarCache::relationIdChanged, this, [this](const QString &oldEventId, const QString &newEventId) {
if (m_event != nullptr && (oldEventId == m_event->id() || newEventId == m_event->id())) {
// HACK: Because DelegateChooser can't switch the delegate on dataChanged it has to think there is a new delegate.
beginResetModel();
updateComponents(newEventId == m_event->id());
endResetModel();
}
});
connect(m_room, &NeoChatRoom::urlPreviewEnabledChanged, this, [this]() {
updateComponents();
});
connect(NeoChatConfig::self(), &NeoChatConfig::ShowLinkPreviewChanged, this, [this]() {
updateComponents();
});
if (m_event != nullptr) {
updateReplyModel();
}
updateComponents();
}
@@ -138,6 +168,12 @@ QVariant MessageContentModel::data(const QModelIndex &index, int role) const
const auto component = m_components[index.row()];
if (role == DisplayRole) {
if (component.type == MessageComponentType::Loading && m_isReply) {
return i18n("Loading reply");
}
if (m_event == nullptr) {
return QString();
}
if (m_event->isRedacted()) {
auto reason = m_event->redactedBecause()->reason();
return (reason.isEmpty()) ? i18n("<i>[This message was deleted]</i>")
@@ -184,20 +220,14 @@ QVariant MessageContentModel::data(const QModelIndex &index, int role) const
if (role == IsReplyRole) {
return eventHandler.hasReply();
}
if (role == ReplyComponentType) {
return eventHandler.replyMessageComponentType();
}
if (role == ReplyEventIdRole) {
return eventHandler.getReplyId();
}
if (role == ReplyAuthorRole) {
return eventHandler.getReplyAuthor();
}
if (role == ReplyDisplayRole) {
return eventHandler.getReplyRichBody();
}
if (role == ReplyMediaInfoRole) {
return eventHandler.getReplyMediaInfo();
if (role == ReplyContentModelRole) {
return QVariant::fromValue<MessageContentModel *>(m_replyModel);
}
if (role == LinkPreviewerRole) {
if (component.type == MessageComponentType::LinkPreview) {
@@ -233,11 +263,9 @@ QHash<int, QByteArray> MessageContentModel::roleNames() const
roles[AssetRole] = "asset";
roles[PollHandlerRole] = "pollHandler";
roles[IsReplyRole] = "isReply";
roles[ReplyComponentType] = "replyComponentType";
roles[ReplyEventIdRole] = "replyEventId";
roles[ReplyAuthorRole] = "replyAuthor";
roles[ReplyDisplayRole] = "replyDisplay";
roles[ReplyMediaInfoRole] = "replyMediaInfo";
roles[ReplyContentModelRole] = "replyContentModel";
roles[LinkPreviewerRole] = "linkPreviewer";
return roles;
}
@@ -247,6 +275,12 @@ void MessageContentModel::updateComponents(bool isEditing)
beginResetModel();
m_components.clear();
if (m_event == nullptr) {
m_components += MessageComponent{MessageComponentType::Loading, QString(), {}};
endResetModel();
return;
}
if (eventCast<const Quotient::RoomMessageEvent>(m_event)
&& eventCast<const Quotient::RoomMessageEvent>(m_event)->rawMsgtype() == QStringLiteral("m.key.verification.request")) {
m_components += MessageComponent{MessageComponentType::Verification, QString(), {}};
@@ -260,19 +294,14 @@ void MessageContentModel::updateComponents(bool isEditing)
return;
}
EventHandler eventHandler(m_room, m_event);
if (eventHandler.hasReply()) {
if (m_room->findInTimeline(eventHandler.getReplyId()) == m_room->historyEdge()) {
m_components += MessageComponent{MessageComponentType::ReplyLoad, QString(), {}};
m_room->loadReply(m_event->id(), eventHandler.getReplyId());
} else {
m_components += MessageComponent{MessageComponentType::Reply, QString(), {}};
}
if (m_replyModel != nullptr) {
m_components += MessageComponent{MessageComponentType::Reply, QString(), {}};
}
if (isEditing) {
m_components += MessageComponent{MessageComponentType::Edit, QString(), {}};
} else {
EventHandler eventHandler(m_room, m_event);
m_components.append(componentsForType(eventHandler.messageComponentType()));
}
@@ -283,6 +312,29 @@ void MessageContentModel::updateComponents(bool isEditing)
endResetModel();
}
void MessageContentModel::updateReplyModel()
{
if (m_event == nullptr || m_replyModel != nullptr || m_isReply) {
return;
}
EventHandler eventHandler(m_room, m_event);
if (!eventHandler.hasReply()) {
return;
}
const auto replyEvent = m_room->findInTimeline(eventHandler.getReplyId());
if (replyEvent == m_room->historyEdge()) {
m_replyModel = new MessageContentModel(m_room, eventHandler.getReplyId(), true);
} else {
m_replyModel = new MessageContentModel(m_room, replyEvent->get(), true);
}
connect(m_replyModel, &MessageContentModel::eventUpdated, this, [this]() {
Q_EMIT dataChanged(index(0), index(0), {ReplyAuthorRole});
});
}
QList<MessageComponent> MessageContentModel::componentsForType(MessageComponentType::Type type)
{
switch (type) {

View File

@@ -58,17 +58,16 @@ public:
PollHandlerRole, /**< The PollHandler for the event, if any. */
IsReplyRole, /**< Is the message a reply to another event. */
ReplyComponentType, /**< The type of component to visualise the reply message. */
ReplyEventIdRole, /**< The matrix ID of the message that was replied to. */
ReplyAuthorRole, /**< The author of the event that was replied to. */
ReplyDisplayRole, /**< The body of the message that was replied to. */
ReplyMediaInfoRole, /**< The media info of the message that was replied to. */
ReplyContentModelRole, /**< The MessageContentModel for the reply event. */
LinkPreviewerRole, /**< The link preview details. */
};
Q_ENUM(Roles)
explicit MessageContentModel(const Quotient::RoomEvent *event, NeoChatRoom *room);
explicit MessageContentModel(NeoChatRoom *room, const Quotient::RoomEvent *event, bool isReply = false);
MessageContentModel(NeoChatRoom *room, const QString &eventId, bool isReply = false);
/**
* @brief Get the given role value at the given index.
@@ -98,13 +97,24 @@ public:
*/
Q_INVOKABLE void closeLinkPreview(int row);
Q_SIGNALS:
void eventUpdated();
private:
QPointer<NeoChatRoom> m_room;
QString m_eventId;
const Quotient::RoomEvent *m_event = nullptr;
bool m_isReply;
void initializeModel();
QList<MessageComponent> m_components;
void updateComponents(bool isEditing = false);
QPointer<MessageContentModel> m_replyModel;
void updateReplyModel();
ItineraryModel *m_itineraryModel = nullptr;
QList<MessageComponent> componentsForType(MessageComponentType::Type type);

View File

@@ -222,7 +222,7 @@ void MessageEventModel::setRoom(NeoChatRoom *room)
beginResetModel();
endResetModel();
});
qCDebug(MessageEvent) << "Connected to room" << room->id() << "as" << room->localUser()->id();
qCDebug(MessageEvent) << "Connected to room" << room->id() << "as" << room->localMember().id();
} else {
lastReadEventId.clear();
}
@@ -440,12 +440,12 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
}
if (role == ContentModelRole) {
if (!evt.isStateEvent()) {
return QVariant::fromValue<MessageContentModel *>(new MessageContentModel(&evt, m_currentRoom));
if (!evt.isStateEvent() && !evt.id().isEmpty()) {
return QVariant::fromValue<MessageContentModel *>(new MessageContentModel(m_currentRoom, &evt));
}
if (evt.isStateEvent()) {
if (evt.matrixType() == QStringLiteral("org.matrix.msc3672.beacon_info")) {
return QVariant::fromValue<MessageContentModel *>(new MessageContentModel(&evt, m_currentRoom));
return QVariant::fromValue<MessageContentModel *>(new MessageContentModel(m_currentRoom, &evt));
}
}
return {};
@@ -592,7 +592,7 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
}
if (role == IsEditableRole) {
return eventHandler.messageComponentType() == MessageComponentType::Text && evt.senderId() == m_currentRoom->localUser()->id();
return eventHandler.messageComponentType() == MessageComponentType::Text && evt.senderId() == m_currentRoom->localMember().id();
}
return {};

View File

@@ -116,7 +116,7 @@ void NotificationsModel::loadData()
if (!room) {
continue;
}
auto u = room->memberAvatarUrl(authorId);
auto u = room->member(authorId).avatarUrl();
auto avatar = u.isEmpty() ? QUrl() : connection()->makeMediaUrl(u);
const auto &authorAvatar = avatar.isValid() && avatar.scheme() == QStringLiteral("mxc") ? avatar : QUrl();
@@ -125,9 +125,9 @@ void NotificationsModel::loadData()
beginInsertRows({}, m_notifications.length(), m_notifications.length());
m_notifications += Notification{
.roomId = notification.roomId,
.text = room->htmlSafeMemberName(authorId) + (roomEvent->is<StateEvent>() ? QStringLiteral(" ") : QStringLiteral(": "))
.text = room->member(authorId).htmlSafeDisplayName() + (roomEvent->is<StateEvent>() ? QStringLiteral(" ") : QStringLiteral(": "))
+ eventHandler.getPlainBody(true),
.authorName = room->htmlSafeMemberName(authorId),
.authorName = room->member(authorId).htmlSafeDisplayName(),
.authorAvatar = authorAvatar,
.eventId = roomEvent->id(),
.roomDisplayName = room->displayName(),

View File

@@ -92,7 +92,7 @@ QVariant ReactionModel::data(const QModelIndex &index, int role) const
if (role == HasLocalUser) {
for (auto author : reaction.authors) {
if (author.toMap()[QStringLiteral("id")] == m_room->localUser()->id()) {
if (author.toMap()[QStringLiteral("id")] == m_room->localMember().id()) {
return true;
}
}
@@ -121,13 +121,13 @@ void ReactionModel::updateReactions()
return;
};
QMap<QString, QList<Quotient::User *>> reactions = {};
QMap<QString, QList<Quotient::RoomMember>> reactions = {};
for (const auto &a : annotations) {
if (a->isRedacted()) { // Just in case?
continue;
}
if (const auto &e = eventCast<const Quotient::ReactionEvent>(a)) {
reactions[e->key()].append(m_room->user(e->senderId()));
reactions[e->key()].append(m_room->member(e->senderId()));
if (e->contentJson()[QStringLiteral("shortcode")].toString().length()) {
m_shortcodes[e->key()] = e->contentJson()[QStringLiteral("shortcode")].toString().toHtmlEscaped();
}

View File

@@ -44,7 +44,7 @@ void SearchModel::search()
}
RoomEventFilter filter;
filter.unreadThreadNotifications = none;
filter.unreadThreadNotifications = {};
filter.lazyLoadMembers = true;
filter.includeRedundantMembers = false;
filter.notRooms = QStringList();
@@ -58,7 +58,7 @@ void SearchModel::search()
.orderBy = "recent"_ls,
.eventContext = SearchJob::IncludeEventContext{3, 3, true},
.includeState = false,
.groupings = none,
.groupings = {},
};
@@ -113,15 +113,18 @@ QVariant SearchModel::data(const QModelIndex &index, int role) const
return eventHandler.threadRoot();
case ContentModelRole: {
if (!event.isStateEvent()) {
return QVariant::fromValue<MessageContentModel *>(new MessageContentModel(&event, m_room));
return QVariant::fromValue<MessageContentModel *>(new MessageContentModel(m_room, &event));
}
if (event.isStateEvent()) {
if (event.matrixType() == QStringLiteral("org.matrix.msc3672.beacon_info")) {
return QVariant::fromValue<MessageContentModel *>(new MessageContentModel(&event, m_room));
return QVariant::fromValue<MessageContentModel *>(new MessageContentModel(m_room, &event));
}
}
return {};
}
case IsEditableRole: {
return false;
}
}
return DelegateType::Message;
}
@@ -158,6 +161,7 @@ QHash<int, QByteArray> SearchModel::roleNames() const
{IsThreadedRole, "isThreaded"},
{ThreadRootRole, "threadRoot"},
{ContentModelRole, "contentModel"},
{IsEditableRole, "isEditable"},
};
}

View File

@@ -71,6 +71,7 @@ public:
IsThreadedRole,
ThreadRootRole,
ContentModelRole,
IsEditableRole,
};
Q_ENUM(Roles)
explicit SearchModel(QObject *parent = nullptr);

View File

@@ -6,6 +6,7 @@
#include <Quotient/jobs/basejob.h>
#include <Quotient/room.h>
#include "definitions.h"
#include "neochatconnection.h"
#include "neochatroom.h"
@@ -87,7 +88,7 @@ void SpaceChildrenModel::refreshModel()
m_rootItem =
new SpaceTreeItem(dynamic_cast<NeoChatConnection *>(m_space->connection()), nullptr, m_space->id(), m_space->displayName(), m_space->canonicalAlias());
endResetModel();
auto job = m_space->connection()->callApi<Quotient::GetSpaceHierarchyJob>(m_space->id(), Quotient::none, Quotient::none, 1);
auto job = m_space->connection()->callApi<Quotient::GetSpaceHierarchyJob>(m_space->id(), quotientNone, quotientNone, 1);
m_currentJobs.append(job);
connect(job, &Quotient::BaseJob::success, this, [this, job]() {
insertChildren(job->rooms());
@@ -136,7 +137,7 @@ void SpaceChildrenModel::insertChildren(std::vector<Quotient::GetSpaceHierarchyJ
}
}
if (children[i].childrenState.size() > 0) {
auto job = m_space->connection()->callApi<Quotient::GetSpaceHierarchyJob>(children[i].roomId, Quotient::none, Quotient::none, 1);
auto job = m_space->connection()->callApi<Quotient::GetSpaceHierarchyJob>(children[i].roomId, quotientNone, quotientNone, 1);
m_currentJobs.append(job);
connect(job, &Quotient::BaseJob::success, this, [this, parent, insertRow, job]() {
insertChildren(job->rooms(), index(insertRow, 0, parent));

View File

@@ -3,6 +3,12 @@
#include "threepidmodel.h"
#include <QCryptographicHash>
#include <QNetworkReply>
#include <Quotient/csapi/openid.h>
#include <Quotient/networkaccessmanager.h>
#include "neochatconnection.h"
ThreePIdModel::ThreePIdModel(NeoChatConnection *connection)
@@ -30,6 +36,9 @@ QVariant ThreePIdModel::data(const QModelIndex &index, int role) const
if (role == MediumRole) {
return m_threePIds.at(index.row()).medium;
}
if (role == IsBoundRole) {
return m_bindings.contains(m_threePIds.at(index.row()).address);
}
return {};
}
@@ -45,6 +54,7 @@ QHash<int, QByteArray> ThreePIdModel::roleNames() const
return {
{AddressRole, QByteArrayLiteral("address")},
{MediumRole, QByteArrayLiteral("medium")},
{IsBoundRole, QByteArrayLiteral("isBound")},
};
}
@@ -57,8 +67,80 @@ void ThreePIdModel::refreshModel()
beginResetModel();
m_threePIds = threePIdJob->threepids();
endResetModel();
refreshBindStatus();
});
}
}
void ThreePIdModel::refreshBindStatus()
{
const auto connection = dynamic_cast<NeoChatConnection *>(this->parent());
if (connection == nullptr || !connection->hasIdentityServer()) {
return;
}
const auto openIdJob = connection->callApi<Quotient::RequestOpenIdTokenJob>(connection->userId());
connect(openIdJob, &Quotient::BaseJob::success, this, [this, connection, openIdJob]() {
const auto requestUrl = QUrl(connection->identityServer().toString() + QStringLiteral("/_matrix/identity/v2/account/register"));
if (!(requestUrl.scheme() == QStringLiteral("https") || requestUrl.scheme() == QStringLiteral("http"))) {
return;
}
QNetworkRequest request(requestUrl);
auto newRequest = Quotient::NetworkAccessManager::instance()->post(request, QJsonDocument(openIdJob->jsonData()).toJson());
connect(newRequest, &QNetworkReply::finished, this, [this, connection, newRequest]() {
QJsonObject replyJson = QJsonDocument::fromJson(newRequest->readAll()).object();
const auto identityServerToken = replyJson[QLatin1String("token")].toString();
const auto requestUrl = QUrl(connection->identityServer().toString() + QStringLiteral("/_matrix/identity/v2/hash_details"));
if (!(requestUrl.scheme() == QStringLiteral("https") || requestUrl.scheme() == QStringLiteral("http"))) {
return;
}
QNetworkRequest hashRequest(requestUrl);
hashRequest.setRawHeader("Authorization", "Bearer " + identityServerToken.toLatin1());
auto hashReply = Quotient::NetworkAccessManager::instance()->get(hashRequest);
connect(hashReply, &QNetworkReply::finished, this, [this, connection, identityServerToken, hashReply]() {
QJsonObject replyJson = QJsonDocument::fromJson(hashReply->readAll()).object();
const auto lookupPepper = replyJson[QLatin1String("lookup_pepper")].toString();
const auto requestUrl = QUrl(connection->identityServer().toString() + QStringLiteral("/_matrix/identity/v2/lookup"));
if (!(requestUrl.scheme() == QStringLiteral("https") || requestUrl.scheme() == QStringLiteral("http"))) {
return;
}
QNetworkRequest lookupRequest(requestUrl);
lookupRequest.setRawHeader("Authorization", "Bearer " + identityServerToken.toLatin1());
QJsonObject requestData = {
{QLatin1String("algorithm"), QLatin1String("none")},
{QLatin1String("pepper"), lookupPepper},
};
QJsonArray idLookups;
for (const auto &id : m_threePIds) {
idLookups += QStringLiteral("%1 %2").arg(id.address, id.medium);
}
requestData[QLatin1String("addresses")] = idLookups;
auto lookupReply = Quotient::NetworkAccessManager::instance()->post(lookupRequest, QJsonDocument(requestData).toJson(QJsonDocument::Compact));
connect(lookupReply, &QNetworkReply::finished, this, [this, connection, lookupReply]() {
beginResetModel();
m_bindings.clear();
QJsonObject mappings = QJsonDocument::fromJson(lookupReply->readAll()).object()[QLatin1String("mappings")].toObject();
for (const auto &id : mappings.keys()) {
if (mappings[id] == connection->userId()) {
m_bindings += id.section(u' ', 0, 0);
}
}
endResetModel();
});
});
});
});
}
#include "moc_threepidmodel.cpp"

View File

@@ -28,6 +28,7 @@ public:
enum EventRoles {
AddressRole = Qt::DisplayRole, /**< The third-party identifier address. */
MediumRole, /**< The medium of the third-party identifier. One of: [email, msisdn]. */
IsBoundRole, /**< Whether the 3PID is bound to the current identity server. */
};
explicit ThreePIdModel(NeoChatConnection *parent);
@@ -57,4 +58,8 @@ public:
private:
QVector<Quotient::GetAccount3PIDsJob::ThirdPartyIdentifier> m_threePIds;
QList<QString> m_bindings;
void refreshBindStatus();
};

View File

@@ -5,7 +5,9 @@
#include <QGuiApplication>
#include <Quotient/avatar.h>
#include <Quotient/events/roompowerlevelsevent.h>
#include <Quotient/room.h>
#include "enums/powerlevel.h"
#include "neochatroom.h"
@@ -26,18 +28,26 @@ void UserListModel::setRoom(NeoChatRoom *room)
if (m_currentRoom) {
m_currentRoom->disconnect(this);
m_currentRoom->connection()->disconnect(this);
}
m_currentRoom = room;
if (m_currentRoom) {
connect(m_currentRoom, &Room::userAdded, this, &UserListModel::userAdded);
connect(m_currentRoom, &Room::userRemoved, this, &UserListModel::userRemoved);
connect(m_currentRoom, &Room::memberAboutToRename, this, &UserListModel::userRemoved);
connect(m_currentRoom, &Room::memberRenamed, this, &UserListModel::userAdded);
connect(m_currentRoom, &Room::changed, this, &UserListModel::refreshAllUsers);
connect(m_currentRoom, &Room::memberJoined, this, &UserListModel::memberJoined);
connect(m_currentRoom, &Room::memberLeft, this, &UserListModel::memberLeft);
connect(m_currentRoom, &Room::memberNameUpdated, this, [this](RoomMember member) {
refreshMember(member, {DisplayNameRole});
});
connect(m_currentRoom, &Room::memberAvatarUpdated, this, [this](RoomMember member) {
refreshMember(member, {AvatarRole});
});
connect(m_currentRoom, &Room::changed, this, &UserListModel::refreshAllMembers);
connect(m_currentRoom->connection(), &Connection::loggedOut, this, [this]() {
setRoom(nullptr);
});
}
refreshAllUsers();
refreshAllMembers();
Q_EMIT roomChanged();
}
@@ -46,44 +56,36 @@ NeoChatRoom *UserListModel::room() const
return m_currentRoom;
}
Quotient::User *UserListModel::userAt(QModelIndex index) const
{
if (index.row() < 0 || index.row() >= m_users.size()) {
return nullptr;
}
return m_users.at(index.row());
}
QVariant UserListModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid()) {
return QVariant();
}
if (index.row() >= m_users.count()) {
if (index.row() >= m_members.count()) {
qDebug() << "UserListModel, something's wrong: index.row() >= "
"users.count()";
return {};
}
auto user = m_users.at(index.row());
auto member = m_members.at(index.row());
if (role == DisplayNameRole) {
return user->displayname(m_currentRoom);
return m_currentRoom->member(member).disambiguatedName();
}
if (role == UserIdRole) {
return user->id();
return member;
}
if (role == AvatarRole) {
return m_currentRoom->avatarForMember(user);
return m_currentRoom->memberAvatar(member).url();
}
if (role == ObjectRole) {
return QVariant::fromValue(user);
return QVariant::fromValue(member);
}
if (role == PowerLevelRole) {
auto plEvent = m_currentRoom->currentState().get<RoomPowerLevelsEvent>();
if (!plEvent) {
return 0;
}
return plEvent->powerLevelForUser(user->id());
return plEvent->powerLevelForUser(member);
}
if (role == PowerLevelStringRole) {
auto pl = m_currentRoom->currentState().get<RoomPowerLevelsEvent>();
@@ -93,7 +95,7 @@ QVariant UserListModel::data(const QModelIndex &index, int role) const
return QStringLiteral("Not Available");
}
auto userPl = pl->powerLevelForUser(user->id());
auto userPl = pl->powerLevelForUser(member);
return i18nc("%1 is the name of the power level, e.g. admin and %2 is the value that represents.",
"%1 (%2)",
@@ -109,87 +111,77 @@ int UserListModel::rowCount(const QModelIndex &parent) const
if (parent.isValid()) {
return 0;
}
return m_users.count();
return m_members.count();
}
bool UserListModel::event(QEvent *event)
{
if (event->type() == QEvent::ApplicationPaletteChange) {
refreshAllUsers();
refreshAllMembers();
}
return QObject::event(event);
}
void UserListModel::userAdded(Quotient::User *user)
void UserListModel::memberJoined(const Quotient::RoomMember &member)
{
auto pos = findUserPos(user);
auto pos = findUserPos(member);
beginInsertRows(QModelIndex(), pos, pos);
m_users.insert(pos, user);
m_members.insert(pos, member.id());
endInsertRows();
connect(user, &User::defaultAvatarChanged, this, [this, user]() {
refreshUser(user, {AvatarRole});
});
}
void UserListModel::userRemoved(Quotient::User *user)
void UserListModel::memberLeft(const Quotient::RoomMember &member)
{
auto pos = findUserPos(user);
if (pos != m_users.size()) {
auto pos = findUserPos(member);
if (pos != m_members.size()) {
beginRemoveRows(QModelIndex(), pos, pos);
m_users.removeAt(pos);
m_members.removeAt(pos);
endRemoveRows();
user->disconnect(this);
} else {
qWarning() << "Trying to remove a room member not in the user list";
}
}
void UserListModel::refreshUser(Quotient::User *user, const QList<int> &roles)
void UserListModel::refreshMember(const Quotient::RoomMember &member, const QList<int> &roles)
{
auto pos = findUserPos(user);
if (pos != m_users.size()) {
auto pos = findUserPos(member);
if (pos != m_members.size()) {
Q_EMIT dataChanged(index(pos), index(pos), roles);
} else {
qWarning() << "Trying to access a room member not in the user list";
}
}
void UserListModel::refreshAllUsers()
void UserListModel::refreshAllMembers()
{
beginResetModel();
for (User *user : std::as_const(m_users)) {
user->disconnect(this);
}
m_users.clear();
m_members.clear();
if (m_currentRoom != nullptr) {
m_users = m_currentRoom->users();
std::sort(m_users.begin(), m_users.end(), m_currentRoom->memberSorter());
for (User *user : std::as_const(m_users)) {
connect(user, &User::defaultAvatarChanged, this, [this, user]() {
refreshUser(user, {AvatarRole});
});
}
connect(m_currentRoom->connection(), &Connection::loggedOut, this, [this]() {
setRoom(nullptr);
m_members = m_currentRoom->joinedMemberIds();
std::sort(m_members.begin(), m_members.end(), [this](const auto &left, const auto &right) {
return m_currentRoom->member(left).displayName() < m_currentRoom->member(right).displayName();
});
}
endResetModel();
Q_EMIT usersRefreshed();
}
int UserListModel::findUserPos(Quotient::User *user) const
int UserListModel::findUserPos(const RoomMember &member) const
{
return findUserPos(m_currentRoom->safeMemberName(user->id()));
return findUserPos(member.id());
}
int UserListModel::findUserPos(const QString &username) const
int UserListModel::findUserPos(const QString &userId) const
{
if (!m_currentRoom) {
return 0;
}
return m_currentRoom->memberSorter().lowerBoundIndex(m_users, username);
#if Quotient_VERSION_MINOR > 8
return Quotient::lowerBoundMemberIndex(m_members, m_currentRoom->member(userId).displayName(), m_currentRoom);
#else
return m_currentRoom->memberSorter().lowerBoundIndex(m_currentRoom->members(), m_currentRoom->member(userId));
#endif
}
QHash<int, QByteArray> UserListModel::roleNames() const

View File

@@ -56,11 +56,6 @@ public:
[[nodiscard]] NeoChatRoom *room() const;
void setRoom(NeoChatRoom *room);
/**
* @brief The user at the given index of the model.
*/
[[nodiscard]] Quotient::User *userAt(QModelIndex index) const;
/**
* @brief Get the given role value at the given index.
*
@@ -90,15 +85,15 @@ protected:
bool event(QEvent *event) override;
private Q_SLOTS:
void userAdded(Quotient::User *user);
void userRemoved(Quotient::User *user);
void refreshUser(Quotient::User *user, const QList<int> &roles = {});
void refreshAllUsers();
void memberJoined(const Quotient::RoomMember &member);
void memberLeft(const Quotient::RoomMember &member);
void refreshMember(const Quotient::RoomMember &member, const QList<int> &roles = {});
void refreshAllMembers();
private:
QPointer<NeoChatRoom> m_currentRoom;
QList<Quotient::User *> m_users;
QList<QString> m_members;
int findUserPos(Quotient::User *user) const;
[[nodiscard]] int findUserPos(const QString &username) const;
int findUserPos(const Quotient::RoomMember &member) const;
[[nodiscard]] int findUserPos(const QString &userId) const;
};

View File

@@ -253,6 +253,7 @@ Action=Popup
[Event/Share]
Name=Share
Name[ar]=شارك
Name[ca]=Compartició
Name[ca@valencia]=Compartició
Name[cs]=Sdílet
@@ -260,6 +261,7 @@ Name[en_GB]=Share
Name[eo]=Kundividi
Name[es]=Compartir
Name[eu]=Partekatu
Name[fi]=Jaa
Name[fr]=Partager
Name[hu]=Megosztás
Name[ia]=Comparti
@@ -269,18 +271,21 @@ Name[lv]=Kopīgot
Name[nl]=Gedeelde
Name[pl]=Udostępnij
Name[sl]=Deli
Name[sv]=Dela
Name[ta]=பகிர்
Name[tr]=Paylaş
Name[uk]=Оприлюднення
Name[x-test]=xxSharexx
Name[zh_TW]=分享
Comment=The result of sharing a piece of content
Comment[ar]=نتيجة مشاركة محتوى
Comment[ca]=El resultat de compartir una peça de contingut
Comment[ca@valencia]=El resultat de compartir una peça de contingut
Comment[en_GB]=The result of sharing a piece of content
Comment[eo]=La rezulto el kundividado de enhavero
Comment[es]=El resultado de compartir una parte de contenido
Comment[eu]=Eduki pieza bat partekatzearen emaitza
Comment[fi]=Tulos yhden sisältöosasen jakamisesta
Comment[fr]=Le résultat du partage d'une partie de contenu.
Comment[hu]=Tartalom megosztásának eredménye
Comment[ia]=Le exito de compartir un pecietta de contento
@@ -290,6 +295,7 @@ Comment[lv]=Satura kopīgošanas rezultāts
Comment[nl]=Het resultaat van het delen van een stukje inhoud
Comment[pl]=Wynik udostępniania kawałka treści
Comment[sl]=Rezultat deljenega kosa vsebine
Comment[sv]=Resultatet av att dela innehåll
Comment[ta]=எதையோ பகிர்ந்த‍தன் விளைவு
Comment[tr]=Bir parça içerik paylaşımının sonucu
Comment[uk]=Результат оприлюднення даних

View File

@@ -12,6 +12,7 @@
#include "linkpreviewer.h"
#include "neochatconfig.h"
#include "neochatroom.h"
#include "notificationsmanager.h"
#include "roommanager.h"
#include "spacehierarchycache.h"
@@ -60,9 +61,16 @@ void NeoChatConnection::connectSignals()
if (type == QLatin1String("org.kde.neochat.account_label")) {
Q_EMIT labelChanged();
}
if (type == QLatin1String("m.identity_server")) {
Q_EMIT identityServerChanged();
}
});
connect(this, &NeoChatConnection::syncDone, this, [this] {
setIsOnline(true);
connect(this, &NeoChatConnection::syncDone, this, [this]() {
NotificationsManager::instance().handleNotifications(this);
});
});
connect(this, &NeoChatConnection::networkError, this, [this]() {
setIsOnline(false);
@@ -256,6 +264,41 @@ ThreePIdModel *NeoChatConnection::threePIdModel() const
return m_threePIdModel;
}
bool NeoChatConnection::hasIdentityServer() const
{
if (!hasAccountData(QLatin1String("m.identity_server"))) {
return false;
}
const auto url = accountData(QLatin1String("m.identity_server"))->contentPart<QUrl>(QLatin1String("base_url"));
if (!url.isEmpty()) {
return true;
}
return false;
}
QUrl NeoChatConnection::identityServer() const
{
if (!hasAccountData(QLatin1String("m.identity_server"))) {
return {};
}
const auto url = accountData(QLatin1String("m.identity_server"))->contentPart<QUrl>(QLatin1String("base_url"));
if (!url.isEmpty()) {
return url;
}
return {};
}
QString NeoChatConnection::identityServerUIString() const
{
if (!hasIdentityServer()) {
return i18nc("@info", "No identity server configured");
}
return identityServer().toString();
}
void NeoChatConnection::createRoom(const QString &name, const QString &topic, const QString &parent, bool setChildParent)
{
QList<CreateRoomJob::StateEvent> initialStateEvents;
@@ -283,9 +326,14 @@ void NeoChatConnection::createRoom(const QString &name, const QString &topic, co
connect(job, &CreateRoomJob::failure, this, [job] {
Q_EMIT Controller::instance().errorOccured(i18n("Room creation failed: %1", job->errorString()), {});
});
connectSingleShot(this, &Connection::newRoom, this, [](Room *room) {
RoomManager::instance().resolveResource(room->id());
});
connect(
this,
&Connection::newRoom,
this,
[](Room *room) {
RoomManager::instance().resolveResource(room->id());
},
Qt::SingleShotConnection);
}
void NeoChatConnection::createSpace(const QString &name, const QString &topic, const QString &parent, bool setChildParent)
@@ -315,9 +363,14 @@ void NeoChatConnection::createSpace(const QString &name, const QString &topic, c
connect(job, &CreateRoomJob::failure, this, [job] {
Q_EMIT Controller::instance().errorOccured(i18n("Space creation failed: %1", job->errorString()), {});
});
connectSingleShot(this, &Connection::newRoom, this, [](Room *room) {
RoomManager::instance().resolveResource(room->id());
});
connect(
this,
&Connection::newRoom,
this,
[](Room *room) {
RoomManager::instance().resolveResource(room->id());
},
Qt::SingleShotConnection);
}
bool NeoChatConnection::directChatExists(Quotient::User *user)
@@ -328,29 +381,30 @@ bool NeoChatConnection::directChatExists(Quotient::User *user)
void NeoChatConnection::openOrCreateDirectChat(const QString &userId)
{
if (auto user = this->user(userId)) {
openOrCreateDirectChat(user);
const auto existing = directChats();
if (existing.contains(user)) {
const auto room = this->room(existing.value(user));
if (room) {
RoomManager::instance().resolveResource(room->id());
return;
}
}
requestDirectChat(userId);
connect(
this,
&Connection::directChatAvailable,
this,
[=](auto room) {
room->activateEncryption();
},
Qt::SingleShotConnection);
} else {
qWarning() << "openOrCreateDirectChat: Couldn't get user object for ID " << userId << ", unable to open/request direct chat.";
}
}
void NeoChatConnection::openOrCreateDirectChat(User *user)
{
const auto existing = directChats();
if (existing.contains(user)) {
const auto room = this->room(existing.value(user));
if (room) {
RoomManager::instance().resolveResource(room->id());
return;
}
}
requestDirectChat(user);
connectSingleShot(this, &Connection::directChatAvailable, this, [=](auto room) {
room->activateEncryption();
});
}
qsizetype NeoChatConnection::directChatNotifications() const
{
qsizetype notifications = 0;

View File

@@ -36,6 +36,19 @@ class NeoChatConnection : public Quotient::Connection
*/
Q_PROPERTY(ThreePIdModel *threePIdModel READ threePIdModel CONSTANT)
/**
* @brief Whether an identity server is configured.
*/
Q_PROPERTY(bool hasIdentityServer READ hasIdentityServer NOTIFY identityServerChanged)
/**
* @brief The identity server URL as a string for showing in a UI.
*
* Will return the string "No identity server configured" if no identity
* server configured. Otherwise it returns the URL as a string.
*/
Q_PROPERTY(QString identityServer READ identityServerUIString NOTIFY identityServerChanged)
/**
* @brief The total number of notifications for all direct chats.
*/
@@ -105,6 +118,17 @@ public:
ThreePIdModel *threePIdModel() const;
bool hasIdentityServer() const;
/**
* @brief The identity server URL.
*
* Empty if no identity server configured.
*/
QUrl identityServer() const;
QString identityServerUIString() const;
/**
* @brief Create new room for a group chat.
*/
@@ -127,13 +151,6 @@ public:
*/
Q_INVOKABLE void openOrCreateDirectChat(const QString &userId);
/**
* @brief Join a direct chat with the given user object.
*
* If a direct chat with the user doesn't exist one is created and then joined.
*/
Q_INVOKABLE void openOrCreateDirectChat(Quotient::User *user);
/**
* @brief Get the account data with \param type as a formatted JSON string.
*/
@@ -162,6 +179,7 @@ public:
Q_SIGNALS:
void labelChanged();
void identityServerChanged();
void directChatNotificationsChanged();
void directChatsHaveHighlightNotificationsChanged();
void homeNotificationsChanged();

View File

@@ -70,6 +70,8 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
});
connect(this, &Room::addedMessages, this, &NeoChatRoom::readMarkerLoadedChanged);
connect(this, &Room::aboutToAddHistoricalMessages, this, &NeoChatRoom::cleanupExtraEventRange);
connect(this, &Room::aboutToAddNewMessages, this, &NeoChatRoom::cleanupExtraEventRange);
const auto &roomLastMessageProvider = RoomLastMessageProvider::self();
@@ -94,23 +96,31 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
});
connect(this, &Room::displaynameChanged, this, &NeoChatRoom::displayNameChanged);
connectSingleShot(this, &Room::baseStateLoaded, this, [this]() {
updatePushNotificationState(QStringLiteral("m.push_rules"));
connect(
this,
&Room::baseStateLoaded,
this,
[this, connection]() {
updatePushNotificationState(QStringLiteral("m.push_rules"));
Q_EMIT canEncryptRoomChanged();
if (this->joinState() != JoinState::Invite) {
return;
}
auto roomMemberEvent = currentState().get<RoomMemberEvent>(localUser()->id());
QImage avatar_image;
if (roomMemberEvent && !user(roomMemberEvent->senderId())->avatarUrl(this).isEmpty()) {
avatar_image = user(roomMemberEvent->senderId())->avatar(128, this);
} else {
qWarning() << "using this room's avatar";
avatar_image = avatar(128);
}
NotificationsManager::instance().postInviteNotification(this, displayName(), htmlSafeMemberName(roomMemberEvent->senderId()), avatar_image);
});
Q_EMIT canEncryptRoomChanged();
if (this->joinState() != JoinState::Invite) {
return;
}
auto roomMemberEvent = currentState().get<RoomMemberEvent>(localMember().id());
QImage avatar_image;
if (roomMemberEvent && !member(roomMemberEvent->senderId()).avatarUrl().isEmpty()) {
avatar_image = memberAvatar(roomMemberEvent->senderId()).get(connection, 128, {});
} else {
qWarning() << "using this room's avatar";
avatar_image = avatar(128);
}
NotificationsManager::instance().postInviteNotification(this,
displayName(),
member(roomMemberEvent->senderId()).htmlSafeDisplayName(),
avatar_image);
},
Qt::SingleShotConnection);
connect(this, &Room::changed, this, [this] {
Q_EMIT canEncryptRoomChanged();
Q_EMIT parentIdsChanged();
@@ -257,18 +267,18 @@ void NeoChatRoom::forget()
QVariantList NeoChatRoom::getUsersTyping() const
{
auto users = usersTyping();
users.removeAll(localUser());
auto users = membersTyping();
users.removeAll(localMember());
QVariantList userVariants;
for (const auto &user : users) {
if (connection()->isIgnored(user->id())) {
if (connection()->isIgnored(user.id())) {
continue;
}
userVariants.append(QVariantMap{
{"id"_ls, user->id()},
{"avatarMediaId"_ls, user->avatarMediaId(this)},
{"displayName"_ls, user->displayname(this)},
{"display"_ls, user->name()},
{"id"_ls, user.id()},
{"avatarMediaId"_ls, user.avatarMediaId()},
{"displayName"_ls, user.displayName()},
{"display"_ls, user.name()},
});
}
return userVariants;
@@ -276,7 +286,7 @@ QVariantList NeoChatRoom::getUsersTyping() const
void NeoChatRoom::sendTypingNotification(bool isTyping)
{
connection()->callApi<SetTypingJob>(BackgroundRequest, localUser()->id(), id(), isTyping, 10000);
connection()->callApi<SetTypingJob>(BackgroundRequest, localMember().id(), id(), isTyping, 10000);
}
const RoomEvent *NeoChatRoom::lastEvent() const
@@ -314,7 +324,7 @@ const RoomEvent *NeoChatRoom::lastEvent() const
}
}
if (connection()->isIgnored(user(event->senderId()))) {
if (connection()->isIgnored(event->senderId())) {
continue;
}
@@ -374,13 +384,13 @@ bool NeoChatRoom::isEventHighlighted(const RoomEvent *e) const
void NeoChatRoom::checkForHighlights(const Quotient::TimelineItem &ti)
{
auto localUserId = localUser()->id();
auto localUserId = localMember().id();
if (ti->senderId() == localUserId) {
return;
}
if (auto *e = ti.viewAs<RoomMessageEvent>()) {
const auto &text = e->plainBody();
if (text.contains(localUserId) || text.contains(safeMemberName(localUserId))) {
if (text.contains(localUserId) || text.contains(localUserId)) {
highlights.insert(e);
}
}
@@ -439,24 +449,20 @@ static const QVariantMap emptyUser = {
QVariantMap NeoChatRoom::getUser(const QString &userID) const
{
return getUser(user(userID));
return getUser(member(userID));
}
QVariantMap NeoChatRoom::getUser(User *user) const
QVariantMap NeoChatRoom::getUser(RoomMember member) const
{
if (user == nullptr) {
return emptyUser;
}
return QVariantMap{
{QStringLiteral("isLocalUser"), user->id() == localUser()->id()},
{QStringLiteral("id"), user->id()},
{QStringLiteral("displayName"), user->displayname(this)},
{QStringLiteral("escapedDisplayName"), htmlSafeMemberName(user->id())},
{QStringLiteral("avatarSource"), avatarForMember(user)},
{QStringLiteral("avatarMediaId"), user->avatarMediaId(this)},
{QStringLiteral("color"), Utils::getUserColor(user->hueF())},
{QStringLiteral("object"), QVariant::fromValue(user)},
{QStringLiteral("isLocalUser"), member.id() == localMember().id()},
{QStringLiteral("id"), member.id()},
{QStringLiteral("displayName"), member.displayName()},
{QStringLiteral("escapedDisplayName"), member.htmlSafeDisplayName()},
{QStringLiteral("avatarSource"), member.avatarUrl()},
{QStringLiteral("avatarMediaId"), member.avatarMediaId()},
{QStringLiteral("color"), Utils::getUserColor(member.hueF())},
{QStringLiteral("object"), QVariant::fromValue(member)},
};
}
@@ -467,10 +473,10 @@ QString NeoChatRoom::avatarMediaId() const
}
// Use the first (excluding self) user's avatar for direct chats
const auto dcUsers = directChatUsers();
const auto dcUsers = directChatMembers();
for (const auto u : dcUsers) {
if (u != localUser()) {
return u->avatarMediaId(this);
if (u != localMember()) {
return u.avatarMediaId().mid(6);
}
}
@@ -637,7 +643,7 @@ void NeoChatRoom::toggleReaction(const QString &eventId, const QString &reaction
continue;
}
if (e->senderId() == localUser()->id()) {
if (e->senderId() == localMember().id()) {
redactEventIds.push_back(e->id());
break;
}
@@ -666,7 +672,7 @@ bool NeoChatRoom::canSendEvent(const QString &eventType) const
return false;
}
auto pl = plEvent->powerLevelForEvent(eventType);
auto currentPl = plEvent->powerLevelForUser(localUser()->id());
auto currentPl = plEvent->powerLevelForUser(localMember().id());
return currentPl >= pl;
}
@@ -678,7 +684,7 @@ bool NeoChatRoom::canSendState(const QString &eventType) const
return false;
}
auto pl = plEvent->powerLevelForState(eventType);
auto currentPl = plEvent->powerLevelForUser(localUser()->id());
auto currentPl = plEvent->powerLevelForUser(localMember().id());
return currentPl >= pl;
}
@@ -856,7 +862,7 @@ void NeoChatRoom::setUrlPreviewEnabled(const bool &urlPreviewEnabled)
* "type": "org.matrix.room.preview_urls",
* }
*/
connection()->callApi<SetAccountDataPerRoomJob>(localUser()->id(),
connection()->callApi<SetAccountDataPerRoomJob>(localMember().id(),
id(),
"org.matrix.room.preview_urls"_ls,
QJsonObject{{"disable"_ls, !urlPreviewEnabled}});
@@ -1524,7 +1530,7 @@ void NeoChatRoom::editLastMessage()
}
// check if the current message's sender's id is same as the user's id
if ((*it)->senderId() == localUser()->id()) {
if ((*it)->senderId() == localMember().id()) {
auto content = (*it)->contentJson();
if (e->msgtype() != MessageEventType::Unknown) {
@@ -1649,13 +1655,13 @@ int NeoChatRoom::maxRoomVersion() const
return maxVersion;
}
Quotient::User *NeoChatRoom::directChatRemoteUser() const
RoomMember NeoChatRoom::directChatRemoteUser() const
{
auto users = connection()->directChatUsers(this);
auto users = connection()->directChatMemberIds(this);
if (users.isEmpty()) {
return nullptr;
return {};
}
return users[0];
return member(users[0]);
}
void NeoChatRoom::sendLocation(float lat, float lon, const QString &description)
@@ -1687,9 +1693,9 @@ QByteArray NeoChatRoom::roomAcountDataJson(const QString &eventType)
return QJsonDocument(accountData(eventType)->fullJson()).toJson();
}
QUrl NeoChatRoom::avatarForMember(Quotient::User *user) const
QUrl NeoChatRoom::avatarForMember(RoomMember member) const
{
const auto &url = memberAvatarUrl(user->id());
const auto &url = member.avatarUrl();
if (url.isEmpty() || url.scheme() != "mxc"_ls) {
return {};
}
@@ -1701,6 +1707,40 @@ QUrl NeoChatRoom::avatarForMember(Quotient::User *user) const
}
}
void NeoChatRoom::downloadEventFromServer(const QString &eventId)
{
if (findInTimeline(eventId) != historyEdge()) {
return;
}
auto job = connection()->callApi<GetOneRoomEventJob>(id(), eventId);
connect(job, &BaseJob::success, this, [this, job, eventId] {
// The event may have arrived in the meantime so check it's not in the timeline.
if (findInTimeline(eventId) != historyEdge()) {
return;
}
event_ptr_tt<RoomEvent> event = fromJson<event_ptr_tt<RoomEvent>>(job->jsonData());
m_extraEvents.push_back(std::move(event));
Q_EMIT extraEventLoaded(eventId);
});
}
const RoomEvent *NeoChatRoom::getEvent(const QString &eventId) const
{
if (eventId.isEmpty()) {
return nullptr;
}
const auto timelineIt = findInTimeline(eventId);
if (timelineIt != historyEdge()) {
return timelineIt->get();
}
auto extraIt = std::find_if(m_extraEvents.begin(), m_extraEvents.end(), [eventId](const Quotient::event_ptr_tt<Quotient::RoomEvent> &event) {
return event->id() == eventId;
});
return extraIt != m_extraEvents.end() ? extraIt->get() : nullptr;
}
const RoomEvent *NeoChatRoom::getReplyForEvent(const RoomEvent &event) const
{
const QString &replyEventId = event.contentJson()["m.relates_to"_ls].toObject()["m.in_reply_to"_ls].toObject()["event_id"_ls].toString();
@@ -1721,18 +1761,27 @@ const RoomEvent *NeoChatRoom::getReplyForEvent(const RoomEvent &event) const
return replyPtr;
}
void NeoChatRoom::loadReply(const QString &eventId, const QString &replyId)
void NeoChatRoom::cleanupExtraEventRange(Quotient::RoomEventsRange events)
{
auto job = connection()->callApi<GetOneRoomEventJob>(id(), replyId);
connect(job, &BaseJob::success, this, [this, job, eventId, replyId] {
m_extraEvents.push_back(fromJson<event_ptr_tt<RoomEvent>>(job->jsonData()));
Q_EMIT replyLoaded(eventId, replyId);
});
for (auto &&event : events) {
cleanupExtraEvent(event->id());
}
}
User *NeoChatRoom::invitingUser() const
void NeoChatRoom::cleanupExtraEvent(const QString &eventId)
{
return connection()->user(currentState().get<RoomMemberEvent>(connection()->userId())->senderId());
auto it = std::find_if(m_extraEvents.begin(), m_extraEvents.end(), [eventId](Quotient::event_ptr_tt<Quotient::RoomEvent> &event) {
return event->id() == eventId;
});
if (it != m_extraEvents.end()) {
m_extraEvents.erase(it);
}
}
QString NeoChatRoom::invitingUserId() const
{
return currentState().get<RoomMemberEvent>(connection()->userId())->senderId();
}
void NeoChatRoom::setRoomState(const QString &type, const QString &stateKey, const QByteArray &content)

View File

@@ -95,7 +95,7 @@ class NeoChatRoom : public Quotient::Room
/**
* @brief Get a user object for the other person in a direct chat.
*/
Q_PROPERTY(Quotient::User *directChatRemoteUser READ directChatRemoteUser CONSTANT)
Q_PROPERTY(Quotient::RoomMember directChatRemoteUser READ directChatRemoteUser CONSTANT)
/**
* @brief The Matrix IDs of this room's parents.
@@ -285,7 +285,7 @@ public:
*
* @sa Quotient::User
*/
Q_INVOKABLE [[nodiscard]] QVariantMap getUser(Quotient::User *user) const;
Q_INVOKABLE [[nodiscard]] QVariantMap getUser(Quotient::RoomMember member) const;
[[nodiscard]] QVariantList getUsersTyping() const;
@@ -400,7 +400,7 @@ public:
[[nodiscard]] QString avatarMediaId() const;
Quotient::User *directChatRemoteUser() const;
Quotient::RoomMember directChatRemoteUser() const;
/**
* @brief Whether this room has one or more parent spaces set.
@@ -630,24 +630,37 @@ public:
*/
Q_INVOKABLE QByteArray roomAcountDataJson(const QString &eventType);
Q_INVOKABLE [[nodiscard]] QUrl avatarForMember(Quotient::User *user) const;
Q_INVOKABLE [[nodiscard]] QUrl avatarForMember(Quotient::RoomMember member) const;
/**
* @brief Loads the event with the given id from the server and saves it locally.
*
* Intended to retrieve events that are needed, e.g. replied to events that are
* not currently in the timeline.
*
* If the event is already in the timeline nothing will happen.
*/
void downloadEventFromServer(const QString &eventId);
/**
* @brief Returns the event with the given ID if available.
*
* This function will check both the timeline and extra events and return a
* non-nullptr value if it is found in either.
*
* The result will be nullptr if not found so needs to be managed.
*/
const Quotient::RoomEvent *getEvent(const QString &eventId) const;
/**
* @brief Returns the event that is being replied to. This includes events that were manually loaded using NeoChatRoom::loadReply.
*/
const Quotient::RoomEvent *getReplyForEvent(const Quotient::RoomEvent &event) const;
/**
* Loads the event replyId with the given id from the server and saves it locally.
* For models to update correctly, eventId must be the event that is replying to replyId.
* Intended to load the replied-to event when it isn't available locally.
*/
Q_INVOKABLE void loadReply(const QString &eventId, const QString &replyId);
/**
* If we're invited to this room, the user that invited us. Undefined in other cases.
*/
Q_INVOKABLE Quotient::User *invitingUser() const;
Q_INVOKABLE QString invitingUserId() const;
private:
QSet<const Quotient::RoomEvent *> highlights;
@@ -674,6 +687,8 @@ private:
QCache<QString, PollHandler> m_polls;
std::vector<Quotient::event_ptr_tt<Quotient::RoomEvent>> m_extraEvents;
void cleanupExtraEventRange(Quotient::RoomEventsRange events);
void cleanupExtraEvent(const QString &eventId);
private Q_SLOTS:
void updatePushNotificationState(QString type);
@@ -703,7 +718,7 @@ Q_SIGNALS:
void defaultUrlPreviewStateChanged();
void urlPreviewEnabledChanged();
void maxRoomVersionChanged();
void replyLoaded(const QString &eventId, const QString &replyId);
void extraEventLoaded(const QString &eventId);
public Q_SLOTS:
/**

View File

@@ -42,109 +42,100 @@ NotificationsManager::NotificationsManager(QObject *parent)
void NotificationsManager::handleNotifications(QPointer<NeoChatConnection> connection)
{
if (!m_connActiveJob.contains(connection->user()->id())) {
if (!m_connActiveJob.contains(connection->userId())) {
auto job = connection->callApi<GetNotificationsJob>();
m_connActiveJob.append(connection->user()->id());
connect(job, &BaseJob::success, this, [this, job, connection]() {
m_connActiveJob.removeAll(connection->user()->id());
processNotificationJob(connection, job, !m_oldNotifications.contains(connection->user()->id()));
m_connActiveJob.removeAll(connection->userId());
processNotificationJob(connection, job, !m_oldNotifications.contains(connection->userId()));
});
}
}
void NotificationsManager::processNotificationJob(QPointer<NeoChatConnection> connection, Quotient::GetNotificationsJob *job, bool initialization)
{
if (job == nullptr) {
return;
}
if (connection == nullptr || !connection->isLoggedIn()) {
qWarning() << QStringLiteral("No connection for GetNotificationsJob %1").arg(job->objectName());
if (!job || !connection || !connection->isLoggedIn()) {
return;
}
const auto connectionId = connection->user()->id();
// If pagination has occurred set off the next job
auto nextToken = job->jsonData()["next_token"_ls].toString();
if (!nextToken.isEmpty()) {
auto nextJob = connection->callApi<GetNotificationsJob>(nextToken);
m_connActiveJob.append(connectionId);
connect(nextJob, &BaseJob::success, this, [this, nextJob, connection, initialization]() {
m_connActiveJob.removeAll(connection->user()->id());
processNotificationJob(connection, nextJob, initialization);
});
}
const auto connectionId = connection->userId();
const auto notifications = job->jsonData()["notifications"_ls].toArray();
if (initialization) {
m_oldNotifications[connectionId] = QStringList();
for (const auto &n : notifications) {
for (const auto &notification : notifications) {
if (!m_initialTimestamp.contains(connectionId)) {
m_initialTimestamp[connectionId] = n.toObject()["ts"_ls].toDouble();
m_initialTimestamp[connectionId] = notification["ts"_ls].toVariant().toLongLong();
} else {
qint64 timestamp = n.toObject()["ts"_ls].toDouble();
qint64 timestamp = notification["ts"_ls].toVariant().toLongLong();
if (timestamp > m_initialTimestamp[connectionId]) {
m_initialTimestamp[connectionId] = timestamp;
}
}
auto connectionNotifications = m_oldNotifications.value(connectionId);
connectionNotifications += n.toObject()["event"_ls].toObject()["event_id"_ls].toString();
connectionNotifications += notification["event"_ls]["event_id"_ls].toString();
m_oldNotifications[connectionId] = connectionNotifications;
}
return;
}
QMap<QString, std::pair<qint64, QJsonObject>> notificationsToPost;
for (const auto &n : notifications) {
const auto notification = n.toObject();
if (notification["read"_ls].toBool()) {
continue;
}
auto connectionNotifications = m_oldNotifications.value(connectionId);
if (connectionNotifications.contains(notification["event"_ls].toObject()["event_id"_ls].toString())) {
if (connectionNotifications.contains(notification["event"_ls]["event_id"_ls].toString())) {
continue;
}
connectionNotifications += notification["event"_ls].toObject()["event_id"_ls].toString();
connectionNotifications += notification["event"_ls]["event_id"_ls].toString();
m_oldNotifications[connectionId] = connectionNotifications;
auto room = connection->room(notification["room_id"_ls].toString());
if (shouldPostNotification(connection, n)) {
// The room might have been deleted (for example rejected invitation).
auto sender = room->user(notification["event"_ls].toObject()["sender"_ls].toString());
QString body;
if (notification["event"_ls].toObject()["type"_ls].toString() == "org.matrix.msc3381.poll.start"_ls) {
body = notification["event"_ls]
.toObject()["content"_ls]
.toObject()["org.matrix.msc3381.poll.start"_ls]
.toObject()["question"_ls]
.toObject()["body"_ls]
.toString();
} else {
body = notification["event"_ls].toObject()["content"_ls].toObject()["body"_ls].toString();
}
if (notification["event"_ls]["type"_ls] == "m.room.encrypted"_ls) {
auto decrypted = connection->decryptNotification(notification);
body = decrypted["content"_ls].toObject()["body"_ls].toString();
if (body.isEmpty()) {
body = i18n("Encrypted Message");
}
}
QImage avatar_image;
if (!sender->avatarUrl(room).isEmpty()) {
avatar_image = sender->avatar(128, room);
} else {
avatar_image = room->avatar(128);
}
postNotification(dynamic_cast<NeoChatRoom *>(room),
sender->displayname(room),
body,
avatar_image,
notification["event"_ls].toObject()["event_id"_ls].toString(),
true);
if (!shouldPostNotification(connection, n)) {
continue;
}
const auto &roomId = notification["room_id"_ls].toString();
if (!notificationsToPost.contains(roomId) || notificationsToPost[roomId].first < notification["ts"_ls].toVariant().toLongLong()) {
notificationsToPost[roomId] = {notification["ts"_ls].toVariant().toLongLong(), notification};
}
}
for (const auto &[roomId, pair] : notificationsToPost.asKeyValueRange()) {
const auto &notification = pair.second;
const auto room = connection->room(roomId);
if (!room) {
continue;
}
auto sender = room->member(notification["event"_ls]["sender"_ls].toString());
QString body;
if (notification["event"_ls]["type"_ls].toString() == "org.matrix.msc3381.poll.start"_ls) {
body = notification["event"_ls]["content"_ls]["org.matrix.msc3381.poll.start"_ls]["question"_ls]["body"_ls].toString();
} else if (notification["event"_ls]["type"_ls] == "m.room.encrypted"_ls) {
const auto decrypted = connection->decryptNotification(notification);
body = decrypted["content"_ls]["body"_ls].toString();
if (body.isEmpty()) {
body = i18n("Encrypted Message");
}
} else {
body = notification["event"_ls]["content"_ls]["body"_ls].toString();
}
QImage avatar_image;
if (!sender.avatarUrl().isEmpty()) {
avatar_image = room->memberAvatar(sender.id()).get(connection, 128, {});
} else {
avatar_image = room->avatar(128);
}
postNotification(dynamic_cast<NeoChatRoom *>(room),
sender.displayName(),
body,
avatar_image,
notification["event"_ls].toObject()["event_id"_ls].toString(),
true,
pair.first);
}
}
@@ -175,6 +166,10 @@ bool NotificationsManager::shouldPostNotification(QPointer<NeoChatConnection> co
return false;
}
if (m_notifications.contains(room->id()) && m_notifications[room->id()].first > timestamp) {
return false;
}
return true;
}
@@ -183,18 +178,23 @@ void NotificationsManager::postNotification(NeoChatRoom *room,
const QString &text,
const QImage &icon,
const QString &replyEventId,
bool canReply)
bool canReply,
qint64 timestamp)
{
const QString roomId = room->id();
KNotification *notification = m_notifications.value(roomId);
if (!notification) {
notification = new KNotification(QStringLiteral("message"));
m_notifications.insert(roomId, notification);
connect(notification, &KNotification::closed, this, [this, roomId] {
m_notifications.remove(roomId);
});
if (auto notification = m_notifications.value(roomId).second) {
notification->close();
}
auto notification = new KNotification(QStringLiteral("message"));
m_notifications.insert(roomId, {timestamp, notification});
connect(notification, &KNotification::closed, this, [this, roomId, notification] {
if (m_notifications[roomId].second == notification) {
m_notifications.remove(roomId);
}
});
QString entry;
if (sender == room->displayName()) {
notification->setTitle(sender);
@@ -204,7 +204,7 @@ void NotificationsManager::postNotification(NeoChatRoom *room,
entry = i18n("%1: %2", sender, text.toHtmlEscaped());
}
notification->setText(notification->text() + QLatin1Char('\n') + entry);
notification->setText(entry);
notification->setPixmap(createNotificationImage(icon, room));
auto defaultAction = notification->addDefaultAction(i18n("Open NeoChat in this room"));
@@ -213,7 +213,7 @@ void NotificationsManager::postNotification(NeoChatRoom *room,
if (!room) {
return;
}
auto connection = dynamic_cast<NeoChatConnection *>(Controller::instance().accounts().get(room->localUser()->id()));
auto connection = dynamic_cast<NeoChatConnection *>(Controller::instance().accounts().get(room->localMember().id()));
Controller::instance().setActiveConnection(connection);
RoomManager::instance().setConnection(connection);
RoomManager::instance().resolveResource(room->id());
@@ -230,7 +230,7 @@ void NotificationsManager::postNotification(NeoChatRoom *room,
notification->setReplyAction(std::move(replyAction));
}
notification->setHint(QStringLiteral("x-kde-origin-name"), room->localUser()->id());
notification->setHint(QStringLiteral("x-kde-origin-name"), room->localMember().id());
notification->sendEvent();
}
@@ -276,7 +276,7 @@ void NotificationsManager::postInviteNotification(NeoChatRoom *rawRoom, const QS
return;
}
RoomManager::instance().leaveRoom(room);
room->connection()->addToIgnoredUsers(room->invitingUser());
room->connection()->addToIgnoredUsers(room->invitingUserId());
notification->close();
});
connect(notification, &KNotification::closed, this, [this, room]() {
@@ -286,10 +286,9 @@ void NotificationsManager::postInviteNotification(NeoChatRoom *rawRoom, const QS
m_invitations.remove(room->id());
});
notification->setHint(QStringLiteral("x-kde-origin-name"), room->localUser()->id());
notification->setHint(QStringLiteral("x-kde-origin-name"), room->localMember().id());
notification->sendEvent();
m_invitations.insert(room->id(), notification);
}
void NotificationsManager::clearInvitationNotification(const QString &roomId)
@@ -343,7 +342,7 @@ void NotificationsManager::postPushNotification(const QByteArray &message)
notification->sendEvent();
m_notifications.insert(roomId, notification);
m_notifications.insert(roomId, {json["ts"_ls].toVariant().toLongLong(), notification});
} else {
qWarning() << "Skipping unsupported push notification" << type;
}

View File

@@ -47,8 +47,13 @@ public:
/**
* @brief Display a native notification for an message.
*/
Q_INVOKABLE void
postNotification(NeoChatRoom *room, const QString &sender, const QString &text, const QImage &icon, const QString &replyEventId, bool canReply);
Q_INVOKABLE void postNotification(NeoChatRoom *room,
const QString &sender,
const QString &text,
const QImage &icon,
const QString &replyEventId,
bool canReply,
qint64 timestamp);
/**
* @brief Display a native notification for an invite.
@@ -82,7 +87,7 @@ private:
bool shouldPostNotification(QPointer<NeoChatConnection> connection, const QJsonValue &notification);
QHash<QString, KNotification *> m_notifications;
QHash<QString, std::pair<qint64, KNotification *>> m_notifications;
QHash<QString, QPointer<KNotification>> m_invitations;
private Q_SLOTS:

View File

@@ -3,7 +3,7 @@
SPDX-License-Identifier: CC0-1.0
-->
<RCC>
<qresource prefix="/knotifications5">
<qresource prefix="/knotifications6">
<file>neochat.notifyrc</file>
</qresource>
</RCC>

View File

@@ -154,7 +154,7 @@ void PollHandler::sendPollAnswer(const QString &eventId, const QString &answerId
return;
}
QStringList ownAnswers;
for (const auto &answer : m_answers[room->localUser()->id()].toArray()) {
for (const auto &answer : m_answers[room->localMember().id()].toArray()) {
ownAnswers += answer.toString();
}
if (ownAnswers.contains(answerId)) {
@@ -169,7 +169,7 @@ void PollHandler::sendPollAnswer(const QString &eventId, const QString &answerId
}
auto response = new PollResponseEvent(eventId, ownAnswers);
handleAnswer(response->contentJson(), room->localUser()->id(), QDateTime::currentDateTime());
handleAnswer(response->contentJson(), room->localMember().id(), QDateTime::currentDateTime());
room->postEvent(response);
}

View File

@@ -3,6 +3,7 @@
"Authors": [
{
"Name": "Tobias Fella",
"Name[ar]": "توبياس فلة",
"Name[ca@valencia]": "Tobias Fella",
"Name[ca]": "Tobias Fella",
"Name[cs]": "Tobias Fella",
@@ -11,6 +12,7 @@
"Name[eo]": "Tobias Fella",
"Name[es]": "Tobias Fella",
"Name[eu]": "Tobias Fella",
"Name[fi]": "Tobias Fella",
"Name[fr]": "Tobias Fella",
"Name[gl]": "Tobias Fella",
"Name[hu]": "Tobias Fella",
@@ -22,6 +24,7 @@
"Name[pl]": "Tobias Fella",
"Name[ru]": "Tobias Fella",
"Name[sl]": "Tobias Fella",
"Name[sv]": "Tobias Fella",
"Name[ta]": "டோபியாஸ் ஃபெல்லா",
"Name[tr]": "Tobias Fella",
"Name[uk]": "Tobias Fella",
@@ -31,6 +34,7 @@
],
"Category": "Utilities",
"Description": "Share via NeoChat",
"Description[ar]": "شارك بواسطة نيوتشات",
"Description[ca@valencia]": "Compartix a través de NeoChat",
"Description[ca]": "Comparteix a través del NeoChat",
"Description[de]": "Über NeoChat teilen",
@@ -38,6 +42,7 @@
"Description[eo]": "Kundividi per NeoChat",
"Description[es]": "Compartir mediante NeoChat",
"Description[eu]": "Partekatu NeoChat bidez",
"Description[fi]": "Jaa NeoChatillä",
"Description[fr]": "Partager grâce à NeoChat",
"Description[gl]": "Compartir por NeoChat",
"Description[hu]": "Megosztás NeoChatben",
@@ -49,6 +54,7 @@
"Description[pl]": "Udostępnij przez NeoChat",
"Description[ru]": "Опубликовать в NeoChat",
"Description[sl]": "Deli prek NeoChat",
"Description[sv]": "Dela via NeoChat",
"Description[ta]": "நியோச்சாட் மூலம் பகிர்",
"Description[tr]": "NeoChat ile Paylaş",
"Description[uk]": "Оприлюднити за допомогою NeoChat",
@@ -57,6 +63,7 @@
"Icon": "org.kde.neochat",
"License": "GPL",
"Name": "NeoChat",
"Name[ar]": "نيوتشات",
"Name[ast]": "NeoChat",
"Name[ca@valencia]": "NeoChat",
"Name[ca]": "NeoChat",
@@ -66,6 +73,7 @@
"Name[eo]": "NeoChat",
"Name[es]": "NeoChat",
"Name[eu]": "NeoChat",
"Name[fi]": "NeoChat",
"Name[fr]": "NeoChat",
"Name[gl]": "NeoChat",
"Name[hu]": "NeoChat",
@@ -77,6 +85,7 @@
"Name[pl]": "NeoChat",
"Name[ru]": "NeoChat",
"Name[sl]": "NeoChat",
"Name[sv]": "NeoChat",
"Name[ta]": "நியோச்சாட்",
"Name[tr]": "NeoChat",
"Name[uk]": "NeoChat",

View File

@@ -72,6 +72,12 @@ QQC2.Menu {
})
enabled: Controller.ssssSupported
}
QQC2.MenuItem {
text: i18nc("@action:inmenu", "Verify this Device")
icon.name: "security-low"
onTriggered: root.connection.startSelfVerification()
enabled: Controller.csSupported
}
QQC2.MenuItem {
text: i18n("Logout")
icon.name: "list-remove-user"

View File

@@ -67,6 +67,11 @@ FormCard.FormCardPage {
}
}
}
FormCard.FormDelegateSeparator {
visible: root.showChildType
}
FormCard.FormTextFieldDelegate {
id: roomNameField
label: i18n("Name:")
@@ -75,17 +80,27 @@ FormCard.FormCardPage {
}
}
FormCard.FormDelegateSeparator {}
FormCard.FormTextFieldDelegate {
id: roomTopicField
label: i18n("Topic:")
onAccepted: ok.clicked()
}
FormCard.FormDelegateSeparator {}
FormCard.FormCheckDelegate {
id: newOfficialCheck
visible: root.parentId.length > 0
text: i18nc("@option:check As in make the space from which this dialog was created an official parent.", "Make this parent official")
checked: true
}
FormCard.FormDelegateSeparator {
visible: root.parentId.length > 0
}
FormCard.FormButtonDelegate {
id: ok
text: root.isSpace ? i18nc("@action:button", "Create Space") : i18nc("@action:button", "Create Room")
@@ -211,6 +226,9 @@ FormCard.FormCardPage {
});
}
}
FormCard.FormDelegateSeparator {}
FormCard.FormCheckDelegate {
id: existingOfficialCheck
visible: root.parentId.length > 0
@@ -230,6 +248,11 @@ FormCard.FormCardPage {
return false;
}
}
FormCard.FormDelegateSeparator {
visible: root.parentId.length > 0
}
FormCard.FormCheckDelegate {
id: makeCanonicalCheck
text: i18nc("@option:check The canonical parent is the default one if a room has multiple parent spaces.", "Make this space the canonical parent")
@@ -237,6 +260,9 @@ FormCard.FormCardPage {
enabled: existingOfficialCheck.enabled
}
FormCard.FormDelegateSeparator {}
FormCard.FormButtonDelegate {
text: i18nc("@action:button", "Ok")
enabled: chosenRoomDelegate.visible

Some files were not shown because too many files have changed in this diff Show More