2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
12 #include "settings/lib/ISettingCallback.h"
13 #include "settings/lib/SettingLevel.h"
20 class CProfileManager
;
22 class CGUIPassword
: public ISettingCallback
26 ~CGUIPassword(void) override
;
28 bool IsItemUnlocked(T pItem
,
29 const std::string
& strType
,
30 const std::string
& strLabel
,
31 const std::string
& strHeading
);
32 /*! \brief Tests if the user is allowed to access the share folder
33 \param pItem The share folder item to access
34 \param strType The type of share being accessed, e.g. "music", "video", etc. See CSettings::UpdateSources()
35 \return If access is granted, returns \e true
37 bool IsItemUnlocked(CFileItem
* pItem
, const std::string
&strType
);
38 /*! \brief Tests if the user is allowed to access the Mediasource
39 \param pItem The share folder item to access
40 \param strType The type of share being accessed, e.g. "music", "video", etc. See CSettings::UpdateSources()
41 \return If access is granted, returns \e true
43 bool IsItemUnlocked(CMediaSource
* pItem
, const std::string
&strType
);
44 bool CheckLock(LockType btnType
, const std::string
& strPassword
, int iHeading
);
45 bool CheckLock(LockType btnType
, const std::string
& strPassword
, int iHeading
, bool& bCanceled
);
46 bool IsProfileLockUnlocked(int iProfile
=-1);
47 bool IsProfileLockUnlocked(int iProfile
, bool& bCanceled
, bool prompt
= true);
48 bool IsMasterLockUnlocked(bool bPromptUser
);
49 bool IsMasterLockUnlocked(bool bPromptUser
, bool& bCanceled
);
51 void UpdateMasterLockRetryCount(bool bResetCount
);
52 bool CheckStartUpLock();
53 /*! \brief Checks if the current profile is allowed to access the given settings level
54 \param level - The level to check
55 \param enforce - If false, CheckSettingLevelLock is allowed to lower the current settings level
56 to a level we're allowed to access
57 \returns true if we're allowed to access the settings
59 bool CheckSettingLevelLock(const SettingLevel
& level
, bool enforce
= false);
60 bool CheckMenuLock(int iWindowID
);
61 bool IsVideoUnlocked();
62 bool IsMusicUnlocked();
63 bool SetMasterLockMode(bool bDetails
=true);
64 bool LockSource(const std::string
& strType
, const std::string
& strName
, bool bState
);
65 void LockSources(bool lock
);
66 void RemoveSourceLocks();
67 bool IsDatabasePathUnlocked(const std::string
& strPath
, std::vector
<CMediaSource
>& sources
);
69 /*! \brief Helper function to test if a matching mediasource is currently unlocked
70 for a given media file
71 \note this function only returns the lock state. it does not provide unlock functionality
72 \param type The type of share being accessed, e.g. "music", "video", etc.
73 \param file The file to check lock state for
74 \return If access is granted, returns \e true
76 bool IsMediaFileUnlocked(const std::string
& type
, const std::string
& file
) const;
78 void SetMediaSourcePath(const std::string
& strMediaSourcePath
)
80 m_strMediaSourcePath
= strMediaSourcePath
;
83 void OnSettingAction(const std::shared_ptr
<const CSetting
>& setting
) override
;
86 int iMasterLockRetriesLeft
;
89 /*! \brief Helper function to test if the user is allowed to access the path
90 by looking up the matching Mediasource. Used internally by CheckMenuLock.
91 \param profileManager instance passed by ref. see CGUIPassword::CheckMenuLock
92 \param strType The type of share being accessed, e.g. "music", "video", etc.
93 \return If access is granted, returns \e true
95 bool IsMediaPathUnlocked(const std::shared_ptr
<CProfileManager
>& profileManager
,
96 const std::string
& strType
) const;
98 std::string m_strMediaSourcePath
;
99 int VerifyPassword(LockType btnType
, const std::string
& strPassword
, const std::string
& strHeading
);
102 extern CGUIPassword g_passwordManager
;