settings: move profile settings to CProfilesManager
authormontellese <montellese@xbmc.org>
Sun, 17 Mar 2013 21:37:14 +0000 (22:37 +0100)
committermontellese <montellese@xbmc.org>
Thu, 4 Apr 2013 21:26:17 +0000 (23:26 +0200)
54 files changed:
xbmc/Application.cpp
xbmc/Autorun.cpp
xbmc/Favourites.cpp
xbmc/GUIInfoManager.cpp
xbmc/GUIPassword.cpp
xbmc/PartyModeManager.cpp
xbmc/PasswordManager.cpp
xbmc/TextureCache.cpp
xbmc/Util.cpp
xbmc/cores/playercorefactory/PlayerCoreFactory.cpp
xbmc/dbwrappers/Database.cpp
xbmc/dialogs/GUIDialogContextMenu.cpp
xbmc/dialogs/GUIDialogFileBrowser.cpp
xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp
xbmc/filesystem/LibraryDirectory.cpp
xbmc/filesystem/SlingboxFile.cpp
xbmc/filesystem/SourcesDirectory.cpp
xbmc/filesystem/SpecialProtocol.cpp
xbmc/input/ButtonTranslator.cpp
xbmc/interfaces/Builtins.cpp
xbmc/interfaces/python/XBPython.cpp
xbmc/music/MusicDatabase.cpp
xbmc/music/dialogs/GUIDialogMusicInfo.cpp
xbmc/music/tags/MusicInfoTagLoaderCDDA.cpp
xbmc/music/windows/GUIWindowMusicBase.cpp
xbmc/music/windows/GUIWindowMusicNav.cpp
xbmc/music/windows/GUIWindowMusicPlaylist.cpp
xbmc/music/windows/GUIWindowMusicSongs.cpp
xbmc/network/upnp/UPnP.cpp
xbmc/profiles/Makefile
xbmc/profiles/ProfilesManager.cpp [new file with mode: 0644]
xbmc/profiles/ProfilesManager.h [new file with mode: 0644]
xbmc/profiles/dialogs/GUIDialogProfileSettings.cpp
xbmc/profiles/windows/GUIWindowSettingsProfile.cpp
xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp
xbmc/pvr/windows/GUIWindowPVRChannels.cpp
xbmc/settings/AdvancedSettings.cpp
xbmc/settings/GUISettings.cpp
xbmc/settings/MediaSourceSettings.cpp
xbmc/settings/Settings.cpp
xbmc/settings/Settings.h
xbmc/settings/windows/GUIWindowSettingsCategory.cpp
xbmc/utils/EdenVideoArtUpdater.cpp
xbmc/utils/RssManager.cpp
xbmc/video/VideoDatabase.cpp
xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp
xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp
xbmc/video/dialogs/GUIDialogVideoInfo.cpp
xbmc/video/dialogs/GUIDialogVideoSettings.cpp
xbmc/video/windows/GUIWindowVideoBase.cpp
xbmc/video/windows/GUIWindowVideoNav.cpp
xbmc/view/GUIViewState.cpp
xbmc/windows/GUIMediaWindow.cpp
xbmc/windows/GUIWindowLoginScreen.cpp

index 5652ab9..3d4cc2e 100644 (file)
@@ -90,6 +90,7 @@
 #include "filesystem/RarManager.h"
 #endif
 #include "playlists/PlayList.h"
+#include "profiles/ProfilesManager.h"
 #include "windowing/WindowingFactory.h"
 #include "powermanagement/PowerManager.h"
 #include "powermanagement/DPMSSupport.h"
@@ -644,7 +645,7 @@ bool CApplication::Create()
   // Init our DllLoaders emu env
   init_emu_environ();
 
-  g_settings.LoadProfiles(PROFILES_FILE);
+  CProfilesManager::Get().Load();
 
   CLog::Log(LOGNOTICE, "-----------------------------------------------------------------------");
 #if defined(TARGET_DARWIN_OSX)
@@ -717,6 +718,7 @@ bool CApplication::Create()
 
   CLog::Log(LOGNOTICE, "load settings...");
   g_settings.RegisterSettingsHandler(this);
+  g_settings.RegisterSettingsHandler(&CProfilesManager::Get());
   g_settings.RegisterSettingsHandler(&g_advancedSettings);
   g_settings.RegisterSettingsHandler(&CMediaSourceSettings::Get());
   g_settings.RegisterSettingsHandler(&CPlayerCoreFactory::Get());
@@ -739,12 +741,12 @@ bool CApplication::Create()
   }
 
   CLog::Log(LOGINFO, "creating subdirectories");
-  CLog::Log(LOGINFO, "userdata folder: %s", g_settings.GetProfileUserDataFolder().c_str());
+  CLog::Log(LOGINFO, "userdata folder: %s", CProfilesManager::Get().GetProfileUserDataFolder().c_str());
   CLog::Log(LOGINFO, "recording folder: %s", g_guiSettings.GetString("audiocds.recordingpath",false).c_str());
   CLog::Log(LOGINFO, "screenshots folder: %s", g_guiSettings.GetString("debug.screenshotpath",false).c_str());
-  CDirectory::Create(g_settings.GetUserDataFolder());
-  CDirectory::Create(g_settings.GetProfileUserDataFolder());
-  g_settings.CreateProfileFolders();
+  CDirectory::Create(CProfilesManager::Get().GetUserDataFolder());
+  CDirectory::Create(CProfilesManager::Get().GetProfileUserDataFolder());
+  CProfilesManager::Get().CreateProfileFolders();
 
   update_emu_environ();//apply the GUI settings
 
@@ -1386,14 +1388,14 @@ bool CApplication::Initialize()
       SAFE_DELETE(m_splash);
 
     if (g_guiSettings.GetBool("masterlock.startuplock") &&
-        g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE &&
-       !g_settings.GetMasterProfile().getLockCode().IsEmpty())
+        CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE &&
+       !CProfilesManager::Get().GetMasterProfile().getLockCode().IsEmpty())
     {
        g_passwordManager.CheckStartUpLock();
     }
 
     // check if we should use the login screen
