Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding device verification to user profile #203

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2e0afde
First design iteration of device verification dialogs
deepbluev7 Mar 8, 2020
b6997db
Add DeviceVerificationFlow dummy and verification test button
deepbluev7 Mar 13, 2020
01a7e0c
Set proper emoji font for device verification
deepbluev7 Mar 14, 2020
b3495bd
Make emojis a bit smaller
deepbluev7 Mar 20, 2020
42a7ac2
Use label in device verification dialogs (for proper theming)
deepbluev7 Mar 30, 2020
689894f
Add DeviceVerificationFlow dummy and verification test button
deepbluev7 Mar 13, 2020
07823f8
Rewrite UserProfile in qml
Chethan2k1 May 17, 2020
2d23353
Adding DeviceList for userprofile
Chethan2k1 May 22, 2020
a4d9cc4
Add C++ Model for DeviceList
Chethan2k1 May 27, 2020
24f59ae
Tweak UI for device verification and Add more slots
Chethan2k1 Jun 4, 2020
0035cc6
Add SAS Method choice and Add send_to_device API call
Chethan2k1 Jun 7, 2020
bbaf15b
Handle Device Verification related to_device messages
Chethan2k1 Jun 9, 2020
8da77bc
Add DeviceVerificationList to keep track of all flows and Popup on
Chethan2k1 Jun 17, 2020
30aaf8c
Shared secret with decimal and emoji works!
Chethan2k1 Jun 20, 2020
33c13ee
Add some more slots and mac
Chethan2k1 Jun 22, 2020
0d8bbfe
Some Improvements
Chethan2k1 Jun 23, 2020
7cc2df9
Some more changes
Chethan2k1 Jun 24, 2020
ff1176e
Fix presence indicator
deepbluev7 Jun 24, 2020
26874eb
Some more fixes
Chethan2k1 Jun 25, 2020
303ceb9
Fix the Weird auto-confirmation and cancellation
Chethan2k1 Jun 25, 2020
2edbf57
Add some Userprofile buttons
Chethan2k1 Jun 25, 2020
2f1d026
Error Handling and some fixes
Chethan2k1 Jun 26, 2020
362ab16
[WIP] Add Caching for users
Chethan2k1 Jun 28, 2020
9e3f900
Some issue with UserProfile
Chethan2k1 Jul 1, 2020
c7e1600
Refactor UserProfile
deepbluev7 Jul 4, 2020
fcbff88
Adding icons to UserProfile
Chethan2k1 Jul 5, 2020
eb80360
Updating keys of outdated encrypted users
Chethan2k1 Jul 6, 2020
ce2acbd
Adding Room Key Verification Stuff
Chethan2k1 Jul 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ set(SRC_FILES
src/dialogs/ReCaptcha.cpp
src/dialogs/ReadReceipts.cpp
src/dialogs/RoomSettings.cpp
src/dialogs/UserProfile.cpp

# Emoji
src/emoji/Category.cpp
Expand Down Expand Up @@ -277,6 +276,7 @@ set(SRC_FILES
src/ui/ToggleButton.cpp
src/ui/Theme.cpp
src/ui/ThemeManager.cpp
src/ui/UserProfile.cpp

src/AvatarProvider.cpp
src/BlurhashProvider.cpp
Expand All @@ -285,6 +285,7 @@ set(SRC_FILES
src/ColorImageProvider.cpp
src/CommunitiesList.cpp
src/CommunitiesListItem.cpp
src/DeviceVerificationFlow.cpp
src/EventAccessors.cpp
src/InviteeItem.cpp
src/Logging.cpp
Expand Down Expand Up @@ -444,7 +445,6 @@ qt5_wrap_cpp(MOC_HEADERS
src/dialogs/ReCaptcha.h
src/dialogs/ReadReceipts.h
src/dialogs/RoomSettings.h
src/dialogs/UserProfile.h

# Emoji
src/emoji/Category.h
Expand Down Expand Up @@ -479,6 +479,7 @@ qt5_wrap_cpp(MOC_HEADERS
src/ui/ToggleButton.h
src/ui/Theme.h
src/ui/ThemeManager.h
src/ui/UserProfile.h

src/notifications/Manager.h

Expand All @@ -488,6 +489,7 @@ qt5_wrap_cpp(MOC_HEADERS
src/ChatPage.h
src/CommunitiesList.h
src/CommunitiesListItem.h
src/DeviceVerificationFlow.h
src/InviteeItem.h
src/LoginPage.h
src/MainWindow.h
Expand Down
12 changes: 7 additions & 5 deletions resources/qml/Avatar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import QtQuick 2.6
import QtQuick.Controls 2.3
import QtGraphicalEffects 1.0

import im.nheko 1.0

Rectangle {
id: avatar
width: 48
height: 48
radius: settings.avatarCircles ? height/2 : 3
radius: Settings.avatarCircles ? height/2 : 3

property alias url: img.source
property string userid
Expand Down Expand Up @@ -40,7 +42,7 @@ Rectangle {
anchors.fill: parent
width: avatar.width
height: avatar.height
radius: settings.avatarCircles ? height/2 : 3
radius: Settings.avatarCircles ? height/2 : 3
}
}

Expand All @@ -52,11 +54,11 @@ Rectangle {

height: avatar.height / 6
width: height
radius: settings.avatarCircles ? height / 2 : height / 4
color: switch (timelineManager.userPresence(userid)) {
radius: Settings.avatarCircles ? height / 2 : height / 4
color: switch (TimelineManager.userPresence(userid)) {
case "online": return "#00cc66"
case "unavailable": return "#ff9933"
case "offline": return "#a82353"
case "offline": // return "#a82353" don't show anything if offline, since it is confusing, if presence is disabled
default: "transparent"
}
}
Expand Down
6 changes: 4 additions & 2 deletions resources/qml/MatrixText.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import QtQuick 2.5
import QtQuick.Controls 2.3

import im.nheko 1.0

TextEdit {
textFormat: TextEdit.RichText
readOnly: true
Expand All @@ -10,10 +12,10 @@ TextEdit {

onLinkActivated: {
if (/^https:\/\/matrix.to\/#\/(@.*)$/.test(link)) chat.model.openUserProfile(/^https:\/\/matrix.to\/#\/(@.*)$/.exec(link)[1])
else if (/^https:\/\/matrix.to\/#\/(![^\/]*)$/.test(link)) timelineManager.setHistoryView(/^https:\/\/matrix.to\/#\/(!.*)$/.exec(link)[1])
else if (/^https:\/\/matrix.to\/#\/(![^\/]*)$/.test(link)) TimelineManager.setHistoryView(/^https:\/\/matrix.to\/#\/(!.*)$/.exec(link)[1])
else if (/^https:\/\/matrix.to\/#\/(![^\/]*)\/(\$.*)$/.test(link)) {
var match = /^https:\/\/matrix.to\/#\/(![^\/]*)\/(\$.*)$/.exec(link)
timelineManager.setHistoryView(match[1])
TimelineManager.setHistoryView(match[1])
chat.positionViewAtIndex(chat.model.idToIndex(match[2]), ListView.Contain)
}
else Qt.openUrlExternally(link)
Expand Down
8 changes: 5 additions & 3 deletions resources/qml/Reactions.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import QtQuick 2.6
import QtQuick.Controls 2.2

import im.nheko 1.0

// This class is for showing Reactions in the timeline row, not for
// adding new reactions via the emoji picker
Flow {
Expand Down Expand Up @@ -34,7 +36,7 @@ Flow {

onClicked: {
console.debug("Picked " + model.key + "in response to " + reactionFlow.eventId + " in room " + reactionFlow.roomId + ". selfReactedEvent: " + model.selfReactedEvent)
timelineManager.reactToMessage(reactionFlow.roomId, reactionFlow.eventId, model.key, model.selfReactedEvent)
TimelineManager.reactToMessage(reactionFlow.roomId, reactionFlow.eventId, model.key, model.selfReactedEvent)
}


Expand All @@ -46,7 +48,7 @@ Flow {

TextMetrics {
id: textMetrics
font.family: settings.emojiFont
font.family: Settings.emojiFont
elide: Text.ElideRight
elideWidth: 150
text: model.key
Expand All @@ -56,7 +58,7 @@ Flow {
anchors.baseline: reactionCounter.baseline
id: reactionText
text: textMetrics.elidedText + (textMetrics.elidedText == model.key ? "" : "…")
font.family: settings.emojiFont
font.family: Settings.emojiFont
color: reaction.hovered ? colors.highlight : colors.text
maximumLineCount: 1
}
Expand Down
10 changes: 5 additions & 5 deletions resources/qml/TimelineRow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ MouseArea {
messageContextMenu.show(model.id, model.type, model.isEncrypted, row)
}
Rectangle {
color: (settings.messageHoverHighlight && parent.containsMouse) ? colors.base : "transparent"
color: (Settings.messageHoverHighlight && parent.containsMouse) ? colors.base : "transparent"
anchors.fill: row
}
RowLayout {
Expand All @@ -46,7 +46,7 @@ MouseArea {
Reply {
visible: model.replyTo
modelData: chat.model.getDump(model.replyTo)
userColor: timelineManager.userColor(modelData.userId, colors.window)
userColor: TimelineManager.userColor(modelData.userId, colors.window)
}

// actual message content
Expand Down Expand Up @@ -81,7 +81,7 @@ MouseArea {
width: 16
}
EmojiButton {
visible: settings.buttonsInTimeline
visible: Settings.buttonsInTimeline
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: 16
Expand All @@ -94,7 +94,7 @@ MouseArea {
event_id: model.id
}
ImageButton {
visible: settings.buttonsInTimeline
visible: Settings.buttonsInTimeline
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: 16
Expand All @@ -110,7 +110,7 @@ MouseArea {
onClicked: chat.model.replyAction(model.id)
}
ImageButton {
visible: settings.buttonsInTimeline
visible: Settings.buttonsInTimeline
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: 16
Expand Down
60 changes: 42 additions & 18 deletions resources/qml/TimelineView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import im.nheko.EmojiModel 1.0

import "./delegates"
import "./emoji"
import "./device-verification"

Page {
property var colors: currentActivePalette
Expand All @@ -18,6 +19,7 @@ Page {
property real highlightHue: colors.highlight.hslHue
property real highlightSat: colors.highlight.hslSaturation
property real highlightLight: colors.highlight.hslLightness
property variant userProfile

palette: colors

Expand Down Expand Up @@ -83,7 +85,7 @@ Page {
visible: messageContextMenu.eventType == MtxEvent.ImageMessage || messageContextMenu.eventType == MtxEvent.VideoMessage || messageContextMenu.eventType == MtxEvent.AudioMessage || messageContextMenu.eventType == MtxEvent.FileMessage || messageContextMenu.eventType == MtxEvent.Sticker
height: visible ? implicitHeight : 0
text: qsTr("Save as")
onTriggered: timelineManager.timeline.saveMedia(messageContextMenu.eventId)
onTriggered: TimelineManager.timeline.saveMedia(messageContextMenu.eventId)
}
}

Expand All @@ -93,8 +95,32 @@ Page {
anchors.fill: parent
color: colors.window

Component {
id: deviceVerificationDialog
DeviceVerification {}
}
Connections {
target: TimelineManager
function onNewDeviceVerificationRequest(flow,transactionId,userId,deviceId) {
flow.userId = userId;
flow.sender = false;
flow.deviceId = deviceId;
flow.tranId = transactionId;
deviceVerificationList.add(flow.tranId);
var dialog = deviceVerificationDialog.createObject(timelineRoot, {flow: flow});
dialog.show();
}
}
Connections {
target: TimelineManager.timeline
function onOpenProfile(profile) {
var userProfile = userProfileComponent.createObject(timelineRoot,{profile: profile});
userProfile.show();
}
}

Label {
visible: !timelineManager.timeline && !timelineManager.isInitialSync
visible: !TimelineManager.timeline && !TimelineManager.isInitialSync
anchors.centerIn: parent
text: qsTr("No room open")
font.pointSize: 24
Expand All @@ -104,7 +130,7 @@ Page {
BusyIndicator {
visible: running
anchors.centerIn: parent
running: timelineManager.isInitialSync
running: TimelineManager.isInitialSync
height: 200
width: 200
z: 3
Expand All @@ -113,7 +139,7 @@ Page {
ListView {
id: chat

visible: timelineManager.timeline != null
visible: TimelineManager.timeline != null

cacheBuffer: 400

Expand All @@ -125,7 +151,7 @@ Page {
anchors.leftMargin: 4
anchors.rightMargin: scrollbar.width

model: timelineManager.timeline
model: TimelineManager.timeline

boundsBehavior: Flickable.StopAtBounds

Expand Down Expand Up @@ -171,7 +197,7 @@ Page {

onCountChanged: if (atYEnd) model.currentIndex = 0 // Mark last event as read, since we are at the bottom

property int delegateMaxWidth: (settings.timelineMaxWidth > 100 && (parent.width - settings.timelineMaxWidth) > 32) ? settings.timelineMaxWidth : (parent.width - 32)
property int delegateMaxWidth: (Settings.timelineMaxWidth > 100 && (parent.width - Settings.timelineMaxWidth) > 32) ? Settings.timelineMaxWidth : (parent.width - 32)

delegate: Rectangle {
// This would normally be previousSection, but our model's order is inverted.
Expand Down Expand Up @@ -213,6 +239,11 @@ Page {

}

Component{
id: userProfileComponent
UserProfile{}
}

section {
property: "section"
}
Expand Down Expand Up @@ -248,6 +279,7 @@ Page {
color: colors.base
}
}

Row {
height: userName.height
spacing: 8
Expand All @@ -270,25 +302,17 @@ Page {
Label {
id: userName
text: chat.model.escapeEmoji(modelData.userName)
color: timelineManager.userColor(modelData.userId, colors.window)
color: TimelineManager.userColor(modelData.userId, colors.window)
textFormat: Text.RichText

MouseArea {
anchors.fill: parent
onClicked: chat.model.openUserProfile(section.split(" ")[0])
Layout.alignment: Qt.AlignHCenter
onClicked: chat.model.openUserProfile(modelData.userId)
cursorShape: Qt.PointingHandCursor
propagateComposedEvents: true
}
}

Label {
color: colors.buttonText
text: timelineManager.userStatus(modelData.userId)
textFormat: Text.PlainText
elide: Text.ElideRight
width: chat.delegateMaxWidth - parent.spacing*2 - userName.implicitWidth - avatarSize
font.italic: true
}
}
}
}
Expand Down Expand Up @@ -352,7 +376,7 @@ Page {
anchors.bottom: parent.bottom

modelData: chat.model ? chat.model.getDump(chat.model.reply) : {}
userColor: timelineManager.userColor(modelData.userId, colors.window)
userColor: TimelineManager.userColor(modelData.userId, colors.window)
}

ImageButton {
Expand Down
Loading