aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/call_window
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui/call_window')
-rw-r--r--main/src/ui/call_window/call_bottom_bar.vala64
-rw-r--r--main/src/ui/call_window/call_encryption_button.vala77
-rw-r--r--main/src/ui/call_window/call_window_controller.vala17
3 files changed, 94 insertions, 64 deletions
diff --git a/main/src/ui/call_window/call_bottom_bar.vala b/main/src/ui/call_window/call_bottom_bar.vala
index 64b157dd..8a0604b3 100644
--- a/main/src/ui/call_window/call_bottom_bar.vala
+++ b/main/src/ui/call_window/call_bottom_bar.vala
@@ -25,8 +25,7 @@ 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 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 };
+ public CallEntryptionButton encryption_button = new CallEntryptionButton() { relief=ReliefStyle.NONE, height_request=30, width_request=30, margin_start=20, margin_bottom=25, halign=Align.START, valign=Align.END };
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 };
@@ -35,8 +34,6 @@ public class Dino.Ui.CallBottomBar : Gtk.Box {
Object(orientation:Orientation.HORIZONTAL, spacing:0);
Overlay default_control = new Overlay() { visible=true };
- 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 };
@@ -89,54 +86,6 @@ public class Dino.Ui.CallBottomBar : Gtk.Box {
this.get_style_context().add_class("call-bottom-bar");
}
- public void set_encryption(Xmpp.Xep.Jingle.ContentEncryption? audio_encryption, Xmpp.Xep.Jingle.ContentEncryption? video_encryption, bool same) {
- encryption_button.visible = true;
-
- Popover popover = new Popover(encryption_button);
- if (audio_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 } );
- return;
- }
-
- encryption_image.set_from_icon_name("changes-prevent-symbolic", IconSize.BUTTON);
- encryption_button.get_style_context().remove_class("unencrypted");
-
- Box box = new Box(Orientation.VERTICAL, 5) { margin=10, visible=true };
- if (audio_encryption.encryption_name == "OMEMO") {
- box.add(new Label("<b>This call is encrypted with OMEMO.</b>") { use_markup=true, xalign=0, visible=true } );
- } else {
- box.add(new Label("<b>This call is end-to-end encrypted.</b>") { use_markup=true, xalign=0, visible=true });
- }
-
- if (same) {
- box.add(create_media_encryption_grid(audio_encryption));
- } else {
- box.add(new Label("<b>Audio</b>") { use_markup=true, xalign=0, visible=true });
- box.add(create_media_encryption_grid(audio_encryption));
- box.add(new Label("<b>Video</b>") { use_markup=true, xalign=0, visible=true });
- box.add(create_media_encryption_grid(video_encryption));
- }
- popover.add(box);
-
- encryption_button.set_popover(popover);
- }
-
- private Grid create_media_encryption_grid(Xmpp.Xep.Jingle.ContentEncryption? encryption) {
- Grid ret = new Grid() { row_spacing=3, column_spacing=5, visible=true };
- if (encryption.peer_key.length > 0) {
- ret.attach(new Label("Peer call key") { xalign=0, visible=true }, 1, 2, 1, 1);
- ret.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);
- }
- if (encryption.our_key.length > 0) {
- ret.attach(new Label("Your call key") { xalign=0, visible=true }, 1, 3, 1, 1);
- ret.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);
- }
- return ret;
- }
-
public AudioSettingsPopover? show_audio_device_choices(bool show) {
audio_settings_button.visible = show;
if (audio_settings_popover != null) audio_settings_popover.visible = false;
@@ -212,15 +161,4 @@ public class Dino.Ui.CallBottomBar : Gtk.Box {
public bool is_menu_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_encryption_button.vala b/main/src/ui/call_window/call_encryption_button.vala
new file mode 100644
index 00000000..1d785d51
--- /dev/null
+++ b/main/src/ui/call_window/call_encryption_button.vala
@@ -0,0 +1,77 @@
+using Dino.Entities;
+using Gtk;
+using Pango;
+
+public class Dino.Ui.CallEntryptionButton : MenuButton {
+
+ private Image encryption_image = new Image.from_icon_name("changes-allow-symbolic", IconSize.BUTTON) { visible=true };
+
+ construct {
+ add(encryption_image);
+ get_style_context().add_class("encryption-box");
+ this.set_popover(popover);
+ }
+
+ public void set_icon(bool encrypted, string? icon_name) {
+ this.visible = true;
+
+ if (encrypted) {
+ encryption_image.set_from_icon_name(icon_name ?? "changes-prevent-symbolic", IconSize.BUTTON);
+ get_style_context().remove_class("unencrypted");
+ } else {
+ encryption_image.set_from_icon_name(icon_name ?? "changes-allow-symbolic", IconSize.BUTTON);
+ get_style_context().add_class("unencrypted");
+ }
+ }
+
+ public void set_info(string? title, bool show_keys, Xmpp.Xep.Jingle.ContentEncryption? audio_encryption, Xmpp.Xep.Jingle.ContentEncryption? video_encryption) {
+ Popover popover = new Popover(this);
+ this.set_popover(popover);
+
+ if (audio_encryption == null) {
+ popover.add(new Label("This call is unencrypted.") { margin=10, visible=true } );
+ return;
+ }
+ if (title != null && !show_keys) {
+ popover.add(new Label(title) { use_markup=true, margin=10, visible=true } );
+ return;
+ }
+
+ Box box = new Box(Orientation.VERTICAL, 10) { margin=10, visible=true };
+ box.add(new Label("<b>%s</b>".printf(title ?? "This call is end-to-end encrypted.")) { use_markup=true, xalign=0, visible=true });
+
+ if (video_encryption == null) {
+ box.add(create_media_encryption_grid(audio_encryption));
+ } else {
+ box.add(new Label("<b>Audio</b>") { use_markup=true, xalign=0, visible=true });
+ box.add(create_media_encryption_grid(audio_encryption));
+ box.add(new Label("<b>Video</b>") { use_markup=true, xalign=0, visible=true });
+ box.add(create_media_encryption_grid(video_encryption));
+ }
+ popover.add(box);
+ }
+
+ private Grid create_media_encryption_grid(Xmpp.Xep.Jingle.ContentEncryption? encryption) {
+ Grid ret = new Grid() { row_spacing=3, column_spacing=5, visible=true };
+ if (encryption.peer_key.length > 0) {
+ ret.attach(new Label("Peer call key") { xalign=0, visible=true }, 1, 2, 1, 1);
+ ret.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);
+ }
+ if (encryption.our_key.length > 0) {
+ ret.attach(new Label("Your call key") { xalign=0, visible=true }, 1, 3, 1, 1);
+ ret.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);
+ }
+ return ret;
+ }
+
+ 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 7e5920ce..b07b41b1 100644
--- a/main/src/ui/call_window/call_window_controller.vala
+++ b/main/src/ui/call_window/call_window_controller.vala
@@ -78,7 +78,22 @@ public class Dino.Ui.CallWindowController : Object {
});
calls.encryption_updated.connect((call, audio_encryption, video_encryption, same) => {
if (!this.call.equals(call)) return;
- call_window.bottom_bar.set_encryption(audio_encryption, video_encryption, same);
+
+ string? title = null;
+ string? icon_name = null;
+ bool show_keys = true;
+ Plugins.Registry registry = Dino.Application.get_default().plugin_registry;
+ Plugins.CallEncryptionEntry? encryption_entry = audio_encryption != null ? registry.call_encryption_entries[audio_encryption.encryption_ns] : null;
+ if (encryption_entry != null) {
+ Plugins.CallEncryptionWidget? encryption_widgets = encryption_entry.get_widget(call.account, audio_encryption);
+ if (encryption_widgets != null) {
+ title = encryption_widgets.get_title();
+ icon_name = encryption_widgets.get_icon_name();
+ show_keys = encryption_widgets.show_keys();
+ }
+ }
+ call_window.bottom_bar.encryption_button.set_info(title, show_keys, audio_encryption, same ? null :video_encryption);
+ call_window.bottom_bar.encryption_button.set_icon(audio_encryption != null, icon_name);
});
own_video.resolution_changed.connect((width, height) => {