aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/call_window
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2021-04-08 12:07:04 +0200
committerfiaxh <git@lightrise.org>2021-04-09 22:23:13 +0200
commit8d1c6c29be7018c74ec3f8ea05f5849eac5b4069 (patch)
treedde27c13cd0ae8af31b9194b3450c58d4fe9cf02 /main/src/ui/call_window
parent3454201e5a3da058ccbef0bbaf467599912a8c38 (diff)
downloaddino-8d1c6c29be7018c74ec3f8ea05f5849eac5b4069.tar.gz
dino-8d1c6c29be7018c74ec3f8ea05f5849eac5b4069.zip
Display+store call encryption info
Diffstat (limited to 'main/src/ui/call_window')
-rw-r--r--main/src/ui/call_window/call_bottom_bar.vala53
-rw-r--r--main/src/ui/call_window/call_window_controller.vala4
2 files changed, 51 insertions, 6 deletions
diff --git a/main/src/ui/call_window/call_bottom_bar.vala b/main/src/ui/call_window/call_bottom_bar.vala
index bc800485..c6375ea2 100644
--- a/main/src/ui/call_window/call_bottom_bar.vala
+++ b/main/src/ui/call_window/call_bottom_bar.vala
@@ -1,5 +1,6 @@
using Dino.Entities;
using Gtk;
+using Pango;
public class Dino.Ui.CallBottomBar : Gtk.Box {
@@ -24,6 +25,10 @@ public class Dino.Ui.CallBottomBar : Gtk.Box {
private MenuButton video_settings_button = new MenuButton() { halign=Align.END, valign=Align.END };
public VideoSettingsPopover? video_settings_popover;
+ private EventBox encryption_event_box = new EventBox() { visible=true };
+ private MenuButton encryption_button = new MenuButton() { relief=ReliefStyle.NONE, height_request=30, width_request=30, margin_start=20, margin_bottom=25, halign=Align.START, valign=Align.END };
+ private Image encryption_image = new Image.from_icon_name("changes-allow-symbolic", IconSize.BUTTON) { visible=true };
+
private Label label = new Label("") { margin=20, halign=Align.CENTER, valign=Align.CENTER, wrap=true, wrap_mode=Pango.WrapMode.WORD_CHAR, hexpand=true, visible=true };
private Stack stack = new Stack() { visible=true };
@@ -31,11 +36,9 @@ public class Dino.Ui.CallBottomBar : Gtk.Box {
Object(orientation:Orientation.HORIZONTAL, spacing:0);
Overlay default_control = new Overlay() { visible=true };
- Image encryption_image = new Image.from_icon_name("changes-allow-symbolic", IconSize.BUTTON) { margin_start=20, margin_bottom=25, halign=Align.START, valign=Align.END, visible=true };
- encryption_image.tooltip_text = _("Unencrypted");
- encryption_image.get_style_context().add_class("unencrypted-box");
-
- default_control.add_overlay(encryption_image);
+ encryption_button.add(encryption_image);
+ encryption_button.get_style_context().add_class("encryption-box");
+ default_control.add_overlay(encryption_button);
Box main_buttons = new Box(Orientation.HORIZONTAL, 20) { margin_start=40, margin_end=40, margin=20, halign=Align.CENTER, hexpand=true, visible=true };
@@ -87,6 +90,33 @@ public class Dino.Ui.CallBottomBar : Gtk.Box {
this.get_style_context().add_class("call-bottom-bar");
}
+ public void set_encryption(Xmpp.Xep.Jingle.ContentEncryption? encryption) {
+ encryption_button.visible = true;
+
+ Popover popover = new Popover(encryption_button);
+
+ if (encryption == null) {
+ encryption_image.set_from_icon_name("changes-allow-symbolic", IconSize.BUTTON);
+ encryption_button.get_style_context().add_class("unencrypted");
+
+ popover.add(new Label("This call isn't encrypted.") { margin=10, visible=true } );
+ } else {
+ encryption_image.set_from_icon_name("changes-prevent-symbolic", IconSize.BUTTON);
+ encryption_button.get_style_context().remove_class("unencrypted");
+
+ Grid encryption_info_grid = new Grid() { margin=10, row_spacing=3, column_spacing=5, visible=true };
+ encryption_info_grid.attach(new Label("<b>This call is end-to-end encrypted.</b>") { use_markup=true, xalign=0, visible=true }, 1, 1, 2, 1);
+ encryption_info_grid.attach(new Label("Peer key") { xalign=0, visible=true }, 1, 2, 1, 1);
+ encryption_info_grid.attach(new Label("Your key") { xalign=0, visible=true }, 1, 3, 1, 1);
+ encryption_info_grid.attach(new Label("<span font_family='monospace'>" + format_fingerprint(encryption.peer_key) + "</span>") { use_markup=true, max_width_chars=25, ellipsize=EllipsizeMode.MIDDLE, xalign=0, hexpand=true, visible=true }, 2, 2, 1, 1);
+ encryption_info_grid.attach(new Label("<span font_family='monospace'>" + format_fingerprint(encryption.our_key) + "</span>") { use_markup=true, max_width_chars=25, ellipsize=EllipsizeMode.MIDDLE, xalign=0, hexpand=true, visible=true }, 2, 3, 1, 1);
+
+ popover.add(encryption_info_grid);
+ }
+
+ encryption_button.set_popover(popover);
+ }
+
public AudioSettingsPopover? show_audio_device_choices(bool show) {
audio_settings_button.visible = show;
if (audio_settings_popover != null) audio_settings_popover.visible = false;
@@ -160,6 +190,17 @@ public class Dino.Ui.CallBottomBar : Gtk.Box {
}
public bool is_menu_active() {
- return video_settings_button.active || audio_settings_button.active;
+ return video_settings_button.active || audio_settings_button.active || encryption_button.active;
+ }
+
+ private string format_fingerprint(uint8[] fingerprint) {
+ var sb = new StringBuilder();
+ for (int i = 0; i < fingerprint.length; i++) {
+ sb.append("%02x".printf(fingerprint[i]));
+ if (i < fingerprint.length - 1) {
+ sb.append(":");
+ }
+ }
+ return sb.str;
}
} \ No newline at end of file
diff --git a/main/src/ui/call_window/call_window_controller.vala b/main/src/ui/call_window/call_window_controller.vala
index 09c8f88c..f66a37e1 100644
--- a/main/src/ui/call_window/call_window_controller.vala
+++ b/main/src/ui/call_window/call_window_controller.vala
@@ -67,6 +67,10 @@ public class Dino.Ui.CallWindowController : Object {
call_window.set_status("ringing");
}
});
+ calls.encryption_updated.connect((call, encryption) => {
+ if (!this.call.equals(call)) return;
+ call_window.bottom_bar.set_encryption(encryption);
+ });
own_video.resolution_changed.connect((width, height) => {
if (width == 0 || height == 0) return;