mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Add basic qrcode functions
This commit is contained in:
parent
010ed78b32
commit
cf83976b51
@ -67,6 +67,8 @@ AC_ARG_ENABLE([icons-and-clipboard],
|
|||||||
[AS_HELP_STRING([--enable-icons-and-clipboard], [enable GTK tray icons and clipboard paste support])])
|
[AS_HELP_STRING([--enable-icons-and-clipboard], [enable GTK tray icons and clipboard paste support])])
|
||||||
AC_ARG_ENABLE([gdk-pixbuf],
|
AC_ARG_ENABLE([gdk-pixbuf],
|
||||||
[AS_HELP_STRING([--enable-gdk-pixbuf], [enable GDK Pixbuf support to scale avatars before uploading])])
|
[AS_HELP_STRING([--enable-gdk-pixbuf], [enable GDK Pixbuf support to scale avatars before uploading])])
|
||||||
|
AC_ARG_ENABLE([omemo-qrcode],
|
||||||
|
[AS_HELP_STRING([--enable-omemo-qrcode], [enable ability to display omemo qr code])])
|
||||||
|
|
||||||
# Required dependencies
|
# Required dependencies
|
||||||
|
|
||||||
@ -345,6 +347,12 @@ AS_IF([test "x$with_themes" = xno -o "x$with_themes" = xyes -o "x$with_themes" =
|
|||||||
AC_SUBST(THEMES_PATH)
|
AC_SUBST(THEMES_PATH)
|
||||||
AM_CONDITIONAL([THEMES_INSTALL], "$THEMES_INSTALL")
|
AM_CONDITIONAL([THEMES_INSTALL], "$THEMES_INSTALL")
|
||||||
|
|
||||||
|
dnl feature: omemo qrcode
|
||||||
|
AS_IF([test "x$omemo_qrcode" != xno],
|
||||||
|
[PKG_CHECK_MODULES([libqrencode], [libqrencode],
|
||||||
|
[AC_DEFINE([HAVE_QRENCODE], [1], [qrcode module])]
|
||||||
|
[LIBS="-lqrencode $LIBS"]], []))
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
# cmocka is required only for tests, profanity shouldn't be linked with it
|
# cmocka is required only for tests, profanity shouldn't be linked with it
|
||||||
|
@ -700,6 +700,7 @@ cmd_ac_init(void)
|
|||||||
autocomplete_add(omemo_ac, "policy");
|
autocomplete_add(omemo_ac, "policy");
|
||||||
autocomplete_add(omemo_ac, "trustmode");
|
autocomplete_add(omemo_ac, "trustmode");
|
||||||
autocomplete_add(omemo_ac, "char");
|
autocomplete_add(omemo_ac, "char");
|
||||||
|
autocomplete_add(omemo_ac, "qrcode");
|
||||||
|
|
||||||
omemo_log_ac = autocomplete_new();
|
omemo_log_ac = autocomplete_new();
|
||||||
autocomplete_add(omemo_log_ac, "on");
|
autocomplete_add(omemo_log_ac, "on");
|
||||||
|
@ -2312,7 +2312,8 @@ static struct cmd_t command_defs[] = {
|
|||||||
{ "fingerprint", cmd_omemo_fingerprint },
|
{ "fingerprint", cmd_omemo_fingerprint },
|
||||||
{ "char", cmd_omemo_char },
|
{ "char", cmd_omemo_char },
|
||||||
{ "policy", cmd_omemo_policy },
|
{ "policy", cmd_omemo_policy },
|
||||||
{ "clear_device_list", cmd_omemo_clear_device_list })
|
{ "clear_device_list", cmd_omemo_clear_device_list },
|
||||||
|
{ "qrcode", cmd_omemo_qrcode })
|
||||||
CMD_NOMAINFUNC
|
CMD_NOMAINFUNC
|
||||||
CMD_TAGS(
|
CMD_TAGS(
|
||||||
CMD_TAG_CHAT,
|
CMD_TAG_CHAT,
|
||||||
|
@ -9035,6 +9035,18 @@ cmd_omemo_policy(ProfWin* window, const char* const command, gchar** args)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cmd_omemo_qrcode(ProfWin* window, const char* const command, gchar** args)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_OMEMO
|
||||||
|
cons_show_omemo_qrcode("some text from me");
|
||||||
|
return TRUE;
|
||||||
|
#else
|
||||||
|
cons_show("This version of Profanity has not been built with OMEMO support enabled");
|
||||||
|
return TRUE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cmd_save(ProfWin* window, const char* const command, gchar** args)
|
cmd_save(ProfWin* window, const char* const command, gchar** args)
|
||||||
{
|
{
|
||||||
|
@ -227,6 +227,7 @@ gboolean cmd_omemo_untrust(ProfWin* window, const char* const command, gchar** a
|
|||||||
gboolean cmd_omemo_trust_mode(ProfWin* window, const char* const command, gchar** args);
|
gboolean cmd_omemo_trust_mode(ProfWin* window, const char* const command, gchar** args);
|
||||||
gboolean cmd_omemo_policy(ProfWin* window, const char* const command, gchar** args);
|
gboolean cmd_omemo_policy(ProfWin* window, const char* const command, gchar** args);
|
||||||
gboolean cmd_omemo_clear_device_list(ProfWin* window, const char* const command, gchar** args);
|
gboolean cmd_omemo_clear_device_list(ProfWin* window, const char* const command, gchar** args);
|
||||||
|
gboolean cmd_omemo_qrcode(ProfWin* window, const char* const command, gchar** args);
|
||||||
|
|
||||||
gboolean cmd_save(ProfWin* window, const char* const command, gchar** args);
|
gboolean cmd_save(ProfWin* window, const char* const command, gchar** args);
|
||||||
gboolean cmd_reload(ProfWin* window, const char* const command, gchar** args);
|
gboolean cmd_reload(ProfWin* window, const char* const command, gchar** args);
|
||||||
|
@ -48,6 +48,10 @@
|
|||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_QRENCODE
|
||||||
|
#include <qrencode.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "config/preferences.h"
|
#include "config/preferences.h"
|
||||||
@ -862,6 +866,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
|
void
|
||||||
cons_show_status(const char* const barejid)
|
cons_show_status(const char* const barejid)
|
||||||
{
|
{
|
||||||
|
@ -277,7 +277,11 @@ void cons_show_bookmarks(const GList* list);
|
|||||||
void cons_show_bookmarks_ignore(gchar** list, gsize len);
|
void cons_show_bookmarks_ignore(gchar** list, gsize len);
|
||||||
void cons_show_disco_items(GSList* items, const char* const jid);
|
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_info(const char* from, GSList* identities, GSList* features);
|
||||||
|
|
||||||
void cons_show_disco_contact_information(GHashTable* addresses);
|
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_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_check_version(gboolean not_available_msg);
|
||||||
void cons_show_typing(const char* const barejid);
|
void cons_show_typing(const char* const barejid);
|
||||||
|
@ -923,27 +923,38 @@ void
|
|||||||
cons_show_disco_items(GSList* items, const char* const jid)
|
cons_show_disco_items(GSList* items, const char* const jid)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cons_show_disco_info(const char* from, GSList* identities, GSList* features)
|
cons_show_disco_info(const char* from, GSList* identities, GSList* features)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cons_show_omemo_qrcode(const char* const text)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cons_show_room_invite(const char* const invitor, const char* const room,
|
cons_show_room_invite(const char* const invitor, const char* const room,
|
||||||
const char* const reason)
|
const char* const reason)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cons_check_version(gboolean not_available_msg)
|
cons_check_version(gboolean not_available_msg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cons_show_typing(const char* const barejid)
|
cons_show_typing(const char* const barejid)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cons_show_incoming_room_message(const char* const nick, const char* const room, const int win_index, gboolean mention, GList* triggers, int unread, ProfWin* const window)
|
cons_show_incoming_room_message(const char* const nick, const char* const room, const int win_index, gboolean mention, GList* triggers, int unread, ProfWin* const window)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cons_show_incoming_message(const char* const short_from, const int win_index, int unread, ProfWin* const window)
|
cons_show_incoming_message(const char* const short_from, const int win_index, int unread, ProfWin* const window)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user