aboutsummaryrefslogtreecommitdiff
path: root/plugins/omemo/src
diff options
context:
space:
mode:
authormjk <yuubi-san@users.noreply.github.com>2022-02-18 21:41:28 +0000
committermjk <yuubi-san@users.noreply.github.com>2022-02-25 22:26:43 +0000
commit855a98c04501eede6dd3553b1acc5a8d036af743 (patch)
tree5b68556d40ae127db423360292e63df527b17c6b /plugins/omemo/src
parent1309d7e2e42a1fdced3127c641f108fb72cc2fdd (diff)
downloaddino-855a98c04501eede6dd3553b1acc5a8d036af743.tar.gz
dino-855a98c04501eede6dd3553b1acc5a8d036af743.zip
OMEMO: Make QR code fixed-resolution and the quiet zone ISO-conformant
Diffstat (limited to 'plugins/omemo/src')
-rw-r--r--plugins/omemo/src/ui/contact_details_dialog.vala22
1 files changed, 8 insertions, 14 deletions
diff --git a/plugins/omemo/src/ui/contact_details_dialog.vala b/plugins/omemo/src/ui/contact_details_dialog.vala
index b268cc13..18884784 100644
--- a/plugins/omemo/src/ui/contact_details_dialog.vala
+++ b/plugins/omemo/src/ui/contact_details_dialog.vala
@@ -92,20 +92,14 @@ public class ContactDetailsDialog : Gtk.Dialog {
copy_button.clicked.connect(() => {Clipboard.get_default(get_display()).set_text(fingerprint, fingerprint.length);});
int sid = plugin.db.identity.row_with(plugin.db.identity.account_id, account.id)[plugin.db.identity.device_id];
- Pixbuf qr_pixbuf = new QRcode(@"xmpp:$(account.bare_jid)?omemo-sid-$(sid)=$(fingerprint)", 2).to_pixbuf();
- qr_pixbuf = qr_pixbuf.scale_simple(150, 150, InterpType.NEAREST);
-
- Pixbuf pixbuf = new Pixbuf(
- qr_pixbuf.colorspace,
- qr_pixbuf.has_alpha,
- qr_pixbuf.bits_per_sample,
- 170,
- 170
- );
- pixbuf.fill(uint32.MAX);
- qr_pixbuf.copy_area(0, 0, 150, 150, pixbuf, 10, 10);
-
- qrcode_image.set_from_pixbuf(pixbuf);
+
+ const int QUIET_ZONE_MODULES = 4; // MUST be at least 4
+ const int MODULE_SIZE_PX = 4; // arbitrary
+ Pixbuf qr_pixbuf = new QRcode(@"xmpp:$(account.bare_jid)?omemo-sid-$(sid)=$(fingerprint)", 2).to_pixbuf(MODULE_SIZE_PX);
+ qrcode_image.set_from_pixbuf(qr_pixbuf);
+ qrcode_image.margin = QUIET_ZONE_MODULES*MODULE_SIZE_PX;
+ qrcode_popover.get_style_context().add_class("qrcode-container");
+
show_qrcode_button.clicked.connect(qrcode_popover.popup);
}