/src/libtomahawk/aclsystem.h
C++ Header | 64 lines | 33 code | 14 blank | 17 comment | 0 complexity | 94adbe9f7be41a3646f9530f1f6a00a4 MD5 | raw file
1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === 2 * 3 * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> 4 * 5 * Tomahawk is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * Tomahawk is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19#ifndef TOMAHAWK_ACLSYSTEM_H 20#define TOMAHAWK_ACLSYSTEM_H 21 22#include <QObject> 23#include <QString> 24#include <QHash> 25#include <QTimer> 26#include <QMutex> 27 28#include "dllmacro.h" 29 30class DLLEXPORT ACLSystem : public QObject 31{ 32 Q_OBJECT 33 34public: 35 36 static ACLSystem* instance(); 37 38 enum ACL { 39 Allow = 0, 40 Deny = 1, 41 NotFound = 2 42 }; 43 44 ACLSystem( QObject *parent = 0 ); 45 ~ACLSystem(); 46 47 ACL isAuthorizedUser( const QString &dbid ); 48 void authorizeUser( const QString &dbid, ACL globalType ); 49 50 ACL isAuthorizedPath( const QString &dbid, const QString &path ); 51 void authorizePath( const QString &dbid, const QString &path, ACL type ); 52 53private slots: 54 void saveTimerFired(); 55 56private: 57 QHash< QString, QHash< QString, ACL > > m_cache; 58 QTimer m_saveTimer; 59 QMutex m_cacheMutex; 60 61 static ACLSystem* s_instance; 62}; 63 64#endif // TOMAHAWK_ACLSYSTEM_H