aboutsummaryrefslogtreecommitdiff
path: root/libdino
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2021-04-10 23:06:13 +0200
committerfiaxh <git@lightrise.org>2021-04-11 14:42:59 +0200
commit8a54a263f2714560d4eb8d83a61e14d184b61fba (patch)
tree4f53567450b8f98eb38bd8fc416ff11c8ee57628 /libdino
parentdfffa08ec16e16157df6e7036e09073a546d7552 (diff)
downloaddino-8a54a263f2714560d4eb8d83a61e14d184b61fba.tar.gz
dino-8a54a263f2714560d4eb8d83a61e14d184b61fba.zip
Improve encryption displaying in calls
Diffstat (limited to 'libdino')
-rw-r--r--libdino/src/service/calls.vala49
1 files changed, 19 insertions, 30 deletions
diff --git a/libdino/src/service/calls.vala b/libdino/src/service/calls.vala
index ccae3e05..d8cb7990 100644
--- a/libdino/src/service/calls.vala
+++ b/libdino/src/service/calls.vala
@@ -375,13 +375,6 @@ namespace Dino {
content.accept();
}
- private void on_connection_ready(Call call) {
- if (call.state == Call.State.RINGING || call.state == Call.State.ESTABLISHING) {
- call.state = Call.State.IN_PROGRESS;
- }
- update_call_encryption(call);
- }
-
private void on_call_terminated(Call call, bool we_terminated, string? reason_name, string? reason_text) {
if (call.state == Call.State.RINGING || call.state == Call.State.IN_PROGRESS || call.state == Call.State.ESTABLISHING) {
call.end_time = new DateTime.now_utc();
@@ -452,7 +445,7 @@ namespace Dino {
}
rtp_content_parameter.stream_created.connect((stream) => on_stream_created(call, rtp_content_parameter.media, stream));
- rtp_content_parameter.connection_ready.connect((status) => on_connection_ready(call));
+ rtp_content_parameter.connection_ready.connect((status) => on_connection_ready(call, content, rtp_content_parameter.media));
content.senders_modify_incoming.connect((content, proposed_senders) => {
if (content.session.senders_include_us(content.senders) != content.session.senders_include_us(proposed_senders)) {
@@ -466,36 +459,32 @@ namespace Dino {
on_counterpart_mute_update(call, false, "video");
}
});
-
- content.notify["encryption"].connect((obj, _) => {
- if (rtp_content_parameter.media == "audio") {
- audio_encryption[call] = ((Xep.Jingle.Content) obj).encryption;
- } else if (rtp_content_parameter.media == "video") {
- video_encryption[call] = ((Xep.Jingle.Content) obj).encryption;
- }
- });
}
- private void update_call_encryption(Call call) {
- if (audio_encryption[call] == null) {
- call.encryption = Encryption.NONE;
- encryption_updated(call, null);
- return;
+ private void on_connection_ready(Call call, Xep.Jingle.Content content, string media) {
+ if (call.state == Call.State.RINGING || call.state == Call.State.ESTABLISHING) {
+ call.state = Call.State.IN_PROGRESS;
}
- bool consistent_encryption = video_encryption[call] != null && audio_encryption[call].encryption_ns == video_encryption[call].encryption_ns;
+ if (media == "audio") {
+ audio_encryption[call] = content.encryption;
+ } else if (media == "video") {
+ video_encryption[call] = content.encryption;
+ }
- if (video_content[call] == null || consistent_encryption) {
- if (audio_encryption[call].encryption_ns == Xep.JingleIceUdp.DTLS_NS_URI) {
- call.encryption = Encryption.DTLS_SRTP;
- } else if (audio_encryption[call].encryption_name == "SRTP") {
- call.encryption = Encryption.SRTP;
- }
- encryption_updated(call, audio_encryption[call]);
- } else {
+ if ((audio_encryption.has_key(call) && audio_encryption[call] == null) || (video_encryption.has_key(call) && video_encryption[call] == null)) {
call.encryption = Encryption.NONE;
encryption_updated(call, null);
+ return;
+ }
+
+ Xep.Jingle.ContentEncryption encryption = audio_encryption[call] ?? video_encryption[call];
+ if (encryption.encryption_ns == Xep.JingleIceUdp.DTLS_NS_URI) {
+ call.encryption = Encryption.DTLS_SRTP;
+ } else if (encryption.encryption_name == "SRTP") {
+ call.encryption = Encryption.SRTP;
}
+ encryption_updated(call, encryption);
}
private void remove_call_from_datastructures(Call call) {