itom 2.2.1
K:/git-itom/sources/itom/Qitom/organizer/userOrganizer.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2016, Institut fuer Technische Optik (ITO),
00005     Universitaet Stuttgart, Germany
00006 
00007     This file is part of itom.
00008   
00009     itom is free software; you can redistribute it and/or modify it
00010     under the terms of the GNU Library General Public Licence as published by
00011     the Free Software Foundation; either version 2 of the Licence, or (at
00012     your option) any later version.
00013 
00014     itom is distributed in the hope that it will be useful, but
00015     WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00017     General Public Licence for more details.
00018 
00019     You should have received a copy of the GNU Library General Public License
00020     along with itom. If not, see <http://www.gnu.org/licenses/>.
00021 *********************************************************************** */
00022 
00023 #ifndef USEROGRANIZER_H
00024 #define USEROGRANIZER_H
00025 
00026 #include "../global.h"
00027 #include <qobject.h>
00028 #include <qdatetime.h>
00029 
00030 #include "models/UserModel.h"
00031 
00032 namespace ito
00033 {
00034 
00035 class UserOrganizer : public QObject
00036 {
00037     Q_OBJECT
00038 
00039     public:
00040         static UserOrganizer * getInstance(void);
00041         static RetVal closeInstance(void);
00042 
00043         inline const QString getUserName() const { return m_userName; }
00044         inline int getUserRole() const { return m_userRole; }
00045         QString getUserID(void) const;
00046 
00047         inline UserModel* getUserModel() const { return m_userModel; }
00048         
00049 
00050         ito::RetVal readUserDataFromFile(const QString &filename, QString &username, QString &uid, UserFeatures &features, UserRole &role, QDateTime &lastModified);
00051         ito::RetVal writeUserDataToFile(const QString &username, const QString &uid, const UserFeatures &features, const UserRole &role);
00052 
00053         UserFeatures getUserFeatures(void) const { return m_features; }
00054 
00055         inline QString getSettingsFile() const { return m_settingsFile; };
00056         ito::RetVal loadSettings(const QString &defUserName);
00057         
00058         bool hasFeature(UserFeature feature)
00059         {
00060             return m_features.testFlag(feature);
00061         }
00062 
00063     private:
00064         UserOrganizer(void);
00065         UserOrganizer(UserOrganizer  &/*copyConstr*/) : QObject() {}
00066         ~UserOrganizer(void);
00067         static UserOrganizer *m_pUserOrganizer;
00068 
00069         QString getUserID(const QString &iniFile) const;
00070         ito::RetVal scanSettingFilesAndLoadModel();
00071 
00072         UserRole m_userRole;  /*< type of user: 0: "dumb" user, 1: admin user, 2: developer */
00073         QString m_userName;  /*< id of current user */
00074         UserFeatures m_features; /*< switch for enabeling and disabeling functions of itom */
00075         QString m_settingsFile;
00076 
00077         QString m_strConstStdUser;
00078         QString m_lastOpenedUserName;
00079 
00080         UserModel *m_userModel;
00081         
00082 };
00083 
00084 } // namespace ito
00085 
00086 #endif //USEROGRANIZER_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Friends