itom 1.3.0
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2013, Institut für Technische Optik (ITO), 00005 Universität 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 00029 namespace ito 00030 { 00031 00032 enum userTypes { 00033 userTypeBasic = 0, 00034 userTypeAdministrator = 1, 00035 userTypeDeveloper = 2 00036 }; 00037 00038 enum userFeatures { 00039 featDeveloper = 1, 00040 featFileSystem = 2, 00041 featUserManag = 4, 00042 featPlugins = 8, 00043 featConsole = 16, 00044 featConsoleRW = 32 00045 }; 00046 00047 #define allFeatures ((userFeatures) (featDeveloper | featFileSystem | featUserManag | featPlugins | featConsole | featConsoleRW)) 00048 00049 00050 class UserOrganizer : QObject 00051 { 00052 Q_OBJECT 00053 00054 public: 00055 static UserOrganizer * getInstance(void); 00056 static RetVal closeInstance(void); 00057 00058 inline void setUserName(const QString userName) { m_userName = userName; } 00059 inline const QString getUserName() const { return m_userName; } 00060 inline void setUserRole(const int role) { m_userRole = role; } 00061 void setUserRole(const QString role) 00062 { 00063 if (role == "developer") 00064 { 00065 m_userRole = 2; 00066 } 00067 else if (role == "admin") 00068 { 00069 m_userRole = 1; 00070 } 00071 else 00072 { 00073 m_userRole = 0; 00074 } 00075 } 00076 inline int getUserRole() const { return m_userRole; } 00077 QString getUserID(void) const; 00078 QString getUserID(QString inifile) const; 00079 int getFlagsFromFile(QString fileName); 00080 inline int getFlagsFromFile(void) { return getFlagsFromFile(m_settingsFile); } 00081 inline void writeFlagsToFile(int flags) { writeFlagsToFile(flags, m_settingsFile); } 00082 void writeFlagsToFile(int flags, QString file); 00083 void setUiFlags(userFeatures flags) { m_features = flags; } 00084 userFeatures getUiFlags(void) const { return m_features; } 00085 void setSettingsFile(QString &settingsFile) { m_settingsFile = settingsFile; } 00086 inline QString getSettingsFile() const { return m_settingsFile; }; 00087 ito::RetVal loadSettings(const QString defUserName); 00088 char hasFeature(userFeatures feature) { return (m_features & feature) > 0; } 00089 00090 private: 00091 UserOrganizer(void); 00092 UserOrganizer(UserOrganizer &/*copyConstr*/) : QObject() {} 00093 ~UserOrganizer(void) {}; 00094 static UserOrganizer *m_pUserOrganizer; 00095 00096 int m_userRole; /*< type of user: 0: "dumb" user, 1: admin user, 2: developer */ 00097 QString m_userName; /*< id of current user */ 00098 userFeatures m_features; /*< switch for enabeling and disabeling functions of itom */ 00099 QString m_settingsFile; 00100 }; 00101 00102 } // namespace ito 00103 00104 #endif //USEROGRANIZER_H