xbmc
GUIPassword.h
1 /*
2  * Copyright (C) 2005-2020 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "LockType.h"
12 #include "settings/lib/ISettingCallback.h"
13 #include "settings/lib/SettingLevel.h"
14 
15 #include <string>
16 #include <vector>
17 
18 class CFileItem;
19 class CMediaSource;
20 class CProfileManager;
21 
22 typedef std::vector<CMediaSource> VECSOURCES;
23 
25 {
26 public:
27  CGUIPassword(void);
28  ~CGUIPassword(void) override;
29  template<typename T>
30  bool IsItemUnlocked(T pItem,
31  const std::string& strType,
32  const std::string& strLabel,
33  const std::string& strHeading);
39  bool IsItemUnlocked(CFileItem* pItem, const std::string &strType);
45  bool IsItemUnlocked(CMediaSource* pItem, const std::string &strType);
46  bool CheckLock(LockType btnType, const std::string& strPassword, int iHeading);
47  bool CheckLock(LockType btnType, const std::string& strPassword, int iHeading, bool& bCanceled);
48  bool IsProfileLockUnlocked(int iProfile=-1);
49  bool IsProfileLockUnlocked(int iProfile, bool& bCanceled, bool prompt = true);
50  bool IsMasterLockUnlocked(bool bPromptUser);
51  bool IsMasterLockUnlocked(bool bPromptUser, bool& bCanceled);
52 
53  void UpdateMasterLockRetryCount(bool bResetCount);
54  bool CheckStartUpLock();
61  bool CheckSettingLevelLock(const SettingLevel& level, bool enforce = false);
62  bool CheckMenuLock(int iWindowID);
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, VECSOURCES& vecSources);
68 
76  bool IsMediaFileUnlocked(const std::string& type, const std::string& file) const;
77 
78  void SetMediaSourcePath(const std::string& strMediaSourcePath)
79  {
80  m_strMediaSourcePath = strMediaSourcePath;
81  }
82 
83  void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override;
84 
85  bool bMasterUser;
86  int iMasterLockRetriesLeft;
87 
88 private:
95  bool IsMediaPathUnlocked(const std::shared_ptr<CProfileManager>& profileManager,
96  const std::string& strType) const;
97 
98  std::string m_strMediaSourcePath;
99  int VerifyPassword(LockType btnType, const std::string& strPassword, const std::string& strHeading);
100 };
101 
102 extern CGUIPassword g_passwordManager;
Definition: ISettingCallback.h:16
bool IsMediaFileUnlocked(const std::string &type, const std::string &file) const
Helper function to test if a matching mediasource is currently unlocked for a given media file...
Definition: GUIPassword.cpp:580
Represents a share.
Definition: MediaSource.h:22
void OnSettingAction(const std::shared_ptr< const CSetting > &setting) override
The given setting has been activated.
Definition: GUIPassword.cpp:605
bool CheckSettingLevelLock(const SettingLevel &level, bool enforce=false)
Checks if the current profile is allowed to access the given settings level.
Definition: GUIPassword.cpp:371
std::vector< CMediaSource > VECSOURCES
A vector to hold CMediaSource objects.
Definition: MediaSource.h:98
Definition: ProfileManager.h:25
SettingLevel
Levels which every setting is assigned to.
Definition: SettingLevel.h:15
Definition: GUIPassword.h:24
Represents a file on a share.
Definition: FileItem.h:102