• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

3rdparty/libQtOlm/H14-Apr-2020-

cmake/H14-Apr-2020-63

lib/H14-Apr-2020-27,99316,781

mime/packages/H14-Apr-2020-39,22539,104

tests/H03-May-2022-745595

.appveyor.ymlH A D14-Apr-20201.4 KiB4334

.clang-formatH A D14-Apr-20203.8 KiB130126

.gitignoreH A D14-Apr-2020118 1210

.gitmodulesH A D14-Apr-2020100 43

.lgtm.ymlH A D14-Apr-2020379 1615

.travis.ymlH A D14-Apr-20202.5 KiB8777

CONTRIBUTING.mdH A D14-Apr-202029.6 KiB443356

COPYINGH A D14-Apr-202025.8 KiB505418

ISSUE_TEMPLATE.mdH A D14-Apr-20201.6 KiB4918

Quotient.pc.inH A D14-Apr-2020302 119

README.mdH A D14-Apr-202010.2 KiB186158

SECURITY.mdH A D14-Apr-20202 KiB3324

libquotient.priH A D14-Apr-20204.3 KiB124118

quotest.proH A D14-Apr-2020202 148

README.md

1# libQuotient (former libQMatrixClient)
2
3<a href='https://matrix.org'><img src='https://matrix.org/docs/projects/images/made-for-matrix.png' alt='Made for Matrix' height=64 target=_blank /></a>
4
5[![license](https://img.shields.io/github/license/quotient-im/libQuotient.svg)](https://github.com/quotient-im/libQuotient/blob/master/COPYING)
6![status](https://img.shields.io/badge/status-beta-yellow.svg)
7[![release](https://img.shields.io/github/release/quotient-im/libQuotient/all.svg)](https://github.com/quotient-im/libQuotient/releases/latest)
8[![](https://img.shields.io/cii/percentage/1023.svg?label=CII%20best%20practices)](https://bestpractices.coreinfrastructure.org/projects/1023/badge)
9![](https://img.shields.io/github/commit-activity/y/quotient-im/libQuotient.svg)
10[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/quotient-im/libQuotient.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/quotient-im/libQuotient/context:cpp)
11[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
12
13The Quotient project aims to produce a Qt5-based SDK to develop applications
14for [Matrix](https://matrix.org). libQuotient is a library that enables client
15applications. It is the backbone of
16[Quaternion](https://github.com/quotient-im/Quaternion),
17[Spectral](https://matrix.org/docs/projects/client/spectral.html) and
18other projects.
19Versions 0.5.x and older use the previous name - libQMatrixClient.
20
21## Contacts
22You can find Quotient developers in the Matrix room:
23[#quotient:matrix.org](https://matrix.to/#/#quotient:matrix.org).
24
25You can file issues at
26[the project issue tracker](https://github.com/quotient-im/libQuotient/issues).
27If you find what looks like a security issue, please use instructions
28in SECURITY.md.
29
30## Getting and using libQuotient
31Depending on your platform, the library can come as a separate package.
32Recent releases of Debian and openSUSE, e.g., already have the package
33(under the old name). If your Linux repo doesn't provide binary package
34(either libqmatrixclient - older - or libquotient - newer), or you're
35on Windows or macOS, your best bet is to build the library from the source
36and bundle it with your application.
37
38### Pre-requisites
39- A recent Linux, macOS or Windows system (desktop versions tried; Ubuntu Touch
40  is known to work; mobile Windows and iOS might work too but never tried)
41  - Recent enough Linux examples: Debian Buster; Fedora 28; openSUSE Leap 15;
42    Ubuntu Bionic Beaver.
43- Qt 5 (either Open Source or Commercial), 5.9 or higher;
44  5.12 is recommended, especially if you use qmake
45- A build configuration tool (CMake is recommended, qmake is yet supported):
46  - CMake 3.10 or newer (from your package management system or
47    [the official website](https://cmake.org/download/))
48  - or qmake (comes with Qt)
49- A C++ toolchain with _reasonably complete_ C++17 support:
50  - GCC 7 (Windows, Linux, macOS), Clang 6 (Linux), Apple Clang 10 (macOS)
51    and Visual Studio 2017 (Windows) are the oldest officially supported.
52- Any build system that works with CMake and/or qmake should be fine:
53  GNU Make, ninja (any platform), NMake, jom (Windows) are known to work.
54
55#### Linux
56Just install things from the list above using your preferred package manager. If your Qt package base is fine-grained you might want to run cmake/qmake and look at error messages. The library is entirely offscreen (QtCore and QtNetwork are essential) but it also depends on QtGui in order to handle avatar thumbnails.
57
58#### macOS
59`brew install qt5` should get you a recent Qt5. If you plan to use CMake, you will need to tell it about the path to Qt by passing `-DCMAKE_PREFIX_PATH=$(brew --prefix qt5)`
60
61#### Windows
621. Install Qt5, using their official installer.
631. If you plan to build with CMake, install CMake; if you're ok with qmake, you don't need to install anything on top of Qt. The commands in further sections imply that cmake/qmake is in your PATH - otherwise you have to prepend those commands with actual paths. As an option, it's a good idea 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 that script on system startup but it's very handy to setup the environment before building. For CMake, setting `CMAKE_PREFIX_PATH` in the same way as for macOS (see above), also helps.
64
65### Using the library
66If you use CMake, `find_package(Quotient)` sets up the client code to use
67libQuotient, assuming the library development files are installed. There's no
68documented procedure to use a preinstalled library with qmake; consider
69introducing a submodule in your source tree and build it along with the rest
70of the application for now. Note also that qmake is considered for phase-out
71in Qt 6 so you should probably think of moving over to CMake eventually.
72
73Building with dynamic linkage are only tested on Linux at the moment and are
74a recommended way of linking your application with libQuotient on this platform.
75Feel free
76Static linkage is the default on Windows/macOS; feel free to experiment
77with dynamic linking and submit PRs if you get reusable results.
78
79The example/test application that comes with libQuotient,
80[quotest](tests) includes most common use cases such as sending messages, uploading files,
81setting room state etc.; for more extensive usage check out the source code
82of [Quaternion](https://github.com/quotient-im/Quaternion)
83(the reference client of Quotient) or [Spectral](https://gitlab.com/b0/spectral).
84
85To ease the first step, `tests/CMakeLists.txt` is a good starting point
86for your own CMake-based project using libQuotient.
87
88## Building the library
89[The source code is at GitHub](https://github.com/quotient-im/libQuotient).
90Checking out a certain commit or tag (rather than downloading the archive)
91along with submodules is strongly recommended. If you want to hack on
92the library as a part of another project (e.g. you are working on Quaternion
93but need to do some changes to the library code), it makes sense
94to make a recursive check out of that project (in this case, Quaternion)
95and update the library submodule (also recursively) to its master branch.
96
97Tags consisting of digits and periods represent released versions; tags ending
98with `-betaN` or `-rcN` mark pre-releases. If/when packaging pre-releases,
99it is advised to replace a dash with a tilde.
100
101### CMake-based
102In the root directory of the project sources:
103```shell script
104mkdir build_dir
105cd build_dir
106cmake .. # Pass -DCMAKE_PREFIX_PATH and -DCMAKE_INSTALL_PREFIX here if needed
107cmake --build . --target all
108```
109This will get you the compiled library in `build_dir` inside your project
110sources. Static builds are tested on all supported platforms.
111
112You can install the library with CMake:
113```shell script
114cmake --build . --target install
115```
116This will also install cmake package config files; once this is done, you
117should be able to use [`tests/CMakeLists.txt`](tests/CMakeLists.txt) to compile quotest
118with the _installed_ library. Installation of the `quotest` binary
119along with the rest of the library can be skipped
120by setting `Quotient_INSTALL_TESTS` to `OFF`.
121
122### qmake-based
123The library provides a .pri file with an intention to be included from a bigger project's .pro file. As a starting point you can use `quotest.pro` that will build a minimal example of library usage for you. In the root directory of the project sources:
124```shell script
125qmake quotest.pro
126make all
127```
128This will get you `debug/quotest` and `release/quotest`
129console executables that login to the Matrix server at matrix.org with
130credentials of your choosing (pass the username and password as arguments),
131run a sync long-polling loop and do some tests of the library API. Note that
132qmake didn't really know about C++17 until Qt 5.12 so if your Qt is older
133you may have quite a bit of warnings during the compilation process.
134
135Installing the standalone library with qmake is not implemented yet; PRs are
136welcome though.
137
138## Troubleshooting
139
140#### Building fails
141
142If `cmake` fails with...
143```
144CMake Warning at CMakeLists.txt:11 (find_package):
145  By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project
146  has asked CMake to find a package configuration file provided by
147  "Qt5Widgets", but CMake did not find one.
148```
149...then you need to set the right `-DCMAKE_PREFIX_PATH` variable, see above.
150
151#### Logging configuration
152
153libQuotient 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:
154```
155quotient.<category>.<level>=<flag>
156```
157where
158- `<category>` is one of: `main`, `jobs`, `jobs.sync`, `events`, `events.state`
159  (covering both the "usual" room state and account data), `events.messages`,
160  `events.ephemeral`, `e2ee` and `profiler` (you can always find the full list
161  in `lib/logging.cpp`)
162- `<level>` is one of `debug`, `info`, and `warning`
163- `<flag>` is either `true` or `false`.
164
165`*` can be used as a wildcard for any part between two dots, and semicolon 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
166```shell script
167QT_LOGGING_RULES="quotient.*.debug=true;quotient.jobs.debug=false"
168```
169Note that `quotient` is a prefix that only works since version 0.6 of
170the library; 0.5.x and older used `libqmatrixclient` instead. If you happen
171to deal with both libQMatrixClient-era and Quotient-era versions,
172it's reasonable to use both prefixes, to make sure you're covered with no
173regard to the library version. For example, the above setting could look like
174```shell script
175QT_LOGGING_RULES="libqmatrixclient.*.debug=true;libqmatrixclient.jobs.debug=false;quotient.*.debug=true;quotient.jobs.debug=false"
176```
177
178#### Cache format
179In case of troubles with room state and caching it may be useful to switch
180cache format from binary to JSON. To do that, set the following value in
181your client's configuration file/registry key (you might need to create
182the libqmatrixclient key for that): `libqmatrixclient/cache_type` to `json`.
183This will make cache saving and loading work slightly slower but the cache
184will be in a text JSON file (very long and unindented so prepare a good
185JSON viewer or text editor with JSON formatting capabilities).
186