-    if (g_settings.UsingLoginScreen())
+    if (CProfilesManager::Get().UsingLoginScreen())
       g_windowManager.ActivateWindow(WINDOW_LOGIN_SCREEN);
     else
     {
@@ -1427,7 +1429,7 @@ bool CApplication::Initialize()
   CLog::Log(LOGINFO, "removing tempfiles");
   CUtil::RemoveTempFiles();
 
-  if (!g_settings.UsingLoginScreen())
+  if (!CProfilesManager::Get().UsingLoginScreen())
   {
     UpdateLibraries();
 #ifdef HAS_PYTHON
@@ -3533,6 +3535,7 @@ bool CApplication::Cleanup()
 #ifdef HAS_UPNP
     g_settings.UnregisterSettingsHandler(&CUPnPSettings::Get());
 #endif
+    g_settings.UnregisterSettingsHandler(&CProfilesManager::Get());
     g_settings.UnregisterSettingsHandler(this);
 
 #ifdef _LINUX
@@ -3584,7 +3587,7 @@ void CApplication::Stop(int exitCode)
     g_settings.m_iSystemTimeTotalUp = g_settings.m_iSystemTimeTotalUp + (int)(CTimeUtils::GetFrameTime() / 60000);
 
     // Update the settings information (volume, uptime etc. need saving)
-    if (CFile::Exists(g_settings.GetSettingsFile()))
+    if (CFile::Exists(CProfilesManager::Get().GetSettingsFile()))
     {
       CLog::Log(LOGNOTICE, "Saving settings");
       g_settings.Save();
@@ -4420,7 +4423,7 @@ bool CApplication::IsFullScreen()
 
 void CApplication::SaveFileState(bool bForeground /* = false */)
 {
-  if (m_progressTrackingItem->IsPVRChannel() || !g_settings.GetCurrentProfile().canWriteDatabases())
+  if (m_progressTrackingItem->IsPVRChannel() || !CProfilesManager::Get().GetCurrentProfile().canWriteDatabases())
     return;
 
   if (bForeground)
@@ -4625,9 +4628,9 @@ bool CApplication::WakeUpScreenSaver(bool bPowerOffKeyPressed /* = false */)
   if (m_bScreenSave && m_screenSaver)
   {
     if (m_iScreenSaveLock == 0)
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE &&
-          (g_settings.UsingLoginScreen() || g_guiSettings.GetBool("masterlock.startuplock")) &&
-          g_settings.GetCurrentProfile().getLockMode() != LOCK_MODE_EVERYONE &&
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE &&
+          (CProfilesManager::Get().UsingLoginScreen() || g_guiSettings.GetBool("masterlock.startuplock")) &&
+          CProfilesManager::Get().GetCurrentProfile().getLockMode() != LOCK_MODE_EVERYONE &&
           m_screenSaver->ID() != "screensaver.xbmc.builtin.dim" && m_screenSaver->ID() != "screensaver.xbmc.builtin.black" && !m_screenSaver->ID().empty() && m_screenSaver->ID() != "visualization")
       {
         m_iScreenSaveLock = 2;
index eaf8bd8..71ef568 100644 (file)
@@ -31,6 +31,7 @@
 #include "filesystem/Directory.h"
 #include "filesystem/DirectoryFactory.h"
 #include "filesystem/File.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/GUISettings.h"
 #include "settings/Settings.h"
 #include "playlists/PlayList.h"
@@ -71,7 +72,7 @@ void CAutorun::ExecuteAutorun(const CStdString& path, bool bypassSettings, bool
   g_application.WakeUpScreenSaverAndDPMS();  // turn off the screensaver if it's active
 #ifdef HAS_CDDA_RIPPER
   if (g_guiSettings.GetInt("audiocds.autoaction") == AUTOCD_RIP && 
-      pInfo->IsAudio(1) && !g_settings.GetCurrentProfile().musicLocked())
+      pInfo->IsAudio(1) && !CProfilesManager::Get().GetCurrentProfile().musicLocked())
   {
     CCDDARipper::GetInstance().RipCD();
   }
@@ -144,9 +145,9 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
   bool bAllowMusic = true;
   if (!g_passwordManager.IsMasterLockUnlocked(false))
   {
-    bAllowVideo = !g_settings.GetCurrentProfile().videoLocked();
-//    bAllowPictures = !g_settings.GetCurrentProfile().picturesLocked();
-    bAllowMusic = !g_settings.GetCurrentProfile().musicLocked();
+    bAllowVideo = !CProfilesManager::Get().GetCurrentProfile().videoLocked();
+//    bAllowPictures = !CProfilesManager::Get().GetCurrentProfile().picturesLocked();
+    bAllowMusic = !CProfilesManager::Get().GetCurrentProfile().musicLocked();
   }
 
   // is this a root folder we have to check the content to determine a disc type
index 3ed0399..4e70738 100644 (file)
@@ -21,6 +21,7 @@
 #include "Favourites.h"
 #include "filesystem/File.h"
 #include "Util.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/Settings.h"
 #include "FileItem.h"
 #include "utils/XBMCTinyXML.h"
@@ -40,7 +41,7 @@ bool CFavourites::Load(CFileItemList &items)
     CFavourites::LoadFavourites(favourites, items);
   else
     CLog::Log(LOGDEBUG, "CFavourites::Load - no system favourites found, skipping");
-  URIUtils::AddFileToFolder(g_settings.GetProfileUserDataFolder(), "favourites.xml", favourites);
+  URIUtils::AddFileToFolder(CProfilesManager::Get().GetProfileUserDataFolder(), "favourites.xml", favourites);
   if(XFILE::CFile::Exists(favourites))
     CFavourites::LoadFavourites(favourites, items);
   else
@@ -108,7 +109,7 @@ bool CFavourites::Save(const CFileItemList &items)
     rootNode->InsertEndChild(favNode);
   }
 
-  URIUtils::AddFileToFolder(g_settings.GetProfileUserDataFolder(), "favourites.xml", favourites);
+  URIUtils::AddFileToFolder(CProfilesManager::Get().GetProfileUserDataFolder(), "favourites.xml", favourites);
   return doc.SaveFile(favourites);
 }
 
index 19d165b..3410e15 100644 (file)
@@ -39,6 +39,7 @@
 #include "music/tags/MusicInfoTag.h"
 #include "guilib/GUIWindowManager.h"
 #include "playlists/PlayList.h"
+#include "profiles/ProfilesManager.h"
 #include "utils/TuxBoxUtil.h"
 #include "windowing/WindowingFactory.h"
 #include "powermanagement/PowerManager.h"
@@ -1672,10 +1673,10 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa
     }
     break;
   case SYSTEM_PROFILENAME:
-    strLabel = g_settings.GetCurrentProfile().getName();
+    strLabel = CProfilesManager::Get().GetCurrentProfile().getName();
     break;
   case SYSTEM_PROFILECOUNT:
-    strLabel.Format("%i", g_settings.GetNumProfiles());
+    strLabel.Format("%i", CProfilesManager::Get().GetNumberOfProfiles());
     break;
   case SYSTEM_LANGUAGE:
     strLabel = g_guiSettings.GetString("locale.language");
@@ -2097,11 +2098,11 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI
     return GetMultiInfoBool(m_multiInfo[condition - MULTI_INFO_START], contextWindow, item);
   }
   else if (condition == SYSTEM_HASLOCKS)
-    bReturn = g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE;
+    bReturn = CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE;
   else if (condition == SYSTEM_HAS_PVR)
     bReturn = true;
   else if (condition == SYSTEM_ISMASTER)
-    bReturn = g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && g_passwordManager.bMasterUser;
+    bReturn = CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && g_passwordManager.bMasterUser;
   else if (condition == SYSTEM_ISFULLSCREEN)
     bReturn = g_Windowing.IsFullScreen();
   else if (condition == SYSTEM_ISSTANDALONE)
@@ -2115,7 +2116,7 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI
   else if (condition == SYSTEM_SHOW_EXIT_BUTTON)
     bReturn = g_advancedSettings.m_showExitButton;
   else if (condition == SYSTEM_HAS_LOGINSCREEN)
-    bReturn = g_settings.UsingLoginScreen();
+    bReturn = CProfilesManager::Get().UsingLoginScreen();
   else if (condition == WEATHER_IS_FETCHED)
     bReturn = g_weatherManager.IsFetched();
   else if (condition >= PVR_CONDITIONS_START && condition <= PVR_CONDITIONS_END)
@@ -3060,7 +3061,7 @@ CStdString CGUIInfoManager::GetImage(int info, int contextWindow, CStdString *fa
     return g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON);
   else if (info == SYSTEM_PROFILETHUMB)
   {
-    CStdString thumb = g_settings.GetCurrentProfile().getThumb();
+    CStdString thumb = CProfilesManager::Get().GetCurrentProfile().getThumb();
     if (thumb.IsEmpty())
       thumb = "unknown-user.png";
     return thumb;
index 24ce407..4862a3a 100644 (file)
@@ -25,6 +25,7 @@
 #include "guilib/GUIKeyboardFactory.h"
 #include "dialogs/GUIDialogNumeric.h"
 #include "dialogs/GUIDialogOK.h"
+#include "profiles/ProfilesManager.h"
 #include "profiles/dialogs/GUIDialogLockSettings.h"
 #include "profiles/dialogs/GUIDialogProfileSettings.h"
 #include "Util.h"
@@ -50,7 +51,7 @@ bool CGUIPassword::IsItemUnlocked(CFileItem* pItem, const CStdString &strType)
   // \param pItem The share folder item to access
   // \param strType The type of share being accessed, e.g. "music", "video", etc. See CSettings::UpdateSources()
   // \return If access is granted, returns \e true
-  if (g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE)
+  if (CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE)
     return true;
 
   while (pItem->m_iHasLock > 1)
@@ -126,14 +127,14 @@ bool CGUIPassword::CheckStartUpLock()
   if (iMasterLockRetriesLeft == -1)
     iMasterLockRetriesLeft = g_guiSettings.GetInt("masterlock.maxretries");
   if (g_passwordManager.iMasterLockRetriesLeft == 0) g_passwordManager.iMasterLockRetriesLeft = 1;
-  CStdString strPassword = g_settings.GetMasterProfile().getLockCode();
-  if (g_settings.GetMasterProfile().getLockMode() == 0)
+  CStdString strPassword = CProfilesManager::Get().GetMasterProfile().getLockCode();
+  if (CProfilesManager::Get().GetMasterProfile().getLockMode() == 0)
     iVerifyPasswordResult = 0;
   else
   {
     for (int i=1; i <= g_passwordManager.iMasterLockRetriesLeft; i++)
     {
-      iVerifyPasswordResult = VerifyPassword(g_settings.GetMasterProfile().getLockMode(), strPassword, strHeader);
+      iVerifyPasswordResult = VerifyPassword(CProfilesManager::Get().GetMasterProfile().getLockMode(), strPassword, strHeader);
       if (iVerifyPasswordResult != 0 )
       {
         CStdString strLabel,strLabel1;
@@ -163,7 +164,7 @@ bool CGUIPassword::CheckStartUpLock()
 
 bool CGUIPassword::SetMasterLockMode(bool bDetails)
 {
-  CProfile* profile = g_settings.GetProfile(0);
+  CProfile* profile = CProfilesManager::Get().GetProfile(0);
   if (profile)
   {
     CProfile::CLock locks = profile->GetLocks();
@@ -188,12 +189,12 @@ bool CGUIPassword::IsProfileLockUnlocked(int iProfile, bool& bCanceled, bool pro
     return true;
   int iProfileToCheck=iProfile;
   if (iProfile == -1)
-    iProfileToCheck = g_settings.GetCurrentProfileIndex();
+    iProfileToCheck = CProfilesManager::Get().GetCurrentProfileIndex();
   if (iProfileToCheck == 0)
     return IsMasterLockUnlocked(prompt,bCanceled);
   else
   {
-    CProfile *profile = g_settings.GetProfile(iProfileToCheck);
+    CProfile *profile = CProfilesManager::Get().GetProfile(iProfileToCheck);
     if (!profile)
       return false;
 
@@ -201,7 +202,7 @@ bool CGUIPassword::IsProfileLockUnlocked(int iProfile, bool& bCanceled, bool pro
       return (profile->getLockMode() == LOCK_MODE_EVERYONE);
 
     if (profile->getDate().IsEmpty() &&
-       (g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE ||
+       (CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE ||
         profile->getLockMode() == LOCK_MODE_EVERYONE))
     {
       // user hasn't set a password and this is the first time they've used this account
@@ -210,7 +211,7 @@ bool CGUIPassword::IsProfileLockUnlocked(int iProfile, bool& bCanceled, bool pro
         return true;
     }
     else
-       if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
+       if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
         return CheckLock(profile->getLockMode(),profile->getLockCode(),20095,bCanceled);
   }
 
@@ -228,11 +229,11 @@ bool CGUIPassword::IsMasterLockUnlocked(bool bPromptUser, bool& bCanceled)
   bCanceled = false;
   if (iMasterLockRetriesLeft == -1)
     iMasterLockRetriesLeft = g_guiSettings.GetInt("masterlock.maxretries");
-  if ((LOCK_MODE_EVERYONE < g_settings.GetMasterProfile().getLockMode() && !bMasterUser) && !bPromptUser)
+  if ((LOCK_MODE_EVERYONE < CProfilesManager::Get().GetMasterProfile().getLockMode() && !bMasterUser) && !bPromptUser)
     // not unlocked, but calling code doesn't want to prompt user
     return false;
 
-  if (g_passwordManager.bMasterUser || g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE)
+  if (g_passwordManager.bMasterUser || CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE)
     return true;
 
   if (iMasterLockRetriesLeft == 0)
@@ -244,8 +245,8 @@ bool CGUIPassword::IsMasterLockUnlocked(bool bPromptUser, bool& bCanceled)
   // no, unlock since we are allowed to prompt
   int iVerifyPasswordResult = -1;
   CStdString strHeading = g_localizeStrings.Get(20075);
-  CStdString strPassword = g_settings.GetMasterProfile().getLockCode();
-  iVerifyPasswordResult = VerifyPassword(g_settings.GetMasterProfile().getLockMode(), strPassword, strHeading);
+  CStdString strPassword = CProfilesManager::Get().GetMasterProfile().getLockCode();
+  iVerifyPasswordResult = VerifyPassword(CProfilesManager::Get().GetMasterProfile().getLockMode(), strPassword, strHeading);
   if (1 == iVerifyPasswordResult)
     UpdateMasterLockRetryCount(false);
 
@@ -303,7 +304,7 @@ bool CGUIPassword::CheckLock(LockType btnType, const CStdString& strPassword, in
 {
   bCanceled = false;
   if (btnType == LOCK_MODE_EVERYONE || strPassword.Equals("-")        ||
-      g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE || g_passwordManager.bMasterUser)
+      CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE || g_passwordManager.bMasterUser)
     return true;
 
   int iVerifyPasswordResult = -1;
@@ -348,25 +349,25 @@ bool CGUIPassword::CheckMenuLock(int iWindowID)
   switch (iSwitch)
   {
     case WINDOW_SETTINGS_MENU:  // Settings
-      bCheckPW = g_settings.GetCurrentProfile().settingsLocked();
+      bCheckPW = CProfilesManager::Get().GetCurrentProfile().settingsLocked();
       break;
     case WINDOW_ADDON_BROWSER:  // Addons
-      bCheckPW = g_settings.GetCurrentProfile().addonmanagerLocked();
+      bCheckPW = CProfilesManager::Get().GetCurrentProfile().addonmanagerLocked();
       break;
     case WINDOW_FILES:          // Files
-      bCheckPW = g_settings.GetCurrentProfile().filesLocked();
+      bCheckPW = CProfilesManager::Get().GetCurrentProfile().filesLocked();
       break;
     case WINDOW_PROGRAMS:       // Programs
-      bCheckPW = g_settings.GetCurrentProfile().programsLocked();
+      bCheckPW = CProfilesManager::Get().GetCurrentProfile().programsLocked();
       break;
     case WINDOW_MUSIC_FILES:    // Music
-      bCheckPW = g_settings.GetCurrentProfile().musicLocked();
+      bCheckPW = CProfilesManager::Get().GetCurrentProfile().musicLocked();
       break;
     case WINDOW_VIDEO_FILES:    // Video
-      bCheckPW = g_settings.GetCurrentProfile().videoLocked();
+      bCheckPW = CProfilesManager::Get().GetCurrentProfile().videoLocked();
       break;
     case WINDOW_PICTURES:       // Pictures
-      bCheckPW = g_settings.GetCurrentProfile().picturesLocked();
+      bCheckPW = CProfilesManager::Get().GetCurrentProfile().picturesLocked();
       break;
     case WINDOW_SETTINGS_PROFILES:
       bCheckPW = true;
@@ -440,7 +441,7 @@ void CGUIPassword::RemoveSourceLocks()
 
 bool CGUIPassword::IsDatabasePathUnlocked(const CStdString& strPath, VECSOURCES& vecSources)
 {
-  if (g_passwordManager.bMasterUser || g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE)
+  if (g_passwordManager.bMasterUser || CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE)
     return true;
 
   // try to find the best matching source
index de9cc94..a8607a9 100644 (file)
@@ -25,6 +25,7 @@
 #include "music/windows/GUIWindowMusicPlaylist.h"
 #include "video/VideoDatabase.h"
 #include "playlists/SmartPlayList.h"
+#include "profiles/ProfilesManager.h"
 #include "dialogs/GUIDialogProgress.h"
 #include "GUIUserMessages.h"
 #include "guilib/GUIWindowManager.h"
@@ -65,9 +66,9 @@ bool CPartyModeManager::Enable(PartyModeContext context /*= PARTYMODECONTEXT_MUS
   if (!strXspPath.IsEmpty()) //if a path to a smartplaylist is supplied use it
     partyModePath = strXspPath;
   else if (m_bIsVideo)
-    partyModePath = g_settings.GetUserDataItem("PartyMode-Video.xsp");
+    partyModePath = CProfilesManager::Get().GetUserDataItem("PartyMode-Video.xsp");
   else
-    partyModePath = g_settings.GetUserDataItem("PartyMode.xsp");
+    partyModePath = CProfilesManager::Get().GetUserDataItem("PartyMode.xsp");
 
   playlistLoaded=playlist.Load(partyModePath);
 
index 76964d4..81f4db8 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include "PasswordManager.h"
+#include "profiles/ProfilesManager.h"
 #include "profiles/dialogs/GUIDialogLockSettings.h"
 #include "URL.h"
 #include "settings/Settings.h"
@@ -117,7 +118,7 @@ void CPasswordManager::Clear()
 void CPasswordManager::Load()
 {
   Clear();
-  CStdString passwordsFile = g_settings.GetUserDataItem("passwords.xml");
+  CStdString passwordsFile = CProfilesManager::Get().GetUserDataItem("passwords.xml");
   if (XFILE::CFile::Exists(passwordsFile))
   {
     CXBMCTinyXML doc;
@@ -166,7 +167,7 @@ void CPasswordManager::Save() const
     XMLUtils::SetPath(path, "to", i->second);
   }
 
-  doc.SaveFile(g_settings.GetUserDataItem("passwords.xml"));
+  doc.SaveFile(CProfilesManager::Get().GetUserDataItem("passwords.xml"));
 }
 
 CStdString CPasswordManager::GetLookupPath(const CURL &url) const
index e16b6cf..f611b67 100644 (file)
@@ -21,6 +21,7 @@
 #include "TextureCache.h"
 #include "TextureCacheJob.h"
 #include "filesystem/File.h"
+#include "profiles/ProfilesManager.h"
 #include "threads/SingleLock.h"
 #include "utils/Crc32.h"
 #include "settings/Settings.h"
@@ -65,7 +66,7 @@ bool CTextureCache::IsCachedImage(const CStdString &url) const
     return true;
   if (URIUtils::IsInPath(url, "special://skin/") ||
       URIUtils::IsInPath(url, "androidapp://")   ||
-      URIUtils::IsInPath(url, g_settings.GetThumbnailsFolder()))
+      URIUtils::IsInPath(url, CProfilesManager::Get().GetThumbnailsFolder()))
     return true;
   return false;
 }
@@ -270,7 +271,7 @@ CStdString CTextureCache::GetCacheFile(const CStdString &url)
 
 CStdString CTextureCache::GetCachedPath(const CStdString &file)
 {
-  return URIUtils::AddFileToFolder(g_settings.GetThumbnailsFolder(), file);
+  return URIUtils::AddFileToFolder(CProfilesManager::Get().GetThumbnailsFolder(), file);
 }
 
 void CTextureCache::OnCachingComplete(bool success, CTextureCacheJob *job)
index 0f3d2ac..25fae82 100644 (file)
@@ -57,6 +57,7 @@
 #ifdef HAS_UPNP
 #include "filesystem/UPnPDirectory.h"
 #endif
+#include "profiles/ProfilesManager.h"
 #include "utils/RegExp.h"
 #include "settings/GUISettings.h"
 #include "guilib/TextureManager.h"
@@ -645,7 +646,7 @@ void CUtil::GetDVDDriveIcon( const CStdString& strPath, CStdString& strIcon )
 
 void CUtil::RemoveTempFiles()
 {
-  CStdString searchPath = g_settings.GetDatabaseFolder();
+  CStdString searchPath = CProfilesManager::Get().GetDatabaseFolder();
   CFileItemList items;
   if (!XFILE::CDirectory::GetDirectory(searchPath, items, ".tmp", DIR_FLAG_NO_FILE_DIRS))
     return;
index de800ed..3e23487 100644 (file)
@@ -29,6 +29,7 @@
 #include "settings/GUISettings.h"
 #include "URL.h"
 #include "FileItem.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/AdvancedSettings.h"
 #include "settings/Settings.h"
 #include "utils/AutoPtrHandle.h"
@@ -61,7 +62,7 @@ CPlayerCoreFactory& CPlayerCoreFactory::Get()
 void CPlayerCoreFactory::OnSettingsLoaded()
 {
   LoadConfiguration("special://xbmc/system/" PLAYERCOREFACTORY_XML, true);
-  LoadConfiguration(g_settings.GetUserDataItem(PLAYERCOREFACTORY_XML), false);
+  LoadConfiguration(CProfilesManager::Get().GetUserDataItem(PLAYERCOREFACTORY_XML), false);
 }
 
 /* generic function to make a vector unique, removes later duplicates */
index b125034..2227155 100644 (file)
@@ -24,6 +24,7 @@
 #include "utils/Crc32.h"
 #include "filesystem/SpecialProtocol.h"
 #include "filesystem/File.h"
+#include "profiles/ProfilesManager.h"
 #include "utils/AutoPtrHandle.h"
 #include "utils/log.h"
 #include "utils/SortUtils.h"
@@ -356,7 +357,7 @@ void CDatabase::InitSettings(DatabaseSettings &dbSettings)
   {
     dbSettings.type = "sqlite3";
     if (dbSettings.host.IsEmpty())
-      dbSettings.host = CSpecialProtocol::TranslatePath(g_settings.GetDatabaseFolder());
+      dbSettings.host = CSpecialProtocol::TranslatePath(CProfilesManager::Get().GetDatabaseFolder());
   }
 
   // use separate, versioned database
index 54a11d4..3c95aaa 100644 (file)
@@ -31,6 +31,7 @@
 #include "settings/GUISettings.h"
 #include "settings/MediaSourceSettings.h"
 #include "GUIDialogMediaSource.h"
+#include "profiles/ProfilesManager.h"
 #include "profiles/dialogs/GUIDialogLockSettings.h"
 #include "storage/MediaManager.h"
 #include "guilib/GUIWindowManager.h"
@@ -325,7 +326,7 @@ void CGUIDialogContextMenu::GetContextButtons(const CStdString &type, const CFil
   // Next, Add buttons to the ContextMenu that should ONLY be visible for sources and not autosourced items
   CMediaSource *share = GetShare(type, item.get());
 
-  if (g_settings.GetCurrentProfile().canWriteSources() || g_passwordManager.bMasterUser)
+  if (CProfilesManager::Get().GetCurrentProfile().canWriteSources() || g_passwordManager.bMasterUser)
   {
     if (share)
     {
@@ -356,9 +357,9 @@ void CGUIDialogContextMenu::GetContextButtons(const CStdString &type, const CFil
 
     buttons.Add(CONTEXT_BUTTON_ADD_SOURCE, 1026); // Add Source
   }
-  if (share && LOCK_MODE_EVERYONE != g_settings.GetMasterProfile().getLockMode())
+  if (share && LOCK_MODE_EVERYONE != CProfilesManager::Get().GetMasterProfile().getLockMode())
   {
-    if (share->m_iHasLock == 0 && (g_settings.GetCurrentProfile().canWriteSources() || g_passwordManager.bMasterUser))
+    if (share->m_iHasLock == 0 && (CProfilesManager::Get().GetCurrentProfile().canWriteSources() || g_passwordManager.bMasterUser))
       buttons.Add(CONTEXT_BUTTON_ADD_LOCK, 12332);
     else if (share->m_iHasLock == 1)
       buttons.Add(CONTEXT_BUTTON_REMOVE_LOCK, 12335);
@@ -385,12 +386,12 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI
   // Add Source doesn't require a valid share
   if (button == CONTEXT_BUTTON_ADD_SOURCE)
   {
-    if (g_settings.IsMasterUser())
+    if (CProfilesManager::Get().IsMasterProfile())
     {
       if (!g_passwordManager.IsMasterLockUnlocked(true))
         return false;
     }
-    else if (!g_settings.GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
+    else if (!CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
       return false;
 
     return CGUIDialogMediaSource::ShowAndAddMediaSource(type);
@@ -425,7 +426,7 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI
   switch (button)
   {
   case CONTEXT_BUTTON_EDIT_SOURCE:
-    if (g_settings.IsMasterUser())
+    if (CProfilesManager::Get().IsMasterProfile())
     {
       if (!g_passwordManager.IsMasterLockUnlocked(true))
         return false;
@@ -437,16 +438,16 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI
 
   case CONTEXT_BUTTON_REMOVE_SOURCE:
   {
-    if (g_settings.IsMasterUser())
+    if (CProfilesManager::Get().IsMasterProfile())
     {
       if (!g_passwordManager.IsMasterLockUnlocked(true))
         return false;
     }
     else
     {
-      if (!g_settings.GetCurrentProfile().canWriteSources() && !g_passwordManager.IsMasterLockUnlocked(false))
+      if (!CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsMasterLockUnlocked(false))
         return false;
-      if (g_settings.GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
+      if (CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
         return false;
     }
     // prompt user if they want to really delete the source
@@ -463,7 +464,7 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI
     return true;
   }
   case CONTEXT_BUTTON_SET_DEFAULT:
-    if (g_settings.GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
+    if (CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
       return false;
     else if (!g_passwordManager.IsMasterLockUnlocked(true))
       return false;
@@ -473,7 +474,7 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI
     return true;
 
   case CONTEXT_BUTTON_CLEAR_DEFAULT:
-    if (g_settings.GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
+    if (CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
       return false;
     else if (!g_passwordManager.IsMasterLockUnlocked(true))
       return false;
@@ -483,7 +484,7 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI
 
   case CONTEXT_BUTTON_SET_THUMB:
     {
-      if (g_settings.GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
+      if (CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
         return false;
       else if (!g_passwordManager.IsMasterLockUnlocked(true))
         return false;
index f55ba08..7af2561 100644 (file)
@@ -38,6 +38,7 @@
 #include "filesystem/File.h"
 #include "FileItem.h"
 #include "filesystem/MultiPathDirectory.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/AdvancedSettings.h"
 #include "settings/Settings.h"
 #include "settings/GUISettings.h"
@@ -427,8 +428,8 @@ void CGUIDialogFileBrowser::Update(const CStdString &strDirectory)
   OnSort();
 
   if (m_Directory->GetPath().IsEmpty() && m_addNetworkShareEnabled &&
-     (g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE ||
-      g_settings.IsMasterUser() || g_passwordManager.bMasterUser))
+     (CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE ||
+      CProfilesManager::Get().IsMasterProfile() || g_passwordManager.bMasterUser))
   { // we are in the virtual directory - add the "Add Network Location" item
     CFileItemPtr pItem(new CFileItem(g_localizeStrings.Get(1032)));
     pItem->SetPath("net://");
index 37b8677..fbfcfca 100644 (file)
@@ -25,6 +25,7 @@
 #include "GUIDialogSmartPlaylistRule.h"
 #include "guilib/GUIWindowManager.h"
 #include "filesystem/File.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/GUISettings.h"
 #include "settings/Settings.h"
 #include "FileItem.h"
@@ -505,9 +506,9 @@ bool CGUIDialogSmartPlaylistEditor::EditPlaylist(const CStdString &path, const C
   if (!editor) return false;
 
   editor->m_mode = type;
-  if (path.Equals(g_settings.GetUserDataItem("PartyMode.xsp")))
+  if (path.Equals(CProfilesManager::Get().GetUserDataItem("PartyMode.xsp").c_str()))
     editor->m_mode = "partymusic";
-  if (path.Equals(g_settings.GetUserDataItem("PartyMode-Video.xsp")))
+  if (path.Equals(CProfilesManager::Get().GetUserDataItem("PartyMode-Video.xsp").c_str()))
     editor->m_mode = "partyvideo";
 
   CSmartPlaylist playlist;
index 2ab2af9..3e96585 100644 (file)
@@ -21,6 +21,7 @@
 #include "LibraryDirectory.h"
 #include "Directory.h"
 #include "playlists/SmartPlayList.h"
+#include "profiles/ProfilesManager.h"
 #include "SmartPlaylistDirectory.h"
 #include "utils/URIUtils.h"
 #include "utils/StringUtils.h"
@@ -172,7 +173,7 @@ bool CLibraryDirectory::Exists(const char* strPath)
 CStdString CLibraryDirectory::GetNode(const CStdString &path)
 {
   CURL url(path);
-  CStdString libDir = URIUtils::AddFileToFolder(g_settings.GetLibraryFolder(), url.GetHostName() + "/");
+  CStdString libDir = URIUtils::AddFileToFolder(CProfilesManager::Get().GetLibraryFolder(), url.GetHostName() + "/");
   if (!CDirectory::Exists(libDir))
     libDir = URIUtils::AddFileToFolder("special://xbmc/system/library/", url.GetHostName() + "/");
 
index 199d271..cc96007 100644 (file)
@@ -22,6 +22,7 @@
 #include "SlingboxFile.h"
 #include "filesystem/File.h"
 #include "lib/SlingboxLib/SlingboxLib.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/Settings.h"
 #include "utils/log.h"
 #include "utils/XMLUtils.h"
@@ -493,7 +494,7 @@ void CSlingboxFile::LoadSettings(const CStdString& strHostname)
     m_sSlingboxSettings.uiCodeNumber[i] = 0;
 
   // Check if a SlingboxSettings.xml file exists
-  CStdString slingboxXMLFile = g_settings.GetUserDataItem("SlingboxSettings.xml");
+  CStdString slingboxXMLFile = CProfilesManager::Get().GetUserDataItem("SlingboxSettings.xml");
   if (!CFile::Exists(slingboxXMLFile))
   {
     CLog::Log(LOGNOTICE, "No SlingboxSettings.xml file (%s) found - using default settings",
index 1d5d4e8..d55b5d9 100644 (file)
@@ -24,6 +24,7 @@
 #include "Util.h"
 #include "FileItem.h"
 #include "File.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/Settings.h"
 #include "settings/MediaSourceSettings.h"
 #include "guilib/TextureManager.h"
@@ -101,7 +102,7 @@ bool CSourcesDirectory::GetDirectory(const VECSOURCES &sources, CFileItemList &i
       strIcon = "DefaultHardDisk.png";
     
     pItem->SetIconImage(strIcon);
-    if (share.m_iHasLock == 2 && g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
+    if (share.m_iHasLock == 2 && CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
       pItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_LOCKED);
     else
       pItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_NONE);
index cdfe019..dd60f90 100644 (file)
@@ -21,6 +21,7 @@
 #include "SpecialProtocol.h"
 #include "URL.h"
 #include "Util.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/GUISettings.h"
 #include "settings/Settings.h"
 #include "utils/log.h"
@@ -129,11 +130,11 @@ CStdString CSpecialProtocol::TranslatePath(const CURL &url)
   if (RootDir.Equals("subtitles"))
     URIUtils::AddFileToFolder(g_guiSettings.GetString("subtitles.custompath"), FileName, translatedPath);
   else if (RootDir.Equals("userdata"))
-    URIUtils::AddFileToFolder(g_settings.GetUserDataFolder(), FileName, translatedPath);
+    URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), FileName, translatedPath);
   else if (RootDir.Equals("database"))
-    URIUtils::AddFileToFolder(g_settings.GetDatabaseFolder(), FileName, translatedPath);
+    URIUtils::AddFileToFolder(CProfilesManager::Get().GetDatabaseFolder(), FileName, translatedPath);
   else if (RootDir.Equals("thumbnails"))
-    URIUtils::AddFileToFolder(g_settings.GetThumbnailsFolder(), FileName, translatedPath);
+    URIUtils::AddFileToFolder(CProfilesManager::Get().GetThumbnailsFolder(), FileName, translatedPath);
   else if (RootDir.Equals("recordings") || RootDir.Equals("cdrips"))
     URIUtils::AddFileToFolder(g_guiSettings.GetString("audiocds.recordingpath", false), FileName, translatedPath);
   else if (RootDir.Equals("screenshots"))
index 940a55a..051cbd1 100644 (file)
@@ -21,6 +21,7 @@
 #include "system.h"
 #include "interfaces/Builtins.h"
 #include "ButtonTranslator.h"
+#include "profiles/ProfilesManager.h"
 #include "utils/URIUtils.h"
 #include "settings/Settings.h"
 #include "guilib/Key.h"
@@ -568,7 +569,7 @@ bool CButtonTranslator::Load(bool AlwaysLoad)
   else
     CLog::Log(LOGDEBUG, "CButtonTranslator::Load - no system %s found, skipping", REMOTEMAP);
 
-  lircmapPath = g_settings.GetUserDataItem(REMOTEMAP);
+  lircmapPath = CProfilesManager::Get().GetUserDataItem(REMOTEMAP);
   if(CFile::Exists(lircmapPath))
     success |= LoadLircMap(lircmapPath);
   else
index e305a54..e96805e 100644 (file)
@@ -48,6 +48,7 @@
 #include "storage/MediaManager.h"
 #include "utils/RssManager.h"
 #include "PartyModeManager.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/DisplaySettings.h"
 #include "settings/Settings.h"
 #include "settings/MediaSourceSettings.h"
@@ -292,11 +293,11 @@ int CBuiltins::Execute(const CStdString& execString)
   }
   else if (execute.Equals("loadprofile"))
   {
-    int index = g_settings.GetProfileIndex(parameter);
+    int index = CProfilesManager::Get().GetProfileIndex(parameter);
     bool prompt = (params.size() == 2 && params[1].Equals("prompt"));
     bool bCanceled;
     if (index >= 0
-        && (g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE
+        && (CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE
             || g_passwordManager.IsProfileLockUnlocked(index,bCanceled,prompt)))
     {
       CApplicationMessenger::Get().LoadProfile(index);
@@ -1263,7 +1264,7 @@ int CBuiltins::Execute(const CStdString& execString)
     ADDON::CAddonMgr::Get().StopServices(true);
 
     g_application.getNetwork().NetworkMessage(CNetwork::SERVICES_DOWN,1);
-    g_settings.LoadMasterForLogin();
+    CProfilesManager::Get().LoadMasterProfileForLogin();
     g_passwordManager.bMasterUser = false;
     g_windowManager.ActivateWindow(WINDOW_LOGIN_SCREEN);
     if (!g_application.StartEventServer()) // event server could be needed in some situations
index 37197b1..67713d0 100644 (file)
@@ -35,6 +35,7 @@
 #include "settings/Settings.h"
 #include "filesystem/File.h"
 #include "filesystem/SpecialProtocol.h"
+#include "profiles/ProfilesManager.h"
 #include "utils/log.h"
 #include "pythreadstate.h"
 #include "utils/TimeUtils.h"
@@ -695,7 +696,7 @@ int XBPython::evalFile(const CStdString &src, const std::vector<CStdString> &arg
   }
 
   // check if locked
-  if (g_settings.GetCurrentProfile().programsLocked() && !g_passwordManager.IsMasterLockUnlocked(true))
+  if (CProfilesManager::Get().GetCurrentProfile().programsLocked() && !g_passwordManager.IsMasterLockUnlocked(true))
     return -1;
 
   CSingleLock lock(m_vecPyList);
index 8d877c9..6c00fdf 100644 (file)
@@ -43,6 +43,7 @@
 #include "dialogs/GUIDialogYesNo.h"
 #include "dialogs/GUIDialogSelect.h"
 #include "filesystem/File.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/GUISettings.h"
 #include "settings/AdvancedSettings.h"
 #include "FileItem.h"
@@ -2408,12 +2409,12 @@ bool CMusicDatabase::LookupCDDBInfo(bool bRequery/*=false*/)
   {
     CStdString strFile;
     strFile.Format("%x.cddb", pCdInfo->GetCddbDiscId());
-    CFile::Delete(URIUtils::AddFileToFolder(g_settings.GetCDDBFolder(), strFile));
+    CFile::Delete(URIUtils::AddFileToFolder(CProfilesManager::Get().GetCDDBFolder(), strFile));
   }
 
   // Prepare cddb
   Xcddb cddb;
-  cddb.setCacheDir(g_settings.GetCDDBFolder());
+  cddb.setCacheDir(CProfilesManager::Get().GetCDDBFolder());
 
   // Do we have to look for cddb information
   if (pCdInfo->HasCDDBInfo() && !cddb.isCDCached(pCdInfo))
@@ -2500,7 +2501,7 @@ void CMusicDatabase::DeleteCDDBInfo()
 {
 #ifdef HAS_DVD_DRIVE
   CFileItemList items;
-  if (!CDirectory::GetDirectory(g_settings.GetCDDBFolder(), items, ".cddb", DIR_FLAG_NO_FILE_DIRS))
+  if (!CDirectory::GetDirectory(CProfilesManager::Get().GetCDDBFolder(), items, ".cddb", DIR_FLAG_NO_FILE_DIRS))
   {
     CGUIDialogOK::ShowAndGetInput(313, 426, 0, 0);
     return ;
@@ -2522,7 +2523,7 @@ void CMusicDatabase::DeleteCDDBInfo()
       strFile.Delete(strFile.size() - 5, 5);
       ULONG lDiscId = strtoul(strFile.c_str(), NULL, 16);
       Xcddb cddb;
-      cddb.setCacheDir(g_settings.GetCDDBFolder());
+      cddb.setCacheDir(CProfilesManager::Get().GetCDDBFolder());
 
       if (!cddb.queryCache(lDiscId))
         continue;
@@ -2560,7 +2561,7 @@ void CMusicDatabase::DeleteCDDBInfo()
       {
         CStdString strFile;
         strFile.Format("%x.cddb", it->first);
-        CFile::Delete(URIUtils::AddFileToFolder(g_settings.GetCDDBFolder(), strFile));
+        CFile::Delete(URIUtils::AddFileToFolder(CProfilesManager::Get().GetCDDBFolder(), strFile));
         break;
       }
     }
index 9f588bf..07d871c 100644 (file)
@@ -28,6 +28,7 @@
 #include "URL.h"
 #include "filesystem/File.h"
 #include "FileItem.h"
+#include "profiles/ProfilesManager.h"
 #include "storage/MediaManager.h"
 #include "utils/AsyncFileCopy.h"
 #include "settings/Settings.h"
@@ -297,7 +298,7 @@ void CGUIDialogMusicInfo::Update()
   }
 
   // disable the GetThumb button if the user isn't allowed it
-  CONTROL_ENABLE_ON_CONDITION(CONTROL_BTN_GET_THUMB, g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser);
+  CONTROL_ENABLE_ON_CONDITION(CONTROL_BTN_GET_THUMB, CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser);
 }
 
 void CGUIDialogMusicInfo::SetLabel(int iControl, const CStdString& strLabel)
index 6892b56..f1997ba 100644 (file)
@@ -22,6 +22,7 @@
 #include "MusicInfoTagLoaderCDDA.h"
 #include "network/cddb.h"
 #include "MusicInfoTag.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/Settings.h"
 #include "storage/MediaManager.h"
 #include "utils/log.h"
@@ -62,7 +63,7 @@ bool CMusicInfoTagLoaderCDDA::Load(const CStdString& strFileName, CMusicInfoTag&
 
     // Prepare cddb
     Xcddb cddb;
-    cddb.setCacheDir(g_settings.GetCDDBFolder());
+    cddb.setCacheDir(CProfilesManager::Get().GetCDDBFolder());
 
     int iTrack = atoi(strFileName.substr(13, strFileName.size() - 13 - 5).c_str());
 
index 8bb3694..9aa6145 100644 (file)
@@ -53,6 +53,7 @@
 #include "dialogs/GUIDialogProgress.h"
 #include "FileItem.h"
 #include "filesystem/File.h"
+#include "profiles/ProfilesManager.h"
 #include "storage/MediaManager.h"
 #include "settings/Settings.h"
 #include "settings/AdvancedSettings.h"
@@ -413,7 +414,7 @@ void CGUIWindowMusicBase::OnManualAlbumInfo()
 void CGUIWindowMusicBase::ShowArtistInfo(const CArtist& artist, const CStdString& path, bool bRefresh, bool bShowInfo)
 {
   bool saveDb = artist.idArtist != -1;
-  if (!g_settings.GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
+  if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
     saveDb = false;
 
   // check cache
@@ -503,7 +504,7 @@ void CGUIWindowMusicBase::ShowArtistInfo(const CArtist& artist, const CStdString
 void CGUIWindowMusicBase::ShowAlbumInfo(const CAlbum& album, const CStdString& path, bool bRefresh, bool bShowInfo)
 {
   bool saveDb = album.idAlbum != -1;
-  if (!g_settings.GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
+  if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
     saveDb = false;
 
   // check cache
@@ -1186,7 +1187,7 @@ void CGUIWindowMusicBase::UpdateThumb(const CAlbum &album, const CStdString &pat
   // check user permissions
   bool saveDb = album.idAlbum != -1;
   bool saveDirThumb = true;
-  if (!g_settings.GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
+  if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
   {
     saveDb = false;
     saveDirThumb = false;
@@ -1312,7 +1313,7 @@ bool CGUIWindowMusicBase::GetDirectory(const CStdString &strDirectory, CFileItem
   // add in the "New Playlist" item if we're in the playlists folder
   if ((items.GetPath() == "special://musicplaylists/") && !items.Contains("newplaylist://"))
   {
-    CFileItemPtr newPlaylist(new CFileItem(g_settings.GetUserDataItem("PartyMode.xsp"),false));
+    CFileItemPtr newPlaylist(new CFileItem(CProfilesManager::Get().GetUserDataItem("PartyMode.xsp"),false));
     newPlaylist->SetLabel(g_localizeStrings.Get(16035));
     newPlaylist->SetLabelPreformated(true);
     newPlaylist->m_bIsFolder = true;
index 83855a5..14ecff1 100644 (file)
@@ -29,6 +29,7 @@
 #include "PartyModeManager.h"
 #include "playlists/PlayList.h"
 #include "playlists/PlayListFactory.h"
+#include "profiles/ProfilesManager.h"
 #include "video/VideoDatabase.h"
 #include "video/windows/GUIWindowVideoNav.h"
 #include "music/tags/MusicInfoTag.h"
@@ -523,7 +524,7 @@ void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &butt
         buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched
       else
         buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103);   //Mark as Watched
-      if ((g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !item->IsPlugin())
+      if ((CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !item->IsPlugin())
       {
         buttons.Add(CONTEXT_BUTTON_RENAME, 16105);
         buttons.Add(CONTEXT_BUTTON_DELETE, 646);
index 97ef418..dd8806a 100644 (file)
@@ -32,6 +32,7 @@
 #include "guilib/Key.h"
 #include "GUIUserMessages.h"
 #include "Favourites.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/Settings.h"
 #include "settings/GUISettings.h"
 #include "guilib/LocalizeStrings.h"
@@ -600,7 +601,7 @@ bool CGUIWindowMusicPlayList::OnContextButton(int itemNumber, CONTEXT_BUTTON but
 
   case CONTEXT_BUTTON_EDIT_PARTYMODE:
   {
-    CStdString playlist = g_settings.GetUserDataItem("PartyMode.xsp");
+    CStdString playlist = CProfilesManager::Get().GetUserDataItem("PartyMode.xsp");
     if (CGUIDialogSmartPlaylistEditor::EditPlaylist(playlist))
     {
       // apply new rules
index 46c8d4c..a0e2a7b 100644 (file)
@@ -29,6 +29,7 @@
 #include "GUIUserMessages.h"
 #include "guilib/GUIWindowManager.h"
 #include "FileItem.h"
+#include "profiles/ProfilesManager.h"
 #include "storage/MediaManager.h"
 #include "settings/Settings.h"
 #include "settings/GUISettings.h"
@@ -346,7 +347,7 @@ void CGUIWindowMusicSongs::GetContextButtons(int itemNumber, CContextButtons &bu
 
       // enable CDDB lookup if the current dir is CDDA
       if (g_mediaManager.IsDiscInDrive() && m_vecItems->IsCDDA() &&
-         (g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser))
+         (CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser))
       {
         buttons.Add(CONTEXT_BUTTON_CDDB, 16002);
       }
@@ -369,7 +370,7 @@ void CGUIWindowMusicSongs::GetContextButtons(int itemNumber, CContextButtons &bu
              !item->GetPath().Equals("add") && !item->IsParentFolder() &&
              !item->IsPlugin()                                         &&
              !item->GetPath().Left(9).Equals("addons://")              &&
-            (g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser))
+            (CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser))
     {
       buttons.Add(CONTEXT_BUTTON_SCAN, 13352);
     }
index 251482f..ecb5f5b 100644 (file)
@@ -33,6 +33,7 @@
 #include "utils/log.h"
 #include "Platinum.h"
 #include "URL.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/GUISettings.h"
 #include "GUIUserMessages.h"
 #include "settings/Settings.h"
@@ -424,7 +425,7 @@ CUPnP::StartServer()
 
     // load upnpserver.xml so that g_settings.m_vecUPnPMusiCMediaSources, etc.. are loaded
     CStdString filename;
-    URIUtils::AddFileToFolder(g_settings.GetUserDataFolder(), "upnpserver.xml", filename);
+    URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), "upnpserver.xml", filename);
     CUPnPSettings::Get().Load(filename);
 
     // create the server with a XBox compatible friendlyname and UUID from upnpserver.xml if found
@@ -504,7 +505,7 @@ void CUPnP::StartRenderer()
     if (!m_RendererHolder->m_Device.IsNull()) return;
 
     CStdString filename;
-    URIUtils::AddFileToFolder(g_settings.GetUserDataFolder(), "upnpserver.xml", filename);
+    URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), "upnpserver.xml", filename);
     CUPnPSettings::Get().Load(filename);
 
     m_RendererHolder->m_Device = CreateRenderer(CUPnPSettings::Get().GetRendererPort());
index fd39aa2..27bd070 100644 (file)
@@ -1,4 +1,5 @@
 SRCS=Profile.cpp \
+     ProfilesManager.cpp \
 
 LIB=profiles.a
 
diff --git a/xbmc/profiles/ProfilesManager.cpp b/xbmc/profiles/ProfilesManager.cpp
new file mode 100644 (file)
index 0000000..8804978
--- /dev/null
@@ -0,0 +1,501 @@
+/*
+ *      Copyright (C) 2013 Team XBMC
+ *      http://www.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
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This Program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with XBMC; see the file COPYING.  If not, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "system.h"
+#include "ProfilesManager.h"
+#include "Application.h"
+#include "DatabaseManager.h"
+#include "FileItem.h"
+#include "GUIInfoManager.h"
+#include "LangInfo.h"
+#include "PasswordManager.h"
+#include "Util.h"
+#include "dialogs/GUIDialogYesNo.h"
+#include "filesystem/Directory.h"
+#include "filesystem/DirectoryCache.h"
+#include "filesystem/File.h"
+#include "filesystem/SpecialProtocol.h"
+#include "guilib/GUIWindowManager.h"
+#include "guilib/LocalizeStrings.h"
+#include "input/ButtonTranslator.h"
+#include "input/MouseStat.h"
+#include "settings/GUISettings.h"
+#include "settings/Settings.h"
+#if !defined(TARGET_WINDOWS) && defined(HAS_DVD_DRIVE)
+#include "storage/DetectDVDType.h"
+#endif
+#include "threads/SingleLock.h"
+#include "utils/CharsetConverter.h"
+#include "utils/FileUtils.h"
+#include "utils/log.h"
+#include "utils/StringUtils.h"
+#include "utils/URIUtils.h"
+#include "utils/XMLUtils.h"
+
+// TODO
+// eventually the profile should dictate where special://masterprofile/ is
+// but for now it makes sense to leave all the profile settings in a user
+// writeable location like special://masterprofile/
+#define PROFILES_FILE     "special://masterprofile/profiles.xml"
+
+#define XML_PROFILES      "profiles"
+#define XML_LAST_LOADED   "lastloaded"
+#define XML_LOGIN_SCREEN  "useloginscreen"
+#define XML_NEXTID        "nextIdProfile"
+#define XML_PROFILE       "profile"
+
+using namespace std;
+using namespace XFILE;
+
+static CProfile EmptyProfile;
+
+CProfilesManager::CProfilesManager()
+  : m_usingLoginScreen(false), m_lastUsedProfile(0),
+    m_currentProfile(0), m_nextProfileId(0)
+{ }
+
+CProfilesManager::~CProfilesManager()
+{ }
+
+CProfilesManager& CProfilesManager::Get()
+{
+  static CProfilesManager sProfilesManager;
+  return sProfilesManager;
+}
+
+bool CProfilesManager::OnSettingsLoading()
+{
+  CSpecialProtocol::SetProfilePath(GetProfileUserDataFolder());
+
+  return true;
+}
+
+void CProfilesManager::OnSettingsLoaded()
+{
+  // check them all
+  string strDir = g_guiSettings.GetString("system.playlistspath");
+  if (strDir == "set default" || strDir.empty())
+  {
+    strDir = "special://profile/playlists/";
+    g_guiSettings.SetString("system.playlistspath", strDir.c_str());
+  }
+
+  CDirectory::Create(strDir);
+  CDirectory::Create(URIUtils::AddFileToFolder(strDir,"music"));
+  CDirectory::Create(URIUtils::AddFileToFolder(strDir,"video"));
+  CDirectory::Create(URIUtils::AddFileToFolder(strDir,"mixed"));
+}
+
+void CProfilesManager::OnSettingsSaved()
+{
+  // save mastercode
+  Save();
+}
+
+void CProfilesManager::OnSettingsCleared()
+{
+  Clear();
+}
+
+bool CProfilesManager::Load()
+{
+  return Load(PROFILES_FILE);
+}
+
+bool CProfilesManager::Load(const std::string &file)
+{
+  CSingleLock lock(m_critical);
+  bool ret = true;
+
+  // clear out our profiles
+  m_profiles.clear();
+
+  if (CFile::Exists(file))
+  {
+    CXBMCTinyXML profilesDoc;
+    if (profilesDoc.LoadFile(file))
+    {
+      const TiXmlElement *rootElement = profilesDoc.RootElement();
+      if (rootElement && StringUtils::EqualsNoCase(rootElement->Value(), XML_PROFILES))
+      {
+        XMLUtils::GetUInt(rootElement, XML_LAST_LOADED, m_lastUsedProfile);
+        XMLUtils::GetBoolean(rootElement, XML_LOGIN_SCREEN, m_usingLoginScreen);
+        XMLUtils::GetInt(rootElement, XML_NEXTID, m_nextProfileId);
+        
+        CStdString defaultDir("special://home/userdata");
+        if (!CDirectory::Exists(defaultDir))
+          defaultDir = "special://xbmc/userdata";
+        
+        const TiXmlElement* pProfile = rootElement->FirstChildElement(XML_PROFILE);
+        while (pProfile)
+        {
+          CProfile profile(defaultDir);
+          profile.Load(pProfile, GetNextProfileId());
+          AddProfile(profile);
+
+          pProfile = pProfile->NextSiblingElement(XML_PROFILE);
+        }
+      }
+      else
+      {
+        CLog::Log(LOGERROR, "CProfilesManager: error loading %s, no <profiles> node", file.c_str());
+        ret = false;
+      }
+    }
+    else
+    {
+      CLog::Log(LOGERROR, "CProfilesManager: error loading %s, Line %d\n%s", file.c_str(), profilesDoc.ErrorRow(), profilesDoc.ErrorDesc());
+      ret = false;
+    }
+  }
+
+  if (m_profiles.empty())
+  { // add the master user
+    CProfile profile("special://masterprofile/", "Master user", 0);
+    AddProfile(profile);
+  }
+
+  // check the validity of the previous profile index
+  if (m_lastUsedProfile >= m_profiles.size())
+    m_lastUsedProfile = 0;
+
+  m_currentProfile = m_lastUsedProfile;
+
+  // the login screen runs as the master profile, so if we're using this, we need to ensure
+  // we switch to the master profile
+  if (m_usingLoginScreen)
+    m_currentProfile = 0;
+
+  return ret;
+}
+
+bool CProfilesManager::Save()
+{
+  return Save(PROFILES_FILE);
+}
+
+bool CProfilesManager::Save(const std::string &file) const
+{
+  CSingleLock lock(m_critical);
+
+  CXBMCTinyXML xmlDoc;
+  TiXmlElement xmlRootElement(XML_PROFILES);
+  TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement);
+  if (pRoot == NULL)
+    return false;
+
+  XMLUtils::SetInt(pRoot, XML_LAST_LOADED, m_currentProfile);
+  XMLUtils::SetBoolean(pRoot, XML_LOGIN_SCREEN, m_usingLoginScreen);
+  XMLUtils::SetInt(pRoot, XML_NEXTID, m_nextProfileId);      
+
+  for (vector<CProfile>::const_iterator profile = m_profiles.begin(); profile != m_profiles.end(); profile++)
+    profile->Save(pRoot);
+
+  // save the file
+  return xmlDoc.SaveFile(file);
+}
+
+void CProfilesManager::Clear()
+{
+  CSingleLock lock(m_critical);
+  m_profiles.clear();
+  m_usingLoginScreen = false;
+  m_lastUsedProfile = 0;
+  m_currentProfile = 0;
+  m_nextProfileId = 0;
+}
+
+bool CProfilesManager::LoadProfile(size_t index)
+{
+  CSingleLock lock(m_critical);
+  // check if the index is valid or not
+  if (index >= m_profiles.size())
+    return false;
+
+  // check if the profile is already active
+  if (m_currentProfile == index)
+    return true;
+
+  m_currentProfile = index;
+
+  // load the new settings
+  if (!g_settings.Load())
+    return false;
+
+  CreateProfileFolders();
+
+  // initialize our charset converter
+  g_charsetConverter.reset();
+
+  // Load the langinfo to have user charset <-> utf-8 conversion
+  string strLanguage = g_guiSettings.GetString("locale.language");
+  strLanguage[0] = toupper(strLanguage[0]);
+
+  string strLangInfoPath = StringUtils::Format("special://xbmc/language/%s/langinfo.xml", strLanguage.c_str());
+  CLog::Log(LOGINFO, "CProfilesManager: load language info file: %s", strLangInfoPath.c_str());
+  g_langInfo.Load(strLangInfoPath);
+
+  CButtonTranslator::GetInstance().Load(true);
+  g_localizeStrings.Load("special://xbmc/language/", strLanguage);
+
+  CDatabaseManager::Get().Initialize();
+
+  g_Mouse.SetEnabled(g_guiSettings.GetBool("input.enablemouse"));
+
+  g_infoManager.ResetCache();
+  g_infoManager.ResetLibraryBools();
+
+  // always reload the skin - we need it for the new language strings
+  g_application.ReloadSkin();
+
+  if (m_currentProfile != 0)
+  {
+    CXBMCTinyXML doc;
+    if (doc.LoadFile(URIUtils::AddFileToFolder(GetUserDataFolder(), "guisettings.xml")))
+      g_guiSettings.LoadMasterLock(doc.RootElement());
+  }
+
+  CPasswordManager::GetInstance().Clear();
+
+  // to set labels - shares are reloaded
+#if !defined(TARGET_WINDOWS) && defined(HAS_DVD_DRIVE)
+  MEDIA_DETECT::CDetectDVDMedia::UpdateState();
+#endif
+
+  // init windows
+  CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_WINDOW_RESET);
+  g_windowManager.SendMessage(msg);
+
+  CUtil::DeleteDirectoryCache();
+  g_directoryCache.Clear();
+
+  return true;
+}
+
+bool CProfilesManager::DeleteProfile(size_t index)
+{
+  CSingleLock lock(m_critical);
+  const CProfile *profile = GetProfile(index);
+  if (profile == NULL)
+    return false;
+
+  CGUIDialogYesNo* dlgYesNo = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
+  if (dlgYesNo == NULL)
+    return false;
+
+  string message;
+  string str = g_localizeStrings.Get(13201);
+  message = StringUtils::Format(str.c_str(), profile->getName().c_str());
+  dlgYesNo->SetHeading(13200);
+  dlgYesNo->SetLine(0, message);
+  dlgYesNo->SetLine(1, "");
+  dlgYesNo->SetLine(2, "");
+  dlgYesNo->DoModal();
+
+  if (!dlgYesNo->IsConfirmed())
+    return false;
+
+  //delete profile
+  string strDirectory = profile->getDirectory();
+  m_profiles.erase(m_profiles.begin() + index);
+
+  // fall back to master profile if necessary
+  if (index == m_currentProfile)
+  {
+    Load(0);
+    g_settings.Save();
+  }
+
+  CFileItemPtr item = CFileItemPtr(new CFileItem(URIUtils::AddFileToFolder(GetUserDataFolder(), strDirectory)));
+  item->SetPath(URIUtils::AddFileToFolder(GetUserDataFolder(), strDirectory + "/"));
+  item->m_bIsFolder = true;
+  item->Select(true);
+  CFileUtils::DeleteItem(item);
+
+  return Save();
+}
+
+void CProfilesManager::CreateProfileFolders()
+{
+  CDirectory::Create(GetDatabaseFolder());
+  CDirectory::Create(GetCDDBFolder());
+  CDirectory::Create(GetLibraryFolder());
+
+  // create Thumbnails/*
+  CDirectory::Create(GetThumbnailsFolder());
+  CDirectory::Create(GetVideoThumbFolder());
+  CDirectory::Create(GetBookmarksThumbFolder());
+  for (size_t hex = 0; hex < 16; hex++)
+    CDirectory::Create(URIUtils::AddFileToFolder(GetThumbnailsFolder(), StringUtils::Format("%x", hex)));
+
+  CDirectory::Create("special://profile/addon_data");
+  CDirectory::Create("special://profile/keymaps");
+}
+
+const CProfile& CProfilesManager::GetMasterProfile() const
+{
+  CSingleLock lock(m_critical);
+  if (m_profiles.size() > 0)
+    return m_profiles[0];
+
+  CLog::Log(LOGERROR, "%s: master profile doesn't exist", __FUNCTION__);
+  return EmptyProfile;
+}
+
+const CProfile& CProfilesManager::GetCurrentProfile() const
+{
+  CSingleLock lock(m_critical);
+  if (m_currentProfile < m_profiles.size())
+    return m_profiles[m_currentProfile];
+
+  CLog::Log(LOGERROR, "CProfilesManager: current profile index (%u) is outside of the valid range (%" PRIdS ")", m_currentProfile, m_profiles.size());
+  return EmptyProfile;
+}
+
+const CProfile* CProfilesManager::GetProfile(size_t index) const
+{
+  CSingleLock lock(m_critical);
+  if (index < m_profiles.size())
+    return &m_profiles[index];
+
+  return NULL;
+}
+
+CProfile* CProfilesManager::GetProfile(size_t index)
+{
+  CSingleLock lock(m_critical);
+  if (index < m_profiles.size())
+    return &m_profiles[index];
+
+  return NULL;
+}
+
+int CProfilesManager::GetProfileIndex(const std::string &name) const
+{
+  CSingleLock lock(m_critical);
+  for (size_t i = 0; i < m_profiles.size(); i++)
+  {
+    if (StringUtils::EqualsNoCase(m_profiles[i].getName(), name))
+      return i;
+  }
+
+  return -1;
+}
+
+void CProfilesManager::AddProfile(const CProfile &profile)
+{
+  CSingleLock lock(m_critical);
+  // data integrity check - covers off migration from old profiles.xml,
+  // incrementing of the m_nextIdProfile,and bad data coming in
+  m_nextProfileId = max(m_nextProfileId, profile.getId() + 1);
+
+  m_profiles.push_back(profile);
+}
+
+void CProfilesManager::UpdateCurrentProfileDate()
+{
+  CSingleLock lock(m_critical);
+  if (m_currentProfile < m_profiles.size())
+    m_profiles[m_currentProfile].setDate();
+}
+
+void CProfilesManager::LoadMasterProfileForLogin()
+{
+  CSingleLock lock(m_critical);
+  // save the previous user
+  m_lastUsedProfile = m_currentProfile;
+  if (m_currentProfile != 0)
+    LoadProfile(0);
+}
+
+std::string CProfilesManager::GetUserDataFolder() const
+{
+  return GetMasterProfile().getDirectory();
+}
+
+std::string CProfilesManager::GetProfileUserDataFolder() const
+{
+  if (m_currentProfile == 0)
+    return GetUserDataFolder();
+
+  return URIUtils::AddFileToFolder(GetUserDataFolder(), GetCurrentProfile().getDirectory());
+}
+
+std::string CProfilesManager::GetDatabaseFolder() const
+{
+  if (GetCurrentProfile().hasDatabases())
+    return URIUtils::AddFileToFolder(GetProfileUserDataFolder(), "Database");
+
+  return URIUtils::AddFileToFolder(GetUserDataFolder(), "Database");
+}
+
+std::string CProfilesManager::GetCDDBFolder() const
+{
+  return URIUtils::AddFileToFolder(GetDatabaseFolder(), "CDDB");
+}
+
+std::string CProfilesManager::GetThumbnailsFolder() const
+{
+  if (GetCurrentProfile().hasDatabases())
+    return URIUtils::AddFileToFolder(GetProfileUserDataFolder(), "Thumbnails");
+
+  return URIUtils::AddFileToFolder(GetUserDataFolder(), "Thumbnails");
+}
+
+std::string CProfilesManager::GetVideoThumbFolder() const
+{
+  return URIUtils::AddFileToFolder(GetThumbnailsFolder(), "Video");
+}
+
+std::string CProfilesManager::GetBookmarksThumbFolder() const
+{
+  return URIUtils::AddFileToFolder(GetVideoThumbFolder(), "Bookmarks");
+}
+
+std::string CProfilesManager::GetLibraryFolder() const
+{
+  if (GetCurrentProfile().hasDatabases())
+    return URIUtils::AddFileToFolder(GetProfileUserDataFolder(), "library");
+
+  return URIUtils::AddFileToFolder(GetUserDataFolder(), "library");
+}
+
+std::string CProfilesManager::GetSettingsFile() const
+{
+  CStdString settings;
+  if (m_currentProfile == 0)
+    return "special://masterprofile/guisettings.xml";
+
+  return "special://profile/guisettings.xml";
+}
+
+std::string CProfilesManager::GetUserDataItem(const std::string& strFile) const
+{
+  std::string path;
+  path = "special://profile/" + strFile;
+
+  // check if item exists in the profile (either for folder or
+  // for a file (depending on slashAtEnd of strFile) otherwise
+  // return path to masterprofile
+  if ((URIUtils::HasSlashAtEnd(path) && !CDirectory::Exists(path)) || !CFile::Exists(path))
+    path = "special://masterprofile/" + strFile;
+
+  return path;
+}
diff --git a/xbmc/profiles/ProfilesManager.h b/xbmc/profiles/ProfilesManager.h
new file mode 100644 (file)
index 0000000..4b64a95
--- /dev/null
@@ -0,0 +1,171 @@
+#pragma once
+/*
+ *      Copyright (C) 2013 Team XBMC
+ *      http://www.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
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This Program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with XBMC; see the file COPYING.  If not, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <vector>
+
+#include "profiles/Profile.h"
+#include "settings/ISettingsHandler.h"
+#include "threads/CriticalSection.h"
+
+class TiXmlNode;
+
+class CProfilesManager : public ISettingsHandler
+{
+public:
+  static CProfilesManager& Get();
+
+  virtual bool OnSettingsLoading();
+  virtual void OnSettingsLoaded();
+  virtual void OnSettingsSaved();
+  virtual void OnSettingsCleared();
+
+  bool Load();
+  /*! \brief Load the user profile information from disk
+    Loads the profiles.xml file and creates the list of profiles.
+    If no profiles exist, a master user is created. Should be called
+    after special://masterprofile/ has been defined.
+    \param file XML file to load.
+    */
+  bool Load(const std::string &file);
+
+  bool Save();
+  /*! \brief Save the user profile information to disk
+    Saves the list of profiles to the profiles.xml file.
+    \param file XML file to save.
+    \return true on success, false on failure to save
+    */
+  bool Save(const std::string &file) const;
+
+  void Clear();
+
+  bool LoadProfile(size_t index);
+  bool DeleteProfile(size_t index);
+
+  void CreateProfileFolders();
+
+  /*! \brief Retrieve the master profile
+    \return const reference to the master profile
+    */
+  const CProfile& GetMasterProfile() const;
+
+  /*! \brief Retreive the current profile
+    \return const reference to the current profile
+    */
+  const CProfile& GetCurrentProfile() const;
+
+  /*! \brief Retreive the profile from an index
+    \param unsigned index of the profile to retrieve
+    \return const pointer to the profile, NULL if the index is invalid
+    */
+  const CProfile* GetProfile(size_t index) const;
+
+  /*! \brief Retreive the profile from an index
+    \param unsigned index of the profile to retrieve
+    \return pointer to the profile, NULL if the index is invalid
+    */
+  CProfile* GetProfile(size_t index);
+
+  /*! \brief Retreive index of a particular profile by name
+    \param name name of the profile index to retrieve
+    \return index of this profile, -1 if invalid.
+    */
+  int GetProfileIndex(const std::string &name) const;
+
+  /*! \brief Retrieve the number of profiles
+    \return number of profiles
+    */
+  size_t GetNumberOfProfiles() const { return m_profiles.size(); }
+
+  /*! \brief Add a new profile
+    \param profile CProfile to add
+    */
+  void AddProfile(const CProfile &profile);
+
+  /*! \brief Are we using the login screen?
+    \return true if we're using the login screen, false otherwise
+    */
+  bool UsingLoginScreen() const { return m_usingLoginScreen; }
+
+  /*! \brief Toggle login screen use on and off
+    Toggles the login screen state
+    */
+  void ToggleLoginScreen() { m_usingLoginScreen = !m_usingLoginScreen; }
+
+  /*! \brief Are we the master user?
+    \return true if the current profile is the master user, false otherwise
+    */
+  bool IsMasterProfile() const { return m_currentProfile == 0; }
+
+  /*! \brief Update the date of the current profile
+    */
+  void UpdateCurrentProfileDate();
+
+  /*! \brief Load the master user for the purposes of logging in
+    Loads the master user.  Identical to LoadProfile(0) but doesn't
+    update the last logged in details
+    */
+  void LoadMasterProfileForLogin();
+
+  /*! \brief Retreive the last used profile index
+    \return the last used profile that logged in.  Does not count the
+    master user during login.
+    */
+  uint32_t GetLastUsedProfileIndex() const { return m_lastUsedProfile; }
+
+  /*! \brief Retrieve the current profile index
+    \return the index of the currently logged in profile.
+    */
+  uint32_t GetCurrentProfileIndex() const { return m_currentProfile; }
+
+  /*! \brief Retrieve the next id to use for a new profile
+    \return the unique <id> to be used when creating a new profile
+    */
+  int GetNextProfileId() const { return m_nextProfileId; }
+
+  int GetCurrentProfileId() const { return GetCurrentProfile().getId(); }
+
+  std::string GetUserDataFolder() const;
+  std::string GetProfileUserDataFolder() const;
+  std::string GetDatabaseFolder() const;
+  std::string GetCDDBFolder() const;
+  std::string GetThumbnailsFolder() const;
+  std::string GetVideoThumbFolder() const;
+  std::string GetBookmarksThumbFolder() const;
+  std::string GetLibraryFolder() const;
+  std::string GetSettingsFile() const;
+
+  // uses HasSlashAtEnd to determine if a directory or file was meant
+  std::string GetUserDataItem(const std::string& strFile) const;
+
+protected:
+  CProfilesManager();
+  CProfilesManager(const CProfilesManager&);
+  CProfilesManager const& operator=(CProfilesManager const&);
+  virtual ~CProfilesManager();
+
+private:
+  std::vector<CProfile> m_profiles;
+  bool m_usingLoginScreen;
+  uint32_t m_lastUsedProfile;
+  uint32_t m_currentProfile;
+  int m_nextProfileId; // for tracking the next available id to give to a new profile to ensure id's are not re-used
+  CCriticalSection m_critical;
+};
index 6f9f3f2..13e813f 100644 (file)
@@ -21,6 +21,7 @@
 #include "GUIDialogProfileSettings.h"
 #include "dialogs/GUIDialogFileBrowser.h"
 #include "guilib/GUIKeyboardFactory.h"
+#include "profiles/ProfilesManager.h"
 #include "profiles/dialogs/GUIDialogLockSettings.h"
 #include "guilib/GUIImage.h"
 #include "guilib/GUIWindowManager.h"
@@ -97,7 +98,7 @@ void CGUIDialogProfileSettings::CreateSettings()
 
   if (m_bShowDetails)
     AddButton(4,20066);
-  if (!m_bShowDetails && m_locks.mode == LOCK_MODE_EVERYONE && g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
+  if (!m_bShowDetails && m_locks.mode == LOCK_MODE_EVERYONE && CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
     AddButton(4,20066);
 
   if (!m_bIsDefault && m_bShowDetails)
@@ -110,7 +111,7 @@ void CGUIDialogProfileSettings::CreateSettings()
     setting.entry.push_back(make_pair(setting.entry.size(), g_localizeStrings.Get(20062)));
     setting.entry.push_back(make_pair(setting.entry.size(), g_localizeStrings.Get(20063)));
     setting.entry.push_back(make_pair(setting.entry.size(), g_localizeStrings.Get(20061)));
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
       setting.entry.push_back(make_pair(setting.entry.size(), g_localizeStrings.Get(20107)));
 
     m_settings.push_back(setting);
@@ -123,7 +124,7 @@ void CGUIDialogProfileSettings::CreateSettings()
     setting2.entry.push_back(make_pair(setting2.entry.size(), g_localizeStrings.Get(20062)));
     setting2.entry.push_back(make_pair(setting2.entry.size(), g_localizeStrings.Get(20063)));
     setting2.entry.push_back(make_pair(setting2.entry.size(), g_localizeStrings.Get(20061)));
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
       setting2.entry.push_back(make_pair(setting2.entry.size(), g_localizeStrings.Get(20107)));
 
     m_settings.push_back(setting2);
@@ -193,14 +194,14 @@ void CGUIDialogProfileSettings::OnSettingChanged(SettingInfo &setting)
   {
     if (m_bShowDetails)
     {
-      if (g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE && !m_bIsDefault)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE && !m_bIsDefault)
       {
         if (CGUIDialogYesNo::ShowAndGetInput(20066,20118,20119,20022))
           g_passwordManager.SetMasterLockMode(false);
-        if (g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE)
+        if (CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE)
           return;
       }
-      if (CGUIDialogLockSettings::ShowAndGetLock(m_locks, m_bIsDefault ? 12360 : 20068, g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE || m_bIsDefault))
+      if (CGUIDialogLockSettings::ShowAndGetLock(m_locks, m_bIsDefault ? 12360 : 20068, CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE || m_bIsDefault))
         m_bNeedSave = true;
     }
     else
@@ -248,14 +249,14 @@ bool CGUIDialogProfileSettings::ShowForProfile(unsigned int iProfile, bool first
     dialog->m_bIsDefault = true;
   else
     dialog->m_bIsDefault = false;
-  if (firstLogin && iProfile > g_settings.GetNumProfiles())
+  if (firstLogin && iProfile > CProfilesManager::Get().GetNumberOfProfiles())
     return false;
 
   dialog->m_bNeedSave = false;
   dialog->m_bShowDetails = !firstLogin;
   dialog->SetProperty("heading", g_localizeStrings.Get(firstLogin ? 20255 : 20067));
 
-  const CProfile *profile = g_settings.GetProfile(iProfile);
+  const CProfile *profile = CProfilesManager::Get().GetProfile(iProfile);
 
   if (!profile)
   { // defaults
@@ -264,7 +265,7 @@ bool CGUIDialogProfileSettings::ShowForProfile(unsigned int iProfile, bool first
     dialog->m_iSourcesMode = 2;
     dialog->m_locks = CProfile::CLock();
 
-    bool bLock = g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser;
+    bool bLock = CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser;
     dialog->m_locks.addonManager = bLock;
     dialog->m_locks.settings = bLock;
     dialog->m_locks.files = bLock;
@@ -305,7 +306,7 @@ bool CGUIDialogProfileSettings::ShowForProfile(unsigned int iProfile, bool first
   dialog->DoModal();
   if (dialog->m_bNeedSave)
   {
-    if (iProfile >= g_settings.GetNumProfiles())
+    if (iProfile >= CProfilesManager::Get().GetNumberOfProfiles())
     {
       if (dialog->m_strName.IsEmpty() || dialog->m_strDirectory.IsEmpty())
         return false;
@@ -313,13 +314,13 @@ bool CGUIDialogProfileSettings::ShowForProfile(unsigned int iProfile, bool first
       strLabel.Format(g_localizeStrings.Get(20047),dialog->m_strName);
       if (!CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(20058),strLabel,dialog->m_strDirectory,""))
       {
-        CDirectory::Remove(URIUtils::AddFileToFolder(g_settings.GetUserDataFolder(), dialog->m_strDirectory));
+        CDirectory::Remove(URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), dialog->m_strDirectory));
         return false;
       }*/
 
       // check for old profile settings
-      CProfile profile(dialog->m_strDirectory,dialog->m_strName,g_settings.GetNextProfileId());
-      g_settings.AddProfile(profile);
+      CProfile profile(dialog->m_strDirectory, dialog->m_strName, CProfilesManager::Get().GetNextProfileId());
+      CProfilesManager::Get().AddProfile(profile);
       bool bExists = CFile::Exists(URIUtils::AddFileToFolder("special://masterprofile/",
                                                           dialog->m_strDirectory+"/guisettings.xml"));
 
@@ -371,7 +372,7 @@ bool CGUIDialogProfileSettings::ShowForProfile(unsigned int iProfile, bool first
       if (!CGUIDialogYesNo::ShowAndGetInput(20067,20103,20022,20022))
         return false;*/
 
-    CProfile *profile = g_settings.GetProfile(iProfile);
+    CProfile *profile = CProfilesManager::Get().GetProfile(iProfile);
     assert(profile);
     profile->setName(dialog->m_strName);
     profile->setDirectory(dialog->m_strDirectory);
@@ -382,7 +383,7 @@ bool CGUIDialogProfileSettings::ShowForProfile(unsigned int iProfile, bool first
     profile->setSources((dialog->m_iSourcesMode & 2) == 2);
     profile->SetLocks(dialog->m_locks);
 
-    g_settings.SaveProfiles(PROFILES_FILE);
+    CProfilesManager::Get().Save();
     return true;
   }
 
index 7822ee9..7799332 100644 (file)
@@ -21,6 +21,7 @@
 #include "GUIWindowSettingsProfile.h"
 #include "windows/GUIWindowFileManager.h"
 #include "profiles/Profile.h"
+#include "profiles/ProfilesManager.h"
 #include "Application.h"
 #include "dialogs/GUIDialogContextMenu.h"
 #include "profiles/dialogs/GUIDialogProfileSettings.h"
@@ -64,7 +65,7 @@ int CGUIWindowSettingsProfile::GetSelectedItem()
 
 void CGUIWindowSettingsProfile::OnPopupMenu(int iItem)
 {
-  if (iItem == (int)g_settings.GetNumProfiles())
+  if (iItem == (int)CProfilesManager::Get().GetNumberOfProfiles())
     return;
 
   // popup the context menu
@@ -81,14 +82,14 @@ void CGUIWindowSettingsProfile::OnPopupMenu(int iItem)
     CGUIMessage msg2(GUI_MSG_ITEM_SELECTED, g_windowManager.GetActiveWindow(), iCtrlID);
     g_windowManager.SendMessage(msg2);
     g_application.getNetwork().NetworkMessage(CNetwork::SERVICES_DOWN,1);
-    g_settings.LoadMasterForLogin();
+    CProfilesManager::Get().LoadMasterProfileForLogin();
     CGUIWindowLoginScreen::LoadProfile(iItem);
     return;
   }
 
   if (choice == 2)
   {
-    if (g_settings.DeleteProfile(iItem))
+    if (CProfilesManager::Get().DeleteProfile(iItem))
       iItem--;
   }
 
@@ -128,13 +129,13 @@ bool CGUIWindowSettingsProfile::OnMessage(CGUIMessage& message)
           if (iAction == ACTION_CONTEXT_MENU || iAction == ACTION_MOUSE_RIGHT_CLICK)
           {
             //contextmenu
-            if (iItem <= (int)g_settings.GetNumProfiles() - 1)
+            if (iItem <= (int)CProfilesManager::Get().GetNumberOfProfiles() - 1)
             {
               OnPopupMenu(iItem);
             }
             return true;
           }
-          else if (iItem < (int)g_settings.GetNumProfiles())
+          else if (iItem < (int)CProfilesManager::Get().GetNumberOfProfiles())
           {
             if (CGUIDialogProfileSettings::ShowForProfile(iItem))
             {
@@ -147,10 +148,10 @@ bool CGUIWindowSettingsProfile::OnMessage(CGUIMessage& message)
 
             return false;
           }
-          else if (iItem > (int)g_settings.GetNumProfiles() - 1)
+          else if (iItem > (int)CProfilesManager::Get().GetNumberOfProfiles() - 1)
           {
-            CDirectory::Create(URIUtils::AddFileToFolder(g_settings.GetUserDataFolder(),"profiles"));
-            if (CGUIDialogProfileSettings::ShowForProfile(g_settings.GetNumProfiles()))
+            CDirectory::Create(URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(),"profiles"));
+            if (CGUIDialogProfileSettings::ShowForProfile(CProfilesManager::Get().GetNumberOfProfiles()))
             {
               LoadList();
               CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), 2,iItem);
@@ -164,8 +165,8 @@ bool CGUIWindowSettingsProfile::OnMessage(CGUIMessage& message)
       }
       else if (iControl == CONTROL_LOGINSCREEN)
       {
-        g_settings.ToggleLoginScreen();
-        g_settings.SaveProfiles(PROFILES_FILE);
+        CProfilesManager::Get().ToggleLoginScreen();
+        CProfilesManager::Get().Save();
         return true;
       }
     }
@@ -179,9 +180,9 @@ void CGUIWindowSettingsProfile::LoadList()
 {
   ClearListItems();
 
-  for (unsigned int i = 0; i < g_settings.GetNumProfiles(); i++)
+  for (unsigned int i = 0; i < CProfilesManager::Get().GetNumberOfProfiles(); i++)
   {
-    const CProfile *profile = g_settings.GetProfile(i);
+    const CProfile *profile = CProfilesManager::Get().GetProfile(i);
     CFileItemPtr item(new CFileItem(profile->getName()));
     item->SetLabel2(profile->getDate());
     item->SetArt("thumb", profile->getThumb());
@@ -195,7 +196,7 @@ void CGUIWindowSettingsProfile::LoadList()
   CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_PROFILES, 0, 0, m_listItems);
   OnMessage(msg);
 
-  if (g_settings.UsingLoginScreen())
+  if (CProfilesManager::Get().UsingLoginScreen())
   {
     CONTROL_SELECT(CONTROL_LOGINSCREEN);
   }
index 1aeb11e..8e93551 100644 (file)
@@ -34,6 +34,7 @@
 #include "guilib/GUIWindowManager.h"
 #include "guilib/Key.h"
 #include "guilib/LocalizeStrings.h"
+#include "profiles/ProfilesManager.h"
 #include "pvr/PVRManager.h"
 #include "pvr/channels/PVRChannelGroupsContainer.h"
 #include "pvr/addons/PVRClients.h"
@@ -300,7 +301,7 @@ bool CGUIDialogPVRChannelManager::OnClickButtonChannelLogo(CGUIMessage &message)
   CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
   if (!pItem)
     return false;
-  if (g_settings.GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
+  if (CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
     return false;
   else if (!g_passwordManager.IsMasterLockUnlocked(true))
     return false;
index a5315d1..0be2c8e 100644 (file)
@@ -29,6 +29,7 @@
 #include "guilib/GUIWindowManager.h"
 #include "guilib/Key.h"
 #include "GUIInfoManager.h"
+#include "profiles/ProfilesManager.h"
 #include "pvr/PVRManager.h"
 #include "pvr/channels/PVRChannelGroupsContainer.h"
 #include "pvr/dialogs/GUIDialogPVRGroupManager.h"
@@ -458,7 +459,7 @@ bool CGUIWindowPVRChannels::OnContextButtonSetThumb(CFileItem *item, CONTEXT_BUT
 
   if (button == CONTEXT_BUTTON_SET_THUMB)
   {
-    if (g_settings.GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
+    if (CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
       return bReturn;
     else if (!g_passwordManager.IsMasterLockUnlocked(true))
       return bReturn;
index 53a9b56..2b94de8 100644 (file)
@@ -27,6 +27,7 @@
 #include "filesystem/File.h"
 #include "utils/LangCodeExpander.h"
 #include "LangInfo.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/GUISettings.h"
 #include "settings/Settings.h"
 #include "utils/StringUtils.h"
@@ -357,7 +358,7 @@ bool CAdvancedSettings::Load()
   ParseSettingsFile("special://xbmc/system/advancedsettings.xml");
   for (unsigned int i = 0; i < m_settingsFiles.size(); i++)
     ParseSettingsFile(m_settingsFiles[i]);
-  ParseSettingsFile(g_settings.GetUserDataItem("advancedsettings.xml"));
+  ParseSettingsFile(CProfilesManager::Get().GetUserDataItem("advancedsettings.xml"));
   return true;
 }
 
index a98fbea..33a1908 100644 (file)
@@ -33,6 +33,7 @@
 #include "guilib/LocalizeStrings.h"
 #include "utils/CharsetConverter.h"
 #include "settings/DisplaySettings.h"
+#include "settings/VideoSettings.h"
 #include "utils/StringUtils.h"
 #include "utils/SystemInfo.h"
 #include "utils/log.h"
index 60c679f..df1dcd2 100644 (file)
@@ -22,6 +22,7 @@
 #include "URL.h"
 #include "Util.h"
 #include "filesystem/File.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/Settings.h"
 #include "utils/log.h"
 #include "utils/StringUtils.h"
@@ -53,10 +54,10 @@ CMediaSourceSettings& CMediaSourceSettings::Get()
 std::string CMediaSourceSettings::GetSourcesFile()
 {
   std::string file;
-  if (g_settings.GetCurrentProfile().hasSources())
-    file = g_settings.GetProfileUserDataFolder();
+  if (CProfilesManager::Get().GetCurrentProfile().hasSources())
+    file = CProfilesManager::Get().GetProfileUserDataFolder();
   else
-    file = g_settings.GetUserDataFolder();
+    file = CProfilesManager::Get().GetUserDataFolder();
 
   return URIUtils::AddFileToFolder(file, SOURCES_FILE);
 }
index efbc15b..00419c4 100644 (file)
  *
  */
 
-#include "system.h"
+#include <limits.h>
+
 #include "Settings.h"
-#include "AdvancedSettings.h"
-#include "Application.h"
-#include "input/KeyboardLayoutConfiguration.h"
-#include "Util.h"
-#include "URL.h"
-#include "guilib/GUIFontManager.h"
-#include "input/ButtonTranslator.h"
-#include "utils/CharsetConverter.h"
-#include "utils/XMLUtils.h"
-#include "PasswordManager.h"
-#include "utils/RegExp.h"
-#include "GUIPassword.h"
-#include "GUIInfoManager.h"
-#include "filesystem/MultiPathDirectory.h"
-#include "filesystem/SpecialProtocol.h"
-#include "guilib/GUIWindowManager.h"
-#include "dialogs/GUIDialogYesNo.h"
-#include "filesystem/Directory.h"
-#include "FileItem.h"
-#include "LangInfo.h"
-#include "guilib/LocalizeStrings.h"
-#include "utils/StringUtils.h"
-#include "utils/SystemInfo.h"
-#ifdef _WIN32
-#include "win32/WIN32Util.h"
-#endif
-#if defined(_LINUX) && defined(HAS_FILESYSTEM_SMB)
-#include "filesystem/SMBDirectory.h"
-#endif
-#include "utils/FileUtils.h"
-#include "utils/URIUtils.h"
-#include "input/MouseStat.h"
 #include "filesystem/File.h"
-#include "filesystem/DirectoryCache.h"
-#include "DatabaseManager.h"
+#include "guilib/WindowIDs.h"
+#include "profiles/ProfilesManager.h"
+#include "settings/GUISettings.h"
 #include "threads/SingleLock.h"
-#include "utils/RssManager.h"
+#include "utils/log.h"
+#include "utils/SystemInfo.h"
+#include "utils/XMLUtils.h"
 
 using namespace std;
 using namespace XFILE;
@@ -150,11 +122,6 @@ void CSettings::Initialize()
 
   m_userAgent = g_sysinfo.GetUserAgent();
 
-  m_usingLoginScreen = false;
-  m_lastUsedProfile = 0;
-  m_currentProfile = 0;
-  m_nextIdProfile = 0;
-
   m_musicNeedsUpdate = 0;
   m_videoNeedsUpdate = 0;
 }
@@ -172,16 +139,16 @@ CSettings::~CSettings(void)
 
 void CSettings::Save() const
 {
-  if (!SaveSettings(GetSettingsFile()))
-    CLog::Log(LOGERROR, "Unable to save settings to %s", GetSettingsFile().c_str());
+  if (!SaveSettings(CProfilesManager::Get().GetSettingsFile()))
+    CLog::Log(LOGERROR, "Unable to save settings to %s", CProfilesManager::Get().GetSettingsFile().c_str());
 }
 
 bool CSettings::Reset()
 {
   CLog::Log(LOGINFO, "Resetting settings");
-  CFile::Delete(GetSettingsFile());
+  CFile::Delete(CProfilesManager::Get().GetSettingsFile());
   Save();
-  return LoadSettings(GetSettingsFile());
+  return LoadSettings(CProfilesManager::Get().GetSettingsFile());
 }
 
 bool CSettings::Load()
@@ -189,17 +156,14 @@ bool CSettings::Load()
   if (!OnSettingsLoading())
     return false;
 
-  CSpecialProtocol::SetProfilePath(GetProfileUserDataFolder());
-  CLog::Log(LOGNOTICE, "loading %s", GetSettingsFile().c_str());
-  if (!LoadSettings(GetSettingsFile()))
+  CLog::Log(LOGNOTICE, "loading %s", CProfilesManager::Get().GetSettingsFile().c_str());
+  if (!LoadSettings(CProfilesManager::Get().GetSettingsFile()))
   {
-    CLog::Log(LOGERROR, "Unable to load %s, creating new %s with default values", GetSettingsFile().c_str(), GetSettingsFile().c_str());
+    CLog::Log(LOGERROR, "Unable to load %s, creating new %s with default values", CProfilesManager::Get().GetSettingsFile().c_str(), CProfilesManager::Get().GetSettingsFile().c_str());
     if (!Reset())
       return false;
   }
 
-  LoadUserFolderLayout();
-
   OnSettingsLoaded();
 
   return true;
@@ -404,9 +368,6 @@ bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *lo
   else // save the global settings
     g_guiSettings.SaveXML(pRoot);
 
-  // For mastercode
-  SaveProfiles( PROFILES_FILE );
-
   OnSettingsSaved();
   
   if (!Save(pRoot))
@@ -416,190 +377,8 @@ bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *lo
   return xmlDoc.SaveFile(strSettingsFile);
 }
 
-bool CSettings::LoadProfile(unsigned int index)
-{
-  unsigned int oldProfile = m_currentProfile;
-  m_currentProfile = index;
-  CStdString strOldSkin = g_guiSettings.GetString("lookandfeel.skin");
-  CStdString strOldFont = g_guiSettings.GetString("lookandfeel.font");
-  CStdString strOldTheme = g_guiSettings.GetString("lookandfeel.skintheme");
-  CStdString strOldColors = g_guiSettings.GetString("lookandfeel.skincolors");
-  if (Load())
-  {
-    CreateProfileFolders();
-
-    // initialize our charset converter
-    g_charsetConverter.reset();
-
-    // Load the langinfo to have user charset <-> utf-8 conversion
-    CStdString strLanguage = g_guiSettings.GetString("locale.language");
-    strLanguage[0] = toupper(strLanguage[0]);
-
-    CStdString strLangInfoPath;
-    strLangInfoPath.Format("special://xbmc/language/%s/langinfo.xml", strLanguage.c_str());
-    CLog::Log(LOGINFO, "load language info file:%s", strLangInfoPath.c_str());
-    g_langInfo.Load(strLangInfoPath);
-
-    CButtonTranslator::GetInstance().Load(true);
-    g_localizeStrings.Load("special://xbmc/language/", strLanguage);
-
-    CDatabaseManager::Get().Initialize();
-
-    g_Mouse.SetEnabled(g_guiSettings.GetBool("input.enablemouse"));
-
-    g_infoManager.ResetCache();
-    g_infoManager.ResetLibraryBools();
-
-    // always reload the skin - we need it for the new language strings
-    g_application.ReloadSkin();
-
-    if (m_currentProfile != 0)
-    {
-      CXBMCTinyXML doc;
-      if (doc.LoadFile(URIUtils::AddFileToFolder(GetUserDataFolder(),"guisettings.xml")))
-        g_guiSettings.LoadMasterLock(doc.RootElement());
-    }
-
-    CPasswordManager::GetInstance().Clear();
-
-    // to set labels - shares are reloaded
-#if !defined(_WIN32) && defined(HAS_DVD_DRIVE)
-    MEDIA_DETECT::CDetectDVDMedia::UpdateState();
-#endif
-    // init windows
-    CGUIMessage msg(GUI_MSG_NOTIFY_ALL,0,0,GUI_MSG_WINDOW_RESET);
-    g_windowManager.SendMessage(msg);
-
-    CUtil::DeleteDirectoryCache();
-    g_directoryCache.Clear();
-
-    return true;
-  }
-
-  m_currentProfile = oldProfile;
-
-  return false;
-}
-
-bool CSettings::DeleteProfile(unsigned int index)
-{
-  const CProfile *profile = GetProfile(index);
-  if (!profile)
-    return false;
-
-  CGUIDialogYesNo* dlgYesNo = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
-  if (dlgYesNo)
-  {
-    CStdString message;
-    CStdString str = g_localizeStrings.Get(13201);
-    message.Format(str.c_str(), profile->getName());
-    dlgYesNo->SetHeading(13200);
-    dlgYesNo->SetLine(0, message);
-    dlgYesNo->SetLine(1, "");
-    dlgYesNo->SetLine(2, "");
-    dlgYesNo->DoModal();
-
-    if (dlgYesNo->IsConfirmed())
-    {
-      //delete profile
-      CStdString strDirectory = profile->getDirectory();
-      m_vecProfiles.erase(m_vecProfiles.begin()+index);
-      if (index == m_currentProfile)
-      {
-        LoadProfile(0);
-        Save();
-      }
-
-      CFileItemPtr item = CFileItemPtr(new CFileItem(URIUtils::AddFileToFolder(GetUserDataFolder(), strDirectory)));
-      item->SetPath(URIUtils::AddFileToFolder(GetUserDataFolder(), strDirectory + "/"));
-      item->m_bIsFolder = true;
-      item->Select(true);
-      CFileUtils::DeleteItem(item);
-    }
-    else
-      return false;
-  }
-
-  SaveProfiles( PROFILES_FILE );
-
-  return true;
-}
-
-void CSettings::LoadProfiles(const CStdString& profilesFile)
-{
-  // clear out our profiles
-  m_vecProfiles.clear();
-
-  CXBMCTinyXML profilesDoc;
-  if (CFile::Exists(profilesFile))
-  {
-    if (profilesDoc.LoadFile(profilesFile))
-    {
-      TiXmlElement *rootElement = profilesDoc.RootElement();
-      if (rootElement && strcmpi(rootElement->Value(),"profiles") == 0)
-      {
-        XMLUtils::GetUInt(rootElement, "lastloaded", m_lastUsedProfile);
-        XMLUtils::GetBoolean(rootElement, "useloginscreen", m_usingLoginScreen);
-        XMLUtils::GetInt(rootElement, "nextIdProfile", m_nextIdProfile);
-
-        TiXmlElement* pProfile = rootElement->FirstChildElement("profile");
-        
-        CStdString defaultDir("special://home/userdata");
-        if (!CDirectory::Exists(defaultDir))
-          defaultDir = "special://xbmc/userdata";
-        while (pProfile)
-        {
-          CProfile profile(defaultDir);
-          profile.Load(pProfile,GetNextProfileId());
-          AddProfile(profile);
-          pProfile = pProfile->NextSiblingElement("profile");
-        }
-      }
-      else
-        CLog::Log(LOGERROR, "Error loading %s, no <profiles> node", profilesFile.c_str());
-    }
-    else
-      CLog::Log(LOGERROR, "Error loading %s, Line %d\n%s", profilesFile.c_str(), profilesDoc.ErrorRow(), profilesDoc.ErrorDesc());
-  }
-
-  if (m_vecProfiles.empty())
-  { // add the master user
-    CProfile profile("special://masterprofile/", "Master user",0);
-    AddProfile(profile);
-  }
-
-  // check the validity of the previous profile index
-  if (m_lastUsedProfile >= m_vecProfiles.size())
-    m_lastUsedProfile = 0;
-
-  m_currentProfile = m_lastUsedProfile;
-
-  // the login screen runs as the master profile, so if we're using this, we need to ensure
-  // we switch to the master profile
-  if (m_usingLoginScreen)
-    m_currentProfile = 0;
-}
-
-bool CSettings::SaveProfiles(const CStdString& profilesFile) const
-{
-  CXBMCTinyXML xmlDoc;
-  TiXmlElement xmlRootElement("profiles");
-  TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement);
-  if (!pRoot) return false;
-  XMLUtils::SetInt(pRoot,"lastloaded", m_currentProfile);
-  XMLUtils::SetBoolean(pRoot,"useloginscreen",m_usingLoginScreen);
-  XMLUtils::SetInt(pRoot,"nextIdProfile",m_nextIdProfile);      
-  for (unsigned int i = 0; i < m_vecProfiles.size(); ++i)
-    m_vecProfiles[i].Save(pRoot);
-
-  // save the file
-  return xmlDoc.SaveFile(profilesFile);
-}
-
 void CSettings::Clear()
 {
-  m_vecProfiles.clear();
-
   m_pictureExtensions.clear();
   m_musicExtensions.clear();
   m_videoExtensions.clear();
@@ -624,218 +403,6 @@ static CStdString ToWatchContent(const CStdString &content)
     return content;
 }
 
-void CSettings::LoadUserFolderLayout()
-{
-  // check them all
-  CStdString strDir = g_guiSettings.GetString("system.playlistspath");
-  if (strDir == "set default")
-  {
-    strDir = "special://profile/playlists/";
-    g_guiSettings.SetString("system.playlistspath",strDir.c_str());
-  }
-  CDirectory::Create(strDir);
-  CDirectory::Create(URIUtils::AddFileToFolder(strDir,"music"));
-  CDirectory::Create(URIUtils::AddFileToFolder(strDir,"video"));
-  CDirectory::Create(URIUtils::AddFileToFolder(strDir,"mixed"));
-}
-
-CStdString CSettings::GetProfileUserDataFolder() const
-{
-  CStdString folder;
-  if (m_currentProfile == 0)
-    return GetUserDataFolder();
-
-  URIUtils::AddFileToFolder(GetUserDataFolder(),GetCurrentProfile().getDirectory(),folder);
-
-  return folder;
-}
-
-CStdString CSettings::GetUserDataItem(const CStdString& strFile) const
-{
-  CStdString folder;
-  folder = "special://profile/"+strFile;
-  //check if item exists in the profile
-  //(either for folder or for a file (depending on slashAtEnd of strFile)
-  //otherwise return path to masterprofile
-  if ( (URIUtils::HasSlashAtEnd(folder) && !CDirectory::Exists(folder)) || !CFile::Exists(folder))
-    folder = "special://masterprofile/"+strFile;
-  return folder;
-}
-
-CStdString CSettings::GetUserDataFolder() const
-{
-  return GetMasterProfile().getDirectory();
-}
-
-CStdString CSettings::GetDatabaseFolder() const
-{
-  CStdString folder;
-  if (GetCurrentProfile().hasDatabases())
-    URIUtils::AddFileToFolder(GetProfileUserDataFolder(), "Database", folder);
-  else
-    URIUtils::AddFileToFolder(GetUserDataFolder(), "Database", folder);
-
-  return folder;
-}
-
-CStdString CSettings::GetCDDBFolder() const
-{
-  CStdString folder;
-  if (GetCurrentProfile().hasDatabases())
-    URIUtils::AddFileToFolder(GetProfileUserDataFolder(), "Database/CDDB", folder);
-  else
-    URIUtils::AddFileToFolder(GetUserDataFolder(), "Database/CDDB", folder);
-
-  return folder;
-}
-
-CStdString CSettings::GetThumbnailsFolder() const
-{
-  CStdString folder;
-  if (GetCurrentProfile().hasDatabases())
-    URIUtils::AddFileToFolder(GetProfileUserDataFolder(), "Thumbnails", folder);
-  else
-    URIUtils::AddFileToFolder(GetUserDataFolder(), "Thumbnails", folder);
-
-  return folder;
-}
-
-CStdString CSettings::GetVideoThumbFolder() const
-{
-  CStdString folder;
-  if (GetCurrentProfile().hasDatabases())
-    URIUtils::AddFileToFolder(GetProfileUserDataFolder(), "Thumbnails/Video", folder);
-  else
-    URIUtils::AddFileToFolder(GetUserDataFolder(), "Thumbnails/Video", folder);
-
-  return folder;
-}
-
-CStdString CSettings::GetBookmarksThumbFolder() const
-{
-  CStdString folder;
-  if (GetCurrentProfile().hasDatabases())
-    URIUtils::AddFileToFolder(GetProfileUserDataFolder(), "Thumbnails/Video/Bookmarks", folder);
-  else
-    URIUtils::AddFileToFolder(GetUserDataFolder(), "Thumbnails/Video/Bookmarks", folder);
-
-  return folder;
-}
-
-CStdString CSettings::GetLibraryFolder() const
-{
-  CStdString folder;
-  if (GetCurrentProfile().hasDatabases())
-    URIUtils::AddFileToFolder(GetProfileUserDataFolder(), "library", folder);
-  else
-    URIUtils::AddFileToFolder(GetUserDataFolder(), "library", folder);
-
-  return folder;
-}
-
-CStdString CSettings::GetSettingsFile() const
-{
-  CStdString settings;
-  if (m_currentProfile == 0)
-    settings = "special://masterprofile/guisettings.xml";
-  else
-    settings = "special://profile/guisettings.xml";
-  return settings;
-}
-
-void CSettings::CreateProfileFolders()
-{
-  CDirectory::Create(GetDatabaseFolder());
-  CDirectory::Create(GetCDDBFolder());
-
-  // Thumbnails/
-  CDirectory::Create(GetThumbnailsFolder());
-  CDirectory::Create(GetVideoThumbFolder());
-  CDirectory::Create(GetBookmarksThumbFolder());
-  CLog::Log(LOGINFO, "thumbnails folder: %s", GetThumbnailsFolder().c_str());
-  for (unsigned int hex=0; hex < 16; hex++)
-  {
-    CStdString strHex;
-    strHex.Format("%x",hex);
-    CDirectory::Create(URIUtils::AddFileToFolder(GetThumbnailsFolder(), strHex));
-  }
-  CDirectory::Create("special://profile/addon_data");
-  CDirectory::Create("special://profile/keymaps");
-  CDirectory::Create(GetLibraryFolder());
-}
-
-static CProfile emptyProfile;
-
-const CProfile &CSettings::GetMasterProfile() const
-{
-  if (GetNumProfiles())
-    return m_vecProfiles[0];
-  CLog::Log(LOGERROR, "%s - master profile requested while none exists", __FUNCTION__);
-  return emptyProfile;
-}
-
-const CProfile &CSettings::GetCurrentProfile() const
-{
-  if (m_currentProfile < m_vecProfiles.size())
-    return m_vecProfiles[m_currentProfile];
-  CLog::Log(LOGERROR, "%s - last profile index (%u) is outside the valid range (%" PRIdS ")", __FUNCTION__, m_currentProfile, m_vecProfiles.size());
-  return emptyProfile;
-}
-
- int CSettings::GetCurrentProfileId() const
- {
-   return GetCurrentProfile().getId();
- }
-
-void CSettings::UpdateCurrentProfileDate()
-{
-  if (m_currentProfile < m_vecProfiles.size())
-    m_vecProfiles[m_currentProfile].setDate();
-}
-
-const CProfile *CSettings::GetProfile(unsigned int index) const
-{
-  if (index < GetNumProfiles())
-    return &m_vecProfiles[index];
-  return NULL;
-}
-
-CProfile *CSettings::GetProfile(unsigned int index)
-{
-  if (index < GetNumProfiles())
-    return &m_vecProfiles[index];
-  return NULL;
-}
-
-unsigned int CSettings::GetNumProfiles() const
-{
-  return m_vecProfiles.size();
-}
-
-int CSettings::GetProfileIndex(const CStdString &name) const
-{
-  for (unsigned int i = 0; i < m_vecProfiles.size(); i++)
-    if (m_vecProfiles[i].getName().Equals(name))
-      return i;
-  return -1;
-}
-
-void CSettings::AddProfile(const CProfile &profile)
-{
-  //data integrity check - covers off migration from old profiles.xml, incrementing of the m_nextIdProfile,and bad data coming in
-  m_nextIdProfile = max(m_nextIdProfile, profile.getId() + 1); 
-
-  m_vecProfiles.push_back(profile);
-}
-
-void CSettings::LoadMasterForLogin()
-{
-  // save the previous user
-  m_lastUsedProfile = m_currentProfile;
-  if (m_currentProfile != 0)
-    LoadProfile(0);
-}
-
 bool CSettings::OnSettingsLoading()
 {
   CSingleLock lock(m_critical);
index 6fafd87..c5e8d92 100644 (file)
  *
  */
 
+#include <vector>
+#include <map>
+#include <set>
+
 #define PRE_SKIN_VERSION_9_10_COMPATIBILITY 1
 #define PRE_SKIN_VERSION_11_COMPATIBILITY 1
 
 
 #include "settings/ISettingsHandler.h"
 #include "settings/ISubSettings.h"
-#include "settings/VideoSettings.h"
-#include "profiles/Profile.h"
-#include "guilib/Resolution.h"
 #include "guilib/GraphicContext.h"
 #include "threads/CriticalSection.h"
 
-#include <vector>
-#include <map>
-#include <set>
-
 #define CACHE_AUDIO 0
 #define CACHE_VIDEO 1
 #define CACHE_VOB   2
 #define VOLUME_DYNAMIC_RANGE 90.0f // 60dB
 #define VOLUME_CONTROL_STEPS 90    // 90 steps
 
-/* FIXME: eventually the profile should dictate where special://masterprofile/ is but for now it
-   makes sense to leave all the profile settings in a user writeable location
-   like special://masterprofile/ */
-#define PROFILES_FILE "special://masterprofile/profiles.xml"
-
 class CGUISettings;
 class TiXmlElement;
 class TiXmlNode;
@@ -92,10 +84,6 @@ public:
 
   void Clear();
 
-  bool LoadProfile(unsigned int index);
-  bool DeleteProfile(unsigned int index);
-  void CreateProfileFolders();
-
   CStdString m_pictureExtensions;
   CStdString m_musicExtensions;
   CStdString m_videoExtensions;
@@ -139,115 +127,6 @@ public:
   int        m_musicNeedsUpdate; ///< if a database update means an update is required (set to the version number of the db)
   int        m_videoNeedsUpdate; ///< if a database update means an update is required (set to the version number of the db)
 
-  /*! \brief Retrieve the master profile
-   \return const reference to the master profile
-   */
-  const CProfile &GetMasterProfile() const;
-
-  /*! \brief Retreive the current profile
-   \return const reference to the current profile
-   */
-  const CProfile &GetCurrentProfile() const;
-
-  /*! \brief Retreive the profile from an index
-   \param unsigned index of the profile to retrieve
-   \return const pointer to the profile, NULL if the index is invalid
-   */
-  const CProfile *GetProfile(unsigned int index) const;
-
-  /*! \brief Retreive the profile from an index
-   \param unsigned index of the profile to retrieve
-   \return pointer to the profile, NULL if the index is invalid
-   */
-  CProfile *GetProfile(unsigned int index);
-
-  /*! \brief Retreive index of a particular profile by name
-   \param name name of the profile index to retrieve
-   \return index of this profile, -1 if invalid.
-   */
-  int GetProfileIndex(const CStdString &name) const;
-
-  /*! \brief Retrieve the number of profiles
-   \return number of profiles
-   */
-  unsigned int GetNumProfiles() const;
-
-  /*! \brief Add a new profile
-   \param profile CProfile to add
-   */
-  void AddProfile(const CProfile &profile);
-
-  /*! \brief Are we using the login screen?
-   \return true if we're using the login screen, false otherwise
-   */
-  bool UsingLoginScreen() const { return m_usingLoginScreen; };
-
-  /*! \brief Toggle login screen use on and off
-   Toggles the login screen state
-   */
-  void ToggleLoginScreen() { m_usingLoginScreen = !m_usingLoginScreen; };
-
-  /*! \brief Are we the master user?
-   \return true if the current profile is the master user, false otherwise
-   */
-  bool IsMasterUser() const { return 0 == m_currentProfile; };
-
-  /*! \brief Update the date of the current profile
-   */
-  void UpdateCurrentProfileDate();
-
-  /*! \brief Load the master user for the purposes of logging in
-   Loads the master user.  Identical to LoadProfile(0) but doesn't update the last logged in details
-   */
-  void LoadMasterForLogin();
-
-  /*! \brief Retreive the last used profile index
-   \return the last used profile that logged in.  Does not count the master user during login.
-   */
-  unsigned int GetLastUsedProfileIndex() const { return m_lastUsedProfile; };
-
-  /*! \brief Retrieve the current profile index
-   \return the index of the currently logged in profile.
-   */
-  unsigned int GetCurrentProfileIndex() const { return m_currentProfile; };
-
-  /*! \brief Retrieve the next id to use for a new profile
-   \return the unique <id> to be used when creating a new profile
-   */
-  int GetNextProfileId() const { return m_nextIdProfile; }; // used to get the value of m_nextIdProfile for use in new profile creation
-
-  int GetCurrentProfileId() const;
-
-  // utility functions for user data folders
-
-  //uses HasSlashAtEnd to determine if a directory or file was meant
-  CStdString GetUserDataItem(const CStdString& strFile) const;
-  CStdString GetProfileUserDataFolder() const;
-  CStdString GetUserDataFolder() const;
-  CStdString GetDatabaseFolder() const;
-  CStdString GetCDDBFolder() const;
-  CStdString GetThumbnailsFolder() const;
-  CStdString GetVideoThumbFolder() const;
-  CStdString GetBookmarksThumbFolder() const;
-  CStdString GetLibraryFolder() const;
-
-  CStdString GetSettingsFile() const;
-
-  /*! \brief Load the user profile information from disk
-   Loads the profiles.xml file and creates the list of profiles. If no profiles
-   exist, a master user is created.  Should be called after special://masterprofile/
-   has been defined.
-   \param profilesFile XML file to load.
-   */
-  void LoadProfiles(const CStdString& profilesFile);
-
-  /*! \brief Save the user profile information to disk
-   Saves the list of profiles to the profiles.xml file.
-   \param profilesFile XML file to save.
-   \return true on success, false on failure to save
-   */
-  bool SaveProfiles(const CStdString& profilesFile) const;
-
   bool SaveSettings(const CStdString& strSettingsFile, CGUISettings *localSettings = NULL) const;
 
   bool GetInteger(const TiXmlElement* pRootElement, const char *strTagName, int& iValue, const int iDefault, const int iMin, const int iMax);
@@ -260,8 +139,6 @@ protected:
   bool LoadSettings(const CStdString& strSettingsFile);
 //  bool SaveSettings(const CStdString& strSettingsFile) const;
 
-  void LoadUserFolderLayout();
-
 private:
   // implementation of ISettingsHandler
   virtual bool OnSettingsLoading();
@@ -279,12 +156,6 @@ private:
   SettingsHandlers m_settingsHandlers;
   typedef std::set<ISubSettings*> SubSettings;
   SubSettings m_subSettings;
-
-  std::vector<CProfile> m_vecProfiles;
-  bool m_usingLoginScreen;
-  unsigned int m_lastUsedProfile;
-  unsigned int m_currentProfile;
-  int m_nextIdProfile; // for tracking the next available id to give to a new profile to ensure id's are not re-used
 };
 
 extern class CSettings g_settings;
index f84911b..6f57416 100644 (file)
@@ -33,6 +33,7 @@
 #include "guilib/GUIImage.h"
 #include "utils/Weather.h"
 #include "music/MusicDatabase.h"
+#include "profiles/ProfilesManager.h"
 #include "video/VideoDatabase.h"
 #include "view/ViewDatabase.h"
 #include "view/ViewState.h"
@@ -334,7 +335,7 @@ void CGUIWindowSettingsCategory::SetupControls()
   int j=0;
   for (unsigned int i = 0; i < m_vecSections.size(); i++)
   {
-    if (m_vecSections[i]->m_labelID == 12360 && !g_settings.IsMasterUser())
+    if (m_vecSections[i]->m_labelID == 12360 && !CProfilesManager::Get().IsMasterProfile())
       continue;
     CGUIButtonControl *pButton = NULL;
     if (m_pOriginalCategoryButton->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON)
@@ -703,17 +704,17 @@ void CGUIWindowSettingsCategory::UpdateSettings()
     else if (strSetting.Equals("filelists.allowfiledeletion"))
     {
       CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
-      if (pControl) pControl->SetEnabled(!g_settings.GetCurrentProfile().filesLocked() || g_passwordManager.bMasterUser);
+      if (pControl) pControl->SetEnabled(!CProfilesManager::Get().GetCurrentProfile().filesLocked() || g_passwordManager.bMasterUser);
     }
     else if (strSetting.Equals("filelists.showaddsourcebuttons"))
     {
       CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
-      if (pControl) pControl->SetEnabled(g_settings.GetCurrentProfile().canWriteSources() || g_passwordManager.bMasterUser);
+      if (pControl) pControl->SetEnabled(CProfilesManager::Get().GetCurrentProfile().canWriteSources() || g_passwordManager.bMasterUser);
     }
     else if (strSetting.Equals("masterlock.startuplock"))
     {
       CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
-      if (pControl) pControl->SetEnabled(g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE);
+      if (pControl) pControl->SetEnabled(CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE);
     }
     else if (strSetting.Equals("pvrmanager.channelscan"))
     {
@@ -1144,7 +1145,7 @@ void CGUIWindowSettingsCategory::OnSettingChanged(BaseSettingControlPtr pSetting
     int retVal = CGUIDialogContextMenu::ShowAndGetChoice(choices);
     if ( retVal > 0 )
     {
-      CStdString path(g_settings.GetDatabaseFolder());
+      CStdString path(CProfilesManager::Get().GetDatabaseFolder());
       VECSOURCES shares;
       g_mediaManager.GetLocalDrives(shares);
       if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(661), path, true))
@@ -1194,7 +1195,7 @@ void CGUIWindowSettingsCategory::OnSettingChanged(BaseSettingControlPtr pSetting
   }
   else if (strSetting.Equals("karaoke.importcsv"))
   {
-    CStdString path(g_settings.GetDatabaseFolder());
+    CStdString path(CProfilesManager::Get().GetDatabaseFolder());
     VECSOURCES shares;
     g_mediaManager.GetLocalDrives(shares);
     if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "karaoke.csv", g_localizeStrings.Get(651) , path))
index fcc8d0a..85e21b8 100644 (file)
@@ -30,6 +30,7 @@
 #include "TextureCache.h"
 #include "TextureCacheJob.h"
 #include "pictures/Picture.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/GUISettings.h"
 #include "settings/Settings.h"
 #include "settings/AdvancedSettings.h"
@@ -330,7 +331,7 @@ bool CEdenVideoArtUpdater::CacheTexture(std::string &originalUrl, const std::str
 
 CStdString CEdenVideoArtUpdater::GetCachedActorThumb(const CFileItem &item)
 {
-  return GetThumb("actor" + item.GetLabel(), g_settings.GetVideoThumbFolder(), true);
+  return GetThumb("actor" + item.GetLabel(), CProfilesManager::Get().GetVideoThumbFolder(), true);
 }
 
 CStdString CEdenVideoArtUpdater::GetCachedSeasonThumb(int season, const CStdString &path)
@@ -342,7 +343,7 @@ CStdString CEdenVideoArtUpdater::GetCachedSeasonThumb(int season, const CStdStri
     label = g_localizeStrings.Get(20381);
   else
     label.Format(g_localizeStrings.Get(20358), season);
-  return GetThumb("season" + path + label, g_settings.GetVideoThumbFolder(), true);
+  return GetThumb("season" + path + label, CProfilesManager::Get().GetVideoThumbFolder(), true);
 }
 
 CStdString CEdenVideoArtUpdater::GetCachedEpisodeThumb(const CFileItem &item)
@@ -350,31 +351,31 @@ CStdString CEdenVideoArtUpdater::GetCachedEpisodeThumb(const CFileItem &item)
   // get the locally cached thumb
   CStdString strCRC;
   strCRC.Format("%sepisode%i", item.GetVideoInfoTag()->m_strFileNameAndPath.c_str(), item.GetVideoInfoTag()->m_iEpisode);
-  return GetThumb(strCRC, g_settings.GetVideoThumbFolder(), true);
+  return GetThumb(strCRC, CProfilesManager::Get().GetVideoThumbFolder(), true);
 }
 
 CStdString CEdenVideoArtUpdater::GetCachedVideoThumb(const CFileItem &item)
 {
   if (item.m_bIsFolder && !item.GetVideoInfoTag()->m_strPath.IsEmpty())
-    return GetThumb(item.GetVideoInfoTag()->m_strPath, g_settings.GetVideoThumbFolder(), true);
+    return GetThumb(item.GetVideoInfoTag()->m_strPath, CProfilesManager::Get().GetVideoThumbFolder(), true);
   else if (!item.GetVideoInfoTag()->m_strFileNameAndPath.IsEmpty())
   {
     CStdString path = item.GetVideoInfoTag()->m_strFileNameAndPath;
     if (URIUtils::IsStack(path))
       path = CStackDirectory::GetFirstStackedFile(path);
-    return GetThumb(path, g_settings.GetVideoThumbFolder(), true);
+    return GetThumb(path, CProfilesManager::Get().GetVideoThumbFolder(), true);
   }
-  return GetThumb(item.GetPath(), g_settings.GetVideoThumbFolder(), true);
+  return GetThumb(item.GetPath(), CProfilesManager::Get().GetVideoThumbFolder(), true);
 }
 
 CStdString CEdenVideoArtUpdater::GetCachedFanart(const CFileItem &item)
 {
   if (!item.GetVideoInfoTag()->m_artist.empty())
-    return GetThumb(StringUtils::Join(item.GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator), URIUtils::AddFileToFolder(g_settings.GetThumbnailsFolder(), "Music/Fanart/"), false);
+    return GetThumb(StringUtils::Join(item.GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator), URIUtils::AddFileToFolder(CProfilesManager::Get().GetThumbnailsFolder(), "Music/Fanart/"), false);
   CStdString path = item.GetVideoInfoTag()->GetPath();
   if (path.empty())
     return "";
-  return GetThumb(path, URIUtils::AddFileToFolder(g_settings.GetVideoThumbFolder(), "Fanart/"), false);
+  return GetThumb(path, URIUtils::AddFileToFolder(CProfilesManager::Get().GetVideoThumbFolder(), "Fanart/"), false);
 }
 
 CStdString CEdenVideoArtUpdater::GetThumb(const CStdString &path, const CStdString &path2, bool split)
index 7e5b57f..c9b2e93 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "RssManager.h"
 #include "filesystem/File.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/Settings.h"
 #include "threads/SingleLock.h"
 #include "utils/log.h"
@@ -75,7 +76,7 @@ void CRssManager::Stop()
 bool CRssManager::Load()
 {
   CSingleLock lock(m_critical);
-  string rssXML = g_settings.GetUserDataItem("RssFeeds.xml");
+  string rssXML = CProfilesManager::Get().GetUserDataItem("RssFeeds.xml");
   if (!CFile::Exists(rssXML))
     return false;
 
index 43957e6..31b3f66 100644 (file)
@@ -39,6 +39,7 @@
 #include "dialogs/GUIDialogProgress.h"
 #include "dialogs/GUIDialogYesNo.h"
 #include "FileItem.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/AdvancedSettings.h"
 #include "settings/GUISettings.h"
 #include "settings/MediaSettings.h"
@@ -4715,7 +4716,7 @@ bool CVideoDatabase::GetNavCommon(const CStdString& strBaseDir, CFileItemList& i
 
     CStdString strSQL;
     Filter extFilter = filter;
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
     {
       if (idContent == VIDEODB_CONTENT_MOVIES)
       {
@@ -4796,7 +4797,7 @@ bool CVideoDatabase::GetNavCommon(const CStdString& strBaseDir, CFileItemList& i
       return true;
     }
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
     {
       map<int, pair<CStdString,int> > mapItems;
       map<int, pair<CStdString,int> >::iterator it;
@@ -5020,7 +5021,7 @@ bool CVideoDatabase::GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileI
 
     CStdString strSQL = "select %s from musicvideoview ";
     Filter extFilter = filter;
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
     {
       extFilter.fields = PrepareSQL("musicvideoview.c%02d, musicvideoview.idMVideo, actors.strActor, path.strPath", VIDEODB_ID_MUSICVIDEO_ALBUM);
       extFilter.AppendJoin("join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo = musicvideoview.idMVideo join actors on actors.idActor = artistlinkmusicvideo.idArtist join files on files.idFile = musicvideoview.idFile join path on path.idPath = files.idPath");
@@ -5061,7 +5062,7 @@ bool CVideoDatabase::GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileI
       return true;
     }
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
     {
       map<int, pair<CStdString,CStdString> > mapAlbums;
       map<int, pair<CStdString,CStdString> >::iterator it;
@@ -5184,7 +5185,7 @@ bool CVideoDatabase::GetPeopleNav(const CStdString& strBaseDir, CFileItemList& i
     // get primary genres for movies
     CStdString strSQL;
     Filter extFilter = filter;
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
     {
       if (idContent == VIDEODB_CONTENT_MOVIES)
       {
@@ -5288,7 +5289,7 @@ bool CVideoDatabase::GetPeopleNav(const CStdString& strBaseDir, CFileItemList& i
       return true;
     }
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
     {
       map<int, CActor> mapActors;
       map<int, CActor>::iterator it;
@@ -5389,7 +5390,7 @@ bool CVideoDatabase::GetYearsNav(const CStdString& strBaseDir, CFileItemList& it
 
     CStdString strSQL;
     Filter extFilter = filter;
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
     {
       if (idContent == VIDEODB_CONTENT_MOVIES)
       {
@@ -5438,7 +5439,7 @@ bool CVideoDatabase::GetYearsNav(const CStdString& strBaseDir, CFileItemList& it
     if (iRowsFound <= 0)
       return iRowsFound == 0;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
     {
       map<int, pair<CStdString,int> > mapYears;
       map<int, pair<CStdString,int> >::iterator it;
@@ -5635,7 +5636,7 @@ bool CVideoDatabase::GetSeasonsNav(const CStdString& strBaseDir, CFileItemList&
     CStdString showStudio = m_pDS->fv(6).get_asString();
     CStdString showMPAARating = m_pDS->fv(7).get_asString();
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
     {
       map<int, CSeason> mapSeasons;
       map<int, CSeason>::iterator it;
@@ -5906,7 +5907,7 @@ bool CVideoDatabase::GetMoviesByWhere(const CStdString& strBaseDir, const Filter
       const dbiplus::sql_record* const record = data.at(targetRow);
 
       CVideoInfoTag movie = GetDetailsForMovie(record);
-      if (g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE ||
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE ||
           g_passwordManager.bMasterUser                                   ||
           g_passwordManager.IsDatabasePathUnlocked(movie.m_strPath, *CMediaSourceSettings::Get().GetSources("video")))
       {
@@ -6011,7 +6012,7 @@ bool CVideoDatabase::GetTvShowsByWhere(const CStdString& strBaseDir, const Filte
       const dbiplus::sql_record* const record = data.at(targetRow);
       
       CVideoInfoTag movie = GetDetailsForTvShow(record, false);
-      if ((g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE ||
+      if ((CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE ||
            g_passwordManager.bMasterUser                                     ||
            g_passwordManager.IsDatabasePathUnlocked(movie.m_strPath, *CMediaSourceSettings::Get().GetSources("video"))) &&
           (!g_advancedSettings.m_bVideoLibraryHideEmptySeries || movie.m_iEpisode > 0))
@@ -6332,7 +6333,7 @@ bool CVideoDatabase::GetEpisodesByWhere(const CStdString& strBaseDir, const Filt
       const dbiplus::sql_record* const record = data.at(targetRow);
 
       CVideoInfoTag movie = GetDetailsForEpisode(record);
-      if (g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE ||
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE ||
           g_passwordManager.bMasterUser                                     ||
           g_passwordManager.IsDatabasePathUnlocked(movie.m_strPath, *CMediaSourceSettings::Get().GetSources("video")))
       {
@@ -6765,7 +6766,7 @@ void CVideoDatabase::GetMovieGenresByName(const CStdString& strSearch, CFileItem
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL=PrepareSQL("select genre.idGenre,genre.strGenre,path.strPath from genre,genrelinkmovie,movie,path,files where genre.idGenre=genrelinkmovie.idGenre and genrelinkmovie.idMovie=movie.idMovie and files.idFile=movie.idFile and path.idPath=files.idPath and genre.strGenre like '%%%s%%'",strSearch.c_str());
     else
       strSQL=PrepareSQL("select distinct genre.idGenre,genre.strGenre from genre,genrelinkmovie where genrelinkmovie.idGenre=genre.idGenre and strGenre like '%%%s%%'", strSearch.c_str());
@@ -6773,7 +6774,7 @@ void CVideoDatabase::GetMovieGenresByName(const CStdString& strSearch, CFileItem
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),
                                                       *CMediaSourceSettings::Get().GetSources("video")))
         {
@@ -6806,7 +6807,7 @@ void CVideoDatabase::GetMovieCountriesByName(const CStdString& strSearch, CFileI
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL=PrepareSQL("select country.idCountry,country.strCountry,path.strPath from country,countrylinkmovie,movie,path,files where country.idCountry=countrylinkmovie.idCountry and countrylinkmovie.idMovie=movie.idMovie and files.idFile=movie.idFile and path.idPath=files.idPath and country.strCountry like '%%%s%%'",strSearch.c_str());
     else
       strSQL=PrepareSQL("select distinct country.idCountry,country.strCountry from country,countrylinkmovie where countrylinkmovie.idCountry=country.idCountry and strCountry like '%%%s%%'", strSearch.c_str());
@@ -6814,7 +6815,7 @@ void CVideoDatabase::GetMovieCountriesByName(const CStdString& strSearch, CFileI
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),
                                                       *CMediaSourceSettings::Get().GetSources("video")))
         {
@@ -6847,7 +6848,7 @@ void CVideoDatabase::GetTvShowGenresByName(const CStdString& strSearch, CFileIte
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL=PrepareSQL("select genre.idGenre,genre.strGenre,path.strPath from genre,genrelinktvshow,tvshow,path,tvshowlinkpath where genre.idGenre=genrelinktvshow.idGenre and genrelinktvshow.idShow=tvshow.idShow and path.idPath=tvshowlinkpath.idPath and tvshowlinkpath.idShow=tvshow.idShow and genre.strGenre like '%%%s%%'",strSearch.c_str());
     else
       strSQL=PrepareSQL("select distinct genre.idGenre,genre.strGenre from genre,genrelinktvshow where genrelinktvshow.idGenre=genre.idGenre and strGenre like '%%%s%%'", strSearch.c_str());
@@ -6855,7 +6856,7 @@ void CVideoDatabase::GetTvShowGenresByName(const CStdString& strSearch, CFileIte
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
@@ -6887,7 +6888,7 @@ void CVideoDatabase::GetMovieActorsByName(const CStdString& strSearch, CFileItem
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL=PrepareSQL("select actors.idActor,actors.strActor,path.strPath from actorlinkmovie,actors,movie,files,path where actors.idActor=actorlinkmovie.idActor and actorlinkmovie.idMovie=movie.idMovie and files.idFile=movie.idFile and files.idPath=path.idPath and actors.strActor like '%%%s%%'",strSearch.c_str());
     else
       strSQL=PrepareSQL("select distinct actors.idActor,actors.strActor from actorlinkmovie,actors,movie where actors.idActor=actorlinkmovie.idActor and actorlinkmovie.idMovie=movie.idMovie and actors.strActor like '%%%s%%'",strSearch.c_str());
@@ -6895,7 +6896,7 @@ void CVideoDatabase::GetMovieActorsByName(const CStdString& strSearch, CFileItem
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
@@ -6927,7 +6928,7 @@ void CVideoDatabase::GetTvShowsActorsByName(const CStdString& strSearch, CFileIt
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL=PrepareSQL("select actors.idActor,actors.strActor,path.strPath from actorlinktvshow,actors,tvshow,path,tvshowlinkpath where actors.idActor=actorlinktvshow.idActor and actorlinktvshow.idShow=tvshow.idShow and tvshowlinkpath.idPath=tvshow.idShow and tvshowlinkpath.idPath=path.idPath and actors.strActor like '%%%s%%'",strSearch.c_str());
     else
       strSQL=PrepareSQL("select distinct actors.idActor,actors.strActor from actorlinktvshow,actors,tvshow where actors.idActor=actorlinktvshow.idActor and actorlinktvshow.idShow=tvshow.idShow and actors.strActor like '%%%s%%'",strSearch.c_str());
@@ -6935,7 +6936,7 @@ void CVideoDatabase::GetTvShowsActorsByName(const CStdString& strSearch, CFileIt
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
@@ -6970,7 +6971,7 @@ void CVideoDatabase::GetMusicVideoArtistsByName(const CStdString& strSearch, CFi
     CStdString strLike;
     if (!strSearch.IsEmpty())
       strLike = "and actors.strActor like '%%%s%%'";
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL=PrepareSQL("select actors.idActor,actors.strActor,path.strPath from artistlinkmusicvideo,actors,musicvideo,files,path where actors.idActor=artistlinkmusicvideo.idArtist and artistlinkmusicvideo.idMVideo=musicvideo.idMVideo and files.idFile=musicvideo.idFile and files.idPath=path.idPath "+strLike,strSearch.c_str());
     else
       strSQL=PrepareSQL("select distinct actors.idActor,actors.strActor from artistlinkmusicvideo,actors where actors.idActor=artistlinkmusicvideo.idArtist "+strLike,strSearch.c_str());
@@ -6978,7 +6979,7 @@ void CVideoDatabase::GetMusicVideoArtistsByName(const CStdString& strSearch, CFi
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
@@ -7010,7 +7011,7 @@ void CVideoDatabase::GetMusicVideoGenresByName(const CStdString& strSearch, CFil
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL=PrepareSQL("select genre.idGenre,genre.strGenre,path.strPath from genre,genrelinkmusicvideo,musicvideo,path,files where genre.idGenre=genrelinkmusicvideo.idGenre and genrelinkmusicvideo.idMVideo = musicvideo.idMVideo and files.idFile=musicvideo.idFile and path.idPath=files.idPath and genre.strGenre like '%%%s%%'",strSearch.c_str());
     else
       strSQL=PrepareSQL("select distinct genre.idGenre,genre.strGenre from genre,genrelinkmusicvideo where genrelinkmusicvideo.idGenre=genre.idGenre and genre.strGenre like '%%%s%%'", strSearch.c_str());
@@ -7018,7 +7019,7 @@ void CVideoDatabase::GetMusicVideoGenresByName(const CStdString& strSearch, CFil
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
@@ -7056,7 +7057,7 @@ void CVideoDatabase::GetMusicVideoAlbumsByName(const CStdString& strSearch, CFil
       strLike.Format("and musicvideo.c%02d",VIDEODB_ID_MUSICVIDEO_ALBUM);
       strLike += "like '%%s%%%'";
     }
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL=PrepareSQL("select distinct musicvideo.c%02d,musicvideo.idMVideo,path.strPath from musicvideo,files,path where files.idFile=musicvideo.idFile and files.idPath=path.idPath"+strLike,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str());
     else
     {
@@ -7074,7 +7075,7 @@ void CVideoDatabase::GetMusicVideoAlbumsByName(const CStdString& strSearch, CFil
         continue;
       }
 
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
@@ -7106,7 +7107,7 @@ void CVideoDatabase::GetMusicVideosByAlbum(const CStdString& strSearch, CFileIte
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL = PrepareSQL("select musicvideo.idMVideo,musicvideo.c%02d,musicvideo.c%02d,path.strPath from musicvideo,files,path where files.idFile=musicvideo.idFile and files.idPath=path.idPath and musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_ALBUM,VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str());
     else
       strSQL = PrepareSQL("select musicvideo.idMVideo,musicvideo.c%02d,musicvideo.c%02d from musicvideo where musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_ALBUM,VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str());
@@ -7114,7 +7115,7 @@ void CVideoDatabase::GetMusicVideosByAlbum(const CStdString& strSearch, CFileIte
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
@@ -7193,7 +7194,7 @@ bool CVideoDatabase::GetMusicVideosByWhere(const CStdString &baseDir, const Filt
       const dbiplus::sql_record* const record = data.at(targetRow);
       
       CVideoInfoTag musicvideo = GetDetailsForMusicVideo(record);
-      if (!checkLocks || g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE || g_passwordManager.bMasterUser ||
+      if (!checkLocks || CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE || g_passwordManager.bMasterUser ||
           g_passwordManager.IsDatabasePathUnlocked(musicvideo.m_strPath, *CMediaSourceSettings::Get().GetSources("video")))
       {
         CFileItemPtr item(new CFileItem(musicvideo));
@@ -7297,14 +7298,14 @@ int CVideoDatabase::GetMatchingMusicVideo(const CStdString& strArtist, const CSt
     CStdString strSQL;
     if (strAlbum.IsEmpty() && strTitle.IsEmpty())
     { // we want to return matching artists only
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         strSQL=PrepareSQL("select distinct actors.idActor,path.strPath from artistlinkmusicvideo,actors,musicvideo,files,path where actors.idActor=artistlinkmusicvideo.idArtist and artistlinkmusicvideo.idMVideo=musicvideo.idMVideo and files.idFile=musicvideo.idFile and files.idPath=path.idPath and actors.strActor like '%s'",strArtist.c_str());
       else
         strSQL=PrepareSQL("select distinct actors.idActor from artistlinkmusicvideo,actors where actors.idActor=artistlinkmusicvideo.idArtist and actors.strActor like '%s'",strArtist.c_str());
     }
     else
     { // we want to return the matching musicvideo
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         strSQL = PrepareSQL("select musicvideo.idMVideo from musicvideo,files,path,artistlinkmusicvideo,actors where files.idFile=musicvideo.idFile and files.idPath=path.idPath and musicvideo.%c02d like '%s' and musicvideo.%c02d like '%s' and artistlinkmusicvideo.idMVideo=musicvideo.idMVideo and artistlinkmusicvideo.idArtist=actors.idActors and actors.strActor like '%s'",VIDEODB_ID_MUSICVIDEO_ALBUM,strAlbum.c_str(),VIDEODB_ID_MUSICVIDEO_TITLE,strTitle.c_str(),strArtist.c_str());
       else
         strSQL = PrepareSQL("select musicvideo.idMVideo from musicvideo join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo=musicvideo.idMVideo join actors on actors.idActor=artistlinkmusicvideo.idArtist where musicvideo.c%02d like '%s' and musicvideo.c%02d like '%s' and actors.strActor like '%s'",VIDEODB_ID_MUSICVIDEO_ALBUM,strAlbum.c_str(),VIDEODB_ID_MUSICVIDEO_TITLE,strTitle.c_str(),strArtist.c_str());
@@ -7314,7 +7315,7 @@ int CVideoDatabase::GetMatchingMusicVideo(const CStdString& strArtist, const CSt
     if (m_pDS->eof())
       return -1;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
       {
         m_pDS->close();
@@ -7341,7 +7342,7 @@ void CVideoDatabase::GetMoviesByName(const CStdString& strSearch, CFileItemList&
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL = PrepareSQL("select movie.idMovie,movie.c%02d,path.strPath, movie.idSet from movie,files,path where files.idFile=movie.idFile and files.idPath=path.idPath and movie.c%02d like '%%%s%%'",VIDEODB_ID_TITLE,VIDEODB_ID_TITLE,strSearch.c_str());
     else
       strSQL = PrepareSQL("select movie.idMovie,movie.c%02d, movie.idSet from movie where movie.c%02d like '%%%s%%'",VIDEODB_ID_TITLE,VIDEODB_ID_TITLE,strSearch.c_str());
@@ -7349,7 +7350,7 @@ void CVideoDatabase::GetMoviesByName(const CStdString& strSearch, CFileItemList&
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
@@ -7386,7 +7387,7 @@ void CVideoDatabase::GetTvShowsByName(const CStdString& strSearch, CFileItemList
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL = PrepareSQL("select tvshow.idShow,tvshow.c%02d,path.strPath from tvshow,path,tvshowlinkpath where tvshowlinkpath.idPath=path.idPath and tvshowlinkpath.idShow=tvshow.idShow and tvshow.c%02d like '%%%s%%'",VIDEODB_ID_TV_TITLE,VIDEODB_ID_TV_TITLE,strSearch.c_str());
     else
       strSQL = PrepareSQL("select tvshow.idShow,tvshow.c%02d from tvshow where tvshow.c%02d like '%%%s%%'",VIDEODB_ID_TV_TITLE,VIDEODB_ID_TV_TITLE,strSearch.c_str());
@@ -7394,7 +7395,7 @@ void CVideoDatabase::GetTvShowsByName(const CStdString& strSearch, CFileItemList
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
@@ -7428,7 +7429,7 @@ void CVideoDatabase::GetEpisodesByName(const CStdString& strSearch, CFileItemLis
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL = PrepareSQL("select episode.idEpisode,episode.c%02d,episode.c%02d,episode.idShow,tvshow.c%02d,path.strPath from episode,files,path,tvshow where files.idFile=episode.idFile and episode.idShow=tvshow.idShow and files.idPath=path.idPath and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_TITLE,strSearch.c_str());
     else
       strSQL = PrepareSQL("select episode.idEpisode,episode.c%02d,episode.c%02d,episode.idShow,tvshow.c%02d from episode,tvshow where tvshow.idShow=episode.idShow and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_TITLE,strSearch.c_str());
@@ -7436,7 +7437,7 @@ void CVideoDatabase::GetEpisodesByName(const CStdString& strSearch, CFileItemLis
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
@@ -7471,7 +7472,7 @@ void CVideoDatabase::GetMusicVideosByName(const CStdString& strSearch, CFileItem
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL = PrepareSQL("select musicvideo.idMVideo,musicvideo.c%02d,path.strPath from musicvideo,files,path where files.idFile=musicvideo.idFile and files.idPath=path.idPath and musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_TITLE,strSearch.c_str());
     else
       strSQL = PrepareSQL("select musicvideo.idMVideo,musicvideo.c%02d from musicvideo where musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_TITLE,strSearch.c_str());
@@ -7479,7 +7480,7 @@ void CVideoDatabase::GetMusicVideosByName(const CStdString& strSearch, CFileItem
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
@@ -7519,7 +7520,7 @@ void CVideoDatabase::GetEpisodesByPlot(const CStdString& strSearch, CFileItemLis
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL = PrepareSQL("select episode.idEpisode,episode.c%02d,episode.c%02d,episode.idShow,tvshow.c%02d,path.strPath from episode,files,path,tvshow where files.idFile=episode.idFile and files.idPath=path.idPath and tvshow.idShow=episode.idShow and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_PLOT,strSearch.c_str());
     else
       strSQL = PrepareSQL("select episode.idEpisode,episode.c%02d,episode.c%02d,episode.idShow,tvshow.c%02d from episode,tvshow where tvshow.idShow=episode.idShow and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_PLOT,strSearch.c_str());
@@ -7527,7 +7528,7 @@ void CVideoDatabase::GetEpisodesByPlot(const CStdString& strSearch, CFileItemLis
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
@@ -7558,7 +7559,7 @@ void CVideoDatabase::GetMoviesByPlot(const CStdString& strSearch, CFileItemList&
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL = PrepareSQL("select movie.idMovie, movie.c%02d, path.strPath from movie,files,path where files.idFile=movie.idFile and files.idPath=path.idPath and (movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%')",VIDEODB_ID_TITLE,VIDEODB_ID_PLOT,strSearch.c_str(),VIDEODB_ID_PLOTOUTLINE,strSearch.c_str(),VIDEODB_ID_TAGLINE,strSearch.c_str());
     else
       strSQL = PrepareSQL("select movie.idMovie, movie.c%02d from movie where (movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%')",VIDEODB_ID_TITLE,VIDEODB_ID_PLOT,strSearch.c_str(),VIDEODB_ID_PLOTOUTLINE,strSearch.c_str(),VIDEODB_ID_TAGLINE,strSearch.c_str());
@@ -7567,7 +7568,7 @@ void CVideoDatabase::GetMoviesByPlot(const CStdString& strSearch, CFileItemList&
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv(2).get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
@@ -7600,7 +7601,7 @@ void CVideoDatabase::GetMovieDirectorsByName(const CStdString& strSearch, CFileI
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL = PrepareSQL("select distinct directorlinkmovie.idDirector,actors.strActor,path.strPath from movie,files,path,actors,directorlinkmovie where files.idFile=movie.idFile and files.idPath=path.idPath and directorlinkmovie.idMovie=movie.idMovie and directorlinkmovie.idDirector=actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
     else
       strSQL = PrepareSQL("select distinct directorlinkmovie.idDirector,actors.strActor from movie,actors,directorlinkmovie where directorlinkmovie.idMovie=movie.idMovie and directorlinkmovie.idDirector=actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
@@ -7609,7 +7610,7 @@ void CVideoDatabase::GetMovieDirectorsByName(const CStdString& strSearch, CFileI
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
@@ -7642,7 +7643,7 @@ void CVideoDatabase::GetTvShowsDirectorsByName(const CStdString& strSearch, CFil
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL = PrepareSQL("select distinct directorlinktvshow.idDirector,actors.strActor,path.strPath from tvshow,path,actors,directorlinktvshow,tvshowlinkpath where tvshowlinkpath.idPath=path.idPath and tvshowlinkpath.idShow=tvshow.idShow and directorlinktvshow.idShow=tvshow.idShow and directorlinktvshow.idDirector=actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
     else
       strSQL = PrepareSQL("select distinct directorlinktvshow.idDirector,actors.strActor from tvshow,actors,directorlinktvshow where directorlinktvshow.idShow=tvshow.idShow and directorlinktvshow.idDirector=actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
@@ -7651,7 +7652,7 @@ void CVideoDatabase::GetTvShowsDirectorsByName(const CStdString& strSearch, CFil
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
@@ -7684,7 +7685,7 @@ void CVideoDatabase::GetMusicVideoDirectorsByName(const CStdString& strSearch, C
     if (NULL == m_pDB.get()) return;
     if (NULL == m_pDS.get()) return;
 
-    if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+    if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
       strSQL = PrepareSQL("select distinct directorlinkmusicvideo.idDirector,actors.strActor,path.strPath from musicvideo,files,path,actors,directorlinkmusicvideo where files.idFile=musicvideo.idFile and files.idPath=path.idPath and directorlinkmusicvideo.idMVideo=musicvideo.idMVideo and directorlinkmusicvideo.idDirector=actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
     else
       strSQL = PrepareSQL("select distinct directorlinkmusicvideo.idDirector,actors.strActor from musicvideo,actors,directorlinkmusicvideo where directorlinkmusicvideo.idMVideo=musicvideo.idMVideo and directorlinkmusicvideo.idDirector=actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
@@ -7693,7 +7694,7 @@ void CVideoDatabase::GetMusicVideoDirectorsByName(const CStdString& strSearch, C
 
     while (!m_pDS->eof())
     {
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
         if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video")))
         {
           m_pDS->next();
index 7b93964..535b979 100644 (file)
@@ -31,6 +31,7 @@
 #include "URL.h"
 #include "FileItem.h"
 #include "addons/Skin.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/AdvancedSettings.h"
 #include "settings/Settings.h"
 #include "settings/GUISettings.h"
@@ -352,8 +353,8 @@ void CGUIDialogAudioSubtitleSettings::OnSettingChanged(SettingInfo &setting)
   }
   else if (setting.id == AUDIO_SETTINGS_MAKE_DEFAULT)
   {
-    if (g_settings.GetCurrentProfile().settingsLocked() &&
-        g_settings.GetMasterProfile().getLockMode() != ::LOCK_MODE_EVERYONE)
+    if (CProfilesManager::Get().GetCurrentProfile().settingsLocked() &&
+        CProfilesManager::Get().GetMasterProfile().getLockMode() != ::LOCK_MODE_EVERYONE)
       if (!g_passwordManager.IsMasterLockUnlocked(true))
         return;
 
index 99d698e..560ecd8 100644 (file)
@@ -29,6 +29,7 @@
 #include "pictures/Picture.h"
 #include "dialogs/GUIDialogContextMenu.h"
 #include "view/ViewState.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/Settings.h"
 #include "settings/AdvancedSettings.h"
 #include "FileItem.h"
@@ -274,7 +275,7 @@ void CGUIDialogVideoBookmarks::AddBookmark(CVideoInfoTag* tag)
         Crc32 crc;
         crc.ComputeFromLowerCase(g_application.CurrentFile());
         bookmark.thumbNailImage.Format("%08x_%i.jpg", (unsigned __int32) crc, m_vecItems->Size() + 1);
-        bookmark.thumbNailImage = URIUtils::AddFileToFolder(g_settings.GetBookmarksThumbFolder(), bookmark.thumbNailImage);
+        bookmark.thumbNailImage = URIUtils::AddFileToFolder(CProfilesManager::Get().GetBookmarksThumbFolder(), bookmark.thumbNailImage);
         if (!CPicture::CreateThumbnailFromSurface(thumbnail->GetPixels(), width, height, thumbnail->GetWidth() * 4,
                                             bookmark.thumbNailImage))
           bookmark.thumbNailImage.Empty();
index 633dc69..88ecf50 100644 (file)
@@ -39,6 +39,7 @@
 #include "FileItem.h"
 #include "storage/MediaManager.h"
 #include "utils/AsyncFileCopy.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/Settings.h"
 #include "settings/AdvancedSettings.h"
 #include "settings/GUISettings.h"
@@ -209,12 +210,12 @@ void CGUIDialogVideoInfo::OnInitWindow()
     database.Close();
   }
 
-  CONTROL_ENABLE_ON_CONDITION(CONTROL_BTN_REFRESH, (g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !m_movieItem->GetVideoInfoTag()->m_strIMDBNumber.Left(2).Equals("xx") && scraper);
-  CONTROL_ENABLE_ON_CONDITION(CONTROL_BTN_GET_THUMB, (g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !m_movieItem->GetVideoInfoTag()->m_strIMDBNumber.Mid(2).Equals("plugin"));
+  CONTROL_ENABLE_ON_CONDITION(CONTROL_BTN_REFRESH, (CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !m_movieItem->GetVideoInfoTag()->m_strIMDBNumber.Left(2).Equals("xx") && scraper);
+  CONTROL_ENABLE_ON_CONDITION(CONTROL_BTN_GET_THUMB, (CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !m_movieItem->GetVideoInfoTag()->m_strIMDBNumber.Mid(2).Equals("plugin"));
 
   VIDEODB_CONTENT_TYPE type = (VIDEODB_CONTENT_TYPE)m_movieItem->GetVideoContentType();
   if (type == VIDEODB_CONTENT_TVSHOWS || type == VIDEODB_CONTENT_MOVIES)
-    CONTROL_ENABLE_ON_CONDITION(CONTROL_BTN_GET_FANART, (g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !m_movieItem->GetVideoInfoTag()->m_strIMDBNumber.Mid(2).Equals("plugin"));
+    CONTROL_ENABLE_ON_CONDITION(CONTROL_BTN_GET_FANART, (CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !m_movieItem->GetVideoInfoTag()->m_strIMDBNumber.Mid(2).Equals("plugin"));
   else
     CONTROL_DISABLE(CONTROL_BTN_GET_FANART);
 
index ae73489..c90bf49 100644 (file)
@@ -29,6 +29,7 @@
 #endif
 #include "video/VideoDatabase.h"
 #include "dialogs/GUIDialogYesNo.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/Settings.h"
 #include "settings/MediaSettings.h"
 #include "addons/Skin.h"
@@ -222,14 +223,14 @@ void CGUIDialogVideoSettings::OnSettingChanged(SettingInfo &setting)
   if (setting.id == VIDEO_SETTINGS_CALIBRATION)
   {
     // launch calibration window
-    if (g_settings.GetCurrentProfile().settingsLocked() && g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
+    if (CProfilesManager::Get().GetCurrentProfile().settingsLocked() && CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
       if (!g_passwordManager.IsMasterLockUnlocked(true))
         return;
     g_windowManager.ActivateWindow(WINDOW_SCREEN_CALIBRATION);
   }
   else if (setting.id == VIDEO_SETTINGS_MAKE_DEFAULT)
   {
-    if (g_settings.GetCurrentProfile().settingsLocked() && g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
+    if (CProfilesManager::Get().GetCurrentProfile().settingsLocked() && CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
       if (!g_passwordManager.IsMasterLockUnlocked(true))
         return;
 
index 9030a7b..181187b 100644 (file)
@@ -52,6 +52,7 @@
 #include "guilib/GUIKeyboardFactory.h"
 #include "filesystem/Directory.h"
 #include "playlists/PlayList.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/Settings.h"
 #include "settings/AdvancedSettings.h"
 #include "settings/GUISettings.h"
@@ -218,7 +219,7 @@ bool CGUIWindowVideoBase::OnMessage(CGUIMessage& message)
         else if (iAction == ACTION_DELETE_ITEM)
         {
           // is delete allowed?
-          if (g_settings.GetCurrentProfile().canWriteDatabases())
+          if (CProfilesManager::Get().GetCurrentProfile().canWriteDatabases())
           {
             // must be at the title window
             if (GetID() == WINDOW_VIDEO_NAV)
@@ -469,7 +470,7 @@ bool CGUIWindowVideoBase::ShowIMDB(CFileItem *item, const ScraperPtr &info2)
   }
 
   // quietly return if Internet lookups are disabled
-  if (!g_settings.GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
+  if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
     return false;
 
   if(!info)
@@ -1637,8 +1638,8 @@ void CGUIWindowVideoBase::OnDeleteItem(CFileItemPtr item)
   // HACK: stacked files need to be treated as folders in order to be deleted
   if (item->IsStack())
     item->m_bIsFolder = true;
-  if (g_settings.GetCurrentProfile().getLockMode() != LOCK_MODE_EVERYONE &&
-      g_settings.GetCurrentProfile().filesLocked())
+  if (CProfilesManager::Get().GetCurrentProfile().getLockMode() != LOCK_MODE_EVERYONE &&
+      CProfilesManager::Get().GetCurrentProfile().filesLocked())
   {
     if (!g_passwordManager.IsMasterLockUnlocked(true))
       return;
@@ -1652,7 +1653,7 @@ void CGUIWindowVideoBase::OnDeleteItem(CFileItemPtr item)
 
 void CGUIWindowVideoBase::MarkWatched(const CFileItemPtr &item, bool bMark)
 {
-  if (!g_settings.GetCurrentProfile().canWriteDatabases())
+  if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases())
     return;
   // dont allow update while scanning
   if (g_application.IsVideoScanning())
@@ -1841,7 +1842,7 @@ bool CGUIWindowVideoBase::GetDirectory(const CStdString &strDirectory, CFileItem
   // add in the "New Playlist" item if we're in the playlists folder
   if ((items.GetPath() == "special://videoplaylists/") && !items.Contains("newplaylist://"))
   {
-    CFileItemPtr newPlaylist(new CFileItem(g_settings.GetUserDataItem("PartyMode-Video.xsp"),false));
+    CFileItemPtr newPlaylist(new CFileItem(CProfilesManager::Get().GetUserDataItem("PartyMode-Video.xsp"),false));
     newPlaylist->SetLabel(g_localizeStrings.Get(16035));
     newPlaylist->SetLabelPreformated(true);
     newPlaylist->m_bIsFolder = true;
index 50981c5..55db374 100644 (file)
@@ -41,6 +41,7 @@
 #include "FileItem.h"
 #include "Application.h"
 #include "ApplicationMessenger.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/Settings.h"
 #include "settings/AdvancedSettings.h"
 #include "settings/GUISettings.h"
@@ -871,7 +872,7 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt
     if (g_application.IsVideoScanning())
       buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353);  // Stop Scanning
     if (!item->IsDVD() && item->GetPath() != "add" && !item->IsParentFolder() &&
-        (g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser))
+        (CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser))
     {
       CVideoDatabase database;
       database.Open();
@@ -939,7 +940,7 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt
         buttons.Add(CONTEXT_BUTTON_INFO, 13346);
 
       // can we update the database?
-      if (g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser)
+      if (CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser)
       {
         if (node == NODE_TYPE_TITLE_TVSHOWS)
         {
index 864e448..39b02db 100644 (file)
@@ -24,6 +24,7 @@
 #include "music/GUIViewStateMusic.h"
 #include "video/GUIViewStateVideo.h"
 #include "pictures/GUIViewStatePictures.h"
+#include "profiles/ProfilesManager.h"
 #include "programs/GUIViewStatePrograms.h"
 #include "PlayListPlayer.h"
 #include "utils/URIUtils.h"
@@ -312,7 +313,7 @@ bool CGUIViewState::HideParentDirItems()
 
 bool CGUIViewState::DisableAddSourceButtons()
 {
-  if (g_settings.GetCurrentProfile().canWriteSources() || g_passwordManager.bMasterUser)
+  if (CProfilesManager::Get().GetCurrentProfile().canWriteSources() || g_passwordManager.bMasterUser)
     return !g_guiSettings.GetBool("filelists.showaddsourcebuttons");
 
   return true;
index c3fb28f..0c2ff5d 100644 (file)
@@ -38,6 +38,7 @@
 #include "Favourites.h"
 #include "utils/LabelFormatter.h"
 #include "dialogs/GUIDialogProgress.h"
+#include "profiles/ProfilesManager.h"
 #include "settings/AdvancedSettings.h"
 #include "settings/GUISettings.h"
 #include "URL.h"
@@ -1019,7 +1020,7 @@ bool CGUIMediaWindow::OnClick(int iItem)
     if ( pItem->m_bIsShareOrDrive )
     {
       const CStdString& strLockType=m_guiState->GetLockType();
-      if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
+      if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
         if (!strLockType.IsEmpty() && !g_passwordManager.IsItemUnlocked(pItem.get(), strLockType))
             return true;
 
@@ -1028,8 +1029,8 @@ bool CGUIMediaWindow::OnClick(int iItem)
     }
 
     // check for the partymode playlist items - they may not exist yet
-    if ((pItem->GetPath() == g_settings.GetUserDataItem("PartyMode.xsp")) ||
-        (pItem->GetPath() == g_settings.GetUserDataItem("PartyMode-Video.xsp")))
+    if ((pItem->GetPath() == CProfilesManager::Get().GetUserDataItem("PartyMode.xsp")) ||
+        (pItem->GetPath() == CProfilesManager::Get().GetUserDataItem("PartyMode-Video.xsp")))
     {
       // party mode playlist item - if it doesn't exist, prompt for user to define it
       if (!XFILE::CFile::Exists(pItem->GetPath()))
@@ -1473,7 +1474,7 @@ void CGUIMediaWindow::OnDeleteItem(int iItem)
   if (item->IsPlayList())
     item->m_bIsFolder = false;
 
-  if (g_settings.GetCurrentProfile().getLockMode() != LOCK_MODE_EVERYONE && g_settings.GetCurrentProfile().filesLocked())
+  if (CProfilesManager::Get().GetCurrentProfile().getLockMode() != LOCK_MODE_EVERYONE && CProfilesManager::Get().GetCurrentProfile().filesLocked())
     if (!g_passwordManager.IsMasterLockUnlocked(true))
       return;
 
@@ -1487,7 +1488,7 @@ void CGUIMediaWindow::OnRenameItem(int iItem)
 {
   if ( iItem < 0 || iItem >= m_vecItems->Size()) return;
 
-  if (g_settings.GetCurrentProfile().getLockMode() != LOCK_MODE_EVERYONE && g_settings.GetCurrentProfile().filesLocked())
+  if (CProfilesManager::Get().GetCurrentProfile().getLockMode() != LOCK_MODE_EVERYONE && CProfilesManager::Get().GetCurrentProfile().filesLocked())
     if (!g_passwordManager.IsMasterLockUnlocked(true))
       return;
 
index 3e2eb3a..d6c472b 100644 (file)
@@ -23,6 +23,7 @@
 #include "ApplicationMessenger.h"
 #include "GUIWindowLoginScreen.h"
 #include "profiles/Profile.h"
+#include "profiles/ProfilesManager.h"
 #include "profiles/dialogs/GUIDialogProfileSettings.h"
 #include "profiles/windows/GUIWindowSettingsProfile.h"
 #include "dialogs/GUIDialogContextMenu.h"
@@ -160,14 +161,14 @@ void CGUIWindowLoginScreen::FrameMove()
     if (m_viewControl.HasControl(CONTROL_BIG_LIST))
       m_iSelectedItem = m_viewControl.GetSelectedItem();
   CStdString strLabel;
-  strLabel.Format(g_localizeStrings.Get(20114),m_iSelectedItem+1,g_settings.GetNumProfiles());
+  strLabel.Format(g_localizeStrings.Get(20114),m_iSelectedItem+1, CProfilesManager::Get().GetNumberOfProfiles());
   SET_CONTROL_LABEL(CONTROL_LABEL_SELECTED_PROFILE,strLabel);
   CGUIWindow::FrameMove();
 }
 
 void CGUIWindowLoginScreen::OnInitWindow()
 {
-  m_iSelectedItem = (int)g_settings.GetLastUsedProfileIndex();
+  m_iSelectedItem = (int)CProfilesManager::Get().GetLastUsedProfileIndex();
   // Update list/thumb control
   m_viewControl.SetCurrentView(DEFAULT_VIEW_LIST);
   Update();
@@ -195,9 +196,9 @@ void CGUIWindowLoginScreen::OnWindowUnload()
 void CGUIWindowLoginScreen::Update()
 {
   m_vecItems->Clear();
-  for (unsigned int i=0;i<g_settings.GetNumProfiles(); ++i)
+  for (unsigned int i=0;i<CProfilesManager::Get().GetNumberOfProfiles(); ++i)
   {
-    const CProfile *profile = g_settings.GetProfile(i);
+    const CProfile *profile = CProfilesManager::Get().GetProfile(i);
     CFileItemPtr item(new CFileItem(profile->getName()));
     CStdString strLabel;
     if (profile->getDate().IsEmpty())
@@ -233,7 +234,7 @@ bool CGUIWindowLoginScreen::OnPopupMenu(int iItem)
   int choice = CGUIDialogContextMenu::ShowAndGetChoice(choices);
   if (choice == 3)
   {
-    if (g_passwordManager.CheckLock(g_settings.GetMasterProfile().getLockMode(),g_settings.GetMasterProfile().getLockCode(),20075))
+    if (g_passwordManager.CheckLock(CProfilesManager::Get().GetMasterProfile().getLockMode(),CProfilesManager::Get().GetMasterProfile().getLockCode(),20075))
       g_passwordManager.iMasterLockRetriesLeft = g_guiSettings.GetInt("masterlock.maxretries");
     else // be inconvenient
       CApplicationMessenger::Get().Shutdown();
@@ -250,12 +251,12 @@ bool CGUIWindowLoginScreen::OnPopupMenu(int iItem)
   {
     int iDelete = m_viewControl.GetSelectedItem();
     m_viewControl.Clear();
-    g_settings.DeleteProfile(iDelete);
+    CProfilesManager::Get().DeleteProfile(iDelete);
     Update();
     m_viewControl.SetSelectedItem(0);
   }
   //NOTE: this can potentially (de)select the wrong item if the filelisting has changed because of an action above.
-  if (iItem < (int)g_settings.GetNumProfiles())
+  if (iItem < (int)CProfilesManager::Get().GetNumberOfProfiles())
     m_vecItems->Get(iItem)->Select(bSelect);
 
   return (choice > 0);
@@ -279,10 +280,10 @@ void CGUIWindowLoginScreen::LoadProfile(unsigned int profile)
   // stop PVR related services
   g_application.StopPVRManager();
 
-  if (profile != 0 || !g_settings.IsMasterUser())
+  if (profile != 0 || !CProfilesManager::Get().IsMasterProfile())
   {
     g_application.getNetwork().NetworkMessage(CNetwork::SERVICES_DOWN,1);
-    g_settings.LoadProfile(profile);
+    CProfilesManager::Get().LoadProfile(profile);
   }
   else
   {
@@ -292,10 +293,10 @@ void CGUIWindowLoginScreen::LoadProfile(unsigned int profile)
   }
   g_application.getNetwork().NetworkMessage(CNetwork::SERVICES_UP,1);
 
-  g_settings.UpdateCurrentProfileDate();
-  g_settings.SaveProfiles(PROFILES_FILE);
+  CProfilesManager::Get().UpdateCurrentProfileDate();
+  CProfilesManager::Get().Save();
 
-  if (g_settings.GetLastUsedProfileIndex() != profile)
+  if (CProfilesManager::Get().GetLastUsedProfileIndex() != profile)
   {
     g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO);
     g_playlistPlayer.ClearPlaylist(PLAYLIST_MUSIC);