aboutsummaryrefslogtreecommitdiff
path: root/plugins/omemo/vapi
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2018-11-10 08:05:14 -0600
committerMarvin W <git@larma.de>2018-11-10 08:05:14 -0600
commitdfb75e2cda1eb9edbbdd9ea88c131d9cb31742ed (patch)
treed3c1ae4251844239eb46e57c8eacf03466aed608 /plugins/omemo/vapi
parent559bbc5ca3ad5d44ea949788005a29fe9d86a232 (diff)
parent65a12021bc7abbf5ddea068ffe9b4715cfc34f0b (diff)
downloaddino-dfb75e2cda1eb9edbbdd9ea88c131d9cb31742ed.tar.gz
dino-dfb75e2cda1eb9edbbdd9ea88c131d9cb31742ed.zip
Merge PR #413 "Improvements to the OMEMO plugin"
Diffstat (limited to 'plugins/omemo/vapi')
-rw-r--r--plugins/omemo/vapi/qrencode.vapi50
1 files changed, 50 insertions, 0 deletions
diff --git a/plugins/omemo/vapi/qrencode.vapi b/plugins/omemo/vapi/qrencode.vapi
new file mode 100644
index 00000000..fc77c855
--- /dev/null
+++ b/plugins/omemo/vapi/qrencode.vapi
@@ -0,0 +1,50 @@
+using Gdk;
+
+[CCode (cheader_filename = "qrencode.h")]
+namespace Qrencode {
+
+ [CCode (cname = "QRecLevel", cprefix = "QR_ECLEVEL_")]
+ public enum ECLevel {
+ L,
+ M,
+ Q,
+ H
+ }
+
+ [CCode (cname = "QRencodeMode", cprefix = "QR_MODE_")]
+ public enum EncodeMode {
+ NUL,
+ NUM,
+ AN,
+ [CCode (cname = "QR_MODE_8")]
+ EIGHT_BIT,
+ KANJI,
+ STRUCTURE,
+ ECI,
+ FNC1FIRST,
+ FNC1SECOND
+ }
+
+ [CCode (cname = "QRcode", free_function = "QRcode_free", has_type_id = false)]
+ [Compact]
+ public class QRcode {
+ private int version;
+ private int width;
+ [CCode (array_length = false)]
+ private uint8[] data;
+
+ [CCode (cname = "QRcode_encodeString")]
+ public QRcode (string str, int version = 0, ECLevel level = ECLevel.L, EncodeMode hint = EncodeMode.EIGHT_BIT, bool casesensitive = true);
+
+ public Pixbuf to_pixbuf() {
+ uint8[] bitmap = new uint8[3*width*width];
+ for (int i = 0; i < width*width; i++) {
+ uint8 color = (data[i] & 1) == 1 ? 0 : 255;
+ bitmap[i*3] = color;
+ bitmap[i*3+1] = color;
+ bitmap[i*3+2] = color;
+ }
+ return new Pixbuf.from_data(bitmap, Colorspace.RGB, false, 8, width, width, width*3);
+ }
+ }
+}