#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"
// Init our DllLoaders emu env
init_emu_environ();
- g_settings.LoadProfiles(PROFILES_FILE);
+ CProfilesManager::Get().Load();
CLog::Log(LOGNOTICE, "-----------------------------------------------------------------------");
#if defined(TARGET_DARWIN_OSX)
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());
}
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
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
{
CLog::Log(LOGINFO, "removing tempfiles");
CUtil::RemoveTempFiles();
- if (!g_settings.UsingLoginScreen())
+ if (!CProfilesManager::Get().UsingLoginScreen())
{
UpdateLibraries();
#ifdef HAS_PYTHON
#ifdef HAS_UPNP
g_settings.UnregisterSettingsHandler(&CUPnPSettings::Get());
#endif
+ g_settings.UnregisterSettingsHandler(&CProfilesManager::Get());
g_settings.UnregisterSettingsHandler(this);
#ifdef _LINUX
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();
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)
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;
#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"
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();
}
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
#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"
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
rootNode->InsertEndChild(favNode);
}
- URIUtils::AddFileToFolder(g_settings.GetProfileUserDataFolder(), "favourites.xml", favourites);
+ URIUtils::AddFileToFolder(CProfilesManager::Get().GetProfileUserDataFolder(), "favourites.xml", favourites);
return doc.SaveFile(favourites);
}
#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"
}
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");
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)
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)
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;
#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"
// \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)
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;
bool CGUIPassword::SetMasterLockMode(bool bDetails)
{
- CProfile* profile = g_settings.GetProfile(0);
+ CProfile* profile = CProfilesManager::Get().GetProfile(0);
if (profile)
{
CProfile::CLock locks = profile->GetLocks();
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;
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
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);
}
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)
// 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);
{
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;
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;
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
#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"
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);
*/
#include "PasswordManager.h"
+#include "profiles/ProfilesManager.h"
#include "profiles/dialogs/GUIDialogLockSettings.h"
#include "URL.h"
#include "settings/Settings.h"
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;
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
#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"
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;
}
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)
#ifdef HAS_UPNP
#include "filesystem/UPnPDirectory.h"
#endif
+#include "profiles/ProfilesManager.h"
#include "utils/RegExp.h"
#include "settings/GUISettings.h"
#include "guilib/TextureManager.h"
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;
#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"
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 */
#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"
{
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
#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"
// 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)
{
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);
// 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);
switch (button)
{
case CONTEXT_BUTTON_EDIT_SOURCE:
- if (g_settings.IsMasterUser())
+ if (CProfilesManager::Get().IsMasterProfile())
{
if (!g_passwordManager.IsMasterLockUnlocked(true))
return false;
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
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;
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;
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;
#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"
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://");
#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"
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;
#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"
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() + "/");
#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"
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",
#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"
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);
#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"
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"))
#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"
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
#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"
}
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);
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
#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"
}
// 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);
#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"
{
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))
{
#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 ;
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;
{
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;
}
}
#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"
}
// 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)
#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"
// 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());
#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"
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
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
// 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;
// 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;
#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"
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);
#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"
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
#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"
// 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);
}
!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);
}
#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"
// 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
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());
SRCS=Profile.cpp \
+ ProfilesManager.cpp \
LIB=profiles.a
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+#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;
+};
#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"
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)
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);
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);
{
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
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
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;
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;
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"));
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);
profile->setSources((dialog->m_iSourcesMode & 2) == 2);
profile->SetLocks(dialog->m_locks);
- g_settings.SaveProfiles(PROFILES_FILE);
+ CProfilesManager::Get().Save();
return true;
}
#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"
void CGUIWindowSettingsProfile::OnPopupMenu(int iItem)
{
- if (iItem == (int)g_settings.GetNumProfiles())
+ if (iItem == (int)CProfilesManager::Get().GetNumberOfProfiles())
return;
// popup the context menu
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--;
}
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))
{
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);
}
else if (iControl == CONTROL_LOGINSCREEN)
{
- g_settings.ToggleLoginScreen();
- g_settings.SaveProfiles(PROFILES_FILE);
+ CProfilesManager::Get().ToggleLoginScreen();
+ CProfilesManager::Get().Save();
return true;
}
}
{
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());
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);
}
#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"
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;
#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"
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;
#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"
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;
}
#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"
#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"
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);
}
*
*/
-#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;
m_userAgent = g_sysinfo.GetUserAgent();
- m_usingLoginScreen = false;
- m_lastUsedProfile = 0;
- m_currentProfile = 0;
- m_nextIdProfile = 0;
-
m_musicNeedsUpdate = 0;
m_videoNeedsUpdate = 0;
}
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()
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;
else // save the global settings
g_guiSettings.SaveXML(pRoot);
- // For mastercode
- SaveProfiles( PROFILES_FILE );
-
OnSettingsSaved();
if (!Save(pRoot))
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();
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);
*
*/
+#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;
void Clear();
- bool LoadProfile(unsigned int index);
- bool DeleteProfile(unsigned int index);
- void CreateProfileFolders();
-
CStdString m_pictureExtensions;
CStdString m_musicExtensions;
CStdString m_videoExtensions;
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);
bool LoadSettings(const CStdString& strSettingsFile);
// bool SaveSettings(const CStdString& strSettingsFile) const;
- void LoadUserFolderLayout();
-
private:
// implementation of ISettingsHandler
virtual bool OnSettingsLoading();
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;
#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"
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)
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"))
{
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))
}
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))
#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"
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)
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)
// 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)
#include "RssManager.h"
#include "filesystem/File.h"
+#include "profiles/ProfilesManager.h"
#include "settings/Settings.h"
#include "threads/SingleLock.h"
#include "utils/log.h"
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;
#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"
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)
{
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;
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");
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;
// 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)
{
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;
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)
{
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;
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;
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")))
{
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))
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")))
{
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());
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")))
{
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());
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")))
{
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());
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();
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());
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();
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());
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();
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());
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();
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());
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();
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
{
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();
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());
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();
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));
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());
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();
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());
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();
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());
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();
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());
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();
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());
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();
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());
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();
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());
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();
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());
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();
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());
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();
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());
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();
#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"
}
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;
#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"
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();
#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"
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);
#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"
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;
#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"
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)
}
// 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)
// 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;
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())
// 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;
#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"
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();
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)
{
#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"
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;
#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"
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;
}
// 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()))
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;
{
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;
#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"
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();
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())
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();
{
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);
// 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
{
}
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);