Introducing QtVarlink

I'm writing this blog in the very very early stages of development because I'm 50% sure someone will link me to some existing library that Google failed to find.

Varlink

Varlink is an IPC mechanism that is gaining popularity in a few places across Linux. It's very simple, JSON blobs over a socket terminated with a null byte. It doesn't have anywhere near the features of DBus, but the simplicity is the main selling point.

Ultimately when it comes to choosing IPC what matters is what the servers you want to talk to are already using and then things become forced.

QtVarlink

Interacting with C APIs is a horrible experience for all involved. We want something that looks and behaves likes a Qt developer would expect and used the inbuilt QtJson classes.

My new library provides API as follows.

    VarlinkClient client("unix:/tmp/foo");
    QFuture<VarlinkResponse> pendingResponse = client.call("org.example.Ping", QJsonObject({{"ping", "1"}}));
    pendingResponse.then(this, [](VarlinkResponse response) {
        qDebug() << response.parameters()["pong"].toString();
    });

Or any variation of QFutureWatcher or just blocking.

State

Code is available at: https://invent.kde.org/davidedmundson/qtvarlink

As mentioned in the intro, it's pre pre alpha. It's the minimum viable product for a task I had, but I intend to make it a standalone project.

Please let me know if this would be useful to you. There's a roadmap in the Readme and pull requests are more than welcome!