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

..03-May-2022-

.github/workflows/H24-Aug-2021-10186

3rdparty/libQtOlm/H24-Aug-2021-

cmake/H24-Aug-2021-63

gtad/H24-Aug-2021-465417

lib/H24-Aug-2021-25,98114,903

mime/packages/H24-Aug-2021-39,22539,104

tests/H03-May-2022-938760

.appveyor.ymlH A D24-Aug-20211.1 KiB4132

.clang-formatH A D24-Aug-20214.3 KiB144139

.gitignoreH A D24-Aug-2021288 2521

.gitmodulesH A D24-Aug-2021100 43

.lgtm.ymlH A D24-Aug-2021497 2120

CONTRIBUTING.mdH A D24-Aug-202132.5 KiB527438

COPYINGH A D24-Aug-202125.8 KiB505418

ISSUE_TEMPLATE.mdH A D24-Aug-20211.6 KiB4918

Quotient.pc.inH A D24-Aug-2021302 119

README.mdH A D24-Aug-202112.1 KiB222192

SECURITY.mdH A D24-Aug-20211.9 KiB3728

libquotient.priH A D24-Aug-20214.3 KiB130123

quotest.proH A D24-Aug-2021203 158

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[NeoChat](https://matrix.org/docs/projects/client/neo-chat) 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 are known to work;
40  mobile operating systems where Qt is available might work too)
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 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
62Install Qt5, using their official installer; if you plan to build with CMake,
63make sure to tick the CMake box in the list of installed components.
64
65The commands in further sections imply that cmake/qmake is in your PATH,
66otherwise you have to prepend those commands with actual paths. As an option
67it's a good idea to run a `qtenv2.bat` script that can be found in
68`C:\Qt\<Qt version>\<toolchain>\bin` (assuming you installed Qt to `C:\Qt`);
69the only thing it does is adding necessary paths to PATH. You might not want
70to run that script on system startup but it's very handy to setup
71the environment before building. For CMake you can alternatively point
72`CMAKE_PREFIX_PATH` to your Qt installation and leave PATH unchanged; but
73in that case you'll have to supply the full path to CMake when calling it.
74
75### Using the library
76If you use CMake, `find_package(Quotient)` sets up the client code to use
77libQuotient, assuming the library development files are installed. There's no
78documented procedure to use a preinstalled library with qmake; consider
79introducing a submodule in your source tree and build it along with the rest
80of the application for now. Note also that qmake is no more supported
81in libQuotient 0.7 so you should really think of moving over to CMake.
82
83Building with dynamic linkage is only tested on Linux at the moment and is
84a recommended way of linking your application with libQuotient on this platform.
85Static linkage is the default on Windows/macOS; feel free to experiment
86with dynamic linking and submit PRs if you get reusable results.
87
88[Quotest](tests), the test application that comes with libQuotient, includes
89most common use cases such as sending messages, uploading files,
90setting room state etc.; for more extensive usage check out the source code
91of [Quaternion](https://github.com/quotient-im/Quaternion)
92(the reference client of Quotient) or
93[NeoChat](https://invent.kde.org/network/neochat).
94
95To ease the first step, `tests/CMakeLists.txt` is a good starting point
96for your own CMake-based project using libQuotient.
97
98## Building the library
99[The source code is at GitHub](https://github.com/quotient-im/libQuotient).
100Checking out a certain commit or tag (rather than downloading the archive)
101along with submodules is strongly recommended. If you want to hack on
102the library as a part of another project (e.g. you are working on Quaternion
103but need to do some changes to the library code), it makes sense
104to make a recursive check out of that project (in this case, Quaternion)
105and update the library submodule (also recursively) to its master branch.
106
107Tags consisting of digits and periods represent released versions; tags ending
108with `-betaN` or `-rcN` mark pre-releases. If/when packaging pre-releases,
109it is advised to replace a dash with a tilde.
110
111### CMake-based
112In the root directory of the project sources:
113```shell script
114mkdir build_dir
115cd build_dir
116cmake .. # [-D<cmake-variable>=<value>...], see below
117cmake --build . --target all
118```
119This will get you the compiled library in `build_dir` inside your project
120sources. Static builds are tested on all supported platforms, building
121the library as a shared object (aka dynamic library) is supported on Linux
122and macOS but is very likely to be broken on Windows.
123
124The first CMake invocation configures the build. You can pass CMake variables,
125such as `-DCMAKE_PREFIX_PATH="path1;path2;..."` and
126`-DCMAKE_INSTALL_PREFIX=path` here if needed.
127[CMake documentation](https://cmake.org/cmake/help/latest/index.html)
128(pick the CMake version at the top of the page that you use) describes
129the standard variables coming with CMake. On top of them, Quotient introduces:
130- `Quotient_INSTALL_TESTS=<ON/OFF>`, `ON` by default - install `quotest` along
131  with the library files when `install` target is invoked. `quotest` is a small
132  command-line program that (assuming correct parameters, see `quotest --help`)
133  that tries to connect to a given room as a given user and perform some basic
134  Matrix operations, such as sending messages and small files, redaction,
135  setting room tags etc. This is useful to check the sanity of your library
136  installation. As of now, `quotest` expects the used homeserver to be able
137  to get the contents of `#quotient:matrix.org`; this is being fixed in
138  [#401](https://github.com/quotient-im/libQuotient/issues/401).
139- `Quotient_ENABLE_E2EE=<ON/OFF>`, `OFF` by default - enable work-in-progress
140  E2EE code in the library. Do NOT use this: as of 0.6, the code is very
141  incomplete and leaks memory; 0.7 will have a different E2EE implementation.
142- `MATRIX_DOC_PATH` and `GTAD_PATH` - these two variables are used to point
143  CMake to the directory with the matrix-doc repository containing API files
144  and to a GTAD binary. These two are used to generate C++ files from Matrix
145  Client-Server API description made in OpenAPI notation. This is not needed
146  if you just need to build the library; if you're really into hacking on it,
147  CONTRIBUTING.md elaborates on what these two variables are for.
148
149You can install the library with CMake:
150```shell script
151cmake --build . --target install
152```
153This will also install cmake package config files; once this is done, you
154should be able to use [`tests/CMakeLists.txt`](tests/CMakeLists.txt) to compile quotest
155with the _installed_ library. Installation of the `quotest` binary
156along with the rest of the library can be skipped
157by setting `Quotient_INSTALL_TESTS` to `OFF`.
158
159### qmake-based (deprecated)
160The 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:
161```shell script
162qmake quotest.pro
163make all
164```
165This will get you `debug/quotest` and `release/quotest`
166console executables that login to the Matrix server at matrix.org with
167credentials of your choosing (pass the username and password as arguments),
168run a sync long-polling loop and do some tests of the library API. Note that
169qmake didn't really know about C++17 until Qt 5.12 so if your Qt is older
170you may have quite a bit of warnings during the compilation process.
171
172Installing the standalone library with qmake has not been implemented.
173
174## Troubleshooting
175
176#### Building fails
177
178If `cmake` fails with...
179```
180CMake Warning at CMakeLists.txt:11 (find_package):
181  By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project
182  has asked CMake to find a package configuration file provided by
183  "Qt5Widgets", but CMake did not find one.
184```
185...then you need to set the right `-DCMAKE_PREFIX_PATH` variable, see above.
186
187#### Logging configuration
188
189libQuotient 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:
190```
191quotient.<category>.<level>=<flag>
192```
193where
194- `<category>` is one of: `main`, `jobs`, `jobs.sync`, `events`, `events.state`
195  (covering both the "usual" room state and account data), `events.messages`,
196  `events.ephemeral`, `e2ee` and `profiler` (you can always find the full list
197  in `lib/logging.cpp`)
198- `<level>` is one of `debug`, `info`, and `warning`
199- `<flag>` is either `true` or `false`.
200
201`*` 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
202```shell script
203QT_LOGGING_RULES="quotient.*.debug=true;quotient.jobs.debug=false"
204```
205Note that `quotient` is a prefix that only works since version 0.6 of
206the library; 0.5.x and older used `libqmatrixclient` instead. If you happen
207to deal with both libQMatrixClient-era and Quotient-era versions,
208it's reasonable to use both prefixes, to make sure you're covered with no
209regard to the library version. For example, the above setting could look like
210```shell script
211QT_LOGGING_RULES="libqmatrixclient.*.debug=true;libqmatrixclient.jobs.debug=false;quotient.*.debug=true;quotient.jobs.debug=false"
212```
213
214#### Cache format
215In case of troubles with room state and caching it may be useful to switch
216cache format from binary to JSON. To do that, set the following value in
217your client's configuration file/registry key (you might need to create
218the libQuotient key for that): `libQuotient/cache_type` to `json`.
219This will make cache saving and loading work slightly slower but the cache
220will be in text JSON files (possibly very long and unindented so prepare a good
221JSON viewer or text editor with JSON formatting capabilities).
222