libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
accountregistry.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2020 Kitsune Ral <Kitsune-Ral@users.sf.net>
2// SPDX-FileCopyrightText: Tobias Fella <fella@posteo.de>
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#pragma once
6
7#include "util.h"
8
9#include <QtCore/QAbstractListModel>
10
11#include <qt6keychain/keychain.h>
12
13namespace Quotient {
14class Connection;
15
17 private QVector<Connection*> {
19 /// Number of accounts that are currently fully loaded
21 /// List of accounts that are currently in some stage of being loaded (Reading token from keychain, trying to contact server, etc).
22 /// Can be used to inform the user or to show a login screen if size() == 0 and no accounts are loaded
24public:
28
33 };
34
35 explicit AccountRegistry(QObject* parent = nullptr);
36
37 // Expose most of vector_t's const-API but only provide add() and drop()
38 // for changing it. In theory other changing operations could be supported
39 // too; but then boilerplate begin/end*() calls has to be tucked into each
40 // and this class gives no guarantees on the order of entries, so why care.
41
42 const vector_t& accounts() const { return *this; }
45 const_iterator begin() const { return vector_t::begin(); }
46 const_iterator end() const { return vector_t::end(); }
47 const_reference front() const { return vector_t::front(); }
48 const_reference back() const { return vector_t::back(); }
49 bool isLoggedIn(const QString& userId) const;
50 Connection* get(const QString& userId) const;
51
55
56 // QAbstractItemModel interface implementation
57
59 int role) const override;
61 const QModelIndex& parent = QModelIndex()) const override;
63
65
66 [[deprecated("This may leak Connection objects when failing and cannot be"
67 "fixed without breaking the API; do not use it")]] //
69
73
77
78private:
79 struct Private;
81};
82} // namespace Quotient
#define QUOTIENT_API