itom 1.0.14
|
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 userFeatures { 00033 featDeveloper = 1, 00034 featFileSystem = 2, 00035 featUserManag = 4, 00036 featPlugins = 8, 00037 featConsole = 16, 00038 featConsoleRW = 32 00039 }; 00040 00041 #define allFeatures ((userFeatures) (featDeveloper | featFileSystem | featUserManag | featPlugins | featConsole | featConsoleRW)) 00042 00043 class UserOrganizer : QObject 00044 { 00045 Q_OBJECT 00046 00047 public: 00048 static UserOrganizer * getInstance(void); 00049 static RetVal closeInstance(void); 00050 00051 inline void setUserName(const QString userName) { m_userName = userName; } 00052 inline const QString getUserName() const { return m_userName; } 00053 inline void setUserRole(const int role) { m_userRole = role; } 00054 void setUserRole(const QString role) 00055 { 00056 if (role == "user") 00057 m_userRole = 0; 00058 else if (role == "admin") 00059 m_userRole = 1; 00060 else 00061 m_userRole = 2; 00062 } 00063 inline int getUserRole() const { return m_userRole; } 00064 QString getUserID(void) const; 00065 QString getUserID(QString inifile) const; 00066 int getFlagsFromFile(QString fileName); 00067 inline int getFlagsFromFile(void) { return getFlagsFromFile(m_settingsFile); } 00068 inline void writeFlagsToFile(int flags) { writeFlagsToFile(flags, m_settingsFile); } 00069 void writeFlagsToFile(int flags, QString file); 00070 void setUiFlags(userFeatures flags) { m_features = flags; } 00071 userFeatures getUiFlags(void) const { return m_features; } 00072 void setSettingsFile(QString &settingsFile) { m_settingsFile = settingsFile; } 00073 inline QString getSettingsFile() const { return m_settingsFile; }; 00074 ito::RetVal loadSettings(const QString defUserName); 00075 char hasFeature(userFeatures feature) { return (m_features & feature) > 0; } 00076 00077 private: 00078 UserOrganizer(void); 00079 UserOrganizer(UserOrganizer &/*copyConstr*/) : QObject() {} 00080 ~UserOrganizer(void) {}; 00081 static UserOrganizer *m_pUserOrganizer; 00082 00083 int m_userRole; /*< type of user: 0: "dumb" user, 1: admin user, 2: developer */ 00084 QString m_userName; /*< id of current user */ 00085 userFeatures m_features; /*< switch for enabeling and disabeling functions of itom */ 00086 QString m_settingsFile; 00087 }; 00088 00089 } // namespace ito 00090 00091 #endif //USEROGRANIZER_H