/*
* Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
+ * http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "profiles/dialogs/GUIDialogProfileSettings.h"
#include "Util.h"
#include "settings/MediaSourceSettings.h"
-#include "settings/Setting.h"
#include "settings/Settings.h"
#include "guilib/GUIWindowManager.h"
#include "FileItem.h"
#include "guilib/LocalizeStrings.h"
#include "utils/log.h"
+#include "utils/StringUtils.h"
+#include "view/ViewStateSettings.h"
CGUIPassword::CGUIPassword(void)
{
iVerifyPasswordResult = VerifyPassword(CProfilesManager::Get().GetMasterProfile().getLockMode(), strPassword, strHeader);
if (iVerifyPasswordResult != 0 )
{
- CStdString strLabel,strLabel1;
+ CStdString strLabel1;
strLabel1 = g_localizeStrings.Get(12343);
int iLeft = g_passwordManager.iMasterLockRetriesLeft-i;
- strLabel.Format("%i %s",iLeft,strLabel1.c_str());
+ CStdString strLabel = StringUtils::Format("%i %s", iLeft, strLabel1.c_str());
// PopUp OK and Display: MasterLock mode has changed but no no Mastercode has been set!
CGUIDialogOK::ShowAndGetInput(20076, 12367, 12368, strLabel);
if (!prompt)
return (profile->getLockMode() == LOCK_MODE_EVERYONE);
- if (profile->getDate().IsEmpty() &&
+ if (profile->getDate().empty() &&
(CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE ||
profile->getLockMode() == LOCK_MODE_EVERYONE))
{
}
CStdString dlgLine1 = "";
if (0 < g_passwordManager.iMasterLockRetriesLeft)
- dlgLine1.Format("%d %s", g_passwordManager.iMasterLockRetriesLeft, g_localizeStrings.Get(12343));
+ dlgLine1 = StringUtils::Format("%d %s",
+ g_passwordManager.iMasterLockRetriesLeft,
+ g_localizeStrings.Get(12343).c_str());
CGUIDialogOK::ShowAndGetInput(20075, 12345, dlgLine1, 0);
}
else
return (iVerifyPasswordResult==0);
}
+bool CGUIPassword::CheckSettingLevelLock(const SettingLevel& level, bool enforce /*=false*/)
+{
+ LOCK_LEVEL::SETTINGS_LOCK lockLevel = CProfilesManager::Get().GetCurrentProfile().settingsLockLevel();
+
+ if (lockLevel == LOCK_LEVEL::NONE)
+ return true;
+
+ //check if we are already in settings and in an level that needs unlocking
+ int windowID = g_windowManager.GetActiveWindow();
+ if ((int)lockLevel-1 <= (short)CViewStateSettings::Get().GetSettingLevel() &&
+ (windowID == WINDOW_SETTINGS_MENU ||
+ (windowID >= WINDOW_SCREEN_CALIBRATION &&
+ windowID <= WINDOW_SETTINGS_MYPVR)))
+ return true; //Already unlocked
+
+ else if (lockLevel == LOCK_LEVEL::ALL)
+ return IsMasterLockUnlocked(true);
+ else if ((int)lockLevel-1 <= (short)level)
+ {
+ if (enforce)
+ return IsMasterLockUnlocked(true);
+ else if (!IsMasterLockUnlocked(false))
+ {
+ //Current Setting level is higher than our permission... so lower the viewing level
+ SettingLevel newLevel = (SettingLevel)(short)(lockLevel-2);
+ CViewStateSettings::Get().SetSettingLevel(newLevel);
+ }
+ }
+ return true;
+
+}
+
+bool IsSettingsWindow(int iWindowID)
+{
+ return (iWindowID >= WINDOW_SCREEN_CALIBRATION && iWindowID <= WINDOW_SETTINGS_MYPVR)
+ || iWindowID == WINDOW_SKIN_SETTINGS;
+}
+
bool CGUIPassword::CheckMenuLock(int iWindowID)
{
bool bCheckPW = false;
int iSwitch = iWindowID;
// check if a settings subcategory was called from other than settings window
- if (iWindowID >= WINDOW_SCREEN_CALIBRATION && iWindowID <= WINDOW_SETTINGS_APPEARANCE)
+ if (IsSettingsWindow(iWindowID))
{
int iCWindowID = g_windowManager.GetActiveWindow();
- if (iCWindowID != WINDOW_SETTINGS_MENU && (iCWindowID < WINDOW_SCREEN_CALIBRATION || iCWindowID > WINDOW_SETTINGS_APPEARANCE))
+ if (iCWindowID != WINDOW_SETTINGS_MENU && !IsSettingsWindow(iCWindowID))
iSwitch = WINDOW_SETTINGS_MENU;
}
switch (iSwitch)
{
case WINDOW_SETTINGS_MENU: // Settings
- bCheckPW = CProfilesManager::Get().GetCurrentProfile().settingsLocked();
+ return CheckSettingLevelLock(CViewStateSettings::Get().GetSettingLevel());
break;
case WINDOW_ADDON_BROWSER: // Addons
bCheckPW = CProfilesManager::Get().GetCurrentProfile().addonmanagerLocked();