itom
Loading...
Searching...
No Matches
userOrganizer.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom.
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 itom is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17 General Public Licence for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with itom. If not, see <http://www.gnu.org/licenses/>.
21*********************************************************************** */
22
23#ifndef USEROGRANIZER_H
24#define USEROGRANIZER_H
25
26#include "../global.h"
27#include <qobject.h>
28#include <qdatetime.h>
29#include <qhash.h>
30#include <qdir.h>
31#include <qcoreapplication.h>
32
33#include "models/UserModel.h"
34
35namespace ito
36{
37
38class UserOrganizer : public QObject
39{
40 Q_OBJECT
41
42 public:
43 static UserOrganizer * getInstance(void);
44 static RetVal closeInstance(void);
45
47 const QString getCurrentUserName() const;
48
50 /*
51 The role is only used by the three python methods itom.userIsUser, itom.userIsDeveloper, itom.userIsAdministrator
52 */
54
56 QString getCurrentUserId() const;
57
59 UserFeatures getCurrentUserFeatures() const;
60
61 QString getCurrentUserSettingsFile() const;
62
63 bool currentUserHasFeature(const UserFeature &feature);
64
65 inline UserModel* getUserModel() const { return m_userModel; }
66
67 ito::RetVal readUserDataFromFile(const QString &filename, QString &username, QString &uid, UserFeatures &features,
68 UserRole &role, QByteArray &password, QDateTime &lastModified);
69
70 ito::RetVal writeUserDataToFile(const QString &username, const QString &uid, const UserFeatures &features,
71 const UserRole &role, const QByteArray &password, const bool &standardUser = false);
72
73 ito::RetVal loadSettings(const QString &userId); //use an empty userId to get the selection dialog of select the standard user
74
75 private:
76 UserOrganizer(void);
77 UserOrganizer(UserOrganizer &/*copyConstr*/) : QObject() {}
78 ~UserOrganizer(void);
80
81 QString getUserIdFromSettingsFilename(const QString &iniFile) const;
82 ito::RetVal scanSettingFilesAndLoadModel();
83
84 QString m_strConstStdUserName;
85 QString m_strConstStdUserId;
86 QString m_lastOpenedUserName;
87
88 UserModel *m_userModel;
89
90};
91
92} // namespace ito
93
94#endif //USEROGRANIZER_H
Class for managing status values (like errors or warning)
Definition retVal.h:54
class for for visualizing the available users
Definition UserModel.h:81
class handling users and their rights
Definition userOrganizer.h:39
const QString getCurrentUserName() const
returns the role of the current user (user, developer, administrator).
Definition userOrganizer.cpp:518
QString getUserIdFromSettingsFilename(const QString &iniFile) const
shortdesc
Definition userOrganizer.cpp:502
ito::RetVal loadSettings(const QString &userId)
shortdesc
Definition userOrganizer.cpp:102
static UserOrganizer * getInstance(void)
Definition userOrganizer.cpp:71
QString getCurrentUserId() const
returns the available features for the current user
Definition userOrganizer.cpp:535
UserFeatures getCurrentUserFeatures() const
< returns the available features for the current user
Definition userOrganizer.cpp:542
ito::UserRole getCurrentUserRole() const
returns the unique ID of the current user
Definition userOrganizer.cpp:528
static RetVal closeInstance(void)
returns the user name of the current user
Definition userOrganizer.cpp:86
static UserOrganizer * m_pUserOrganizer
Definition userOrganizer.h:79
Definition apiFunctionsGraph.cpp:40
UserFeature
Enumeration that defines some feature permissions for a user.
Definition UserModel.h:42
UserRole
Enumeration that defines some user roles.
Definition UserModel.h:33