A Qt5 library to write cross-platfrom clients for Matrix
C++ CMake QMake
Pull request Compare This branch is 303 commits ahead of davidar:master.
Latest commit f4ef8a4 Oct 31, 2017 @KitsuneRal KitsuneRal More .gitignored files
Permalink
Failed to load latest commit information.
events Support m.room.avatar events Oct 27, 2017
examples Introduce device_id and initial_device_name support; switch to genera… Oct 19, 2017
jobs Put access token to headers instead of query Oct 27, 2017
mime/packages Use own copy of MIME database on Windows Apr 13, 2017
.gitignore More .gitignored files Oct 31, 2017
.gitmodules Removing kcoreaddons submodule Jul 27, 2016
.travis.yml Better support of qmake Oct 20, 2017
CMakeLists.txt Support m.room.avatar events Oct 27, 2017
CONTRIBUTING.md Better documentation Aug 28, 2017
COPYING Add missing licence file Jun 5, 2016
README.md Better documentation Aug 28, 2017
avatar.cpp Move out the avatar code from User Oct 26, 2017
avatar.h Move out the avatar code from User Oct 26, 2017
connection.cpp Fix Connection::deviceId(): Q_INVOKABLE is incompatible with references Oct 31, 2017
connection.h Fix Connection::deviceId(): Q_INVOKABLE is incompatible with references Oct 31, 2017
connectiondata.cpp Put access token to headers instead of query Oct 27, 2017
connectiondata.h Put access token to headers instead of query Oct 27, 2017
joinstate.h Fixed building with clang+libcpp (used on OS X) Oct 15, 2017
libqmatrixclient.pri Support m.room.avatar events Oct 27, 2017
logging.cpp Fixed building with Qt version=5.4; moved away a macro unused in headers Jun 28, 2017
logging.h Use -pedantic with compilers that support it Aug 28, 2017
qmc-example.pro Better support of qmake Oct 20, 2017
room.cpp Room::timelineSize() convenience method Oct 30, 2017
room.h Room::timelineSize() convenience method Oct 30, 2017
settings.cpp Introduce device_id and initial_device_name support; switch to genera… Oct 19, 2017
settings.h Introduce device_id and initial_device_name support; switch to genera… Oct 19, 2017
state.cpp Use nullptr May 27, 2016
state.h Use #pragma once everywhere Nov 6, 2016
user.cpp Support m.room.avatar events Oct 27, 2017
user.h Support m.room.avatar events Oct 27, 2017
util.h Cleanup Oct 20, 2017

README.md

Libqmatrixclient

license PRs Welcome

libqmatrixclient is a Qt-based library to make IM clients for the Matrix protocol. It is used by the Quaternion client and is a part of the Quaternion project. The below instructions are the same for Quaternion and libqmatrixclient (the source tree of Quaternion has most up-to-date instructions but this source tree strives to closely follow).

Contacts

You can find authors of libqmatrixclient in the Quaternion Matrix room: #quaternion:matrix.org.

Issues should be submitted to the project's issue tracker. We do not guarantee a response but we usually try to at least acknowledge the issue

Pre-requisites

a Linux, MacOS or Windows system (desktop versions tried; mobile Linux/Windows might work too)

  • a Git client (to check out this repo)
  • CMake (from your package management system or the official website)
  • Qt 5 (either Open Source or Commercial), version 5.2.1 or higher as of this writing (check the CMakeLists.txt for most up-to-date information). Qt 5.3 or higher recommended on Windows.
  • a C++ toolchain supported by your version of Qt (see a link for your platform at the Qt's platform requirements page)
    • GCC 4.8, Clang 3.5.0, Visual C++ 2015 are the oldest officially supported as of this writing

Installing pre-requisites

Linux

Just install things from "Pre-requisites" using your preferred package manager. If your Qt package base is fine-grained you might want to take a look at CMakeLists.txt to figure out which specific libraries libqmatrixclient uses (or blindly run cmake and look at error messages).

OS X

brew install qt5 should get you Qt5. You may need to tell CMake about the path to Qt by passing -DCMAKE_PREFIX_PATH=<where-Qt-installed>

Windows

  1. Install a Git client and CMake. The commands here imply that git and cmake are in your PATH - otherwise you have to prepend them with your actual paths.
  2. Install Qt5, using their official installer. If for some reason you need to use Qt 5.2.1, select its Add-ons component in the installer as well; for later versions, no extras are needed. If you don't have a toolchain and/or IDE, you can easily get one by selecting Qt Creator and at least one toolchain under Qt Creator.
  3. Make sure CMake knows about Qt and the toolchain - the easiest way is to run a qtenv2.bat script that can be found in C:\Qt\<Qt version>\<toolchain>\bin (assuming you installed Qt to C:\Qt). The only thing it does is adding necessary paths to PATH - you might not want to run it on system startup but it's very handy to setup environment before building. Setting CMAKE_PREFIX_PATH, the same way as for OS X (see above), also helps.

There are no official MinGW-based 64-bit packages for Qt. If you're determined to build 64-bit libqmatrixclient, either use a Visual Studio toolchain or build Qt5 yourself as described in Qt documentation.

Source code

To get all necessary sources, simply clone the GitHub repo. If you have cloned Quaternion or Tensor sources with --recursive, you already have libqmatrixclient in the respective lib subdirectory.

Building

In the root directory of the project sources:

mkdir build_dir
cd build_dir
cmake .. # Pass -DCMAKE_PREFIX_PATH and -DCMAKE_INSTALL_PREFIX here if needed
cmake --build . --target all

This will get you the compiled library in build_dir inside your project sources. Only static builds of libqmatrixclient are tested at the moment; experiments with dynamic builds are welcome. The two known projects to link with libqmatrixclient are Tensor and Quaternion; you should take a look at their source code before doing anything with libqmatrixclient on your own.

Troubleshooting

If cmake fails with...

CMake Warning at CMakeLists.txt:11 (find_package):
  By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "Qt5Widgets", but CMake did not find one.

...then you need to set the right -DCMAKE_PREFIX_PATH variable, see above.

libqmatrixclient uses Qt's logging categories to make switching certain types of logging easier. In case of troubles at runtime (bugs, crashes) you can increase logging if you add the following to the QT_LOGGING_RULES environment variable:

libqmatrixclient.<category>.<level>=<flag>

where

  • <category> is something like main, jobs, or events (the full list is in the file debug.cpp)
  • <level> is one of debug and warning
  • <flag> is either true or false.

* can be used as a wildcard for any part between two dots, and comma is used for a separator. Latter statements override former ones, so if you want to switch on all debug logs except jobs you can set

QT_LOGGING_RULES="libqmatrixclient.*.debug=true,libqmatrixclient.jobs.debug=false"