File indexing completed on 2024-11-24 04:44:30

0001 /*
0002     This file is part of oxaccess.
0003 
0004     SPDX-FileCopyrightText: 2009 Tobias Koenig <tokoe@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #pragma once
0010 
0011 #include "user.h"
0012 
0013 #include <QMap>
0014 #include <QObject>
0015 
0016 namespace OXA
0017 {
0018 class Users : public QObject
0019 {
0020     Q_OBJECT
0021 
0022 public:
0023     ~Users() override;
0024 
0025     static Users *self();
0026 
0027     void init(const QString &identifier);
0028 
0029     [[nodiscard]] qlonglong currentUserId() const;
0030 
0031     User lookupUid(qlonglong uid) const;
0032     User lookupEmail(const QString &email) const;
0033 
0034     QString cacheFilePath() const;
0035 
0036 private:
0037     friend class UpdateUsersJob;
0038 
0039     Users();
0040     void setCurrentUserId(qlonglong);
0041     void setUsers(const User::List &);
0042 
0043     void loadFromCache();
0044     void saveToCache();
0045 
0046     qlonglong mCurrentUserId = -1;
0047     QMap<qlonglong, User> mUsers;
0048     QString mIdentifier;
0049 
0050     static Users *mSelf;
0051 };
0052 }