Merge pull request #2634 from FlyingRat/patch-0028-cwd-updated
[vuplus_xbmc] / xbmc / GUIPassword.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://www.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/ISettingCallback.h"
27 #include "utils/StdString.h"
28
29 class CFileItem;
30 class CMediaSource;
31
32 typedef std::vector<CMediaSource> VECSOURCES;
33
34 typedef enum
35 {
36   LOCK_MODE_UNKNOWN            = -1,
37   LOCK_MODE_EVERYONE           =  0,
38   LOCK_MODE_NUMERIC            =  1,
39   LOCK_MODE_GAMEPAD            =  2,
40   LOCK_MODE_QWERTY             =  3,
41   LOCK_MODE_SAMBA              =  4,
42   LOCK_MODE_EEPROM_PARENTAL    =  5
43 } LockType;
44
45 class CGUIPassword : public ISettingCallback
46 {
47 public:
48   CGUIPassword(void);
49   virtual ~CGUIPassword(void);
50   bool IsItemUnlocked(CFileItem* pItem, const CStdString &strType);
51   bool IsItemUnlocked(CMediaSource* pItem, const CStdString &strType);
52   bool CheckLock(LockType btnType, const CStdString& strPassword, int iHeading);
53   bool CheckLock(LockType btnType, const CStdString& strPassword, int iHeading, bool& bCanceled);
54   bool IsProfileLockUnlocked(int iProfile=-1);
55   bool IsProfileLockUnlocked(int iProfile, bool& bCanceled, bool prompt = true);
56   bool IsMasterLockUnlocked(bool bPromptUser);
57   bool IsMasterLockUnlocked(bool bPromptUser, bool& bCanceled);
58
59   void UpdateMasterLockRetryCount(bool bResetCount);
60   bool CheckStartUpLock();
61   bool CheckMenuLock(int iWindowID);
62   bool SetMasterLockMode(bool bDetails=true);
63   bool LockSource(const CStdString& strType, const CStdString& strName, bool bState);
64   void LockSources(bool lock);
65   void RemoveSourceLocks();
66   bool IsDatabasePathUnlocked(const CStdString& strPath, VECSOURCES& vecSources);
67
68   virtual void OnSettingAction(const CSetting *setting);
69
70   bool bMasterUser;
71   int iMasterLockRetriesLeft;
72
73 private:
74   int VerifyPassword(LockType btnType, const CStdString& strPassword, const CStdString& strHeading);
75 };
76
77 extern CGUIPassword g_passwordManager;
78
79