Skip to content

Commit

Permalink
Special handling of login QR-code for bitlbee.
Browse files Browse the repository at this point in the history
  • Loading branch information
hoehermann committed Jul 24, 2024
1 parent e30761f commit da9da70
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 23 deletions.
47 changes: 25 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand All @@ -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:

Expand All @@ -84,23 +87,23 @@ 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:

1. Generate project:

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:

cmake --build .
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.

Expand Down
17 changes: 16 additions & 1 deletion src/c/qrcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:<br>%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) {
Expand All @@ -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);
}
}
}

Expand Down

0 comments on commit da9da70

Please sign in to comment.