From 1128a84c8707130a000d26af05314770b1a656dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hermann=20H=C3=B6hne?= Date: Wed, 24 Jul 2024 00:39:32 +0200 Subject: [PATCH] Special handling of login QR-code for bitlbee. --- README.md | 47 +++++++++++++++++++++++++---------------------- src/c/qrcode.c | 17 ++++++++++++++++- 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index b069dba..09b8977 100755 --- a/README.md +++ b/README.md @@ -1,17 +1,19 @@ A libpurple/Pidgin protocol plugin for Signal (formerly textsecure) using [presage](https://github.com/whisperfish/presage). -### Download +## Download * [Latest Build for Windows](https://nightly.link/hoehermann/purple-presage/workflows/build/master/libpresage.dll.zip) -### Set-up +## Set-up 1. Create a new Pidgin account. Enter your Signal account UUID as username. In case you do not know your UUID, just enter anything. The plug-in will tell you what to use. 2. Enable the connection. A window with the QR-code should pop-up. Scan it with your master device. Wait for the window to close. -### Features +Note: bitlbee users will receive the login QR-code in form of a URI from a system contact "Logon QR Code". You may need to allow unsolicited messages from unknown contacts in your client. The URI can be converted using any tools like local [`qrencode`](https://www.shellhacks.com/qr-code-generator-windows-linux-macos/) or [online services](https://www.the-qrcode-generator.com/) (use at your own risk). -#### Present +## Features + +### Present * Can link as secondary device via QR-Code. * Receives a simple text message from a contact or a group. @@ -20,48 +22,49 @@ A libpurple/Pidgin protocol plugin for Signal (formerly textsecure) using [presa * Can reply with a simple text message. * Will add buddies to contact list unconditionally. * Can list groups as rooms and open the chat. +* Special handling of login procedure for bitlbee. -#### Missing - -These lists are not exhaustive. +### Missing -##### To Be Done Soon™ +#### To Be Done Soon™ * Add chats to contact list unconditionally. * Forward all errors to front-end properly. * Send an attachment (example exists in flare). -##### On Hold +#### On Hold * Mark messages as "read" (currently not implemented in back-end, see https://github.com/whisperfish/presage/issues/141). At time of writing, notifications on main device are deleted after answering via linked device. So that is working alright. * Reply to a specific message (no example exists in back-end). -##### "Contributions Welcome" +#### "Contributions Welcome" * Configuration option whether to add contacts to buddy list or not * Reasonable generation of C headers and rust constants * Stickers, mentions, replies, styles,… * Display typing notifications * Display receipts (not important) -* Support for alternative UIs (Spectrum, Bitlbee) +* Support for alternative host applications (Spectrum, Bitlbee) * Support for adding contacts via phone number -#### Known Issues +These lists are not exhaustive. + +### Known Issues * Handling errors when sending messages is barely tested. -* Attachments end up in the conversation of the sender, not the destination (espeically confusing when a group chat is involved). +* Attachments end up in the conversation of the sender, not the destination (especially confusing when a group chat is involved). -### Building +## Building -#### Linux +### Linux -##### Dependencies +#### Dependencies * `libpurple-dev` * `libqrencode-dev` * `protobuf` (or any other package which provides the `protoc` compiler) -##### Build +#### Build git clone --recurse-submodules https://github.com/hoehermann/purple-presage mkdir purple-presage/build @@ -70,11 +73,11 @@ These lists are not exhaustive. cmake --build . sudo cmake --install . -#### Windows +### Windows purple-presage is known to compile with MSVC 19.30 and rust 1.75. You need the version of rust mentioned in [libsignal-service-rs](https://github.com/whisperfish/libsignal-service-rs/tree/main#note-on-supported-rust-versions). A newer version will probably work, too. Using the "x86 Native Tools Command Prompt for VS 2022" is recommended. -##### Dependencies +#### Dependencies Install dependencies via vcpkg: @@ -84,7 +87,7 @@ protoc needs to be in your PATH. You can install it with any method you like, in vcpkg.exe install protobuf -##### Build +#### Build Same as Linux build instructions, but may need to modify the configuration: @@ -92,7 +95,7 @@ Same as Linux build instructions, but may need to modify the configuration: cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE="…/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x86-windows-static -DRust_CARGO_TARGET="i686-pc-windows-msvc" .. - If necessary, the rust toolchain version can be specified via `-DRust_TOOLCHAIN="1.75-i686-pc-windows-msvc"`. + If necessary, the rust tool-chain version can be specified via `-DRust_TOOLCHAIN="1.75-i686-pc-windows-msvc"`. 2. Build, Install and Run: @@ -100,7 +103,7 @@ Same as Linux build instructions, but may need to modify the configuration: cmake --install . cmake --build . --target run -##### Notes +#### Notes purple-presage must be built with MSVC. MinGW's GCC encountered a number of issues such as [incompatibility with rustc versions newer than 1.69](https://github.com/rust-lang/rust/issues/112368) and not shipping libbcrypt by default. diff --git a/src/c/qrcode.c b/src/c/qrcode.c index fcc0a43..724dd38 100755 --- a/src/c/qrcode.c +++ b/src/c/qrcode.c @@ -71,6 +71,14 @@ static void generate_and_show_qrcode(PurpleConnection *connection, const char *d } } +static void write_qrcode_as_conversation(PurpleConnection *connection, const char *data) { + const gchar *who = "Logon QR Code"; + PurpleMessageFlags flags = PURPLE_MESSAGE_RECV; + gchar *msg = g_strdup_printf("Convert the next line into a QR code and scan it with your main device:
%s", data); + purple_serv_got_im(connection, who, msg, flags, time(NULL)); + g_free(msg); +} + void presage_handle_qrcode(PurpleConnection *connection, const char *data) { g_return_if_fail(data != NULL); if (data[0] == 0) { @@ -79,7 +87,14 @@ void presage_handle_qrcode(PurpleConnection *connection, const char *data) { Presage *presage = purple_connection_get_protocol_data(connection); presage_rust_whoami(rust_runtime, presage->tx_ptr); // now that linking is done, get own uuid } else { - generate_and_show_qrcode(connection, data); + PurpleRequestUiOps *ui_ops = purple_request_get_ui_ops(); + if (ui_ops && ui_ops->request_fields) { + // UI supports request fields (e.g. Pidgin) + generate_and_show_qrcode(connection, data); + } else { + // UI does not implement request fields (e.g. bitlbee) + write_qrcode_as_conversation(connection, data); + } } }