Merge pull request #4857 from t-nelson/Gotham_13.2_backports
[vuplus_xbmc] / xbmc / GUIPassword.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22
23 #include <map>
24 #include <vector>
25
26 #include "settings/lib/ISettingCallback.h"
27 #include "utils/StdString.h"
28 #include "settings/lib/Setting.h"
29
30 class CFileItem;
31 class CMediaSource;
32
33 typedef std::vector<CMediaSource> VECSOURCES;
34
35 typedef enum
36 {
37   LOCK_MODE_UNKNOWN            = -1,
38   LOCK_MODE_EVERYONE           =  0,
39   LOCK_MODE_NUMERIC            =  1,
40   LOCK_MODE_GAMEPAD            =  2,
41   LOCK_MODE_QWERTY             =  3,
42   LOCK_MODE_SAMBA              =  4,
43   LOCK_MODE_EEPROM_PARENTAL    =  5
44 } LockType;
45
46 namespace LOCK_LEVEL {
47   /**
48    Specifies, what Settings levels are locked for the user
49    **/
50   enum SETTINGS_LOCK
51   {
52     NONE,     //settings are unlocked => user can access all settings levels
53     ALL,      //all settings are locked => user always has to enter password, when entering the settings screen
54     STANDARD, //settings level standard and up are locked => user can still access the beginner levels
55     ADVANCED, 
56     EXPERT
57   };
58 }
59
60 class CGUIPassword : public ISettingCallback
61 {
62 public:
63   CGUIPassword(void);
64   virtual ~CGUIPassword(void);
65   bool IsItemUnlocked(CFileItem* pItem, const CStdString &strType);
66   bool IsItemUnlocked(CMediaSource* pItem, const CStdString &strType);
67   bool CheckLock(LockType btnType, const CStdString& strPassword, int iHeading);
68   bool CheckLock(LockType btnType, const CStdString& strPassword, int iHeading, bool& bCanceled);
69   bool IsProfileLockUnlocked(int iProfile=-1);
70   bool IsProfileLockUnlocked(int iProfile, bool& bCanceled, bool prompt = true);
71   bool IsMasterLockUnlocked(bool bPromptUser);
72   bool IsMasterLockUnlocked(bool bPromptUser, bool& bCanceled);
73
74   void UpdateMasterLockRetryCount(bool bResetCount);
75   bool CheckStartUpLock();
76   /*! \brief Checks if the current profile is allowed to access the given settings level
77    \param level - The level to check
78    \param enforce - If false, CheckSettingLevelLock is allowed to lower the current settings level
79                     to a level we're allowed to access
80    \returns true if we're allowed to access the settings
81    */
82   bool CheckSettingLevelLock(const SettingLevel& level, bool enforce = false);
83   bool CheckMenuLock(int iWindowID);
84   bool SetMasterLockMode(bool bDetails=true);
85   bool LockSource(const CStdString& strType, const CStdString& strName, bool bState);
86   void LockSources(bool lock);
87   void RemoveSourceLocks();
88   bool IsDatabasePathUnlocked(const CStdString& strPath, VECSOURCES& vecSources);
89
90   virtual void OnSettingAction(const CSetting *setting);
91
92   bool bMasterUser;
93   int iMasterLockRetriesLeft;
94
95 private:
96   int VerifyPassword(LockType btnType, const CStdString& strPassword, const CStdString& strHeading);
97 };
98
99 extern CGUIPassword g_passwordManager;
100
101