diff options
author | Michael Vetter <jubalh@iodoru.org> | 2022-05-30 18:04:36 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2022-05-30 18:04:36 +0200 |
commit | cf83976b51dd103a17b75dd77f326f64166199bc (patch) | |
tree | c4307d8ba27a81e3319ca87df7282cfed42342f4 /src/ui | |
parent | 010ed78b32a501395476ec98cab5cdff4c32fb12 (diff) | |
download | profani-tty-cf83976b51dd103a17b75dd77f326f64166199bc.tar.gz |
Add basic qrcode functions
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/console.c | 34 | ||||
-rw-r--r-- | src/ui/ui.h | 4 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/ui/console.c b/src/ui/console.c index 3e7a0844..ae1f796d 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -48,6 +48,10 @@ #include <curses.h> #endif +#ifdef HAVE_QRENCODE +#include <qrencode.h> +#endif + #include "common.h" #include "log.h" #include "config/preferences.h" @@ -863,6 +867,36 @@ cons_show_disco_contact_information(GHashTable* addresses) } void +cons_show_omemo_qrcode(const char* const text) +{ +#ifdef HAVE_QRENCODE + static const size_t ZOOM_SIZE = 10; + QRcode *qrcode = QRcode_encodeString(text, 0, QR_ECLEVEL_L, QR_MODE_8, 1); + + int width = (qrcode->width * ZOOM_SIZE); + unsigned char *data = qrcode->data; + + ProfWin* console = wins_get_console(); + + for (size_t y = 0; y < width; y+=ZOOM_SIZE) { + //size_t y_index = y * width; + for (size_t x = 0; x < width; x+=ZOOM_SIZE) { + if (x==0) { + win_print(console, THEME_DEFAULT, "", "%s", (*data & 1) ? "A" : "B"); + } else { + win_append(console, THEME_DEFAULT, "", "%s", (*data & 1) ? "A" : "B"); + } + + data++; + } + win_println(console, THEME_DEFAULT, "", ""); + } + + QRcode_free(qrcode); +#endif +} + +void cons_show_status(const char* const barejid) { ProfWin* console = wins_get_console(); diff --git a/src/ui/ui.h b/src/ui/ui.h index 5f31354f..8615045a 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -277,7 +277,11 @@ void cons_show_bookmarks(const GList* list); void cons_show_bookmarks_ignore(gchar** list, gsize len); void cons_show_disco_items(GSList* items, const char* const jid); void cons_show_disco_info(const char* from, GSList* identities, GSList* features); + void cons_show_disco_contact_information(GHashTable* addresses); + +void cons_show_omemo_qrcode(const char* const text); + void cons_show_room_invite(const char* const invitor, const char* const room, const char* const reason); void cons_check_version(gboolean not_available_msg); void cons_show_typing(const char* const barejid); |