/src/libtomahawk/aclsystem.h

http://github.com/tomahawk-player/tomahawk · 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. #ifndef TOMAHAWK_ACLSYSTEM_H
  19. #define TOMAHAWK_ACLSYSTEM_H
  20. #include <QObject>
  21. #include <QString>
  22. #include <QHash>
  23. #include <QTimer>
  24. #include <QMutex>
  25. #include "dllmacro.h"
  26. class DLLEXPORT ACLSystem : public QObject
  27. {
  28. Q_OBJECT
  29. public:
  30. static ACLSystem* instance();
  31. enum ACL {
  32. Allow = 0,
  33. Deny = 1,
  34. NotFound = 2
  35. };
  36. ACLSystem( QObject *parent = 0 );
  37. ~ACLSystem();
  38. ACL isAuthorizedUser( const QString &dbid );
  39. void authorizeUser( const QString &dbid, ACL globalType );
  40. ACL isAuthorizedPath( const QString &dbid, const QString &path );
  41. void authorizePath( const QString &dbid, const QString &path, ACL type );
  42. private slots:
  43. void saveTimerFired();
  44. private:
  45. QHash< QString, QHash< QString, ACL > > m_cache;
  46. QTimer m_saveTimer;
  47. QMutex m_cacheMutex;
  48. static ACLSystem* s_instance;
  49. };
  50. #endif // TOMAHAWK_ACLSYSTEM_H