mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-01-08 08:12:37 +01:00
add emoji verification
This commit is contained in:
parent
334bb9c664
commit
8114284ffa
@ -13,6 +13,8 @@ import '../l10n/l10n.dart';
|
|||||||
import '../utils/beautify_string_extension.dart';
|
import '../utils/beautify_string_extension.dart';
|
||||||
import '../utils/famedlysdk_store.dart';
|
import '../utils/famedlysdk_store.dart';
|
||||||
import 'avatar.dart';
|
import 'avatar.dart';
|
||||||
|
import '../views/key_verification.dart';
|
||||||
|
import '../utils/app_route.dart';
|
||||||
|
|
||||||
class Matrix extends StatefulWidget {
|
class Matrix extends StatefulWidget {
|
||||||
static const String callNamespace = 'chat.fluffy.jitsi_call';
|
static const String callNamespace = 'chat.fluffy.jitsi_call';
|
||||||
@ -96,6 +98,7 @@ class MatrixState extends State<Matrix> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
StreamSubscription onRoomKeyRequestSub;
|
StreamSubscription onRoomKeyRequestSub;
|
||||||
|
StreamSubscription onKeyVerificationRequestSub;
|
||||||
StreamSubscription onJitsiCallSub;
|
StreamSubscription onJitsiCallSub;
|
||||||
|
|
||||||
void onJitsiCall(EventUpdate eventUpdate) {
|
void onJitsiCall(EventUpdate eventUpdate) {
|
||||||
@ -180,6 +183,22 @@ class MatrixState extends State<Matrix> {
|
|||||||
await request.forwardKey();
|
await request.forwardKey();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
onKeyVerificationRequestSub ??= client.onKeyVerificationRequest.stream.listen((KeyVerification request) async {
|
||||||
|
if (await SimpleDialogs(context).askConfirmation(
|
||||||
|
titleText: 'New verification request from ${request.userId} and device ${request.deviceId}',
|
||||||
|
contentText: 'Start verification?',
|
||||||
|
)) {
|
||||||
|
await request.acceptVerification();
|
||||||
|
await Navigator.of(context).push(
|
||||||
|
AppRoute.defaultRoute(
|
||||||
|
context,
|
||||||
|
KeyVerificationView(request: request),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await request.rejectVerification();
|
||||||
|
}
|
||||||
|
});
|
||||||
_initWithStore();
|
_initWithStore();
|
||||||
} else {
|
} else {
|
||||||
client = widget.client;
|
client = widget.client;
|
||||||
|
@ -6,6 +6,8 @@ import 'package:fluffychat/utils/beautify_string_extension.dart';
|
|||||||
import 'package:fluffychat/l10n/l10n.dart';
|
import 'package:fluffychat/l10n/l10n.dart';
|
||||||
import 'package:fluffychat/views/chat_list.dart';
|
import 'package:fluffychat/views/chat_list.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'key_verification.dart';
|
||||||
|
import '../utils/app_route.dart';
|
||||||
|
|
||||||
class ChatEncryptionSettingsView extends StatelessWidget {
|
class ChatEncryptionSettingsView extends StatelessWidget {
|
||||||
final String id;
|
final String id;
|
||||||
@ -109,8 +111,13 @@ class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
|
|||||||
deviceKeys[i]
|
deviceKeys[i]
|
||||||
.setBlocked(false, Matrix.of(context).client);
|
.setBlocked(false, Matrix.of(context).client);
|
||||||
}
|
}
|
||||||
deviceKeys[i]
|
final req = deviceKeys[i].startVerification(Matrix.of(context).client);
|
||||||
.setVerified(true, Matrix.of(context).client);
|
Navigator.of(context).push(
|
||||||
|
AppRoute.defaultRoute(
|
||||||
|
context,
|
||||||
|
KeyVerificationView(request: req),
|
||||||
|
),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
if (deviceKeys[i].verified) {
|
if (deviceKeys[i].verified) {
|
||||||
deviceKeys[i].setVerified(
|
deviceKeys[i].setVerified(
|
||||||
|
@ -18,9 +18,9 @@ class HomeserverPicker extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _checkHomeserverAction(String homeserver, BuildContext context) async {
|
void _checkHomeserverAction(String homeserver, BuildContext context) async {
|
||||||
if (!homeserver.startsWith('https://')) {
|
// if (!homeserver.startsWith('https://')) {
|
||||||
homeserver = 'https://$homeserver';
|
// homeserver = 'https://$homeserver';
|
||||||
}
|
// }
|
||||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||||
Matrix.of(context).client.checkServer(homeserver));
|
Matrix.of(context).client.checkServer(homeserver));
|
||||||
if (success != false) {
|
if (success != false) {
|
||||||
|
71
lib/views/key_verification.dart
Normal file
71
lib/views/key_verification.dart
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
import 'chat_list.dart';
|
||||||
|
import '../components/adaptive_page_layout.dart';
|
||||||
|
|
||||||
|
class KeyVerificationView extends StatelessWidget {
|
||||||
|
final KeyVerification request;
|
||||||
|
|
||||||
|
KeyVerificationView({this.request});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AdaptivePageLayout(
|
||||||
|
primaryPage: FocusPage.SECOND,
|
||||||
|
firstScaffold: ChatList(),
|
||||||
|
secondScaffold: KeyVerificationPage(request: request),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class KeyVerificationPage extends StatefulWidget {
|
||||||
|
final KeyVerification request;
|
||||||
|
|
||||||
|
KeyVerificationPage({this.request});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_KeyVerificationPageState createState() => _KeyVerificationPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _KeyVerificationPageState extends State<KeyVerificationPage> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
widget.request.onUpdate = () => setState(() => null);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
switch (widget.request.state) {
|
||||||
|
case KeyVerificationState.askAccept:
|
||||||
|
return Text('Accept this request? (you should never see this)');
|
||||||
|
case KeyVerificationState.waitingAccept:
|
||||||
|
return Text('Waiting for partner to accept the request...');
|
||||||
|
case KeyVerificationState.askSas:
|
||||||
|
final emojis = widget.request.sasEmojis;
|
||||||
|
final emojiWidgets = emojis.map((e) => Text(e.emoji, style: TextStyle(fontSize: 20))).toList();
|
||||||
|
return Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Row(
|
||||||
|
children: emojiWidgets,
|
||||||
|
),
|
||||||
|
FlatButton(
|
||||||
|
child: Text('Match'),
|
||||||
|
onPressed: () => widget.request.acceptSas(),
|
||||||
|
),
|
||||||
|
FlatButton(
|
||||||
|
child: Text('Reject'),
|
||||||
|
onPressed: () => widget.request.rejectSas(),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
case KeyVerificationState.waitingSas:
|
||||||
|
return Text('Waiting for partner to accept the emoji...');
|
||||||
|
case KeyVerificationState.done:
|
||||||
|
return Text('Verification done!');
|
||||||
|
case KeyVerificationState.error:
|
||||||
|
return Text('Error ${widget.request.canceledCode}: ${widget.request.canceledReason}');
|
||||||
|
}
|
||||||
|
return Text('Unknown state');
|
||||||
|
}
|
||||||
|
}
|
43
pubspec.lock
43
pubspec.lock
@ -71,13 +71,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.3"
|
version: "1.1.3"
|
||||||
clock:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: clock
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.1"
|
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -136,21 +129,12 @@ packages:
|
|||||||
url: "https://github.com/simolus3/moor.git"
|
url: "https://github.com/simolus3/moor.git"
|
||||||
source: git
|
source: git
|
||||||
version: "1.0.0"
|
version: "1.0.0"
|
||||||
fake_async:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: fake_async
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.0"
|
|
||||||
famedlysdk:
|
famedlysdk:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "/home/sorunome/repos/famedly/famedlysdk"
|
||||||
ref: bb690a22daab54a53a8df8e2dffb87da8a374bb1
|
relative: false
|
||||||
resolved-ref: bb690a22daab54a53a8df8e2dffb87da8a374bb1
|
source: path
|
||||||
url: "https://gitlab.com/famedly/famedlysdk.git"
|
|
||||||
source: git
|
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
ffi:
|
ffi:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
@ -399,11 +383,9 @@ packages:
|
|||||||
matrix_file_e2ee:
|
matrix_file_e2ee:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "/home/sorunome/repos/famedly/matrix_file_e2ee"
|
||||||
ref: "1.x.y"
|
relative: false
|
||||||
resolved-ref: "32edeff765369a7a77a0822f4b19302ca24a017b"
|
source: path
|
||||||
url: "https://gitlab.com/famedly/libraries/matrix_file_e2ee.git"
|
|
||||||
source: git
|
|
||||||
version: "1.0.3"
|
version: "1.0.3"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
@ -465,8 +447,8 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: "1.x.y"
|
ref: "2ef8828859e0c4f6064038e45d89be3e46f8013c"
|
||||||
resolved-ref: "79868b06b3ea156f90b73abafb3bbf3ac4114cc6"
|
resolved-ref: "2ef8828859e0c4f6064038e45d89be3e46f8013c"
|
||||||
url: "https://gitlab.com/famedly/libraries/dart-olm.git"
|
url: "https://gitlab.com/famedly/libraries/dart-olm.git"
|
||||||
source: git
|
source: git
|
||||||
version: "1.0.0"
|
version: "1.0.0"
|
||||||
@ -497,7 +479,7 @@ packages:
|
|||||||
name: path
|
name: path
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.7.0"
|
version: "1.6.4"
|
||||||
path_drawing:
|
path_drawing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -575,6 +557,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.2"
|
version: "1.4.2"
|
||||||
|
quiver:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: quiver
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.3"
|
||||||
random_string:
|
random_string:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -25,9 +25,10 @@ dependencies:
|
|||||||
cupertino_icons: ^0.1.2
|
cupertino_icons: ^0.1.2
|
||||||
|
|
||||||
famedlysdk:
|
famedlysdk:
|
||||||
git:
|
path: /home/sorunome/repos/famedly/famedlysdk
|
||||||
url: https://gitlab.com/famedly/famedlysdk.git
|
# git:
|
||||||
ref: bb690a22daab54a53a8df8e2dffb87da8a374bb1
|
# url: https://gitlab.com/famedly/famedlysdk.git
|
||||||
|
# ref: bb690a22daab54a53a8df8e2dffb87da8a374bb1
|
||||||
|
|
||||||
localstorage: ^3.0.1+4
|
localstorage: ^3.0.1+4
|
||||||
bubble: ^1.1.9+1
|
bubble: ^1.1.9+1
|
||||||
|
Loading…
Reference in New Issue
Block a user