From cdd4c0b854fd4d27fa1d9bd941df03888301780a Mon Sep 17 00:00:00 2001 From: Marvin W Date: Wed, 2 Jan 2019 15:24:03 +0100 Subject: Find libqrencode using cmake/pkg-config logic --- plugins/omemo/CMakeLists.txt | 6 +++-- plugins/omemo/vapi/libqrencode.vapi | 50 +++++++++++++++++++++++++++++++++++++ plugins/omemo/vapi/qrencode.vapi | 50 ------------------------------------- 3 files changed, 54 insertions(+), 52 deletions(-) create mode 100644 plugins/omemo/vapi/libqrencode.vapi delete mode 100644 plugins/omemo/vapi/qrencode.vapi (limited to 'plugins') diff --git a/plugins/omemo/CMakeLists.txt b/plugins/omemo/CMakeLists.txt index b2145be7..92d5cd51 100644 --- a/plugins/omemo/CMakeLists.txt +++ b/plugins/omemo/CMakeLists.txt @@ -10,6 +10,7 @@ find_packages(OMEMO_PACKAGES REQUIRED GObject GTK3 Soup + Qrencode ) set(RESOURCE_LIST @@ -57,17 +58,18 @@ CUSTOM_VAPIS ${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi ${CMAKE_BINARY_DIR}/exports/qlite.vapi ${CMAKE_BINARY_DIR}/exports/dino.vapi - ${CMAKE_CURRENT_SOURCE_DIR}/vapi/qrencode.vapi PACKAGES ${OMEMO_PACKAGES} GRESOURCES ${OMEMO_GRESOURCES_XML} +OPTIONS + --vapidir=${CMAKE_CURRENT_SOURCE_DIR}/vapi ) add_definitions(${VALA_CFLAGS} -DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\" -DLOCALE_INSTALL_DIR=\"${LOCALE_INSTALL_DIR}\") add_library(omemo SHARED ${OMEMO_VALA_C} ${OMEMO_GRESOURCES_TARGET}) add_dependencies(omemo ${GETTEXT_PACKAGE}-translations) -target_link_libraries(omemo libdino signal-protocol-vala qrencode ${OMEMO_PACKAGES}) +target_link_libraries(omemo libdino signal-protocol-vala ${OMEMO_PACKAGES}) set_target_properties(omemo PROPERTIES PREFIX "") set_target_properties(omemo PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins/) diff --git a/plugins/omemo/vapi/libqrencode.vapi b/plugins/omemo/vapi/libqrencode.vapi new file mode 100644 index 00000000..fc77c855 --- /dev/null +++ b/plugins/omemo/vapi/libqrencode.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); + } + } +} diff --git a/plugins/omemo/vapi/qrencode.vapi b/plugins/omemo/vapi/qrencode.vapi deleted file mode 100644 index fc77c855..00000000 --- a/plugins/omemo/vapi/qrencode.vapi +++ /dev/null @@ -1,50 +0,0 @@ -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); - } - } -} -- cgit v1.2.3-70-g09d2