3 * Copyright (C) 2005-2008 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, write to
18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19 * http://www.gnu.org/copyleft/gpl.html
23 #define PRE_SKIN_VERSION_9_10_COMPATIBILITY 1
24 #define PRE_SKIN_VERSION_11_COMPATIBILITY 1
26 #if defined(HAS_SKIN_TOUCHED) && defined(TARGET_DARWIN_IOS) && !defined(TARGET_DARWIN_IOS_ATV2)
27 #define DEFAULT_SKIN "skin.touched"
29 #define DEFAULT_SKIN "skin.confluence"
31 #define DEFAULT_FANART_HEIGHT 0
32 #define DEFAULT_WEATHER_ADDON "weather.xbmc.builtin"
33 #define DEFAULT_WEB_INTERFACE "webinterface.default"
35 #define DEFAULT_VSYNC VSYNC_DISABLED
36 #define DEFAULT_THUMB_SIZE 256
38 #if defined(__APPLE__) || defined(_WIN32)
39 #define DEFAULT_VSYNC VSYNC_ALWAYS
41 #define DEFAULT_VSYNC VSYNC_DRIVER
43 #define DEFAULT_THUMB_SIZE 512
46 #include "settings/VideoSettings.h"
48 #include "ViewState.h"
49 #include "guilib/Resolution.h"
50 #include "guilib/GraphicContext.h"
59 #define VOLUME_MINIMUM -6000 // -60dB
60 #define VOLUME_MAXIMUM 0 // 0dB
61 #define VOLUME_DRC_MINIMUM 0 // 0dB
62 #define VOLUME_DRC_MAXIMUM 3000 // 30dB
64 #define VIEW_MODE_NORMAL 0
65 #define VIEW_MODE_ZOOM 1
66 #define VIEW_MODE_STRETCH_4x3 2
67 #define VIEW_MODE_WIDE_ZOOM 3
68 #define VIEW_MODE_STRETCH_16x9 4
69 #define VIEW_MODE_ORIGINAL 5
70 #define VIEW_MODE_CUSTOM 6
72 #define VIDEO_SHOW_ALL 0
73 #define VIDEO_SHOW_UNWATCHED 1
74 #define VIDEO_SHOW_WATCHED 2
76 /* FIXME: eventually the profile should dictate where special://masterprofile/ is but for now it
77 makes sense to leave all the profile settings in a user writeable location
78 like special://masterprofile/ */
79 #define PROFILES_FILE "special://masterprofile/profiles.xml"
91 CSkinBool() : value(false) {};
105 virtual ~CSettings(void);
115 bool LoadProfile(unsigned int index);
116 bool DeleteProfile(unsigned int index);
117 void CreateProfileFolders();
119 VECSOURCES *GetSourcesFromType(const CStdString &type);
120 CStdString GetDefaultSourceFromType(const CStdString &type);
122 bool UpdateSource(const CStdString &strType, const CStdString strOldName, const CStdString &strUpdateChild, const CStdString &strUpdateValue);
123 bool DeleteSource(const CStdString &strType, const CStdString strName, const CStdString strPath, bool virtualSource = false);
124 bool UpdateShare(const CStdString &type, const CStdString oldName, const CMediaSource &share);
125 bool AddShare(const CStdString &type, const CMediaSource &share);
127 int TranslateSkinString(const CStdString &setting);
128 const CStdString &GetSkinString(int setting) const;
129 void SetSkinString(int setting, const CStdString &label);
131 int TranslateSkinBool(const CStdString &setting);
132 bool GetSkinBool(int setting) const;
133 void SetSkinBool(int setting, bool set);
135 /*! \brief Retreive the watched mode for the given content type
136 \param content Current content type
137 \return the current watch mode for this content type, WATCH_MODE_ALL if the content type is unknown.
138 \sa SetWatchMode, IncrementWatchMode
140 int GetWatchMode(const CStdString& content) const;
142 /*! \brief Set the watched mode for the given content type
143 \param content Current content type
144 \param value Watched mode to set
145 \sa GetWatchMode, IncrementWatchMode
147 void SetWatchMode(const CStdString& content, int value);
149 /*! \brief Cycle the watched mode for the given content type
150 \param content Current content type
151 \sa GetWatchMode, SetWatchMode
153 void CycleWatchMode(const CStdString& content);
155 void ResetSkinSetting(const CStdString &setting);
156 void ResetSkinSettings();
158 CStdString m_pictureExtensions;
159 CStdString m_musicExtensions;
160 CStdString m_videoExtensions;
161 CStdString m_discStubExtensions;
163 CStdString m_logFolder;
165 CStdString m_activeKeyboardMapping;
167 bool m_bMyMusicSongInfoInVis;
168 bool m_bMyMusicSongThumbInVis;
170 CViewState m_viewStateMusicNavArtists;
171 CViewState m_viewStateMusicNavAlbums;
172 CViewState m_viewStateMusicNavSongs;
173 CViewState m_viewStateMusicLastFM;
174 CViewState m_viewStateVideoNavActors;
175 CViewState m_viewStateVideoNavYears;
176 CViewState m_viewStateVideoNavGenres;
177 CViewState m_viewStateVideoNavTitles;
178 CViewState m_viewStateVideoNavEpisodes;
179 CViewState m_viewStateVideoNavSeasons;
180 CViewState m_viewStateVideoNavTvShows;
181 CViewState m_viewStateVideoNavMusicVideos;
183 CViewState m_viewStatePrograms;
184 CViewState m_viewStatePictures;
185 CViewState m_viewStateMusicFiles;
186 CViewState m_viewStateVideoFiles;
188 bool m_bMyMusicPlaylistRepeat;
189 bool m_bMyMusicPlaylistShuffle;
190 int m_iMyMusicStartWindow;
193 bool m_bMyMusicIsScanning;
195 CVideoSettings m_defaultVideoSettings;
196 CVideoSettings m_currentVideoSettings;
198 float m_fZoomAmount; // current zoom amount
199 float m_fPixelRatio; // current pixel ratio
200 float m_fVerticalShift; // current vertical shift
201 bool m_bNonLinStretch; // current non-linear stretch
203 bool m_bMyVideoPlaylistRepeat;
204 bool m_bMyVideoPlaylistShuffle;
205 bool m_bMyVideoNavFlatten;
206 bool m_bStartVideoWindowed;
207 bool m_bAddonAutoUpdate;
208 bool m_bAddonNotifications;
210 int m_iVideoStartWindow;
212 bool m_videoStacking;
214 int iAdditionalSubtitleDirectoryChecked;
216 int m_HttpApiBroadcastPort;
217 int m_HttpApiBroadcastLevel;
218 int m_nVolumeLevel; // measured in milliBels -60dB -> 0dB range.
219 int m_dynamicRangeCompressionLevel; // measured in milliBels 0dB -> 30dB range.
220 int m_iPreMuteVolumeLevel; // save the m_nVolumeLevel for proper restore
222 int m_iSystemTimeTotalUp; // Uptime in minutes!
224 CStdString m_userAgent;
229 std::vector<int> interval;
230 std::vector<std::string> url;
233 std::map<int,RssSet> m_mapRssUrls;
234 std::map<int, CSkinString> m_skinStrings;
235 std::map<int, CSkinBool> m_skinBools;
237 VECSOURCES m_programSources;
238 VECSOURCES m_pictureSources;
239 VECSOURCES m_fileSources;
240 VECSOURCES m_musicSources;
241 VECSOURCES m_videoSources;
243 CStdString m_defaultProgramSource;
244 CStdString m_defaultMusicSource;
245 CStdString m_defaultPictureSource;
246 CStdString m_defaultFileSource;
247 CStdString m_defaultMusicLibSource;
249 CStdString m_UPnPUUIDServer;
250 int m_UPnPPortServer;
251 int m_UPnPMaxReturnedItems;
252 CStdString m_UPnPUUIDRenderer;
253 int m_UPnPPortRenderer;
255 /*! \brief Retrieve the master profile
256 \return const reference to the master profile
258 const CProfile &GetMasterProfile() const;
260 /*! \brief Retreive the current profile
261 \return const reference to the current profile
263 const CProfile &GetCurrentProfile() const;
265 /*! \brief Retreive the profile from an index
266 \param unsigned index of the profile to retrieve
267 \return const pointer to the profile, NULL if the index is invalid
269 const CProfile *GetProfile(unsigned int index) const;
271 /*! \brief Retreive the profile from an index
272 \param unsigned index of the profile to retrieve
273 \return pointer to the profile, NULL if the index is invalid
275 CProfile *GetProfile(unsigned int index);
277 /*! \brief Retreive index of a particular profile by name
278 \param name name of the profile index to retrieve
279 \return index of this profile, -1 if invalid.
281 int GetProfileIndex(const CStdString &name) const;
283 /*! \brief Retrieve the number of profiles
284 \return number of profiles
286 unsigned int GetNumProfiles() const;
288 /*! \brief Add a new profile
289 \param profile CProfile to add
291 void AddProfile(const CProfile &profile);
293 /*! \brief Are we using the login screen?
294 \return true if we're using the login screen, false otherwise
296 bool UsingLoginScreen() const { return m_usingLoginScreen; };
298 /*! \brief Toggle login screen use on and off
299 Toggles the login screen state
301 void ToggleLoginScreen() { m_usingLoginScreen = !m_usingLoginScreen; };
303 /*! \brief Are we the master user?
304 \return true if the current profile is the master user, false otherwise
306 bool IsMasterUser() const { return 0 == m_currentProfile; };
308 /*! \brief Update the date of the current profile
310 void UpdateCurrentProfileDate();
312 /*! \brief Load the master user for the purposes of logging in
313 Loads the master user. Identical to LoadProfile(0) but doesn't update the last logged in details
315 void LoadMasterForLogin();
317 /*! \brief Retreive the last used profile index
318 \return the last used profile that logged in. Does not count the master user during login.
320 unsigned int GetLastUsedProfileIndex() const { return m_lastUsedProfile; };
322 /*! \brief Retrieve the current profile index
323 \return the index of the currently logged in profile.
325 unsigned int GetCurrentProfileIndex() const { return m_currentProfile; };
327 /*! \brief Retrieve the next id to use for a new profile
328 \return the unique <id> to be used when creating a new profile
330 int GetNextProfileId() const { return m_nextIdProfile; }; // used to get the value of m_nextIdProfile for use in new profile creation
332 int GetCurrentProfileId() const;
334 std::vector<RESOLUTION_INFO> m_ResInfo;
336 // utility functions for user data folders
338 //uses HasSlashAtEnd to determine if a directory or file was meant
339 CStdString GetUserDataItem(const CStdString& strFile) const;
340 CStdString GetProfileUserDataFolder() const;
341 CStdString GetUserDataFolder() const;
342 CStdString GetDatabaseFolder() const;
343 CStdString GetCDDBFolder() const;
344 CStdString GetThumbnailsFolder() const;
345 CStdString GetMusicThumbFolder() const;
346 CStdString GetLastFMThumbFolder() const;
347 CStdString GetMusicArtistThumbFolder() const;
348 CStdString GetVideoThumbFolder() const;
349 CStdString GetBookmarksThumbFolder() const;
350 CStdString GetSourcesFile() const;
351 CStdString GetVideoFanartFolder() const;
352 CStdString GetMusicFanartFolder() const;
354 CStdString GetSettingsFile() const;
356 bool LoadUPnPXml(const CStdString& strSettingsFile);
357 bool SaveUPnPXml(const CStdString& strSettingsFile) const;
359 /*! \brief Load the user profile information from disk
360 Loads the profiles.xml file and creates the list of profiles. If no profiles
361 exist, a master user is created. Should be called after special://masterprofile/
363 \param profilesFile XML file to load.
365 void LoadProfiles(const CStdString& profilesFile);
367 /*! \brief Save the user profile information to disk
368 Saves the list of profiles to the profiles.xml file.
369 \param profilesFile XML file to save.
370 \return true on success, false on failure to save
372 bool SaveProfiles(const CStdString& profilesFile) const;
374 bool SaveSettings(const CStdString& strSettingsFile, CGUISettings *localSettings = NULL) const;
380 bool GetInteger(const TiXmlElement* pRootElement, const char *strTagName, int& iValue, const int iDefault, const int iMin, const int iMax);
381 bool GetFloat(const TiXmlElement* pRootElement, const char *strTagName, float& fValue, const float fDefault, const float fMin, const float fMax);
382 static bool GetPath(const TiXmlElement* pRootElement, const char *tagName, CStdString &strValue);
383 static bool GetString(const TiXmlElement* pRootElement, const char *strTagName, CStdString& strValue, const CStdString& strDefaultValue);
384 bool GetString(const TiXmlElement* pRootElement, const char *strTagName, char *szValue, const CStdString& strDefaultValue);
385 bool GetSource(const CStdString &category, const TiXmlNode *source, CMediaSource &share);
387 void GetSources(const TiXmlElement* pRootElement, const CStdString& strTagName, VECSOURCES& items, CStdString& strDefault);
388 bool SetSources(TiXmlNode *root, const char *section, const VECSOURCES &shares, const char *defaultPath);
389 void GetViewState(const TiXmlElement* pRootElement, const CStdString& strTagName, CViewState &viewState, SORT_METHOD defaultSort = SORT_METHOD_LABEL, int defaultView = DEFAULT_VIEW_LIST);
391 // functions for writing xml files
392 void SetViewState(TiXmlNode* pRootNode, const CStdString& strTagName, const CViewState &viewState) const;
394 bool LoadCalibration(const TiXmlElement* pElement, const CStdString& strSettingsFile);
395 bool SaveCalibration(TiXmlNode* pRootNode) const;
397 bool LoadSettings(const CStdString& strSettingsFile);
398 // bool SaveSettings(const CStdString& strSettingsFile) const;
400 bool LoadPlayerCoreFactorySettings(const CStdString& fileStr, bool clear);
402 // skin activated settings
403 void LoadSkinSettings(const TiXmlElement* pElement);
404 void SaveSkinSettings(TiXmlNode *pElement) const;
406 void LoadUserFolderLayout();
409 std::vector<CProfile> m_vecProfiles;
410 std::map<CStdString, int> m_watchMode;
411 bool m_usingLoginScreen;
412 unsigned int m_lastUsedProfile;
413 unsigned int m_currentProfile;
414 int m_nextIdProfile; // for tracking the next available id to give to a new profile to ensure id's are not re-used
417 extern class CSettings g_settings;