itom  3.0.0
userOrganizer.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2016, Institut fuer Technische Optik (ITO),
5  Universitaet 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 
30 #include "models/UserModel.h"
31 
32 namespace ito
33 {
34 
35 class UserOrganizer : public QObject
36 {
37  Q_OBJECT
38 
39  public:
40  static UserOrganizer * getInstance(void);
41  static RetVal closeInstance(void);
42 
43  inline const QString getUserName() const { return m_userName; }
44  inline int getUserRole() const { return m_userRole; }
45  QString getUserID(void) const;
46 
47  inline UserModel* getUserModel() const { return m_userModel; }
48 
49 
50  ito::RetVal readUserDataFromFile(const QString &filename, QString &username, QString &uid, UserFeatures &features, UserRole &role, QDateTime &lastModified);
51  ito::RetVal writeUserDataToFile(const QString &username, const QString &uid, const UserFeatures &features, const UserRole &role);
52 
53  UserFeatures getUserFeatures(void) const { return m_features; }
54 
55  inline QString getSettingsFile() const { return m_settingsFile; };
56  ito::RetVal loadSettings(const QString &defUserName);
57 
58  bool hasFeature(UserFeature feature)
59  {
60  return m_features.testFlag(feature);
61  }
62 
63  private:
64  UserOrganizer(void);
65  UserOrganizer(UserOrganizer &/*copyConstr*/) : QObject() {}
66  ~UserOrganizer(void);
68 
69  QString getUserID(const QString &iniFile) const;
70  ito::RetVal scanSettingFilesAndLoadModel();
71 
72  UserRole m_userRole; /*< type of user: 0: "dumb" user, 1: admin user, 2: developer */
73  QString m_userName; /*< id of current user */
74  UserFeatures m_features; /*< switch for enabeling and disabeling functions of itom */
75  QString m_settingsFile;
76 
77  QString m_strConstStdUser;
78  QString m_lastOpenedUserName;
79 
80  UserModel *m_userModel;
81 
82 };
83 
84 } // namespace ito
85 
86 #endif //USEROGRANIZER_H
class handling users and their rights
Definition: userOrganizer.h:35
Class for managing status values (like errors or warning)
Definition: retVal.h:54
class for for visualizing the available users
Definition: UserModel.h:73
QString getUserID(void) const
shortdesc
Definition: userOrganizer.cpp:414
static UserOrganizer * getInstance(void)
Definition: userOrganizer.cpp:74
Definition: apiFunctionsGraph.cpp:39
static UserOrganizer * m_pUserOrganizer
Definition: userOrganizer.h:67
static RetVal closeInstance(void)
Definition: userOrganizer.cpp:89
ito::RetVal loadSettings(const QString &defUserName)
shortdesc
Definition: userOrganizer.cpp:105